Audacity  3.0.3
Classes | Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
SpectrumView Class Referencefinal

#include <SpectrumView.h>

Inheritance diagram for SpectrumView:
[legend]
Collaboration diagram for SpectrumView:
[legend]

Classes

class  SpectralDataSaver
 

Public Member Functions

 SpectrumView (WaveTrackView &waveTrackView, const SpectrumView &src)=delete
 
 SpectrumView (WaveTrackView &waveTrackView)
 
 ~SpectrumView () override
 
const TypeSubViewType () const override
 
std::shared_ptr< TrackVRulerControlsDoGetVRulerControls () override
 
std::shared_ptr< SpectralDataGetSpectralData ()
 
bool IsSpectral () const override
 
void CopyToSubView (WaveTrackSubView *destSubView) const override
 
- Public Member Functions inherited from WaveTrackSubView
 WaveTrackSubView (WaveTrackView &waveTrackView)
 
std::pair< bool, std::vector< UIHandlePtr > > DoDetailedHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject, int currentTool, bool bMultiTool, const std::shared_ptr< WaveTrack > &wt)
 
- Public Member Functions inherited from CommonTrackView
std::shared_ptr< TrackPanelCellContextMenuDelegate () override
 
std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &, const AudacityProject *pProject) final override
 
void TimeShiftHitTest ()
 
virtual int GetMinimizedHeight () const override
 
 TrackView (const std::shared_ptr< Track > &pTrack)
 
- Public Member Functions inherited from TrackView
 TrackView (const std::shared_ptr< Track > &pTrack)
 
virtual ~TrackView ()=0
 
void CopyTo (Track &track) const override
 
bool GetMinimized () const
 
void SetMinimized (bool minimized)
 
int GetCumulativeHeightBefore () const
 
int GetExpandedHeight () const
 
int GetHeight () const
 
void SetCumulativeHeightBefore (int y)
 Set cached value dependent on position within the track list. More...
 
void SetExpandedHeight (int height)
 
std::shared_ptr< TrackVRulerControlsGetVRulerControls ()
 
std::shared_ptr< const TrackVRulerControlsGetVRulerControls () const
 
virtual std::shared_ptr< CommonTrackCellGetAffordanceControls ()
 
void WriteXMLAttributes (XMLWriter &) const override
 
bool HandleXMLAttribute (const wxChar *attr, const wxChar *value) override
 
virtual Refinement GetSubViews (const wxRect &rect)
 
- Public Member Functions inherited from CommonTrackCell
 CommonTrackCell (const std::shared_ptr< Track > &pTrack)
 
 ~CommonTrackCell ()
 
std::shared_ptr< TrackDoFindTrack () override
 
virtual void Reparent (const std::shared_ptr< Track > &parent)
 
- Public Member Functions inherited from CommonTrackPanelCell
 CommonTrackPanelCell ()
 
virtual ~CommonTrackPanelCell ()=0
 
HitTestPreview DefaultPreview (const TrackPanelMouseState &, const AudacityProject *) override
 
std::shared_ptr< TrackFindTrack ()
 
std::shared_ptr< const TrackFindTrack () const
 
- Public Member Functions inherited from TrackPanelCell
 TrackPanelCell ()=default
 
 TrackPanelCell (const TrackPanelCell &) PROHIBITED
 
TrackPanelCelloperator= (const TrackPanelCell &) PROHIBITED
 
virtual ~TrackPanelCell ()=0
 
virtual unsigned KeyUp (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned LoseFocus (AudacityProject *project)
 
- Public Member Functions inherited from TrackPanelNode
 TrackPanelNode ()
 
virtual ~TrackPanelNode ()=0
 
- Public Member Functions inherited from TrackPanelDrawable
virtual ~TrackPanelDrawable ()=0
 
virtual wxRect DrawingArea (TrackPanelDrawingContext &context, const wxRect &rect, const wxRect &panelRect, unsigned iPass)
 

Static Public Attributes

static int mBrushRadius
 

Private Member Functions

SpectrumViewoperator= (const SpectrumView &)=delete
 
void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass) override
 
