|
MathPlot
|
Canvas for plotting mpLayer implementations. More...
#include <mathplot.h>


Public Member Functions | |
| mpWindow (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long flags=0) | |
| wxMenu * | GetPopupMenu () |
| Get reference to context menu of the plot canvas. More... | |
| bool | AddLayer (mpLayer *layer, bool refreshDisplay=true, bool refreshConfig=true) |
| Add a plot layer to the canvas. More... | |
| bool | DelLayer (mpLayer *layer, mpDeleteAction alsoDeleteObject, bool refreshDisplay=true, bool refreshConfig=true) |
| Remove a plot layer from the canvas. More... | |
| void | DelAllLayers (mpDeleteAction alsoDeleteObject, bool refreshDisplay=true) |
| Remove all layers from the plot. More... | |
| void | DelAllPlot (mpDeleteAction alsoDeleteObject, mpFunctionType func=mpfAllType, bool refreshDisplay=true) |
| Remove all plot layers. More... | |
| void | DelAllYAxisAfterID (mpDeleteAction alsoDeleteObject, int yAxisID=0, bool refreshDisplay=true) |
| Remove all extra y axis after the selected y axis. More... | |
| mpLayer * | GetLayer (int position) |
| int | GetLayerPosition (mpLayer *layer) |
| mpLayer * | GetLayersType (int position, mpLayerType type) |
| mpLayer * | GetLayerPlot (int position, mpFunctionType func=mpfAllType) |
| mpLayer * | GetLayerAxis (int position, mpScaleType scale=mpsAllType) |
| mpFXYVector * | GetXYSeries (unsigned int n, const wxString &name=_T("Serie "), bool create=true) |
| mpLayer * | GetClosestPlot (wxCoord ix, wxCoord iy, double *xnear, double *ynear) |
| mpLayer * | GetLayerByName (const wxString &name) |
| mpLayer * | GetLayerByClassName (const wxString &name) |
| void | RefreshLegend (void) |
| bool | IsYAxisUsed (int yAxisID) |
| mpScaleX * | GetLayerXAxis () |
| Get the first scale X layer (X axis) or NULL if not found. More... | |
| mpScaleY * | GetLayerYAxis (int yAxisID) |
| Get the scale Y layer (Y axis) with a specific yAxisID or NULL if not found. More... | |
| void | SetScaleX (const double scaleX) |
| Set current view's X scale and refresh display. More... | |
| double | GetScaleX (void) const |
| Get current view's X scale. More... | |
| void | SetScaleY (const double scaleY, int yAxisID) |
| Set current view's Y scale and refresh display. More... | |
| double | GetScaleY (int yAxisID) |
| Get current view's Y scale. More... | |
| void | SetBound () |
| Update bound for mpFX and mpFY when axis is scaled. More... | |
| mpRange | Get_BoundX (void) const |
| Get bounding box for X axis. More... | |
| mpRange | Get_BoundY (int yAxisID) |
| Get bounding box for Y axis of ID yAxisID. More... | |
| void | SetPosX (const double posX) |
| Set current view's X position and refresh display. More... | |
| double | GetPosX (void) const |
| Get current view's X position. More... | |
| void | SetPosY (const std::vector< double > &posYList) |
| Set current view's Y position and refresh display. More... | |
| double | GetPosY (int yAxisID) |
| Get current view's Y position. More... | |
| int | GetNOfYAxis (void) const |
| Get the number of Y axis. More... | |
| mpAxisList | GetAxisDataYList (void) const |
| void | SetScreen (const int scrX, const int scrY) |
| Set current view's dimensions in device context units. More... | |
| int | GetScreenX (void) const |
| Get current view's X dimension in device context units. More... | |
| int | GetScreenY (void) const |
| Get current view's Y dimension in device context units. More... | |
| void | SetPos (const double posX, const std::vector< double > &posYList) |
| Set current view's X and Y position and refresh display. More... | |
| double | p2x (const wxCoord pixelCoordX) const |
| Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale. More... | |
| double | p2y (const wxCoord pixelCoordY, int yAxisID=0) |
| Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale. More... | |
| wxCoord | x2p (const double x) const |
| Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale. More... | |
| wxCoord | y2p (const double y, int yAxisID=0) |
| Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale. More... | |
| void | EnableDoubleBuffer (const bool enabled) |
| Enable/disable the double-buffering of the window, eliminating the flicker (default=enabled). | |
| void | EnableMousePanZoom (const bool enabled) |
| Enable/disable the feature of pan/zoom with the mouse (default=enabled) | |
| void | LockAspect (bool enable=true) |
| Enable or disable X/Y scale aspect locking for the view. More... | |
| bool | IsAspectLocked () const |
| Checks whether the X/Y scale aspect is locked. More... | |
| bool | IsRepainting () const |
| Checks if we are repainting. More... | |
| void | Fit () |
| Set view to fit global bounding box of all plot layers and refresh display with UpdateAll(). More... | |
| void | Fit (const mpRange &rangeX, const std::vector< mpRange > &rangeY, wxCoord *printSizeX=NULL, wxCoord *printSizeY=NULL) |
| Set view to fit a given bounding box and refresh display with UpdateAll(). More... | |
| void | FitX (void) |
| Similar to Fit() but only fit in X. More... | |
| void | FitY (int yAxisID) |
| Similar to Fit() but only fit in Y and only one Y-axis, specified by ID. More... | |
| void | ZoomIn (const wxPoint ¢erPoint=wxDefaultPosition) |
| Zoom into current view and refresh display. More... | |
| void | ZoomOut (const wxPoint ¢erPoint=wxDefaultPosition) |
| Zoom out current view and refresh display. More... | |
| void | ZoomInX () |
| Zoom in current view along X around center and refresh display. | |
| void | ZoomOutX () |
| Zoom out current view along X around center and refresh display. | |
| void | ZoomInY (std::optional< int > yAxisID=std::nullopt) |
| Zoom in current view along Y around center and refresh display. More... | |
| void | ZoomOutY (std::optional< int > yAxisID=std::nullopt) |
| Zoom out current view along Y around center and refresh display. More... | |
| 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 | UpdateAll () |
| Refresh display. | |
| unsigned int | CountLayers () |
| Counts the number of plot layers, including axes: this is to count only the layers which have a bounding box. More... | |
| unsigned int | CountAllLayers () |
| Counts the number of plot layers, whether or not they have a bounding box. More... | |
| unsigned int | CountLayersType (mpLayerType type) |
| Counts the number of plot layers: this is to count only the layers which have a plot. More... | |
| unsigned int | CountLayersFXYPlot () |
| void | UpdateDesiredBoundingBox (mpAxisUpdate update) |
| Draws the mpWindow on a page for printing. More... | |
| mpFloatRectSimple | GetBoundingBox (bool desired, unsigned int yAxisID=0) |
| Return a bounding box for an y-axis ID. More... | |
| double | GetDesiredXmin () const |
| Returns the left-border layer coordinate that the user wants the mpWindow to show (it may be not exactly the actual shown coordinate in the case of locked aspect ratio). More... | |
| double | GetDesiredXmax () const |
| Return the right-border layer coordinate that the user wants the mpWindow to show (it may be not exactly the actual shown coordinate in the case of locked aspect ratio). More... | |
| double | GetDesiredYmin (int yAxisID) |
| Return the bottom-border layer coordinate that the user wants the mpWindow to show (it may be not exactly the actual shown coordinate in the case of locked aspect ratio). More... | |
| double | GetDesiredYmax (int yAxisID) |
| Return the top layer-border coordinate that the user wants the mpWindow to show (it may be not exactly the actual shown coordinate in the case of locked aspect ratio). More... | |
| bool | GetBoundingBox (mpRange *boundX, mpRange *boundY, int yAxisID) |
| Return the bounding box coordinates for the Y axis of ID yAxisID. | |
| bool | PointIsInsideBound (double px, double py, int yAxisID) |
| void | UpdateBoundingBoxToInclude (double px, double py, int yAxisID) |
| void | InitializeBoundingBox (double px, double py, int yAxisID) |
| void | SetMPScrollbars (bool status) |
| Enable/disable scrollbars. More... | |
| bool | GetMPScrollbars () const |
| Get scrollbars status. More... | |
| bool | SaveScreenshot (const wxString &filename, int type=wxBITMAP_TYPE_BMP, wxSize imageSize=wxDefaultSize, bool fit=false) |
| Draw the window on a wxBitmap, then save it to a file. More... | |
| wxBitmap * | BitmapScreenshot (wxSize imageSize=wxDefaultSize, bool fit=false) |
| Get a screen shot of the window plot. | |
| void | ClipboardScreenshot (wxSize imageSize=wxDefaultSize, bool fit=false) |
| Send the screen shot to the Clipboard. | |
| bool | LoadFile (const wxString &filename) |
| Load a data file like a csv file Data must be formatted in 2 columns X value and Y value separated by space or ; or tab character. | |
| void | SetMargins (int top, int right, int bottom, int left) |
| Set window margins, creating a blank area where some kinds of layers cannot draw. More... | |
| void | UpdateMargins () |
| Update margins if e.g. More... | |
| void | SetMarginTop (int top) |
| Set the top margin. More... | |
| int | GetMarginTop (bool minusExtra=false) const |
| Get the top margin. More... | |
| void | SetMarginRight (int right) |
| Set the right margin. More... | |
| int | GetMarginRight (bool minusExtra=false) const |
| Get the right margin. More... | |
| int | GetMarginRightOuter () const |
| Get the right outer margin, exluding Y-axis. More... | |
| void | SetMarginBottom (int bottom) |
| Set the bottom margin. More... | |
| int | GetMarginBottom (bool minusExtra=false) const |
| Get the bottom margin. More... | |
| void | SetMarginLeft (int left) |
| Set the left margin. More... | |
| int | GetMarginLeft (bool minusExtra=false) const |
| Get the left margin. More... | |
| void | SetExtraMargin (int extra) |
| Set the extra margin. More... | |
| int | GetExtraMargin () const |
| Get the extra margin. More... | |
| int | GetMarginLeftOuter () const |
| Get the left outer margin, exluding Y-axis. More... | |
| int | GetPlotWidth () const |
| Get the width of the plot. More... | |
| int | GetPlotHeight () const |
| Get the height of the plot. More... | |
| mpRect | GetPlotBoundaries (bool with_margin) const |
| Get the boundaries of the plot. More... | |
| int | GetLeftYAxesWidth (std::optional< int > yAxisID=std::nullopt) |
| Calculate width of all axes to the left of this axis. More... | |
| int | GetRightYAxesWidth (std::optional< int > yAxisID=std::nullopt) |
| Calculate width of all axes to the right of this axis. More... | |
| void | SetDrawBox (bool drawbox) |
| Set the draw of the box around the plot. More... | |
| bool | GetDrawBox () const |
| Get the draw of the box around the plot. More... | |
| std::optional< int > | IsInsideYAxis (const wxPoint &point) |
| Check if a given point is inside the area of a visible Y-axis and returns its ID if so. More... | |
| mpInfoLayer * | IsInsideInfoLayer (const wxPoint &point) |
| Check if a given point is inside the area of a mpInfoLayer and eventually returns its pointer. More... | |
| void | SetLayerVisible (const wxString &name, bool viewable) |
| Sets the visibility of a layer by its name. More... | |
| bool | IsLayerVisible (const wxString &name) |
| Check whether a layer with given name is visible. More... | |
| bool | IsLayerVisible (const unsigned int position) |
| Check whether the layer at given position is visible. More... | |
| void | SetLayerVisible (const unsigned int position, bool viewable) |
| Sets the visibility of a layer by its position in layer list. More... | |
| void | SetColourTheme (const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour) |
| Set Color theme. More... | |
| const wxColour & | GetAxesColour () const |
| Get axes draw colour. More... | |
| const wxColour & | GetbgColour () const |
| void | SetbgColour (const wxColour &colour) |
| void | SetOnDeleteLayer (const mpOnDeleteLayer &event) |
| On delete layer event Allows the user to perform certain actions before deleting the layer. More... | |
| void | UnSetOnDeleteLayer () |
| Remove the 'delete layer event' callback. | |
| void | SetOnUserMouseAction (const mpOnUserMouseAction &userMouseEventHandler) |
| On user mouse action event Allows the user to perform certain actions before normal event processing. More... | |
| void | UnSetOnUserMouseAction () |
| Remove the 'user mouse action event' callback. | |
| bool | IsLogXaxis () |
| Is this an X axis to be displayed with log scale? It is really an axis property but as we need to control the bound and the scale, it is easiest and faster to declare this property here. | |
| bool | IsLogYaxis (int yAxisID) |
| Get the log property (true or false) Y layer (Y axis) with a specific Y ID or false if not found. | |
| void | SetLogXaxis (bool log) |
| void | SetLogYaxis (int yAxisID, bool log) |
| Set the log property (true or false) for a Y layer (Y axis) given by is ID. | |
| bool | GetMagnetize () const |
| Magnetize the position of the mouse in the plot ie draw a vertical and horizontal line. More... | |
| void | SetMagnetize (bool mag) |
| void | SetMouseLeftDownAction (mpMouseButtonAction action) |
| Set the type of action for the left mouse button. More... | |
| mpMouseButtonAction | GetMouseLeftDownAction () |
| Returns the type of action for the left mouse button. More... | |
Static Public Attributes | |
| static double | m_zoomIncrementalFactor = 1.5 |
| This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse wheel. More... | |
Protected Member Functions | |
| virtual void | OnPaint (wxPaintEvent &event) |
| Paint handler, will plot all attached layers. | |
| virtual void | OnSize (wxSizeEvent &event) |
| Size handler, will update scroll bar sizes. | |
| virtual void | OnShowPopupMenu (wxMouseEvent &event) |
| Mouse handler, will show context menu. | |
| virtual void | OnCenter (wxCommandEvent &event) |
| Context menu handler. | |
| virtual void | OnFit (wxCommandEvent &event) |
| Context menu handler. | |
| virtual void | OnToggleGrids (wxCommandEvent &event) |
| Context menu handler. | |
| virtual void | OnToggleCoords (wxCommandEvent &event) |
| Context menu handler. | |
| virtual void | OnScreenShot (wxCommandEvent &event) |
| Context menu handler. | |
| virtual void | OnFullScreen (wxCommandEvent &event) |
| Context menu handler. | |
| virtual void | OnLoadFile (wxCommandEvent &event) |
| Context menu handler. More... | |
| virtual void | OnZoomIn (wxCommandEvent &event) |
| Context menu handler. | |
| virtual void | OnZoomOut (wxCommandEvent &event) |
| Context menu handler. | |
| virtual void | OnLockAspect (wxCommandEvent &event) |
| Context menu handler. | |
| virtual void | OnMouseHelp (wxCommandEvent &event) |
| Context menu handler. | |
| virtual void | OnMouseLeftDown (wxMouseEvent &event) |
| Mouse left click (for rect zoom) | |
| virtual void | OnMouseRightDown (wxMouseEvent &event) |
| Mouse handler, for detecting when the user drags with the right button or just "clicks" for the menu. | |
| virtual void | OnMouseMove (wxMouseEvent &event) |
| Mouse handler for mouse motion (for pan) | |
| virtual void | OnMouseLeftRelease (wxMouseEvent &event) |
| Mouse left click (for rect zoom) | |
| virtual void | OnMouseWheel (wxMouseEvent &event) |
| Mouse handler for the wheel. | |
| virtual void | OnMouseLeave (wxMouseEvent &event) |
| Mouse handler for mouse motion (for pan) More... | |
| bool | CheckUserMouseAction (wxMouseEvent &event) |
| Check if a user mouse action is required. | |
| virtual void | OnScrollThumbTrack (wxScrollWinEvent &event) |
| Scroll thumb on scroll bar moving. | |
| virtual void | OnScrollPageUp (wxScrollWinEvent &event) |
| Scroll page up. | |
| virtual void | OnScrollPageDown (wxScrollWinEvent &event) |
| Scroll page down. | |
| virtual void | OnScrollLineUp (wxScrollWinEvent &event) |
| Scroll line up. | |
| virtual void | OnScrollLineDown (wxScrollWinEvent &event) |
| Scroll line down. | |
| virtual void | OnScrollTop (wxScrollWinEvent &event) |
| Scroll to top. | |
| virtual void | OnScrollBottom (wxScrollWinEvent &event) |
| Scroll to bottom. | |
| void | DoScrollCalc (const int position, const int orientation) |
| void | DoZoomXCalc (bool zoomIn, wxCoord staticXpixel=-1) |
| Zoom in or out X around a X position. More... | |
| void | DoZoomYCalc (bool zoomIn, wxCoord staticYpixel=-1, std::optional< int >=std::nullopt) |
| Zoom in or out Y around a Y position. More... | |
| void | SetScaleXAndCenter (double scaleX) |
| Set the m_scaleX directly to fixed zoom level, but also adjust m_posX to to make the zoom around center. More... | |
| void | SetScaleYAndCenter (double scaleY, int yAxisID) |
| Set the m_scaleY directly to fixed zoom level, but also adjust m_posY to to make the zoom around center. More... | |
| void | Zoom (bool zoomIn, const wxPoint ¢erPoint) |
| virtual bool | UpdateBBox () |
| Set bounding box 'm_bound' to contain all visible plots of this mpWindow. More... | |
| void | InitParameters () |
| virtual void | DesiredBoundsHaveChanged () |
| To be notified of displayed bounds changes (after user zoom etc), override this callback in your derived class and look at the new value of m_desired. More... | |
Protected Attributes | |
| wxTopLevelWindow * | m_parent |
| bool | m_fullscreen |
| mpLayerList | m_layers |
| List of attached plot layers. | |
| mpAxisData | m_AxisDataX |
| Axis data for the X direction. | |
| mpAxisList | m_AxisDataYList |
| List of axis data for the Y direction. | |
| bool | m_desiredChanged = false |
| Is the desired bounds have changed ? Used to call DesiredBoundsHaveChanged() | |
| wxMenu | m_popmenu |
| Canvas' context menu. | |
| bool | m_lockaspect |
| Scale aspect is locked or not. | |
| wxColour | m_bgColour |
| Background Colour. | |
| wxColour | m_fgColour |
| Foreground Colour. | |
| wxColour | m_axColour |
| Axes Colour. | |
| bool | m_drawBox |
| Draw box of the plot bound. Default true. | |
| int | m_scrX |
| Current view's X dimension in DC units, including all scales, margins. | |
| int | m_scrY |
| Current view's Y dimension. | |
| int | m_clickedX |
| Last mouse click X position, for centering and zooming the view. | |
| int | m_clickedY |
| Last mouse click Y position, for centering and zooming the view. | |
| mpRect | m_margin |
| Margin around the plot including Y-axis. | |
| mpRect | m_marginOuter |
| Margin around the plot exluding Y-axis. Default 50. | |
| int | m_extraMargin |
| Extra margin around the plot. Default 8. | |
| wxCoord | m_plotWidth |
| Width of the plot = m_scrX - (m_margin.left + m_margin.right) | |
| wxCoord | m_plotHeight |
| Height of the plot = m_scrY - (m_margin.top + m_margin.bottom) | |
| mpRect | m_plotBoundaries |
| The full size of the plot. Calculated. | |
| mpRect | m_plotBoundariesMargin |
| The size of the plot with the margins. Calculated. | |
| wxRect | m_PlotArea |
| The full size of the plot with m_extraMargin. | |
| bool | m_repainting |
| int | m_last_lx |
| int | m_last_ly |
| For double buffering. | |
| wxBitmap * | m_buff_bmp |
| For double buffering. | |
| bool | m_enableDoubleBuffer |
| For double buffering. Default enabled. | |
| bool | m_enableMouseNavigation |
| For pan/zoom with the mouse. | |
| mpMouseButtonAction | m_mouseLeftDownAction |
| Type of action for left mouse button. | |
| bool | m_mouseMovedAfterRightClick |
| wxPoint | m_mouseRClick |
| For the right button "drag" feature. | |
| wxPoint | m_mouseLClick |
| Starting coords for rectangular zoom selection. | |
| double | m_mouseScaleX |
| Store current X-scale, used as reference during drag zooming. | |
| std::vector< double > | m_mouseScaleYList |
| Store current Y-scales, used as reference during drag zooming. | |
| std::optional< int > | m_mouseYAxisID |
| Indicate which ID of Y-axis the mouse was on during zoom/pan. | |
| bool | m_enableScrollBars |
| int | m_scrollX |
| int | m_scrollY |
| mpInfoLayer * | m_movingInfoLayer |
| For moving info layers over the window area. | |
| mpInfoCoords * | m_InfoCoords |
| pointer to the optional info coords layer | |
| mpInfoLegend * | m_InfoLegend |
| pointer to the optional info legend layer | |
| bool | m_InInfoLegend |
| wxBitmap * | m_zoom_bmp |
| For zoom selection. | |
| wxRect | m_zoom_dim |
| wxRect | m_zoom_oldDim |
| bool | m_magnetize |
| For mouse magnetization. | |
| mpMagnet | m_magnet |
| For mouse magnetization. | |
| wxBitmap * | m_Screenshot_bmp |
| For clipboard, save and print. | |
| mpOnDeleteLayer | m_OnDeleteLayer = NULL |
| Event when we delete a layer. | |
| mpOnUserMouseAction | m_OnUserMouseAction = NULL |
| Event when we have a mouse click. | |
Canvas for plotting mpLayer implementations.
This class defines a zoomable and moveable 2D plot canvas. Any number of mpLayer implementations (scale rulers, function plots, ...) can be attached using mpWindow::AddLayer.
The canvas window provides a context menu with actions for navigating the view. The context menu can be retrieved with mpWindow::GetPopupMenu, e.g. for extending it externally.
Since wxMathPlot version 0.03, the mpWindow incorporates the following features:
The mouse commands can be visualized by the user through the popup menu, and are:
| bool mpWindow::AddLayer | ( | mpLayer * | layer, |
| bool | refreshDisplay = true, |
||
| bool | refreshConfig = true |
||
| ) |
Add a plot layer to the canvas.
| layer | Pointer to layer. The mpLayer object will get under control of mpWindow, i.e. it will be delete'd on mpWindow destruction |
| refreshDisplay | States whether to fit and refresh the display (UpdateAll) after adding the layer. |
| refreshConfig | States whether to refresh the config window (if exist) |
| TRUE | Success |
| FALSE | Failure. layer = NULL or layer already exist (Coords or Legend). |
|
inline |
Counts the number of plot layers, whether or not they have a bounding box.
| unsigned int mpWindow::CountLayers | ( | ) |
Counts the number of plot layers, including axes: this is to count only the layers which have a bounding box.
Several layer operations.
| unsigned int mpWindow::CountLayersType | ( | mpLayerType | type | ) |
Counts the number of plot layers: this is to count only the layers which have a plot.
| void mpWindow::DelAllLayers | ( | mpDeleteAction | alsoDeleteObject, |
| bool | refreshDisplay = true |
||
| ) |
Remove all layers from the plot.
| alsoDeleteObject | If set to true, the mpLayer objects will be also "deleted", not just removed from the internal list. |
| refreshDisplay | States whether to refresh the display (UpdateAll) after removing the layers. See DelLayer() for more infos |
| void mpWindow::DelAllPlot | ( | mpDeleteAction | alsoDeleteObject, |
| mpFunctionType | func = mpfAllType, |
||
| bool | refreshDisplay = true |
||
| ) |
Remove all plot layers.
| alsoDeleteObject | If set to true, the mpLayer objects will be also "deleted", not just removed from the internal list. |
| func | Select type of plot |
| refreshDisplay | States whether to refresh the display (UpdateAll) after removing the layers. See DelLayer() for more infos |
| void mpWindow::DelAllYAxisAfterID | ( | mpDeleteAction | alsoDeleteObject, |
| int | yAxisID = 0, |
||
| bool | refreshDisplay = true |
||
| ) |
Remove all extra y axis after the selected y axis.
| alsoDeleteObject | If set to true, the mpLayer objects will be also "deleted", not just removed from the internal list. |
| yAxisID | the ID of the axis to keep (Default 0). Remove all y axis after this ID. If y-axis ID < 0, remove all y axis. |
| refreshDisplay | States whether to refresh the display (UpdateAll) after removing the layers. See DelLayer() for more infos |
| bool mpWindow::DelLayer | ( | mpLayer * | layer, |
| mpDeleteAction | alsoDeleteObject, | ||
| bool | refreshDisplay = true, |
||
| bool | refreshConfig = true |
||
| ) |
Remove a plot layer from the canvas.
| layer | Pointer to layer. The mpLayer object will be destructed using delete. |
| alsoDeleteObject | If set to mpYesDelete, the mpLayer object will be also "deleted", not just removed from the internal list. In case mpForceDelete, the mpLayer object is deleted even if m_CanDelete is false |
| refreshDisplay | States whether to refresh the display (UpdateAll) after removing the layer. |
| refreshConfig | States whether to refresh the config window (if exist) |
N.B. If alsoDeleteObject is false, only the layer pointer in the mpWindow is removed, the layer object still exists. WARNING: Invalidates any extant m_layers iterators! WARNING: If alsoDeleteObject is true, the layer object object is deleted but his reference (pointer) is not set to NULL.
|
inlineprotectedvirtual |
To be notified of displayed bounds changes (after user zoom etc), override this callback in your derived class and look at the new value of m_desired.
Useful for keeping multiple plots in sync when user zooms.
|
protected |
Zoom in or out X around a X position.
Is the position is not set, it will zoom around center.
| Zoom | in or zoom out boolean |
| Optional | center position |
|
protected |
Zoom in or out Y around a Y position.
Is the position is not set, it will zoom around center. An optional Y-axis ID can be passe to only zoom a specific Y-axis
| Zoom | in or zoom out boolean |
| Optional | center position |
| Optional | Y-axis ID used to specify which Y-axis to zoom |
| void mpWindow::Fit | ( | ) |
Set view to fit global bounding box of all plot layers and refresh display with UpdateAll().
General fit Use global layer bounding box.
Scale and position will be set to show all attached mpLayers. The X/Y scale aspect lock is taken into account.
| void mpWindow::Fit | ( | const mpRange & | rangeX, |
| const std::vector< mpRange > & | rangeY, | ||
| wxCoord * | printSizeX = NULL, |
||
| wxCoord * | printSizeY = NULL |
||
| ) |
Set view to fit a given bounding box and refresh display with UpdateAll().
Here rangeY is a vector and he is exactly ordered like Range in m_AxisDataYList.
The X/Y scale aspect lock is taken into account. If provided, the parameters printSizeX and printSizeY are taken as the DC size, and the pixel scales are computed accordingly. Also, in this case the passed borders are not saved as the "desired borders", since this use will be invoked only when printing.
| void mpWindow::FitX | ( | void | ) |
Similar to Fit() but only fit in X.
Intentionally don't call UpdateAll() since you might want to perform other actions before updating plot
| void mpWindow::FitY | ( | int | yAxisID | ) |
Similar to Fit() but only fit in Y and only one Y-axis, specified by ID.
Intentionally don't call UpdateAll() since you might want to perform other actions before updating plot
| yAxisID | indicating which Y-axis to fit |
|
inline |
Get bounding box for X axis.
|
inline |
Get bounding box for Y axis of ID yAxisID.
| yAxisID | Y axis ID to get bound |
|
inline |
Get axes draw colour.
|
inline |
Return a bounding box for an y-axis ID.
| desired | if true return desired bound else return bound desired yAxisID: the y-axis ID (default 0) |
| mpLayer * mpWindow::GetClosestPlot | ( | wxCoord | ix, |
| wxCoord | iy, | ||
| double * | xnear, | ||
| double * | ynear | ||
| ) |
Search the point of the layer plot nearest a point
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Get the draw of the box around the plot.
|
inline |
Get the extra margin.
| mpLayer * mpWindow::GetLayer | ( | int | position | ) |
Get the layer in list position indicated. N.B. You must know the index of the layer inside the list!
| position | position of the layer in the layers list |
| mpLayer * mpWindow::GetLayerAxis | ( | int | position, |
| mpScaleType | scale = mpsAllType |
||
| ) |
Get the layer axis in list position indicated.
| mpLayer * mpWindow::GetLayerByClassName | ( | const wxString & | name | ) |
Get the first layer by its class name (case sensitive).
| name | The class name of the layer to retrieve |
| mpLayer * mpWindow::GetLayerByName | ( | const wxString & | name | ) |
Get the layer by its name (case sensitive).
| name | The name of the layer to retrieve |
| mpLayer * mpWindow::GetLayerPlot | ( | int | position, |
| mpFunctionType | func = mpfAllType |
||
| ) |
Get the layer plot in list position indicated. N.B. You must know the index of the layer plot inside the list of plot!
| position | position of the layer plot in the layers plot list |
| int mpWindow::GetLayerPosition | ( | mpLayer * | layer | ) |
Get the position of the layer in the list.
| layer | the layer to find |
| mpLayer * mpWindow::GetLayersType | ( | int | position, |
| mpLayerType | type | ||
| ) |
Get the layer of a certain type in list position indicated. N.B. You must know the index of the layer inside the list!
| position | position of the layer in the layers list |
| type | of the layer |
| mpScaleX * mpWindow::GetLayerXAxis | ( | ) |
Get the first scale X layer (X axis) or NULL if not found.
Get the first scale X layer (X axis).
| mpScaleY * mpWindow::GetLayerYAxis | ( | int | yAxisID | ) |
Get the scale Y layer (Y axis) with a specific yAxisID or NULL if not found.
Get the scale Y layer (Y axis) with a specific yAxisID
| int mpWindow::GetLeftYAxesWidth | ( | std::optional< int > | yAxisID = std::nullopt | ) |
Calculate width of all axes to the left of this axis.
If y-axis ID is not specified, calculate width of all left axes
| index | of this y-axis |
|
inline |
Magnetize the position of the mouse in the plot ie draw a vertical and horizontal line.
Useful to read the position on axis.
| mag. if true magnetize the mouse |
|
inline |
Get the bottom margin.
| minusExtra | (default false): return bottom margin minus extra margin |
|
inline |
Get the left margin.
| minusExtra | (default false): return left margin minus extra margin |
|
inline |
Get the left outer margin, exluding Y-axis.
|
inline |
Get the right margin.
| minusExtra | (default false): return right margin minus extra margin |
|
inline |
Get the right outer margin, exluding Y-axis.
|
inline |
Get the top margin.
| minusExtra | (default false): return top margin minus extra margin |
|
inline |
Returns the type of action for the left mouse button.
|
inline |
Get scrollbars status.
|
inline |
Get the number of Y axis.
|
inline |
Get the boundaries of the plot.
Bond is reduced by m_extraMargin constant
| with_margin | include margin if true |
|
inline |
Get the height of the plot.
|
inline |
Get the width of the plot.
|
inline |
Get reference to context menu of the plot canvas.
|
inline |
Get current view's X position.
See rules for coordinate transformation
|
inline |
Get current view's Y position.
See rules for coordinate transformation
| yAxisID | Y axis ID to get Pos |
| int mpWindow::GetRightYAxesWidth | ( | std::optional< int > | yAxisID = std::nullopt | ) |
Calculate width of all axes to the right of this axis.
If y-axis ID is not specified, calculate width of all right axes
| index | of this y-axis |
|
inline |
|
inline |
Get current view's Y scale.
See rules for coordinate transformation
| yAxisID | Y axis ID to get scale |
|
inline |
Get current view's X dimension in device context units.
Usually this is equal to wxDC::GetSize, but it might differ thus mpLayer implementations should rely on the value returned by the function. See rules for coordinate transformation
|
inline |
Get current view's Y dimension in device context units.
Usually this is equal to wxDC::GetSize, but it might differ thus mpLayer implementations should rely on the value returned by the function. See rules for coordinate transformation
| mpFXYVector * mpWindow::GetXYSeries | ( | unsigned int | n, |
| const wxString & | name = _T("Serie "), |
||
| bool | create = true |
||
| ) |
Return the serie n If the serie not exist then create it
|
inline |
Checks whether the X/Y scale aspect is locked.
| TRUE | Locked |
| FALSE | Unlocked |
| mpInfoLayer * mpWindow::IsInsideInfoLayer | ( | const wxPoint & | point | ) |
Check if a given point is inside the area of a mpInfoLayer and eventually returns its pointer.
| point | The position to be checked |
| std::optional< int > mpWindow::IsInsideYAxis | ( | const wxPoint & | point | ) |
Check if a given point is inside the area of a visible Y-axis and returns its ID if so.
| point | The position to be checked |
| bool mpWindow::IsLayerVisible | ( | const wxString & | name | ) |
Check whether a layer with given name is visible.
| name | The layer name |
| bool mpWindow::IsLayerVisible | ( | const unsigned int | position | ) |
Check whether the layer at given position is visible.
| position | The layer position in layer list |
|
inline |
Checks if we are repainting.
| TRUE | |
| FALSE |
| bool mpWindow::IsYAxisUsed | ( | int | yAxisID | ) |
Check if a specific Y-axis exists or is used by any function
| yAxisID | ID of Y axis to check |
| void mpWindow::LockAspect | ( | bool | enable = true | ) |
Enable or disable X/Y scale aspect locking for the view.
|
protectedvirtual |
Context menu handler.
Create series from a data file.
The file is not formatted. For example a simple txt file or csv file First data is x abscissa and next is up to 9 ordinates Separator is : space or ; or tab
|
protectedvirtual |
Mouse handler for mouse motion (for pan)
Mouse leave the plot area.
|
inline |
|
inline |
| void mpWindow::RefreshLegend | ( | void | ) |
Flag for refresh legend
| bool mpWindow::SaveScreenshot | ( | const wxString & | filename, |
| int | type = wxBITMAP_TYPE_BMP, |
||
| wxSize | imageSize = wxDefaultSize, |
||
| bool | fit = false |
||
| ) |
Draw the window on a wxBitmap, then save it to a file.
| filename | File name where to save the screenshot |
| type | image type to be saved: see wxImage output file types for flags |
| imageSize | Set a size for the output image. Default is the same as the screen size |
| fit | Decide whether to fit the plot into the size |
| void mpWindow::SetBound | ( | ) |
Update bound for mpFX and mpFY when axis is scaled.
Deprecated: Incomplete, set bound only for mpFX and mpFY with one y-axis! Use UpdateBBox for complete set!
| void mpWindow::SetColourTheme | ( | const wxColour & | bgColour, |
| const wxColour & | drawColour, | ||
| const wxColour & | axesColour | ||
| ) |
Set Color theme.
Provide colours to set a new colour theme.
| bgColour | Background colour |
| drawColour | The colour used to draw all elements in foreground, axes excluded |
| axesColour | The colour used to draw axes (but not their labels) |
|
inline |
Set the draw of the box around the plot.
|
inline |
Set the extra margin.
| extra | Extra Margin |
| void mpWindow::SetLayerVisible | ( | const wxString & | name, |
| bool | viewable | ||
| ) |
Sets the visibility of a layer by its name.
| name | The layer name to set visibility |
| viewable | the view status to be set |
| void mpWindow::SetLayerVisible | ( | const unsigned int | position, |
| bool | viewable | ||
| ) |
Sets the visibility of a layer by its position in layer list.
| position | The layer position in layer list |
| viewable | the view status to be set |
|
inline |
Set the bottom margin.
| bottom | Bottom Margin |
|
inline |
Set the left margin.
| left | Left Margin |
|
inline |
Set the right margin.
| right | Right Margin |
| void mpWindow::SetMargins | ( | int | top, |
| int | right, | ||
| int | bottom, | ||
| int | left | ||
| ) |
Set window margins, creating a blank area where some kinds of layers cannot draw.
This is useful for example to draw axes outside the area where the plots are drawn.
| top | Top border |
| right | Right border |
| bottom | Bottom border |
| left | Left border |
|
inline |
Set the top margin.
| top | Top Margin |
|
inline |
Set the type of action for the left mouse button.
| Left | mouse button action |
| void mpWindow::SetMPScrollbars | ( | bool | status | ) |
Enable/disable scrollbars.
| status | Set to true to show scrollbars |
|
inline |
On delete layer event Allows the user to perform certain actions before deleting the layer.
The user can abort the deletion.
|
inline |
On user mouse action event Allows the user to perform certain actions before normal event processing.
The user has the possibility to interrupt or continue the normal processing of the event.
|
inline |
Set current view's X and Y position and refresh display.
| posX | New position that corresponds to the center point of the view. |
| posYList | New positions that corresponds to the center point of the view. IMPORTANT: posYList items must be in the same order of Y axis list |
|
inline |
Set current view's X position and refresh display.
| posX | New position that corresponds to the center point of the view. |
|
inline |
Set current view's Y position and refresh display.
| posYList | New position that corresponds to the center point of the view. IMPORTANT: posYList items must be in the same order of Y axis list |
|
inline |
Set current view's X scale and refresh display.
| scaleX | New scale, must not be 0. |
|
protected |
Set the m_scaleX directly to fixed zoom level, but also adjust m_posX to to make the zoom around center.
| scaleX | value |
|
inline |
Set current view's Y scale and refresh display.
| scaleY | New scale, must not be 0. |
| yAxisID | Y axis ID to set scale |
|
protected |
Set the m_scaleY directly to fixed zoom level, but also adjust m_posY to to make the zoom around center.
| scaleY | value |
| yAxisID | ID used to specify which Y-axis to set |
|
inline |
Set current view's dimensions in device context units.
Needed by plotting functions. It doesn't refresh display.
| scrX | New position that corresponds to the center point of the view. |
| scrY | New position that corresponds to the center point of the view. |
|
protectedvirtual |
Set bounding box 'm_bound' to contain all visible plots of this mpWindow.
|
inline |
Draws the mpWindow on a page for printing.
| the mpPrintout where to print the graph Update m_desired bounds. Store the min and max position of the visible data in the plot. Used primarily during frame resizing via OnSize so that the data stays in the same place when resizing the frame. Needs to be updated whenever m_posX, m_scaleX, m_posY or m_scaleY is updated. Check if there is some changes |
|
inline |
Update margins if e.g.
more axis have been added.
|
inline |
|
inline |
| void mpWindow::ZoomIn | ( | const wxPoint & | centerPoint = wxDefaultPosition | ) |
Zoom into current view and refresh display.
| centerPoint | The point (pixel coordinates) that will stay in the same position on the screen after the zoom (by default, the center of the mpWindow). |
| void mpWindow::ZoomInY | ( | std::optional< int > | yAxisID = std::nullopt | ) |
Zoom in current view along Y around center and refresh display.
| Optional | Y-axis ID used to specify which Y-axis to zoom |
| void mpWindow::ZoomOut | ( | const wxPoint & | centerPoint = wxDefaultPosition | ) |
Zoom out current view and refresh display.
| centerPoint | The point (pixel coordinates) that will stay in the same position on the screen after the zoom (by default, the center of the mpWindow). |
| void mpWindow::ZoomOutY | ( | std::optional< int > | yAxisID = std::nullopt | ) |
Zoom out current view along Y around center and refresh display.
| Optional | Y-axis ID used to specify which Y-axis to zoom |
|
static |
This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse wheel.
It must be a number above unity. This number is used for zoom in, and its inverse for zoom out. Set to 1.5 by default.
1.8.13