KiCad PCB EDA Suite
FREQUENCY_LOG_SCALE Class Reference
Inheritance diagram for FREQUENCY_LOG_SCALE:
mpScaleXLog mpScaleXBase mpScaleBase mpLayer

Public Member Functions

 FREQUENCY_LOG_SCALE (wxString name, int flags)
 
void formatLabels () override
 
virtual double TransformToPlot (double x) override
 
virtual double TransformFromPlot (double xplot) override
 
virtual bool IsHorizontal () override
 
virtual void Plot (wxDC &dc, mpWindow &w) override
 Layer plot handler. More...
 
virtual void getVisibleDataRange (mpWindow &w, double &minV, double &maxV) override
 
bool HasBBox () override
 Check whether this layer has a bounding box. More...
 
void SetAlign (int align)
 Set X axis alignment. More...
 
void SetNameAlign (int align)
 
void SetTicks (bool enable)
 Set X axis ticks or grid. More...
 
bool GetTicks ()
 Get X axis ticks or grid. More...
 
void SetDataRange (double minV, double maxV)
 
void GetDataRange (double &minV, double &maxV)
 
void ExtendDataRange (double minV, double maxV)
 
void ResetDataRange ()
 
double AbsMaxValue () const
 
double AbsVisibleMaxValue () const
 
std::vector< TickLabel > & TickLabels ()
 
virtual bool IsInfo ()
 Check whether the layer is an info box. More...
 
virtual double GetMinX ()
 Get inclusive left border of bounding box. More...
 
virtual double GetMaxX ()
 Get inclusive right border of bounding box. More...
 
virtual double GetMinY ()
 Get inclusive bottom border of bounding box. More...
 
virtual double GetMaxY ()
 Get inclusive top border of bounding box. More...
 
const wxString & GetName () const
 Get layer name. More...
 
const wxFont & GetFont () const
 Get font set for this layer. More...
 
const wxPen & GetPen () const
 Get pen set for this layer. More...
 
void SetContinuity (bool continuity)
 Set the 'continuity' property of the layer (true:draws a continuous line, false:draws separate points). More...
 
bool GetContinuity () const
 Gets the 'continuity' property of the layer. More...
 
void ShowName (bool show)
 Shows or hides the text label with the name of the layer (default is visible). More...
 
void SetName (wxString name)
 Set layer name. More...
 
void SetFont (wxFont &font)
 Set layer font. More...
 
void SetPen (wxPen pen)
 Set layer pen. More...
 
void SetDrawOutsideMargins (bool drawModeOutside)
 Set Draw mode: inside or outside margins. More...
 
bool GetDrawOutsideMargins ()
 Get Draw mode: inside or outside margins. More...
 
wxBitmap GetColourSquare (int side=16)
 Get a small square bitmap filled with the colour of the pen used in the layer. More...
 
mpLayerType GetLayerType ()
 Get layer type: a Layer can be of different types: plot lines, axis, info boxes, etc, this method returns the right value. More...
 
bool IsVisible ()
 Checks whether the layer is visible or not. More...
 
void SetVisible (bool show)
 Sets layer visibility. More...
 
const wxBrush & GetBrush () const
 Get brush set for this layer. More...
 
void SetBrush (wxBrush brush)
 Set layer brush. More...
 

Protected Member Functions

void recalculateTicks (wxDC &dc, mpWindow &w) override
 Layer plot handler. More...
 
void computeLabelExtents (wxDC &dc, mpWindow &w)
 
void updateTickLabels (wxDC &dc, mpWindow &w)
 
int tickCount () const
 
virtual int labelCount () const
 
virtual const wxString formatLabel (double value, int nDigits)
 
virtual double getTickPos (int n)
 
virtual double getLabelPos (int n)
 
virtual const wxString getLabel (int n)
 

Protected Attributes

std::vector< double > m_tickValues
 
std::vector< TickLabelm_tickLabels
 
double m_offset
 
double m_scale
 
double m_absVisibleMaxV
 
int m_flags
 
int m_nameFlags
 
bool m_ticks
 
double m_minV
 
double m_maxV
 
bool m_rangeSet
 
int m_maxLabelHeight
 
int m_maxLabelWidth
 
wxFont m_font
 
wxPen m_pen
 
wxBrush m_brush
 
wxString m_name
 
bool m_continuous
 
bool m_showName
 
bool m_drawOutsideMargins
 
mpLayerType m_type
 
bool m_visible
 

Detailed Description

Definition at line 149 of file sim_plot_panel.cpp.

Constructor & Destructor Documentation

◆ FREQUENCY_LOG_SCALE()

FREQUENCY_LOG_SCALE::FREQUENCY_LOG_SCALE ( wxString  name,
int  flags 
)
inline

Definition at line 152 of file sim_plot_panel.cpp.

152  :
153  mpScaleXLog( name, flags ) {};
mpScaleXLog(const wxString &name=wxT("log(X)"), int flags=mpALIGN_CENTER, bool ticks=true, unsigned int type=mpX_NORMAL)
Full constructor.
Definition: mathplot.cpp:1289
const char * name
Definition: DXF_plotter.cpp:59

Member Function Documentation

◆ AbsMaxValue()

double mpScaleBase::AbsMaxValue ( ) const
inlineinherited

Definition at line 765 of file mathplot.h.

766  {
767  return std::max( std::abs( m_maxV ), std::abs( m_minV ) );
768  }
double m_maxV
Definition: mathplot.h:837
double m_minV
Definition: mathplot.h:837

◆ AbsVisibleMaxValue()

double mpScaleBase::AbsVisibleMaxValue ( ) const
inlineinherited

Definition at line 770 of file mathplot.h.

771  {
772  return m_absVisibleMaxV;
773  }
double m_absVisibleMaxV
Definition: mathplot.h:833

◆ computeLabelExtents()

void mpScaleXLog::computeLabelExtents ( wxDC &  dc,
mpWindow w 
)
protectedinherited

◆ ExtendDataRange()

void mpScaleBase::ExtendDataRange ( double  minV,
double  maxV 
)
inlineinherited

Definition at line 739 of file mathplot.h.

740  {
741  if( !m_rangeSet )
742  {
743  m_minV = minV;
744  m_maxV = maxV;
745  m_rangeSet = true;
746  }
747  else
748  {
749  m_minV = std::min( minV, m_minV );
750  m_maxV = std::max( maxV, m_maxV );
751  }
752 
753  if( m_minV == m_maxV )
754  {
755  m_minV = m_minV - 1.0;
756  m_maxV = m_maxV + 1.0;
757  }
758  }
double m_maxV
Definition: mathplot.h:837
bool m_rangeSet
Definition: mathplot.h:838
double m_minV
Definition: mathplot.h:837

Referenced by mpFXY::UpdateScales().

◆ formatLabel()

virtual const wxString mpScaleBase::formatLabel ( double  value,
int  nDigits 
)
inlineprotectedvirtualinherited

Definition at line 811 of file mathplot.h.

811 { return wxT( "" ); }

◆ formatLabels()

void FREQUENCY_LOG_SCALE::formatLabels ( )
inlineoverridevirtual

Reimplemented from mpScaleBase.

Definition at line 155 of file sim_plot_panel.cpp.

156  {
157  const wxString unit = wxT( "Hz" );
158  wxString suffix;
159  int power;
160 
161  for( auto &l : TickLabels() )
162  {
163  getSISuffix( l.pos, unit, power, suffix );
164  double sf = pow( 10.0, power );
165  int k = countDecimalDigits( l.pos / sf, 3 );
166 
167  l.label = formatFloat( l.pos / sf, k ) + suffix;
168  l.visible = true;
169  }
170  }
static wxString formatFloat(double x, int nDigits)
std::vector< TickLabel > & TickLabels()
Definition: mathplot.h:790
static int countDecimalDigits(double x, int maxDigits)
static void getSISuffix(double x, const wxString &unit, int &power, wxString &suffix)

References countDecimalDigits(), formatFloat(), getSISuffix(), and mpScaleBase::TickLabels().

◆ GetBrush()

const wxBrush& mpLayer::GetBrush ( ) const
inlineinherited

Get brush set for this layer.

Returns
brush.

Definition at line 307 of file mathplot.h.

307 { return m_brush; };
wxBrush m_brush
Definition: mathplot.h:317

◆ GetColourSquare()

wxBitmap mpLayer::GetColourSquare ( int  side = 16)
inherited

Get a small square bitmap filled with the colour of the pen used in the layer.

Useful to create legends or similar reference to the layers.

Parameters
sideside length in pixels
Returns
a wxBitmap filled with layer's colour

Definition at line 83 of file mathplot.cpp.

84 {
85  wxBitmap square( side, side, -1 );
86  wxColour filler = m_pen.GetColour();
87  wxBrush brush( filler, wxBRUSHSTYLE_SOLID );
88  wxMemoryDC dc;
89 
90  dc.SelectObject( square );
91  dc.SetBackground( brush );
92  dc.Clear();
93  dc.SelectObject( wxNullBitmap );
94  return square;
95 }
double square(double x)
wxPen m_pen
Definition: mathplot.h:316

References mpLayer::m_pen, and square().

◆ GetContinuity()

bool mpLayer::GetContinuity ( ) const
inlineinherited

Gets the 'continuity' property of the layer.

See also
SetContinuity

Definition at line 259 of file mathplot.h.

259 { return m_continuous; }
bool m_continuous
Definition: mathplot.h:319

◆ GetDataRange()

void mpScaleBase::GetDataRange ( double &  minV,
double &  maxV 
)
inlineinherited

Definition at line 733 of file mathplot.h.

734  {
735  minV = m_minV;
736  maxV = m_maxV;
737  }
double m_maxV
Definition: mathplot.h:837
double m_minV
Definition: mathplot.h:837

Referenced by mpScaleX::recalculateTicks(), mpScaleXLog::recalculateTicks(), and mpScaleY::recalculateTicks().

◆ GetDrawOutsideMargins()

bool mpLayer::GetDrawOutsideMargins ( )
inlineinherited

Get Draw mode: inside or outside margins.

Returns
The draw mode

Definition at line 286 of file mathplot.h.

286 { return m_drawOutsideMargins; };
bool m_drawOutsideMargins
Definition: mathplot.h:321

◆ GetFont()

const wxFont& mpLayer::GetFont ( ) const
inlineinherited

Get font set for this layer.

Returns
Font

Definition at line 244 of file mathplot.h.

244 { return m_font; }
wxFont m_font
Definition: mathplot.h:311

◆ getLabel()

virtual const wxString mpScaleBase::getLabel ( int  n)
inlineprotectedvirtualinherited

Definition at line 824 of file mathplot.h.

825  {
826  return m_tickLabels[n].label;
827  }
std::vector< TickLabel > m_tickLabels
Definition: mathplot.h:830

Referenced by mpScaleBase::computeLabelExtents(), and mpScaleY::Plot().

◆ getLabelPos()

virtual double mpScaleBase::getLabelPos ( int  n)
inlineprotectedvirtualinherited

Definition at line 819 of file mathplot.h.

820  {
821  return m_tickLabels[n].pos;
822  }
std::vector< TickLabel > m_tickLabels
Definition: mathplot.h:830

Referenced by mpScaleXBase::Plot(), and mpScaleY::Plot().

◆ GetLayerType()

mpLayerType mpLayer::GetLayerType ( )
inlineinherited

Get layer type: a Layer can be of different types: plot lines, axis, info boxes, etc, this method returns the right value.

Returns
An integer indicating layer type

Definition at line 295 of file mathplot.h.

295 { return m_type; };
mpLayerType m_type
Definition: mathplot.h:322

Referenced by mpInfoLegend::Plot().

◆ GetMaxX()

virtual double mpLayer::GetMaxX ( )
inlinevirtualinherited

Get inclusive right border of bounding box.

Returns
Value

Reimplemented in mpBitmapLayer, mpMovableObject, and mpFXYVector.

Definition at line 181 of file mathplot.h.

181 { return 1.0; }

Referenced by mpWindow::UpdateBBox(), and mpFXY::UpdateScales().

◆ GetMaxY()

virtual double mpLayer::GetMaxY ( )
inlinevirtualinherited

Get inclusive top border of bounding box.

Returns
Value

Reimplemented in mpBitmapLayer, mpMovableObject, and mpFXYVector.

Definition at line 191 of file mathplot.h.

191 { return 1.0; }

Referenced by mpWindow::UpdateBBox(), and mpFXY::UpdateScales().

◆ GetMinX()

virtual double mpLayer::GetMinX ( )
inlinevirtualinherited

Get inclusive left border of bounding box.

Returns
Value

Reimplemented in mpBitmapLayer, mpMovableObject, and mpFXYVector.

Definition at line 176 of file mathplot.h.

176 { return -1.0; }

Referenced by mpWindow::UpdateBBox(), and mpFXY::UpdateScales().

◆ GetMinY()

virtual double mpLayer::GetMinY ( )
inlinevirtualinherited

Get inclusive bottom border of bounding box.

Returns
Value

Reimplemented in mpBitmapLayer, mpMovableObject, and mpFXYVector.

Definition at line 186 of file mathplot.h.

186 { return -1.0; }

Referenced by mpWindow::UpdateBBox(), and mpFXY::UpdateScales().

◆ GetName()

const wxString& mpLayer::GetName ( void  ) const
inlineinherited

Get layer name.

Returns
Name

Definition at line 239 of file mathplot.h.

239 { return m_name; }
wxString m_name
Definition: mathplot.h:318

Referenced by SIM_PLOT_PANEL::GetLabelX(), SIM_PLOT_PANEL::GetLabelY1(), SIM_PLOT_PANEL::GetLabelY2(), mpInfoLegend::Plot(), and mpText::Plot().

◆ GetPen()

const wxPen& mpLayer::GetPen ( ) const
inlineinherited

Get pen set for this layer.

Returns
Pen

Definition at line 249 of file mathplot.h.

249 { return m_pen; }
wxPen m_pen
Definition: mathplot.h:316

Referenced by mpInfoLegend::Plot().

◆ getTickPos()

virtual double mpScaleBase::getTickPos ( int  n)
inlineprotectedvirtualinherited

Definition at line 814 of file mathplot.h.

815  {
816  return m_tickValues[n];
817  }
std::vector< double > m_tickValues
Definition: mathplot.h:829

Referenced by mpScaleXBase::Plot(), and mpScaleY::Plot().

◆ GetTicks()

bool mpScaleBase::GetTicks ( )
inlineinherited

Get X axis ticks or grid.

Returns
TRUE if plot is drawing axis ticks, FALSE if the grid is active.

Definition at line 720 of file mathplot.h.

720 { return m_ticks; };
bool m_ticks
Definition: mathplot.h:836

Referenced by SIM_PLOT_PANEL::IsGridShown().

◆ getVisibleDataRange()

void mpScaleXBase::getVisibleDataRange ( mpWindow w,
double &  minV,
double &  maxV 
)
overridevirtualinherited

Reimplemented from mpScaleBase.

Definition at line 1217 of file mathplot.cpp.

1218 {
1219  wxCoord startPx = m_drawOutsideMargins ? 0 : w.GetMarginLeft();
1220  wxCoord endPx = m_drawOutsideMargins ? w.GetScrX() : w.GetScrX() - w.GetMarginRight();
1221  double pxmin = w.p2x( startPx );
1222  double pxmax = w.p2x( endPx );
1223 
1224  minV = TransformFromPlot( pxmin );
1225  maxV = TransformFromPlot( pxmax );
1226 }
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1189
int GetScrX(void) const
Get current view's X dimension in device context units.
Definition: mathplot.h:1135
bool m_drawOutsideMargins
Definition: mathplot.h:321
int GetMarginRight()
Definition: mathplot.h:1370
int GetMarginLeft()
Definition: mathplot.h:1374
virtual double TransformFromPlot(double xplot)
Definition: mathplot.h:776

References mpWindow::GetMarginLeft(), mpWindow::GetMarginRight(), mpWindow::GetScrX(), mpLayer::m_drawOutsideMargins, mpWindow::p2x(), and mpScaleBase::TransformFromPlot().

Referenced by mpScaleX::recalculateTicks(), and mpScaleXLog::recalculateTicks().

◆ HasBBox()

bool mpScaleBase::HasBBox ( )
inlineoverridevirtualinherited

Check whether this layer has a bounding box.

The default implementation returns TRUE. Override and return FALSE if your mpLayer implementation should be ignored by the calculation of the global bounding box for all layers in a mpWindow.

Return values
TRUEHas bounding box
FALSEHas not bounding box

Reimplemented from mpLayer.

Reimplemented in mpScaleY.

Definition at line 702 of file mathplot.h.

702 { return FALSE; }

◆ IsHorizontal()

virtual bool mpScaleXBase::IsHorizontal ( )
inlineoverridevirtualinherited

Implements mpScaleBase.

Definition at line 856 of file mathplot.h.

856 { return true; }

◆ IsInfo()

virtual bool mpLayer::IsInfo ( )
inlinevirtualinherited

Check whether the layer is an info box.

The default implementation returns FALSE. It is overrided to TRUE for mpInfoLayer class and its derivative. It is necessary to define mouse actions behaviour over info boxes.

Returns
whether the layer is an info boxes
See also
mpInfoLayer::IsInfo

Reimplemented in mpInfoLayer.

Definition at line 171 of file mathplot.h.

171 { return false; };

◆ IsVisible()

bool mpLayer::IsVisible ( )
inlineinherited

Checks whether the layer is visible or not.

Returns
true if visible

Definition at line 299 of file mathplot.h.

299 { return m_visible; };
bool m_visible
Definition: mathplot.h:323

Referenced by mpWindow::IsLayerVisible(), SIM_PLOT_PANEL::IsLegendShown(), and mpInfoLegend::Plot().

◆ labelCount()

virtual int mpScaleBase::labelCount ( ) const
inlineprotectedvirtualinherited

Definition at line 806 of file mathplot.h.

807  {
808  return m_tickLabels.size();
809  }
std::vector< TickLabel > m_tickLabels
Definition: mathplot.h:830

Referenced by mpScaleBase::computeLabelExtents(), mpScaleXBase::Plot(), and mpScaleY::Plot().

◆ Plot()

void mpScaleXBase::Plot ( wxDC &  dc,
mpWindow w 
)
overridevirtualinherited

Layer plot handler.

This implementation will plot the ruler adjusted to the visible area.

2;

Implements mpLayer.

Definition at line 1295 of file mathplot.cpp.

