KiCad PCB EDA Suite
mpScaleXLog Class Reference

#include <mathplot.h>

Inheritance diagram for mpScaleXLog:
mpScaleXBase mpScaleBase mpLayer

Public Member Functions

 mpScaleXLog (const wxString &name=wxT("log(X)"), int flags=mpALIGN_CENTER, bool ticks=true, unsigned int type=mpX_NORMAL)
 Full constructor. More...
 
virtual double TransformToPlot (double x) const override
 
virtual double TransformFromPlot (double xplot) const override
 
virtual bool IsHorizontal () const 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 () const 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 () const
 Get X axis ticks or grid. More...
 
void SetDataRange (double minV, double maxV)
 
void GetDataRange (double &minV, double &maxV) const
 
void ExtendDataRange (double minV, double maxV)
 
void ResetDataRange ()
 
double AbsMaxValue () const
 
double AbsVisibleMaxValue () const
 
std::vector< TickLabel > & TickLabels ()
 
virtual bool IsInfo () const
 Check whether the layer is an info box. More...
 
virtual double GetMinX () const
 Get inclusive left border of bounding box. More...
 
virtual double GetMaxX () const
 Get inclusive right border of bounding box. More...
 
virtual double GetMinY () const
 Get inclusive bottom border of bounding box. More...
 
virtual double GetMaxY () const
 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) const
 Get a small square bitmap filled with the colour of the pen used in the layer. More...
 
mpLayerType GetLayerType () const
 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 () const
 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 void formatLabels ()
 
virtual double getTickPos (int n) const
 
virtual double getLabelPos (int n) const
 
virtual wxString getLabel (int n) const
 

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 897 of file mathplot.h.

Constructor & Destructor Documentation

◆ mpScaleXLog()

mpScaleXLog::mpScaleXLog ( const wxString &  name = wxT("log(X)"),
int  flags = mpALIGN_CENTER,
bool  ticks = true,
unsigned int  type = mpX_NORMAL 
)

Full constructor.

Parameters
nameLabel to plot by the ruler
flagsSet the position of the scale with respect to the window.
ticksSelect ticks or grid. Give true (default) for drawing axis ticks, false for drawing the grid.
typempX_NORMAL for normal labels, mpX_TIME for time axis in hours, minutes, seconds.

Definition at line 1194 of file mathplot.cpp.

1194 :
1195 mpScaleXBase( name, flags, ticks, type )
1196{
1197}
const char * name
Definition: DXF_plotter.cpp:56
mpScaleXBase(const wxString &name=wxT("X"), int flags=mpALIGN_CENTER, bool ticks=true, unsigned int type=mpX_NORMAL)
Full constructor.
Definition: mathplot.cpp:1176

Member Function Documentation

◆ AbsMaxValue()

double mpScaleBase::AbsMaxValue ( ) const
inlineinherited

Definition at line 764 of file mathplot.h.

765 {
766 return std::max( std::abs( m_maxV ), std::abs( m_minV ) );
767 }
double m_maxV
Definition: mathplot.h:836
double m_minV
Definition: mathplot.h:836
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Definition: eda_angle.h:412

References std::abs().

◆ AbsVisibleMaxValue()

double mpScaleBase::AbsVisibleMaxValue ( ) const
inlineinherited

Definition at line 769 of file mathplot.h.

770 {
771 return m_absVisibleMaxV;
772 }
double m_absVisibleMaxV
Definition: mathplot.h:832

◆ computeLabelExtents()

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

◆ ExtendDataRange()

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

Definition at line 738 of file mathplot.h.

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

Referenced by mpFXY::UpdateScales().

◆ formatLabel()

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

Definition at line 810 of file mathplot.h.

810{ return wxT( "" ); }

◆ formatLabels()

virtual void mpScaleBase::formatLabels ( )
inlineprotectedvirtualinherited

Definition at line 811 of file mathplot.h.

811{};

Referenced by mpScaleBase::updateTickLabels().

◆ GetBrush()

const wxBrush & mpLayer::GetBrush ( ) const
inlineinherited

Get brush set for this layer.

Returns
brush.

Definition at line 306 of file mathplot.h.

306{ return m_brush; };
wxBrush m_brush
Definition: mathplot.h:316

◆ GetColourSquare()

wxBitmap mpLayer::GetColourSquare ( int  side = 16) const
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 74 of file mathplot.cpp.

