Audacity 3.2.0
Classes | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes | List of all members
Ruler Class Reference

Used to display a Ruler. More...

#include <Ruler.h>

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

Classes

struct  Cache
 
struct  TickLengths
 

Public Member Functions

 Ruler (const RulerUpdater &updater, const RulerFormat &format)
 
 ~Ruler ()
 
void SetBounds (int left, int top, int right, int bottom)
 
void SetOrientation (int orient)
 
void SetRange (double min, double max)
 
void SetRange (double min, double max, double hiddenMin, double hiddenMax)
 
void SetUpdater (const RulerUpdater *pUpdater)
 
void SetTwoTone (bool twoTone)
 
void SetFormat (const RulerFormat *pFormat)
 
void SetUnits (const TranslatableString &units)
 
void SetDbMirrorValue (const double d)
 
void SetLabelEdges (bool labelEdges)
 
void SetFlip (bool flip)
 
void SetMinor (bool value)
 
void SetFonts (const wxFont &minorFont, const wxFont &majorFont, const wxFont &minorMinorFont)
 
RulerStruct::Fonts GetFonts () const
 
void SetNumberScale (const NumberScale &scale)
 
void SetTickLengths (const TickLengths &tLengths)
 
void OfflimitsPixels (int start, int end)
 
void GetMaxSize (wxCoord *width, wxCoord *height)
 
void Draw (wxDC &dc) const
 
void Draw (wxDC &dc, const Envelope *envelope) const
 
void DrawGrid (wxDC &dc, int length, bool minor=true, bool major=true, int xOffset=0, int yOffset=0) const
 
void SetTickColour (const wxColour &colour)
 
void Invalidate ()
 
- Public Member Functions inherited from Observer::Publisher< RulerInvalidatedMessage >
 Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={})
 Constructor supporting type-erased custom allocation/deletion. More...
 
 Publisher (Publisher &&)=default
 
Publisheroperator= (Publisher &&)=default
 
Subscription Subscribe (Callback callback)
 Connect a callback to the Publisher; later-connected are called earlier. More...
 
Subscription Subscribe (Object &obj, Return(Object::*callback)(Args...))
 Overload of Subscribe takes an object and pointer-to-member-function. More...
 

Public Attributes

bool mbTicksOnly
 
bool mbTicksAtExtremes
 

Private Member Functions

void ChooseFonts (wxDC &dc) const
 
void UpdateCache (wxDC &dc, const Envelope *envelope) const
 
int FindZero (const RulerUpdater::Labels &labels) const
 
int GetZeroPosition () const
 

Private Attributes

RulerStruct mRulerStruct
 
TickLengths mTickLengths
 
wxColour mTickColour
 
wxPen mPen
 
std::unique_ptr< RulerStruct::FontsmpUserFonts
 
const RulerUpdatermpUpdater {}
 
RulerUpdater::Bits mUserBits
 
std::unique_ptr< CachempCache
 
bool mbMinor
 
bool mTwoTone
 

Additional Inherited Members

- Public Types inherited from Observer::Publisher< RulerInvalidatedMessage >
using message_type = RulerInvalidatedMessage
 
using CallbackReturn = std::conditional_t< true, void, bool >
 
using Callback = std::function< CallbackReturn(const RulerInvalidatedMessage &) >
 Type of functions that can be connected to the Publisher. More...
 
- Static Public Attributes inherited from Observer::Publisher< RulerInvalidatedMessage >
static constexpr bool notifies_all
 
- Protected Member Functions inherited from Observer::Publisher< RulerInvalidatedMessage >
CallbackReturn Publish (const RulerInvalidatedMessage &message)
 Send a message to connected callbacks. More...
 

Detailed Description

Used to display a Ruler.

This is a generic class which can be used to display just about any kind of ruler.

At a minimum, the user must specify the dimensions of the ruler, its orientation (horizontal or vertical), and the values displayed at the two ends of the ruler (min and max). By default, this class will display tick marks at reasonable round numbers and fractions, for example, 100, 50, 10, 5, 1, 0.5, 0.1, etc.

The class is designed to display a small handful of labeled Major ticks, and a few Minor ticks between each of these. Minor ticks are labeled if there is enough space. Labels will never run into each other.

In addition to Real numbers, the Ruler currently supports two other formats for its display:

Integer - never shows tick marks for fractions of an integer

Time - Assumes values represent seconds, and labels the tick marks in "HH:MM:SS" format, e.g. 4000 seconds becomes "1:06:40", for example. Will display fractions of a second, and tick marks are all reasonable round numbers for time (i.e. 15 seconds, 30 seconds, etc.)