1296 {
1297  int tx, ty;
1298 
1299  m_offset = -m_minV;
1300  m_scale = 1.0 / ( m_maxV - m_minV );
1301 
1302  recalculateTicks( dc, w );
1303 
1304  if( m_visible )
1305  {
1306  dc.SetPen( m_pen );
1307  dc.SetFont( m_font );
1308  int orgy = 0;
1309 
1310  const int extend = w.GetScrX();
1311 
1312  if( m_flags == mpALIGN_CENTER )
1313  orgy = w.y2p( 0 ); // (int)(w.GetPosY() * w.GetScaleY());
1314 
1315  if( m_flags == mpALIGN_TOP )
1316  {
1317  if( m_drawOutsideMargins )
1318  orgy = X_BORDER_SEPARATION;
1319  else
1320  orgy = w.GetMarginTop();
1321  }
1322 
1323  if( m_flags == mpALIGN_BOTTOM )
1324  {
1325  if( m_drawOutsideMargins )
1326  orgy = X_BORDER_SEPARATION;
1327  else
1328  orgy = w.GetScrY() - w.GetMarginBottom();
1329  }
1330 
1332  orgy = w.GetScrY() - 1; // dc.LogicalToDeviceY(0) - 1;
1333 
1334  if( m_flags == mpALIGN_BORDER_TOP )
1335  orgy = 1; // -dc.LogicalToDeviceY(0);
1336 
1337  // dc.DrawLine( 0, orgy, w.GetScrX(), orgy);
1338 
1339  wxCoord startPx = m_drawOutsideMargins ? 0 : w.GetMarginLeft();
1340  wxCoord endPx = m_drawOutsideMargins ? w.GetScrX() : w.GetScrX() - w.GetMarginRight();
1341  wxCoord minYpx = m_drawOutsideMargins ? 0 : w.GetMarginTop();
1342  wxCoord maxYpx = m_drawOutsideMargins ? w.GetScrY() : w.GetScrY() - w.GetMarginBottom();
1343 
1344  // int tmp=-65535;
1345  int labelH = m_maxLabelHeight; // Control labels heigth to decide where to put axis name (below labels or on top of axis)
1346 
1347  // int maxExtent = tc.MaxLabelWidth();
1348  for( int n = 0; n < tickCount(); n++ )
1349  {
1350  double tp = getTickPos( n );
1351 
1352  // double xlogmin = log10 ( m_minV );
1353  // double xlogmax = log10 ( m_maxV );
1354 
1355  double px = TransformToPlot( tp ); // ( log10 ( tp ) - xlogmin) / (xlogmax - xlogmin);
1356 
1357  const int p = (int) ( ( px - w.GetPosX() ) * w.GetScaleX() );
1358 
1359  if( (p >= startPx) && (p <= endPx) )
1360  {
1361  if( m_ticks ) // draw axis ticks
1362  {
1364  dc.DrawLine( p, orgy, p, orgy - 4 );
1365  else
1366  dc.DrawLine( p, orgy, p, orgy + 4 );
1367  }
1368  else // draw grid dotted lines
1369  {
1370  m_pen.SetStyle( wxPENSTYLE_DOT );
1371  dc.SetPen( m_pen );
1372 
1374  {
1375  m_pen.SetStyle( wxPENSTYLE_DOT );
1376  dc.SetPen( m_pen );
1377  dc.DrawLine( p, orgy + 4, p, minYpx );
1378  m_pen.SetStyle( wxPENSTYLE_SOLID );
1379  dc.SetPen( m_pen );
1380  dc.DrawLine( p, orgy + 4, p, orgy - 4 );
1381  }
1382  else
1383  {
1385  {
1386  dc.DrawLine( p, orgy - 4, p, maxYpx );
1387  }
1388  else
1389  {
1390  dc.DrawLine( p, minYpx, p, maxYpx ); // 0/*-w.GetScrY()*/, p, w.GetScrY() );
1391  }
1392  }
1393 
1394  m_pen.SetStyle( wxPENSTYLE_SOLID );
1395  dc.SetPen( m_pen );
1396  }
1397  }
1398  }
1399 
1400  m_pen.SetStyle( wxPENSTYLE_SOLID );
1401  dc.SetPen( m_pen );
1402  dc.DrawLine( startPx, minYpx, endPx, minYpx );
1403  dc.DrawLine( startPx, maxYpx, endPx, maxYpx );
1404 
1405  // Actually draw labels, taking care of not overlapping them, and distributing them
1406  // regularly
1407  for( int n = 0; n < labelCount(); n++ )
1408  {
1409  double tp = getLabelPos( n );
1410 
1411  if( !m_tickLabels[n].visible )
1412  continue;
1413 
1414  // double xlogmin = log10 ( m_minV );
1415  // double xlogmax = log10 ( m_maxV );
1416 
1417  double px = TransformToPlot( tp ); // ( log10 ( tp ) - xlogmin) / (xlogmax - xlogmin);
1418 
1419  const int p = (int) ( ( px - w.GetPosX() ) * w.GetScaleX() );
1420 
1421  if( (p >= startPx) && (p <= endPx) )
1422  {
1423  // Write ticks labels in s string
1424  wxString s = m_tickLabels[n].label;
1425 
1426  dc.GetTextExtent( s, &tx, &ty );
1427 
1429  {
1430  dc.DrawText( s, p - tx / 2, orgy - 4 - ty );
1431  }
1432  else
1433  {
1434  dc.DrawText( s, p - tx / 2, orgy + 4 );
1435  }
1436  }
1437  }
1438 
1439  // Draw axis name
1440  dc.GetTextExtent( m_name, &tx, &ty );
1441 
1442  switch( m_nameFlags )
1443  {
1444  case mpALIGN_BORDER_BOTTOM:
1445  dc.DrawText( m_name, extend - tx - 4, orgy - 8 - ty - labelH );
1446  break;
1447 
1448  case mpALIGN_BOTTOM:
1449  {
1450  dc.DrawText( m_name, (endPx + startPx) / 2 - tx / 2, orgy + 6 + labelH );
1451  }
1452  break;
1453 
1454  case mpALIGN_CENTER:
1455  dc.DrawText( m_name, extend - tx - 4, orgy - 4 - ty );
1456  break;
1457 
1458  case mpALIGN_TOP:
1459  {
1460  if( (!m_drawOutsideMargins) && ( w.GetMarginTop() > (ty + labelH + 8) ) )
1461  {
1462  dc.DrawText( m_name, (endPx - startPx - tx) >> 1, orgy - 6 - ty - labelH );
1463  }
1464  else
1465  {
1466  dc.DrawText( m_name, extend - tx - 4, orgy + 4 );
1467  }
1468  }
1469  break;
1470 
1471  case mpALIGN_BORDER_TOP:
1472  dc.DrawText( m_name, extend - tx - 4, orgy + 6 + labelH );
1473  break;
1474 
1475  default:
1476  break;
1477  }
1478  }
1479 }
double m_maxV
Definition: mathplot.h:837
virtual void recalculateTicks(wxDC &dc, mpWindow &w)
Definition: mathplot.h:799
double GetScaleX(void) const
Definition: mathplot.h:1106
bool m_ticks
Definition: mathplot.h:836
double m_offset
Definition: mathplot.h:832
int m_maxLabelHeight
Definition: mathplot.h:839
int GetMarginBottom()
Definition: mathplot.h:1372
int m_flags
Definition: mathplot.h:834
std::vector< TickLabel > m_tickLabels
Definition: mathplot.h:830
int tickCount() const
Definition: mathplot.h:801
double GetPosX(void) const
Definition: mathplot.h:1120
bool m_visible
Definition: mathplot.h:323
#define X_BORDER_SEPARATION
Definition: mathplot.h:95
#define mpALIGN_BORDER_TOP
Aligns X axis to top border.
Definition: mathplot.h:490
wxCoord y2p(double y)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
Definition: mathplot.h:1204
int GetMarginTop()
Definition: mathplot.h:1368
int GetScrX(void) const
Get current view's X dimension in device context units.
Definition: mathplot.h:1135
virtual double getLabelPos(int n)
Definition: mathplot.h:819
#define mpALIGN_TOP
Aligns label to the top.
Definition: mathplot.h:484
wxFont m_font
Definition: mathplot.h:311
double m_minV
Definition: mathplot.h:837
bool m_drawOutsideMargins
Definition: mathplot.h:321
int GetMarginRight()
Definition: mathplot.h:1370
int GetMarginLeft()
Definition: mathplot.h:1374
#define mpALIGN_BORDER_BOTTOM
Aligns X axis to bottom border.
Definition: mathplot.h:488
double m_scale
Definition: mathplot.h:832
virtual double TransformToPlot(double x)
Definition: mathplot.h:775
wxPen m_pen
Definition: mathplot.h:316
#define mpALIGN_BOTTOM
Aligns label to the bottom.
Definition: mathplot.h:486
#define mpALIGN_CENTER
Aligns label to the center.
Definition: mathplot.h:480
wxString m_name
Definition: mathplot.h:318
int m_nameFlags
Definition: mathplot.h:835
virtual int labelCount() const
Definition: mathplot.h:806
virtual double getTickPos(int n)
Definition: mathplot.h:814
int GetScrY(void) const
Get current view's Y dimension in device context units.
Definition: mathplot.h:1144

References mpScaleBase::getLabelPos(), mpWindow::GetMarginBottom(), mpWindow::GetMarginLeft(), mpWindow::GetMarginRight(), mpWindow::GetMarginTop(), mpWindow::GetPosX(), mpWindow::GetScaleX(), mpWindow::GetScrX(), mpWindow::GetScrY(), mpScaleBase::getTickPos(), mpScaleBase::labelCount(), mpLayer::m_drawOutsideMargins, mpScaleBase::m_flags, mpLayer::m_font, mpScaleBase::m_maxLabelHeight, mpScaleBase::m_maxV, mpScaleBase::m_minV, mpLayer::m_name, mpScaleBase::m_nameFlags, mpScaleBase::m_offset, mpLayer::m_pen, mpScaleBase::m_scale, mpScaleBase::m_tickLabels, mpScaleBase::m_ticks, mpLayer::m_visible, mpALIGN_BORDER_BOTTOM, mpALIGN_BORDER_TOP, mpALIGN_BOTTOM, mpALIGN_CENTER, mpALIGN_TOP, mpScaleBase::recalculateTicks(), mpScaleBase::tickCount(), mpScaleBase::TransformToPlot(), X_BORDER_SEPARATION, and mpWindow::y2p().

◆ recalculateTicks()

void mpScaleXLog::recalculateTicks ( wxDC &  dc,
mpWindow w 
)
overrideprotectedvirtualinherited

Layer plot handler.

This implementation will plot the ruler adjusted to the visible area.

Reimplemented from mpScaleBase.

Definition at line 1229 of file mathplot.cpp.

1230 {
1231  double minV, maxV, minVvis, maxVvis;
1232 
1233  GetDataRange( minV, maxV );
1234  getVisibleDataRange( w, minVvis, maxVvis );
1235 
1236  // double decades = log( maxV / minV ) / log(10);
1237  double minDecade = pow( 10, floor( log10( minV ) ) );
1238  double maxDecade = pow( 10, ceil( log10( maxV ) ) );
1239  double visibleDecades = log( maxVvis / minVvis ) / log( 10 );
1240 
1241  double d;
1242 
1243  m_tickValues.clear();
1244  m_tickLabels.clear();
1245 
1246  if( minDecade == 0.0 )
1247  return;
1248 
1249 
1250  for( d = minDecade; d<=maxDecade; d *= 10.0 )
1251  {
1252  m_tickLabels.emplace_back( d );
1253 
1254  for( double dd = d; dd < d * 10; dd += d )
1255  {
1256  if( visibleDecades < 2 )
1257  m_tickLabels.emplace_back( dd );
1258 
1259  m_tickValues.push_back( dd );
1260  }
1261  }
1262 
1263  updateTickLabels( dc, w );
1264 }
virtual void getVisibleDataRange(mpWindow &w, double &minV, double &maxV) override
Definition: mathplot.cpp:1217
void GetDataRange(double &minV, double &maxV)
Definition: mathplot.h:733
void updateTickLabels(wxDC &dc, mpWindow &w)
Definition: mathplot.cpp:997
std::vector< TickLabel > m_tickLabels
Definition: mathplot.h:830
std::vector< double > m_tickValues
Definition: mathplot.h:829

References mpScaleBase::GetDataRange(), mpScaleXBase::getVisibleDataRange(), mpScaleBase::m_tickLabels, mpScaleBase::m_tickValues, and mpScaleBase::updateTickLabels().

◆ ResetDataRange()

void mpScaleBase::ResetDataRange ( )
inlineinherited

Definition at line 760 of file mathplot.h.

761  {
762  m_rangeSet = 0;
763  }
bool m_rangeSet
Definition: mathplot.h:838

Referenced by SIM_PLOT_PANEL::ResetScales().

◆ SetAlign()

void mpScaleBase::SetAlign ( int  align)
inlineinherited

Set X axis alignment.