75{
76 wxBitmap square( side, side, -1 );
77 wxColour filler = m_pen.GetColour();
78 wxBrush brush( filler, wxBRUSHSTYLE_SOLID );
79 wxMemoryDC dc;
80
81 dc.SelectObject( square );
82 dc.SetBackground( brush );
83 dc.Clear();
84 dc.SelectObject( wxNullBitmap );
85 return square;
86}
double square(double x)
wxPen m_pen
Definition: mathplot.h:315

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 258 of file mathplot.h.

258{ return m_continuous; }
bool m_continuous
Definition: mathplot.h:318

◆ GetDataRange()

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

Definition at line 732 of file mathplot.h.

733 {
734 minV = m_minV;
735 maxV = m_maxV;
736 }

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

◆ GetDrawOutsideMargins()

bool mpLayer::GetDrawOutsideMargins ( )
inlineinherited

Get Draw mode: inside or outside margins.

Returns
The draw mode

Definition at line 285 of file mathplot.h.

285{ return m_drawOutsideMargins; };
bool m_drawOutsideMargins
Definition: mathplot.h:320

◆ GetFont()

const wxFont & mpLayer::GetFont ( ) const
inlineinherited

Get font set for this layer.

Returns
Font

Definition at line 243 of file mathplot.h.

243{ return m_font; }
wxFont m_font
Definition: mathplot.h:314

◆ getLabel()

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

Definition at line 823 of file mathplot.h.

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

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

◆ getLabelPos()

virtual double mpScaleBase::getLabelPos ( int  n) const
inlineprotectedvirtualinherited

Definition at line 818 of file mathplot.h.

819 {
820 return m_tickLabels[n].pos;
821 }

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

◆ GetLayerType()

mpLayerType mpLayer::GetLayerType ( ) const
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 294 of file mathplot.h.

294{ return m_type; };
mpLayerType m_type
Definition: mathplot.h:321

Referenced by mpInfoLegend::Plot().

◆ GetMaxX()

virtual double mpLayer::GetMaxX ( ) const
inlinevirtualinherited

Get inclusive right border of bounding box.

Returns
Value

Reimplemented in mpFXYVector, mpMovableObject, and mpBitmapLayer.

Definition at line 180 of file mathplot.h.

180{ return 1.0; }

Referenced by mpFXY::UpdateScales().

◆ GetMaxY()

virtual double mpLayer::GetMaxY ( ) const
inlinevirtualinherited

Get inclusive top border of bounding box.

Returns
Value

Reimplemented in mpFXYVector, mpMovableObject, and mpBitmapLayer.

Definition at line 190 of file mathplot.h.

190{ return 1.0; }

Referenced by mpFXY::UpdateScales().

◆ GetMinX()

virtual double mpLayer::GetMinX ( ) const
inlinevirtualinherited

Get inclusive left border of bounding box.

Returns
Value

Reimplemented in mpFXYVector, mpMovableObject, and mpBitmapLayer.

Definition at line 175 of file mathplot.h.

175{ return -1.0; }

Referenced by mpFXY::UpdateScales().

◆ GetMinY()

virtual double mpLayer::GetMinY ( ) const
inlinevirtualinherited

Get inclusive bottom border of bounding box.

Returns
Value

Reimplemented in mpFXYVector, mpMovableObject, and mpBitmapLayer.

Definition at line 185 of file mathplot.h.

185{ return -1.0; }

Referenced by mpFXY::UpdateScales().

◆ GetName()

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

Get layer name.

Returns
Name

Definition at line 238 of file mathplot.h.

238{ return m_name; }
wxString m_name
Definition: mathplot.h:317

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 248 of file mathplot.h.

248{ return m_pen; }

Referenced by CURSOR::Plot(), and mpInfoLegend::Plot().

◆ getTickPos()

virtual double mpScaleBase::getTickPos ( int  n) const
inlineprotectedvirtualinherited

Definition at line 813 of file mathplot.h.

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

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

◆ GetTicks()

bool mpScaleBase::GetTicks ( ) const
inlineinherited

Get X axis ticks or grid.

Returns
true if plot is drawing axis ticks, false if the grid is active.

Definition at line 719 of file mathplot.h.

719{ return m_ticks; };
bool m_ticks
Definition: mathplot.h:835

Referenced by SIM_PLOT_PANEL::IsGridShown().

◆ getVisibleDataRange()

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

Reimplemented from mpScaleBase.

Definition at line 1122 of file mathplot.cpp.

