Audacity 3.2.0
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 ()
 
virtual double AS_GetRate ()=0
 
virtual void AS_SetRate (double rate)=0
 
virtual int AS_GetSnapTo ()=0
 
virtual void AS_SetSnapTo (int snap)=0
 
virtual const NumericFormatSymbolAS_GetSelectionFormat ()=0
 
virtual void AS_SetSelectionFormat (const NumericFormatSymbol &format)=0
 
virtual void AS_ModifySelection (double &start, double &end, bool done)=0
 
- Public Member Functions inherited from SpectralSelectionBarListener
 SpectralSelectionBarListener ()
 
virtual ~SpectralSelectionBarListener ()
 
virtual double SSBL_GetRate () const =0
 
virtual const NumericFormatSymbolSSBL_GetFrequencySelectionFormatName ()=0
 
virtual void SSBL_SetFrequencySelectionFormatName (const NumericFormatSymbol &formatName)=0
 
virtual const NumericFormatSymbolSSBL_GetBandwidthSelectionFormatName ()=0
 
virtual void SSBL_SetBandwidthSelectionFormatName (const NumericFormatSymbol &formatName)=0
 
virtual void SSBL_ModifySpectralSelection (double &bottom, double &top, bool done)=0
 
- Public Member Functions inherited from TimeToolBarListener
 TimeToolBarListener ()
 
virtual ~TimeToolBarListener ()
 
virtual const NumericFormatSymbolTT_GetAudioTimeFormat ()=0
 
virtual void TT_SetAudioTimeFormat (const NumericFormatSymbol &format)=0
 

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}
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:28
double GetRate() const
Definition: ProjectRate.cpp:53

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}
static Settings & settings()
Definition: TrackInfo.cpp:87
static ProjectSettings & Get(AudacityProject &project)

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}
static ProjectHistory & Get(AudacityProject &project)
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:230
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159

References PackedArray::end(), ProjectHistory::Get(), ViewInfo::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}
void SetRate(double rate)
Definition: ProjectRate.cpp:58
void SetRate(double rate)
static SelectionBar & Get(AudacityProject &project)

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}
int format
Definition: ExportPCM.cpp:56
FileConfig * gPrefs
Definition: Prefs.cpp:71
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
Definition: FileConfig.cpp:143
void SetSelectionFormat(const NumericFormatSymbol &format)
void Refresh(bool eraseBackground=true, const wxRect *rect=(const wxRect *) NULL) override
Definition: TrackPanel.cpp:786

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
122
123 window.RedrawProject();
124
125 SelectionBar::Get( project ).SetSnapTo(snap);
126}
static ProjectWindow & Get(AudacityProject &project)
void SetSnapTo(int)

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

Definition at line 36 of file ProjectSelectionManager.cpp.

38{
39 return project.AttachedObjects::Get< ProjectSelectionManager >(
41}
static AudacityProject::AttachedObjects::RegisteredFactory sProjectSelectionManagerKey

References sProjectSelectionManagerKey.

Referenced by SelectFrequenciesCommand::Apply(), Get(), AUPImportFileHandle::Import(), ProjectManager::New(), PluginActions::Handler::OnResetConfig(), SelectActions::Handler::OnSnapToNearest(), SelectActions::Handler::OnSnapToOff(), SelectActions::Handler::OnSnapToPrior(), ProjectFileManager::OpenProjectFile(), and anonymous_namespace{HelpMenus.cpp}::QuickFixDialog::PopulateOrExchange().

Here is the caller graph for this function:

◆ 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}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
static ProjectSelectionManager & Get(AudacityProject &project)

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}
@ SNAP_NEAREST
@ SNAP_OFF
NumericConverter provides the advanced formatting control used in the selection bar of Audacity.

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}
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:486
A Track that contains audio waveform data.
Definition: WaveTrack.h:57
double GetRate() const override
Definition: WaveTrack.cpp:479

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}
int min(int a, int b)
double SSBL_GetRate() const override

References ProjectHistory::Get(), ViewInfo::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}
const wxString & Internal() const
void SetBandwidthSelectionFormatName(const NumericFormatSymbol &formatName)
static SpectralSelectionBar & Get(AudacityProject &project)

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}
void SetFrequencySelectionFormatName(const NumericFormatSymbol &formatName)

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}
void SetAudioTimeFormat(const NumericFormatSymbol &format)
static TimeToolBar & Get(AudacityProject &project)
Definition: TimeToolBar.cpp:65

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: