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 121 of file Ruler.cpp.

122  : mpNumberScale{}
123 {
124  mMin = mHiddenMin = 0.0;
125  mMax = mHiddenMax = 100.0;
126  mOrientation = wxHORIZONTAL;
127  mSpacing = 6;
128  mHasSetSpacing = false;
130  mFlip = false;
131  mLog = false;
132  mLabelEdges = false;
133  mUnits = wxT("");
134 
135  mLeft = -1;
136  mTop = -1;
137  mRight = -1;
138  mBottom = -1;
139  mbTicksOnly = true;
140  mbTicksAtExtremes = false;
141  mTickColour = wxColour( theTheme.Colour( clrTrackPanelText ));
142  mPen.SetColour(mTickColour);
143  mDbMirrorValue = 0.0;
144 
145  // Note: the font size is now adjusted automatically whenever
146  // Invalidate is called on a horizontal Ruler, unless the user
147  // calls SetFonts manually. So the defaults here are not used
148  // often.
149 
150  int fontSize = 10;
151 #ifdef __WXMSW__
152  fontSize = 8;
153 #endif
154 
155  mMinorMinorFont = std::make_unique<wxFont>(fontSize - 1, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
156  mMinorFont = std::make_unique<wxFont>(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
157  mMajorFont = std::make_unique<wxFont>(fontSize, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
158 
159  mUserFonts = false;
160 
161  mLengthOld = 0;
162  mLength = 0;
163  mUserBitLen = 0;
164 
165  mValid = false;
166 
167  mCustom = false;
168  mbMinor = true;
169 
170  mGridLineLength = 0;
171  mMajorGrid = false;
172  mMinorGrid = false;
173 
174  mTwoTone = false;
175 
176  mUseZoomInfo = NULL;
177 }
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 179 of file Ruler.cpp.

References Invalidate().

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

Member Function Documentation

void Ruler::Draw ( wxDC &  dc)

Definition at line 1330 of file Ruler.cpp.

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

1331 {
1332  Draw( dc, NULL);
1333 }
void Draw(wxDC &dc)
Definition: Ruler.cpp:1330
void Ruler::Draw ( wxDC &  dc,
const TimeTrack timetrack 
)

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

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

1473 {
1474  mGridLineLength = length;
1475  mMajorGrid = major;
1476  mMinorGrid = minor;
1477  mDC = &dc;
1478 
1479  Update();
1480 
1481  int gridPos;
1482  wxPen gridPen;
1483 
1484  if(mbMinor && (mMinorGrid && (mGridLineLength != 0 ))) {
1485  gridPen.SetColour(178, 178, 178); // very light grey
1486  mDC->SetPen(gridPen);
1487  for(int i=0; i<mNumMinor; i++) {
1488  gridPos = mMinorLabels[i].pos;
1489  if(mOrientation == wxHORIZONTAL) {
1490  if((gridPos != 0) && (gridPos != mGridLineLength))
1491  mDC->DrawLine(gridPos+xOffset, yOffset, gridPos+xOffset, mGridLineLength+yOffset);
1492  }
1493  else {
1494  if((gridPos != 0) && (gridPos != mGridLineLength))
1495  mDC->DrawLine(xOffset, gridPos+yOffset, mGridLineLength+xOffset, gridPos+yOffset);
1496  }
1497  }
1498  }
1499 
1500  if(mMajorGrid && (mGridLineLength != 0 )) {
1501  gridPen.SetColour(127, 127, 127); // light grey
1502  mDC->SetPen(gridPen);
1503  for(int i=0; i<mNumMajor; i++) {
1504  gridPos = mMajorLabels[i].pos;
1505  if(mOrientation == wxHORIZONTAL) {
1506  if((gridPos != 0) && (gridPos != mGridLineLength))
1507  mDC->DrawLine(gridPos+xOffset, yOffset, gridPos+xOffset, mGridLineLength+yOffset);
1508  }
1509  else {
1510  if((gridPos != 0) && (gridPos != mGridLineLength))
1511  mDC->DrawLine(xOffset, gridPos+yOffset, mGridLineLength+xOffset, gridPos+yOffset);
1512  }
1513  }
1514 
1515  int zeroPosition = GetZeroPosition();
1516  if(zeroPosition > 0) {
1517  // Draw 'zero' grid line in black
1518  mDC->SetPen(*wxBLACK_PEN);
1519  if(mOrientation == wxHORIZONTAL) {
1520  if(zeroPosition != mGridLineLength)
1521  mDC->DrawLine(zeroPosition+xOffset, yOffset, zeroPosition+xOffset, mGridLineLength+yOffset);
1522  }
1523  else {
1524  if(zeroPosition != mGridLineLength)
1525  mDC->DrawLine(xOffset, zeroPosition+yOffset, mGridLineLength+xOffset, zeroPosition+yOffset);
1526  }
1527  }
1528  }
1529 }
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:1547
void Update()
Definition: Ruler.cpp:994
ArrayOf< Label > mMinorLabels
Definition: Ruler.h:214
void Ruler::FindLinearTickSizes ( double  UPP)
private

Definition at line 388 of file Ruler.cpp.

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

Referenced by Update().

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

References Ruler::Label::value.

Referenced by GetZeroPosition().

1532 {
1533  int i = 0;
1534  double d = 1.0; // arbitrary
1535 
1536  do {
1537  d = label[i].value;
1538  i++;
1539  } while( (i < len) && (d != 0.0) );
1540 
1541  if(d == 0.0)
1542  return (label[i - 1].pos) ;
1543  else
1544  return -1;
1545 }
wxString label
Definition: Tags.cpp:733
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 1556 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().

1557 {
1558  if (!mValid) {
1559  wxScreenDC sdc;
1560  mDC = &sdc;
1561  Update(NULL);
1562  }
1563 
1564  if (width)
1565  *width = mRect.GetWidth(); //mMaxWidth;
1566 
1567  if (height)
1568  *height = mRect.GetHeight(); //mMaxHeight;
1569 }
bool mValid
Definition: Ruler.h:199
wxRect mRect
Definition: Ruler.h:172
wxDC * mDC
Definition: Ruler.h:182
void Update()
Definition: Ruler.cpp:994
int Ruler::GetZeroPosition ( )

Definition at line 1547 of file Ruler.cpp.

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

Referenced by DrawGrid().

1548 {
1549  int zero;
1550  if((zero = FindZero(mMajorLabels.get(), mNumMajor)) < 0)
1551  zero = FindZero(mMinorLabels.get(), mNumMinor);
1552  // PRL: don't consult minor minor??
1553  return zero;
1554 }
int mNumMinor
Definition: Ruler.h:213
ArrayOf< Label > mMajorLabels
Definition: Ruler.h:212
int FindZero(Label *label, int len)
Definition: Ruler.cpp:1531
int mNumMajor
Definition: Ruler.h:211
ArrayOf< Label > mMinorLabels
Definition: Ruler.h:214
void Ruler::Invalidate ( )

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

373 {
374  mValid = false;
375 
376  if (mOrientation == wxHORIZONTAL)
377  mLength = mRight-mLeft;
378  else
379  mLength = mBottom-mTop;
380 
381  mBits.reset();
382  if (mUserBits && mLength+1 != mUserBitLen) {
383  mUserBits.reset();
384  mUserBitLen = 0;
385  }
386 }
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 621 of file Ruler.cpp.

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

Referenced by Tick().

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

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

Referenced by MeterPanel::HandleLayout().

335 {
336  if (!mUserBits) {
337  if (mOrientation == wxHORIZONTAL)
338  mLength = mRight-mLeft;
339  else
340  mLength = mBottom-mTop;
341  if( mLength < 0 )
342  return;
343  mUserBits.reinit(static_cast<size_t>(mLength+1), true);
344  mUserBitLen = mLength+1;
345  }
346 
347  if (end < start)
348  std::swap( start, end );
349 
350  if (start < 0)
351  start = 0;
352  if (end > mLength)
353  end = mLength;
354 
355  for(int i = start; i <= end; i++)
356  mUserBits[i] = 1;
357 }
void reinit(Integral count, bool initialize=false)
Definition: MemoryX.h:113
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 359 of file Ruler.cpp.

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

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

360 {
361  if (mLeft != left || mTop != top ||
362  mRight != right || mBottom != bottom) {
363  mLeft = left;
364  mTop = top;
365  mRight = right;
366  mBottom = bottom;
367 
368  Invalidate();
369  }
370 }
void Invalidate()
Definition: Ruler.cpp:372
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 1574 of file Ruler.cpp.

References mMajorLabels, and mNumMajor.

1575 {
1576  mNumMajor = numLabel;
1577  mMajorLabels.reinit(numLabel);
1578 
1579  for(size_t i = 0; i<numLabel; i++) {
1580  mMajorLabels[i].text = label->Item(i);
1581  mMajorLabels[i].pos = start + i*step;
1582  }
1583  //Remember: DELETE majorlabels....
1584 }
ArrayOf< Label > mMajorLabels
Definition: Ruler.h:212
wxString label
Definition: Tags.cpp:733
int mNumMajor
Definition: Ruler.h:211
void Ruler::SetCustomMinorLabels ( wxArrayString *  label,
size_t  numLabel,
int  start,
int  step 
)

Definition at line 1586 of file Ruler.cpp.

References mMinorLabels, and mNumMinor.

1587 {
1588  mNumMinor = numLabel;
1589  mMinorLabels.reinit(numLabel);
1590 
1591  for(size_t i = 0; i<numLabel; i++) {
1592  mMinorLabels[i].text = label->Item(i);
1593  mMinorLabels[i].pos = start + i*step;
1594  }
1595  //Remember: DELETE majorlabels....
1596 }
int mNumMinor
Definition: Ruler.h:213
wxString label
Definition: Tags.cpp:733
ArrayOf< Label > mMinorLabels
Definition: Ruler.h:214
void Ruler::SetCustomMode ( bool  value)

Definition at line 1572 of file Ruler.cpp.

References mCustom.

1572 { 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 288 of file Ruler.cpp.

References Invalidate(), and mFlip.

Referenced by EffectCompressorPanel::OnPaint().

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

Definition at line 306 of file Ruler.cpp.

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

307 {
308  *mMinorMinorFont = minorMinorFont;
309  *mMinorFont = minorFont;
310  *mMajorFont = majorFont;
311 
312  // Won't override these fonts
313  mUserFonts = true;
314 
315  Invalidate();
316 }
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:372
std::unique_ptr< wxFont > mMajorFont
Definition: Ruler.h:184
void Ruler::SetFormat ( RulerFormat  format)

Definition at line 189 of file Ruler.cpp.

References format, Invalidate(), and mFormat.

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

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

Definition at line 275 of file Ruler.cpp.

References Invalidate(), and mLabelEdges.

Referenced by AdornedRulerPanel::AdornedRulerPanel(), and AudacityPrintout::OnPrintPage().

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

Definition at line 200 of file Ruler.cpp.

References Invalidate(), and mLog.

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

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

Definition at line 301 of file Ruler.cpp.

References mbMinor.

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

Definition at line 318 of file Ruler.cpp.

References Invalidate(), and mpNumberScale.

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

Definition at line 223 of file Ruler.cpp.

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

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

224 {
225  // wxHORIZONTAL || wxVERTICAL
226 
227  if (mOrientation != orient) {
228  mOrientation = orient;
229 
230  if (mOrientation == wxVERTICAL && !mHasSetSpacing)
231  mSpacing = 2;
232 
233  Invalidate();
234  }
235 }
bool mHasSetSpacing
Definition: Ruler.h:228
void Invalidate()
Definition: Ruler.cpp:372
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 243 of file Ruler.cpp.

References min().

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

References Invalidate(), mHasSetSpacing, and mSpacing.

265 {
266  mHasSetSpacing = true;
267 
268  if (mSpacing != spacing) {
269  mSpacing = spacing;
270 
271  Invalidate();
272  }
273 }
bool mHasSetSpacing
Definition: Ruler.h:228
void Invalidate()
Definition: Ruler.cpp:372
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 184 of file Ruler.cpp.

References mTwoTone.

Referenced by AdornedRulerPanel::UpdatePrefs().

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

Definition at line 211 of file Ruler.cpp.

References Invalidate(), and mUnits.

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

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

Definition at line 1613 of file Ruler.cpp.

References mLeftOffset, and mUseZoomInfo.

Referenced by AdornedRulerPanel::AdornedRulerPanel(), and AdornedRulerPanel::SetLeftOffset().

1614 {
1615  mLeftOffset = leftOffset;
1616  mUseZoomInfo = zoomInfo;
1617 }
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 769 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().

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

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

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

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

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

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