1123{
1124 wxCoord startPx = m_drawOutsideMargins ? 0 : w.GetMarginLeft();
1125 wxCoord endPx = m_drawOutsideMargins ? w.GetScrX() : w.GetScrX() - w.GetMarginRight();
1126 double pxmin = w.p2x( startPx );
1127 double pxmax = w.p2x( endPx );
1128
1129 minV = TransformFromPlot( pxmin );
1130 maxV = TransformFromPlot( pxmax );
1131}
virtual double TransformFromPlot(double xplot) const
Definition: mathplot.h:775
int GetMarginLeft() const
Definition: mathplot.h:1377
int GetScrX(void) const
Get current view's X dimension in device context units.
Definition: mathplot.h:1138
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1192
int GetMarginRight() const
Definition: mathplot.h:1373

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

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

◆ HasBBox()

bool mpScaleBase::HasBBox ( ) const
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 701 of file mathplot.h.

701{ return false; }

◆ IsHorizontal()

virtual bool mpScaleXBase::IsHorizontal ( ) const
inlineoverridevirtualinherited

Implements mpScaleBase.

Definition at line 855 of file mathplot.h.

855{ return true; }

◆ IsInfo()

virtual bool mpLayer::IsInfo ( ) const
inlinevirtualinherited

Check whether the layer is an info box.

The default implementation returns false. It is overridden 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 170 of file mathplot.h.

170{ return false; };

◆ IsVisible()

bool mpLayer::IsVisible ( ) const
inlineinherited

Checks whether the layer is visible or not.

Returns
true if visible

Definition at line 298 of file mathplot.h.

298{ return m_visible; };
bool m_visible
Definition: mathplot.h:322

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

◆ labelCount()

virtual int mpScaleBase::labelCount ( ) const
inlineprotectedvirtualinherited

Definition at line 805 of file mathplot.h.

806 {
807 return m_tickLabels.size();
808 }

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 1200 of file mathplot.cpp.

