Audacity  2.2.2
Classes | Public Types | 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>

Classes

struct  Fonts
 
class  Label
 An array of these created by the Ruler is used to determine what and where text annotations to the numbers on the Ruler get drawn. More...
 

Public Types

enum  RulerFormat {
  IntFormat, RealFormat, RealLogFormat, TimeFormat,
  LinearDBFormat
}
 

Public Member Functions

 Ruler ()
 
 ~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 SetTwoTone (bool twoTone)
 
void SetFormat (RulerFormat format)
 
void SetUnits (const wxString &units)
 
void SetLog (bool log)
 
void SetSpacing (int spacing)
 
void SetLabelEdges (bool labelEdges)
 
void SetFlip (bool flip)
 
void SetMinor (bool value)
 
void SetFonts (const wxFont &minorFont, const wxFont &majorFont, const wxFont &minorMinorFont)
 
Fonts GetFonts () const
 
void SetNumberScale (const NumberScale *pScale)
 
void OfflimitsPixels (int start, int end)
 
void GetMaxSize (wxCoord *width, wxCoord *height)
 
void SetCustomMode (bool value)
 
void SetCustomMajorLabels (wxArrayString *label, size_t numLabel, int start, int step)
 
void SetCustomMinorLabels (wxArrayString *label, size_t numLabel, int start, int step)
 
void SetUseZoomInfo (int leftOffset, const ZoomInfo *zoomInfo)
 
void Draw (wxDC &dc)
 
void Draw (wxDC &dc, const TimeTrack *timetrack)
 
void DrawGrid (wxDC &dc, int length, bool minor=true, bool major=true, int xOffset=0, int yOffset=0)
 
void SetTickColour (const wxColour &colour)
 
void Invalidate ()
 
int GetZeroPosition ()
 

Public Attributes

bool mbTicksOnly
 
bool mbTicksAtExtremes
 
wxRect mRect
 

Private Member Functions

void Update ()
 
void Update (const TimeTrack *timetrack)
 
void FindTickSizes ()
 
void FindLinearTickSizes (double UPP)
 
wxString LabelString (double d, bool major)
 
void Tick (int pos, double d, bool major, bool minor)
 
void TickCustom (int labelIdx, bool major, bool minor)
 
int FindZero (Label *label, int len)
 

Private Attributes

wxColour mTickColour
 
wxPen mPen
 
int mMaxWidth
 
int mMaxHeight
 
int mLeft
 
int mTop
 
int mRight
 
int mBottom
 
int mLead
 
int mLength
 
int mLengthOld
 
wxDC * mDC
 
std::unique_ptr< wxFont > mMinorFont
 
std::unique_ptr< wxFont > mMajorFont
 
std::unique_ptr< wxFont > mMinorMinorFont
 
bool mUserFonts
 
double mMin
 
double mMax
 
double mHiddenMin
 
double mHiddenMax
 
double mMajor
 
double mMinor
 
int mDigits
 
ArrayOf< int > mUserBits
 
ArrayOf< int > mBits
 
int mUserBitLen
 
bool mValid
 
int mNumMajor
 
ArrayOf< LabelmMajorLabels
 
int mNumMinor
 
ArrayOf< LabelmMinorLabels
 
int mNumMinorMinor
 
ArrayOf< LabelmMinorMinorLabels
 
int mOrientation
 
int mSpacing
 
bool mHasSetSpacing
 
bool mLabelEdges
 
RulerFormat mFormat
 
bool mLog
 
bool mFlip
 
bool mCustom
 
bool mbMinor
 
bool mMajorGrid
 
bool mMinorGrid
 
int mGridLineLength
 
wxString mUnits
 
bool mTwoTone
 
const ZoomInfomUseZoomInfo
 
int mLeftOffset
 
std::unique_ptr< NumberScalempNumberScale
 

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.

Member Enumeration Documentation

Enumerator
IntFormat 
RealFormat 
RealLogFormat 
TimeFormat 
LinearDBFormat 

Definition at line 35 of file Ruler.h.

Constructor & Destructor Documentation

Ruler::Ruler ( )

Definition at line 119 of file Ruler.cpp.

