14#ifndef _MP_MATHPLOT_H_ 
   15#define _MP_MATHPLOT_H_ 
   58#ifdef mathplot_EXPORTS 
   59#define WXDLLIMPEXP_MATHPLOT WXEXPORT 
   60#define WXDLLIMPEXP_DATA_MATHPLOT( type ) WXEXPORT type 
   62#define WXDLLIMPEXP_MATHPLOT 
   63#define WXDLLIMPEXP_DATA_MATHPLOT( type ) type 
   69#include <wx/scrolwin.h> 
   71#include <wx/dynarray.h> 
   73#include <wx/dcmemory.h> 
   88#define DEBUG_NEW   new (_NORMAL_BLOCK, __FILE__, __LINE__) 
   95#define X_BORDER_SEPARATION 40 
   96#define Y_BORDER_SEPARATION 60 
  171    virtual bool IsInfo()
 const { 
return false; };
 
  176    virtual double GetMinX()
 const { 
return -1.0; }
 
  181    virtual double GetMaxX()
 const { 
return 1.0; }
 
  186    virtual double GetMinY()
 const { 
return -1.0; }
 
  191    virtual double GetMaxY()
 const { 
return 1.0; }
 
  317    DECLARE_DYNAMIC_CLASS( 
mpLayer )
 
 
  338    mpInfoLayer( wxRect rect, 
const wxBrush* brush = wxTRANSPARENT_BRUSH );
 
  345    virtual bool HasBBox()
 const override { 
return false; }
 
  351    virtual void Plot( wxDC& dc, 
mpWindow& w ) 
override;
 
  356    virtual bool IsInfo()
 const override { 
return true; }
 
  361    virtual bool Inside( 
const wxPoint& point ) 
const;
 
  363    virtual bool OnDoubleClick( 
const wxPoint& point, 
mpWindow& w );
 
  367    virtual void Move( wxPoint 
delta );
 
  370    virtual void UpdateReference();
 
  374    wxPoint GetPosition() 
const;
 
  378    wxSize GetSize() 
const;
 
 
  404    mpInfoLegend( wxRect rect, 
const wxBrush* brush = wxTRANSPARENT_BRUSH );
 
 
  427#define mpALIGNMASK             0x03 
  429#define mpALIGN_RIGHT           0x00 
  431#define mpALIGN_CENTER          0x01 
  433#define mpALIGN_LEFT            0x02 
  435#define mpALIGN_TOP             mpALIGN_RIGHT 
  437#define mpALIGN_BOTTOM          mpALIGN_LEFT 
  439#define mpALIGN_BORDER_BOTTOM   0x04 
  441#define mpALIGN_BORDER_TOP      0x05 
  443#define mpALIGN_FAR_RIGHT       0x06 
  445#define mpX_NORMAL              0x00 
  449#define mpX_HOURS               0x02 
  453#define mpX_DATETIME            0x04 
  455#define mpALIGN_BORDER_LEFT     mpALIGN_BORDER_BOTTOM 
  457#define mpALIGN_BORDER_RIGHT    mpALIGN_BORDER_TOP 
  459#define mpALIGN_NE              0x00 
  461#define mpALIGN_NW              0x01 
  463#define mpALIGN_SW              0x02 
  465#define mpALIGN_SE              0x03 
  490    virtual double GetY( 
double x ) 
const = 0;
 
  501    DECLARE_DYNAMIC_CLASS( 
mpFX )
 
 
  522    virtual double GetX( 
double y ) 
const = 0;
 
  533    DECLARE_DYNAMIC_CLASS( 
mpFY )
 
 
  571    virtual void Plot( wxDC& dc, 
mpWindow& w ) 
override;
 
  577    double  s2x( 
double plotCoordX ) 
const;
 
  578    double  s2y( 
double plotCoordY ) 
const;
 
  580    double  x2s( 
double x ) 
const;
 
  581    double  y2s( 
double y ) 
const;
 
  597    DECLARE_DYNAMIC_CLASS( 
mpFXY )
 
 
  623    bool HasBBox()
 const override { 
return false; }
 
  713        TICK_LABEL( 
double pos_ = 0.0, 
const wxString& label_ = wxT( 
"" ) ) :
 
 
 
 
  768    virtual void Plot( wxDC& dc, 
mpWindow& w ) 
override;
 
  770    virtual void getVisibleDataRange( 
mpWindow& w, 
double& minV, 
double& maxV ) 
override;
 
 
  810                 bool ticks = 
