30#include "wx/dcclient.h"
36#include <wx/graphics.h>
50#define mpLEGEND_MARGIN 5
51#define mpLEGEND_LINEWIDTH 10
60IMPLEMENT_ABSTRACT_CLASS(
mpLayer, wxObject )
65 SetPen( (wxPen&) *wxBLACK_PEN );
66 SetFont( (wxFont&) *wxNORMAL_FONT );
80 m_dim = wxRect( 0, 0, 1, 1 );
81 m_brush = *wxTRANSPARENT_BRUSH;
82 m_reference.x = 0; m_reference.y = 0;
108 return m_dim.Contains( point );
166 return m_dim.GetPosition();
172 return m_dim.GetSize();
237 dc.GetTextExtent( label, &tmpX, &tmpY );
238 textX = ( textX > tmpX + baseWidth ) ? textX : tmpX + baseWidth +
mpLEGEND_MARGIN;
250 m_dim.height = textY;
261 dc.GetTextExtent( label, &tmpX, &tmpY );
306 if(
m_pen.GetWidth() <= 1 )
308 for( wxCoord i = startPx; i < endPx; ++i )
313 if( (iy >= minYpx) && (iy <= maxYpx) )
314 dc.DrawPoint( i, iy );
319 for( wxCoord i = startPx; i < endPx; ++i )
324 if( iy >= minYpx && iy <= maxYpx )
325 dc.DrawLine( i, iy, i, iy );
334 dc.GetTextExtent(
m_name, &tx, &ty );
372 if(
m_pen.GetWidth() <= 1 )
374 for( i = minYpx; i < maxYpx; ++i )
378 if( (ix >= startPx) && (ix <= endPx) )
379 dc.DrawPoint( ix, i );
384 for( i = 0; i< w.
GetScrY(); ++i )
388 if( (ix >= startPx) && (ix <= endPx) )
389 dc.DrawLine( ix, i, ix, i );
398 dc.GetTextExtent(
m_name, &tx, &ty );
424 maxDrawX = minDrawX = maxDrawY = minDrawY = 0;
446 wxCHECK_RET(
m_scaleX, wxS(
"X scale was not set" ) );
447 wxCHECK_RET(
m_scaleY, wxS(
"Y scale was not set" ) );
458 if( endPx <= startPx || minYpx >= maxYpx )
474 dc.SetClippingRegion( startPx, minYpx, endPx - startPx + 1, maxYpx - minYpx + 1 );
480 std::set<wxCoord> ys;
486 wxCoord newX = w.
x2p( px );
497 ys.insert( w.
y2p( py ) );
503 if( (ix >= startPx) && (ix <= endPx) && (iy >= minYpx) && (iy <= maxYpx) )
507 if(
m_pen.GetWidth() <= 1 )
508 dc.DrawPoint( ix, iy );
510 dc.DrawLine( ix, iy, ix, iy );
518 ys.insert( w.
y2p( py ) );
531 std::vector<wxPoint>pointList;
532 pointList.reserve( ( endPx - startPx ) * 2 );
536 bool hasNext =
GetNextXY( nextX, nextY );
537 bool offRight =
false;
554 wxCoord x1 = w.
x2p( px );
555 wxCoord y1 = w.
y2p( py );
565 if( nextX1 < startPx-1 )
568 else if( x1 > endPx )
576 if( !count || line_start.x != x1 )
582 if( count && dupx0 > 1 && abs( ymax0 - ymin0 ) > 2 )
583 dc.DrawLine( x0, ymin0, x0, ymax0 );
589 pointList.emplace_back( wxPoint( x1, y1 ) );
597 ymin0 = std::min( ymin0, y1 );
598 ymax0 = std::max( ymax0, y1 );
604 if( pointList.size() > 1 )
611 std::vector<wxPoint> drawPoints;
612 drawPoints.reserve( ( endPx - startPx ) * 2 );
615 int chunkSize = 10000;
617 int chunkSize = 100000;
619 if( dc.GetPen().GetStyle() == wxPENSTYLE_DOT )
622 drawPoints.push_back( pointList[0] );
624 for(
size_t ii = 1; ii < pointList.size()-1; ii++ )
628 if( drawPoints.back().y == pointList[ii].y &&
629 drawPoints.back().y == pointList[ii+1].y )
635 drawPoints.push_back( pointList[ii] );
637 if( (
int) drawPoints.size() > chunkSize )
639 dc.DrawLines( (
int) drawPoints.size(), &drawPoints[0] );
643 drawPoints.push_back( pointList[ii] );
649 if( drawPoints.back() != pointList.back() )
650 drawPoints.push_back( pointList.back() );
652 dc.DrawLines( (
int) drawPoints.size(), &drawPoints[0] );
661 dc.GetTextExtent(
m_name, &tx, &ty );
685 dc.DrawText(
m_name, tx, ty );
688 dc.DestroyClippingRegion();
696#define mpLN10 2.3025850929940456840179914546844
700 double minV, maxV, minVvis, maxVvis;
710 double minErr = 1000000000000.0;
711 double bestStep = 1.0;
714 for(
int i = 10; i <= 20; i += 2 )
716 double curr_step = fabs( maxVvis - minVvis ) / (double) i;
717 double base = pow( 10, floor( log10( curr_step ) ) );
718 double stepInt = floor( curr_step / base ) * base;
719 double err = fabs( curr_step - stepInt );
728 double numberSteps = floor( ( maxVvis - minVvis ) / bestStep );
733 while( numberSteps - 2.0 >= m_scrX/96.0 )
736 numberSteps = floor( ( maxVvis - minVvis ) / bestStep );
739 double v = floor( minVvis / bestStep ) * bestStep;
740 double zeroOffset = 100000000.0;
746 if( fabs( v ) < zeroOffset )
747 zeroOffset = fabs( v );
752 if( zeroOffset <= bestStep )
794 const wxString s = tickLabel.label;
796 dc.GetTextExtent( s, &tx, &ty );
815 double pymin = w.
p2y( minYpx );
816 double pymax = w.
p2y( maxYpx );
838 double y_slave0 = p0 /
m_scale;
839 double y_slave1 = p1 /
m_scale;
841 double dy_slave = (y_slave1 - y_slave0);
842 double exponent = floor( log10( dy_slave ) );
843 double base = dy_slave / pow( 10.0, exponent );
845 double dy_scaled = ceil( 2.0 * base ) / 2.0 * pow( 10.0, exponent );
851 minvv = floor( minvv / dy_scaled ) * dy_scaled;
854 m_scale *= dy_slave / dy_scaled;
874 double minVvis, maxVvis;
899 double minErr = 1000000000000.0;
900 double bestStep = 1.0;
903 for(
int i = 10; i <= 20; i += 2 )
905 double curr_step = fabs( maxVvis - minVvis ) / (double) i;
906 double base = pow( 10, floor( log10( curr_step ) ) );
907 double stepInt = floor( curr_step / base ) * base;
908 double err = fabs( curr_step - stepInt );
917 double numberSteps = floor( ( maxVvis - minVvis ) / bestStep );
921 while( numberSteps >= m_scrY/32.0 )
924 numberSteps = floor( ( maxVvis - minVvis ) / bestStep );
927 double v = floor( minVvis / bestStep ) * bestStep;
928 double zeroOffset = 100000000.0;
929 const int iterLimit = 1000;
932 while( v <= maxVvis && i < iterLimit )
936 if( fabs( v ) < zeroOffset )
937 zeroOffset = fabs( v );
947 if( zeroOffset <= bestStep )
964 double pxmin = w.
p2x( startPx );
965 double pxmax = w.
p2x( endPx );
974 double minV, maxV, minVvis, maxVvis;
980 double minDecade = pow( 10, floor( log10( minV ) ) );
981 double maxDecade = pow( 10, ceil( log10( maxV ) ) );
982 double visibleDecades = log( maxVvis / minVvis ) / log( 10 );
991 if( minDecade == 0.0 )
997 while( visibleDecades - 2 >= m_scrX / 96.0 )
1000 visibleDecades = log( maxVvis / minVvis ) / log( step );
1003 for( d = minDecade; d<=maxDecade; d *= step )
1007 for(
double dd = d; dd < d * step; dd += d )
1009 if( visibleDecades < 2 )
1027 SetFont( (wxFont&) *wxSMALL_FONT );
1028 SetPen( (wxPen&) *wxGREY_PEN );
1062 const int extend = w.
GetScrX();
1093 if( p >= startPx && p <= endPx )
1098 dc.DrawLine( p, orgy, p, orgy - 4 );
1100 dc.DrawLine( p, orgy, p, orgy + 4 );
1104 m_pen.SetStyle( wxPENSTYLE_DOT );
1109 m_pen.SetStyle( wxPENSTYLE_DOT );
1111 dc.DrawLine( p, orgy + 4, p, minYpx );
1112 m_pen.SetStyle( wxPENSTYLE_SOLID );
1114 dc.DrawLine( p, orgy + 4, p, orgy - 4 );
1119 dc.DrawLine( p, orgy - 4, p, maxYpx );
1121 dc.DrawLine( p, minYpx, p, maxYpx );
1124 m_pen.SetStyle( wxPENSTYLE_SOLID );
1130 m_pen.SetStyle( wxPENSTYLE_SOLID );
1132 dc.DrawLine( startPx, minYpx, endPx, minYpx );
1133 dc.DrawLine( startPx, maxYpx, endPx, maxYpx );
1139 if( !tickLabel.visible )
1145 if( (p >= startPx) && (p <= endPx) )
1148 wxString s = tickLabel.label;
1150 dc.GetTextExtent( s, &tx, &ty );
1153 dc.DrawText( s, p - tx / 2, orgy - 4 - ty );
1155 dc.DrawText( s, p - tx / 2, orgy + 4 );
1160 dc.GetTextExtent(
m_name, &tx, &ty );
1165 dc.DrawText(
m_name, extend - tx - 4, orgy - 8 - ty - labelH );
1169 dc.DrawText(
m_name, (endPx + startPx) / 2 - tx / 2, orgy + 6 + labelH );
1173 dc.DrawText(
m_name, extend - tx - 4, orgy - 4 - ty );
1178 dc.DrawText(
m_name, (endPx - startPx - tx) >> 1, orgy - 6 - ty - labelH );
1180 dc.DrawText(
m_name, extend - tx - 4, orgy + 4 );
1185 dc.DrawText(
m_name, extend - tx - 4, orgy + 6 + labelH );
1200 SetFont( (wxFont&) *wxSMALL_FONT );
1201 SetPen( (wxPen&) *wxGREY_PEN );
1205 m_masterScale =
nullptr;
1246 dc.DrawLine( orgx, minYpx, orgx, maxYpx );
1254 int labelHeight = 0;
1256 dc.GetTextExtent( s, &tx, &labelHeight );
1263 if( p >= minYpx && p <= maxYpx )
1268 dc.DrawLine( orgx, p, orgx + 4, p );
1270 dc.DrawLine( orgx - 4, p, orgx, p );
1274 dc.DrawLine( orgx - 4, p, orgx + 4, p );
1276 m_pen.SetStyle( wxPENSTYLE_DOT );
1279 dc.DrawLine( orgx - 4, p, endPx, p );
1281 m_pen.SetStyle( wxPENSTYLE_SOLID );
1294 if( !tickLabel.visible )
1297 if( p >= minYpx && p <= maxYpx )
1299 s = tickLabel.label;
1300 dc.GetTextExtent( s, &tx, &ty );
1303 dc.DrawText( s, orgx + 4, p - ty / 2 );
1305 dc.DrawText( s, orgx - 4 - tx, p - ty / 2 );
1311 dc.GetTextExtent(
m_name, &tx, &ty );
1316 dc.DrawText(
m_name, labelW + 8, 4 );
1320 dc.DrawText(
m_name, orgx - ( tx / 2 ), minYpx - ty - 4 );
1324 dc.DrawText(
m_name, orgx + 4, 4 );
1329 dc.DrawText(
m_name, orgx - ( tx / 2 ), minYpx - ty - 4 );
1333 dc.DrawText(
m_name, orgx - 6 - tx - labelW, 4 );
1347IMPLEMENT_DYNAMIC_CLASS(
mpWindow, wxWindow )
1349BEGIN_EVENT_TABLE(
mpWindow, wxWindow )
1384 m_desiredXmin( 0.0 ),
1385 m_desiredXmax( 1.0 ),
1386 m_desiredYmin( 0.0 ),
1387 m_desiredYmax( 1.0 ),
1390 m_marginBottom( 0 ),
1394 m_buff_bmp(
nullptr ),
1395 m_enableDoubleBuffer( false ),
1396 m_enableMouseNavigation( true ),
1397 m_enableMouseWheelPan( false ),
1398 m_enableLimitedView( false ),
1399 m_movingInfoLayer(
nullptr ),
1402 if( wxGraphicsContext *ctx = m_buff_dc.GetGraphicsContext() )
1404 if( !ctx->SetInterpolationQuality( wxINTERPOLATION_BEST )
1405 || !ctx->SetInterpolationQuality( wxINTERPOLATION_GOOD ) )
1407 ctx->SetInterpolationQuality( wxINTERPOLATION_FAST );
1410 ctx->SetAntialiasMode( wxANTIALIAS_DEFAULT );
1415 wxWindow( parent, id, wxDefaultPosition, wxDefaultSize, 0, wxT(
"mathplot" ) ),
1429 m_desiredXmin( 0.0 ),
1430 m_desiredXmax( 1.0 ),
1431 m_desiredYmin( 0.0 ),
1432 m_desiredYmax( 1.0 ),
1435 m_marginBottom( 0 ),
1439 m_buff_bmp( nullptr ),
1440 m_enableDoubleBuffer( false ),
1441 m_enableMouseNavigation( true ),
1442 m_enableMouseWheelPan( false ),
1443 m_enableLimitedView( false ),
1444 m_movingInfoLayer( nullptr ),
1453 m_popmenu.Append(
mpID_FIT,
_(
"Fit on Screen" ),
_(
"Set plot view to show all items" ) );
1456 SetBackgroundColour( *wxWHITE );
1460 SetSizeHints( 128, 128 );
1463 SetBackgroundStyle( wxBG_STYLE_CUSTOM );
1465 if( wxGraphicsContext* ctx =
m_buff_dc.GetGraphicsContext() )
1467 if( !ctx->SetInterpolationQuality( wxINTERPOLATION_BEST )
1468 || !ctx->SetInterpolationQuality( wxINTERPOLATION_GOOD ) )
1470 ctx->SetInterpolationQuality( wxINTERPOLATION_FAST );
1473 ctx->SetAntialiasMode( wxANTIALIAS_DEFAULT );
1507 float zoom =
event.GetMagnification() + 1.0f;
1508 wxPoint pos( event.GetX(), event.GetY() );
1512 else if(
zoom < 1.0f )
1527 int change =
event.GetWheelRotation();
1528 const int axis =
event.GetWheelAxis();
1529 double changeUnitsX = change /
m_scaleX;
1530 double changeUnitsY = change /
m_scaleY;
1538 if( axis == wxMOUSE_WHEEL_HORIZONTAL || event.ShiftDown() )
1551 if( event.ControlDown() )
1568 wxPoint clickPt( event.GetX(), event.GetY() );
1570 if( event.GetWheelRotation() > 0 )
1590 wxCursor
cursor = wxCURSOR_MAGNIFIER;
1592 if( event.m_middleDown )
1619 else if( event.m_leftDown )
1624 cursor = wxCURSOR_SIZING;
1626 cursor = wxCURSOR_SIZEWE;
1634 cursor = wxCURSOR_MAGNIFIER;
1636 wxClientDC dc(
this );
1639 dc.SetBrush( *wxTRANSPARENT_BRUSH );
1655 if( layer->IsInfo() && layer->IsVisible() )
1659 if( infoLayer->
Inside( event.GetPosition() ) )
1662 cursor = wxCURSOR_SIZING;
1664 cursor = wxCURSOR_SIZEWE;
1681 wxPoint pointClicked =
event.GetPosition();
1690 wxPoint release( event.GetX(), event.GetY() );
1702 if( release != press )
1719 const wxCoord* printSizeX,
const wxCoord* printSizeY )
1726 double xExtra = fabs( xMax - xMin ) * 0.00;
1727 double yExtra = fabs( yMax - yMin ) * 0.03;
1734 if( printSizeX !=
nullptr && printSizeY !=
nullptr )
1746 double Ax = xMax - xMin;
1747 double Ay = yMax - yMin;
1763 if( printSizeX ==
nullptr || printSizeY ==
nullptr )
1846 wxPoint c( centerPoint );
1848 if( c == wxDefaultPosition )
1863 double prior_layer_x =
p2x( c.x );
1864 double prior_layer_y =
p2y( c.y );
1868 double newScaleX =
m_scaleX * zoomFactor;
1869 double newScaleY =
m_scaleY * zoomFactor;
1909 wxPoint c( centerPoint );
1911 if( c == wxDefaultPosition )
1919 double prior_layer_x =
p2x( c.x );
1920 double prior_layer_y =
p2y( c.y );
1956 double p0x =
p2x( p0.x );
1957 double p0y =
p2y( p0.y );
1958 double p1x =
p2x( p1.x );
1959 double p1y =
p2y( p1.y );
1962 double zoom_x_min = p0x<p1x ? p0x : p1x;
1963 double zoom_x_max = p0x>p1x ? p0x : p1x;
1964 double zoom_y_min = p0y<p1y ? p0y : p1y;
1965 double zoom_y_max = p0y>p1y ? p0y : p1y;
1973 Fit( zoom_x_min, zoom_x_max, zoom_y_min, zoom_y_max );
2025 PopupMenu( &
m_popmenu, event.GetX(), event.GetY() );
2083 if( refreshDisplay )
2095 wxLayerList::iterator layIt;
2099 if( *layIt == layer )
2102 if( alsoDeleteObject )
2107 if( refreshDisplay )
2123 if( alsoDeleteObject )
2129 if( refreshDisplay )
2136 wxPaintDC paintDC(
this );
2141 wxDC* targetDC = &paintDC;
2158 if( wxGraphicsContext* ctx = targetDC->GetGraphicsContext() )
2160 if( !ctx->SetInterpolationQuality( wxINTERPOLATION_BEST ) )
2161 if( !ctx->SetInterpolationQuality( wxINTERPOLATION_GOOD ) )
2162 ctx->SetInterpolationQuality( wxINTERPOLATION_FAST );
2164 ctx->SetAntialiasMode( wxANTIALIAS_DEFAULT );
2168 targetDC->SetPen( *wxTRANSPARENT_PEN );
2169 wxBrush brush( GetBackgroundColour() );
2170 targetDC->SetBrush( brush );
2176 layer->Plot( *targetDC, *
this );
2181 targetDC->SetPen( pen );
2182 targetDC->SetBrush( *wxTRANSPARENT_BRUSH );
2223 if( ( position >= (
int)
m_layers.size() ) || position < 0 )
2234 if( !layer->GetName().Cmp(
name ) )
2256 if( imageSize == wxDefaultSize )
2263 sizeX = imageSize.x;
2264 sizeY = imageSize.y;
2268 wxBitmap screenBuffer( sizeX, sizeY );
2269 wxMemoryDC screenDC;
2270 screenDC.SelectObject( screenBuffer );
2271 screenDC.SetPen( *wxWHITE_PEN );
2273 wxBrush brush( GetBackgroundColour() );
2274 screenDC.SetBrush( brush );
2275 screenDC.DrawRectangle( 0, 0, sizeX, sizeY );
2284 layer->Plot( screenDC, *
this );
2286 if( imageSize != wxDefaultSize )
2291 SetScr( bk_scrX, bk_scrY );
2297 wxImage screenImage = screenBuffer.ConvertToImage();
2298 return screenImage.SaveFile( filename, type );
2315 if( layer->IsInfo() )
2319 if( tmpLyr->
Inside( point ) )
2332 lx->SetVisible( viewable );
2341 return lx->IsVisible();
2351 lx->SetVisible( viewable );
2360 return lx->IsVisible();
2367 const wxColour& axesColour )
2369 SetBackgroundColour( bgColour );
2370 SetForegroundColour( drawColour );
2380 wxPen axisPen = layer->GetPen();
2381 axisPen.SetColour( axesColour );
2382 layer->SetPen( axisPen );
2387 wxPen infoPen = layer->GetPen();
2388 infoPen.SetColour( drawColour );
2389 layer->SetPen( infoPen );
2440 double xlogmin = log10(
m_minV );
2441 double xlogmax = log10(
m_maxV );
2443 return ( log10( x ) - xlogmin) / (xlogmax - xlogmin);
2449 double xlogmin = log10(
m_minV );
2450 double xlogmax = log10(
m_maxV );
2452 return pow( 10.0, xplot * (xlogmax - xlogmin) + xlogmin );
2493 if( xs.size() != ys.size() )
2508 for(
const double x : xs )
2517 for(
const double y : ys )
A class providing graphs functionality for a 2D plot (either continuous or a set of points),...
bool GetNextXY(double &x, double &y) override
Get locus value for next N.
std::vector< double > m_ys
double m_minX
Loaded at SetData.
std::vector< double > m_xs
The internal copy of the set of data to draw.
virtual void SetData(const std::vector< double > &xs, const std::vector< double > &ys)
Changes the internal data: the set of points to draw.
void Clear()
Clears all the data, leaving the layer empty.
void Rewind() override
Rewind value enumeration with mpFXY::GetNextXY.
size_t GetCount() const override
size_t m_index
The internal counter for the "GetNextXY" interface.
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,...
double s2y(double plotCoordY) const
virtual void SetScale(mpScaleBase *scaleX, mpScaleBase *scaleY)
virtual void Rewind()=0
Rewind value enumeration with mpFXY::GetNextXY.
virtual size_t GetCount() const =0
virtual void Plot(wxDC &dc, mpWindow &w) override
Layer plot handler.
double y2s(double y) const
void UpdateViewBoundary(wxCoord xnew, wxCoord ynew)
Update label positioning data.
double x2s(double x) const
double s2x(double plotCoordX) const
virtual bool GetNextXY(double &x, double &y)=0
Get locus value for next N.
Abstract base class providing plot and labeling functionality for functions F:X->Y.
virtual double GetY(double x) const =0
Get function value for argument.
virtual void Plot(wxDC &dc, mpWindow &w) override
Layer plot handler.
Abstract base class providing plot and labeling functionality for functions F:Y->X.
virtual double GetX(double y) const =0
Get function value for argument.
virtual void Plot(wxDC &dc, mpWindow &w) override
Layer plot handler.
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
virtual ~mpInfoLayer()
Destructor.
mpInfoLayer()
Default constructor.
wxPoint GetPosition() const
Returns the position of the upper left corner of the box (in pixels)
virtual void Plot(wxDC &dc, mpWindow &w) override
Plot method.
virtual void UpdateReference()
Updates the rectangle reference point.
virtual bool Inside(const wxPoint &point) const
Checks whether a point is inside the info box rectangle.
virtual void Move(wxPoint delta)
Moves the layer rectangle of given pixel deltas.
wxSize GetSize() const
Returns the size of the box (in pixels)
Implements the legend to be added to the plot This layer allows you to add a legend to describe the p...
mpInfoLegend()
Default constructor.
virtual void Plot(wxDC &dc, mpWindow &w) override
Plot method.
~mpInfoLegend()
Default destructor.
const wxString & GetDisplayName() const
mpLayerType GetLayerType() const
Get layer type: a Layer can be of different types: plot lines, axis, info boxes, etc,...
bool IsVisible() const
Checks whether the layer is visible or not.
virtual double GetMinY() const
Get inclusive bottom border of bounding box.
const wxPen & GetPen() const
Get pen set for this layer.
virtual double GetMaxX() const
Get inclusive right border of bounding box.
virtual double GetMinX() const
Get inclusive left border of bounding box.
virtual double GetMaxY() const
Get inclusive top border of bounding box.
Plot layer implementing a x-scale ruler.
virtual void recalculateTicks(wxDC &dc, mpWindow &w)
void GetDataRange(double &minV, double &maxV) const
std::vector< double > m_tickValues
virtual double TransformToPlot(double x) const
virtual void formatLabels()
void computeLabelExtents(wxDC &dc, mpWindow &w)
virtual void ExtendDataRange(double minV, double maxV)
std::vector< TICK_LABEL > m_tickLabels
void updateTickLabels(wxDC &dc, mpWindow &w)
virtual double TransformFromPlot(double xplot) const
virtual void getVisibleDataRange(mpWindow &w, double &minV, double &maxV) override
virtual void Plot(wxDC &dc, mpWindow &w) override
Plot given view of layer to the given device context.
mpScaleXLog(const wxString &name=wxT("log(X)"), int flags=mpALIGN_CENTER, bool ticks=true, unsigned int type=mpX_NORMAL)
Full constructor.
virtual double TransformFromPlot(double xplot) const override
virtual double TransformToPlot(double x) const override
void recalculateTicks(wxDC &dc, mpWindow &w) override
virtual double TransformToPlot(double x) const override
virtual double TransformFromPlot(double xplot) const override
virtual void recalculateTicks(wxDC &dc, mpWindow &w) override
mpScaleX(const wxString &name=wxT("X"), int flags=mpALIGN_CENTER, bool ticks=true, unsigned int type=mpX_NORMAL)
Full constructor.
Plot layer implementing a y-scale ruler.
virtual void getVisibleDataRange(mpWindow &w, double &minV, double &maxV) override
virtual double TransformFromPlot(double xplot) const override
void computeSlaveTicks(mpWindow &w)
virtual void Plot(wxDC &dc, mpWindow &w) override
Layer plot handler.
virtual void recalculateTicks(wxDC &dc, mpWindow &w) override
virtual double TransformToPlot(double x) const override
Canvas for plotting mpLayer implementations.
mpInfoLayer * m_movingInfoLayer
void DelAllLayers(bool alsoDeleteObject, bool refreshDisplay=true)
Remove all layers from the plot.
void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour)
Set Color theme.
virtual bool SetYView(double pos, double desiredMax, double desiredMin)
Applies new Y view coordinates depending on the settings.
void ZoomRect(wxPoint p0, wxPoint p1)
Zoom view fitting given coordinates to the window (p0 and p1 do not need to be in any specific order)
void onMouseLeftRelease(wxMouseEvent &event)
int GetMarginLeft() const
bool m_enableMouseNavigation
void OnPaint(wxPaintEvent &event)
void OnShowPopupMenu(wxMouseEvent &event)
void onMouseLeftDown(wxMouseEvent &event)
void onMouseWheel(wxMouseEvent &event)
void SetMargins(int top, int right, int bottom, int left)
Set window margins, creating a blank area where some kinds of layers cannot draw.
bool m_enableMouseWheelPan
int GetScrX() const
Get current view's X dimension in device context units.
int GetScrY() const
Get current view's Y dimension in device context units.
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
wxCoord x2p(double x)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
mpInfoLayer * IsInsideInfoLayer(wxPoint &point)
Check if a given point is inside the area of a mpInfoLayer and eventually returns its pointer.
void OnMouseMiddleDown(wxMouseEvent &event)
std::stack< std::array< double, 4 > > m_redoZoomStack
void SetLayerVisible(const wxString &name, bool viewable)
Sets the visibility of a layer by its name.
mpLayer * GetLayer(int position) const
void onZoomRedo(wxCommandEvent &event)
bool SaveScreenshot(const wxString &filename, wxBitmapType type=wxBITMAP_TYPE_BMP, wxSize imageSize=wxDefaultSize, bool fit=false)
Draw the window on a wxBitmap, then save it to a file.
void ZoomIn(const wxPoint ¢erPoint=wxDefaultPosition)
Zoom into current view and refresh display.
void ZoomOut(const wxPoint ¢erPoint=wxDefaultPosition)
Zoom out current view and refresh display.
virtual bool UpdateBBox()
Recalculate global layer bounding box, and save it in m_minX,...
bool CheckYLimits(double &desiredMax, double &desiredMin) const
bool DelLayer(mpLayer *layer, bool alsoDeleteObject=false, bool refreshDisplay=true)
Remove a plot layer from the canvas.
void UpdateAll()
Refresh display.
wxCoord y2p(double y)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
void OnCenter(wxCommandEvent &event)
virtual bool SetXView(double pos, double desiredMax, double desiredMin)
Applies new X view coordinates depending on the settings.
void SetScaleX(double scaleX)
Set current view's X scale and refresh display.
bool CheckXLimits(double &desiredMax, double &desiredMin) const
void onMagnify(wxMouseEvent &event)
void onZoomOut(wxCommandEvent &event)
void pushZoomUndo(const std::array< double, 4 > &aZoom)
std::stack< std::array< double, 4 > > m_undoZoomStack
int GetMarginRight() const
void GetBoundingBox(double *bbox) const
Returns the bounding box coordinates.
void SetScr(int scrX, int scrY)
Set current view's dimensions in device context units.
int GetMarginBottom() const
static double zoomIncrementalFactor
This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse...
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
bool m_enableDoubleBuffer
void OnFit(wxCommandEvent &event)
void OnSize(wxSizeEvent &event)
const mpLayer * GetLayerByName(const wxString &name) const
unsigned int CountAllLayers() const
Counts the number of plot layers, whether or not they have a bounding box.
void SetPos(double posX, double posY)
Set current view's X and Y position and refresh display.
void onZoomIn(wxCommandEvent &event)
double GetScaleY() const
Get current view's Y scale.
double GetScaleX() const
Get current view's X scale.
bool AddLayer(mpLayer *layer, bool refreshDisplay=true)
Add a plot layer to the canvas.
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
void onZoomUndo(wxCommandEvent &event)
double GetPosY() const
Get current view's Y position.
void onMouseMove(wxMouseEvent &event)
double GetPosX() const
Get current view's X position.
bool IsLayerVisible(const wxString &name) const
Check whether a layer with given name is visible.
#define mpLEGEND_LINEWIDTH
#define mpALIGN_BORDER_RIGHT
Aligns Y axis to right border.
#define mpALIGN_RIGHT
Aligns label to the right.
#define mpALIGN_NW
Aligns label to north-west.
#define mpALIGN_FAR_RIGHT
Aligns label to the right of mpALIGN_RIGHT.
#define mpALIGN_BORDER_TOP
Aligns X axis to top border.
#define mpALIGN_CENTER
Aligns label to the center.
#define mpALIGN_LEFT
Aligns label to the left.
#define mpALIGN_TOP
Aligns label to the top.
#define mpALIGN_BORDER_LEFT
Aligns Y axis to left border.
#define mpALIGN_SE
Aligns label to south-east.
#define mpALIGN_NE
Aligns label to north-east.
#define mpALIGN_BOTTOM
Aligns label to the bottom.
#define mpALIGN_BORDER_BOTTOM
Aligns X axis to bottom border.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...