Definition at line 32 of file Ruler.h.

Constructor & Destructor Documentation

◆ Ruler()

Ruler::Ruler ( const RulerUpdater updater,
const RulerFormat format 
)

Definition at line 66 of file Ruler.cpp.

67{
68 mbTicksOnly = true;
69 mbTicksAtExtremes = false;
70 mTickColour = wxColour( theTheme.Colour( clrTrackPanelText ));
71 mPen.SetColour(mTickColour);
72
73 // Note: the font size is now adjusted automatically whenever
74 // Invalidate is called on a horizontal Ruler, unless the user
75 // calls SetFonts manually. So the defaults here are not used
76 // often.
77
78 int fontSize = 10;
79#ifdef __WXMSW__
80 fontSize = 8;
81#endif
82
83 mbMinor = true;
84
85 mTwoTone = false;
86
89
90 mTickLengths = { 4, 2, 2 };
91}
THEME_API Theme theTheme
Definition: Theme.cpp:82
static CustomUpdaterValue updater
wxColour mTickColour
Definition: Ruler.h:156
wxPen mPen
Definition: Ruler.h:158
TickLengths mTickLengths
Definition: Ruler.h:154
bool mbTicksOnly
Definition: Ruler.h:148
void SetUpdater(const RulerUpdater *pUpdater)
Definition: Ruler.cpp:112
void SetFormat(const RulerFormat *pFormat)
Definition: Ruler.cpp:104
bool mbTicksAtExtremes
Definition: Ruler.h:149
bool mbMinor
Definition: Ruler.h:174
bool mTwoTone
Definition: Ruler.h:175
wxColour & Colour(int iIndex)

References ThemeBase::Colour(), anonymous_namespace{ExportPCM.cpp}::format, mbMinor, mbTicksAtExtremes, mbTicksOnly, mPen, mTickColour, mTickLengths, mTwoTone, SetFormat(), SetUpdater(), theTheme, and updater.

Here is the call graph for this function:

◆ ~Ruler()

Ruler::~Ruler ( )

Definition at line 93 of file Ruler.cpp.

94{
95 // DV: Why?
96 // Invalidate(); // frees up our arrays
97}

Member Function Documentation

◆ ChooseFonts()

void Ruler::ChooseFonts ( wxDC &  dc) const
private

Definition at line 354 of file Ruler.cpp.

355{
356 const RulerStruct::Fonts* pUserFonts = mpUserFonts.get();
357 int desiredPixelHeight = mRulerStruct.mOrientation == wxHORIZONTAL
358 ? mRulerStruct.mBottom - mRulerStruct.mTop - 5 // height less ticks and 1px gap
360
362 return;
363
364 if (pUserFonts) {
365 mRulerStruct.mpFonts = std::make_unique<RulerStruct::Fonts>(*pUserFonts);
366 return;
367 }
368
369 mRulerStruct.mpFonts = std::make_unique<RulerStruct::Fonts>(RulerStruct::Fonts{ {}, {}, {}, 0 });
370 auto& fonts = *(mRulerStruct.mpFonts);
371
372 int fontSize = 4;
373
374 desiredPixelHeight =
375 std::max(MinPixelHeight, std::min(MaxPixelHeight, -desiredPixelHeight));
376
377 // Keep making the font bigger until it's too big, then subtract one.
378 wxCoord height;
379 FindFontHeights(height, fonts.lead, dc, fontSize, wxFONTWEIGHT_BOLD);
380 while (height <= desiredPixelHeight && fontSize < 40) {
381 fontSize++;
382 FindFontHeights(height, fonts.lead, dc, fontSize, wxFONTWEIGHT_BOLD);
383 }
384 fontSize--;
385 FindFontHeights(height, fonts.lead, dc, fontSize);
386
387 fonts.major = wxFont{ fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD };
388 fonts.minor = wxFont{ fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL };
389 fonts.minorMinor = wxFont{ fontSize - 1, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL };
390
391}
int min(int a, int b)
static constexpr int MaxPixelHeight
Definition: Ruler.cpp:344
static constexpr int MinPixelHeight
Definition: Ruler.cpp:337
RulerStruct mRulerStruct
Definition: Ruler.h:153
std::unique_ptr< RulerStruct::Fonts > mpUserFonts
Definition: Ruler.h:160
void FindFontHeights(wxCoord &height, wxCoord &lead, wxDC &dc, int fontSize, wxFontWeight weight=wxFONTWEIGHT_NORMAL)
Definition: Ruler.cpp:222
std::unique_ptr< Fonts > mpFonts
Definition: RulerUpdater.h:52
int mOrientation
Definition: RulerUpdater.h:37