true, 
unsigned int type = 
mpX_NORMAL );
 
 
  844    virtual void Plot( wxDC& dc, 
mpWindow& w ) 
override;
 
  850    virtual bool HasBBox()
 const override { 
return false; }
 
  852    virtual double  TransformToPlot( 
double x ) 
const override;
 
  853    virtual double  TransformFromPlot( 
double xplot ) 
const override;
 
  858    virtual void    getVisibleDataRange( 
mpWindow& w, 
double& minV, 
double& maxV ) 
override;
 
  859    virtual void    recalculateTicks( wxDC& dc, 
mpWindow& w ) 
override;
 
  861    void    computeSlaveTicks( 
mpWindow& w );
 
 
  878#define mpMOUSEMODE_DRAG    0 
  880#define mpMOUSEMODE_ZOOMBOX 1 
  945    mpWindow( wxWindow* parent, wxWindowID 
id );
 
  961    bool AddLayer( 
mpLayer* layer, 
bool refreshDisplay = 
true );
 
  973    bool DelLayer( 
mpLayer* layer, 
bool alsoDeleteObject = 
false, 
bool refreshDisplay = 
true );
 
  981    void DelAllLayers( 
bool alsoDeleteObject, 
bool refreshDisplay = 
true );
 
  989    mpLayer* GetLayer( 
int position ) 
const;
 
  995    const mpLayer* GetLayerByName( 
const wxString& 
name ) 
const;
 
  998        return const_cast<mpLayer*
>( 
static_cast<const mpWindow*
>( this )->GetLayerByName( 
name ) );
 
 
 1046    void SetScaleX( 
double scaleX );
 
 1114    void Fit() 
override;
 
 1122    void Fit( 
double xMin, 
double xMax, 
double yMin, 
double yMax,
 
 1123              const wxCoord* printSizeX = 
nullptr, 
const wxCoord* printSizeY = 
nullptr,
 
 1124              wxOrientation directions = wxBOTH );
 
 1130    void ZoomIn( 
const wxPoint& centerPoint = wxDefaultPosition );
 
 1131    void ZoomIn( 
const wxPoint& centerPoint, 
double zoomFactor, wxOrientation directions = wxBOTH );
 
 1137    void ZoomOut( 
const wxPoint& centerPoint = wxDefaultPosition );
 
 1138    void ZoomOut( 
const wxPoint& centerPoint, 
double zoomFactor,
 
 1139                  wxOrientation directions = wxBOTH );
 
 1143    void ZoomRect( wxPoint p0, wxPoint p1 );
 
 1181    void GetBoundingBox( 
double* bbox ) 
const;
 
 1188    bool SaveScreenshot( wxImage& aImage,
 
 1189                         wxSize aImageSize = wxDefaultSize, 
bool aFit = 
false );
 
 1231    void SetLayerVisible( 
const wxString& 
name, 
bool viewable );
 
 1236    bool IsLayerVisible( 
const wxString& 
name ) 
const;
 
 1241    void SetLayerVisible( 
const unsigned int position, 
bool viewable );
 
 1246    bool IsLayerVisible( 
unsigned int position ) 
const;
 
 1252    void SetColourTheme( 
const wxColour& bgColour, 
const wxColour& drawColour,
 
 1253                         const wxColour& axesColour );
 
 1274    void AdjustLimitedView( wxOrientation directions = wxBOTH );
 
 1276    void OnFit( wxCommandEvent& event );
 
 1277    void OnCenter( wxCommandEvent& event );
 
 1280    static MouseWheelActionSet defaultMouseWheelActions();
 
 1282    void pushZoomUndo( 
const std::array<double, 4>& aZoom );
 
 1284    void OnPaint( wxPaintEvent& event );             
 
 1285    void OnSize( wxSizeEvent& event );               
 
 1287    void OnShowPopupMenu( wxMouseEvent& event );     
 
 1288    void OnMouseMiddleDown( wxMouseEvent& event );   
 
 1291    void onZoomIn( wxCommandEvent& event );          
 
 1292    void onZoomOut( wxCommandEvent& event );         
 
 1293    void onZoomUndo( wxCommandEvent& event );        
 
 1294    void onZoomRedo( wxCommandEvent& event );        
 
 1295    void onMouseWheel( wxMouseEvent& event );        
 
 1296    void onMagnify( wxMouseEvent& event );           
 
 1297    void onMouseMove( wxMouseEvent& event );         
 
 1298    void onMouseLeftDown( wxMouseEvent& event );     
 
 1299    void onMouseLeftDClick( wxMouseEvent& event );
 
 1300    void onMouseLeftRelease( wxMouseEvent& event );  
 
 1302    void DoZoom( 
const wxPoint& centerPoint, 
double zoomFactor, wxOrientation directions );
 
 1303    void RecomputeDesiredX( 
double& min, 
double& max );
 
 1304    void RecomputeDesiredY( 
double& min, 
double& max );
 
 1305    wxOrientation ViewNeedsRefitting( wxOrientation directions ) 
