Audacity 3.2.0
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
SetTrackVisualsCommand Class Reference

A SetTrackBase that sets appearance of a track. More...

#include <SetTrackInfoCommand.h>

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

Public Member Functions

ComponentInterfaceSymbol GetSymbol () const override
 
TranslatableString GetDescription () const override
 
template<bool Const>
bool VisitSettings (SettingsVisitorBase< Const > &S)
 
bool VisitSettings (SettingsVisitor &S) override
 
bool VisitSettings (ConstSettingsVisitor &S) override
 
void PopulateOrExchange (ShuttleGui &S) override
 
ManualPageID ManualPage () override
 
bool ApplyInner (const CommandContext &context, Track &t) override
 
- Public Member Functions inherited from SetTrackBase
bool Apply (const CommandContext &context) final
 
virtual bool ApplyInner (const CommandContext &context, Track &t)=0
 
- Public Member Functions inherited from AudacityCommand
 AudacityCommand ()
 
virtual ~AudacityCommand ()
 
PluginPath GetPath () const override
 
VendorSymbol GetVendor () const override
 
wxString GetVersion () const override
 
ComponentInterfaceSymbol GetSymbol () const override=0
 
virtual TranslatableString GetDescription () const override
 
virtual ManualPageID ManualPage ()
 
virtual bool IsBatchProcessing () const
 
virtual void SetBatchProcessing (bool start)
 
virtual bool Apply (const CommandContext &WXUNUSED(context))
 
bool ShowInterface (wxWindow *parent, bool forceModal=false)
 
wxDialog * CreateUI (wxWindow *parent, AudacityCommand *client)
 
bool SaveSettingsAsString (wxString &parms)
 
bool LoadSettingsFromString (const wxString &parms)
 
bool DoAudacityCommand (const CommandContext &context, bool shouldPrompt=true)
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 
virtual bool Init ()
 
virtual bool PromptUser (AudacityProject &)
 
virtual bool CheckWhetherSkipAudacityCommand ()
 
virtual void End ()
 
virtual void PopulateOrExchange (ShuttleGui &WXUNUSED(S))
 
virtual bool TransferDataToWindow ()
 
virtual bool TransferDataFromWindow ()
 
virtual bool VisitSettings (SettingsVisitor &)
 
virtual bool VisitSettings (ConstSettingsVisitor &)
 
- Public Member Functions inherited from ComponentInterface
virtual ~ComponentInterface ()
 
virtual PluginPath GetPath () const =0
 
virtual ComponentInterfaceSymbol GetSymbol () const =0
 
virtual VendorSymbol GetVendor () const =0
 
virtual wxString GetVersion () const =0
 
virtual TranslatableString GetDescription () const =0
 
TranslatableString GetName () const
 

Public Attributes

int mColour
 
int mHeight
 
int mDisplayType
 
int mScaleType
 
int mVZoom
 
double mVZoomTop
 
double mVZoomBottom
 
bool bUseSpecPrefs
 
bool bSpectralSelect
 
int mSpecColorScheme
 
bool bHasColour
 
bool bHasHeight
 
bool bHasDisplayType
 
bool bHasScaleType
 
bool bHasVZoom
 
bool bHasVZoomTop
 
bool bHasVZoomBottom
 
bool bHasUseSpecPrefs
 
bool bHasSpectralSelect
 
bool bHasSpecColorScheme
 

Static Public Attributes

static const ComponentInterfaceSymbol Symbol { XO("Set Track Visuals") }
 

Additional Inherited Members

- Public Types inherited from AudacityCommand
enum  : long { DefaultMessageBoxStyle = wxOK | wxCENTRE }
 
- Protected Attributes inherited from AudacityCommand
ProgressDialogmProgress
 
wxDialog * mUIDialog
 
wxWindow * mUIParent
 

Detailed Description

A SetTrackBase that sets appearance of a track.

Definition at line 92 of file SetTrackInfoCommand.h.

Member Function Documentation

◆ ApplyInner()

bool SetTrackVisualsCommand::ApplyInner ( const CommandContext context,
Track t 
)
overridevirtual

Implements SetTrackBase.

Definition at line 325 of file SetTrackInfoCommand.cpp.

