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

#include <ProjectSelectionManager.h>

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

Public Member Functions

 ProjectSelectionManager (AudacityProject &project)
 
 ProjectSelectionManager (const ProjectSelectionManager &) PROHIBITED
 
ProjectSelectionManageroperator= (const ProjectSelectionManager &) PROHIBITED
 
 ~ProjectSelectionManager () override
 
double AS_GetRate () override
 
void AS_SetRate (double rate) override
 
int AS_GetSnapTo () override
 
void AS_SetSnapTo (int snap) override
 
const NumericFormatSymbolAS_GetSelectionFormat () override
 
void AS_SetSelectionFormat (const NumericFormatSymbol &format) override
 
const NumericFormatSymbolTT_GetAudioTimeFormat () override
 
void TT_SetAudioTimeFormat (const NumericFormatSymbol &format) override
 
void AS_ModifySelection (double &start, double &end, bool done) override
 
double SSBL_GetRate () const override
 
const NumericFormatSymbolSSBL_GetFrequencySelectionFormatName () override
 
void SSBL_SetFrequencySelectionFormatName (const NumericFormatSymbol &formatName) override
 
const NumericFormatSymbolSSBL_GetBandwidthSelectionFormatName () override
 
void SSBL_SetBandwidthSelectionFormatName (const NumericFormatSymbol &formatName) override
 
void SSBL_ModifySpectralSelection (double &bottom, double &top, bool done) override
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 
- Public Member Functions inherited from SelectionBarListener
 SelectionBarListener ()
 
virtual ~SelectionBarListener ()
 
- Public Member Functions inherited from SpectralSelectionBarListener
 SpectralSelectionBarListener ()
 
virtual ~SpectralSelectionBarListener ()
 
- Public Member Functions inherited from TimeToolBarListener
 TimeToolBarListener ()
 
virtual ~TimeToolBarListener ()
 

Static Public Member Functions

static ProjectSelectionManagerGet (AudacityProject &project)
 
static const ProjectSelectionManagerGet (const AudacityProject &project)
 

Private Member Functions

bool SnapSelection ()
 

Private Attributes

AudacityProjectmProject
 

Detailed Description

Definition at line 21 of file ProjectSelectionManager.h.

Constructor & Destructor Documentation

◆ ProjectSelectionManager() [1/2]

ProjectSelectionManager::ProjectSelectionManager ( AudacityProject project)
explicit

Definition at line 49 of file ProjectSelectionManager.cpp.

50  : mProject{ project }
51 {
52 }

◆ ProjectSelectionManager() [2/2]

ProjectSelectionManager::ProjectSelectionManager ( const ProjectSelectionManager )

◆ ~ProjectSelectionManager()

ProjectSelectionManager::~ProjectSelectionManager ( )
overridedefault

Member Function Documentation

◆ AS_GetRate()

double ProjectSelectionManager::AS_GetRate ( )
overridevirtual

Implements SelectionBarListener.

Definition at line 89 of file ProjectSelectionManager.cpp.

90 {
92 }

References ProjectRate::Get(), ProjectRate::GetRate(), and mProject.

Here is the call graph for this function:

◆ AS_GetSelectionFormat()

const NumericFormatSymbol & ProjectSelectionManager::AS_GetSelectionFormat ( )
overridevirtual

Implements SelectionBarListener.

Definition at line 128 of file ProjectSelectionManager.cpp.

129 {
130  auto &project = mProject;
131  auto &settings = ProjectSettings::Get( project );
132  return settings.GetSelectionFormat();
133 }

References ProjectSettings::Get(), mProject, and settings().

Here is the call graph for this function:

◆ AS_GetSnapTo()

int ProjectSelectionManager::AS_GetSnapTo ( )
overridevirtual

Implements SelectionBarListener.

Definition at line 101 of file ProjectSelectionManager.cpp.

102 {
103  auto &project = mProject;
104  auto &settings = ProjectSettings::Get( project );
105  return settings.GetSnapTo();
106 }

References ProjectSettings::Get(), mProject, and settings().

Here is the call graph for this function:

◆ AS_ModifySelection()

void ProjectSelectionManager::AS_ModifySelection ( double &  start,
double &  end,
bool  done 
)
overridevirtual

Implements SelectionBarListener.

Definition at line 171 of file ProjectSelectionManager.cpp.

173 {
174  auto &project = mProject;
175  auto &history = ProjectHistory::Get( project );
176  auto &trackPanel = TrackPanel::Get( project );
177  auto &viewInfo = ViewInfo::Get( project );
178  viewInfo.selectedRegion.setTimes(start, end);
179  trackPanel.Refresh(false);
180  if (done) {
181  history.ModifyState(false);
182  }
183 }

References ViewInfo::Get(), ProjectHistory::Get(), TrackPanel::Get(), and mProject.

Here is the call graph for this function:

◆ AS_SetRate()

void ProjectSelectionManager::AS_SetRate ( double  rate)
overridevirtual

Implements SelectionBarListener.

Definition at line 94 of file ProjectSelectionManager.cpp.

95 {
96  auto &project = mProject;
97  ProjectRate::Get( project ).SetRate( rate );
98  SelectionBar::Get( project ).SetRate(rate);
99 }

References ProjectRate::Get(), SelectionBar::Get(), mProject, ProjectRate::SetRate(), and SelectionBar::SetRate().

Referenced by PluginActions::Handler::OnResetConfig().

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

◆ AS_SetSelectionFormat()

void ProjectSelectionManager::AS_SetSelectionFormat ( const NumericFormatSymbol format)
overridevirtual

Implements SelectionBarListener.

Definition at line 135 of file ProjectSelectionManager.cpp.

137 {
138  auto &project = mProject;
139  auto &settings = ProjectSettings::Get( project );
140  settings.SetSelectionFormat( format );
141 
142  gPrefs->Write(wxT("/SelectionFormat"), format.Internal());
143  gPrefs->Flush();
144 
145  if (SnapSelection())
146  TrackPanel::Get( project ).Refresh(false);
147 
149 }

References FileConfig::Flush(), format, ProjectSettings::Get(), SelectionBar::Get(), TrackPanel::Get(), gPrefs, mProject, TrackPanel::Refresh(), SelectionBar::SetSelectionFormat(), settings(), and SnapSelection().

Here is the call graph for this function:

◆ AS_SetSnapTo()

void ProjectSelectionManager::AS_SetSnapTo ( int  snap)
overridevirtual

Implements SelectionBarListener.

Definition at line 108 of file ProjectSelectionManager.cpp.

109 {
110  auto &project = mProject;
111  auto &settings = ProjectSettings::Get( project );
112  auto &window = ProjectWindow::Get( project );
113 
114  settings.SetSnapTo( snap );
115 
116 // LLL: TODO - what should this be changed to???
117 // GetCommandManager()->Check(wxT("Snap"), mSnapTo);
118  gPrefs->Write(wxT("/SnapTo"), snap);
119  gPrefs->Flush();
120 
121  SnapSelection();
122 
123  window.RedrawProject();
124 
125  SelectionBar::Get( project ).SetSnapTo(snap);
126 }

References FileConfig::Flush(), ProjectSettings::Get(), ProjectWindow::Get(), SelectionBar::Get(), gPrefs, mProject, SelectionBar::SetSnapTo(), settings(), and SnapSelection().

Referenced by PluginActions::Handler::OnResetConfig(), SelectActions::Handler::OnSnapToNearest(), SelectActions::Handler::OnSnapToOff(), SelectActions::Handler::OnSnapToPrior(), and anonymous_namespace{HelpMenus.cpp}::QuickFixDialog::PopulateOrExchange().

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

◆ Get() [1/2]

ProjectSelectionManager & ProjectSelectionManager::Get ( AudacityProject project)
static

◆ Get() [2/2]

const ProjectSelectionManager & ProjectSelectionManager::Get ( const AudacityProject project)
static

Definition at line 43 of file ProjectSelectionManager.cpp.

45 {
46  return Get( const_cast< AudacityProject & >( project ) );
47 }

References Get().

Here is the call graph for this function:

◆ operator=()

ProjectSelectionManager& ProjectSelectionManager::operator= ( const ProjectSelectionManager )

◆ SnapSelection()

bool ProjectSelectionManager::SnapSelection ( )
private

Definition at line 56 of file ProjectSelectionManager.cpp.

57 {
58  auto &project = mProject;
59  auto &settings = ProjectSettings::Get( project );
60  auto &window = ProjectWindow::Get( project );
61  auto snapTo = settings.GetSnapTo();
62  if (snapTo != SNAP_OFF) {
63  auto &viewInfo = ViewInfo::Get( project );
64  auto &selectedRegion = viewInfo.selectedRegion;
66  settings.GetSelectionFormat(), 0, ProjectRate::Get(project).GetRate());
67  const bool nearest = (snapTo == SNAP_NEAREST);
68 
69  const double oldt0 = selectedRegion.t0();
70  const double oldt1 = selectedRegion.t1();
71 
72  nc.ValueToControls(oldt0, nearest);
73  nc.ControlsToValue();
74  const double t0 = nc.GetValue();
75 
76  nc.ValueToControls(oldt1, nearest);
77  nc.ControlsToValue();
78  const double t1 = nc.GetValue();
79 
80  if (t0 != oldt0 || t1 != oldt1) {
81  selectedRegion.setTimes(t0, t1);
82  return true;
83  }
84  }
85 
86  return false;
87 }

References NumericConverter::ControlsToValue(), ProjectRate::Get(), ViewInfo::Get(), ProjectSettings::Get(), ProjectWindow::Get(), ProjectRate::GetRate(), NumericConverter::GetValue(), mProject, settings(), SNAP_NEAREST, SNAP_OFF, NumericConverter::TIME, and NumericConverter::ValueToControls().

Referenced by AS_SetSelectionFormat(), and AS_SetSnapTo().

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

◆ SSBL_GetBandwidthSelectionFormatName()

const NumericFormatSymbol & ProjectSelectionManager::SSBL_GetBandwidthSelectionFormatName ( )
overridevirtual

Implements SpectralSelectionBarListener.

Definition at line 220 of file ProjectSelectionManager.cpp.

221 {
222  auto &project = mProject;
223  auto &settings = ProjectSettings::Get( project );
224  return settings.GetBandwidthSelectionFormatName();
225 }

References ProjectSettings::Get(), mProject, and settings().

Here is the call graph for this function:

◆ SSBL_GetFrequencySelectionFormatName()

const NumericFormatSymbol & ProjectSelectionManager::SSBL_GetFrequencySelectionFormatName ( )
overridevirtual

Implements SpectralSelectionBarListener.

Definition at line 195 of file ProjectSelectionManager.cpp.

196 {
197  auto &project = mProject;
198  auto &settings = ProjectSettings::Get( project );
199  return settings.GetFrequencySelectionFormatName();
200 }

References ProjectSettings::Get(), mProject, and settings().

Here is the call graph for this function:

◆ SSBL_GetRate()

double ProjectSelectionManager::SSBL_GetRate ( ) const
overridevirtual

Implements SpectralSelectionBarListener.

Definition at line 185 of file ProjectSelectionManager.cpp.

186 {
187  auto &project = mProject;
188  auto &tracks = TrackList::Get( project );
189  // Return maximum of project rate and all track rates.
190  return std::max( ProjectRate::Get( project ).GetRate(),
191  tracks.Any<const WaveTrack>().max( &WaveTrack::GetRate ) );
192 }

References ProjectRate::Get(), TrackList::Get(), anonymous_namespace{TimeTrack.cpp}::GetRate(), WaveTrack::GetRate(), and mProject.

Referenced by SSBL_ModifySpectralSelection().

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

◆ SSBL_ModifySpectralSelection()

void ProjectSelectionManager::SSBL_ModifySpectralSelection ( double &  bottom,
double &  top,
bool  done 
)
overridevirtual

Implements SpectralSelectionBarListener.

Definition at line 244 of file ProjectSelectionManager.cpp.