References anonymous_namespace{Ruler.cpp}::FindFontHeights(), MaxPixelHeight, RulerStruct::mBottom, min(), MinPixelHeight, RulerStruct::mOrientation, RulerStruct::mpFonts, mpUserFonts, mRulerStruct, and RulerStruct::mTop.

Referenced by GetFonts().

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

◆ Draw() [1/2]

void Ruler::Draw ( wxDC &  dc) const

Definition at line 441 of file Ruler.cpp.

442{
443 Draw( dc, NULL);
444}
void Draw(wxDC &dc) const
Definition: Ruler.cpp:441

References Draw().

Referenced by WaveChannelVRulerControls::DoDraw(), AdornedRulerPanel::DoDrawMarks(), Draw(), anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve(), MeterPanel::OnPaint(), and RulerPanel::OnPaint().

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

◆ Draw() [2/2]

void Ruler::Draw ( wxDC &  dc,
const Envelope envelope 
) const

Definition at line 446 of file Ruler.cpp.

447{
448 if(mRulerStruct.mLength <=0 )
449 return;
450
451 UpdateCache( dc, envelope );
452 auto &cache = *mpCache;
453
454 dc.SetTextForeground( mTickColour );
455#ifdef EXPERIMENTAL_THEMING
456 dc.SetPen(mPen);
457#else
458 dc.SetPen(*wxBLACK_PEN);
459#endif
460
461 // Draws a long line the length of the ruler.
462 if( !mbTicksOnly )
463 {
464 if (mRulerStruct.mOrientation == wxHORIZONTAL) {
467 else
469 }
470 else {
473 else
474 {
475 // These calculations appear to be wrong, and to never have been used (so not tested) prior to MixerBoard.
476 // AColor::Line(dc, mRect.x-mRect.width, mTop, mRect.x-mRect.width, mBottom);
477 const int nLineX = mRulerStruct.mRight - 1;
478 AColor::Line(dc, nLineX, mRulerStruct.mTop, nLineX, mRulerStruct.mBottom);
479 }
480 }
481 }
482
483 dc.SetFont( mRulerStruct.mpFonts->major );
484
485 // We may want to not show the ticks at the extremes,
486 // though still showing the labels.
487 // This gives a better look when the ruler is on a bevelled
488 // button, since otherwise the tick is drawn on the bevel.
489 int iMaxPos = (mRulerStruct.mOrientation==wxHORIZONTAL)? mRulerStruct.mRight : mRulerStruct.mBottom-5;
490
491 auto drawLabel = [this, iMaxPos, &dc]( const RulerUpdater::Label &label, int length ){
492 int pos = label.pos;
493
494 if( mbTicksAtExtremes || ((pos!=0)&&(pos!=iMaxPos)))
495 {
496 if (mRulerStruct.mOrientation == wxHORIZONTAL) {
499 mRulerStruct.mLeft + pos, mRulerStruct.mTop + length);
500 else
503 }
504 else {
507 mRulerStruct.mLeft + length, mRulerStruct.mTop + pos);
508 else
511 }
512 }
513
515 };
516
517 for( const auto &label : cache.mMajorLabels )
518 drawLabel( label, mTickLengths.majorLength );
519
520 if( mbMinor ) {
521 dc.SetFont( mRulerStruct.mpFonts->minor );
522 for( const auto &label : cache.mMinorLabels )
523 drawLabel( label, mTickLengths.minorLength );
524 }
525
526 dc.SetFont( mRulerStruct.mpFonts->minorMinor );
527
528 for( const auto &label : cache.mMinorMinorLabels )
529 if ( label.text )
530 drawLabel( label, mTickLengths.minorMinorLength );
531}
TranslatableString label
Definition: TagsEditor.cpp:165
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:187
std::unique_ptr< Cache > mpCache
Definition: Ruler.h:166
void UpdateCache(wxDC &dc, const Envelope *envelope) const
Definition: Ruler.cpp:393
int minorMinorLength
Definition: Ruler.h:38
An array of these created by the Updater is used to determine what and where text annotations to the ...
Definition: RulerUpdater.h:60

References label, AColor::Line(), Ruler::TickLengths::majorLength, mbMinor, RulerStruct::mBottom, mbTicksAtExtremes, mbTicksOnly, RulerStruct::mFlip, Ruler::TickLengths::minorLength, Ruler::TickLengths::minorMinorLength, RulerStruct::mLeft, RulerStruct::mLength, RulerStruct::mOrientation, mpCache, mPen, RulerStruct::mpFonts, RulerStruct::mRight, mRulerStruct, mTickColour, mTickLengths, RulerStruct::mTop, mTwoTone, and UpdateCache().

