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
 SetTrackBase ()
 
bool Apply (const CommandContext &context) override
 
virtual bool ApplyInner (const CommandContext &context, Track *t)
 
template<bool Const>
bool VisitSettings (SettingsVisitorBase< Const > &S)
 
bool VisitSettings (SettingsVisitor &S) override
 
bool VisitSettings (ConstSettingsVisitor &S) override
 
virtual void PopulateOrExchange (ShuttleGui &S) override
 
- 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 (wxWindow *parent, const CommandContext &context, bool shouldPrompt=true)
 
int MessageBox (const TranslatableString &message, long style=DefaultMessageBoxStyle, const TranslatableString &titleStr={})
 
virtual bool Init ()
 
virtual bool PromptUser (wxWindow *parent)
 
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
 
- Public Attributes inherited from SetTrackBase
int mTrackIndex
 
int mChannelIndex
 
bool bHasTrackIndex
 
bool bHasChannelIndex
 
bool bIsSecondChannel
 
bool mbPromptForTracks
 

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 106 of file SetTrackInfoCommand.h.

Member Function Documentation

◆ ApplyInner()

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

Reimplemented from SetTrackBase.

Definition at line 406 of file SetTrackInfoCommand.cpp.

407{
408 static_cast<void>(context);
409 auto wt = dynamic_cast<WaveTrack *>(t);
410 //auto pt = dynamic_cast<PlayableTrack *>(t);
411 static const double ZOOMLIMIT = 0.001f;
412
413 // You can get some intriguing effects by setting R and L channels to
414 // different values.
415 if( wt && bHasColour )
417
418 if( t && bHasHeight )
420
421 if( wt && bHasDisplayType ) {
422 auto &view = WaveTrackView::Get( *wt );
423 auto &all = WaveTrackSubViewType::All();
424 if (mDisplayType < all.size())
425 view.SetDisplay( all[ mDisplayType ].id );
426 else {
427 view.SetMultiView( true );
428 view.SetDisplay( WaveTrackSubViewType::Default(), false );
429 }
430 }
431 if (wt && bHasScaleType) {
432 auto &scaleType = WaveformSettings::Get(*wt).scaleType;
433 switch (mScaleType) {
434 default:
437 case kLinearDb: scaleType = WaveformSettings::stLinearDb;
438 }
439 }
440
441 if( wt && bHasVZoom ){
442 auto &cache = WaveformScale::Get(*wt);
443 switch( mVZoom ){
444 default:
445 case kReset: cache.SetDisplayBounds(-1,1); break;
446 case kTimes2: cache.SetDisplayBounds(-2,2); break;
447 case kHalfWave: cache.SetDisplayBounds(0,1); break;
448 }
449 }
450
451 if ( wt && (bHasVZoomTop || bHasVZoomBottom) && !bHasVZoom){
452 float vzmin, vzmax;
453 auto &cache = WaveformScale::Get(*wt);
454 cache.GetDisplayBounds(vzmin, vzmax);
455
456 if ( !bHasVZoomTop ){
457 mVZoomTop = vzmax;
458 }
459 if ( !bHasVZoomBottom ){
460 mVZoomBottom = vzmin;
461 }
462
463 // Can't use std::clamp until C++17
464 mVZoomTop = std::max(-2.0, std::min(mVZoomTop, 2.0));
465 mVZoomBottom = std::max(-2.0, std::min(mVZoomBottom, 2.0));
466
467 if (mVZoomBottom > mVZoomTop){
469 }
470 if ( mVZoomTop - mVZoomBottom < ZOOMLIMIT ){
471 double c = (mVZoomBottom + mVZoomTop) / 2;
472 mVZoomBottom = c - ZOOMLIMIT / 2.0;
473 mVZoomTop = c + ZOOMLIMIT / 2.0;
474 }
475 cache.SetDisplayBounds(mVZoomBottom, mVZoomTop);
476 auto &tp = TrackPanel::Get( context.project );
477 tp.UpdateVRulers();
478 }
479
480 if( wt && bHasUseSpecPrefs ){
481 if( bUseSpecPrefs ){
482 // reset it, and next we will be getting the defaults.
484 }
485 else {
487 }
488 }
490 if (wt && bHasSpectralSelect)
491 settings.spectralSelection = bSpectralSelect;
492 if (wt && bHasSpecColorScheme)
493 settings.colorScheme =
495
496 return true;
497}
int min(int a, int b)
@ kLogarithmicDb
static Settings & settings()
Definition: TrackInfo.cpp:87
AudacityProject & project
static void Reset(WaveTrack &track)
Make track lose indpendent settings and use defaults.
static SpectrogramSettings & Get(const WaveTrack &track)
Mutative access to attachment even if the track argument is const.
static SpectrogramSettings & Own(WaveTrack &track)
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:231
void SetExpandedHeight(int height)
Definition: TrackView.cpp:172
static TrackView & Get(Track &)
Definition: TrackView.cpp:69
A Track that contains audio waveform data.
Definition: WaveTrack.h:51
void SetWaveColorIndex(int colorIndex)
Definition: WaveTrack.cpp:437
static WaveTrackView & Get(WaveTrack &track)
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:752
static const std::vector< WaveTrackSubViewType > & All()
Discover all registered types.
static Display Default()
Return a preferred type.