const;
 
 1307    void PerformMouseWheelAction( wxMouseEvent& event, MouseWheelAction action );
 
 1312    virtual bool UpdateBBox();
 
 1317    virtual bool SetXView( 
double pos, 
double desiredMax, 
double desiredMin );
 
 1322    virtual bool SetYView( 
double pos, 
double desiredMax, 
double desiredMin );
 
 1377    DECLARE_EVENT_TABLE()
 
 1382    template <
typename... Ts>
 
 
 1425    virtual void SetData( 
const std::vector<double>& xs, 
const std::vector<double>& ys );
 
 1480    bool GetNextXY( 
double& x, 
double& y ) 
override;
 
 
A class providing graphs functionality for a 2D plot (either continuous or a set of points),...
 
double GetMaxY() const override
Returns the actual maximum Y data (loaded in SetData).
 
void SetSweepWindow(int aSweepIdx) override
 
void SetSweepSize(size_t aSweepSize)
 
double GetMinY() const override
Returns the actual minimum Y data (loaded in SetData).
 
bool GetNextXY(double &x, double &y) override
Get locus value for next N.
 
double GetMinX() const override
Returns the actual minimum X data (loaded in SetData).
 
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.
 
size_t GetSweepSize() const
 
void Rewind() override
Rewind value enumeration with mpFXY::GetNextXY.
 
double GetMaxX() const override
Returns the actual maximum X data (loaded in SetData).
 
void SetSweepCount(int aSweepCount)
 
size_t GetCount() const override
 
int GetSweepCount() const override
 
Abstract base class providing plot and labeling functionality for a locus plot F:N->X,...
 
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)
 
void UpdateViewBoundary(wxCoord xnew, wxCoord ynew)
Update label positioning data.
 
virtual int GetSweepCount() 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 bool HasBBox() const override
mpInfoLayer has not bounding box.
 
mpInfoLayer()
Default constructor.
 
virtual bool IsInfo() const override
Specifies that this is an Info box layer.
 
mpInfoLegend()
Default constructor.
 
virtual void Plot(wxDC &dc, mpWindow &w) override
Plot method.
 
const wxString & GetDisplayName() const
 
virtual void Plot(wxDC &dc, mpWindow &w)=0
Plot given view of layer to the given device context.
 
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.
 
const wxString & GetName() const
Get layer name.
 
virtual double GetMinY() const
Get inclusive bottom border of bounding box.
 
bool GetContinuity() const
Gets the 'continuity' property of the layer.
 
virtual bool IsInfo() const
Check whether the layer is an info box.
 
