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 );
108 return m_dim.Contains( point );
172 return m_dim.GetPosition();
178 return m_dim.GetSize();
243 dc.GetTextExtent( label, &tmpX, &tmpY );
244 textX = ( textX > tmpX + baseWidth ) ? textX : tmpX + baseWidth +
mpLEGEND_MARGIN;
256 m_dim.height = textY;
267 dc.GetTextExtent( label, &tmpX, &tmpY );
312 if(
m_pen.GetWidth() <= 1 )
314 for( wxCoord i = startPx; i < endPx; ++i )
320 if( ( iy >= minYpx ) && ( iy <= maxYpx ) )
321 dc.DrawPoint( i, iy );
326 for( wxCoord i = startPx; i < endPx; ++i )
332 if( iy >= minYpx && iy <= maxYpx )
333 dc.DrawLine( i, iy, i, iy );
342 dc.GetTextExtent(
m_name, &tx, &ty );
382 if(
m_pen.GetWidth() <= 1 )
384 for( i = minYpx; i < maxYpx; ++i )
388 if( ( ix >= startPx ) && ( ix <= endPx ) )
389 dc.DrawPoint( ix, i );
394 for( i = 0; i< w.
GetScrY(); ++i )
398 if( ( ix >= startPx ) && ( ix <= endPx ) )
399 dc.DrawLine( ix, i, ix, i );
408 dc.GetTextExtent(
m_name, &tx, &ty );
458 wxCHECK_RET(
m_scaleX, wxS(
"X scale was not set" ) );
459 wxCHECK_RET(
m_scaleY, wxS(
"Y scale was not set" ) );
470 if( endPx <= startPx || minYpx >= maxYpx )
486 dc.SetClippingRegion( startPx, minYpx, endPx - startPx + 1, maxYpx - minYpx + 1 );
492 std::set<wxCoord> ys;
496 double px =
m_scaleX->TransformToPlot( x );
497 double py =
m_scaleY->TransformToPlot( y );
498 wxCoord newX = w.
x2p( px );
509 ys.insert( w.
y2p( py ) );
515 if( ( ix >= startPx ) && ( ix <= endPx ) && ( iy >= minYpx ) && ( iy <= maxYpx ) )
519 if(
m_pen.GetWidth() <= 1 )
520 dc.DrawPoint( ix, iy );
522 dc.DrawLine( ix, iy, ix, iy );
530 ys.insert( w.
y2p( py ) );
545 std::vector<wxPoint>pointList;
546 pointList.reserve( ( endPx - startPx ) * 2 );
550 bool hasNext =
GetNextXY( nextX, nextY );
551 bool offRight =
false;
565 double px =
m_scaleX->TransformToPlot( x );
566 double py =
m_scaleY->TransformToPlot( y );
568 wxCoord x1 = w.
x2p( px );
569 wxCoord y1 = w.
y2p( py );
577 wxCoord nextX1 = w.
x2p(
m_scaleX->TransformToPlot( nextX ) );
579 if( nextX1 < startPx-1 )
582 else if( x1 > endPx )
590 if( !count || line_start.x != x1 )
596 if( count && dupx0 > 1 && abs( ymax0 - ymin0 ) > 2 )
597 dc.DrawLine( x0, ymin0, x0, ymax0 );
603 pointList.emplace_back( wxPoint( x1, y1 ) );
611 ymin0 = std::min( ymin0, y1 );
612 ymax0 = std::max( ymax0, y1 );
618 if( pointList.size() > 1 )
625 std::vector<wxPoint> drawPoints;
626 drawPoints.reserve( ( endPx - startPx ) * 2 );
629 int chunkSize = 10000;
631 int chunkSize = 100000;
633 wxPenStyle penStyle = dc.GetPen().GetStyle();
634 bool isSolidPen = ( penStyle == wxPENSTYLE_SOLID
635 || penStyle == wxPENSTYLE_TRANSPARENT );
640 drawPoints.push_back( pointList[0] );
642 for(
size_t ii = 1; ii < pointList.size()-1; ii++ )
648 && drawPoints.back().y == pointList[ii].y
649 && drawPoints.back().y == pointList[ii+1].y )
655 drawPoints.push_back( pointList[ii] );
657 if( (
int) drawPoints.size() > chunkSize )
659 dc.DrawLines( (
int) drawPoints.size(), &drawPoints[0] );
663 drawPoints.push_back( pointList[ii] );
669 if( drawPoints.back() != pointList.back() )
670 drawPoints.push_back( pointList.back() );
672 dc.DrawLines( (
int) drawPoints.size(), &drawPoints[0] );
681 dc.GetTextExtent(
m_name, &tx, &ty );
705 dc.DrawText(
m_name, tx, ty );
708 dc.DestroyClippingRegion();
716#define mpLN10 2.3025850929940456840179914546844
720 double minV, maxV, minVvis, maxVvis;
730 double minErr = 1000000000000.0;
731 double bestStep = 1.0;
734 for(
int i = 10; i <= 20; i += 2 )
736 double curr_step = fabs( maxVvis - minVvis ) / (double) i;
737 double base = pow( 10, floor( log10( curr_step ) ) );
738 double stepInt = floor( curr_step / base ) * base;
739 double err = fabs( curr_step - stepInt );
748 double numberSteps = floor( ( maxVvis - minVvis ) / bestStep );
753 while( numberSteps - 2.0 >= m_scrX/96.0 )
756 numberSteps = floor( ( maxVvis - minVvis ) / bestStep );
759 double v = floor( minVvis / bestStep ) * bestStep;
760 double zeroOffset = 100000000.0;
766 if( fabs( v ) < zeroOffset )
767 zeroOffset = fabs( v );
772 if( zeroOffset <= bestStep )
814 const wxString s = tickLabel.label;
816 dc.GetTextExtent( s, &tx, &ty );
835 double pymin = w.
p2y( minYpx );
836 double pymax = w.
p2y( maxYpx );
858 double y_slave0 = p0 /
m_scale;
859 double y_slave1 = p1 /
m_scale;
861 double dy_slave = ( y_slave1 - y_slave0 );
862 double exponent = floor( log10( dy_slave ) );
863 double base = dy_slave / pow( 10.0, exponent );
865 double dy_scaled = ceil( 2.0 * base ) / 2.0 * pow( 10.0, exponent );
871 minvv = floor( minvv / dy_scaled ) * dy_scaled;
874 m_scale *= dy_slave / dy_scaled;
894 double minVvis, maxVvis;
919 double minErr = 1000000000000.0;
920 double bestStep = 1.0;
923 for(
int i = 10; i <= 20; i += 2 )
925 double curr_step = fabs( maxVvis - minVvis ) / (double) i;
926 double base = pow( 10, floor( log10( curr_step ) ) );
927 double stepInt = floor( curr_step / base ) * base;
928 double err = fabs( curr_step - stepInt );
937 double numberSteps = floor( ( maxVvis - minVvis ) / bestStep );
941 while( numberSteps >= m_scrY / 32.0 )
944 numberSteps = floor( ( maxVvis - minVvis ) / bestStep );
947 double v = floor( minVvis / bestStep ) * bestStep;
948 double zeroOffset = 100000000.0;
949 const int iterLimit = 1000;
952 while( v <= maxVvis && i < iterLimit )
956 if( fabs( v ) < zeroOffset )
957 zeroOffset = fabs( v );
967 if( zeroOffset <= bestStep )
984 double pxmin = w.
p2x( startPx );
985 double pxmax = w.
p2x( endPx );
994 double minV, maxV, minVvis, maxVvis;
1000 double minDecade = pow( 10, floor( log10( minV ) ) );
1001 double maxDecade = pow( 10, ceil( log10( maxV ) ) );
1002 double visibleDecades = log( maxVvis / minVvis ) / log( 10 );
1011 if( minDecade == 0.0 )
1017 while( visibleDecades - 2 >= m_scrX / 96.0 )
1020 visibleDecades = log( maxVvis / minVvis ) / log( step );
1022 if( !std::isfinite( visibleDecades ) )
1026 for( d = minDecade; d<=maxDecade; d *= step )
1030 for(
double dd = d; dd < d * step; dd += d )
1032 if( visibleDecades < 2 )
1051 SetFont( (wxFont&) *wxSMALL_FONT );
1052 SetPen( (wxPen&) *wxGREY_PEN );
1086 const int extend = w.
GetScrX();
1119 if( p >= startPx && p <= endPx )
1124 dc.DrawLine( p, orgy, p, orgy - 4 );
1126 dc.DrawLine( p, orgy, p, orgy + 4 );
1130 m_pen.SetStyle( wxPENSTYLE_DOT );
1135 m_pen.SetStyle( wxPENSTYLE_DOT );
1137 dc.DrawLine( p, orgy + 4, p, minYpx );
1138 m_pen.SetStyle( wxPENSTYLE_SOLID );
1140 dc.DrawLine( p, orgy + 4, p, orgy - 4 );
1145 dc.DrawLine( p, orgy - 4, p, maxYpx );
1147 dc.DrawLine( p, minYpx, p, maxYpx );
1150 m_pen.SetStyle( wxPENSTYLE_SOLID );
1156 m_pen.SetStyle( wxPENSTYLE_SOLID );
1158 dc.DrawLine( startPx, minYpx, endPx, minYpx );
1159 dc.DrawLine( startPx, maxYpx, endPx, maxYpx );
1165 if( !tickLabel.visible )
1171 if( ( p >= startPx ) && ( p <= endPx ) )
1174 wxString s = tickLabel.label;
1176 dc.GetTextExtent( s, &tx, &ty );
1179 dc.DrawText( s, p - tx / 2, orgy - 4 - ty );
1181 dc.DrawText( s, p - tx / 2, orgy + 4 );
1186 dc.GetTextExtent(
m_name, &tx, &ty );
1191 dc.DrawText(
m_name, extend - tx - 4, orgy - 8 - ty - labelH );
1195 dc.DrawText(
m_name, ( endPx + startPx ) / 2 - tx / 2, orgy + 6 + labelH );
1199 dc.DrawText(
m_name, extend - tx - 4, orgy - 4 - ty );
1204 dc.DrawText(
m_name, ( endPx - startPx - tx ) >> 1, orgy - 6 - ty - labelH );
1206 dc.DrawText(
m_name, extend - tx - 4, orgy + 4 );
1211 dc.DrawText(
m_name, extend - tx - 4, orgy + 6 + labelH );
1227 SetFont( (wxFont&) *wxSMALL_FONT );
1228 SetPen( (wxPen&) *wxGREY_PEN );
1274 dc.DrawLine( orgx, minYpx, orgx, maxYpx );
1283 int labelHeight = 0;
1285 dc.GetTextExtent( s, &tx, &labelHeight );
1292 if( p >= minYpx && p <= maxYpx )
1297 dc.DrawLine( orgx, p, orgx + 4, p );
1299 dc.DrawLine( orgx - 4, p, orgx, p );
1303 dc.DrawLine( orgx - 4, p, orgx + 4, p );
1305 m_pen.SetStyle( wxPENSTYLE_DOT );
1308 dc.DrawLine( orgx - 4, p, endPx, p );
1310 m_pen.SetStyle( wxPENSTYLE_SOLID );
1323 if( !tickLabel.visible )
1326 if( p >= minYpx && p <= maxYpx )
1328 s = tickLabel.label;
1329 dc.GetTextExtent( s, &tx, &ty );
1333 dc.DrawText( s, orgx + 4, p - ty / 2 );
1335 dc.DrawText( s, orgx - 4 - tx, p - ty / 2 );
1340 dc.GetTextExtent(
m_name, &tx, &ty );
1345 dc.DrawText(
m_name, labelW + 8, 4 );
1349 dc.DrawText(
m_name, orgx - ( tx / 2 ), minYpx - ty - 4 );
1353 dc.DrawText(
m_name, orgx + 4, 4 );
1358 dc.DrawText(
m_name, orgx - ( tx / 2 ), minYpx - ty - 4 );
1362 dc.DrawText(
m_name, orgx - 6 - tx - labelW, 4 );
1376IMPLEMENT_DYNAMIC_CLASS(
mpWindow, wxWindow )
1378BEGIN_EVENT_TABLE(
mpWindow, wxWindow )
1411 _(
"Return zoom to level prior to last zoom action" ) );
1413 _(
"Return zoom to level prior to last zoom undo" ) );
1418 _(
"Center plot view to this position" ) );
1419 m_popmenu.Append(
mpID_FIT,
_(
"Fit on Screen" ),
_(
"Set plot view to show all items" ) );
1422 SetBackgroundColour( *wxWHITE );
1426 SetSizeHints( 128, 128 );
1429 SetBackgroundStyle( wxBG_STYLE_CUSTOM );
1464 float zoom =
event.GetMagnification() + 1.0f;
1465 wxPoint pos( event.GetX(), event.GetY() );
1469 else if(
zoom < 1.0f )
1484 const wxMouseWheelAxis axis =
event.GetWheelAxis();
1485 const int modifiers =
event.GetModifiers();
1488 if( axis == wxMOUSE_WHEEL_HORIZONTAL )
1492 else if( modifiers == wxMOD_NONE )
1496 else if( modifiers == wxMOD_CONTROL )
1500 else if( modifiers == wxMOD_SHIFT )
1504 else if( modifiers == wxMOD_ALT )
1528 wxCursor
cursor = wxCURSOR_MAGNIFIER;
1530 if( event.m_middleDown )
1557 else if( event.m_leftDown )
1562 cursor = wxCURSOR_SIZING;
1564 cursor = wxCURSOR_SIZEWE;
1572 cursor = wxCURSOR_MAGNIFIER;
1574 wxClientDC dc(
this );
1577 dc.SetBrush( *wxTRANSPARENT_BRUSH );
1593 if( layer->IsInfo() && layer->IsVisible() )
1597 if( infoLayer->
Inside( event.GetPosition() ) )
1600 cursor = wxCURSOR_SIZING;
1602 cursor = wxCURSOR_SIZEWE;
1619 wxPoint pointClicked =
event.GetPosition();
1628 wxPoint pointClicked =
event.GetPosition();
1632 if( infoLayer->OnDoubleClick( pointClicked, *
this ) )
1645 wxPoint release( event.GetX(), event.GetY() );
1657 if( release != press )
1673void mpWindow::Fit(
double xMin,
double xMax,
double yMin,
double yMax,
const wxCoord* printSizeX,
1674 const wxCoord* printSizeY, wxOrientation directions )
1676 const bool isPrinting = printSizeX !=
nullptr && printSizeY !=
nullptr;
1679 double newDesiredXmin = xMin;
1680 double newDesiredXmax = xMax;
1681 double newDesiredYmin = yMin;
1682 double newDesiredYmax = yMax;
1699 newScrX = *printSizeX;
1700 newScrY = *printSizeY;
1705 GetClientSize( &newScrX, &newScrY );
1713 double desiredSpanX = xMax - xMin;
1714 double desiredSpanY = yMax - yMin;
1715 double newScaleX = ( desiredSpanX != 0 ) ?
double( plotScreenWidth ) / desiredSpanX : 1;
1716 double newScaleY = ( desiredSpanY != 0 ) ?
double( plotScreenHeight ) / desiredSpanY : 1;
1721 double newPosY = yMax + (
m_marginTop / newScaleY );
1724 if( ( ( directions & wxHORIZONTAL ) != 0 ) || isPrinting )
1738 if( ( ( directions & wxVERTICAL ) != 0 ) || isPrinting )
1769 if( ( directions & wxHORIZONTAL ) != 0 )
1788 if( ( directions & wxVERTICAL ) != 0 )
1840void mpWindow::ZoomIn(
const wxPoint& centerPoint,
double zoomFactor, wxOrientation directions )
1842 DoZoom( centerPoint, zoomFactor, directions );
1854 if( zoomFactor == 0 )
1857 DoZoom( centerPoint, 1.0 / zoomFactor, directions );
1870 p0.x = std::max( p0.x, pMinX );
1871 p0.x = std::min( p0.x, pMaxX );
1872 p0.y = std::max( p0.y, pMinY );
1873 p0.y = std::min( p0.y, pMaxY );
1874 p1.x = std::max( p1.x, pMinX );
1875 p1.x = std::min( p1.x, pMaxX );
1876 p1.y = std::max( p1.y, pMinY );
1877 p1.y = std::min( p1.y, pMaxY );
1880 double p0x =
p2x( p0.x );
1881 double p0y =
p2y( p0.y );
1882 double p1x =
p2x( p1.x );
1883 double p1y =
p2y( p1.y );
1886 double zoom_x_min = p0x<p1x ? p0x : p1x;
1887 double zoom_x_max = p0x>p1x ? p0x : p1x;
1888 double zoom_y_min = p0y<p1y ? p0y : p1y;
1889 double zoom_y_max = p0y>p1y ? p0y : p1y;
1897 Fit( zoom_x_min, zoom_x_max, zoom_y_min, zoom_y_max );
1907 if( directionsNeedingRefitting != 0 )
1959 PopupMenu( &
m_popmenu, event.GetX(), event.GetY() );
2029 if( refreshDisplay )
2041 wxLayerList::iterator layIt;
2045 if( *layIt == layer )
2048 if( alsoDeleteObject )
2053 if( refreshDisplay )
2069 if( alsoDeleteObject )
2075 if( refreshDisplay )
2082 wxPaintDC paintDC(
this );
2087 wxDC* targetDC = &paintDC;
2104 if( wxGraphicsContext* ctx = targetDC->GetGraphicsContext() )
2106 if( !ctx->SetInterpolationQuality( wxINTERPOLATION_BEST ) )
2107 if( !ctx->SetInterpolationQuality( wxINTERPOLATION_GOOD ) )
2108 ctx->SetInterpolationQuality( wxINTERPOLATION_FAST );
2110 ctx->SetAntialiasMode( wxANTIALIAS_DEFAULT );
2114 targetDC->SetPen( *wxTRANSPARENT_PEN );
2115 wxBrush brush( GetBackgroundColour() );
2116 targetDC->SetBrush( brush );
2122 layer->Plot( *targetDC, *
this );
2127 targetDC->SetPen( pen );
2128 targetDC->SetBrush( *wxTRANSPARENT_BRUSH );
2138void mpWindow::DoZoom(
const wxPoint& centerPoint,
double zoomFactor, wxOrientation directions )
2142 if( directions == wxVERTICAL )
2145 directions = wxHORIZONTAL;
2148 const bool horizontally = ( directions & wxHORIZONTAL ) != 0;
2149 const bool vertically = ( directions & wxVERTICAL ) != 0;
2154 wxPoint c( centerPoint );
2155 if( c == wxDefaultPosition )
2171 const double newScaleX = horizontally ? (
m_scaleX * zoomFactor ) :
m_scaleX;
2172 const double newScaleY = vertically ? (
m_scaleY * zoomFactor ) :
m_scaleY;
2181 const double prior_layer_x =
p2x( c.x );
2185 m_posX = prior_layer_x - c.x / newScaleX;
2194 const double prior_layer_y =
p2y( c.y );
2198 m_posY = prior_layer_y + c.y / newScaleY;
2206 if( zoomFactor < 1.0 )
2214 if( directionsNeedingRefitting != 0 )
2225 const double plotSpanX = plotScreenWidth /
m_scaleX;
2236 const double plotSpanY = plotScreenHeight /
m_scaleY;
2247 return static_cast<wxOrientation
>( 0 );
2254 wxOrientation
result = {};
2256 if( ( directions & wxHORIZONTAL ) != 0 )
2259 result =
static_cast<wxOrientation
>(
result | wxHORIZONTAL );
2262 if( ( directions & wxVERTICAL ) != 0 )
2265 result =
static_cast<wxOrientation
>(
result | wxVERTICAL );
2274 const int change =
event.GetWheelRotation();
2275 const double changeUnitsX = change /
m_scaleX;
2276 const double changeUnitsY = change /
m_scaleY;
2277 const wxPoint clickPt( event.GetX(), event.GetY() );
2306 if( event.GetWheelRotation() > 0 )
2314 if( event.GetWheelRotation() > 0 )
2322 if( event.GetWheelRotation() > 0 )
2366 if( ( position >= (
int)
m_layers.size() ) || position < 0 )
2377 if( !layer->GetName().Cmp(
name ) )
2398 if( aImageSize == wxDefaultSize )
2405 sizeX = aImageSize.x;
2406 sizeY = aImageSize.y;
2410 wxBitmap screenBuffer( sizeX, sizeY );
2411 wxMemoryDC screenDC;
2412 screenDC.SelectObject( screenBuffer );
2413 screenDC.SetPen( *wxWHITE_PEN );
2415 wxBrush brush( GetBackgroundColour() );
2416 screenDC.SetBrush( brush );
2417 screenDC.DrawRectangle( 0, 0, sizeX, sizeY );
2426 layer->Plot( screenDC, *
this );
2428 if( aImageSize != wxDefaultSize )
2433 SetScr( bk_scrX, bk_scrY );
2439 aImage = screenBuffer.ConvertToImage();
2458 if( layer->IsInfo() )
2462 if( tmpLyr->
Inside( point ) )
2475 lx->SetVisible( viewable );
2494 lx->SetVisible( viewable );
2503 return lx->IsVisible();
2510 const wxColour& axesColour )
2512 SetBackgroundColour( bgColour );
2513 SetForegroundColour( drawColour );
2524 wxPen axisPen = layer->GetPen();
2525 axisPen.SetColour( axesColour );
2526 layer->SetPen( axisPen );
2532 wxPen infoPen = layer->GetPen();
2533 infoPen.SetColour( drawColour );
2534 layer->SetPen( infoPen );
2540template <
typename... Ts>
2542 wxWindow(
std::forward<Ts>( windowArgs )... ),
2580 if( wxGraphicsContext* ctx =
m_buff_dc.GetGraphicsContext() )
2582 if( !ctx->SetInterpolationQuality( wxINTERPOLATION_BEST )
2583 || !ctx->SetInterpolationQuality( wxINTERPOLATION_GOOD ) )
2585 ctx->SetInterpolationQuality( wxINTERPOLATION_FAST );
2588 ctx->SetAntialiasMode( wxANTIALIAS_DEFAULT );
2639 double xlogmin = log10(
m_minV );
2640 double xlogmax = log10(
m_maxV );
2642 return ( log10( x ) - xlogmin ) / ( xlogmax - xlogmin );
2648 double xlogmin = log10(
m_minV );
2649 double xlogmax = log10(
m_maxV );
2651 return pow( 10.0, xplot * ( xlogmax - xlogmin ) + xlogmin );
2694 if( xs.size() != ys.size() )
2709 for(
const double x : xs )
2718 for(
const double y : ys )
A class providing graphs functionality for a 2D plot (either continuous or a set of points),...
void SetSweepWindow(int aSweepIdx) override
bool GetNextXY(double &x, double &y) override
Get locus value for next N.
mpFXYVector(const wxString &name=wxEmptyString, int flags=mpALIGN_NE)
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.
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 void SetSweepWindow(int aSweepIdx)
virtual size_t GetCount() const =0
mpFXY(const wxString &name=wxEmptyString, int flags=mpALIGN_NE)
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
virtual int GetSweepCount() 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.
mpFX(const wxString &name=wxEmptyString, int flags=mpALIGN_RIGHT)
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.
mpFY(const wxString &name=wxEmptyString, int flags=mpALIGN_TOP)
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 bool OnDoubleClick(const wxPoint &point, mpWindow &w)
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,...
void SetFont(const wxFont &font)
Set layer font.
bool IsVisible() const
Checks whether the layer is visible or not.
virtual double GetMinY() const
Get inclusive bottom border of bounding box.
virtual void SetName(const wxString &name)
Set layer name.
const wxPen & GetPen() const
Get pen set for this layer.
void SetPen(const wxPen &pen)
Set layer pen.
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)
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.
mpScaleXBase(const wxString &name=wxT("X"), int flags=mpALIGN_CENTER, bool ticks=true, unsigned int type=mpX_NORMAL)
Full constructor.
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
mpScaleY(const wxString &name=wxT("Y"), int flags=mpALIGN_CENTER, bool ticks=true)
Canvas for plotting mpLayer implementations.
bool SaveScreenshot(wxImage &aImage, wxSize aImageSize=wxDefaultSize, bool aFit=false)
Draw the window on a wxBitmap, then save it to a file.
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 RecomputeDesiredY(double &min, double &max)
wxOrientation ViewNeedsRefitting(wxOrientation directions) const
void OnPaint(wxPaintEvent &event)
void OnShowPopupMenu(wxMouseEvent &event)
void onMouseLeftDown(wxMouseEvent &event)
void onMouseWheel(wxMouseEvent &event)
static MouseWheelActionSet defaultMouseWheelActions()
void SetMargins(int top, int right, int bottom, int left)
Set window margins, creating a blank area where some kinds of layers cannot draw.
MouseWheelActionSet m_mouseWheelActions
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,...
void initializeGraphicsContext()
void RecomputeDesiredX(double &min, double &max)
wxCoord x2p(double x)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
MouseWheelAction
Enumerates the possible mouse wheel actions that can be performed on the plot.
double m_leftRightPlotGapFactor
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.
void DoZoom(const wxPoint ¢erPoint, double zoomFactor, wxOrientation directions)
mpLayer * GetLayer(int position) const
void onZoomRedo(wxCommandEvent &event)
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 DelLayer(mpLayer *layer, bool alsoDeleteObject=false, bool refreshDisplay=true)
Remove a plot layer from the canvas.
void UpdateAll()
Refresh display.
void AdjustLimitedView(wxOrientation directions=wxBOTH)
Limits the zoomed or panned view to the area used by the plots.
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.
void onMagnify(wxMouseEvent &event)
double m_topBottomPlotGapFactor
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
void PerformMouseWheelAction(wxMouseEvent &event, MouseWheelAction action)
static double zoomIncrementalFactor
This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse...
void onMouseLeftDClick(wxMouseEvent &event)
double m_desiredXmin
These are updated in Fit, ZoomIn, ZoomOut, ZoomRect, SetXView, SetYView and may be different from the...
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...
Contains the set of modified mouse wheel actions that can be performed on the plot.
MouseWheelAction horizontal
MouseWheelAction verticalWithShift
MouseWheelAction verticalWithCtrl
MouseWheelAction verticalWithAlt
MouseWheelAction verticalUnmodified
KIBIS top(path, &reporter)
wxString result
Test unit parsing edge cases and error handling.