Parameters
alignalignment (choose between mpALIGN_BORDER_BOTTOM, mpALIGN_BOTTOM, mpALIGN_CENTER, mpALIGN_TOP, mpALIGN_BORDER_TOP

Definition at line 708 of file mathplot.h.

708 { m_flags = align; };
int m_flags
Definition: mathplot.h:834

◆ SetBrush()

void mpLayer::SetBrush ( wxBrush  brush)
inlineinherited

Set layer brush.

Parameters
brushbrush, will be copied to internal class member

Definition at line 311 of file mathplot.h.

311 { m_brush = brush; };
wxBrush m_brush
Definition: mathplot.h:317

◆ SetContinuity()

void mpLayer::SetContinuity ( bool  continuity)
inlineinherited

Set the 'continuity' property of the layer (true:draws a continuous line, false:draws separate points).

See also
GetContinuity

Definition at line 254 of file mathplot.h.

254 { m_continuous = continuity; }
bool m_continuous
Definition: mathplot.h:319

Referenced by TRACE::TRACE().

◆ SetDataRange()

void mpScaleBase::SetDataRange ( double  minV,
double  maxV 
)
inlineinherited

Definition at line 726 of file mathplot.h.

727  {
728  m_rangeSet = true;
729  m_minV = minV;
730  m_maxV = maxV;
731  }
double m_maxV
Definition: mathplot.h:837
bool m_rangeSet
Definition: mathplot.h:838
double m_minV
Definition: mathplot.h:837

◆ SetDrawOutsideMargins()

void mpLayer::SetDrawOutsideMargins ( bool  drawModeOutside)
inlineinherited

Set Draw mode: inside or outside margins.

Default is outside, which allows the layer to draw up to the mpWindow border.

Parameters
drawModeOutsideThe draw mode to be set

Definition at line 282 of file mathplot.h.

282 { m_drawOutsideMargins = drawModeOutside; };
bool m_drawOutsideMargins
Definition: mathplot.h:321

Referenced by CURSOR::CURSOR(), and TRACE::TRACE().

◆ SetFont()

void mpLayer::SetFont ( wxFont &  font)
inlineinherited

Set layer font.

Parameters
fontFont, will be copied to internal class member

Definition at line 273 of file mathplot.h.

273 { m_font = font; }
wxFont m_font
Definition: mathplot.h:311

◆ SetName()

void mpLayer::SetName ( wxString  name)
inlineinherited

Set layer name.

Parameters
nameName, will be copied to internal class member

Definition at line 268 of file mathplot.h.

268 { m_name = name; }
const char * name
Definition: DXF_plotter.cpp:59
wxString m_name
Definition: mathplot.h:318

References name.

◆ SetNameAlign()

void mpScaleBase::SetNameAlign ( int  align)
inlineinherited

Definition at line 710 of file mathplot.h.

710 { m_nameFlags = align; }
int m_nameFlags
Definition: mathplot.h:835

Referenced by SIM_PLOT_PANEL::SIM_PLOT_PANEL().

◆ SetPen()

void mpLayer::SetPen ( wxPen  pen)
inlineinherited

Set layer pen.

Parameters
penPen, will be copied to internal class member

Definition at line 278 of file mathplot.h.

278 { m_pen = pen; }
wxPen m_pen
Definition: mathplot.h:316

Referenced by SIM_PLOT_PANEL::UpdateTraceStyle().

◆ SetTicks()

void mpScaleBase::SetTicks ( bool  enable)
inlineinherited

Set X axis ticks or grid.

Parameters
enable= true to plot axis ticks, false to plot grid.

Definition at line 715 of file mathplot.h.

715 { m_ticks = enable; };
bool m_ticks
Definition: mathplot.h:836

Referenced by SIM_PLOT_PANEL::ShowGrid(), and SIM_PLOT_PANEL::SIM_PLOT_PANEL().

◆ SetVisible()

void mpLayer::SetVisible ( bool  show)
inlineinherited

Sets layer visibility.

Parameters
showvisibility bool.

Definition at line 303 of file mathplot.h.

303 { m_visible = show; };
bool m_visible
Definition: mathplot.h:323

Referenced by mpWindow::SetLayerVisible(), SIM_PLOT_PANEL::ShowLegend(), and SIM_PLOT_PANEL::SIM_PLOT_PANEL().

◆ ShowName()

void mpLayer::ShowName ( bool  show)
inlineinherited

Shows or hides the text label with the name of the layer (default is visible).

Definition at line 263 of file mathplot.h.

263 { m_showName = show; };
bool m_showName
Definition: mathplot.h:320

Referenced by TRACE::TRACE().

◆ tickCount()

int mpScaleBase::tickCount ( ) const
inlineprotectedinherited

Definition at line 801 of file mathplot.h.

802  {
803  return m_tickValues.size();
804  }
std::vector< double > m_tickValues
Definition: mathplot.h:829

Referenced by mpScaleXBase::Plot(), and mpScaleY::Plot().

◆ TickLabels()

std::vector<TickLabel>& mpScaleBase::TickLabels ( )
inlineinherited

Definition at line 790 of file mathplot.h.

790 { return m_tickLabels; };
std::vector< TickLabel > m_tickLabels
Definition: mathplot.h:830

Referenced by formatLabels().

◆ TransformFromPlot()

double mpScaleXLog::TransformFromPlot ( double  xplot)
overridevirtualinherited

Reimplemented from mpScaleBase.

Definition at line 3237 of file mathplot.cpp.

3238 {
3239  double xlogmin = log10( m_minV );
3240  double xlogmax = log10( m_maxV );
3241 
3242  return pow( 10.0, xplot * (xlogmax - xlogmin) + xlogmin );
3243 }
double m_maxV
Definition: mathplot.h:837
double m_minV
Definition: mathplot.h:837

References mpScaleBase::m_maxV, and mpScaleBase::m_minV.

◆ TransformToPlot()

double mpScaleXLog::TransformToPlot ( double  x)
overridevirtualinherited

Reimplemented from mpScaleBase.

Definition at line 3228 of file mathplot.cpp.

3229 {
3230  double xlogmin = log10( m_minV );
3231  double xlogmax = log10( m_maxV );
3232 
3233  return ( log10( x ) - xlogmin) / (xlogmax - xlogmin);
3234 }
double m_maxV
Definition: mathplot.h:837
double m_minV
Definition: mathplot.h:837

References mpScaleBase::m_maxV, and mpScaleBase::m_minV.

◆ updateTickLabels()

void mpScaleBase::updateTickLabels ( wxDC &  dc,
mpWindow w 
)
protectedinherited

Definition at line 997 of file mathplot.cpp.

998 {
999  formatLabels();
1000  computeLabelExtents( dc, w );
1001 
1002  // int gap = IsHorizontal() ? m_maxLabelWidth + 10 : m_maxLabelHeight + 5;
1003 
1004  // if ( m_tickLabels.size() <= 2)
1005  // return;
1006 
1007  /*
1008  * fixme!
1009  *
1010  * for ( auto &l : m_tickLabels )
1011  * {
1012  * double p = TransformToPlot ( l.pos );
1013  *
1014  * if ( !IsHorizontal() )
1015  * l.pixelPos = (int)(( w.GetPosY() - p ) * w.GetScaleY());
1016  * else
1017  * l.pixelPos = (int)(( p - w.GetPosX()) * w.GetScaleX());
1018  * }
1019  *
1020  *
1021  * for (int i = 1; i < m_tickLabels.size() - 1; i++)
1022  * {
1023  * int dist_prev;
1024  *
1025  * for(int j = i-1; j >= 1; j--)
1026  * {
1027  * if( m_tickLabels[j].visible)
1028  * {
1029  * dist_prev = abs( m_tickLabels[j].pixelPos - m_tickLabels[i].pixelPos );
1030  * break;
1031  * }
1032  * }
1033  *
1034  * if (dist_prev < gap)
1035  * m_tickLabels[i].visible = false;
1036  * }
1037  */
1038 }
void computeLabelExtents(wxDC &dc, mpWindow &w)
Definition: mathplot.cpp:980
virtual void formatLabels()
Definition: mathplot.h:812

References mpScaleBase::computeLabelExtents(), and mpScaleBase::formatLabels().

Referenced by mpScaleX::recalculateTicks(), mpScaleXLog::recalculateTicks(), and mpScaleY::recalculateTicks().

Member Data Documentation

◆ m_absVisibleMaxV

double mpScaleBase::m_absVisibleMaxV
protectedinherited

◆ m_brush

wxBrush mpLayer::m_brush
protectedinherited

Definition at line 317 of file mathplot.h.

◆ m_continuous

bool mpLayer::m_continuous
protectedinherited

Definition at line 319 of file mathplot.h.

Referenced by CURSOR::Plot(), mpFXY::Plot(), and mpMovableObject::Plot().

◆ m_drawOutsideMargins

◆ m_flags

int mpScaleBase::m_flags
protectedinherited

Definition at line 834 of file mathplot.h.

Referenced by mpScaleBase::mpScaleBase(), and mpScaleXBase::Plot().

◆ m_font

◆ m_maxLabelHeight

int mpScaleBase::m_maxLabelHeight
protectedinherited

◆ m_maxLabelWidth

int mpScaleBase::m_maxLabelWidth
protectedinherited

Definition at line 840 of file mathplot.h.

Referenced by mpScaleBase::computeLabelExtents(), and mpScaleBase::mpScaleBase().

◆ m_maxV

◆ m_minV

◆ m_name

wxString mpLayer::m_name
protectedinherited

◆ m_nameFlags

int mpScaleBase::m_nameFlags
protectedinherited

Definition at line 835 of file mathplot.h.

Referenced by mpScaleBase::mpScaleBase(), mpScaleXBase::Plot(), and mpScaleY::Plot().

◆ m_offset

◆ m_pen

◆ m_rangeSet

bool mpScaleBase::m_rangeSet
protectedinherited

Definition at line 838 of file mathplot.h.

Referenced by mpScaleBase::mpScaleBase().

◆ m_scale

◆ m_showName

bool mpLayer::m_showName
protectedinherited

◆ m_tickLabels

std::vector<TickLabel> mpScaleBase::m_tickLabels
protectedinherited

◆ m_ticks

bool mpScaleBase::m_ticks
protectedinherited

Definition at line 836 of file mathplot.h.

Referenced by mpScaleY::GetTicks(), mpScaleBase::mpScaleBase(), and mpScaleXBase::Plot().

◆ m_tickValues

std::vector<double> mpScaleBase::m_tickValues
protectedinherited

◆ m_type

mpLayerType mpLayer::m_type
protectedinherited

Definition at line 322 of file mathplot.h.

Referenced by mpInfoLayer::mpInfoLayer().

◆ m_visible


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