Here is the call graph for this function:

◆ DrawGrid()

void Ruler::DrawGrid ( wxDC &  dc,
int  length,
bool  minor = true,
bool  major = true,
int  xOffset = 0,
int  yOffset = 0 
) const

Definition at line 534 of file Ruler.cpp.

538{
539 UpdateCache( dc, nullptr );
540 auto &cache = *mpCache;
541
542 int gridPos;
543 wxPen gridPen;
544
545 if(mbMinor && (minorGrid && (gridLineLength != 0 ))) {
546 gridPen.SetColour(178, 178, 178); // very light grey
547 dc.SetPen(gridPen);
548 for( const auto &label : cache.mMinorLabels ) {
549 gridPos = label.pos;
550 if(mRulerStruct.mOrientation == wxHORIZONTAL) {
551 if((gridPos != 0) && (gridPos != gridLineLength))
552 AColor::Line(dc, gridPos+xOffset, yOffset, gridPos+xOffset, gridLineLength-1+yOffset);
553 }
554 else {
555 if((gridPos != 0) && (gridPos != gridLineLength))
556 AColor::Line(dc, xOffset, gridPos+yOffset, gridLineLength-1+xOffset, gridPos+yOffset);
557 }
558 }
559 }
560
561 if(majorGrid && (gridLineLength != 0 )) {
562 gridPen.SetColour(127, 127, 127); // light grey
563 dc.SetPen(gridPen);
564 for( const auto &label : cache.mMajorLabels ) {
565 gridPos = label.pos;
566 if(mRulerStruct.mOrientation == wxHORIZONTAL) {
567 if((gridPos != 0) && (gridPos != gridLineLength))
568 AColor::Line(dc, gridPos+xOffset, yOffset, gridPos+xOffset, gridLineLength-1+yOffset);
569 }
570 else {
571 if((gridPos != 0) && (gridPos != gridLineLength))
572 AColor::Line(dc, xOffset, gridPos+yOffset, gridLineLength-1+xOffset, gridPos+yOffset);
573 }
574 }
575
576 int zeroPosition = GetZeroPosition();
577 if(zeroPosition > 0) {
578 // Draw 'zero' grid line in black
579 dc.SetPen(*wxBLACK_PEN);
580 if(mRulerStruct.mOrientation == wxHORIZONTAL) {
581 if(zeroPosition != gridLineLength)
582 AColor::Line(dc, zeroPosition+xOffset, yOffset, zeroPosition+xOffset, gridLineLength-1+yOffset);
583 }
584 else {
585 if(zeroPosition != gridLineLength)
586 AColor::Line(dc, xOffset, zeroPosition+yOffset, gridLineLength-1+xOffset, zeroPosition+yOffset);
587 }
588 }
589 }
590}
int GetZeroPosition() const
Definition: Ruler.cpp:605

References GetZeroPosition(), label, AColor::Line(), mbMinor, RulerStruct::mOrientation, mpCache, mRulerStruct, and UpdateCache().

Referenced by FrequencyPlotDialog::DrawPlot(), EqualizationPanel::OnPaint(), and EffectScienFilterPanel::OnPaint().

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

◆ FindZero()

int Ruler::FindZero ( const RulerUpdater::Labels labels) const
private

Definition at line 592 of file Ruler.cpp.