1201{
1202 int tx, ty;
1203
1204 m_offset = -m_minV;
1205 m_scale = 1.0 / ( m_maxV - m_minV );
1206
1207 recalculateTicks( dc, w );
1208
1209 if( m_visible )
1210 {
1211 dc.SetPen( m_pen );
1212 dc.SetFont( m_font );
1213 int orgy = 0;
1214
1215 const int extend = w.GetScrX();
1216
1217 if( m_flags == mpALIGN_CENTER )
1218 orgy = w.y2p( 0 ); // (int)(w.GetPosY() * w.GetScaleY());
1219
1220 if( m_flags == mpALIGN_TOP )
1221 {
1223 orgy = X_BORDER_SEPARATION;
1224 else
1225 orgy = w.GetMarginTop();
1226 }
1227
1228 if( m_flags == mpALIGN_BOTTOM )
1229 {
1231 orgy = X_BORDER_SEPARATION;
1232 else
1233 orgy = w.GetScrY() - w.GetMarginBottom();
1234 }
1235
1237 orgy = w.GetScrY() - 1; // dc.LogicalToDeviceY(0) - 1;
1238
1240 orgy = 1; // -dc.LogicalToDeviceY(0);
1241
1242 // dc.DrawLine( 0, orgy, w.GetScrX(), orgy);
1243
1244 wxCoord startPx = m_drawOutsideMargins ? 0 : w.GetMarginLeft();
1245 wxCoord endPx = m_drawOutsideMargins ? w.GetScrX() : w.GetScrX() - w.GetMarginRight();
1246 wxCoord minYpx = m_drawOutsideMargins ? 0 : w.GetMarginTop();
1247 wxCoord maxYpx = m_drawOutsideMargins ? w.GetScrY() : w.GetScrY() - w.GetMarginBottom();
1248
1249 // int tmp=-65535;
1250 int labelH = m_maxLabelHeight; // Control labels height to decide where to put axis name (below labels or on top of axis)
1251
1252 // int maxExtent = tc.MaxLabelWidth();
1253 for( int n = 0; n < tickCount(); n++ )
1254 {
1255 double tp = getTickPos( n );
1256
1257 // double xlogmin = log10 ( m_minV );
1258 // double xlogmax = log10 ( m_maxV );
1259
1260 double px = TransformToPlot( tp ); // ( log10 ( tp ) - xlogmin) / (xlogmax - xlogmin);
1261
1262 const int p = (int) ( ( px - w.GetPosX() ) * w.GetScaleX() );
1263
1264 if( (p >= startPx) && (p <= endPx) )
1265 {
1266 if( m_ticks ) // draw axis ticks
1267 {
1269 dc.DrawLine( p, orgy, p, orgy - 4 );
1270 else
1271 dc.DrawLine( p, orgy, p, orgy + 4 );
1272 }
1273 else // draw grid dotted lines
1274 {
1275 m_pen.SetStyle( wxPENSTYLE_DOT );
1276 dc.SetPen( m_pen );
1277
1279 {
1280 m_pen.SetStyle( wxPENSTYLE_DOT );
1281 dc.SetPen( m_pen );
1282 dc.DrawLine( p, orgy + 4, p, minYpx );
1283 m_pen.SetStyle( wxPENSTYLE_SOLID );
1284 dc.SetPen( m_pen );
1285 dc.DrawLine( p, orgy + 4, p, orgy - 4 );
1286 }
1287 else
1288 {
1290 {
1291 dc.DrawLine( p, orgy - 4, p, maxYpx );
1292 }
1293 else
1294 {
1295 dc.DrawLine( p, minYpx, p, maxYpx ); // 0/*-w.GetScrY()*/, p, w.GetScrY() );
1296 }
1297 }
1298
1299 m_pen.SetStyle( wxPENSTYLE_SOLID );
1300 dc.SetPen( m_pen );
1301 }
1302 }
1303 }
1304
1305 m_pen.SetStyle( wxPENSTYLE_SOLID );
1306 dc.SetPen( m_pen );
1307 dc.DrawLine( startPx, minYpx, endPx, minYpx );
1308 dc.DrawLine( startPx, maxYpx, endPx, maxYpx );
1309
1310 // Actually draw labels, taking care of not overlapping them, and distributing them
1311 // regularly
1312 for( int n = 0; n < labelCount(); n++ )
1313 {
1314 double tp = getLabelPos( n );
1315
1316 if( !m_tickLabels[n].visible )
1317 continue;
1318
1319 // double xlogmin = log10 ( m_minV );
1320 // double xlogmax = log10 ( m_maxV );
1321
1322 double px = TransformToPlot( tp ); // ( log10 ( tp ) - xlogmin) / (xlogmax - xlogmin);
1323
1324 const int p = (int) ( ( px - w.GetPosX() ) * w.GetScaleX() );
1325
1326 if( (p >= startPx) && (p <= endPx) )
1327 {
1328 // Write ticks labels in s string
1329 wxString s = m_tickLabels[n].label;
1330
1331 dc.GetTextExtent( s, &tx, &ty );
1332
1334 {
1335 dc.DrawText( s, p - tx / 2, orgy - 4 - ty );
1336 }
1337 else
1338 {
1339 dc.DrawText( s, p - tx / 2, orgy + 4 );
1340 }
1341 }
1342 }
1343
1344 // Draw axis name
1345 dc.GetTextExtent( m_name, &tx, &ty );
1346
1347 switch( m_nameFlags )
1348 {
1350 dc.DrawText( m_name, extend - tx - 4, orgy - 8 - ty - labelH );
1351 break;
1352
1353 case mpALIGN_BOTTOM:
1354 {
1355 dc.DrawText( m_name, (endPx + startPx) / 2 - tx / 2, orgy + 6 + labelH );
1356 }
1357 break;
1358
1359 case mpALIGN_CENTER:
1360 dc.DrawText( m_name, extend - tx - 4, orgy - 4 - ty );
1361 break;
1362
1363 case mpALIGN_TOP:
1364 {
1365 if( (!m_drawOutsideMargins) && ( w.GetMarginTop() > (ty + labelH + 8) ) )
1366 {
1367 dc.DrawText( m_name, (endPx - startPx - tx) >> 1, orgy - 6 - ty - labelH );
1368 }
1369 else
1370 {
1371 dc.DrawText( m_name, extend - tx - 4, orgy + 4 );
1372 }
1373 }
1374 break;
1375
1376 case mpALIGN_BORDER_TOP:
1377 dc.DrawText( m_name, extend - tx - 4, orgy + 6 + labelH );
1378 break;
1379
1380 default:
1381 break;
1382 }
1383 }
1384}
double m_scale
Definition: mathplot.h:831
virtual void recalculateTicks(wxDC &dc, mpWindow &w)
Definition: mathplot.h:798
double m_offset
Definition: mathplot.h:831
virtual double TransformToPlot(double x) const
Definition: mathplot.h:774
int m_maxLabelHeight
Definition: mathplot.h:838
virtual double getTickPos(int n) const
Definition: mathplot.h:813
int tickCount() const
Definition: mathplot.h:800
virtual double getLabelPos(int n) const
Definition: mathplot.h:818
int m_flags
Definition: mathplot.h:833
int m_nameFlags
Definition: mathplot.h:834
virtual int labelCount() const
Definition: mathplot.h:805
int GetMarginTop() const
Definition: mathplot.h:1371
double GetScaleX(void) const
Definition: mathplot.h:1109
wxCoord y2p(double y)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
Definition: mathplot.h:1207
int GetMarginBottom() const
Definition: mathplot.h:1375
int GetScrY(void) const
Get current view's Y dimension in device context units.
Definition: mathplot.h:1147
double GetPosX(void) const
Definition: mathplot.h:1123
#define mpALIGN_BORDER_TOP
Aligns X axis to top border.
Definition: mathplot.h:489
#define mpALIGN_CENTER
Aligns label to the center.
Definition: mathplot.h:479
#define mpALIGN_TOP
Aligns label to the top.
Definition: mathplot.h:483
#define X_BORDER_SEPARATION
Definition: mathplot.h:94
#define mpALIGN_BOTTOM
Aligns label to the bottom.
Definition: mathplot.h:485
#define mpALIGN_BORDER_BOTTOM
Aligns X axis to bottom border.
Definition: mathplot.h:487
static thread_pool * tp
Definition: thread_pool.cpp:30

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(), tp, mpScaleBase::TransformToPlot(), X_BORDER_SEPARATION, and mpWindow::y2p().