void DoDraw (TrackPanelDrawingContext &context, const WaveTrack *track, const WaveClip *selectedClip, const wxRect &rect)
 
std::vector< UIHandlePtrDetailedHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject, int currentTool, bool bMultiTool) override
 
unsigned CaptureKey (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project) override
 
unsigned KeyDown (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project) override
 
unsigned Char (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project) override
 
void DoSetMinimized (bool minimized) override
 

Static Private Member Functions

static void ForAll (AudacityProject &project, std::function< void(SpectrumView &view)> fn)
 

Private Attributes

std::weak_ptr< BrushHandlemBrushHandle
 
std::shared_ptr< SpectralDatampSpectralData
 
std::shared_ptr< SpectralDatampBackupSpectralData
 
bool mOnBrushTool
 

Additional Inherited Members

- Public Types inherited from WaveTrackSubView
using Display = WaveTrackViewConstants::Display
 
using Type = WaveTrackSubViewType
 
- Public Types inherited from TrackView
enum  : unsigned { DefaultHeight = 150 }
 
using Refinement = std::vector< std::pair< wxCoord, std::shared_ptr< TrackView > > >
 
- Public Types inherited from CommonTrackPanelCell
using Hook = std::function< unsigned(const TrackPanelMouseEvent &evt, AudacityProject *pProject) >
 
- Static Public Member Functions inherited from TrackView
static int GetTrackHeight (const Track *pTrack)
 
static int GetChannelGroupHeight (const Track *pTrack)
 
static int GetCumulativeHeight (const Track *pTrack)
 
static int GetTotalHeight (const TrackList &list)
 
static TrackViewGet (Track &)
 
static const TrackViewGet (const Track &)
 
- Static Public Member Functions inherited from CommonTrackPanelCell
static Hook InstallMouseWheelHook (const Hook &hook)
 
- Static Public Member Functions inherited from TrackPanelDrawable
static wxRect MaximizeWidth (const wxRect &rect, const wxRect &panelRect)
 
static wxRect MaximizeHeight (const wxRect &rect, const wxRect &panelRect)
 
- Public Attributes inherited from CommonTrackView
std::weak_ptr< TimeShiftHandlemTimeShiftHandle
 
- Protected Member Functions inherited from WaveTrackSubView
std::weak_ptr< WaveTrackViewGetWaveTrackView () const
 
std::vector< MenuItemGetMenuItems (const wxRect &rect, const wxPoint *pPosition, AudacityProject *pProject) override
 Return a list of items for DoContextMenu() (empties for separators) More...
 
- Protected Member Functions inherited from CommonTrackPanelCell
unsigned DoContextMenu (const wxRect &rect, wxWindow *pParent, const wxPoint *pPosition, AudacityProject *pProject) override
 
