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

A SetChannelsBase 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 SetChannelsBase 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 322 of file SetTrackInfoCommand.cpp.

324{
325 static_cast<void>(context);
326 const auto wt = dynamic_cast<WaveTrack *>(&t);
327 if (!wt)
328 return true;
329 //auto pt = dynamic_cast<PlayableTrack *>(t);
330 static const double ZOOMLIMIT = 0.001f;
331
332 if (bHasColour)
334
335 if (bHasHeight)
336 for (auto pChannel : t.Channels<WaveTrack>())
338
339 if (bHasDisplayType) {
340 auto &view = WaveChannelView::Get(*wt);
341 auto &all = WaveChannelSubViewType::All();
342 if (mDisplayType < all.size())
343 view.SetDisplay( all[ mDisplayType ].id );
344 else {
345 view.SetMultiView( true );
346 view.SetDisplay(WaveChannelSubViewType::Default(), false);
347 }
348 }
349 if (bHasScaleType) {
350 auto &scaleType = WaveformSettings::Get(*wt).scaleType;
351 switch (mScaleType) {
352 default:
355 case kLinearDb: scaleType = WaveformSettings::stLinearDb;
356 }
357 }
358
359 if (bHasVZoom) {
360 auto &cache = WaveformScale::Get(*wt);
361 switch( mVZoom ){
362 default:
363 case kReset: cache.SetDisplayBounds(-1,1); break;
364 case kTimes2: cache.SetDisplayBounds(-2,2); break;
365 case kHalfWave: cache.SetDisplayBounds(0,1); break;
366 }
367 }
368
370 float vzmin, vzmax;
371 auto &cache = WaveformScale::Get(*wt);
372 cache.GetDisplayBounds(vzmin, vzmax);
373
374 if ( !bHasVZoomTop ){
375 mVZoomTop = vzmax;
376 }
377 if ( !bHasVZoomBottom ){
378 mVZoomBottom = vzmin;
379 }
380
381 mVZoomTop = std::clamp(mVZoomTop, -2.0, 2.0);
382 mVZoomBottom = std::clamp(mVZoomBottom, -2.0, 2.0);
383
384 if (mVZoomBottom > mVZoomTop){
386 }
387 if ( mVZoomTop - mVZoomBottom < ZOOMLIMIT ){
388 double c = (mVZoomBottom + mVZoomTop) / 2;
389 mVZoomBottom = c - ZOOMLIMIT / 2.0;
390 mVZoomTop = c + ZOOMLIMIT / 2.0;
391 }
392 cache.SetDisplayBounds(mVZoomBottom, mVZoomTop);
393 auto &tp = TrackPanel::Get( context.project );
394 tp.UpdateVRulers();
395 }
396
397 if (bHasUseSpecPrefs) {
398 if (bUseSpecPrefs)
399 // reset it, and next we will be getting the defaults.
401 else
403 }
405 if (wt && bHasSpectralSelect)
406 settings.spectralSelection = bSpectralSelect;
407 if (wt && bHasSpecColorScheme)
408 settings.colorScheme =
410
411 return true;
412}
@ kLogarithmicDb
static Settings & settings()
Definition: TrackInfo.cpp:69
IteratorRange< ChannelIterator< ChannelType > > Channels()
Get range of channels with mutative access.
Definition: Channel.h:408
static ChannelView & Get(Channel &channel)
void SetExpandedHeight(int height)
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:233
static WaveChannelView & Get(WaveChannel &channel)
A Track that contains audio waveform data.
Definition: WaveTrack.h:227
void SetWaveColorIndex(int colorIndex)
Definition: WaveTrack.cpp:1233
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:645
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(), WaveChannelSubViewType::Default(), TrackPanel::Get(), ChannelView::Get(), SpectrogramSettings::Get(), WaveformSettings::Get(), WaveformScale::Get(), WaveChannelView::Get(), kHalfWave, kLinearAmp, kLinearDb, kLogarithmicDb, kReset, kTimes2, mColour, mDisplayType, mHeight, mScaleType, mSpecColorScheme, mVZoom, mVZoomBottom, mVZoomTop, SpectrogramSettings::Own(), CommandContext::project, SpectrogramSettings::Reset(), WaveformSettings::scaleType, ChannelView::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 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 280 of file SetTrackInfoCommand.cpp.

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

278 { 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 274 of file SetTrackInfoCommand.cpp.

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

References S.

◆ VisitSettings() [3/3]

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

Definition at line 251 of file SetTrackInfoCommand.cpp.

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