◆ recalculateTicks()

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

Layer plot handler.

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

Reimplemented from mpScaleBase.

Definition at line 1134 of file mathplot.cpp.

1135{
1136 double minV, maxV, minVvis, maxVvis;
1137
1138 GetDataRange( minV, maxV );
1139 getVisibleDataRange( w, minVvis, maxVvis );
1140
1141 // double decades = log( maxV / minV ) / log(10);
1142 double minDecade = pow( 10, floor( log10( minV ) ) );
1143 double maxDecade = pow( 10, ceil( log10( maxV ) ) );
1144 double visibleDecades = log( maxVvis / minVvis ) / log( 10 );
1145
1146 double d;
1147
1148 m_tickValues.clear();
1149 m_tickLabels.clear();
1150
1151 if( minDecade == 0.0 )
1152 return;
1153
1154
1155 for( d = minDecade; d<=maxDecade; d *= 10.0 )
1156 {
1157 m_tickLabels.emplace_back( d );
1158
1159 for( double dd = d; dd < d * 10; dd += d )
1160 {
1161 if( visibleDecades < 2 )
1162 m_tickLabels.emplace_back( dd );
1163
1164 m_tickValues.push_back( dd );
1165 }
1166 }
1167
1168 updateTickLabels( dc, w );
1169}
void GetDataRange(double &minV, double &maxV) const
Definition: mathplot.h:732
void updateTickLabels(wxDC &dc, mpWindow &w)
Definition: mathplot.cpp:934
virtual void getVisibleDataRange(mpWindow &w, double &minV, double &maxV) override
Definition: mathplot.cpp:1122

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

◆ ResetDataRange()

void mpScaleBase::ResetDataRange ( )
inlineinherited

Definition at line 759 of file mathplot.h.

760 {
761 m_rangeSet = 0;
762 }

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 707 of file mathplot.h.

707{ m_flags = align; };

◆ SetBrush()

void mpLayer::SetBrush ( wxBrush  brush)
inlineinherited

Set layer brush.

Parameters
brushbrush, will be copied to internal class member

Definition at line 310 of file mathplot.h.

310{ m_brush = brush; };

◆ 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 253 of file mathplot.h.

253{ m_continuous = continuity; }

Referenced by TRACE::TRACE().

◆ SetDataRange()

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

Definition at line 725 of file mathplot.h.

726 {
727 m_rangeSet = true;
728 m_minV = minV;
729 m_maxV = maxV;
730 }

◆ 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 281 of file mathplot.h.

281{ m_drawOutsideMargins = drawModeOutside; };

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 272 of file mathplot.h.

272{ m_font = font; }

◆ SetName()

void mpLayer::SetName ( wxString  name)
inlineinherited

Set layer name.

Parameters
nameName, will be copied to internal class member

Definition at line 267 of file mathplot.h.

267{ m_name = name; }

References name.

◆ SetNameAlign()

void mpScaleBase::SetNameAlign ( int  align)
inlineinherited

Definition at line 709 of file mathplot.h.

709{ m_nameFlags = align; }

Referenced by SIM_PLOT_PANEL::updateAxes().