unsigned HandleWheelRotation (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
- Static Protected Member Functions inherited from WaveTrackSubView
static void DrawBoldBoundaries (TrackPanelDrawingContext &context, const WaveTrack *track, const wxRect &rect)
 
- Protected Attributes inherited from CommonTrackView
std::weak_ptr< SelectHandlemSelectHandle
 
- Protected Attributes inherited from TrackView
std::shared_ptr< TrackVRulerControlsmpVRulerControls
 

Detailed Description

Definition at line 113 of file SpectrumView.h.

Constructor & Destructor Documentation

◆ SpectrumView() [1/2]

SpectrumView::SpectrumView ( WaveTrackView waveTrackView,
const SpectrumView src 
)
delete

◆ SpectrumView() [2/2]

SpectrumView::SpectrumView ( WaveTrackView waveTrackView)
explicit

Definition at line 45 of file SpectrumView.cpp.

45  : WaveTrackSubView(waveTrackView) {
46  auto wt = static_cast<WaveTrack*>( FindTrack().get() );
47  mpSpectralData = std::make_shared<SpectralData>(wt->GetRate());
48  mOnBrushTool = false;
49 }

References CommonTrackPanelCell::FindTrack(), mOnBrushTool, and mpSpectralData.

Here is the call graph for this function:

◆ ~SpectrumView()

SpectrumView::~SpectrumView ( )
overridedefault

Member Function Documentation

◆ CaptureKey()

unsigned SpectrumView::CaptureKey ( wxKeyEvent &  event,
ViewInfo viewInfo,
wxWindow *  pParent,
AudacityProject project 
)
overrideprivatevirtual

Reimplemented from TrackPanelCell.

Definition at line 1028 of file SpectrumView.cpp.

1030 {
1031  bool capture = ShouldCaptureEvent(event, mpSpectralData.get());
1032  event.Skip(!capture);
1033  return RefreshCode::RefreshNone;
1034 }

References mpSpectralData, RefreshCode::RefreshNone, and ShouldCaptureEvent().

Here is the call graph for this function:

◆ Char()

unsigned SpectrumView::Char ( wxKeyEvent &  event,
ViewInfo viewInfo,
wxWindow *  pParent,
AudacityProject project 
)
overrideprivatevirtual

Reimplemented from TrackPanelCell.

Definition at line 1046 of file SpectrumView.cpp.

1048 {
1049  bool capture = ShouldCaptureEvent(event, mpSpectralData.get());
1050  event.Skip(!capture);
1051  return RefreshCode::RefreshNone;
1052 }

References mpSpectralData, RefreshCode::RefreshNone, and ShouldCaptureEvent().

Here is the call graph for this function:

◆ CopyToSubView()

void SpectrumView::CopyToSubView ( WaveTrackSubView destSubView) const
overridevirtual

Reimplemented from WaveTrackSubView.

Definition at line 219 of file SpectrumView.cpp.

219  {
220  if ( const auto pDest = dynamic_cast< SpectrumView* >( destSubView ) ) {
221  pDest->mpSpectralData = std::make_shared<SpectralData>(mpSpectralData->GetSR());
222  pDest->mpSpectralData->CopyFrom(*mpSpectralData);
223  }
224 }

References mpSpectralData.

◆ DetailedHitTest()

std::vector< UIHandlePtr > SpectrumView::DetailedHitTest ( const TrackPanelMouseState state,
const AudacityProject pProject,
int  currentTool,
bool  bMultiTool 
)
overrideprivatevirtual

Implements CommonTrackView.

Definition at line 156 of file SpectrumView.cpp.

159 {
160  const auto wt = std::static_pointer_cast< WaveTrack >( FindTrack() );
161  std::vector<UIHandlePtr> results;
162 
163 #ifdef EXPERIMENTAL_BRUSH_TOOL
164  mOnBrushTool = (currentTool == ToolCodes::brushTool);
165  if(mOnBrushTool){
166  const auto result = BrushHandleHitTest(
167  mBrushHandle, state,
168  pProject, std::static_pointer_cast<SpectrumView>(shared_from_this()),
170  results.push_back(result);
171  return results;
172  }
173 #endif
174 
176  state, pProject, currentTool, bMultiTool, wt
177  ).second;
178 }

References BrushHandleHitTest(), WaveTrackSubView::DoDetailedHitTest(), CommonTrackPanelCell::FindTrack(), mBrushHandle, mOnBrushTool, and mpSpectralData.

Here is the call graph for this function:

◆ DoDraw()

void SpectrumView::DoDraw ( TrackPanelDrawingContext context,
const WaveTrack track,
const WaveClip selectedClip,
const wxRect &  rect 
)
private

Definition at line 821 of file SpectrumView.cpp.

825 {
826  const auto artist = TrackArtist::Get( context );
827  const auto &blankSelectedBrush = artist->blankSelectedBrush;
828  const auto &blankBrush = artist->blankBrush;
830  context, rect, track, blankSelectedBrush, blankBrush );
831 
832  WaveTrackCache cache(track->SharedPointer<const WaveTrack>());
833  for (const auto &clip: track->GetClips()){
834  DrawClipSpectrum( context, cache, clip.get(), rect,
835  mpSpectralData, clip.get() == selectedClip);
836  }
837 
838  DrawBoldBoundaries( context, track, rect );
839 }