120  : mpNumberScale{}
121 {
122  mMin = mHiddenMin = 0.0;
123  mMax = mHiddenMax = 100.0;
124  mOrientation = wxHORIZONTAL;
125  mSpacing = 6;
126  mHasSetSpacing = false;
128  mFlip = false;
129  mLog = false;
130  mLabelEdges = false;
131  mUnits = wxT("");
132 
133  mLeft = -1;
134  mTop = -1;
135  mRight = -1;
136  mBottom = -1;
137  mbTicksOnly = true;
138  mbTicksAtExtremes = false;
139  mTickColour = wxColour( theTheme.Colour( clrTrackPanelText ));
140  mPen.SetColour(mTickColour);
141 
142  // Note: the font size is now adjusted automatically whenever
143  // Invalidate is called on a horizontal Ruler, unless the user
144  // calls SetFonts manually. So the defaults here are not used
145  // often.
146 
147  int fontSize = 10;
148 #ifdef __WXMSW__
149  fontSize = 8;
150 #endif
151 
152  mMinorMinorFont = std::make_unique<wxFont>(fontSize - 1, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
153  mMinorFont = std::make_unique<wxFont>(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
154  mMajorFont = std::make_unique<wxFont>(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
155 
156  mUserFonts = false;
157 
158  mLengthOld = 0;
159  mLength = 0;
160  mUserBitLen = 0;
161 
162  mValid = false;
163 
164  mCustom = false;
165  mbMinor = true;
166 
167  mGridLineLength = 0;
168  mMajorGrid = false;
169  mMinorGrid = false;
170 
171  mTwoTone = false;
172 
173  mUseZoomInfo = NULL;
174 }
bool mLabelEdges
Definition: Ruler.h:227
bool mMajorGrid
Definition: Ruler.h:233
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:215
bool mHasSetSpacing
Definition: Ruler.h:226
std::unique_ptr< wxFont > mMinorMinorFont
Definition: Ruler.h:183
wxString mUnits
Definition: Ruler.h:236
wxPen mPen
Definition: Ruler.h:175
int mLengthOld
Definition: Ruler.h:180
bool mbMinor
Definition: Ruler.h:232
std::unique_ptr< wxFont > mMinorFont
Definition: Ruler.h:183
bool mFlip
Definition: Ruler.h:230
bool mUserFonts
Definition: Ruler.h:184
double mMax
Definition: Ruler.h:186
double mMin
Definition: Ruler.h:186
bool mValid
Definition: Ruler.h:198
std::unique_ptr< NumberScale > mpNumberScale
Definition: Ruler.h:241
bool mMinorGrid
Definition: Ruler.h:234
int mTop
Definition: Ruler.h:178
bool mCustom
Definition: Ruler.h:231
wxColour mTickColour
Definition: Ruler.h:174
int mRight
Definition: Ruler.h:178
bool mLog
Definition: Ruler.h:229
int mBottom
Definition: Ruler.h:178
RulerFormat mFormat
Definition: Ruler.h:228
bool mbTicksOnly
Definition: Ruler.h:169
const ZoomInfo * mUseZoomInfo
Definition: Ruler.h:238
double mHiddenMin
Definition: Ruler.h:187
bool mTwoTone
Definition: Ruler.h:237
int mUserBitLen
Definition: Ruler.h:196
int mLength
Definition: Ruler.h:179
double mHiddenMax
Definition: Ruler.h:187
int mGridLineLength
Definition: Ruler.h:235
int mLeft
Definition: Ruler.h:178
int mOrientation
Definition: Ruler.h:224
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1214
bool mbTicksAtExtremes
Definition: Ruler.h:170
std::unique_ptr< wxFont > mMajorFont
Definition: Ruler.h:183
int mSpacing
Definition: Ruler.h:225
Ruler::~Ruler ( )

Definition at line 176 of file Ruler.cpp.

References Invalidate().

177 {
178  Invalidate(); // frees up our arrays
179 }
void Invalidate()
Definition: Ruler.cpp:369

Member Function Documentation

void Ruler::Draw ( wxDC &  dc)

Definition at line 1307 of file Ruler.cpp.

Referenced by AdornedRulerPanel::DoDrawMarks(), EffectCompressorPanel::OnPaint(), Meter::OnPaint(), and AudacityPrintout::OnPrintPage().

1308 {
1309  Draw( dc, NULL);
1310 }
void Draw(wxDC &dc)
Definition: Ruler.cpp:1307
void Ruler::Draw ( wxDC &  dc,
const TimeTrack timetrack 
)

Definition at line 1312 of file Ruler.cpp.

References mbMinor, mBottom, mbTicksAtExtremes, mbTicksOnly, mDC, mFlip, mLeft, mLength, mMajorFont, mMajorLabels, mMinorFont, mMinorLabels, mMinorMinorFont, mMinorMinorLabels, mNumMajor, mNumMinor, mNumMinorMinor, mOrientation, mPen, mRight, mTickColour, mTop, mTwoTone, mValid, and Update().

1313 {
1314  mDC = &dc;
1315  if( mLength <=0 )
1316  return;
1317 
1318  if (!mValid)
1319  Update(timetrack);
1320 
1321  mDC->SetTextForeground( mTickColour );
1322 #ifdef EXPERIMENTAL_THEMING
1323  mDC->SetPen(mPen);
1324 #else
1325  mDC->SetPen(*wxBLACK_PEN);
1326 #endif
1327 
1328  // Draws a long line the length of the ruler.
1329  if( !mbTicksOnly )
1330  {
1331  if (mOrientation == wxHORIZONTAL) {
1332  if (mFlip)
1333  mDC->DrawLine(mLeft, mTop, mRight+1, mTop);
1334  else
1335  mDC->DrawLine(mLeft, mBottom, mRight+1, mBottom);
1336  }
1337  else {
1338  if (mFlip)
1339  mDC->DrawLine(mLeft, mTop, mLeft, mBottom+1);
1340  else
1341  {
1342  // These calculations appear to be wrong, and to never have been used (so not tested) prior to MixerBoard.
1343  // mDC->DrawLine(mRect.x-mRect.width, mTop, mRect.x-mRect.width, mBottom+1);
1344  const int nLineX = mRight - 1;
1345  mDC->DrawLine(nLineX, mTop, nLineX, mBottom+1);
1346  }
1347  }
1348  }
1349 
1350  int i;
1351 
1352  mDC->SetFont(*mMajorFont);
1353 
1354  // We may want to not show the ticks at the extremes,
1355  // though still showing the labels.
1356  // This gives a better look when the ruler is on a bevelled
1357  // button, since otherwise the tick is drawn on the bevel.
1358  int iMaxPos = (mOrientation==wxHORIZONTAL)? mRight : mBottom-5;
1359 
1360  for(i=0; i<mNumMajor; i++) {
1361  int pos = mMajorLabels[i].pos;
1362 
1363  if( mbTicksAtExtremes || ((pos!=0)&&(pos!=iMaxPos)))
1364  {
1365  if (mOrientation == wxHORIZONTAL) {
1366  if (mFlip)
1367  mDC->DrawLine(mLeft + pos, mTop,
1368  mLeft + pos, mTop + 4);
1369  else
1370  mDC->DrawLine(mLeft + pos, mBottom - 4,
1371  mLeft + pos, mBottom);
1372  }
1373  else {
1374  if (mFlip)
1375  mDC->DrawLine(mLeft, mTop + pos,
1376  mLeft + 4, mTop + pos);
1377  else
1378  mDC->DrawLine(mRight - 4, mTop + pos,
1379  mRight, mTop + pos);
1380  }
1381  }
1382 
1383  mMajorLabels[i].Draw(*mDC, mTwoTone, mTickColour);
1384  }
1385 
1386  if(mbMinor == true) {
1387  mDC->SetFont(*mMinorFont);
1388  for(i=0; i<mNumMinor; i++) {
1389  int pos = mMinorLabels[i].pos;
1390  if( mbTicksAtExtremes || ((pos!=0)&&(pos!=iMaxPos)))
1391  {
1392  if (mOrientation == wxHORIZONTAL)
1393  {
1394  if (mFlip)
1395  mDC->DrawLine(mLeft + pos, mTop,
1396  mLeft + pos, mTop + 2);
1397  else
1398  mDC->DrawLine(mLeft + pos, mBottom - 2,
1399  mLeft + pos, mBottom);
1400  }
1401  else
1402  {
1403  if (mFlip)
1404  mDC->DrawLine(mLeft, mTop + pos,
1405  mLeft + 2, mTop + pos);
1406  else
1407  mDC->DrawLine(mRight - 2, mTop + pos,
1408  mRight, mTop + pos);
1409  }
1410  }
1411  mMinorLabels[i].Draw(*mDC, mTwoTone, mTickColour);
1412  }
1413  }
1414 
1415  mDC->SetFont(*mMinorMinorFont);
1416 
1417  for(i=0; i<mNumMinorMinor; i++) {
1418  if (mMinorMinorLabels[i].text != wxT(""))
1419  {
1420  int pos = mMinorMinorLabels[i].pos;
1421 
1422  if( mbTicksAtExtremes || ((pos!=0)&&(pos!=iMaxPos)))
1423  {
1424  if (mOrientation == wxHORIZONTAL)
1425  {
1426  if (mFlip)
1427  mDC->DrawLine(mLeft + pos, mTop,
1428  mLeft + pos, mTop + 2);
1429  else
1430  mDC->DrawLine(mLeft + pos, mBottom - 2,
1431  mLeft + pos, mBottom);
1432  }
1433  else
1434  {
1435  if (mFlip)
1436  mDC->DrawLine(mLeft, mTop + pos,
1437  mLeft + 2, mTop + pos);
1438  else
1439  mDC->DrawLine(mRight - 2, mTop + pos,
1440  mRight, mTop + pos);
1441  }
1442  }
1444  }
1445  }
1446 }
std::unique_ptr< wxFont > mMinorMinorFont
Definition: Ruler.h:183
wxPen mPen
Definition: Ruler.h:175
int mNumMinor
Definition: Ruler.h:212
bool mbMinor
Definition: Ruler.h:232
std::unique_ptr< wxFont > mMinorFont
Definition: Ruler.h:183
ArrayOf< Label > mMajorLabels
Definition: Ruler.h:211
bool mFlip
Definition: Ruler.h:230
bool mValid
Definition: Ruler.h:198
int mTop
Definition: Ruler.h:178
wxColour mTickColour
Definition: Ruler.h:174
int mRight
Definition: Ruler.h:178
int mBottom
Definition: Ruler.h:178
bool mbTicksOnly
Definition: Ruler.h:169
ArrayOf< Label > mMinorMinorLabels
Definition: Ruler.h:215
bool mTwoTone
Definition: Ruler.h:237
int mLength
Definition: Ruler.h:179
wxDC * mDC
Definition: Ruler.h:181
int mNumMajor
Definition: Ruler.h:210
int mNumMinorMinor
Definition: Ruler.h:214
int mLeft
Definition: Ruler.h:178
int mOrientation
Definition: Ruler.h:224
bool mbTicksAtExtremes
Definition: Ruler.h:170
std::unique_ptr< wxFont > mMajorFont
Definition: Ruler.h:183
void Update()
Definition: Ruler.cpp:986
ArrayOf< Label > mMinorLabels
Definition: Ruler.h:213
void Ruler::DrawGrid ( wxDC &  dc,
int  length,
bool  minor = true,
bool  major = true,
int  xOffset = 0,
int  yOffset = 0 
)

Definition at line 1449 of file Ruler.cpp.

References GetZeroPosition(), mbMinor, mDC, mGridLineLength, mMajorGrid, mMajorLabels, mMinorGrid, mMinorLabels, mNumMajor, mNumMinor, mOrientation, and Update().

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

1450 {
1451  mGridLineLength = length;
1452  mMajorGrid = major;
1453  mMinorGrid = minor;
1454  mDC = &dc;
1455 
1456  Update();
1457 
1458  int gridPos;
1459  wxPen gridPen;
1460 
1461  if(mbMinor && (mMinorGrid && (mGridLineLength != 0 ))) {
1462  gridPen.SetColour(178, 178, 178); // very light grey
1463  mDC->SetPen(gridPen);
1464  for(int i=0; i<mNumMinor; i++) {
1465  gridPos = mMinorLabels[i].pos;
1466  if(mOrientation == wxHORIZONTAL) {
1467  if((gridPos != 0) && (gridPos != mGridLineLength))
1468  mDC->DrawLine(gridPos+xOffset, yOffset, gridPos+xOffset, mGridLineLength+yOffset);
1469  }
1470  else {
1471  if((gridPos != 0) && (gridPos != mGridLineLength))
1472  mDC->DrawLine(xOffset, gridPos+yOffset, mGridLineLength+xOffset, gridPos+yOffset);
1473  }
1474  }
1475  }
1476 
1477  if(mMajorGrid && (mGridLineLength != 0 )) {
1478  gridPen.SetColour(127, 127, 127); // light grey
1479  mDC->SetPen(gridPen);
1480  for(int i=0; i<mNumMajor; i++) {
1481  gridPos = mMajorLabels[i].pos;
1482  if(mOrientation == wxHORIZONTAL) {
1483  if((gridPos != 0) && (gridPos != mGridLineLength))
1484  mDC->DrawLine(gridPos+xOffset, yOffset, gridPos+xOffset, mGridLineLength+yOffset);
1485  }
1486  else {
1487  if((gridPos != 0) && (gridPos != mGridLineLength))
1488  mDC->DrawLine(xOffset, gridPos+yOffset, mGridLineLength+xOffset, gridPos+yOffset);
1489  }
1490  }
1491 
1492  int zeroPosition = GetZeroPosition();
1493  if(zeroPosition > 0) {
1494  // Draw 'zero' grid line in black
1495  mDC->SetPen(*wxBLACK_PEN);
1496  if(mOrientation == wxHORIZONTAL) {
1497  if(zeroPosition != mGridLineLength)
1498  mDC->DrawLine(zeroPosition+xOffset, yOffset, zeroPosition+xOffset, mGridLineLength+yOffset);
1499  }
1500  else {
1501  if(zeroPosition != mGridLineLength)
1502  mDC->DrawLine(xOffset, zeroPosition+yOffset, mGridLineLength+xOffset, zeroPosition+yOffset);
1503  }
1504  }
1505  }
1506 }
bool mMajorGrid
Definition: Ruler.h:233
int mNumMinor
Definition: Ruler.h:212
bool mbMinor
Definition: Ruler.h:232
ArrayOf< Label > mMajorLabels
Definition: Ruler.h:211
bool mMinorGrid
Definition: Ruler.h:234
wxDC * mDC
Definition: Ruler.h:181
int mNumMajor
Definition: Ruler.h:210
int mGridLineLength
Definition: Ruler.h:235
int mOrientation
Definition: Ruler.h:224
int GetZeroPosition()
Definition: Ruler.cpp:1524
void Update()
Definition: Ruler.cpp:986
ArrayOf< Label > mMinorLabels
Definition: Ruler.h:213
void Ruler::FindLinearTickSizes ( double  UPP)
private

Definition at line 385 of file Ruler.cpp.

References IntFormat, LinearDBFormat, mDigits, mFormat, mMajor, mMinor, RealFormat, RealLogFormat, and TimeFormat.

Referenced by Update().

386 {
387  // Given the dimensions of the ruler, the range of values it
388  // has to display, and the format (i.e. Int, Real, Time),
389  // figure out how many units are in one Minor tick, and
390  // in one Major tick.
391  //
392  // The goal is to always put tick marks on nice round numbers
393  // that are easy for humans to grok. This is the most tricky
394  // with time.
395 
396  double d;
397 
398  // As a heuristic, we want at least 16 pixels
399  // between each minor tick
400  double units = 16 * fabs(UPP);
401 
402  mDigits = 0;
403 
404  switch(mFormat) {
405  case LinearDBFormat:
406  if (units < 0.001) {
407  mMinor = 0.001;
408  mMajor = 0.005;
409  return;
410  }
411  if (units < 0.01) {
412  mMinor = 0.01;
413  mMajor = 0.05;
414  return;
415  }
416  if (units < 0.1) {
417  mMinor = 0.1;
418  mMajor = 0.5;
419  return;
420  }
421  if (units < 1.0) {
422  mMinor = 1.0;
423  mMajor = 6.0;
424  return;
425  }
426  if (units < 3.0) {
427  mMinor = 3.0;
428  mMajor = 12.0;
429  return;
430  }
431  if (units < 6.0) {
432  mMinor = 6.0;
433  mMajor = 24.0;
434  return;
435  }
436  if (units < 12.0) {
437  mMinor = 12.0;
438  mMajor = 48.0;
439  return;
440  }
441  if (units < 24.0) {
442  mMinor = 24.0;
443  mMajor = 96.0;
444  return;
445  }
446  d = 20.0;
447  for(;;) {
448  if (units < d) {
449  mMinor = d;
450  mMajor = d*5.0;
451  return;
452  }
453  d *= 5.0;
454  if (units < d) {
455  mMinor = d;
456  mMajor = d*5.0;
457  return;
458  }
459  d *= 2.0;
460  }
461  break;
462 
463  case IntFormat:
464  d = 1.0;
465  for(;;) {
466  if (units < d) {
467  mMinor = d;
468  mMajor = d*5.0;
469  return;
470  }
471  d *= 5.0;
472  if (units < d) {
473  mMinor = d;
474  mMajor = d*2.0;
475  return;
476  }
477  d *= 2.0;
478  }
479  break;
480 
481  case TimeFormat:
482  if (units > 0.5) {
483  if (units < 1.0) { // 1 sec
484  mMinor = 1.0;
485  mMajor = 5.0;
486  return;
487  }
488  if (units < 5.0) { // 5 sec
489  mMinor = 5.0;
490  mMajor = 15.0;
491  return;
492  }
493  if (units < 10.0) {
494  mMinor = 10.0;
495  mMajor = 30.0;
496  return;
497  }
498  if (units < 15.0) {
499  mMinor = 15.0;
500  mMajor = 60.0;
501  return;
502  }
503  if (units < 30.0) {
504  mMinor = 30.0;
505  mMajor = 60.0;
506  return;
507  }
508  if (units < 60.0) { // 1 min
509  mMinor = 60.0;
510  mMajor = 300.0;
511  return;
512  }
513  if (units < 300.0) { // 5 min
514  mMinor = 300.0;
515  mMajor = 900.0;
516  return;
517  }
518  if (units < 600.0) { // 10 min
519  mMinor = 600.0;
520  mMajor = 1800.0;
521  return;
522  }
523  if (units < 900.0) { // 15 min
524  mMinor = 900.0;
525  mMajor = 3600.0;
526  return;
527  }
528  if (units < 1800.0) { // 30 min
529  mMinor = 1800.0;
530  mMajor = 3600.0;
531  return;
532  }
533  if (units < 3600.0) { // 1 hr
534  mMinor = 3600.0;
535  mMajor = 6*3600.0;
536  return;
537  }
538  if (units < 6*3600.0) { // 6 hrs
539  mMinor = 6*3600.0;
540  mMajor = 24*3600.0;
541  return;
542  }
543  if (units < 24*3600.0) { // 1 day
544  mMinor = 24*3600.0;
545  mMajor = 7*24*3600.0;
546  return;
547  }
548 
549  mMinor = 24.0 * 7.0 * 3600.0; // 1 week
550  mMajor = 24.0 * 7.0 * 3600.0;
551  }
552 
553  // Otherwise fall through to RealFormat
554  // (fractions of a second should be dealt with
555  // the same way as for RealFormat)
556 
557  case RealFormat:
558  d = 0.000001;
559  // mDigits is number of digits after the decimal point.
560  mDigits = 6;
561  for(;;) {
562  if (units < d) {
563  mMinor = d;
564  mMajor = d*5.0;
565  return;
566  }
567  d *= 5.0;
568  if (units < d) {
569  mMinor = d;
570  mMajor = d*2.0;
571  return;
572  }
573  d *= 2.0;
574  mDigits--;
575  // More than 10 digit numbers? Something is badly wrong.
576  // Probably units is coming in with too high a value.
577  wxASSERT( mDigits >= -10 );
578  if( mDigits < -10 )
579  break;
580  }
581  mMinor = d;
582  mMajor = d * 2.0;
583  break;
584 
585  case RealLogFormat:
586  d = 0.000001;
587  // mDigits is number of digits after the decimal point.
588  mDigits = 6;
589  for(;;) {
590  if (units < d) {
591  mMinor = d;
592  mMajor = d*5.0;
593  return;
594  }
595  d *= 5.0;
596  if (units < d) {
597  mMinor = d;
598  mMajor = d*2.0;
599  return;
600  }
601  d *= 2.0;
602  mDigits--;
603  // More than 10 digit numbers? Something is badly wrong.
604  // Probably units is coming in with too high a value.
605  wxASSERT( mDigits >= -10 );
606  if( mDigits < -10 )
607  break;
608  }
609  mDigits++;
610  mMinor = d;
611  mMajor = d * 2.0;
612  break;
613  }
614 }
double mMinor
Definition: Ruler.h:190
RulerFormat mFormat
Definition: Ruler.h:228
int mDigits
Definition: Ruler.h:192
double mMajor
Definition: Ruler.h:189
void Ruler::FindTickSizes ( )
private
int Ruler::FindZero ( Label label,
int  len 
)
private

Definition at line 1508 of file Ruler.cpp.

References Ruler::Label::value.

Referenced by GetZeroPosition().

1509 {
1510  int i = 0;
1511  double d = 1.0; // arbitrary
1512 
1513  do {
1514  d = label[i].value;
1515  i++;
1516  } while( (i < len) && (d != 0.0) );
1517 
1518  if(d == 0.0)
1519  return (label[i - 1].pos) ;
1520  else
1521  return -1;
1522 }
wxString label
Definition: Tags.cpp:727
Fonts Ruler::GetFonts ( ) const
inline

Definition at line 106 of file Ruler.h.

107  { return { mMajorFont.get(), mMinorFont.get(), mMinorMinorFont.get() }; }
std::unique_ptr< wxFont > mMinorMinorFont
Definition: Ruler.h:183
std::unique_ptr< wxFont > mMinorFont
Definition: Ruler.h:183
std::unique_ptr< wxFont > mMajorFont
Definition: Ruler.h:183
void Ruler::GetMaxSize ( wxCoord *  width,
wxCoord *  height 
)

Definition at line 1533 of file Ruler.cpp.

References mDC, mRect, mValid, and Update().

Referenced by FreqWindow::DrawPlot(), FreqWindow::FreqWindow(), AdornedRulerPanel::GetMaxSize(), EffectCompressorPanel::OnPaint(), EffectScienFilter::PopulateOrExchange(), EffectEqualization::PopulateOrExchange(), Meter::SetActiveStyle(), EffectEqualization::TransferDataFromWindow(), and EffectScienFilter::TransferGraphLimitsFromWindow().

1534 {
1535  if (!mValid) {
1536  wxScreenDC sdc;
1537  mDC = &sdc;
1538  Update(NULL);
1539  }
1540 
1541  if (width)
1542  *width = mRect.GetWidth(); //mMaxWidth;
1543 
1544  if (height)
1545  *height = mRect.GetHeight(); //mMaxHeight;
1546 }
bool mValid
Definition: Ruler.h:198
wxRect mRect
Definition: Ruler.h:171
wxDC * mDC
Definition: Ruler.h:181
void Update()
Definition: Ruler.cpp:986
int Ruler::GetZeroPosition ( )

Definition at line 1524 of file Ruler.cpp.

References FindZero(), mMajorLabels, mMinorLabels, mNumMajor, and mNumMinor.

Referenced by DrawGrid().

1525 {
1526  int zero;
1527  if((zero = FindZero(mMajorLabels.get(), mNumMajor)) < 0)
1528  zero = FindZero(mMinorLabels.get(), mNumMinor);
1529  // PRL: don't consult minor minor??
1530  return zero;
1531 }
int mNumMinor
Definition: Ruler.h:212
ArrayOf< Label > mMajorLabels
Definition: Ruler.h:211
int FindZero(Label *label, int len)
Definition: Ruler.cpp:1508
int mNumMajor
Definition: Ruler.h:210
ArrayOf< Label > mMinorLabels
Definition: Ruler.h:213
void Ruler::Invalidate ( )

Definition at line 369 of file Ruler.cpp.

References mBits, mBottom, mLeft, mLength, mOrientation, mRight, mTop, mUserBitLen, mUserBits, and mValid.

Referenced by AdornedRulerPanel::InvalidateRuler(), SetBounds(), SetFlip(), SetFonts(), SetFormat(), SetLabelEdges(), SetLog(), SetNumberScale(), SetOrientation(), SetSpacing(), SetUnits(), and ~Ruler().

370 {
371  mValid = false;
372 
373  if (mOrientation == wxHORIZONTAL)
374  mLength = mRight-mLeft;
375  else
376  mLength = mBottom-mTop;
377 
378  mBits.reset();
379  if (mUserBits && mLength+1 != mUserBitLen) {
380  mUserBits.reset();
381  mUserBitLen = 0;
382  }
383 }
ArrayOf< int > mUserBits
Definition: Ruler.h:194
ArrayOf< int > mBits
Definition: Ruler.h:195
bool mValid
Definition: Ruler.h:198
int mTop
Definition: Ruler.h:178
int mRight
Definition: Ruler.h:178
int mBottom
Definition: Ruler.h:178
int mUserBitLen
Definition: Ruler.h:196
int mLength
Definition: Ruler.h:179
int mLeft
Definition: Ruler.h:178
int mOrientation
Definition: Ruler.h:224
wxString Ruler::LabelString ( double  d,
bool  major 
)
private

Definition at line 616 of file Ruler.cpp.

References format, IntFormat, LinearDBFormat, mDigits, mFormat, mMinor, mUnits, RealFormat, RealLogFormat, and TimeFormat.

Referenced by Tick().

617 {
618  // Given a value, turn it into a string according
619  // to the current ruler format. The number of digits of
620  // accuracy depends on the resolution of the ruler,
621  // i.e. how far zoomed in or out you are.
622 
623  wxString s;
624 
625  // Replace -0 with 0
626  if (d < 0.0 && (d+mMinor > 0.0) && ( mFormat != RealLogFormat ))
627  d = 0.0;
628 
629  switch(mFormat) {
630  case IntFormat:
631  s.Printf(wxT("%d"), (int)floor(d+0.5));
632  break;
633  case LinearDBFormat:
634  if (mMinor >= 1.0)
635  s.Printf(wxT("%d"), (int)floor(d+0.5));
636  else {
637  int precision = -log10(mMinor);
638  s.Printf(wxT("%.*f"), precision, d);
639  }
640  break;
641  case RealFormat:
642  if (mMinor >= 1.0)
643  s.Printf(wxT("%d"), (int)floor(d+0.5));
644  else {
645  s.Printf(wxString::Format(wxT("%%.%df"), mDigits), d);
646  }
647  break;
648  case RealLogFormat:
649  if (mMinor >= 1.0)
650  s.Printf(wxT("%d"), (int)floor(d+0.5));
651  else {
652  s.Printf(wxString::Format(wxT("%%.%df"), mDigits), d);
653  }
654  break;
655  case TimeFormat:
656  if (major) {
657  if (d < 0) {
658  s = wxT("-");
659  d = -d;
660  }
661 
662  #if ALWAYS_HH_MM_SS
663  int secs = (int)(d + 0.5);
664  if (mMinor >= 1.0) {
665  s.Printf(wxT("%d:%02d:%02d"), secs/3600, (secs/60)%60, secs%60);
666  }
667  else {
668  wxString t1, t2, format;
669  t1.Printf(wxT("%d:%02d:"), secs/3600, (secs/60)%60);
670  format.Printf(wxT("%%0%d.%dlf"), mDigits+3, mDigits);
671  t2.Printf(format, fmod(d, 60.0));
672  s += t1 + t2;
673  }
674  break;
675  #endif
676 
677  if (mMinor >= 3600.0) {
678  int hrs = (int)(d / 3600.0 + 0.5);
679  wxString h;
680  h.Printf(wxT("%d:00:00"), hrs);
681  s += h;
682  }
683  else if (mMinor >= 60.0) {
684  int minutes = (int)(d / 60.0 + 0.5);
685  wxString m;
686  if (minutes >= 60)
687  m.Printf(wxT("%d:%02d:00"), minutes/60, minutes%60);
688  else
689  m.Printf(wxT("%d:00"), minutes);
690  s += m;
691  }
692  else if (mMinor >= 1.0) {
693  int secs = (int)(d + 0.5);
694  wxString t;
695  if (secs >= 3600)
696  t.Printf(wxT("%d:%02d:%02d"), secs/3600, (secs/60)%60, secs%60);
697  else if (secs >= 60)
698  t.Printf(wxT("%d:%02d"), secs/60, secs%60);
699  else
700  t.Printf(wxT("%d"), secs);
701  s += t;
702  }
703  else {
704 // Commented out old and incorrect code for avoiding the 40mins and 60 seconds problem
705 // It was causing Bug 463 - Incorrect Timeline numbering (where at high zoom and long tracks,
706 // numbers did not change.
707 #if 0
708  // The casting to float is working around an issue where 59 seconds
709  // would show up as 60 when using g++ (Ubuntu 4.3.3-5ubuntu4) 4.3.3.
710  int secs = (int)(float)(d);
711  wxString t1, t2, format;
712 
713  if (secs >= 3600)
714  t1.Printf(wxT("%d:%02d:"), secs/3600, (secs/60)%60);
715  else if (secs >= 60)
716  t1.Printf(wxT("%d:"), secs/60);
717 
718  if (secs >= 60)
719  format.Printf(wxT("%%0%d.%dlf"), mDigits+3, mDigits);
720  else
721  format.Printf(wxT("%%%d.%dlf"), mDigits+3, mDigits);
722  // The casting to float is working around an issue where 59 seconds
723  // would show up as 60 when using g++ (Ubuntu 4.3.3-5ubuntu4) 4.3.3.
724  t2.Printf(format, fmod((float)d, (float)60.0));
725 #else
726  // For d in the range of hours, d is just very slightly below the value it should
727  // have, because of using a double, which in turn yields values like 59:59:999999
728  // mins:secs:nanosecs when we want 1:00:00:000000
729  // so adjust by less than a nano second per hour to get nicer number formatting.
730  double dd = d * 1.000000000000001;
731  int secs = (int)(dd);
732  wxString t1, t2, format;
733 
734  if (secs >= 3600)
735  t1.Printf(wxT("%d:%02d:"), secs/3600, (secs/60)%60);
736  else if (secs >= 60)
737  t1.Printf(wxT("%d:"), secs/60);
738 
739  if (secs >= 60)
740  format.Printf(wxT("%%0%d.%dlf"), mDigits+3, mDigits);
741  else
742  format.Printf(wxT("%%%d.%dlf"), mDigits+3, mDigits);
743  // dd will be reduced to just the seconds and fractional part.
744  dd = dd - secs + (secs%60);
745  // truncate to appropriate number of digits, so that the print formatting
746  // doesn't round up 59.9999999 to 60.
747  double multiplier = pow( 10, mDigits);
748  dd = ((int)(dd * multiplier))/multiplier;
749  t2.Printf(format, dd);
750 #endif
751  s += t1 + t2;
752  }
753  }
754  else {
755  }
756  }
757 
758  if (mUnits != wxT(""))
759  s = (s + mUnits);
760 
761  return s;
762 }
wxString mUnits
Definition: Ruler.h:236
int format
Definition: ExportPCM.cpp:56
double mMinor
Definition: Ruler.h:190
RulerFormat mFormat
Definition: Ruler.h:228
int mDigits
Definition: Ruler.h:192
void Ruler::OfflimitsPixels ( int  start,
int  end 
)

Definition at line 331 of file Ruler.cpp.

References mBottom, mLeft, mLength, mOrientation, mRight, mTop, mUserBitLen, mUserBits, and ArrayOf< X >::reinit().

Referenced by Meter::HandleLayout().

332 {
333  if (!mUserBits) {
334  if (mOrientation == wxHORIZONTAL)
335  mLength = mRight-mLeft;
336  else
337  mLength = mBottom-mTop;
338  if( mLength < 0 )
339  return;
340  mUserBits.reinit(static_cast<size_t>(mLength+1), true);
341  mUserBitLen = mLength+1;
342  }
343 
344  if (end < start)
345  std::swap( start, end );
346 
347  if (start < 0)
348  start = 0;
349  if (end > mLength)
350  end = mLength;
351 
352  for(int i = start; i <= end; i++)
353  mUserBits[i] = 1;
354 }
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:499
ArrayOf< int > mUserBits
Definition: Ruler.h:194
int mTop
Definition: Ruler.h:178
int mRight
Definition: Ruler.h:178
int mBottom
Definition: Ruler.h:178
int mUserBitLen
Definition: Ruler.h:196
int mLength
Definition: Ruler.h:179
int mLeft
Definition: Ruler.h:178
int mOrientation
Definition: Ruler.h:224
void Ruler::SetBounds ( int  left,
int  top,
int  right,
int  bottom 
)

Definition at line 356 of file Ruler.cpp.

References Invalidate(), mBottom, mLeft, mRight, and mTop.

Referenced by FreqWindow::FreqWindow(), Meter::HandleLayout(), EffectCompressorPanel::OnPaint(), AudacityPrintout::OnPrintPage(), EffectScienFilter::PopulateOrExchange(), EffectEqualization::PopulateOrExchange(), Meter::SetActiveStyle(), and AdornedRulerPanel::UpdateRects().

357 {
358  if (mLeft != left || mTop != top ||
359  mRight != right || mBottom != bottom) {
360  mLeft = left;
361  mTop = top;
362  mRight = right;
363  mBottom = bottom;
364 
365  Invalidate();
366  }
367 }
void Invalidate()
Definition: Ruler.cpp:369
int mTop
Definition: Ruler.h:178
int mRight
Definition: Ruler.h:178
int mBottom
Definition: Ruler.h:178
int mLeft
Definition: Ruler.h:178
void Ruler::SetCustomMajorLabels ( wxArrayString *  label,
size_t  numLabel,
int  start,
int  step 
)

Definition at line 1551 of file Ruler.cpp.

References mMajorLabels, and mNumMajor.

1552 {
1553  mNumMajor = numLabel;
1554  mMajorLabels.reinit(numLabel);
1555 
1556  for(size_t i = 0; i<numLabel; i++) {
1557  mMajorLabels[i].text = label->Item(i);
1558  mMajorLabels[i].pos = start + i*step;
1559  }
1560  //Remember: DELETE majorlabels....
1561 }
ArrayOf< Label > mMajorLabels
Definition: Ruler.h:211
wxString label
Definition: Tags.cpp:727
int mNumMajor
Definition: Ruler.h:210
void Ruler::SetCustomMinorLabels ( wxArrayString *  label,
size_t  numLabel,
int  start,
int  step 
)

Definition at line 1563 of file Ruler.cpp.

References mMinorLabels, and mNumMinor.

1564 {
1565  mNumMinor = numLabel;
1566  mMinorLabels.reinit(numLabel);
1567 
1568  for(size_t i = 0; i<numLabel; i++) {
1569  mMinorLabels[i].text = label->Item(i);
1570  mMinorLabels[i].pos = start + i*step;
1571  }
1572  //Remember: DELETE majorlabels....
1573 }
int mNumMinor
Definition: Ruler.h:212
wxString label
Definition: Tags.cpp:727
ArrayOf< Label > mMinorLabels
Definition: Ruler.h:213
void Ruler::SetCustomMode ( bool  value)

Definition at line 1549 of file Ruler.cpp.

References mCustom.

1549 { mCustom = value; }
bool mCustom
Definition: Ruler.h:231
void Ruler::SetFlip ( bool  flip)

Definition at line 285 of file Ruler.cpp.

References Invalidate(), and mFlip.

Referenced by FreqWindow::FreqWindow(), EffectCompressorPanel::OnPaint(), EffectScienFilter::PopulateOrExchange(), and EffectEqualization::PopulateOrExchange().

286 {
287  // If this is true, the orientation of the tick marks
288  // is reversed from the default; eg. above the line
289  // instead of below
290 
291  if (mFlip != flip) {
292  mFlip = flip;
293 
294  Invalidate();
295  }
296 }
bool mFlip
Definition: Ruler.h:230
void Invalidate()
Definition: Ruler.cpp:369
void Ruler::SetFonts ( const wxFont &  minorFont,
const wxFont &  majorFont,
const wxFont &  minorMinorFont 
)

Definition at line 303 of file Ruler.cpp.

References Invalidate(), mMajorFont, mMinorFont, mMinorMinorFont, and mUserFonts.

304 {
305  *mMinorMinorFont = minorMinorFont;
306  *mMinorFont = minorFont;
307  *mMajorFont = majorFont;
308 
309  // Won't override these fonts
310  mUserFonts = true;
311 
312  Invalidate();
313 }
std::unique_ptr< wxFont > mMinorMinorFont
Definition: Ruler.h:183
std::unique_ptr< wxFont > mMinorFont
Definition: Ruler.h:183
bool mUserFonts
Definition: Ruler.h:184
void Invalidate()
Definition: Ruler.cpp:369
std::unique_ptr< wxFont > mMajorFont
Definition: Ruler.h:183
void Ruler::SetFormat ( RulerFormat  format)

Definition at line 186 of file Ruler.cpp.

References format, Invalidate(), and mFormat.

Referenced by FreqWindow::DrawPlot(), FreqWindow::FreqWindow(), EffectCompressorPanel::OnPaint(), AudacityPrintout::OnPrintPage(), EffectScienFilter::PopulateOrExchange(), EffectEqualization::PopulateOrExchange(), and Meter::SetActiveStyle().

187 {
188  // IntFormat, RealFormat, RealLogFormat, TimeFormat, or LinearDBFormat
189 
190  if (mFormat != format) {
191  mFormat = format;
192 
193  Invalidate();
194  }
195 }
void Invalidate()
Definition: Ruler.cpp:369
int format
Definition: ExportPCM.cpp:56
RulerFormat mFormat
Definition: Ruler.h:228
void Ruler::SetLabelEdges ( bool  labelEdges)

Definition at line 272 of file Ruler.cpp.

References Invalidate(), and mLabelEdges.

Referenced by FreqWindow::FreqWindow(), AudacityPrintout::OnPrintPage(), EffectScienFilter::PopulateOrExchange(), and EffectEqualization::PopulateOrExchange().

273 {
274  // If this is true, the edges of the ruler will always
275  // receive a label. If not, the nearest round number is
276  // labeled (which may or may not be the edge).
277 
278  if (mLabelEdges != labelEdges) {
279  mLabelEdges = labelEdges;
280 
281  Invalidate();
282  }
283 }
bool mLabelEdges
Definition: Ruler.h:227
void Invalidate()
Definition: Ruler.cpp:369
void Ruler::SetLog ( bool  log)

Definition at line 197 of file Ruler.cpp.

References Invalidate(), and mLog.

Referenced by FreqWindow::DrawPlot(), FreqWindow::FreqWindow(), EffectEqualization::OnLinFreq(), EffectScienFilter::PopulateOrExchange(), EffectEqualization::PopulateOrExchange(), EffectEqualization::UpdateDraw(), and EffectEqualization::UpdateGraphic().

198 {
199  // Logarithmic
200 
201  if (mLog != log) {
202  mLog = log;
203 
204  Invalidate();
205  }
206 }
void Invalidate()
Definition: Ruler.cpp:369
bool mLog
Definition: Ruler.h:229
void Ruler::SetMinor ( bool  value)

Definition at line 298 of file Ruler.cpp.

References mbMinor.

299 {
300  mbMinor = value;
301 }
bool mbMinor
Definition: Ruler.h:232
void Ruler::SetNumberScale ( const NumberScale pScale)

Definition at line 315 of file Ruler.cpp.

References Invalidate(), and mpNumberScale.

316 {
317  if (!pScale) {
318  if (mpNumberScale) {
319  mpNumberScale.reset();
320  Invalidate();
321  }
322  }
323  else {
324  if (!mpNumberScale || *mpNumberScale != *pScale) {
325  mpNumberScale = std::make_unique<NumberScale>(*pScale);
326  Invalidate();
327  }
328  }
329 }
std::unique_ptr< NumberScale > mpNumberScale
Definition: Ruler.h:241
void Invalidate()
Definition: Ruler.cpp:369
void Ruler::SetOrientation ( int  orient)

Definition at line 220 of file Ruler.cpp.

References Invalidate(), mHasSetSpacing, mOrientation, and mSpacing.

Referenced by FreqWindow::FreqWindow(), EffectCompressorPanel::OnPaint(), AudacityPrintout::OnPrintPage(), EffectScienFilter::PopulateOrExchange(), EffectEqualization::PopulateOrExchange(), and Meter::SetActiveStyle().

221 {
222  // wxHORIZONTAL || wxVERTICAL
223 
224  if (mOrientation != orient) {
225  mOrientation = orient;
226 
227  if (mOrientation == wxVERTICAL && !mHasSetSpacing)
228  mSpacing = 2;
229 
230  Invalidate();
231  }
232 }
bool mHasSetSpacing
Definition: Ruler.h:226
void Invalidate()
Definition: Ruler.cpp:369
int mOrientation
Definition: Ruler.h:224
int mSpacing
Definition: Ruler.h:225
void Ruler::SetRange ( double  min,
double  max 
)
void Ruler::SetRange ( double  min,
double  max,
double  hiddenMin,
double  hiddenMax 
)

Definition at line 240 of file Ruler.cpp.

References min().

241 {
242  // For a horizontal ruler,
243  // min is the value in the center of pixel "left",
244  // max is the value in the center of pixel "right".
245 
246  // In the special case of a time ruler,
247  // hiddenMin and hiddenMax are values that would be shown with the fisheye
248  // turned off. In other cases they equal min and max respectively.
249 
250  if (mMin != min || mMax != max ||
251  mHiddenMin != hiddenMin || mHiddenMax != hiddenMax) {
252  mMin = min;
253  mMax = max;
254  mHiddenMin = hiddenMin;
255  mHiddenMax = hiddenMax;
256 
257  Invalidate();
258  }
259 }
double mMax
Definition: Ruler.h:186
double mMin
Definition: Ruler.h:186
void Invalidate()
Definition: Ruler.cpp:369
int min(int a, int b)
double mHiddenMin
Definition: Ruler.h:187
double mHiddenMax
Definition: Ruler.h:187
void Ruler::SetSpacing ( int  spacing)

Definition at line 261 of file Ruler.cpp.

References Invalidate(), mHasSetSpacing, and mSpacing.

262 {
263  mHasSetSpacing = true;
264 
265  if (mSpacing != spacing) {
266  mSpacing = spacing;
267 
268  Invalidate();
269  }
270 }
bool mHasSetSpacing
Definition: Ruler.h:226
void Invalidate()
Definition: Ruler.cpp:369
int mSpacing
Definition: Ruler.h:225
void Ruler::SetTickColour ( const wxColour &  colour)
inline

Definition at line 150 of file Ruler.h.

Referenced by AdornedRulerPanel::DoDrawMarks(), EffectCompressorPanel::OnPaint(), Meter::OnPaint(), and EffectEqualization::PopulateOrExchange().

151  { mTickColour = colour; mPen.SetColour( colour );}
wxPen mPen
Definition: Ruler.h:175
wxColour mTickColour
Definition: Ruler.h:174
void Ruler::SetTwoTone ( bool  twoTone)

Definition at line 181 of file Ruler.cpp.

References mTwoTone.

Referenced by AdornedRulerPanel::UpdatePrefs().

182 {
183  mTwoTone = twoTone;
184 }
bool mTwoTone
Definition: Ruler.h:237
void Ruler::SetUnits ( const wxString &  units)

Definition at line 208 of file Ruler.cpp.

References Invalidate(), and mUnits.

Referenced by FreqWindow::DrawPlot(), FreqWindow::FreqWindow(), EffectCompressorPanel::OnPaint(), EffectScienFilter::PopulateOrExchange(), and EffectEqualization::PopulateOrExchange().

209 {
210  // Specify the name of the units (like "dB") if you
211  // want numbers like "1.6" formatted as "1.6 dB".
212 
213  if (mUnits != units) {
214  mUnits = units;
215 
216  Invalidate();
217  }
218 }
wxString mUnits
Definition: Ruler.h:236
void Invalidate()
Definition: Ruler.cpp:369
void Ruler::SetUseZoomInfo ( int  leftOffset,
const ZoomInfo zoomInfo 
)

Definition at line 1590 of file Ruler.cpp.

References mLeftOffset, and mUseZoomInfo.

Referenced by AdornedRulerPanel::SetLeftOffset().

1591 {
1592  mLeftOffset = leftOffset;
1593  mUseZoomInfo = zoomInfo;
1594 }
int mLeftOffset
Definition: Ruler.h:239
const ZoomInfo * mUseZoomInfo
Definition: Ruler.h:238
void Ruler::Tick ( int  pos,
double  d,
bool  major,
bool  minor 
)
private

Definition at line 764 of file Ruler.cpp.

References label, LabelString(), Ruler::Label::lx, Ruler::Label::ly, mBits, mDC, mFlip, mLead, mLeft, mLength, mMajorFont, mMajorLabels, mMaxHeight, mMaxWidth, mMinorFont, mMinorLabels, mMinorMinorFont, mMinorMinorLabels, mNumMajor, mNumMinor, mNumMinorMinor, mOrientation, mRect, mSpacing, mTop, Ruler::Label::pos, Ruler::Label::text, and Ruler::Label::value.

Referenced by Update().

765 {
766  wxString l;
767  wxCoord strW, strH, strD, strL;
768  int strPos, strLen, strLeft, strTop;
769 
770  // FIXME: We don't draw a tick if of end of our label arrays
771  // But we shouldn't have an array of labels.
772  if( mNumMinorMinor >= mLength )
773  return;
774  if( mNumMinor >= mLength )
775  return;
776  if( mNumMajor >= mLength )
777  return;
778 
779  Label *label;
780  if (major)
781  label = &mMajorLabels[mNumMajor++];
782  else if (minor)
783  label = &mMinorLabels[mNumMinor++];
784  else
785  label = &mMinorMinorLabels[mNumMinorMinor++];
786 
787  label->value = d;
788  label->pos = pos;
789  label->lx = mLeft - 1000; // don't display
790  label->ly = mTop - 1000; // don't display
791  label->text = wxT("");
792 
793  mDC->SetFont(major? *mMajorFont: minor? *mMinorFont : *mMinorMinorFont);
794  l = LabelString(d, major);
795  mDC->GetTextExtent(l, &strW, &strH, &strD, &strL);
796 
797  if (mOrientation == wxHORIZONTAL) {
798  strLen = strW;
799  strPos = pos - strW/2;
800  if (strPos < 0)
801  strPos = 0;
802  if (strPos + strW >= mLength)
803  strPos = mLength - strW;
804  strLeft = mLeft + strPos;
805  if (mFlip) {
806  strTop = mTop + 4;
807  mMaxHeight = max(mMaxHeight, strH + 4);
808  }
809  else {
810  strTop =-strH-mLead;
811  mMaxHeight = max(mMaxHeight, strH + 6);
812  }
813  }
814  else {
815  strLen = strH;
816  strPos = pos - strH/2;
817  if (strPos < 0)
818  strPos = 0;
819  if (strPos + strH >= mLength)
820  strPos = mLength - strH;
821  strTop = mTop + strPos;
822  if (mFlip) {
823  strLeft = mLeft + 5;
824  mMaxWidth = max(mMaxWidth, strW + 5);
825  }
826  else
827  strLeft =-strW-6;
828  }
829 
830 
831  // FIXME: we shouldn't even get here if strPos < 0.
832  // Ruler code currently does not handle very small or
833  // negative sized windows (i.e. don't draw) properly.
834  if( strPos < 0 )
835  return;
836 
837  // See if any of the pixels we need to draw this
838  // label is already covered
839 
840  int i;
841  for(i=0; i<strLen; i++)
842  if (mBits[strPos+i])
843  return;
844 
845  // If not, position the label and give it text
846 
847  label->lx = strLeft;
848  label->ly = strTop;
849  label->text = l;
850 
851  // And mark these pixels, plus some surrounding
852  // ones (the spacing between labels), as covered
853  int leftMargin = mSpacing;
854  if (strPos < leftMargin)
855  leftMargin = strPos;
856  strPos -= leftMargin;
857  strLen += leftMargin;
858 
859  int rightMargin = mSpacing;
860  if (strPos + strLen > mLength - mSpacing)
861  rightMargin = mLength - strPos - strLen;
862  strLen += rightMargin;
863 
864  for(i=0; i<strLen; i++)
865  mBits[strPos+i] = 1;
866 
867  wxRect r(strLeft, strTop, strW, strH);
868  mRect.Union(r);
869 
870 }
std::unique_ptr< wxFont > mMinorMinorFont
Definition: Ruler.h:183
int mNumMinor
Definition: Ruler.h:212
std::unique_ptr< wxFont > mMinorFont
Definition: Ruler.h:183
ArrayOf< Label > mMajorLabels
Definition: Ruler.h:211
bool mFlip
Definition: Ruler.h:230
wxString label
Definition: Tags.cpp:727
ArrayOf< int > mBits
Definition: Ruler.h:195
int mMaxWidth
Definition: Ruler.h:177
wxRect mRect
Definition: Ruler.h:171
int mTop
Definition: Ruler.h:178
wxString LabelString(double d, bool major)
Definition: Ruler.cpp:616
int mMaxHeight
Definition: Ruler.h:177
ArrayOf< Label > mMinorMinorLabels
Definition: Ruler.h:215
int mLead
Definition: Ruler.h:178
int mLength
Definition: Ruler.h:179
wxDC * mDC
Definition: Ruler.h:181
int mNumMajor
Definition: Ruler.h:210
int mNumMinorMinor
Definition: Ruler.h:214
int mLeft
Definition: Ruler.h:178
int mOrientation
Definition: Ruler.h:224
std::unique_ptr< wxFont > mMajorFont
Definition: Ruler.h:183
int mSpacing
Definition: Ruler.h:225
ArrayOf< Label > mMinorLabels
Definition: Ruler.h:213
void Ruler::TickCustom ( int  labelIdx,
bool  major,
bool  minor 
)
private

Definition at line 872 of file Ruler.cpp.

References label, Ruler::Label::lx, Ruler::Label::ly, mBits, mDC, mFlip, mLead, mLeft, mLength, mMajorFont, mMajorLabels, mMaxHeight, mMaxWidth, mMinorFont, mMinorLabels, mMinorMinorFont, mMinorMinorLabels, mNumMajor, mNumMinor, mOrientation, mRect, mSpacing, mTop, Ruler::Label::pos, Ruler::Label::text, and Ruler::Label::value.

Referenced by Update().

873 {
874  //This should only used in the mCustom case
875  // Many code comes from 'Tick' method: this should
876  // be optimized.
877 
878  int pos;
879  wxString l;
880  wxCoord strW, strH, strD, strL;
881  int strPos, strLen, strLeft, strTop;
882 
883  // FIXME: We don't draw a tick if of end of our label arrays
884  // But we shouldn't have an array of labels.
885  if( mNumMinor >= mLength )
886  return;
887  if( mNumMajor >= mLength )
888  return;
889 
890  Label *label;
891  if (major)
892  label = &mMajorLabels[labelIdx];
893  else if (minor)
894  label = &mMinorLabels[labelIdx];
895  else
896  label = &mMinorMinorLabels[labelIdx];
897 
898  label->value = 0.0;
899  pos = label->pos; // already stored in label class
900  l = label->text;
901  label->lx = mLeft - 1000; // don't display
902  label->ly = mTop - 1000; // don't display
903 
904  mDC->SetFont(major? *mMajorFont: minor? *mMinorFont : *mMinorMinorFont);
905 
906  mDC->GetTextExtent(l, &strW, &strH, &strD, &strL);
907 
908  if (mOrientation == wxHORIZONTAL) {
909  strLen = strW;
910  strPos = pos - strW/2;
911  if (strPos < 0)
912  strPos = 0;
913  if (strPos + strW >= mLength)
914  strPos = mLength - strW;
915  strLeft = mLeft + strPos;
916  if (mFlip) {
917  strTop = mTop + 4;
918  mMaxHeight = max(mMaxHeight, strH + 4);
919  }
920  else {
921 
922  strTop = mTop- mLead+4;// More space was needed...
923  mMaxHeight = max(mMaxHeight, strH + 6);
924  }
925  }
926  else {
927  strLen = strH;
928  strPos = pos - strH/2;
929  if (strPos < 0)
930  strPos = 0;
931  if (strPos + strH >= mLength)
932  strPos = mLength - strH;
933  strTop = mTop + strPos;
934  if (mFlip) {
935  strLeft = mLeft + 5;
936  mMaxWidth = max(mMaxWidth, strW + 5);
937  }
938  else {
939 
940  strLeft =-strW-6;
941  }
942  }
943 
944 
945  // FIXME: we shouldn't even get here if strPos < 0.
946  // Ruler code currently does not handle very small or
947  // negative sized windows (i.e. don't draw) properly.
948  if( strPos < 0 )
949  return;
950 
951  // See if any of the pixels we need to draw this
952  // label is already covered
953 
954  int i;
955  for(i=0; i<strLen; i++)
956  if (mBits[strPos+i])
957  return;
958 
959  // If not, position the label
960 
961  label->lx = strLeft;
962  label->ly = strTop;
963 
964  // And mark these pixels, plus some surrounding
965  // ones (the spacing between labels), as covered
966  int leftMargin = mSpacing;
967  if (strPos < leftMargin)
968  leftMargin = strPos;
969  strPos -= leftMargin;
970  strLen += leftMargin;
971 
972  int rightMargin = mSpacing;
973  if (strPos + strLen > mLength - mSpacing)
974  rightMargin = mLength - strPos - strLen;
975  strLen += rightMargin;
976 
977  for(i=0; i<strLen; i++)
978  mBits[strPos+i] = 1;
979 
980 
981  wxRect r(strLeft, strTop, strW, strH);
982  mRect.Union(r);
983 
984 }
std::unique_ptr< wxFont > mMinorMinorFont
Definition: Ruler.h:183
int mNumMinor
Definition: Ruler.h:212
std::unique_ptr< wxFont > mMinorFont
Definition: Ruler.h:183
ArrayOf< Label > mMajorLabels
Definition: Ruler.h:211
bool mFlip
Definition: Ruler.h:230
wxString label
Definition: Tags.cpp:727
ArrayOf< int > mBits
Definition: Ruler.h:195
int mMaxWidth
Definition: Ruler.h:177
wxRect mRect
Definition: Ruler.h:171
int mTop
Definition: Ruler.h:178
int mMaxHeight
Definition: Ruler.h:177
ArrayOf< Label > mMinorMinorLabels
Definition: Ruler.h:215
int mLead
Definition: Ruler.h:178
int mLength
Definition: Ruler.h:179
wxDC * mDC
Definition: Ruler.h:181
int mNumMajor
Definition: Ruler.h:210
int mLeft
Definition: Ruler.h:178
int mOrientation
Definition: Ruler.h:224
std::unique_ptr< wxFont > mMajorFont
Definition: Ruler.h:183
int mSpacing
Definition: Ruler.h:225
ArrayOf< Label > mMinorLabels
Definition: Ruler.h:213
void Ruler::Update ( )
private

Definition at line 986 of file Ruler.cpp.

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

987 {
988  Update(NULL);
989 }
void Update()
Definition: Ruler.cpp:986
void Ruler::Update ( const TimeTrack timetrack)
private

Definition at line 991 of file Ruler.cpp.

References TimeTrack::ComputeWarpedLength(), FindLinearTickSizes(), IntFormat, mBits, mBottom, mCustom, mDC, mDigits, mFlip, mFormat, mHiddenMax, mHiddenMin, min(), mLabelEdges, mLead, mLeft, mLeftOffset, mLength, mLengthOld, mLog, mMajor, mMajorFont, mMajorLabels, mMax, mMaxHeight, mMaxWidth, mMin, mMinor, mMinorFont, mMinorLabels, mMinorMinorFont, mMinorMinorLabels, mNumMajor, mNumMinor, mNumMinorMinor, mOrientation, mpNumberScale, mRect, mRight, mTop, mUserBits, mUserFonts, mUseZoomInfo, mValid, nstLogarithmic, ZoomInfo::PositionToTime(), ArrayOf< X >::reinit(), Tick(), TickCustom(), ZoomInfo::TimeToPosition(), and NumberScale::ValueToPosition().

992 {
993  const ZoomInfo *zoomInfo = NULL;
994  if (!mLog && mOrientation == wxHORIZONTAL)
995  zoomInfo = mUseZoomInfo;
996 
997  // This gets called when something has been changed
998  // (i.e. we've been invalidated). Recompute all
999  // tick positions and font size.
1000 
1001  int i;
1002  int j;
1003 
1004  if (!mUserFonts) {
1005  int fontSize = 4;
1006  wxCoord strW, strH, strD, strL;
1007  wxString exampleText = wxT("0.9"); //ignored for height calcs on all platforms
1008  int desiredPixelHeight;
1009 
1010 
1011  static const int MinPixelHeight = 10; // 8;
1012  static const int MaxPixelHeight =
1013 #ifdef __WXMAC__
1014  10
1015 #else
1016  12
1017 #endif
1018  ;
1019 
1020  if (mOrientation == wxHORIZONTAL)
1021  desiredPixelHeight = mBottom - mTop - 5; // height less ticks and 1px gap
1022  else
1023  desiredPixelHeight = MaxPixelHeight;
1024 
1025  desiredPixelHeight =
1026  std::max(MinPixelHeight, std::min(MaxPixelHeight,
1027  desiredPixelHeight));
1028 
1029  // Keep making the font bigger until it's too big, then subtract one.
1030  mDC->SetFont(wxFont(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
1031  mDC->GetTextExtent(exampleText, &strW, &strH, &strD, &strL);
1032  while ((strH - strD - strL) <= desiredPixelHeight && fontSize < 40) {
1033  fontSize++;
1034  mDC->SetFont(wxFont(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
1035  mDC->GetTextExtent(exampleText, &strW, &strH, &strD, &strL);
1036  }
1037  fontSize--;
1038  mDC->SetFont(wxFont(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
1039  mDC->GetTextExtent(exampleText, &strW, &strH, &strD, &strL);
1040  mLead = strL;
1041 
1042  mMajorFont = std::make_unique<wxFont>(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
1043 
1044  mMinorFont = std::make_unique<wxFont>(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
1045 
1046  mMinorMinorFont = std::make_unique<wxFont>(fontSize - 1, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
1047  }
1048 
1049  // If ruler is being resized, we could end up with it being too small.
1050  // Values of mLength of zero or below cause bad array allocations and
1051  // division by zero. So...
1052  // IF too small THEN bail out and don't draw.
1053  if( mLength <= 0 )
1054  return;
1055 
1056  if (mOrientation == wxHORIZONTAL) {
1057  mMaxWidth = mLength;
1058  mMaxHeight = 0;
1059  mRect = wxRect(0,0, mLength,0);
1060  }
1061  else {
1062  mMaxWidth = 0;
1063  mMaxHeight = mLength;
1064  mRect = wxRect(0,0, 0,mLength);
1065  }
1066 
1067  // FIXME: Surely we do not need to allocate storage for the labels?
1068  // We can just recompute them as we need them? Yes, but only if
1069  // mCustom is false!!!!
1070 
1071  auto size = static_cast<size_t>(mLength + 1);
1072  if(!mCustom) {
1073  mNumMajor = 0;
1074  mNumMinor = 0;
1075  mNumMinorMinor = 0;
1076  if (mLength!=mLengthOld) {
1077  mMajorLabels.reinit(size);
1078  mMinorLabels.reinit(size);
1079  mMinorMinorLabels.reinit(size);
1080  mLengthOld = mLength;
1081  }
1082  }
1083 
1084  mBits.reinit(size);
1085  if (mUserBits)
1086  for(i=0; i<=mLength; i++)
1087  mBits[i] = mUserBits[i];
1088  else
1089  for(i=0; i<=mLength; i++)
1090  mBits[i] = 0;
1091 
1092  // *************** Label calculation routine **************
1093  if(mCustom == true) {
1094 
1095  // SET PARAMETER IN MCUSTOM CASE
1096  // Works only with major labels
1097 
1098  int numLabel = mNumMajor;
1099 
1100  i = 0;
1101  while((i<numLabel) && (i<=mLength)) {
1102 
1103  TickCustom(i, true, false);
1104  i++;
1105  }
1106 
1107  } else if(mLog==false) {
1108 
1109  // Use the "hidden" min and max to determine the tick size.
1110  // That may make a difference with fisheye.
1111  // Otherwise you may see the tick size for the whole ruler change
1112  // when the fisheye approaches start or end.
1113  double UPP = (mHiddenMax-mHiddenMin)/mLength; // Units per pixel
1114  FindLinearTickSizes(UPP);
1115 
1116  // Left and Right Edges
1117  if (mLabelEdges) {
1118  Tick(0, mMin, true, false);
1119  Tick(mLength, mMax, true, false);
1120  }
1121 
1122  // Zero (if it's in the middle somewhere)
1123  if (mMin * mMax < 0.0) {
1124  int mid;
1125  if (zoomInfo != NULL)
1126  mid = (int)(zoomInfo->TimeToPosition(0.0, mLeftOffset));
1127  else
1128  mid = (int)(mLength*(mMin / (mMin - mMax)) + 0.5);
1129  const int iMaxPos = (mOrientation == wxHORIZONTAL) ? mRight : mBottom - 5;
1130  if (mid >= 0 && mid < iMaxPos)
1131  Tick(mid, 0.0, true, false);
1132  }
1133 
1134  double sg = UPP > 0.0? 1.0: -1.0;
1135 
1136  // Major and minor ticks
1137  for (int jj = 0; jj < 2; ++jj) {
1138  const double denom = jj == 0 ? mMajor : mMinor;
1139  i = -1; j = 0;
1140  double d, warpedD, nextD;
1141 
1142  double prevTime = 0.0, time = 0.0;
1143  if (zoomInfo != NULL) {
1144  j = zoomInfo->TimeToPosition(mMin);
1145  prevTime = zoomInfo->PositionToTime(--j);
1146  time = zoomInfo->PositionToTime(++j);
1147  d = (prevTime + time) / 2.0;
1148  }
1149  else
1150  d = mMin - UPP / 2;
1151  if (timetrack)
1152  warpedD = timetrack->ComputeWarpedLength(0.0, d);
1153  else
1154  warpedD = d;
1155  // using ints doesn't work, as
1156  // this will overflow and be negative at high zoom.
1157  double step = floor(sg * warpedD / denom);
1158  while (i <= mLength) {
1159  i++;
1160  if (zoomInfo)
1161  {
1162  prevTime = time;
1163  time = zoomInfo->PositionToTime(++j);
1164  nextD = (prevTime + time) / 2.0;
1165  // wxASSERT(time >= prevTime);
1166  }
1167  else
1168  nextD = d + UPP;
1169  if (timetrack)
1170  warpedD += timetrack->ComputeWarpedLength(d, nextD);
1171  else
1172  warpedD = nextD;
1173  d = nextD;
1174 
1175  if (floor(sg * warpedD / denom) > step) {
1176  step = floor(sg * warpedD / denom);
1177  bool major = jj == 0;
1178  Tick(i, sg * step * denom, major, !major);
1179  }
1180  }
1181  }
1182 
1183  // Left and Right Edges
1184  if (mLabelEdges) {
1185  Tick(0, mMin, true, false);
1186  Tick(mLength, mMax, true, false);
1187  }
1188  }
1189  else {
1190  // log case
1191 
1192  NumberScale numberScale(mpNumberScale
1193  ? *mpNumberScale
1195  );
1196 
1197  mDigits=2; //TODO: implement dynamic digit computation
1198  double loLog = log10(mMin);
1199  double hiLog = log10(mMax);
1200  int loDecade = (int) floor(loLog);
1201 
1202  double val;
1203  double startDecade = pow(10., (double)loDecade);
1204 
1205  // Major ticks are the decades
1206  double decade = startDecade;
1207  double delta=hiLog-loLog, steps=fabs(delta);
1208  double step = delta>=0 ? 10 : 0.1;
1209  double rMin=std::min(mMin, mMax), rMax=std::max(mMin, mMax);
1210  for(i=0; i<=steps; i++)
1211  { // if(i!=0)
1212  { val = decade;
1213  if(val >= rMin && val < rMax) {
1214  const int pos(0.5 + mLength * numberScale.ValueToPosition(val));
1215  Tick(pos, val, true, false);
1216  }
1217  }
1218  decade *= step;
1219  }
1220 
1221  // Minor ticks are multiples of decades
1222  decade = startDecade;
1223  float start, end, mstep;
1224  if (delta > 0)
1225  { start=2; end=10; mstep=1;
1226  }else
1227  { start=9; end=1; mstep=-1;
1228  }
1229  steps++;
1230  for(i=0; i<=steps; i++) {
1231  for(j=start; j!=end; j+=mstep) {
1232  val = decade * j;
1233  if(val >= rMin && val < rMax) {
1234  const int pos(0.5 + mLength * numberScale.ValueToPosition(val));
1235  Tick(pos, val, false, true);
1236  }
1237  }
1238  decade *= step;
1239  }
1240 
1241  // MinorMinor ticks are multiples of decades
1242  decade = startDecade;
1243  if (delta > 0)
1244  { start= 10; end=100; mstep= 1;
1245  }else
1246  { start=100; end= 10; mstep=-1;
1247  }
1248  steps++;
1249  for (i = 0; i <= steps; i++) {
1250  // PRL: Bug1038. Don't label 1.6, rounded, as a duplicate tick for "2"
1251  if (!(mFormat == IntFormat && decade < 10.0)) {
1252  for (int f = start; f != (int)(end); f += mstep) {
1253  if ((int)(f / 10) != f / 10.0f) {
1254  val = decade * f / 10;
1255  if (val >= rMin && val < rMax) {
1256  const int pos(0.5 + mLength * numberScale.ValueToPosition(val));
1257  Tick(pos, val, false, false);
1258  }
1259  }
1260  }
1261  }
1262  decade *= step;
1263  }
1264  }
1265 
1266  int displacementx=0, displacementy=0;
1267  if (!mFlip) {
1268  if (mOrientation==wxHORIZONTAL) {
1269  int d=mTop+mRect.GetHeight()+5;
1270  mRect.Offset(0,d);
1271  mRect.Inflate(0,5);
1272  displacementx=0;
1273  displacementy=d;
1274  }
1275  else {
1276  int d=mLeft-mRect.GetLeft()+5;
1277  mRect.Offset(d,0);
1278  mRect.Inflate(5,0);
1279  displacementx=d;
1280  displacementy=0;
1281  }
1282  }
1283  else {
1284  if (mOrientation==wxHORIZONTAL) {
1285  mRect.Inflate(0,5);
1286  displacementx=0;
1287  displacementy=0;
1288  }
1289  }
1290  for(i=0; i<mNumMajor; i++) {
1291  mMajorLabels[i].lx+= displacementx;
1292  mMajorLabels[i].ly+= displacementy;
1293  }
1294  for(i=0; i<mNumMinor; i++) {
1295  mMinorLabels[i].lx+= displacementx;
1296  mMinorLabels[i].ly+= displacementy;
1297  }
1298  for(i=0; i<mNumMinorMinor; i++) {
1299  mMinorMinorLabels[i].lx+= displacementx;
1300  mMinorMinorLabels[i].ly+= displacementy;
1301  }
1302  mMaxWidth = mRect.GetWidth ();
1303  mMaxHeight= mRect.GetHeight();
1304  mValid = true;
1305 }
bool mLabelEdges
Definition: Ruler.h:227
double ComputeWarpedLength(double t0, double t1) const
Compute the duration (in seconds at playback) of the specified region of the track.
Definition: TimeTrack.cpp:160
std::unique_ptr< wxFont > mMinorMinorFont
Definition: Ruler.h:183
void Tick(int pos, double d, bool major, bool minor)
Definition: Ruler.cpp:764
int mNumMinor
Definition: Ruler.h:212
int mLengthOld
Definition: Ruler.h:180
std::unique_ptr< wxFont > mMinorFont
Definition: Ruler.h:183
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:499
ArrayOf< Label > mMajorLabels
Definition: Ruler.h:211
bool mFlip
Definition: Ruler.h:230
void TickCustom(int labelIdx, bool major, bool minor)
Definition: Ruler.cpp:872
bool mUserFonts
Definition: Ruler.h:184
ArrayOf< int > mUserBits
Definition: Ruler.h:194
double mMax
Definition: Ruler.h:186
ArrayOf< int > mBits
Definition: Ruler.h:195
double PositionToTime(wxInt64 position, wxInt64 origin=0, bool ignoreFisheye=false) const
Definition: ViewInfo.cpp:49
int mMaxWidth
Definition: Ruler.h:177
double mMin
Definition: Ruler.h:186
bool mValid
Definition: Ruler.h:198
std::unique_ptr< NumberScale > mpNumberScale
Definition: Ruler.h:241
wxRect mRect
Definition: Ruler.h:171
int mTop
Definition: Ruler.h:178
bool mCustom
Definition: Ruler.h:231
void FindLinearTickSizes(double UPP)
Definition: Ruler.cpp:385
int mRight
Definition: Ruler.h:178
double mMinor
Definition: Ruler.h:190
bool mLog
Definition: Ruler.h:229
int mLeftOffset
Definition: Ruler.h:239
int mBottom
Definition: Ruler.h:178
RulerFormat mFormat
Definition: Ruler.h:228
wxInt64 TimeToPosition(double time, wxInt64 origin=0, bool ignoreFisheye=false) const
STM: Converts a project time to screen x position.
Definition: ViewInfo.cpp:59
int mMaxHeight
Definition: Ruler.h:177
int min(int a, int b)
ArrayOf< Label > mMinorMinorLabels
Definition: Ruler.h:215
const ZoomInfo * mUseZoomInfo
Definition: Ruler.h:238
double mHiddenMin
Definition: Ruler.h:187
int mLead
Definition: Ruler.h:178
int mLength
Definition: Ruler.h:179
wxDC * mDC
Definition: Ruler.h:181
int mNumMajor
Definition: Ruler.h:210
double mHiddenMax
Definition: Ruler.h:187
int mNumMinorMinor
Definition: Ruler.h:214
int mDigits
Definition: Ruler.h:192
int mLeft
Definition: Ruler.h:178
int mOrientation
Definition: Ruler.h:224
double mMajor
Definition: Ruler.h:189
std::unique_ptr< wxFont > mMajorFont
Definition: Ruler.h:183
ArrayOf< Label > mMinorLabels
Definition: Ruler.h:213

Member Data Documentation

ArrayOf<int> Ruler::mBits
private

Definition at line 195 of file Ruler.h.

Referenced by Invalidate(), Tick(), TickCustom(), and Update().

bool Ruler::mbMinor
private

Definition at line 232 of file Ruler.h.

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

int Ruler::mBottom
private

Definition at line 178 of file Ruler.h.

Referenced by Draw(), Invalidate(), OfflimitsPixels(), SetBounds(), and Update().

bool Ruler::mbTicksAtExtremes

Definition at line 170 of file Ruler.h.

Referenced by Draw(), and EffectEqualization::PopulateOrExchange().

bool Ruler::mbTicksOnly

Definition at line 169 of file Ruler.h.

Referenced by Draw().

bool Ruler::mCustom
private

Definition at line 231 of file Ruler.h.

Referenced by SetCustomMode(), and Update().

wxDC* Ruler::mDC
private

Definition at line 181 of file Ruler.h.

Referenced by Draw(), DrawGrid(), GetMaxSize(), Tick(), TickCustom(), and Update().

int Ruler::mDigits
private

Definition at line 192 of file Ruler.h.

Referenced by FindLinearTickSizes(), LabelString(), and Update().

bool Ruler::mFlip
private

Definition at line 230 of file Ruler.h.

Referenced by Draw(), SetFlip(), Tick(), TickCustom(), and Update().

RulerFormat Ruler::mFormat
private

Definition at line 228 of file Ruler.h.

Referenced by FindLinearTickSizes(), LabelString(), SetFormat(), and Update().

int Ruler::mGridLineLength
private

Definition at line 235 of file Ruler.h.

Referenced by DrawGrid().

bool Ruler::mHasSetSpacing
private

Definition at line 226 of file Ruler.h.

Referenced by SetOrientation(), and SetSpacing().

double Ruler::mHiddenMax
private

Definition at line 187 of file Ruler.h.

Referenced by Update().

double Ruler::mHiddenMin
private

Definition at line 187 of file Ruler.h.

Referenced by Update().

bool Ruler::mLabelEdges
private

Definition at line 227 of file Ruler.h.

Referenced by SetLabelEdges(), and Update().

int Ruler::mLead
private

Definition at line 178 of file Ruler.h.

Referenced by Tick(), TickCustom(), and Update().

int Ruler::mLeft
private

Definition at line 178 of file Ruler.h.

Referenced by Draw(), Invalidate(), OfflimitsPixels(), SetBounds(), Tick(), TickCustom(), and Update().

int Ruler::mLeftOffset
private

Definition at line 239 of file Ruler.h.

Referenced by SetUseZoomInfo(), and Update().

int Ruler::mLength
private

Definition at line 179 of file Ruler.h.

Referenced by Draw(), Invalidate(), OfflimitsPixels(), Tick(), TickCustom(), and Update().

int Ruler::mLengthOld
private

Definition at line 180 of file Ruler.h.

Referenced by Update().

bool Ruler::mLog
private

Definition at line 229 of file Ruler.h.

Referenced by SetLog(), and Update().

double Ruler::mMajor
private

Definition at line 189 of file Ruler.h.

Referenced by FindLinearTickSizes(), and Update().

std::unique_ptr<wxFont> Ruler::mMajorFont
private

Definition at line 183 of file Ruler.h.

Referenced by Draw(), SetFonts(), Tick(), TickCustom(), and Update().

bool Ruler::mMajorGrid
private

Definition at line 233 of file Ruler.h.

Referenced by DrawGrid().

ArrayOf<Label> Ruler::mMajorLabels
private

Definition at line 211 of file Ruler.h.

Referenced by Draw(), DrawGrid(), GetZeroPosition(), SetCustomMajorLabels(), Tick(), TickCustom(), and Update().

double Ruler::mMax
private

Definition at line 186 of file Ruler.h.

Referenced by Update().

int Ruler::mMaxHeight
private

Definition at line 177 of file Ruler.h.

Referenced by Tick(), TickCustom(), and Update().

int Ruler::mMaxWidth
private

Definition at line 177 of file Ruler.h.

Referenced by Tick(), TickCustom(), and Update().

double Ruler::mMin
private

Definition at line 186 of file Ruler.h.

Referenced by Update().

double Ruler::mMinor
private

Definition at line 190 of file Ruler.h.

Referenced by FindLinearTickSizes(), LabelString(), and Update().

std::unique_ptr<wxFont> Ruler::mMinorFont
private

Definition at line 183 of file Ruler.h.

Referenced by Draw(), SetFonts(), Tick(), TickCustom(), and Update().

bool Ruler::mMinorGrid
private

Definition at line 234 of file Ruler.h.

Referenced by DrawGrid().

ArrayOf<Label> Ruler::mMinorLabels
private

Definition at line 213 of file Ruler.h.

Referenced by Draw(), DrawGrid(), GetZeroPosition(), SetCustomMinorLabels(), Tick(), TickCustom(), and Update().

std::unique_ptr<wxFont> Ruler::mMinorMinorFont
private

Definition at line 183 of file Ruler.h.

Referenced by Draw(), SetFonts(), Tick(), TickCustom(), and Update().

ArrayOf<Label> Ruler::mMinorMinorLabels
private

Definition at line 215 of file Ruler.h.

Referenced by Draw(), Tick(), TickCustom(), and Update().

int Ruler::mNumMajor
private

Definition at line 210 of file Ruler.h.

Referenced by Draw(), DrawGrid(), GetZeroPosition(), SetCustomMajorLabels(), Tick(), TickCustom(), and Update().

int Ruler::mNumMinor
private

Definition at line 212 of file Ruler.h.

Referenced by Draw(), DrawGrid(), GetZeroPosition(), SetCustomMinorLabels(), Tick(), TickCustom(), and Update().

int Ruler::mNumMinorMinor
private

Definition at line 214 of file Ruler.h.

Referenced by Draw(), Tick(), and Update().

int Ruler::mOrientation
private

Definition at line 224 of file Ruler.h.

Referenced by Draw(), DrawGrid(), Invalidate(), OfflimitsPixels(), SetOrientation(), Tick(), TickCustom(), and Update().

wxPen Ruler::mPen
private

Definition at line 175 of file Ruler.h.

Referenced by Draw().

std::unique_ptr<NumberScale> Ruler::mpNumberScale
private

Definition at line 241 of file Ruler.h.

Referenced by SetNumberScale(), and Update().

wxRect Ruler::mRect

Definition at line 171 of file Ruler.h.

Referenced by GetMaxSize(), Tick(), TickCustom(), and Update().

int Ruler::mRight
private

Definition at line 178 of file Ruler.h.

Referenced by Draw(), Invalidate(), OfflimitsPixels(), SetBounds(), and Update().

int Ruler::mSpacing
private

Definition at line 225 of file Ruler.h.

Referenced by SetOrientation(), SetSpacing(), Tick(), and TickCustom().

wxColour Ruler::mTickColour
private

Definition at line 174 of file Ruler.h.

Referenced by Draw().

int Ruler::mTop
private

Definition at line 178 of file Ruler.h.

Referenced by Draw(), Invalidate(), OfflimitsPixels(), SetBounds(), Tick(), TickCustom(), and Update().

bool Ruler::mTwoTone
private

Definition at line 237 of file Ruler.h.

Referenced by Draw(), and SetTwoTone().

wxString Ruler::mUnits
private

Definition at line 236 of file Ruler.h.

Referenced by LabelString(), and SetUnits().

int Ruler::mUserBitLen
private

Definition at line 196 of file Ruler.h.

Referenced by Invalidate(), and OfflimitsPixels().

ArrayOf<int> Ruler::mUserBits
private

Definition at line 194 of file Ruler.h.

Referenced by Invalidate(), OfflimitsPixels(), and Update().

bool Ruler::mUserFonts
private

Definition at line 184 of file Ruler.h.

Referenced by SetFonts(), and Update().

const ZoomInfo* Ruler::mUseZoomInfo
private

Definition at line 238 of file Ruler.h.

Referenced by SetUseZoomInfo(), and Update().

bool Ruler::mValid
private

Definition at line 198 of file Ruler.h.

Referenced by Draw(), GetMaxSize(), Invalidate(), and Update().


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