246 {
247 #ifdef EXPERIMENTAL_SPECTRAL_EDITING
248  auto &project = mProject;
249  auto &history = ProjectHistory::Get( project );
250  auto &trackPanel = TrackPanel::Get( project );
251  auto &viewInfo = ViewInfo::Get( project );
252 
253  double nyq = SSBL_GetRate() / 2.0;
254  if (bottom >= 0.0)
255  bottom = std::min(nyq, bottom);
256  if (top >= 0.0)
257  top = std::min(nyq, top);
258  viewInfo.selectedRegion.setFrequencies(bottom, top);
259  trackPanel.Refresh(false);
260  if (done) {
261  history.ModifyState(false);
262  }
263 #else
264  bottom; top; done;
265 #endif
266 }

References ViewInfo::Get(), ProjectHistory::Get(), TrackPanel::Get(), min(), mProject, and SSBL_GetRate().

Referenced by SelectFrequenciesCommand::Apply().

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

◆ SSBL_SetBandwidthSelectionFormatName()

void ProjectSelectionManager::SSBL_SetBandwidthSelectionFormatName ( const NumericFormatSymbol formatName)
overridevirtual

Implements SpectralSelectionBarListener.

Definition at line 227 of file ProjectSelectionManager.cpp.

229 {
230  auto &project = mProject;
231  auto &settings = ProjectSettings::Get( project );
232 
233  settings.SetBandwidthSelectionFormatName( formatName );
234 
235  gPrefs->Write(wxT("/BandwidthSelectionFormatName"),
236  formatName.Internal());
237  gPrefs->Flush();
238 
239 #ifdef EXPERIMENTAL_SPECTRAL_EDITING
241 #endif
242 }

References FileConfig::Flush(), ProjectSettings::Get(), SpectralSelectionBar::Get(), gPrefs, ComponentInterfaceSymbol::Internal(), mProject, SpectralSelectionBar::SetBandwidthSelectionFormatName(), and settings().

Here is the call graph for this function:

◆ SSBL_SetFrequencySelectionFormatName()

void ProjectSelectionManager::SSBL_SetFrequencySelectionFormatName ( const NumericFormatSymbol formatName)
overridevirtual

Implements SpectralSelectionBarListener.

Definition at line 202 of file ProjectSelectionManager.cpp.

204 {
205  auto &project = mProject;
206  auto &settings = ProjectSettings::Get( project );
207 
208  settings.SetFrequencySelectionFormatName( formatName );
209 
210  gPrefs->Write(wxT("/FrequencySelectionFormatName"),
211  formatName.Internal());
212  gPrefs->Flush();
213 
214 #ifdef EXPERIMENTAL_SPECTRAL_EDITING
216 #endif
217 }

References FileConfig::Flush(), ProjectSettings::Get(), SpectralSelectionBar::Get(), gPrefs, ComponentInterfaceSymbol::Internal(), mProject, SpectralSelectionBar::SetFrequencySelectionFormatName(), and settings().

Here is the call graph for this function:

◆ TT_GetAudioTimeFormat()

const NumericFormatSymbol & ProjectSelectionManager::TT_GetAudioTimeFormat ( )
overridevirtual

Implements TimeToolBarListener.

Definition at line 151 of file ProjectSelectionManager.cpp.

152 {
153  auto &project = mProject;
154  auto &settings = ProjectSettings::Get( project );
155  return settings.GetAudioTimeFormat();
156 }

References ProjectSettings::Get(), mProject, and settings().

Here is the call graph for this function:

◆ TT_SetAudioTimeFormat()

void ProjectSelectionManager::TT_SetAudioTimeFormat ( const NumericFormatSymbol format)
overridevirtual

Implements TimeToolBarListener.

Definition at line 158 of file ProjectSelectionManager.cpp.

160 {
161  auto &project = mProject;
162  auto &settings = ProjectSettings::Get( project );
163  settings.SetAudioTimeFormat( format );
164 
165  gPrefs->Write(wxT("/AudioTimeFormat"), format.Internal());
166  gPrefs->Flush();
167 
169 }