void SetContinuity(bool continuity)
Set the 'continuity' property of the layer (true:draws a continuous line, false:draws separate points...
 
void ShowName(bool show)
Shows or hides the text label with the name of the layer (default is visible).
 
virtual void SetName(const wxString &name)
Set layer name.
 
const wxFont & GetFont() const
Get font set for this layer.
 
const wxPen & GetPen() const
Get pen set for this layer.
 
void SetVisible(bool show)
Sets layer visibility.
 
void SetPen(const wxPen &pen)
Set layer pen.
 
void SetBrush(const wxBrush &brush)
Set layer brush.
 
virtual double GetMaxX() const
Get inclusive right border of bounding box.
 
const wxBrush & GetBrush() const
Get brush set for this layer.
 
virtual double GetMinX() const
Get inclusive left border of bounding box.
 
virtual double GetMaxY() const
Get inclusive top border of bounding box.
 
virtual bool HasBBox() const
Check whether this layer has a bounding box.
 
Plot layer implementing a x-scale ruler.
 
void SetAxisMinMax(bool lock, double minV, double maxV)
 
void SetNameAlign(int align)
 
virtual void recalculateTicks(wxDC &dc, mpWindow &w)
 
double AbsMaxValue() const
 
void GetDataRange(double &minV, double &maxV) const
 
std::vector< double > m_tickValues
 
double AbsVisibleMaxValue() const
 
bool HasBBox() const override
Check whether this layer has a bounding box.
 
void SetAlign(int align)
Set X axis alignment.
 
void SetTicks(bool enable)
Set X axis ticks or grid.
 
virtual double TransformToPlot(double x) const
 
virtual void ResetDataRange()
 
virtual void formatLabels()
 
virtual bool IsHorizontal() const =0
 
void computeLabelExtents(wxDC &dc, mpWindow &w)
 
bool GetTicks() const
Get X axis ticks or grid.
 
virtual void ExtendDataRange(double minV, double maxV)
 
std::vector< TICK_LABEL > m_tickLabels
 
bool GetAxisMinMax(double *minV, double *maxV)
 
void updateTickLabels(wxDC &dc, mpWindow &w)
 
virtual void getVisibleDataRange(mpWindow &w, double &minV, double &maxV)
 
virtual double TransformFromPlot(double xplot) const
 
mpScaleXBase(const wxString &name=wxT("X"), int flags=mpALIGN_CENTER, bool ticks=true, unsigned int type=mpX_NORMAL)
Full constructor.
 
virtual bool IsHorizontal() const override
 
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 bool IsHorizontal() const override
 
void SetMasterScale(mpScaleY *masterScale)
 
virtual bool HasBBox() const override
Check whether this layer has a bounding box.
 
mpScaleY(const wxString &name=wxT("Y"), int flags=mpALIGN_CENTER, bool ticks=true)
 
Canvas for plotting mpLayer implementations.
 
mpInfoLayer * m_movingInfoLayer
 
int RedoZoomStackSize() const
 
int GetMarginLeft() const
 
bool m_enableMouseNavigation
 
void EnableMousePanZoom(bool enabled)
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
 
void SetMarginLeft(int left)
Set the left margin.
 
const wxColour & GetAxesColour()
Get axes draw colour.
 
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.
 
void SetMouseWheelActions(const MouseWheelActionSet &s)
Set the pan/zoom actions corresponding to mousewheel/trackpad events.
 
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 SetMarginRight(int right)
Set the right margin.
 
void LimitView(bool aEnable)
Enable limiting of zooming & panning to the area used by the plots.
 
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
 
void SetMarginTop(int top)
Set the top margin.
 
std::stack< std::array< double, 4 > > m_redoZoomStack
 
void SetPosX(double posX)
Set current view's X position and refresh display.
 
double GetDesiredYmax() const
Returns the top layer-border coordinate that the user wants the mpWindow to show (it may be not exact...
 
void SetMarginBottom(int bottom)
Set the bottom margin.
 
void SetPosY(double posY)
Set current view's Y position and refresh display.
 
void SetScaleY(double scaleY)
Set current view's Y scale and refresh display.
 
double GetDesiredYmin() const
Returns the bottom-border layer coordinate that the user wants the mpWindow to show (it may be not ex...
 
void UpdateAll()
Refresh display.
 
wxCoord y2p(double y)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
 
double GetDesiredXmax() const
Returns the right-border layer coordinate that the user wants the mpWindow to show (it may be not exa...
 
double m_topBottomPlotGapFactor
 
wxMenu * GetPopupMenu()
Get reference to context menu of the plot canvas.
 
double GetDesiredXmin() const
Returns the left-border layer coordinate that the user wants the mpWindow to show (it may be not exac...
 
std::stack< std::array< double, 4 > > m_undoZoomStack
 
int GetMarginRight() const
 
void SetScr(int scrX, int scrY)
Set current view's dimensions in device context units.
 
int GetMarginBottom() const
 
void EnableDoubleBuffer(bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=disabled).
 
static double zoomIncrementalFactor
This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse...
 
mpLayer * GetLayerByName(const wxString &name)
 
int UndoZoomStackSize() const
 
double m_desiredXmin
These are updated in Fit, ZoomIn, ZoomOut, ZoomRect, SetXView, SetYView and may be different from the...
 
bool m_enableDoubleBuffer
 
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.
 
double GetScaleY() const
Get current view's Y scale.
 
double GetScaleX() const
Get current view's X scale.
 
double GetPosY() const
Get current view's Y position.
 
double GetPosX() const
Get current view's X position.
 
class WXDLLIMPEXP_MATHPLOT mpFY
 
class WXDLLIMPEXP_MATHPLOT mpWindow
 
class WXDLLIMPEXP_MATHPLOT mpPrintout
 
class WXDLLIMPEXP_MATHPLOT mpFXYVector
 
#define mpALIGN_RIGHT
Aligns label to the right.
 
enum __mp_Layer_Type mpLayerType
 
std::deque< mpLayer * > wxLayerList
Define the type for the list of layers inside mpWindow.
 
class WXDLLIMPEXP_MATHPLOT mpFXY
 
#define mpALIGN_CENTER
Aligns label to the center.
 
#define mpALIGN_TOP
Aligns label to the top.
 
#define WXDLLIMPEXP_MATHPLOT
wxMathPlot is a framework for mathematical graph plotting in wxWindows.
 
class WXDLLIMPEXP_MATHPLOT mpLayer
 
class WXDLLIMPEXP_MATHPLOT mpFX
 
class WXDLLIMPEXP_MATHPLOT mpScaleX
 
class WXDLLIMPEXP_MATHPLOT mpScaleY
 
#define mpX_NORMAL
Set label for X axis in normal mode.
 
#define mpALIGN_NE
Aligns label to north-east.
 
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
 
TICK_LABEL(double pos_=0.0, const wxString &label_=wxT(""))
 
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