327{
328 static_cast<void>(context);
329 const auto wt = dynamic_cast<WaveTrack *>(&t);
330 if (!wt)
331 return true;
332 auto &wc = **wt->Channels().begin();
333 //auto pt = dynamic_cast<PlayableTrack *>(t);
334 static const double ZOOMLIMIT = 0.001f;
335
336 if (bHasColour)
338
339 if (bHasHeight)
340 for (auto pChannel : t.Channels<WaveChannel>())
342
343 if (bHasDisplayType) {
344 auto &view = WaveChannelView::Get(wc);
345 auto &all = WaveChannelSubViewType::All();
346 if (mDisplayType < all.size())
347 view.SetDisplay( all[ mDisplayType ].id );
348 else {
349 view.SetMultiView( true );
350 view.SetDisplay(WaveChannelSubViewType::Default(), false);
351 }
352 }
353 if (bHasScaleType) {
354 auto &scaleType = WaveformSettings::Get(*wt).scaleType;
355 switch (mScaleType) {
356 default:
359 case kLinearDb: scaleType = WaveformSettings::stLinearDb;
360 }
361 }
362
363 if (bHasVZoom) {
364 auto &cache = WaveformScale::Get(*wt);
365 switch( mVZoom ){
366 default:
367 case kReset: cache.SetDisplayBounds(-1,1); break;
368 case kTimes2: cache.SetDisplayBounds(-2,2); break;
369 case kHalfWave: cache.SetDisplayBounds(0,1); break;
370 }
371 }
372
374 float vzmin, vzmax;
375 auto &cache = WaveformScale::Get(*wt);
376 cache.GetDisplayBounds(vzmin, vzmax);
377
378 if ( !bHasVZoomTop ){
379 mVZoomTop = vzmax;
380 }
381 if ( !bHasVZoomBottom ){
382 mVZoomBottom = vzmin;
383 }
384
385 mVZoomTop = std::clamp(mVZoomTop, -2.0, 2.0);
386 mVZoomBottom = std::clamp(mVZoomBottom, -2.0, 2.0);
387
388 if (mVZoomBottom > mVZoomTop){
390 }
391 if ( mVZoomTop - mVZoomBottom < ZOOMLIMIT ){
392 double c = (mVZoomBottom + mVZoomTop) / 2;
393 mVZoomBottom = c - ZOOMLIMIT / 2.0;
394 mVZoomTop = c + ZOOMLIMIT / 2.0;
395 }
396 cache.SetDisplayBounds(mVZoomBottom, mVZoomTop);
397 auto &tp = TrackPanel::Get( context.project );
398 tp.UpdateVRulers();
399 }
400
401 if (bHasUseSpecPrefs) {
402 if (bUseSpecPrefs)
403 // reset it, and next we will be getting the defaults.
405 else
407 }
409 if (wt && bHasSpectralSelect)
410 settings.spectralSelection = bSpectralSelect;
411 if (wt && bHasSpecColorScheme)
412 settings.colorScheme =
414
415 return true;
416}
@ kLogarithmicDb
static Settings & settings()
Definition: TrackInfo.cpp:51
IteratorRange< ChannelIterator< ChannelType > > Channels()
Get range of channels with mutative access.
Definition: Channel.h:384
static ChannelView & Get(Channel &channel)
void SetExpandedHeight(int height)
AudacityProject & project
static SpectrogramSettings & Get(const WaveTrack &track)
static SpectrogramSettings & Own(WaveChannel &wc)
static void Reset(WaveChannel &channel)
Make channel lose indpendent settings and use defaults.
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:234
static WaveChannelView & Get(WaveChannel &channel)
A Track that contains audio waveform data.
Definition: WaveTrack.h:203
auto Channels()
Definition: WaveTrack.h:263
static WaveformAppearance & Get(WaveTrack &track)
void SetColorIndex(int colorIndex)
static WaveformScale & Get(const WaveTrack &track)
Mutative access to attachment even if the track argument is const.
static WaveformSettings & Get(const WaveTrack &track)
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:634
static Display Default()
Return a preferred type.
static const std::vector< WaveChannelSubViewType > & All()
Discover all registered types.

References WaveChannelSubViewType::All(), bHasColour, bHasDisplayType, bHasHeight, bHasScaleType, bHasSpecColorScheme, bHasSpectralSelect, bHasUseSpecPrefs, bHasVZoom, bHasVZoomBottom, bHasVZoomTop, bSpectralSelect, bUseSpecPrefs, ChannelGroup::Channels(), WaveTrack::Channels(), WaveChannelSubViewType::Default(), TrackPanel::Get(), ChannelView::Get(), SpectrogramSettings::Get(), WaveformSettings::Get(), WaveformScale::Get(), WaveChannelView::Get(), WaveformAppearance::Get(), kHalfWave, kLinearAmp, kLinearDb, kLogarithmicDb, kReset, kTimes2, mColour, mDisplayType, mHeight, mScaleType, mSpecColorScheme, mVZoom, mVZoomBottom, mVZoomTop, SpectrogramSettings::Own(), CommandContext::project, SpectrogramSettings::Reset(), WaveformSettings::scaleType, WaveformAppearance::SetColorIndex(), ChannelView::SetExpandedHeight(), settings(), WaveformSettings::stLinearAmp, WaveformSettings::stLinearDb, WaveformSettings::stLogarithmicDb, and anonymous_namespace{NoteTrack.cpp}::swap().