References FileConfig::Flush(), format, ProjectSettings::Get(), TimeToolBar::Get(), gPrefs, mProject, TimeToolBar::SetAudioTimeFormat(), and settings().

Here is the call graph for this function:

Member Data Documentation

◆ mProject

AudacityProject& ProjectSelectionManager::mProject
private

The documentation for this class was generated from the following files:
SelectionBar::Get
static SelectionBar & Get(AudacityProject &project)
Definition: SelectionBar.cpp:137
ViewInfo::Get
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:161
SNAP_OFF
@ SNAP_OFF
Definition: ProjectSettings.h:29
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:69
ProjectSelectionManager
Definition: ProjectSelectionManager.h:26
gPrefs
FileConfig * gPrefs
Definition: Prefs.cpp:70
ProjectRate::Get
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:42
SelectionBar::SetRate
void SetRate(double rate)
Definition: SelectionBar.cpp:720
TrackPanel::Get
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:227
ProjectSettings::Get
static ProjectSettings & Get(AudacityProject &project)
Definition: ProjectSettings.cpp:41
ProjectRate::SetRate
void SetRate(double rate)
Definition: ProjectRate.cpp:73
ProjectWindow::Get
static ProjectWindow & Get(AudacityProject &project)
Definition: ProjectWindow.cpp:535
SpectralSelectionBar::SetFrequencySelectionFormatName
void SetFrequencySelectionFormatName(const NumericFormatSymbol &formatName)
ProjectSelectionManager::SnapSelection
bool SnapSelection()
Definition: ProjectSelectionManager.cpp:56
ProjectSelectionManager::SSBL_GetRate
double SSBL_GetRate() const override
Definition: ProjectSelectionManager.cpp:185
sProjectSelectionManagerKey
static AudacityProject::AttachedObjects::RegisteredFactory sProjectSelectionManagerKey
Definition: ProjectSelectionManager.cpp:30
SNAP_NEAREST
@ SNAP_NEAREST
Definition: ProjectSettings.h:30
SpectralSelectionBar::SetBandwidthSelectionFormatName
void SetBandwidthSelectionFormatName(const NumericFormatSymbol &formatName)
ProjectSelectionManager::Get
static ProjectSelectionManager & Get(AudacityProject &project)
Definition: ProjectSelectionManager.cpp:36
SpectralSelectionBar::Get
static SpectralSelectionBar & Get(AudacityProject &project)
anonymous_namespace{TimeTrack.cpp}::GetRate
double GetRate()
Definition: TimeTrack.cpp:175
NumericConverter::TIME
@ TIME
Definition: NumericTextCtrl.h:52
SelectionBar::SetSelectionFormat
void SetSelectionFormat(const NumericFormatSymbol &format)
Definition: SelectionBar.cpp:707
format
int format
Definition: ExportPCM.cpp:56
ProjectRate::GetRate
double GetRate() const
Definition: ProjectRate.cpp:68
TimeToolBar::Get
static TimeToolBar & Get(AudacityProject &project)
Definition: TimeToolBar.cpp:64
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
TimeToolBar::SetAudioTimeFormat
void SetAudioTimeFormat(const NumericFormatSymbol &format)
Definition: TimeToolBar.cpp:195
NumericConverter
NumericConverter provides the advanced formatting control used in the selection bar of Audacity.
Definition: NumericTextCtrl.h:48
FileConfig::Flush
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
TrackList::Get
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:506
TrackPanel::Refresh
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
Definition: TrackPanel.cpp:793
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
ComponentInterfaceSymbol::Internal
const wxString & Internal() const
Definition: ComponentInterfaceSymbol.h:55
ProjectSelectionManager::mProject
AudacityProject & mProject
Definition: ProjectSelectionManager.h:62
settings
static Settings & settings()
Definition: TrackInfo.cpp:86
SelectionBar::SetSnapTo
void SetSnapTo(int)
Definition: SelectionBar.cpp:702
ProjectHistory::Get
static ProjectHistory & Get(AudacityProject &project)
Definition: ProjectHistory.cpp:26
WaveTrack::GetRate
double GetRate() const
Definition: WaveTrack.cpp:452