diff --git a/src/Envelope.cpp b/src/Envelope.cpp index 3ce97819f..3d563c6e5 100644 --- a/src/Envelope.cpp +++ b/src/Envelope.cpp @@ -186,7 +186,7 @@ static void DrawPoint(wxDC & dc, const wxRect & r, int x, int y, bool top) /// TODO: This should probably move to track artist. void Envelope::DrawPoints(wxDC & dc, const wxRect & r, const ZoomInfo &zoomInfo, bool dB, double dBRange, - float zoomMin, float zoomMax) + float zoomMin, float zoomMax) const { dc.SetPen(AColor::envelopePen); dc.SetBrush(*wxWHITE_BRUSH); @@ -1151,7 +1151,7 @@ void Envelope::GetValues buffer[xx] = GetValue(zoomInfo.PositionToTime(xx, -leftOffset)); } -int Envelope::NumberOfPointsAfter(double t) +int Envelope::NumberOfPointsAfter(double t) const { if( t >= mEnv[mEnv.size()-1].GetT() ) return 0; @@ -1169,7 +1169,7 @@ int Envelope::NumberOfPointsAfter(double t) } } -double Envelope::NextPointAfter(double t) +double Envelope::NextPointAfter(double t) const { if( mEnv[mEnv.size()-1].GetT() < t ) return t; @@ -1186,7 +1186,7 @@ double Envelope::NextPointAfter(double t) } } -double Envelope::Average( double t0, double t1 ) +double Envelope::Average( double t0, double t1 ) const { if( t0 == t1 ) return GetValue( t0 ); @@ -1194,7 +1194,7 @@ double Envelope::Average( double t0, double t1 ) return Integral( t0, t1 ) / (t1 - t0); } -double Envelope::AverageOfInverse( double t0, double t1 ) +double Envelope::AverageOfInverse( double t0, double t1 ) const { if( t0 == t1 ) return 1.0 / GetValue( t0 ); @@ -1285,7 +1285,7 @@ static double SolveIntegrateInverseInterpolated(double y1, double y2, double tim // We should be able to write a very efficient memoizer for this // but make sure it gets reset when the envelope is changed. -double Envelope::Integral( double t0, double t1 ) +double Envelope::Integral( double t0, double t1 ) const { if(t0 == t1) return 0.0; @@ -1345,7 +1345,7 @@ double Envelope::Integral( double t0, double t1 ) } } -double Envelope::IntegralOfInverse( double t0, double t1 ) +double Envelope::IntegralOfInverse( double t0, double t1 ) const { if(t0 == t1) return 0.0; @@ -1405,7 +1405,7 @@ double Envelope::IntegralOfInverse( double t0, double t1 ) } } -double Envelope::SolveIntegralOfInverse( double t0, double area ) +double Envelope::SolveIntegralOfInverse( double t0, double area ) const { if(area == 0.0) return t0; @@ -1503,7 +1503,7 @@ double Envelope::SolveIntegralOfInverse( double t0, double area ) } } -void Envelope::print() +void Envelope::print() const { for( unsigned int i = 0; i < mEnv.size(); i++ ) printf( "(%.2f, %.2f)\n", mEnv[i].GetT(), mEnv[i].GetVal() ); diff --git a/src/Envelope.h b/src/Envelope.h index e3816087a..1e8c017d2 100644 --- a/src/Envelope.h +++ b/src/Envelope.h @@ -108,7 +108,7 @@ class Envelope final : public XMLTagHandler { void DrawPoints(wxDC & dc, const wxRect & r, const ZoomInfo &zoomInfo, bool dB, double dBRange, - float zoomMin, float zoomMax); + float zoomMin, float zoomMax) const; // Event Handlers // Each ofthese returns true if parents needs to be redrawn @@ -149,16 +149,16 @@ class Envelope final : public XMLTagHandler { void GetValues (double *buffer, int bufferLen, int leftOffset, const ZoomInfo &zoomInfo) const; - int NumberOfPointsAfter(double t); - double NextPointAfter(double t); + int NumberOfPointsAfter(double t) const; + double NextPointAfter(double t) const; - double Average( double t0, double t1 ); - double AverageOfInverse( double t0, double t1 ); - double Integral( double t0, double t1 ); - double IntegralOfInverse( double t0, double t1 ); - double SolveIntegralOfInverse( double t0, double area); + double Average( double t0, double t1 ) const; + double AverageOfInverse( double t0, double t1 ) const; + double Integral( double t0, double t1 ) const; + double IntegralOfInverse( double t0, double t1 ) const; + double SolveIntegralOfInverse( double t0, double area) const; - void print(); + void print() const; void testMe(); bool IsDirty() const; diff --git a/src/LabelTrack.cpp b/src/LabelTrack.cpp index 25ced4d3c..0dcb42e60 100644 --- a/src/LabelTrack.cpp +++ b/src/LabelTrack.cpp @@ -315,7 +315,7 @@ void LabelTrack::ResetFont() /// take priority over the ones earlier, so because centering /// is the first thing we do, it's the first thing we lose if /// we can't do everything we want to. -void LabelTrack::ComputeTextPosition(const wxRect & r, int index) +void LabelTrack::ComputeTextPosition(const wxRect & r, int index) const { // xExtra is extra space // between the text and the endpoints. @@ -457,7 +457,7 @@ void LabelTrack::ComputeTextPosition(const wxRect & r, int index) /// ComputeLayout determines which row each label /// should be placed on, and reserves space for it. /// Function assumes that the labels are sorted. -void LabelTrack::ComputeLayout(const wxRect & r, const ZoomInfo &zoomInfo) +void LabelTrack::ComputeLayout(const wxRect & r, const ZoomInfo &zoomInfo) const { int i; int iRow; @@ -710,7 +710,7 @@ void LabelStruct::DrawHighlight( wxDC & dc, int xPos1, int xPos2, int charHeight dc.DrawRectangle(xPos2-1, y-charHeight/2, xPos1-xPos2+1, charHeight); } -void LabelStruct::getXPos( wxDC & dc, int * xPos1, int cursorPos) +void LabelStruct::getXPos( wxDC & dc, int * xPos1, int cursorPos) const { *xPos1 = xText; if( cursorPos > 0) @@ -744,7 +744,7 @@ bool LabelTrack::CalcCursorX(wxWindow * parent, int * x) /// @param r the LabelTrack rectangle. void LabelTrack::Draw(wxDC & dc, const wxRect & r, const SelectedRegion &selectedRegion, - const ZoomInfo &zoomInfo) + const ZoomInfo &zoomInfo) const { if(msFont.Ok()) dc.SetFont(msFont); @@ -881,7 +881,7 @@ void LabelTrack::Draw(wxDC & dc, const wxRect & r, /// Set the cursor position according to x position of mouse /// uses GetTextExtent to find the character position /// corresponding to the x pixel position. -void LabelTrack::SetCurrentCursorPosition(wxDC & dc, int xPos) +void LabelTrack::SetCurrentCursorPosition(wxDC & dc, int xPos) const { // A bool indicator to see if set the cursor position or not bool finished = false; @@ -925,7 +925,7 @@ void LabelTrack::SetCurrentCursorPosition(wxDC & dc, int xPos) } } -void LabelTrack::calculateFontHeight(wxDC & dc) +void LabelTrack::calculateFontHeight(wxDC & dc) const { int charDescent; int charLeading; diff --git a/src/LabelTrack.h b/src/LabelTrack.h index 35e836148..3df894c8d 100644 --- a/src/LabelTrack.h +++ b/src/LabelTrack.h @@ -56,7 +56,7 @@ public: void DrawText( wxDC & dc, const wxRect & r); void DrawTextBox( wxDC & dc, const wxRect & r); void DrawHighlight( wxDC & dc, int xPos1, int xPos2, int charHeight); - void getXPos( wxDC & dc, int * xPos1, int cursorPos); + void getXPos( wxDC & dc, int * xPos1, int cursorPos) const; const SelectedRegion &getSelectedRegion() const { return selectedRegion; } double getDuration() const { return selectedRegion.duration(); } double getT0() const { return selectedRegion.t0(); } @@ -128,7 +128,7 @@ class AUDACITY_DLL_API LabelTrack final : public Track void Draw(wxDC & dc, const wxRect & r, const SelectedRegion &selectedRegion, - const ZoomInfo &zoomInfo); + const ZoomInfo &zoomInfo) const; int getSelectedIndex() const { return mSelIndex; } bool IsAdjustingLabel() const { return mIsAdjustingLabel; } @@ -258,29 +258,29 @@ class AUDACITY_DLL_API LabelTrack final : public Track static bool mbGlyphsReady; static wxBitmap mBoundaryGlyphs[NUM_GLYPH_CONFIGS * NUM_GLYPH_HIGHLIGHTS]; - int xUsed[MAX_NUM_ROWS]; + mutable int xUsed[MAX_NUM_ROWS]; static int mFontHeight; - int mXPos1; /// left X pos of highlighted area - int mXPos2; /// right X pos of highlighted area - int mCurrentCursorPos; /// current cursor position - int mInitialCursorPos; /// initial cursor position - double mMouseXPos; /// mouse X pos + mutable int mXPos1; /// left X pos of highlighted area + mutable int mXPos2; /// right X pos of highlighted area + mutable int mCurrentCursorPos; /// current cursor position + mutable int mInitialCursorPos; /// initial cursor position + mutable double mMouseXPos; /// mouse X pos int mDragXPos; /// end X pos of dragging bool mInBox; /// flag to tell if the mouse is in text box - bool mResetCursorPos; /// flag to reset cursor position(used in the dragging the glygh) + mutable bool mResetCursorPos; /// flag to reset cursor position(used in the dragging the glygh) bool mRightDragging; /// flag to tell if it's a valid dragging - bool mDrawCursor; /// flag to tell if drawing the cursor or not + mutable bool mDrawCursor; /// flag to tell if drawing the cursor or not int mRestoreFocus; /// Restore focus to this track when done editing // Set in copied label tracks double mClipLen; - void ComputeLayout(const wxRect & r, const ZoomInfo &zoomInfo); - void ComputeTextPosition(const wxRect & r, int index); - void SetCurrentCursorPosition(wxDC & dc, int xPos); + void ComputeLayout(const wxRect & r, const ZoomInfo &zoomInfo) const; + void ComputeTextPosition(const wxRect & r, int index) const; + void SetCurrentCursorPosition(wxDC & dc, int xPos) const; - void calculateFontHeight(wxDC & dc); + void calculateFontHeight(wxDC & dc) const; void RemoveSelectedText(); bool mIsAdjustingLabel; diff --git a/src/NoteTrack.h b/src/NoteTrack.h index e848bb529..23da96a05 100644 --- a/src/NoteTrack.h +++ b/src/NoteTrack.h @@ -116,7 +116,7 @@ class AUDACITY_DLL_API NoteTrack final : public Track { // call this once before a series of calls to IPitchToY(). It // sets mBottom to offset of octave 0 so that mBottomNote // is located at r.y + r.height - (GetNoteMargin() + 1 + mPitchHeight) - void PrepareIPitchToY(const wxRect &r) { + void PrepareIPitchToY(const wxRect &r) const { mBottom = r.y + r.height - GetNoteMargin() - 1 - mPitchHeight + (mBottomNote / 12) * GetOctaveHeight() + GetNotePos(mBottomNote % 12); @@ -197,7 +197,7 @@ class AUDACITY_DLL_API NoteTrack final : public Track { // mSeq variable. (TrackArtist should check to make sure this // flip-flop from mSeq to mSerializationBuffer happened an // even number of times, otherwise mSeq will be NULL). - char *mSerializationBuffer; // NULL means no buffer + mutable char *mSerializationBuffer; // NULL means no buffer long mSerializationLength; DirManager *mDirManager; @@ -207,7 +207,7 @@ class AUDACITY_DLL_API NoteTrack final : public Track { #endif // mBottom is the Y offset of pitch 0 (normally off screen) - int mBottom; + mutable int mBottom; int mBottomNote; int mStartBottomNote; int mPitchHeight; diff --git a/src/TimeTrack.cpp b/src/TimeTrack.cpp index ab8bb1b8c..ce1dbb0e1 100644 --- a/src/TimeTrack.cpp +++ b/src/TimeTrack.cpp @@ -124,17 +124,17 @@ void TimeTrack::SetInterpolateLog(bool interpolateLog) { } //Compute the (average) warp factor between two non-warped time points -double TimeTrack::ComputeWarpFactor(double t0, double t1) +double TimeTrack::ComputeWarpFactor(double t0, double t1) const { return GetEnvelope()->AverageOfInverse(t0, t1); } -double TimeTrack::ComputeWarpedLength(double t0, double t1) +double TimeTrack::ComputeWarpedLength(double t0, double t1) const { return GetEnvelope()->IntegralOfInverse(t0, t1); } -double TimeTrack::SolveWarpedLength(double t0, double length) +double TimeTrack::SolveWarpedLength(double t0, double length) const { return GetEnvelope()->SolveIntegralOfInverse(t0, length); } @@ -229,7 +229,7 @@ void TimeTrack::WriteXML(XMLWriter &xmlFile) xmlFile.EndTag(wxT("timetrack")); } -void TimeTrack::Draw(wxDC & dc, const wxRect & r, const ZoomInfo &zoomInfo) +void TimeTrack::Draw(wxDC & dc, const wxRect & r, const ZoomInfo &zoomInfo) const { double min = zoomInfo.PositionToTime(0); double max = zoomInfo.PositionToTime(r.width); diff --git a/src/TimeTrack.h b/src/TimeTrack.h index 88e0bb8ae..506b434b2 100644 --- a/src/TimeTrack.h +++ b/src/TimeTrack.h @@ -50,7 +50,7 @@ class TimeTrack final : public Track { double GetStartTime() const override { return 0.0; } double GetEndTime() const override { return 0.0; } - void Draw(wxDC & dc, const wxRect & r, const ZoomInfo &zoomInfo); + void Draw(wxDC & dc, const wxRect & r, const ZoomInfo &zoomInfo) const; // XMLTagHandler callback methods for loading and saving @@ -68,6 +68,7 @@ class TimeTrack final : public Track { // Access the track's speed envelope Envelope *GetEnvelope() { return mEnvelope; } + const Envelope *GetEnvelope() const { return mEnvelope; } //Note: The meaning of this function has changed (December 2012) //Previously this function did something that was close to the opposite (but not entirely accurate). @@ -81,7 +82,7 @@ class TimeTrack final : public Track { * @param t1 The ending time to calculate to * @return The relative length increase of the chosen segment from the original sound. */ - double ComputeWarpFactor(double t0, double t1); + double ComputeWarpFactor(double t0, double t1) const; /** @brief Compute the duration (in seconds at playback) of the specified region of the track. * * Takes a region of the time track (specified by the unwarped time points in the project), and @@ -91,7 +92,7 @@ class TimeTrack final : public Track { * @param t1 unwarped time to stop calculation at * @return the warped duration in seconds */ - double ComputeWarpedLength(double t0, double t1); + double ComputeWarpedLength(double t0, double t1) const; /** @brief Compute how much unwarped time must have elapsed if length seconds of warped time has * elapsed * @@ -99,7 +100,7 @@ class TimeTrack final : public Track { * @param length How many seconds of warped time went past. * @return The end point (in seconds from project start) as unwarped time */ - double SolveWarpedLength(double t0, double length); + double SolveWarpedLength(double t0, double length) const; // Get/Set the speed-warping range, as percentage of original speed (e.g. 90%-110%) diff --git a/src/TrackArtist.cpp b/src/TrackArtist.cpp index b8c8d0961..6bb47a5c5 100644 --- a/src/TrackArtist.cpp +++ b/src/TrackArtist.cpp @@ -1306,7 +1306,7 @@ void TrackArtist::DrawMinMaxRMS(wxDC &dc, const wxRect & rect, const double env[ void TrackArtist::DrawIndividualSamples(wxDC &dc, int leftOffset, const wxRect &rect, float zoomMin, float zoomMax, bool dB, float dBRange, - WaveClip *clip, + const WaveClip *clip, const ZoomInfo &zoomInfo, bool bigPoints, bool showPoints, bool muted) { @@ -1457,7 +1457,7 @@ void TrackArtist::DrawEnvLine(wxDC &dc, const wxRect &rect, int x0, int y0, int } } -void TrackArtist::DrawWaveform(WaveTrack *track, +void TrackArtist::DrawWaveform(const WaveTrack *track, wxDC & dc, const wxRect & rect, const SelectedRegion &selectedRegion, @@ -1472,7 +1472,8 @@ void TrackArtist::DrawWaveform(WaveTrack *track, DrawBackgroundWithSelection(&dc, rect, track, blankSelectedBrush, blankBrush, selectedRegion, zoomInfo); - for (WaveClipList::compatibility_iterator it = track->GetClipIterator(); it; it = it->GetNext()) + for (WaveClipList::compatibility_iterator it = + const_cast(track)->GetClipIterator(); it; it = it->GetNext()) DrawClipWaveform(track, it->GetData(), dc, rect, selectedRegion, zoomInfo, drawEnvelope, bigPoints, dB, muted); @@ -1718,8 +1719,8 @@ void FindWavePortions } } -void TrackArtist::DrawClipWaveform(WaveTrack *track, - WaveClip *clip, +void TrackArtist::DrawClipWaveform(const WaveTrack *track, + const WaveClip *clip, wxDC & dc, const wxRect & rect, const SelectedRegion &selectedRegion, @@ -2001,7 +2002,7 @@ void TrackArtist::DrawTimeSlider(wxDC & dc, } -void TrackArtist::DrawSpectrum(WaveTrack *track, +void TrackArtist::DrawSpectrum(const WaveTrack *track, wxDC & dc, const wxRect & rect, const SelectedRegion &selectedRegion, @@ -2011,7 +2012,8 @@ void TrackArtist::DrawSpectrum(WaveTrack *track, selectedRegion, zoomInfo); WaveTrackCache cache(track); - for (WaveClipList::compatibility_iterator it = track->GetClipIterator(); it; it = it->GetNext()) { + for (WaveClipList::compatibility_iterator it = + const_cast(track)->GetClipIterator(); it; it = it->GetNext()) { DrawClipSpectrum(cache, it->GetData(), dc, rect, selectedRegion, zoomInfo); } } @@ -2099,7 +2101,7 @@ AColor::ColorGradientChoice ChooseColorSet( float bin0, float bin1, float selBin void TrackArtist::DrawClipSpectrum(WaveTrackCache &waveTrackCache, - WaveClip *clip, + const WaveClip *clip, wxDC & dc, const wxRect & rect, const SelectedRegion &selectedRegion, @@ -2669,7 +2671,7 @@ int PitchToY(double p, int bottom) sel is equal to rect, and the entire region is drawn with unselected background colors. */ -void TrackArtist::DrawNoteBackground(NoteTrack *track, wxDC &dc, +void TrackArtist::DrawNoteBackground(const NoteTrack *track, wxDC &dc, const wxRect &rect, const wxRect &sel, const ZoomInfo &zoomInfo, const wxBrush &wb, const wxPen &wp, @@ -2763,7 +2765,7 @@ graphics. Since there may be notes outside of the display region, reserve a half-note-height margin at the top and bottom of the window and draw out-of-bounds notes here instead. */ -void TrackArtist::DrawNoteTrack(NoteTrack *track, +void TrackArtist::DrawNoteTrack(const NoteTrack *track, wxDC & dc, const wxRect & rect, const SelectedRegion &selectedRegion, @@ -2786,7 +2788,7 @@ void TrackArtist::DrawNoteTrack(NoteTrack *track, Alg_track_ptr alg_track = Alg_seq::unserialize(track->mSerializationBuffer, track->mSerializationLength); assert(alg_track->get_type() == 's'); - track->mSeq = seq = (Alg_seq_ptr) alg_track; + const_cast(track)->mSeq = seq = (Alg_seq_ptr) alg_track; free(track->mSerializationBuffer); track->mSerializationBuffer = NULL; } @@ -3133,7 +3135,7 @@ void TrackArtist::DrawNoteTrack(NoteTrack *track, #endif // USE_MIDI -void TrackArtist::DrawLabelTrack(LabelTrack *track, +void TrackArtist::DrawLabelTrack(const LabelTrack *track, wxDC & dc, const wxRect & rect, const SelectedRegion &selectedRegion, @@ -3148,7 +3150,7 @@ void TrackArtist::DrawLabelTrack(LabelTrack *track, track->Draw(dc, rect, SelectedRegion(sel0, sel1), zoomInfo); } -void TrackArtist::DrawTimeTrack(TimeTrack *track, +void TrackArtist::DrawTimeTrack(const TimeTrack *track, wxDC & dc, const wxRect & rect, const ZoomInfo &zoomInfo) @@ -3293,7 +3295,7 @@ void TrackArtist::DrawSyncLockTiles(wxDC *dc, wxRect rect) } void TrackArtist::DrawBackgroundWithSelection(wxDC *dc, const wxRect &rect, - Track *track, wxBrush &selBrush, wxBrush &unselBrush, + const Track *track, wxBrush &selBrush, wxBrush &unselBrush, const SelectedRegion &selectedRegion, const ZoomInfo &zoomInfo) { //MM: Draw background. We should optimize that a bit more. diff --git a/src/TrackArtist.h b/src/TrackArtist.h index 6fd98a2b6..e7dc920ad 100644 --- a/src/TrackArtist.h +++ b/src/TrackArtist.h @@ -84,7 +84,7 @@ class AUDACITY_DLL_API TrackArtist { // Helper: draws background with selection rect static void DrawBackgroundWithSelection(wxDC *dc, const wxRect &rect, - Track *track, wxBrush &selBrush, wxBrush &unselBrush, + const Track *track, wxBrush &selBrush, wxBrush &unselBrush, const SelectedRegion &selectedRegion, const ZoomInfo &zoomInfo); private: @@ -93,46 +93,46 @@ class AUDACITY_DLL_API TrackArtist { // Lower-level drawing functions // - void DrawWaveform(WaveTrack *track, + void DrawWaveform(const WaveTrack *track, wxDC & dc, const wxRect & rect, const SelectedRegion &selectedRegion, const ZoomInfo &zoomInfo, bool drawEnvelope, bool bigPoints, bool drawSliders, bool muted); - void DrawSpectrum(WaveTrack *track, + void DrawSpectrum(const WaveTrack *track, wxDC & dc, const wxRect & rect, const SelectedRegion &selectedRegion, const ZoomInfo &zoomInfo); #ifdef USE_MIDI int GetBottom(NoteTrack *t, const wxRect &rect); - void DrawNoteBackground(NoteTrack *track, wxDC &dc, + void DrawNoteBackground(const NoteTrack *track, wxDC &dc, const wxRect &rect, const wxRect &sel, const ZoomInfo &zoomInfo, const wxBrush &wb, const wxPen &wp, const wxBrush &bb, const wxPen &bp, const wxPen &mp); - void DrawNoteTrack(NoteTrack *track, + void DrawNoteTrack(const NoteTrack *track, wxDC & dc, const wxRect & rect, const SelectedRegion &selectedRegion, const ZoomInfo &zoomInfo, bool muted); #endif // USE_MIDI - void DrawLabelTrack(LabelTrack *track, + void DrawLabelTrack(const LabelTrack *track, wxDC & dc, const wxRect & rect, const SelectedRegion &selectedRegion, const ZoomInfo &zoomInfo); - void DrawTimeTrack(TimeTrack *track, + void DrawTimeTrack(const TimeTrack *track, wxDC & dc, const wxRect & rect, const ZoomInfo &zoomInfo); void DrawTimeSlider(wxDC & dc, const wxRect & rect, bool rightwards); - void DrawClipWaveform(WaveTrack *track, WaveClip *clip, + void DrawClipWaveform(const WaveTrack *track, const WaveClip *clip, wxDC & dc, const wxRect & rect, const SelectedRegion &selectedRegion, const ZoomInfo &zoomInfo, bool drawEnvelope, bool bigPoints, bool dB, bool muted); - void DrawClipSpectrum(WaveTrackCache &cache, WaveClip *clip, + void DrawClipSpectrum(WaveTrackCache &cache, const WaveClip *clip, wxDC & dc, const wxRect & rect, const SelectedRegion &selectedRegion, const ZoomInfo &zoomInfo); @@ -156,7 +156,7 @@ class AUDACITY_DLL_API TrackArtist { void DrawIndividualSamples(wxDC & dc, int leftOffset, const wxRect & rect, float zoomMin, float zoomMax, bool dB, float dBRange, - WaveClip *clip, + const WaveClip *clip, const ZoomInfo &zoomInfo, bool bigPoints, bool showPoints, bool muted); diff --git a/src/WaveClip.cpp b/src/WaveClip.cpp index fa35e4a2f..e00204dc1 100644 --- a/src/WaveClip.cpp +++ b/src/WaveClip.cpp @@ -502,7 +502,7 @@ fillWhere(std::vector &where, int len, double bias, double correcti // bool WaveClip::GetWaveDisplay(WaveDisplay &display, double t0, - double pixelsPerSecond, bool &isLoadingOD) + double pixelsPerSecond, bool &isLoadingOD) const { const bool allocated = (display.where != 0); @@ -1072,7 +1072,7 @@ void SpecCache::Populate bool WaveClip::GetSpectrogram(WaveTrackCache &waveTrackCache, const float *& spectrogram, const sampleCount *& where, int numPixels, - double t0, double pixelsPerSecond) + double t0, double pixelsPerSecond) const { const WaveTrack *const track = waveTrackCache.GetTrack(); const SpectrogramSettings &settings = track->GetSpectrogramSettings(); @@ -1235,7 +1235,7 @@ void WaveClip::ClearDisplayRect() mDisplayRect.width = mDisplayRect.height = -1; } -void WaveClip::SetDisplayRect(const wxRect& r) +void WaveClip::SetDisplayRect(const wxRect& r) const { mDisplayRect = r; } diff --git a/src/WaveClip.h b/src/WaveClip.h index 599a0e695..bd8024819 100644 --- a/src/WaveClip.h +++ b/src/WaveClip.h @@ -265,6 +265,7 @@ public: sampleCount start, sampleCount len); Envelope* GetEnvelope() { return mEnvelope; } + const Envelope* GetEnvelope() const { return mEnvelope; } BlockArray* GetSequenceBlockArray(); // Get low-level access to the sequence. Whenever possible, don't use this, @@ -283,18 +284,18 @@ public: /** Getting high-level data from the for screen display and clipping * calculations and Contrast */ bool GetWaveDisplay(WaveDisplay &display, - double t0, double pixelsPerSecond, bool &isLoadingOD); + double t0, double pixelsPerSecond, bool &isLoadingOD) const; bool GetSpectrogram(WaveTrackCache &cache, const float *& spectrogram, const sampleCount *& where, int numPixels, - double t0, double pixelsPerSecond); + double t0, double pixelsPerSecond) const; bool GetMinMax(float *min, float *max, double t0, double t1); bool GetRMS(float *rms, double t0, double t1); // Set/clear/get rectangle that this WaveClip fills on screen. This is // called by TrackArtist while actually drawing the tracks and clips. void ClearDisplayRect(); - void SetDisplayRect(const wxRect& r); + void SetDisplayRect(const wxRect& r) const; void GetDisplayRect(wxRect* r); /** Whenever you do an operation to the sequence that will change the number @@ -373,14 +374,14 @@ public: void WriteXML(XMLWriter &xmlFile) /* not override */; // Cache of values to colour pixels of Spectrogram - used by TrackArtist - SpecPxCache *mSpecPxCache; + mutable SpecPxCache *mSpecPxCache; // AWD, Oct 2009: for pasting whitespace at the end of selection bool GetIsPlaceholder() const { return mIsPlaceholder; } void SetIsPlaceholder(bool val) { mIsPlaceholder = val; } protected: - wxRect mDisplayRect; + mutable wxRect mDisplayRect; double mOffset; int mRate; @@ -389,9 +390,9 @@ protected: Sequence *mSequence; Envelope *mEnvelope; - WaveCache *mWaveCache; - ODLock mWaveCacheMutex; - SpecCache *mSpecCache; + mutable WaveCache *mWaveCache; + mutable ODLock mWaveCacheMutex; + mutable SpecCache *mSpecCache; SampleBuffer mAppendBuffer; sampleCount mAppendBufferLen; diff --git a/src/WaveTrack.cpp b/src/WaveTrack.cpp index 9c7275fd0..7ea2122be 100644 --- a/src/WaveTrack.cpp +++ b/src/WaveTrack.cpp @@ -2423,7 +2423,7 @@ bool WaveTrack::SplitAt(double t) return true; } -void WaveTrack::UpdateLocationsCache() +void WaveTrack::UpdateLocationsCache() const { unsigned int i; WaveClipArray clips; @@ -2608,11 +2608,12 @@ static int SortClipArrayCmpFunc(WaveClip** clip1, WaveClip** clip2) return 1; } -void WaveTrack::FillSortedClipArray(WaveClipArray& clips) +void WaveTrack::FillSortedClipArray(WaveClipArray& clips) const { clips.Empty(); - for (WaveClipList::compatibility_iterator it=GetClipIterator(); it; it=it->GetNext()) + for (WaveClipList::compatibility_iterator it = + const_cast(this)->GetClipIterator(); it; it=it->GetNext()) clips.Add(it->GetData()); clips.Sort(SortClipArrayCmpFunc); diff --git a/src/WaveTrack.h b/src/WaveTrack.h index 994ec0ffe..789150c27 100644 --- a/src/WaveTrack.h +++ b/src/WaveTrack.h @@ -342,7 +342,7 @@ class AUDACITY_DLL_API WaveTrack final : public Track { // Add all wave clips to the given array 'clips' and sort the array by // clip start time. The array is emptied prior to adding the clips. - void FillSortedClipArray(WaveClipArray& clips); + void FillSortedClipArray(WaveClipArray& clips) const; // Before calling 'Offset' on a clip, use this function to see if the // offsetting is allowed with respect to the other clips in this track. @@ -373,7 +373,7 @@ class AUDACITY_DLL_API WaveTrack final : public Track { bool MergeClips(int clipidx1, int clipidx2); // Cache special locations (e.g. cut lines) for later speedy access - void UpdateLocationsCache(); + void UpdateLocationsCache() const; // Get cached locations const std::vector &GetCachedLocations() const { return mDisplayLocationsCache; } diff --git a/src/widgets/Ruler.cpp b/src/widgets/Ruler.cpp index d74ecd10c..d2647e4ca 100644 --- a/src/widgets/Ruler.cpp +++ b/src/widgets/Ruler.cpp @@ -970,7 +970,7 @@ void Ruler::Update() Update(NULL); } -void Ruler::Update(TimeTrack* timetrack)// Envelope *speedEnv, long minSpeed, long maxSpeed ) +void Ruler::Update(const TimeTrack* timetrack)// Envelope *speedEnv, long minSpeed, long maxSpeed ) { const ZoomInfo *zoomInfo = NULL; if (!mLog && mOrientation == wxHORIZONTAL) @@ -1295,7 +1295,7 @@ void Ruler::Draw(wxDC& dc) Draw( dc, NULL); } -void Ruler::Draw(wxDC& dc, TimeTrack* timetrack) +void Ruler::Draw(wxDC& dc, const TimeTrack* timetrack) { mDC = &dc; if( mLength <=0 ) diff --git a/src/widgets/Ruler.h b/src/widgets/Ruler.h index c140e1996..d6846b01f 100644 --- a/src/widgets/Ruler.h +++ b/src/widgets/Ruler.h @@ -136,7 +136,7 @@ class AUDACITY_DLL_API Ruler { // Note that it will not erase for you... void Draw(wxDC& dc); - void Draw(wxDC& dc, TimeTrack* timetrack); + void Draw(wxDC& dc, const TimeTrack* timetrack); // If length <> 0, draws lines perpendiculars to ruler corresponding // to selected ticks (major, minor, or both), in an adjacent window. // You may need to use the offsets if you are using part of the dc for rulers, borders etc. @@ -151,7 +151,7 @@ class AUDACITY_DLL_API Ruler { private: void Update(); - void Update(TimeTrack* timetrack); + void Update(const TimeTrack* timetrack); void FindTickSizes(); void FindLinearTickSizes(double UPP); wxString LabelString(double d, bool major);