593{
594 auto begin = labels.begin(), end = labels.end(),
595 iter = std::find_if( begin, end, []( const RulerUpdater::Label &label ){
596 return label.value == 0.0;
597 } );
598
599 if ( iter == end )
600 return -1;
601 else
602 return iter->pos;
603}
auto end(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:159
auto begin(const Ptr< Type, BaseDeleter > &p)
Enables range-for.
Definition: PackedArray.h:150

References PackedArray::begin(), PackedArray::end(), and label.

Referenced by GetZeroPosition().

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

◆ GetFonts()

auto Ruler::GetFonts ( ) const

Definition at line 431 of file Ruler.cpp.

432{
433 if ( !mRulerStruct.mpFonts ) {
434 wxScreenDC dc;
435 ChooseFonts( dc );
436 }
437
438 return *(mRulerStruct.mpFonts);
439}
void ChooseFonts(wxDC &dc) const
Definition: Ruler.cpp:354

References ChooseFonts(), RulerStruct::mpFonts, and mRulerStruct.

Here is the call graph for this function:

◆ GetMaxSize()

void Ruler::GetMaxSize ( wxCoord *  width,
wxCoord *  height 
)

Definition at line 616 of file Ruler.cpp.

617{
618 if ( !mpCache ) {
619 wxScreenDC sdc;
620 UpdateCache( sdc, nullptr );
621 }
622
623 auto &cache = *mpCache;
624 if (width)
625 *width = cache.mRect.GetWidth();
626
627 if (height)
628 *height = cache.mRect.GetHeight();
629}

References mpCache, and UpdateCache().

Referenced by FrequencyPlotDialog::DrawPlot(), AdornedRulerPanel::GetMaxSize(), MeterPanel::SetActiveStyle(), EffectScienFilter::TransferGraphLimitsFromWindow(), and EqualizationUI::UpdateRuler().

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

◆ GetZeroPosition()

int Ruler::GetZeroPosition ( ) const
private

Definition at line 605 of file Ruler.cpp.

606{
607 wxASSERT( mpCache );
608 auto &cache = *mpCache;
609 int zero;
610 if( (zero = FindZero( cache.mMajorLabels ) ) < 0)
611 zero = FindZero( cache.mMinorLabels );
612 // PRL: don't consult minor minor??
613 return zero;
614}
int FindZero(const RulerUpdater::Labels &labels) const
Definition: Ruler.cpp:592

References FindZero(), and mpCache.

Referenced by DrawGrid().

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

◆ Invalidate()

void Ruler::Invalidate ( )

Definition at line 317 of file Ruler.cpp.

318{
319 if (mRulerStruct.mOrientation == wxHORIZONTAL)
321 else
323
324 mpCache.reset();
325 // Bug 2316 we must preserve off-limit pixels.
326 // mUserBits.clear();
327
329}
CallbackReturn Publish(const RulerInvalidatedMessage &message)
Send a message to connected callbacks.
Definition: Observer.h:207

References RulerStruct::mBottom, RulerStruct::mLeft, RulerStruct::mLength, RulerStruct::mOrientation, mpCache, RulerStruct::mRight, mRulerStruct, RulerStruct::mTop, and Observer::Publisher< RulerInvalidatedMessage >::Publish().

Referenced by anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve(), ProjectTimeRuler::Impl::Impl(), AdornedRulerPanel::InvalidateRuler(), OfflimitsPixels(), SetBounds(), SetDbMirrorValue(), SetFlip(), SetFonts(), SetFormat(), SetLabelEdges(), AdornedRulerPanel::SetLeftOffset(), SetNumberScale(), SetOrientation(), SetRange(), SetTickLengths(), SetUnits(), and SetUpdater().

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

◆ OfflimitsPixels()

void Ruler::OfflimitsPixels ( int  start,
int  end 
)

Definition at line 274 of file Ruler.cpp.

275{
276 int length = mRulerStruct.mLength;
277 if (mRulerStruct.mOrientation == wxHORIZONTAL)
279 else
281 if( length < 0 )
282 return;
283
284 auto size = static_cast<size_t>( length + 1 );
285 if ( mUserBits.size() < size ) {
286 mRulerStruct.mLength = length;
287 mUserBits.resize( size, false );
288 }
289
290 if (end < start)
291 std::swap( start, end );
292
293 if (start < 0)
294 start = 0;
297
298 for(int i = start; i <= end; i++)
299 mUserBits[i] = true;
300
301 Invalidate();
302}
RulerUpdater::Bits mUserBits
Definition: Ruler.h:164
void Invalidate()
Definition: Ruler.cpp:317
void swap(std::unique_ptr< Alg_seq > &a, std::unique_ptr< Alg_seq > &b)
Definition: NoteTrack.cpp:645

References PackedArray::end(), Invalidate(), RulerStruct::mBottom, RulerStruct::mLeft, RulerStruct::mLength, RulerStruct::mOrientation, RulerStruct::mRight, mRulerStruct, RulerStruct::mTop, mUserBits, size, and anonymous_namespace{NoteTrack.cpp}::swap().

Referenced by MeterPanel::HandleLayout().

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

◆ SetBounds()

void Ruler::SetBounds ( int  left,
int  top,
int  right,
int  bottom 
)

Definition at line 304 of file Ruler.cpp.

305{
306 if (mRulerStruct.mLeft != left || mRulerStruct.mTop != top ||
307 mRulerStruct.mRight != right || mRulerStruct.mBottom != bottom) {
308 mRulerStruct.mLeft = left;
309 mRulerStruct.mTop = top;
310 mRulerStruct.mRight = right;
311 mRulerStruct.mBottom = bottom;
312
313 Invalidate();
314 }
315}

References Invalidate(), RulerStruct::mBottom, RulerStruct::mLeft, RulerStruct::mRight, mRulerStruct, and RulerStruct::mTop.

Referenced by RulerPanel::DoSetSize(), anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve(), MeterPanel::HandleLayout(), MeterPanel::SetActiveStyle(), AdornedRulerPanel::UpdateRects(), and NoteTrackVRulerControls::UpdateRuler().

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

◆ SetDbMirrorValue()

void Ruler::SetDbMirrorValue ( const double  d)

Definition at line 132 of file Ruler.cpp.

133{
134 if (mRulerStruct.mDbMirrorValue != d) {
136
137 Invalidate();
138 }
139}
double mDbMirrorValue
Definition: RulerUpdater.h:49

References Invalidate(), RulerStruct::mDbMirrorValue, and mRulerStruct.

Here is the call graph for this function:

◆ SetFlip()

void Ruler::SetFlip ( bool  flip)

Definition at line 192 of file Ruler.cpp.

193{
194 // If this is true, the orientation of the tick marks
195 // is reversed from the default; eg. above the line
196 // instead of below
197
198 if (mRulerStruct.mFlip != flip) {
199 mRulerStruct.mFlip = flip;
200
201 Invalidate();
202 }
203}

References Invalidate(), RulerStruct::mFlip, and mRulerStruct.

Referenced by anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve().

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

◆ SetFonts()

void Ruler::SetFonts ( const wxFont &  minorFont,
const wxFont &  majorFont,
const wxFont &  minorMinorFont 
)

Definition at line 231 of file Ruler.cpp.

232{
233 // Won't override these fonts
234
235 mpUserFonts = std::make_unique<RulerStruct::Fonts>(
236 RulerStruct::Fonts{ majorFont, minorFont, minorMinorFont, 0 } );
237
238 wxScreenDC dc;
239 wxCoord height;
240 FindFontHeights( height, mpUserFonts->lead, dc, majorFont );
241
242 mRulerStruct.mpFonts.reset();
243 mRulerStruct.mpFonts.reset();
244 Invalidate();
245}

References anonymous_namespace{Ruler.cpp}::FindFontHeights(), Invalidate(), RulerStruct::mpFonts, mpUserFonts, and mRulerStruct.

Here is the call graph for this function:

◆ SetFormat()

void Ruler::SetFormat ( const RulerFormat pFormat)

Definition at line 104 of file Ruler.cpp.

105{
106 if (mRulerStruct.mpRulerFormat != pFormat) {
107 mRulerStruct.mpRulerFormat = pFormat;
108 Invalidate();
109 }
110}
const RulerFormat * mpRulerFormat
Definition: RulerUpdater.h:41

References Invalidate(), RulerStruct::mpRulerFormat, and mRulerStruct.

Referenced by FrequencyPlotDialog::DrawPlot(), Ruler(), and MeterPanel::SetActiveStyle().

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

◆ SetLabelEdges()

void Ruler::SetLabelEdges ( bool  labelEdges)

Definition at line 179 of file Ruler.cpp.

180{
181 // If this is true, the edges of the ruler will always
182 // receive a label. If not, the nearest round number is
183 // labeled (which may or may not be the edge).
184
185 if (mRulerStruct.mLabelEdges != labelEdges) {
186 mRulerStruct.mLabelEdges = labelEdges;
187
188 Invalidate();
189 }
190}
bool mLabelEdges
Definition: RulerUpdater.h:39

References Invalidate(), RulerStruct::mLabelEdges, and mRulerStruct.

Referenced by AdornedRulerPanel::AdornedRulerPanel(), and TimeTrackView::Draw().

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

◆ SetMinor()

void Ruler::SetMinor ( bool  value)

Definition at line 205 of file Ruler.cpp.

206{
207 mbMinor = value;
208}

References mbMinor.

◆ SetNumberScale()

void Ruler::SetNumberScale ( const NumberScale scale)

Definition at line 247 of file Ruler.cpp.

248{
249 if ( mRulerStruct.mNumberScale != scale ) {
251 Invalidate();
252 }
253}
NumberScale mNumberScale
Definition: RulerUpdater.h:55

References Invalidate(), RulerStruct::mNumberScale, and mRulerStruct.

Here is the call graph for this function:

◆ SetOrientation()

void Ruler::SetOrientation ( int  orient)

Definition at line 141 of file Ruler.cpp.

142{
143 // wxHORIZONTAL || wxVERTICAL
144
145 if (mRulerStruct.mOrientation != orient) {
146 mRulerStruct.mOrientation = orient;
147
148 Invalidate();
149 }
150}

References Invalidate(), RulerStruct::mOrientation, and mRulerStruct.

Referenced by MeterPanel::SetActiveStyle().

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

◆ SetRange() [1/2]

void Ruler::SetRange ( double  min,
double  max 
)

Definition at line 152 of file Ruler.cpp.

153{
154 SetRange(min, max, min, max);
155}
void SetRange(double min, double max)
Definition: Ruler.cpp:152

References min(), and SetRange().

Referenced by AdornedRulerPanel::DoDrawMarks(), anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve(), FrequencyPlotDialog::DrawPlot(), EqualizationUI::OnLinFreq(), MeterPanel::SetActiveStyle(), SetRange(), EffectScienFilter::TransferGraphLimitsFromWindow(), EqualizationUI::UpdateDraw(), EqualizationUI::UpdateGraphic(), and EqualizationUI::UpdateRuler().

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

◆ SetRange() [2/2]

void Ruler::SetRange ( double  min,
double  max,
double  hiddenMin,
double  hiddenMax 
)

Definition at line 157 of file Ruler.cpp.

159{
160 // For a horizontal ruler,
161 // min is the value in the center of pixel "left",
162 // max is the value in the center of pixel "right".
163
164 // In the special case of a time ruler,
165 // hiddenMin and hiddenMax are values that would be shown with the fisheye
166 // turned off. In other cases they equal min and max respectively.
167
168 if (mRulerStruct.mMin != min || mRulerStruct.mMax != max ||
169 mRulerStruct.mHiddenMin != hiddenMin || mRulerStruct.mHiddenMax != hiddenMax) {
171 mRulerStruct.mMax = max;
172 mRulerStruct.mHiddenMin = hiddenMin;
173 mRulerStruct.mHiddenMax = hiddenMax;
174
175 Invalidate();
176 }
177}
double mMax
Definition: RulerUpdater.h:34
double mHiddenMax
Definition: RulerUpdater.h:35
double mMin
Definition: RulerUpdater.h:32
double mHiddenMin
Definition: RulerUpdater.h:33

References Invalidate(), RulerStruct::mHiddenMax, RulerStruct::mHiddenMin, min(), RulerStruct::mMax, RulerStruct::mMin, and mRulerStruct.

Here is the call graph for this function:

◆ SetTickColour()

void Ruler::SetTickColour ( const wxColour &  colour)
inline

Definition at line 135 of file Ruler.h.

136 { mTickColour = colour; mPen.SetColour( colour );}

Referenced by WaveChannelVRulerControls::DoDraw(), AdornedRulerPanel::DoDrawMarks(), anonymous_namespace{TimeTrackView.cpp}::DrawHorzRulerAndCurve(), MeterPanel::OnPaint(), and RulerPanel::SetTickColour().

Here is the caller graph for this function:

◆ SetTickLengths()

void Ruler::SetTickLengths ( const TickLengths tLengths)

Definition at line 255 of file Ruler.cpp.

256{
257 bool inv = false;
258 if (mTickLengths.majorLength != tLengths.majorLength) {
259 mTickLengths.majorLength = tLengths.majorLength;
260 inv = true;
261 }
262 if (mTickLengths.minorLength != tLengths.minorLength) {
263 mTickLengths.minorLength = tLengths.minorLength;
264 inv = true;
265 }
266 if (mTickLengths.minorMinorLength != tLengths.minorMinorLength) {
267 mTickLengths.minorMinorLength = tLengths.minorMinorLength;
268 inv = true;
269 }
270
271 if (inv) Invalidate();
272}

References Invalidate(), Ruler::TickLengths::majorLength, Ruler::TickLengths::minorLength, Ruler::TickLengths::minorMinorLength, and mTickLengths.

Referenced by AdornedRulerPanel::DoDrawMarks().

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

◆ SetTwoTone()

void Ruler::SetTwoTone ( bool  twoTone)

Definition at line 99 of file Ruler.cpp.

100{
101 mTwoTone = twoTone;
102}

References mTwoTone.

◆ SetUnits()

void Ruler::SetUnits ( const TranslatableString units)

Definition at line 120 of file Ruler.cpp.

121{
122 // Specify the name of the units (like "dB") if you
123 // want numbers like "1.6" formatted as "1.6 dB".
124
125 if (mRulerStruct.mUnits != units) {
126 mRulerStruct.mUnits = units;
127
128 Invalidate();
129 }
130}
TranslatableString mUnits
Definition: RulerUpdater.h:53

References Invalidate(), mRulerStruct, and RulerStruct::mUnits.

Referenced by FrequencyPlotDialog::DrawPlot().

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

◆ SetUpdater()

void Ruler::SetUpdater ( const RulerUpdater pUpdater)

Definition at line 112 of file Ruler.cpp.

113{
114 if (mpUpdater != pUpdater) {
116 Invalidate();
117 }
118}
const RulerUpdater * mpUpdater
Definition: Ruler.h:162
std::optional< LogWindowUpdater > pUpdater
Definition: LogWindow.cpp:53

References Invalidate(), mpUpdater, and anonymous_namespace{LogWindow.cpp}::pUpdater.

Referenced by FrequencyPlotDialog::DrawPlot(), EqualizationUI::OnLinFreq(), Ruler(), EqualizationUI::UpdateDraw(), and EqualizationUI::UpdateGraphic().

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

◆ UpdateCache()

void Ruler::UpdateCache ( wxDC &  dc,
const Envelope envelope 
) const
private

Definition at line 393 of file Ruler.cpp.

396{
397 if ( mpCache )
398 return;
399
400 // This gets called when something has been changed
401 // (i.e. we've been invalidated). Recompute all
402 // tick positions and font size.
403
404 ChooseFonts( dc );
405 mpCache = std::make_unique< Cache >();
406 auto &cache = *mpCache;
407
408 // If ruler is being resized, we could end up with it being too small.
409 // Values of mLength of zero or below cause bad array allocations and
410 // division by zero. So...
411 // IF too small THEN bail out and don't draw.
412 if( mRulerStruct.mLength <= 0 )
413 return;
414
415 if (mRulerStruct.mOrientation == wxHORIZONTAL)
416 cache.mRect = { 0, 0, mRulerStruct.mLength, 0 };
417 else
418 cache.mRect = { 0, 0, 0, mRulerStruct.mLength };
419
420 cache.mBits = mUserBits;
421 cache.mBits.resize( static_cast<size_t>(mRulerStruct.mLength + 1), false );
422
424 cache.mMajorLabels, cache.mMinorLabels, cache.mMinorMinorLabels,
425 cache.mBits, cache.mRect
426 };
427 if (mpUpdater)
428 mpUpdater->Update(dc, envelope, allOutputs, mRulerStruct);
429}
virtual void Update(wxDC &dc, const Envelope *envelope, UpdateOutputs &allOutputs, const RulerStruct &context) const =0