References TrackArt::DrawBackgroundWithSelection(), WaveTrackSubView::DrawBoldBoundaries(), anonymous_namespace{SpectrumView.cpp}::DrawClipSpectrum(), TrackArtist::Get(), WaveTrack::GetClips(), mpSpectralData, and Track::SharedPointer().

Referenced by Draw().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DoGetVRulerControls()

std::shared_ptr< TrackVRulerControls > SpectrumView::DoGetVRulerControls ( )
overridevirtual

Implements TrackView.

Definition at line 210 of file SpectrumView.cpp.

211 {
212  return std::make_shared<SpectrumVRulerControls>( shared_from_this() );
213 }

◆ DoSetMinimized()

void SpectrumView::DoSetMinimized ( bool  minimized)
overrideprivatevirtual

Reimplemented from TrackView.

Definition at line 180 of file SpectrumView.cpp.

181 {
182  auto wt = static_cast<WaveTrack*>( FindTrack().get() );
183 
184 #ifdef EXPERIMENTAL_HALF_WAVE
185  bool bHalfWave;
186  gPrefs->Read(wxT("/GUI/CollapseToHalfWave"), &bHalfWave, false);
187  if( bHalfWave && minimized)
188  {
189  // It is all right to set the top of scale to a huge number,
190  // not knowing the track rate here -- because when retrieving the
191  // value, then we pass in a sample rate and clamp it above to the
192  // Nyquist frequency.
193  constexpr auto max = std::numeric_limits<float>::max();
194  const bool spectrumLinear =
195  (wt->GetSpectrogramSettings().scaleType ==
197  // Zoom out full
198  wt->SetSpectrumBounds( spectrumLinear ? 0.0f : 1.0f, max );
199  }
200 #endif
201 
202  TrackView::DoSetMinimized( minimized );
203 }

References TrackView::DoSetMinimized(), CommonTrackPanelCell::FindTrack(), gPrefs, and SpectrogramSettings::stLinear.

Here is the call graph for this function:

◆ Draw()

void SpectrumView::Draw ( TrackPanelDrawingContext context,
const wxRect &  rect,
unsigned  iPass 
)
overrideprivatevirtual

Reimplemented from TrackPanelDrawable.

Definition at line 841 of file SpectrumView.cpp.

843 {
844  if ( iPass == TrackArtist::PassTracks ) {
845  auto &dc = context.dc;
846  // Update cache for locations, e.g. cutlines and merge points
847  // Bug2588: do this for both channels, even if one is not drawn, so that
848  // cut-line editing (which depends on the locations cache) works properly.
849  // If both channels are visible, we will duplicate this effort, but that
850  // matters little.
851  for( auto channel:
852  TrackList::Channels(static_cast<WaveTrack*>(FindTrack().get())) )
853  channel->UpdateLocationsCache();
854 
855  const auto wt = std::static_pointer_cast<const WaveTrack>(
856  FindTrack()->SubstitutePendingChangedTrack());
857 
858  const auto artist = TrackArtist::Get( context );
859 
860 #if defined(__WXMAC__)
861  wxAntialiasMode aamode = dc.GetGraphicsContext()->GetAntialiasMode();
862  dc.GetGraphicsContext()->SetAntialiasMode(wxANTIALIAS_NONE);
863 #endif
864 
865  auto waveTrackView = GetWaveTrackView().lock();
866  wxASSERT(waveTrackView.use_count());
867 
868  auto seletedClip = waveTrackView->GetSelectedClip().lock();
869  DoDraw( context, wt.get(), seletedClip.get(), rect );
870 
871 #if defined(__WXMAC__)
872  dc.GetGraphicsContext()->SetAntialiasMode(aamode);
873 #endif
874  }
875  WaveTrackSubView::Draw( context, rect, iPass );
876 }

References TrackList::Channels(), TrackPanelDrawingContext::dc, DoDraw(), TrackPanelDrawable::Draw(), CommonTrackPanelCell::FindTrack(), TrackArtist::Get(), WaveTrackSubView::GetWaveTrackView(), and TrackArtist::PassTracks.

Here is the call graph for this function:

◆ ForAll()

void SpectrumView::ForAll ( AudacityProject project,
std::function< void(SpectrumView &view)>  fn 
)
staticprivate

Definition at line 140 of file SpectrumView.cpp.

142 {
143  if (!fn)
144  return;
145  for ( const auto wt : TrackList::Get(project).Any< WaveTrack >() ) {
146  if (auto pWaveTrackView =
147  dynamic_cast<WaveTrackView*>( &TrackView::Get(*wt)) ) {
148  for (const auto &pSubView : pWaveTrackView->GetAllSubViews()) {
149  if (const auto sView = dynamic_cast<SpectrumView*>(pSubView.get()))
150  fn( *sView );
151  }
152  }
153  }
154 }

References fn, TrackList::Get(), and TrackView::Get().

Referenced by SpectrumView::SpectralDataSaver::Init(), and SpectrumView::SpectralDataSaver::~SpectralDataSaver().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSpectralData()

std::shared_ptr< SpectralData > SpectrumView::GetSpectralData ( )

Definition at line 215 of file SpectrumView.cpp.

215  {
216  return mpSpectralData;
217 }

References mpSpectralData.

◆ IsSpectral()

bool SpectrumView::IsSpectral ( ) const
overridevirtual

Reimplemented from TrackView.

Definition at line 53 of file SpectrumView.cpp.

54 {
55  return true;
56 }

◆ KeyDown()

unsigned SpectrumView::KeyDown ( wxKeyEvent &  event,
ViewInfo viewInfo,
wxWindow *  pParent,
AudacityProject project 
)
overrideprivatevirtual

Reimplemented from TrackPanelCell.

Definition at line 1036 of file SpectrumView.cpp.

1037 {
1038  bool capture = ShouldCaptureEvent(event, mpSpectralData.get());
1039  event.Skip(!capture);
1040  if (capture && SpectralDataManager::ProcessTracks(*project))
1041  // Not RefreshCell, because there might be effects in multiple tracks
1042  return RefreshCode::RefreshAll;
1043  return RefreshCode::RefreshNone;
1044 }

References mpSpectralData, SpectralDataManager::ProcessTracks(), RefreshCode::RefreshAll, RefreshCode::RefreshNone, and ShouldCaptureEvent().

Here is the call graph for this function:

◆ operator=()

SpectrumView& SpectrumView::operator= ( const SpectrumView )
privatedelete

◆ SubViewType()

auto SpectrumView::SubViewType ( ) const
overridevirtual

Implements WaveTrackSubView.

Definition at line 205 of file SpectrumView.cpp.

206 {
207  return sType;
208 }

References sType.

Member Data Documentation

◆ mBrushHandle

std::weak_ptr<BrushHandle> SpectrumView::mBrushHandle
private

Definition at line 136 of file SpectrumView.h.

Referenced by DetailedHitTest().

◆ mBrushRadius

int SpectrumView::mBrushRadius
static

Definition at line 129 of file SpectrumView.h.

◆ mOnBrushTool

bool SpectrumView::mOnBrushTool
private

Definition at line 138 of file SpectrumView.h.

Referenced by DetailedHitTest(), and SpectrumView().

◆ mpBackupSpectralData

std::shared_ptr<SpectralData> SpectrumView::mpBackupSpectralData
private

◆ mpSpectralData

std::shared_ptr<SpectralData> SpectrumView::mpSpectralData
private

The documentation for this class was generated from the following files:
WaveTrackCache
A short-lived object, during whose lifetime, the contents of the WaveTrack are assumed not to change.
Definition: WaveTrack.h:636
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
WaveTrackView
Definition: WaveTrackView.h:97
fn
static const auto fn
Definition: WaveformView.cpp:1108
RefreshCode::RefreshAll
@ RefreshAll
Definition: RefreshCode.h:26
TrackView::Get
static TrackView & Get(Track &)
Definition: TrackView.cpp:63
RefreshCode::RefreshNone
@ RefreshNone
Definition: RefreshCode.h:21
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
CommonTrackPanelCell::FindTrack
std::shared_ptr< Track > FindTrack()
Definition: CommonTrackPanelCell.h:46
TrackList::Channels
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1484
WaveTrackSubView::DrawBoldBoundaries
static void DrawBoldBoundaries(TrackPanelDrawingContext &context, const WaveTrack *track, const wxRect &rect)
Definition: WaveTrackView.cpp:773
Track::SharedPointer
std::shared_ptr< Subclass > SharedPointer()
Definition: Track.h:291
TrackPanelDrawingContext::dc
wxDC & dc
Definition: TrackPanelDrawingContext.h:23
WaveTrackSubView::WaveTrackSubView
WaveTrackSubView(WaveTrackView &waveTrackView)
Definition: WaveTrackView.cpp:866
SpectrumView::mBrushHandle
std::weak_ptr< BrushHandle > mBrushHandle
Definition: SpectrumView.h:133
WaveTrackSubView::DoDetailedHitTest
std::pair< bool, std::vector< UIHandlePtr > > DoDetailedHitTest(const TrackPanelMouseState &state, const AudacityProject *pProject, int currentTool, bool bMultiTool, const std::shared_ptr< WaveTrack > &wt)
SpectrumView
Definition: SpectrumView.h:114
SpectrumView::mpSpectralData
std::shared_ptr< SpectralData > mpSpectralData
Definition: SpectrumView.h:137
TrackArtist::Get
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:79
WaveTrack::GetClips
WaveClipHolders & GetClips()
Definition: WaveTrack.h:371
sType
static WaveTrackSubView::Type sType
Definition: SpectrumView.cpp:38
SpectrumView::DoDraw
void DoDraw(TrackPanelDrawingContext &context, const WaveTrack *track, const WaveClip *selectedClip, const wxRect &rect)
Definition: SpectrumView.cpp:821
SpectralDataManager::ProcessTracks
static bool ProcessTracks(AudacityProject &project)
Definition: SpectralDataManager.cpp:36
TrackView::DoSetMinimized
virtual void DoSetMinimized(bool isMinimized)
Definition: TrackView.cpp:126
SpectrogramSettings::stLinear
@ stLinear
Definition: SpectrogramSettings.h:59
TrackArt::DrawBackgroundWithSelection
AUDACITY_DLL_API void DrawBackgroundWithSelection(TrackPanelDrawingContext &context, const wxRect &rect, const Track *track, const wxBrush &selBrush, const wxBrush &unselBrush, bool useSelection=true)
Definition: TrackArtist.cpp:528
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:506
BrushHandleHitTest
static UIHandlePtr BrushHandleHitTest(std::weak_ptr< BrushHandle > &holder, const TrackPanelMouseState &st, const AudacityProject *pProject, const std::shared_ptr< SpectrumView > &pTrackView, const std::shared_ptr< SpectralData > &mpData)
Definition: SpectrumView.cpp:113
WaveTrackSubView::GetWaveTrackView
std::weak_ptr< WaveTrackView > GetWaveTrackView() const
Definition: WaveTrackView.cpp:814
TrackArtist::PassTracks
@ PassTracks
Definition: TrackArtist.h:81
SpectrumView::mOnBrushTool
bool mOnBrushTool
Definition: SpectrumView.h:138
ShouldCaptureEvent
static bool ShouldCaptureEvent(wxKeyEvent &event, SpectralData *pData)
Definition: SpectrumView.cpp:1019
anonymous_namespace{SpectrumView.cpp}::DrawClipSpectrum
void DrawClipSpectrum(TrackPanelDrawingContext &context, WaveTrackCache &waveTrackCache, const WaveClip *clip, const wxRect &rect, const std::shared_ptr< SpectralData > &mpSpectralData, bool selected)
Definition: SpectrumView.cpp:308
TrackPanelDrawable::Draw
virtual void Draw(TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
Definition: TrackPanelDrawable.cpp:17