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 (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
 

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 324 of file SetTrackInfoCommand.cpp.

326{
327 static_cast<void>(context);
328 const auto wt = dynamic_cast<WaveTrack *>(&t);
329 if (!wt)
330 return true;
331 auto &wc = **wt->Channels().begin();
332 //auto pt = dynamic_cast<PlayableTrack *>(t);
333 static const double ZOOMLIMIT = 0.001f;
334
335 if (bHasColour)
337
338 if (bHasHeight)
339 for (auto pChannel : t.Channels<WaveChannel>())
341
342 if (bHasDisplayType) {
343 auto &view = WaveChannelView::Get(wc);
344 auto &all = WaveChannelSubViewType::All();
345 if (mDisplayType < all.size())
346 view.SetDisplay( all[ mDisplayType ].id );
347 else {
348 view.SetMultiView( true );
349 view.SetDisplay(WaveChannelSubViewType::Default(), false);
350 }
351 }
352 if (bHasScaleType) {
353 auto &scaleType = WaveformSettings::Get(*wt).scaleType;
354 switch (mScaleType) {
355 default:
358 case kLinearDb: scaleType = WaveformSettings::stLinearDb;
359 }
360 }
361
362 if (bHasVZoom) {
363 auto &cache = WaveformScale::Get(*wt);
364 switch( mVZoom ){
365 default:
366 case kReset: cache.SetDisplayBounds(-1,1); break;
367 case kTimes2: cache.SetDisplayBounds(-2,2); break;
368 case kHalfWave: cache.SetDisplayBounds(0,1); break;
369 }
370 }
371
373 float vzmin, vzmax;
374 auto &cache = WaveformScale::Get(*wt);
375 cache.GetDisplayBounds(vzmin, vzmax);
376
377 if ( !bHasVZoomTop ){
378 mVZoomTop = vzmax;
379 }
380 if ( !bHasVZoomBottom ){
381 mVZoomBottom = vzmin;
382 }
383
384 mVZoomTop = std::clamp(mVZoomTop, -2.0, 2.0);
385 mVZoomBottom = std::clamp(mVZoomBottom, -2.0, 2.0);
386
387 if (mVZoomBottom > mVZoomTop){
389 }
390 if ( mVZoomTop - mVZoomBottom < ZOOMLIMIT ){
391 double c = (mVZoomBottom + mVZoomTop) / 2;
392 mVZoomBottom = c - ZOOMLIMIT / 2.0;
393 mVZoomTop = c + ZOOMLIMIT / 2.0;
394 }
395 cache.SetDisplayBounds(mVZoomBottom, mVZoomTop);
396 auto &tp = TrackPanel::Get( context.project );
397 tp.UpdateVRulers();
398 }
399
400 if (bHasUseSpecPrefs) {
401 if (bUseSpecPrefs)
402 // reset it, and next we will be getting the defaults.
404 else
406 }
408 if (wt && bHasSpectralSelect)
409 settings.spectralSelection = bSpectralSelect;
410 if (wt && bHasSpecColorScheme)
411 settings.colorScheme =
413
414 return true;
415}
@ kLogarithmicDb
static Settings & settings()
Definition: TrackInfo.cpp:69
IteratorRange< ChannelIterator< ChannelType > > Channels()
Get range of channels with mutative access.
Definition: Channel.h:381
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:628
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 282 of file SetTrackInfoCommand.cpp.

283{
284 S.StartMultiColumn(3, wxEXPAND);
285 {
286 S.SetStretchyCol( 2 );
287 S.Optional( bHasHeight ).TieNumericTextBox( XXO("Height:"), mHeight );
288 S.Optional( bHasColour ).TieChoice( XXO("Color:"), mColour,
290
291 {
292 auto symbols = DiscoverSubViewTypes();
293 auto typeNames = transform_container<TranslatableStrings>(
294 symbols, std::mem_fn( &EnumValueSymbol::Stripped ) );
295 S.Optional( bHasDisplayType ).TieChoice( XXO("Display:"), mDisplayType,
296 typeNames );
297 }
298
299 S.Optional( bHasScaleType ).TieChoice( XXO("Scale:"), mScaleType,
301 S.Optional( bHasVZoom ).TieChoice( XXO("VZoom:"), mVZoom,
303 S.Optional( bHasVZoomTop ).TieTextBox( XXO("VZoom Top:"), mVZoomTop );
304 S.Optional( bHasVZoomBottom ).TieTextBox( XXO("VZoom Bottom:"), mVZoomBottom );
305 }
306 S.EndMultiColumn();
307 S.StartMultiColumn(2, wxEXPAND);
308 {
309 S.SetStretchyCol( 1 );
310 S.Optional( bHasUseSpecPrefs ).TieCheckBox( XXO("Use Spectral Prefs"), bUseSpecPrefs );
311 S.Optional( bHasSpectralSelect ).TieCheckBox( XXO("Spectral Select"), bSpectralSelect);
312 }
313 S.EndMultiColumn();
314 S.StartMultiColumn(3, wxEXPAND);
315 {
316 S.SetStretchyCol( 2 );
318 S.Optional( bHasSpecColorScheme).TieChoice( XC("Sche&me:", "spectrum prefs"), mSpecColorScheme,
319 Msgids( schemes.data(), schemes.size() ) );
320 }
321 S.EndMultiColumn();
322}
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 279 of file SetTrackInfoCommand.cpp.

280 { 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 276 of file SetTrackInfoCommand.cpp.

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

References S.

◆ VisitSettings() [3/3]

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

Definition at line 253 of file SetTrackInfoCommand.cpp.

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