Referenced by Draw(), DrawGrid(), and GetMaxSize().

Here is the caller graph for this function:

Member Data Documentation

◆ mbMinor

bool Ruler::mbMinor
private

Definition at line 174 of file Ruler.h.

Referenced by Draw(), DrawGrid(), Ruler(), and SetMinor().

◆ mbTicksAtExtremes

bool Ruler::mbTicksAtExtremes

Definition at line 149 of file Ruler.h.

Referenced by Draw(), and Ruler().

◆ mbTicksOnly

bool Ruler::mbTicksOnly

Definition at line 148 of file Ruler.h.

Referenced by Draw(), and Ruler().

◆ mpCache

std::unique_ptr<Cache> Ruler::mpCache
mutableprivate

Definition at line 167 of file Ruler.h.

Referenced by Draw(), DrawGrid(), GetMaxSize(), GetZeroPosition(), and Invalidate().

◆ mPen

wxPen Ruler::mPen
private

Definition at line 158 of file Ruler.h.

Referenced by Draw(), and Ruler().

◆ mpUpdater

const RulerUpdater* Ruler::mpUpdater {}
private

Definition at line 162 of file Ruler.h.

Referenced by SetUpdater().

◆ mpUserFonts

std::unique_ptr<RulerStruct::Fonts> Ruler::mpUserFonts
private

Definition at line 160 of file Ruler.h.

Referenced by ChooseFonts(), and SetFonts().

◆ mRulerStruct

RulerStruct Ruler::mRulerStruct
private

◆ mTickColour

wxColour Ruler::mTickColour
private

Definition at line 156 of file Ruler.h.

Referenced by Draw(), and Ruler().

◆ mTickLengths

TickLengths Ruler::mTickLengths
private

Definition at line 154 of file Ruler.h.

Referenced by Draw(), Ruler(), and SetTickLengths().

◆ mTwoTone

bool Ruler::mTwoTone
private

Definition at line 175 of file Ruler.h.

Referenced by Draw(), Ruler(), and SetTwoTone().

◆ mUserBits

RulerUpdater::Bits Ruler::mUserBits
private

Definition at line 164 of file Ruler.h.

Referenced by OfflimitsPixels().


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