References WaveTrackSubViewType::All(), bHasColour, bHasDisplayType, bHasHeight, bHasScaleType, bHasSpecColorScheme, bHasSpectralSelect, bHasUseSpecPrefs, bHasVZoom, bHasVZoomBottom, bHasVZoomTop, bSpectralSelect, bUseSpecPrefs, WaveTrackSubViewType::Default(), TrackPanel::Get(), SpectrogramSettings::Get(), WaveformSettings::Get(), WaveformScale::Get(), TrackView::Get(), WaveTrackView::Get(), kHalfWave, kLinearAmp, kLinearDb, kLogarithmicDb, kReset, kTimes2, mColour, mDisplayType, mHeight, min(), mScaleType, mSpecColorScheme, mVZoom, mVZoomBottom, mVZoomTop, SpectrogramSettings::Own(), CommandContext::project, SpectrogramSettings::Reset(), WaveformSettings::scaleType, TrackView::SetExpandedHeight(), settings(), WaveTrack::SetWaveColorIndex(), 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 114 of file SetTrackInfoCommand.h.

114{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 113 of file SetTrackInfoCommand.h.

113{return Symbol;};
static const ComponentInterfaceSymbol Symbol

References Symbol.

◆ ManualPage()

ManualPageID SetTrackVisualsCommand::ManualPage ( )
inlineoverridevirtual

Reimplemented from AudacityCommand.

Definition at line 121 of file SetTrackInfoCommand.h.

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

◆ PopulateOrExchange()

void SetTrackVisualsCommand::PopulateOrExchange ( ShuttleGui S)
overridevirtual

Reimplemented from SetTrackBase.

Definition at line 363 of file SetTrackInfoCommand.cpp.

364{
366 S.StartMultiColumn(3, wxEXPAND);
367 {
368 S.SetStretchyCol( 2 );
369 S.Optional( bHasHeight ).TieNumericTextBox( XXO("Height:"), mHeight );
370 S.Optional( bHasColour ).TieChoice( XXO("Color:"), mColour,
372
373 {
374 auto symbols = DiscoverSubViewTypes();
375 auto typeNames = transform_container<TranslatableStrings>(
376 symbols, std::mem_fn( &EnumValueSymbol::Stripped ) );
377 S.Optional( bHasDisplayType ).TieChoice( XXO("Display:"), mDisplayType,
378 typeNames );
379 }
380
381 S.Optional( bHasScaleType ).TieChoice( XXO("Scale:"), mScaleType,
383 S.Optional( bHasVZoom ).TieChoice( XXO("VZoom:"), mVZoom,
385 S.Optional( bHasVZoomTop ).TieTextBox( XXO("VZoom Top:"), mVZoomTop );
386 S.Optional( bHasVZoomBottom ).TieTextBox( XXO("VZoom Bottom:"), mVZoomBottom );
387 }
388 S.EndMultiColumn();
389 S.StartMultiColumn(2, wxEXPAND);
390 {
391 S.SetStretchyCol( 1 );
392 S.Optional( bHasUseSpecPrefs ).TieCheckBox( XXO("Use Spectral Prefs"), bUseSpecPrefs );
393 S.Optional( bHasSpectralSelect ).TieCheckBox( XXO("Spectral Select"), bSpectralSelect);
394 }
395 S.EndMultiColumn();
396 S.StartMultiColumn(3, wxEXPAND);
397 {
398 S.SetStretchyCol( 2 );
400 S.Optional( bHasSpecColorScheme).TieChoice( XC("Sche&me", "spectrum prefs"), mSpecColorScheme,
401 Msgids( schemes.data(), schemes.size() ) );
402 }
403 S.EndMultiColumn();
404}
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
virtual void PopulateOrExchange(ShuttleGui &S) override
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, SetTrackBase::PopulateOrExchange(), 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 SetTrackBase.

Definition at line 360 of file SetTrackInfoCommand.cpp.

361 { 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 SetTrackBase.

Definition at line 357 of file SetTrackInfoCommand.cpp.

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

References S.

◆ VisitSettings() [3/3]

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

Definition at line 333 of file SetTrackInfoCommand.cpp.

333 {
335 S.OptionalN( bHasHeight ).Define( mHeight, wxT("Height"), 120, 44, 2000 );
336
337 {
338 auto symbols = DiscoverSubViewTypes();
339 S.OptionalN( bHasDisplayType ).DefineEnum( mDisplayType, wxT("Display"), 0, symbols.data(), symbols.size() );
340 }
341
342 S.OptionalN( bHasScaleType ).DefineEnum( mScaleType, wxT("Scale"), kLinearAmp, kScaleTypeStrings, nScaleTypes );
343 S.OptionalN( bHasColour ).DefineEnum( mColour, wxT("Color"), kColour0, kColourStrings, nColours );
344 S.OptionalN( bHasVZoom ).DefineEnum( mVZoom, wxT("VZoom"), kReset, kZoomTypeStrings, nZoomTypes );
345 S.OptionalN( bHasVZoomTop ).Define( mVZoomTop, wxT("VZoomHigh"), 1.0, -2.0, 2.0 );
346 S.OptionalN( bHasVZoomBottom ).Define( mVZoomBottom, wxT("VZoomLow"), -1.0, -2.0, 2.0 );
347
348 S.OptionalN( bHasUseSpecPrefs ).Define( bUseSpecPrefs, wxT("SpecPrefs"), false );
349 S.OptionalN( bHasSpectralSelect ).Define( bSpectralSelect, wxT("SpectralSel"),true );
350
352 S.OptionalN( bHasSpecColorScheme).DefineEnum( mSpecColorScheme,wxT("SpecColor"), SpectrogramSettings::csColorNew, schemes.data(), schemes.size());
353
354 return true;
355};
wxT("CloseDown"))
bool VisitSettings(SettingsVisitorBase< Const > &S)

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, SetTrackBase::VisitSettings(), 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 138 of file SetTrackInfoCommand.h.

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

◆ bHasDisplayType

bool SetTrackVisualsCommand::bHasDisplayType

Definition at line 140 of file SetTrackInfoCommand.h.

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

◆ bHasHeight

bool SetTrackVisualsCommand::bHasHeight

Definition at line 139 of file SetTrackInfoCommand.h.

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

◆ bHasScaleType

bool SetTrackVisualsCommand::bHasScaleType

Definition at line 141 of file SetTrackInfoCommand.h.

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

◆ bHasSpecColorScheme

bool SetTrackVisualsCommand::bHasSpecColorScheme

Definition at line 148 of file SetTrackInfoCommand.h.

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

◆ bHasSpectralSelect

bool SetTrackVisualsCommand::bHasSpectralSelect

Definition at line 147 of file SetTrackInfoCommand.h.

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

◆ bHasUseSpecPrefs

bool SetTrackVisualsCommand::bHasUseSpecPrefs

Definition at line 146 of file SetTrackInfoCommand.h.

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

◆ bHasVZoom

bool SetTrackVisualsCommand::bHasVZoom

Definition at line 142 of file SetTrackInfoCommand.h.

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

◆ bHasVZoomBottom

bool SetTrackVisualsCommand::bHasVZoomBottom

Definition at line 144 of file SetTrackInfoCommand.h.

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

◆ bHasVZoomTop

bool SetTrackVisualsCommand::bHasVZoomTop

Definition at line 143 of file SetTrackInfoCommand.h.

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

◆ bSpectralSelect

bool SetTrackVisualsCommand::bSpectralSelect

Definition at line 134 of file SetTrackInfoCommand.h.

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

◆ bUseSpecPrefs

bool SetTrackVisualsCommand::bUseSpecPrefs

Definition at line 133 of file SetTrackInfoCommand.h.

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

◆ mColour

int SetTrackVisualsCommand::mColour

Definition at line 125 of file SetTrackInfoCommand.h.

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

◆ mDisplayType

int SetTrackVisualsCommand::mDisplayType

Definition at line 127 of file SetTrackInfoCommand.h.

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

◆ mHeight

int SetTrackVisualsCommand::mHeight

Definition at line 126 of file SetTrackInfoCommand.h.

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

◆ mScaleType

int SetTrackVisualsCommand::mScaleType

Definition at line 128 of file SetTrackInfoCommand.h.

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

◆ mSpecColorScheme

int SetTrackVisualsCommand::mSpecColorScheme

Definition at line 135 of file SetTrackInfoCommand.h.

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

◆ mVZoom

int SetTrackVisualsCommand::mVZoom

Definition at line 129 of file SetTrackInfoCommand.h.

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

◆ mVZoomBottom

double SetTrackVisualsCommand::mVZoomBottom

Definition at line 131 of file SetTrackInfoCommand.h.

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

◆ mVZoomTop

double SetTrackVisualsCommand::mVZoomTop

Definition at line 130 of file SetTrackInfoCommand.h.

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

◆ Symbol

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

Definition at line 109 of file SetTrackInfoCommand.h.

Referenced by GetSymbol().


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