◆ SetPen()

void mpLayer::SetPen ( wxPen  pen)
inlineinherited

Set layer pen.

Parameters
penPen, will be copied to internal class member

Definition at line 277 of file mathplot.h.

277{ m_pen = pen; }

Referenced by SIM_PLOT_PANEL::EnableCursor(), and 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 714 of file mathplot.h.

714{ m_ticks = enable; };

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

◆ SetVisible()

void mpLayer::SetVisible ( bool  show)
inlineinherited

Sets layer visibility.

Parameters
showvisibility bool.

Definition at line 302 of file mathplot.h.

302{ m_visible = show; };

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 262 of file mathplot.h.

262{ m_showName = show; };
bool m_showName
Definition: mathplot.h:319

Referenced by TRACE::TRACE().

◆ tickCount()

int mpScaleBase::tickCount ( ) const
inlineprotectedinherited

Definition at line 800 of file mathplot.h.

801 {
802 return m_tickValues.size();
803 }

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

◆ TickLabels()

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

Definition at line 789 of file mathplot.h.

789{ return m_tickLabels; };

◆ TransformFromPlot()

double mpScaleXLog::TransformFromPlot ( double  xplot) const
overridevirtual

Reimplemented from mpScaleBase.

Definition at line 2828 of file mathplot.cpp.

2829{
2830 double xlogmin = log10( m_minV );
2831 double xlogmax = log10( m_maxV );
2832
2833 return pow( 10.0, xplot * (xlogmax - xlogmin) + xlogmin );
2834}

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

◆ TransformToPlot()

double mpScaleXLog::TransformToPlot ( double  x) const
overridevirtual

Reimplemented from mpScaleBase.

Definition at line 2819 of file mathplot.cpp.

2820{
2821 double xlogmin = log10( m_minV );
2822 double xlogmax = log10( m_maxV );
2823
2824 return ( log10( x ) - xlogmin) / (xlogmax - xlogmin);
2825}

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

◆ updateTickLabels()

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

Definition at line 934 of file mathplot.cpp.

935{
936 formatLabels();
937 computeLabelExtents( dc, w );
938
939 // int gap = IsHorizontal() ? m_maxLabelWidth + 10 : m_maxLabelHeight + 5;
940
941 // if ( m_tickLabels.size() <= 2)
942 // return;
943
944 /*
945 * fixme!
946 *
947 * for ( auto &l : m_tickLabels )
948 * {
949 * double p = TransformToPlot ( l.pos );
950 *
951 * if ( !IsHorizontal() )
952 * l.pixelPos = (int)(( w.GetPosY() - p ) * w.GetScaleY());
953 * else
954 * l.pixelPos = (int)(( p - w.GetPosX()) * w.GetScaleX());
955 * }
956 *
957 *
958 * for (int i = 1; i < m_tickLabels.size() - 1; i++)
959 * {
960 * int dist_prev;
961 *
962 * for(int j = i-1; j >= 1; j--)
963 * {
964 * if( m_tickLabels[j].visible)
965 * {
966 * dist_prev = abs( m_tickLabels[j].pixelPos - m_tickLabels[i].pixelPos );
967 * break;
968 * }
969 * }
970 *
971 * if (dist_prev < gap)
972 * m_tickLabels[i].visible = false;
973 * }
974 */
975}
virtual void formatLabels()
Definition: mathplot.h:811
void computeLabelExtents(wxDC &dc, mpWindow &w)
Definition: mathplot.cpp:917

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

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

Member Data Documentation

◆ m_absVisibleMaxV

double mpScaleBase::m_absVisibleMaxV
protectedinherited

◆ m_brush

wxBrush mpLayer::m_brush
protectedinherited

Definition at line 316 of file mathplot.h.

◆ m_continuous

bool mpLayer::m_continuous
protectedinherited

Definition at line 318 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 833 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 839 of file mathplot.h.

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

◆ m_maxV

double mpScaleBase::m_maxV
protectedinherited

◆ m_minV

double mpScaleBase::m_minV
protectedinherited

◆ m_name

wxString mpLayer::m_name
protectedinherited

◆ m_nameFlags

int mpScaleBase::m_nameFlags
protectedinherited

Definition at line 834 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 837 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 835 of file mathplot.h.

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

◆ m_tickValues

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

◆ m_type

mpLayerType mpLayer::m_type
protectedinherited

Definition at line 321 of file mathplot.h.

Referenced by mpInfoLayer::mpInfoLayer().

◆ m_visible


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