Referenced by SetTrackCommand::ApplyInner().

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

◆ GetDescription()

TranslatableString SetTrackVisualsCommand::GetDescription ( ) const
inlineoverridevirtual

Reimplemented from AudacityCommand.

Definition at line 100 of file SetTrackInfoCommand.h.

100{return XO("Sets various values for a track.");};
XO("Cut/Copy/Paste")

References XO().

Here is the call graph for this function:

◆ GetSymbol()

ComponentInterfaceSymbol SetTrackVisualsCommand::GetSymbol ( ) const
inlineoverridevirtual

Implements AudacityCommand.

Definition at line 99 of file SetTrackInfoCommand.h.

99{return Symbol;};
static const ComponentInterfaceSymbol Symbol

References Symbol.

◆ ManualPage()

ManualPageID SetTrackVisualsCommand::ManualPage ( )
inlineoverridevirtual

Reimplemented from AudacityCommand.

Definition at line 107 of file SetTrackInfoCommand.h.

107{return L"Extra_Menu:_Scriptables_I#set_track_visuals";}

◆ PopulateOrExchange()

void SetTrackVisualsCommand::PopulateOrExchange ( ShuttleGui S)
override

Definition at line 283 of file SetTrackInfoCommand.cpp.

284{
285 S.StartMultiColumn(3, wxEXPAND);
286 {
287 S.SetStretchyCol( 2 );
288 S.Optional( bHasHeight ).TieNumericTextBox( XXO("Height:"), mHeight );
289 S.Optional( bHasColour ).TieChoice( XXO("Color:"), mColour,
291
292 {
293 auto symbols = DiscoverSubViewTypes();
294 auto typeNames = transform_container<TranslatableStrings>(
295 symbols, std::mem_fn( &EnumValueSymbol::Stripped ) );
296 S.Optional( bHasDisplayType ).TieChoice( XXO("Display:"), mDisplayType,
297 typeNames );
298 }
299
300 S.Optional( bHasScaleType ).TieChoice( XXO("Scale:"), mScaleType,
302 S.Optional( bHasVZoom ).TieChoice( XXO("VZoom:"), mVZoom,
304 S.Optional( bHasVZoomTop ).TieTextBox( XXO("VZoom Top:"), mVZoomTop );
305 S.Optional( bHasVZoomBottom ).TieTextBox( XXO("VZoom Bottom:"), mVZoomBottom );
306 }
307 S.EndMultiColumn();
308 S.StartMultiColumn(2, wxEXPAND);
309 {
310 S.SetStretchyCol( 1 );
311 S.Optional( bHasUseSpecPrefs ).TieCheckBox( XXO("Use Spectral Prefs"), bUseSpecPrefs );
312 S.Optional( bHasSpectralSelect ).TieCheckBox( XXO("Spectral Select"), bSpectralSelect);
313 }
314 S.EndMultiColumn();
315 S.StartMultiColumn(3, wxEXPAND);
316 {
317 S.SetStretchyCol( 2 );
319 S.Optional( bHasSpecColorScheme).TieChoice( XC("Sche&me:", "spectrum prefs"), mSpecColorScheme,
320 Msgids( schemes.data(), schemes.size() ) );
321 }
322 S.EndMultiColumn();
323}
XXO("&Cut/Copy/Paste Toolbar")
#define XC(s, c)
Definition: Internat.h:37
static const EnumValueSymbol kScaleTypeStrings[nScaleTypes]
static const EnumValueSymbol kZoomTypeStrings[nZoomTypes]
static EnumValueSymbols DiscoverSubViewTypes()
static const EnumValueSymbol kColourStrings[nColours]
TranslatableStrings Msgids(const EnumValueSymbol strings[], size_t nStrings)
Convenience function often useful when adding choice controls.
#define S(N)
Definition: ToChars.cpp:64
const TranslatableString Stripped() const
static const EnumValueSymbols & GetColorSchemeNames()

References bHasColour, bHasDisplayType, bHasHeight, bHasScaleType, bHasSpecColorScheme, bHasSpectralSelect, bHasUseSpecPrefs, bHasVZoom, bHasVZoomBottom, bHasVZoomTop, bSpectralSelect, bUseSpecPrefs, DiscoverSubViewTypes(), SpectrogramSettings::GetColorSchemeNames(), kColourStrings, kScaleTypeStrings, kZoomTypeStrings, mColour, mDisplayType, mHeight, mScaleType, Msgids(), mSpecColorScheme, mVZoom, mVZoomBottom, mVZoomTop, nColours, nScaleTypes, nZoomTypes, S, ComponentInterfaceSymbol::Stripped(), XC, and XXO().

Referenced by SetTrackCommand::PopulateOrExchange().

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

◆ VisitSettings() [1/3]

bool SetTrackVisualsCommand::VisitSettings ( ConstSettingsVisitor )
overridevirtual

Visit settings, if defined. false means no defined settings. Default implementation returns false

Reimplemented from AudacityCommand.

Definition at line 280 of file SetTrackInfoCommand.cpp.

281 { return VisitSettings<true>(S); }

References S.

◆ VisitSettings() [2/3]

bool SetTrackVisualsCommand::VisitSettings ( SettingsVisitor )
overridevirtual

Visit settings, if defined. false means no defined settings. Default implementation returns false

Reimplemented from AudacityCommand.

Definition at line 277 of file SetTrackInfoCommand.cpp.

278 { return VisitSettings<false>(S); }

References S.

◆ VisitSettings() [3/3]

template<bool Const>
bool SetTrackVisualsCommand::VisitSettings ( SettingsVisitorBase< Const > &  S)

Definition at line 254 of file SetTrackInfoCommand.cpp.

254 {
255 S.OptionalN( bHasHeight ).Define( mHeight, wxT("Height"), 120, 44, 2000 );
256
257 {
258 auto symbols = DiscoverSubViewTypes();
259 S.OptionalN( bHasDisplayType ).DefineEnum( mDisplayType, wxT("Display"), 0, symbols.data(), symbols.size() );
260 }
261
262 S.OptionalN( bHasScaleType ).DefineEnum( mScaleType, wxT("Scale"), kLinearAmp, kScaleTypeStrings, nScaleTypes );
263 S.OptionalN( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, kColourStrings, nColours );
264 S.OptionalN( bHasVZoom ).DefineEnum( mVZoom, wxT("VZoom"), kReset, kZoomTypeStrings, nZoomTypes );
265 S.OptionalN( bHasVZoomTop ).Define( mVZoomTop, wxT("VZoomHigh"), 1.0, -2.0, 2.0 );
266 S.OptionalN( bHasVZoomBottom ).Define( mVZoomBottom, wxT("VZoomLow"), -1.0, -2.0, 2.0 );
267
268 S.OptionalN( bHasUseSpecPrefs ).Define( bUseSpecPrefs, wxT("SpecPrefs"), false );
269 S.OptionalN( bHasSpectralSelect ).Define( bSpectralSelect, wxT("SpectralSel"),true );
270
272 S.OptionalN( bHasSpecColorScheme).DefineEnum( mSpecColorScheme,wxT("SpecColor"), SpectrogramSettings::csColorNew, schemes.data(), schemes.size());
273
274 return true;
275};
wxT("CloseDown"))

References bHasColour, bHasDisplayType, bHasHeight, bHasScaleType, bHasSpecColorScheme, bHasSpectralSelect, bHasUseSpecPrefs, bHasVZoom, bHasVZoomBottom, bHasVZoomTop, bSpectralSelect, bUseSpecPrefs, SpectrogramSettings::csColorNew, DiscoverSubViewTypes(), SpectrogramSettings::GetColorSchemeNames(), kColour0, kColourStrings, kLinearAmp, kReset, kScaleTypeStrings, kZoomTypeStrings, mColour, mDisplayType, mHeight, mScaleType, mSpecColorScheme, mVZoom, mVZoomBottom, mVZoomTop, nColours, nScaleTypes, nZoomTypes, S, and wxT().

Referenced by SetTrackCommand::VisitSettings().

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

Member Data Documentation

◆ bHasColour

bool SetTrackVisualsCommand::bHasColour

Definition at line 124 of file SetTrackInfoCommand.h.

Referenced by ApplyInner(), PopulateOrExchange(), and VisitSettings().

◆ bHasDisplayType

bool SetTrackVisualsCommand::bHasDisplayType

Definition at line 126 of file SetTrackInfoCommand.h.

Referenced by ApplyInner(), PopulateOrExchange(), and VisitSettings().

◆ bHasHeight

bool SetTrackVisualsCommand::bHasHeight

Definition at line 125 of file SetTrackInfoCommand.h.

Referenced by ApplyInner(), PopulateOrExchange(), and VisitSettings().

◆ bHasScaleType

bool SetTrackVisualsCommand::bHasScaleType

Definition at line 127 of file SetTrackInfoCommand.h.

Referenced by ApplyInner(), PopulateOrExchange(), and VisitSettings().

◆ bHasSpecColorScheme

bool SetTrackVisualsCommand::bHasSpecColorScheme

Definition at line 134 of file SetTrackInfoCommand.h.

Referenced by ApplyInner(), PopulateOrExchange(), and VisitSettings().

◆ bHasSpectralSelect

bool SetTrackVisualsCommand::bHasSpectralSelect

Definition at line 133 of file SetTrackInfoCommand.h.

Referenced by ApplyInner(), PopulateOrExchange(), and VisitSettings().

◆ bHasUseSpecPrefs

bool SetTrackVisualsCommand::bHasUseSpecPrefs

Definition at line 132 of file SetTrackInfoCommand.h.

Referenced by ApplyInner(), PopulateOrExchange(), and VisitSettings().

◆ bHasVZoom

bool SetTrackVisualsCommand::bHasVZoom

Definition at line 128 of file SetTrackInfoCommand.h.

Referenced by ApplyInner(), PopulateOrExchange(), and VisitSettings().

◆ bHasVZoomBottom

bool SetTrackVisualsCommand::bHasVZoomBottom

Definition at line 130 of file SetTrackInfoCommand.h.

Referenced by ApplyInner(), PopulateOrExchange(), and VisitSettings().

◆ bHasVZoomTop

bool SetTrackVisualsCommand::bHasVZoomTop

Definition at line 129 of file SetTrackInfoCommand.h.

Referenced by ApplyInner(), PopulateOrExchange(), and VisitSettings().

◆ bSpectralSelect

bool SetTrackVisualsCommand::bSpectralSelect

Definition at line 120 of file SetTrackInfoCommand.h.

Referenced by ApplyInner(), PopulateOrExchange(), and VisitSettings().

◆ bUseSpecPrefs

bool SetTrackVisualsCommand::bUseSpecPrefs

Definition at line 119 of file SetTrackInfoCommand.h.

Referenced by ApplyInner(), PopulateOrExchange(), and VisitSettings().

◆ mColour

int SetTrackVisualsCommand::mColour

Definition at line 111 of file SetTrackInfoCommand.h.

Referenced by ApplyInner(), PopulateOrExchange(), and VisitSettings().

◆ mDisplayType

int SetTrackVisualsCommand::mDisplayType

Definition at line 113 of file SetTrackInfoCommand.h.

Referenced by ApplyInner(), PopulateOrExchange(), and VisitSettings().

◆ mHeight

int SetTrackVisualsCommand::mHeight

Definition at line 112 of file SetTrackInfoCommand.h.

Referenced by ApplyInner(), PopulateOrExchange(), and VisitSettings().

◆ mScaleType

int SetTrackVisualsCommand::mScaleType

Definition at line 114 of file SetTrackInfoCommand.h.

Referenced by ApplyInner(), PopulateOrExchange(), and VisitSettings().

◆ mSpecColorScheme

int SetTrackVisualsCommand::mSpecColorScheme

Definition at line 121 of file SetTrackInfoCommand.h.

Referenced by ApplyInner(), PopulateOrExchange(), and VisitSettings().

◆ mVZoom

int SetTrackVisualsCommand::mVZoom

Definition at line 115 of file SetTrackInfoCommand.h.

Referenced by ApplyInner(), PopulateOrExchange(), and VisitSettings().

◆ mVZoomBottom

double SetTrackVisualsCommand::mVZoomBottom

Definition at line 117 of file SetTrackInfoCommand.h.

Referenced by ApplyInner(), PopulateOrExchange(), and VisitSettings().

◆ mVZoomTop

double SetTrackVisualsCommand::mVZoomTop

Definition at line 116 of file SetTrackInfoCommand.h.

Referenced by ApplyInner(), PopulateOrExchange(), and VisitSettings().

◆ Symbol

const ComponentInterfaceSymbol SetTrackVisualsCommand::Symbol { XO("Set Track Visuals") }
static

Definition at line 95 of file SetTrackInfoCommand.h.

Referenced by GetSymbol().


The documentation for this class was generated from the following files: