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 SetDbMirrorValue (const double d)
 
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
 
double mDbMirrorValue
 
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 120 of file Ruler.cpp.

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

Definition at line 178 of file Ruler.cpp.

References Invalidate().

179 {
180  Invalidate(); // frees up our arrays
181 }
void Invalidate()
Definition: Ruler.cpp:371

Member Function Documentation

void Ruler::Draw ( wxDC &  dc)

Definition at line 1323 of file Ruler.cpp.

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

1324 {
1325  Draw( dc, NULL);
1326 }
void Draw(wxDC &dc)
Definition: Ruler.cpp:1323
void Ruler::Draw ( wxDC &  dc,
const TimeTrack timetrack 
)

Definition at line 1328 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().

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

Definition at line 1465 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().

1466 {
1467  mGridLineLength = length;
1468  mMajorGrid = major;
1469  mMinorGrid = minor;
1470  mDC = &dc;
1471 
1472  Update();
1473 
1474  int gridPos;
1475  wxPen gridPen;
1476 
1477  if(mbMinor && (mMinorGrid && (mGridLineLength != 0 ))) {
1478  gridPen.SetColour(178, 178, 178); // very light grey
1479  mDC->SetPen(gridPen);
1480  for(int i=0; i<mNumMinor; i++) {
1481  gridPos = mMinorLabels[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 
1493  if(mMajorGrid && (mGridLineLength != 0 )) {
1494  gridPen.SetColour(127, 127, 127); // light grey
1495  mDC->SetPen(gridPen);
1496  for(int i=0; i<mNumMajor; i++) {
1497  gridPos = mMajorLabels[i].pos;
1498  if(mOrientation == wxHORIZONTAL) {
1499  if((gridPos != 0) && (gridPos != mGridLineLength))
1500  mDC->DrawLine(gridPos+xOffset, yOffset, gridPos+xOffset, mGridLineLength+yOffset);
1501  }
1502  else {
1503  if((gridPos != 0) && (gridPos != mGridLineLength))
1504  mDC->DrawLine(xOffset, gridPos+yOffset, mGridLineLength+xOffset, gridPos+yOffset);
1505  }
1506  }
1507 
1508  int zeroPosition = GetZeroPosition();
1509  if(zeroPosition > 0) {
1510  // Draw 'zero' grid line in black
1511  mDC->SetPen(*wxBLACK_PEN);
1512  if(mOrientation == wxHORIZONTAL) {
1513  if(zeroPosition != mGridLineLength)
1514  mDC->DrawLine(zeroPosition+xOffset, yOffset, zeroPosition+xOffset, mGridLineLength+yOffset);
1515  }
1516  else {
1517  if(zeroPosition != mGridLineLength)
1518  mDC->DrawLine(xOffset, zeroPosition+yOffset, mGridLineLength+xOffset, zeroPosition+yOffset);
1519  }
1520  }
1521  }
1522 }
bool mMajorGrid
Definition: Ruler.h:235
int mNumMinor
Definition: Ruler.h:213
bool mbMinor
Definition: Ruler.h:234
ArrayOf< Label > mMajorLabels
Definition: Ruler.h:212
bool mMinorGrid
Definition: Ruler.h:236
wxDC * mDC
Definition: Ruler.h:182
int mNumMajor
Definition: Ruler.h:211
int mGridLineLength
Definition: Ruler.h:237
int mOrientation
Definition: Ruler.h:225
int GetZeroPosition()
Definition: Ruler.cpp:1540
void Update()
Definition: Ruler.cpp:993
ArrayOf< Label > mMinorLabels
Definition: Ruler.h:214
void Ruler::FindLinearTickSizes ( double  UPP)
private

Definition at line 387 of file Ruler.cpp.

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

Referenced by Update().

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

Definition at line 1524 of file Ruler.cpp.

References Ruler::Label::value.

Referenced by GetZeroPosition().

1525 {
1526  int i = 0;
1527  double d = 1.0; // arbitrary
1528 
1529  do {
1530  d = label[i].value;
1531  i++;
1532  } while( (i < len) && (d != 0.0) );
1533 
1534  if(d == 0.0)
1535  return (label[i - 1].pos) ;
1536  else
1537  return -1;
1538 }
wxString label
Definition: Tags.cpp:727
Fonts Ruler::GetFonts ( ) const
inline

Definition at line 107 of file Ruler.h.

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

Definition at line 1549 of file Ruler.cpp.

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

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

1550 {
1551  if (!mValid) {
1552  wxScreenDC sdc;
1553  mDC = &sdc;
1554  Update(NULL);
1555  }
1556 
1557  if (width)
1558  *width = mRect.GetWidth(); //mMaxWidth;
1559 
1560  if (height)
1561  *height = mRect.GetHeight(); //mMaxHeight;
1562 }
bool mValid
Definition: Ruler.h:199
wxRect mRect
Definition: Ruler.h:172
wxDC * mDC
Definition: Ruler.h:182
void Update()
Definition: Ruler.cpp:993
int Ruler::GetZeroPosition ( )

Definition at line 1540 of file Ruler.cpp.

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

Referenced by DrawGrid().

1541 {
1542  int zero;
1543  if((zero = FindZero(mMajorLabels.get(), mNumMajor)) < 0)
1544  zero = FindZero(mMinorLabels.get(), mNumMinor);
1545  // PRL: don't consult minor minor??
1546  return zero;
1547 }
int mNumMinor
Definition: Ruler.h:213
ArrayOf< Label > mMajorLabels
Definition: Ruler.h:212
int FindZero(Label *label, int len)
Definition: Ruler.cpp:1524
int mNumMajor
Definition: Ruler.h:211
ArrayOf< Label > mMinorLabels
Definition: Ruler.h:214
void Ruler::Invalidate ( )

Definition at line 371 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().

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

Definition at line 620 of file Ruler.cpp.

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

Referenced by Tick().

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

Definition at line 333 of file Ruler.cpp.

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

Referenced by MeterPanel::HandleLayout().

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

Definition at line 358 of file Ruler.cpp.

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

Referenced by MeterPanel::HandleLayout(), EffectCompressorPanel::OnPaint(), AudacityPrintout::OnPrintPage(), MeterPanel::SetActiveStyle(), and AdornedRulerPanel::UpdateRects().

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

Definition at line 1567 of file Ruler.cpp.

References mMajorLabels, and mNumMajor.

1568 {
1569  mNumMajor = numLabel;
1570  mMajorLabels.reinit(numLabel);
1571 
1572  for(size_t i = 0; i<numLabel; i++) {
1573  mMajorLabels[i].text = label->Item(i);
1574  mMajorLabels[i].pos = start + i*step;
1575  }
1576  //Remember: DELETE majorlabels....
1577 }
ArrayOf< Label > mMajorLabels
Definition: Ruler.h:212
wxString label
Definition: Tags.cpp:727
int mNumMajor
Definition: Ruler.h:211
void Ruler::SetCustomMinorLabels ( wxArrayString *  label,
size_t  numLabel,
int  start,
int  step 
)

Definition at line 1579 of file Ruler.cpp.

References mMinorLabels, and mNumMinor.

1580 {
1581  mNumMinor = numLabel;
1582  mMinorLabels.reinit(numLabel);
1583 
1584  for(size_t i = 0; i<numLabel; i++) {
1585  mMinorLabels[i].text = label->Item(i);
1586  mMinorLabels[i].pos = start + i*step;
1587  }
1588  //Remember: DELETE majorlabels....
1589 }
int mNumMinor
Definition: Ruler.h:213
wxString label
Definition: Tags.cpp:727
ArrayOf< Label > mMinorLabels
Definition: Ruler.h:214
void Ruler::SetCustomMode ( bool  value)

Definition at line 1565 of file Ruler.cpp.

References mCustom.

1565 { mCustom = value; }
bool mCustom
Definition: Ruler.h:233
void Ruler::SetDbMirrorValue ( const double  d)
inline

Definition at line 84 of file Ruler.h.

84 { mDbMirrorValue = d ; };
double mDbMirrorValue
Definition: Ruler.h:227
void Ruler::SetFlip ( bool  flip)

Definition at line 287 of file Ruler.cpp.

References Invalidate(), and mFlip.

Referenced by EffectCompressorPanel::OnPaint().

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

Definition at line 305 of file Ruler.cpp.

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

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

Definition at line 188 of file Ruler.cpp.

References format, Invalidate(), and mFormat.

Referenced by FreqWindow::DrawPlot(), EffectCompressorPanel::OnPaint(), AudacityPrintout::OnPrintPage(), and MeterPanel::SetActiveStyle().

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

Definition at line 274 of file Ruler.cpp.

References Invalidate(), and mLabelEdges.

Referenced by AudacityPrintout::OnPrintPage().

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

Definition at line 199 of file Ruler.cpp.

References Invalidate(), and mLog.

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

200 {
201  // Logarithmic
202 
203  if (mLog != log) {
204  mLog = log;
205 
206  Invalidate();
207  }
208 }
void Invalidate()
Definition: Ruler.cpp:371
bool mLog
Definition: Ruler.h:231
void Ruler::SetMinor ( bool  value)

Definition at line 300 of file Ruler.cpp.

References mbMinor.

301 {
302  mbMinor = value;
303 }
bool mbMinor
Definition: Ruler.h:234
void Ruler::SetNumberScale ( const NumberScale pScale)

Definition at line 317 of file Ruler.cpp.

References Invalidate(), and mpNumberScale.

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

Definition at line 222 of file Ruler.cpp.

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

Referenced by EffectCompressorPanel::OnPaint(), AudacityPrintout::OnPrintPage(), and MeterPanel::SetActiveStyle().

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

Definition at line 242 of file Ruler.cpp.

References min().

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

Definition at line 263 of file Ruler.cpp.

References Invalidate(), mHasSetSpacing, and mSpacing.

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

Definition at line 151 of file Ruler.h.

Referenced by AdornedRulerPanel::DoDrawMarks(), EffectCompressorPanel::OnPaint(), and MeterPanel::OnPaint().

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

Definition at line 183 of file Ruler.cpp.

References mTwoTone.

Referenced by AdornedRulerPanel::UpdatePrefs().

184 {
185  mTwoTone = twoTone;
186 }
bool mTwoTone
Definition: Ruler.h:239
void Ruler::SetUnits ( const wxString &  units)

Definition at line 210 of file Ruler.cpp.

References Invalidate(), and mUnits.

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

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

Definition at line 1606 of file Ruler.cpp.

References mLeftOffset, and mUseZoomInfo.

Referenced by AdornedRulerPanel::SetLeftOffset().

1607 {
1608  mLeftOffset = leftOffset;
1609  mUseZoomInfo = zoomInfo;
1610 }
int mLeftOffset
Definition: Ruler.h:241
const ZoomInfo * mUseZoomInfo
Definition: Ruler.h:240
void Ruler::Tick ( int  pos,
double  d,
bool  major,
bool  minor 
)
private

Definition at line 768 of file Ruler.cpp.

References label, LabelString(), Ruler::Label::lx, Ruler::Label::ly, mBits, mDbMirrorValue, 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().

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

Definition at line 879 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().

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

Definition at line 993 of file Ruler.cpp.

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

994 {
995  Update(NULL);
996 }
void Update()
Definition: Ruler.cpp:993
void Ruler::Update ( const TimeTrack timetrack)
private

Definition at line 998 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().

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

Member Data Documentation

ArrayOf<int> Ruler::mBits
private

Definition at line 196 of file Ruler.h.

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

bool Ruler::mbMinor
private

Definition at line 234 of file Ruler.h.

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

int Ruler::mBottom
private

Definition at line 179 of file Ruler.h.

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

bool Ruler::mbTicksAtExtremes

Definition at line 171 of file Ruler.h.

Referenced by Draw().

bool Ruler::mbTicksOnly

Definition at line 170 of file Ruler.h.

Referenced by Draw().

bool Ruler::mCustom
private

Definition at line 233 of file Ruler.h.

Referenced by SetCustomMode(), and Update().

double Ruler::mDbMirrorValue
private

Definition at line 227 of file Ruler.h.

Referenced by Tick().

wxDC* Ruler::mDC
private

Definition at line 182 of file Ruler.h.

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

int Ruler::mDigits
private

Definition at line 193 of file Ruler.h.

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

bool Ruler::mFlip
private

Definition at line 232 of file Ruler.h.

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

RulerFormat Ruler::mFormat
private

Definition at line 230 of file Ruler.h.

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

int Ruler::mGridLineLength
private

Definition at line 237 of file Ruler.h.

Referenced by DrawGrid().

bool Ruler::mHasSetSpacing
private

Definition at line 228 of file Ruler.h.

Referenced by SetOrientation(), and SetSpacing().

double Ruler::mHiddenMax
private

Definition at line 188 of file Ruler.h.

Referenced by Update().

double Ruler::mHiddenMin
private

Definition at line 188 of file Ruler.h.

Referenced by Update().

bool Ruler::mLabelEdges
private

Definition at line 229 of file Ruler.h.

Referenced by SetLabelEdges(), and Update().

int Ruler::mLead
private

Definition at line 179 of file Ruler.h.

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

int Ruler::mLeft
private

Definition at line 179 of file Ruler.h.

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

int Ruler::mLeftOffset
private

Definition at line 241 of file Ruler.h.

Referenced by SetUseZoomInfo(), and Update().

int Ruler::mLength
private

Definition at line 180 of file Ruler.h.

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

int Ruler::mLengthOld
private

Definition at line 181 of file Ruler.h.

Referenced by Update().

bool Ruler::mLog
private

Definition at line 231 of file Ruler.h.

Referenced by SetLog(), and Update().

double Ruler::mMajor
private

Definition at line 190 of file Ruler.h.

Referenced by FindLinearTickSizes(), and Update().

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

Definition at line 184 of file Ruler.h.

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

bool Ruler::mMajorGrid
private

Definition at line 235 of file Ruler.h.

Referenced by DrawGrid().

ArrayOf<Label> Ruler::mMajorLabels
private

Definition at line 212 of file Ruler.h.

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

double Ruler::mMax
private

Definition at line 187 of file Ruler.h.

Referenced by Update().

int Ruler::mMaxHeight
private

Definition at line 178 of file Ruler.h.

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

int Ruler::mMaxWidth
private

Definition at line 178 of file Ruler.h.

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

double Ruler::mMin
private

Definition at line 187 of file Ruler.h.

Referenced by Update().

double Ruler::mMinor
private

Definition at line 191 of file Ruler.h.

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

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

Definition at line 184 of file Ruler.h.

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

bool Ruler::mMinorGrid
private

Definition at line 236 of file Ruler.h.

Referenced by DrawGrid().

ArrayOf<Label> Ruler::mMinorLabels
private

Definition at line 214 of file Ruler.h.

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

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

Definition at line 184 of file Ruler.h.

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

ArrayOf<Label> Ruler::mMinorMinorLabels
private

Definition at line 216 of file Ruler.h.

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

int Ruler::mNumMajor
private

Definition at line 211 of file Ruler.h.

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

int Ruler::mNumMinor
private

Definition at line 213 of file Ruler.h.

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

int Ruler::mNumMinorMinor
private

Definition at line 215 of file Ruler.h.

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

int Ruler::mOrientation
private
wxPen Ruler::mPen
private

Definition at line 176 of file Ruler.h.

Referenced by Draw().

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

Definition at line 243 of file Ruler.h.

Referenced by SetNumberScale(), and Update().

wxRect Ruler::mRect

Definition at line 172 of file Ruler.h.

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

int Ruler::mRight
private

Definition at line 179 of file Ruler.h.

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

int Ruler::mSpacing
private

Definition at line 226 of file Ruler.h.

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

wxColour Ruler::mTickColour
private

Definition at line 175 of file Ruler.h.

Referenced by Draw().

int Ruler::mTop
private

Definition at line 179 of file Ruler.h.

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

bool Ruler::mTwoTone
private

Definition at line 239 of file Ruler.h.

Referenced by Draw(), and SetTwoTone().

wxString Ruler::mUnits
private

Definition at line 238 of file Ruler.h.

Referenced by LabelString(), and SetUnits().

int Ruler::mUserBitLen
private

Definition at line 197 of file Ruler.h.

Referenced by Invalidate(), and OfflimitsPixels().

ArrayOf<int> Ruler::mUserBits
private

Definition at line 195 of file Ruler.h.

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

bool Ruler::mUserFonts
private

Definition at line 185 of file Ruler.h.

Referenced by SetFonts(), and Update().

const ZoomInfo* Ruler::mUseZoomInfo
private

Definition at line 240 of file Ruler.h.

Referenced by SetUseZoomInfo(), and Update().

bool Ruler::mValid
private

Definition at line 199 of file Ruler.h.

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


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