MathPlot
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
mpWindow Class Reference

Canvas for plotting mpLayer implementations. More...

#include <mathplot.h>

Inheritance diagram for mpWindow:
Inheritance graph
[legend]
Collaboration diagram for mpWindow:
Collaboration graph
[legend]

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...
 
mpLayerGetLayer (int position)
 
int GetLayerPosition (mpLayer *layer)
 
mpLayerGetLayersType (int position, mpLayerType type)
 
mpLayerGetLayerPlot (int position, mpFunctionType func=mpfAllType)
 
mpLayerGetLayerAxis (int position, mpScaleType scale=mpsAllType)
 
mpFXYVectorGetXYSeries (unsigned int n, const wxString &name=_T("Serie "), bool create=true)
 
mpLayerGetClosestPlot (wxCoord ix, wxCoord iy, double *xnear, double *ynear)
 
mpLayerGetLayerByName (const wxString &name)
 
mpLayerGetLayerByClassName (const wxString &name)
 
void RefreshLegend (void)
 
bool IsYAxisUsed (int yAxisID)
 
mpScaleXGetLayerXAxis ()
 Get the first scale X layer (X axis) or NULL if not found. More...
 
mpScaleYGetLayerYAxis (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 &centerPoint=wxDefaultPosition)
 Zoom into current view and refresh display. More...
 
void ZoomOut (const wxPoint &centerPoint=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...
 
mpInfoLayerIsInsideInfoLayer (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 &centerPoint)
 
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
 
mpInfoLayerm_movingInfoLayer
 For moving info layers over the window area.
 
mpInfoCoordsm_InfoCoords
 pointer to the optional info coords layer
 
mpInfoLegendm_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.
 

Detailed Description

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:

Member Function Documentation

◆ AddLayer()

bool mpWindow::AddLayer ( mpLayer layer,
bool  refreshDisplay = true,
bool  refreshConfig = true 
)

Add a plot layer to the canvas.

Parameters
layerPointer to layer. The mpLayer object will get under control of mpWindow, i.e. it will be delete'd on mpWindow destruction
refreshDisplayStates whether to fit and refresh the display (UpdateAll) after adding the layer.
refreshConfigStates whether to refresh the config window (if exist)
Return values
TRUESuccess
FALSEFailure. layer = NULL or layer already exist (Coords or Legend).

◆ CountAllLayers()

unsigned int mpWindow::CountAllLayers ( )
inline

Counts the number of plot layers, whether or not they have a bounding box.

Returns
The number of layers in the mpWindow.

◆ CountLayers()

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.

Returns
The number of profiles plotted.

◆ CountLayersType()

unsigned int mpWindow::CountLayersType ( mpLayerType  type)

Counts the number of plot layers: this is to count only the layers which have a plot.

Returns
The number of profiles plotted.

◆ DelAllLayers()

void mpWindow::DelAllLayers ( mpDeleteAction  alsoDeleteObject,
bool  refreshDisplay = true 
)

Remove all layers from the plot.

Parameters
alsoDeleteObjectIf set to true, the mpLayer objects will be also "deleted", not just removed from the internal list.
refreshDisplayStates whether to refresh the display (UpdateAll) after removing the layers. See DelLayer() for more infos

◆ DelAllPlot()

void mpWindow::DelAllPlot ( mpDeleteAction  alsoDeleteObject,
mpFunctionType  func = mpfAllType,
bool  refreshDisplay = true 
)

Remove all plot layers.

Parameters
alsoDeleteObjectIf set to true, the mpLayer objects will be also "deleted", not just removed from the internal list.
funcSelect type of plot
refreshDisplayStates whether to refresh the display (UpdateAll) after removing the layers. See DelLayer() for more infos

◆ DelAllYAxisAfterID()

void mpWindow::DelAllYAxisAfterID ( mpDeleteAction  alsoDeleteObject,
int  yAxisID = 0,
bool  refreshDisplay = true 
)

Remove all extra y axis after the selected y axis.

Parameters
alsoDeleteObjectIf set to true, the mpLayer objects will be also "deleted", not just removed from the internal list.
yAxisIDthe ID of the axis to keep (Default 0). Remove all y axis after this ID. If y-axis ID < 0, remove all y axis.
refreshDisplayStates whether to refresh the display (UpdateAll) after removing the layers. See DelLayer() for more infos

◆ DelLayer()

bool mpWindow::DelLayer ( mpLayer layer,
mpDeleteAction  alsoDeleteObject,
bool  refreshDisplay = true,
bool  refreshConfig = true 
)

Remove a plot layer from the canvas.

Parameters
layerPointer to layer. The mpLayer object will be destructed using delete.
alsoDeleteObjectIf 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
refreshDisplayStates whether to refresh the display (UpdateAll) after removing the layer.
refreshConfigStates whether to refresh the config window (if exist)
Returns
true if layer is deleted correctly

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.

◆ DesiredBoundsHaveChanged()

virtual void mpWindow::DesiredBoundsHaveChanged ( )
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.

◆ DoZoomXCalc()

void mpWindow::DoZoomXCalc ( bool  zoomIn,
wxCoord  staticXpixel = -1 
)
protected

Zoom in or out X around a X position.

Is the position is not set, it will zoom around center.

Parameters
Zoomin or zoom out boolean
Optionalcenter position

◆ DoZoomYCalc()

void mpWindow::DoZoomYCalc ( bool  zoomIn,
wxCoord  staticYpixel = -1,
std::optional< int >  yAxisID = std::nullopt 
)
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

Parameters
Zoomin or zoom out boolean
Optionalcenter position
OptionalY-axis ID used to specify which Y-axis to zoom

◆ Fit() [1/2]

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.

◆ Fit() [2/2]

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.

◆ FitX()

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

◆ FitY()

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

Parameters
yAxisIDindicating which Y-axis to fit

◆ Get_BoundX()

mpRange mpWindow::Get_BoundX ( void  ) const
inline

Get bounding box for X axis.

◆ Get_BoundY()

mpRange mpWindow::Get_BoundY ( int  yAxisID)
inline

Get bounding box for Y axis of ID yAxisID.

Parameters
yAxisIDY axis ID to get bound

◆ GetAxesColour()

const wxColour& mpWindow::GetAxesColour ( ) const
inline

Get axes draw colour.

Returns
reference to axis colour used in theme

◆ GetBoundingBox()

mpFloatRectSimple mpWindow::GetBoundingBox ( bool  desired,
unsigned int  yAxisID = 0 
)
inline

Return a bounding box for an y-axis ID.

Parameters
desiredif true return desired bound else return bound desired yAxisID: the y-axis ID (default 0)

◆ GetClosestPlot()

mpLayer * mpWindow::GetClosestPlot ( wxCoord  ix,
wxCoord  iy,
double *  xnear,
double *  ynear 
)

Search the point of the layer plot nearest a point

◆ GetDesiredXmax()

double mpWindow::GetDesiredXmax ( ) const
inline

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).

See also
Fit, Zoom

◆ GetDesiredXmin()

double mpWindow::GetDesiredXmin ( ) const
inline

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).

See also
Fit, Zoom

◆ GetDesiredYmax()

double mpWindow::GetDesiredYmax ( int  yAxisID)
inline

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).

Parameters
yAxisIDY axis ID to get desired max
See also
Fit, Zoom

◆ GetDesiredYmin()

double mpWindow::GetDesiredYmin ( int  yAxisID)
inline

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).

Parameters
yAxisIDY axis ID to get desired min
See also
Fit, Zoom

◆ GetDrawBox()

bool mpWindow::GetDrawBox ( ) const
inline

Get the draw of the box around the plot.

◆ GetExtraMargin()

int mpWindow::GetExtraMargin ( ) const
inline

Get the extra margin.

◆ GetLayer()

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!

Parameters
positionposition of the layer in the layers list
Returns
pointer to mpLayer

◆ GetLayerAxis()

mpLayer * mpWindow::GetLayerAxis ( int  position,
mpScaleType  scale = mpsAllType 
)

Get the layer axis in list position indicated.

◆ GetLayerByClassName()

mpLayer * mpWindow::GetLayerByClassName ( const wxString &  name)

Get the first layer by its class name (case sensitive).

Parameters
nameThe class name of the layer to retrieve
Returns
A pointer to the mpLayer object, or NULL if not found.

◆ GetLayerByName()

mpLayer * mpWindow::GetLayerByName ( const wxString &  name)

Get the layer by its name (case sensitive).

Parameters
nameThe name of the layer to retrieve
Returns
A pointer to the mpLayer object, or NULL if not found.

◆ GetLayerPlot()

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!

Parameters
positionposition of the layer plot in the layers plot list
Returns
pointer to mpLayer

◆ GetLayerPosition()

int mpWindow::GetLayerPosition ( mpLayer layer)

Get the position of the layer in the list.

Parameters
layerthe layer to find
Returns
the position of the layer or -1 if not found

◆ GetLayersType()

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!

Parameters
positionposition of the layer in the layers list
typeof the layer
Returns
pointer to mpLayer

◆ GetLayerXAxis()

mpScaleX * mpWindow::GetLayerXAxis ( )

Get the first scale X layer (X axis) or NULL if not found.

Get the first scale X layer (X axis).

Returns
A pointer to the mpScaleX object, or NULL if not found.

◆ GetLayerYAxis()

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

Returns
A pointer to the mpScaleY object, or NULL if not found.

◆ GetLeftYAxesWidth()

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

Parameters
indexof this y-axis

◆ GetMagnetize()

bool mpWindow::GetMagnetize ( ) const
inline

Magnetize the position of the mouse in the plot ie draw a vertical and horizontal line.

Useful to read the position on axis.

Parameters
mag. if true magnetize the mouse

◆ GetMarginBottom()

int mpWindow::GetMarginBottom ( bool  minusExtra = false) const
inline

Get the bottom margin.

Parameters
minusExtra(default false): return bottom margin minus extra margin

◆ GetMarginLeft()

int mpWindow::GetMarginLeft ( bool  minusExtra = false) const
inline

Get the left margin.

Parameters
minusExtra(default false): return left margin minus extra margin

◆ GetMarginLeftOuter()

int mpWindow::GetMarginLeftOuter ( ) const
inline

Get the left outer margin, exluding Y-axis.

◆ GetMarginRight()

int mpWindow::GetMarginRight ( bool  minusExtra = false) const
inline

Get the right margin.

Parameters
minusExtra(default false): return right margin minus extra margin

◆ GetMarginRightOuter()

int mpWindow::GetMarginRightOuter ( ) const
inline

Get the right outer margin, exluding Y-axis.

◆ GetMarginTop()

int mpWindow::GetMarginTop ( bool  minusExtra = false) const
inline

Get the top margin.

Parameters
minusExtra(default false): return top margin minus extra margin

◆ GetMouseLeftDownAction()

mpMouseButtonAction mpWindow::GetMouseLeftDownAction ( )
inline

Returns the type of action for the left mouse button.

Returns
Left mouse button action

◆ GetMPScrollbars()

bool mpWindow::GetMPScrollbars ( ) const
inline

Get scrollbars status.

Returns
true if scrollbars are visible

◆ GetNOfYAxis()

int mpWindow::GetNOfYAxis ( void  ) const
inline

Get the number of Y axis.

Returns
The number of Y axis in m_AxisDataYList

◆ GetPlotBoundaries()

mpRect mpWindow::GetPlotBoundaries ( bool  with_margin) const
inline

Get the boundaries of the plot.

Bond is reduced by m_extraMargin constant

Parameters
with_margininclude margin if true

◆ GetPlotHeight()

int mpWindow::GetPlotHeight ( ) const
inline

Get the height of the plot.

◆ GetPlotWidth()

int mpWindow::GetPlotWidth ( ) const
inline

Get the width of the plot.

◆ GetPopupMenu()

wxMenu* mpWindow::GetPopupMenu ( )
inline

Get reference to context menu of the plot canvas.

Returns
Pointer to menu. The menu can be modified.

◆ GetPosX()

double mpWindow::GetPosX ( void  ) const
inline

Get current view's X position.

See rules for coordinate transformation

Returns
X Position in layer coordinate system, that corresponds to the center point of the view.

◆ GetPosY()

double mpWindow::GetPosY ( int  yAxisID)
inline

Get current view's Y position.

See rules for coordinate transformation

Parameters
yAxisIDY axis ID to get Pos
Returns
Y Position in layer coordinate system, that corresponds to the center point of the view.

◆ GetRightYAxesWidth()

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

Parameters
indexof this y-axis

◆ GetScaleX()

double mpWindow::GetScaleX ( void  ) const
inline

Get current view's X scale.

See rules for coordinate transformation

Returns
Scale

◆ GetScaleY()

double mpWindow::GetScaleY ( int  yAxisID)
inline

Get current view's Y scale.

See rules for coordinate transformation

Parameters
yAxisIDY axis ID to get scale
Returns
Scale

◆ GetScreenX()

int mpWindow::GetScreenX ( void  ) const
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

Returns
X dimension.

◆ GetScreenY()

int mpWindow::GetScreenY ( void  ) const
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

Returns
Y dimension.

◆ GetXYSeries()

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

◆ IsAspectLocked()

bool mpWindow::IsAspectLocked ( ) const
inline

Checks whether the X/Y scale aspect is locked.

Return values
TRUELocked
FALSEUnlocked

◆ IsInsideInfoLayer()

mpInfoLayer * mpWindow::IsInsideInfoLayer ( const wxPoint &  point)

Check if a given point is inside the area of a mpInfoLayer and eventually returns its pointer.

Parameters
pointThe position to be checked
Returns
If an info layer is found, returns its pointer, NULL otherwise

◆ IsInsideYAxis()

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.

Parameters
pointThe position to be checked
Returns
If the point is inside a Y-Axis, returns its ID, otherwise -1

◆ IsLayerVisible() [1/2]

bool mpWindow::IsLayerVisible ( const wxString &  name)

Check whether a layer with given name is visible.

Parameters
nameThe layer name
Returns
layer visibility status

◆ IsLayerVisible() [2/2]

bool mpWindow::IsLayerVisible ( const unsigned int  position)

Check whether the layer at given position is visible.

Parameters
positionThe layer position in layer list
Returns
layer visibility status

◆ IsRepainting()

bool mpWindow::IsRepainting ( ) const
inline

Checks if we are repainting.

Return values
TRUE
FALSE

◆ IsYAxisUsed()

bool mpWindow::IsYAxisUsed ( int  yAxisID)

Check if a specific Y-axis exists or is used by any function

Parameters
yAxisIDID of Y axis to check
Returns
True if specified Y-axis is used, false otherwise

◆ LockAspect()

void mpWindow::LockAspect ( bool  enable = true)

Enable or disable X/Y scale aspect locking for the view.

Note
Explicit calls to mpWindow::SetScaleX and mpWindow::SetScaleY will set an unlocked aspect, but any other action changing the view scale will lock the aspect again.

◆ OnLoadFile()

void mpWindow::OnLoadFile ( wxCommandEvent &  event)
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

◆ OnMouseLeave()

void mpWindow::OnMouseLeave ( wxMouseEvent &  event)
protectedvirtual

Mouse handler for mouse motion (for pan)

Mouse leave the plot area.

◆ p2x()

double mpWindow::p2x ( const wxCoord  pixelCoordX) const
inline

Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.

See also
p2y,x2p,y2p

◆ p2y()

double mpWindow::p2y ( const wxCoord  pixelCoordY,
int  yAxisID = 0 
)
inline

Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.

See also
p2x,x2p,y2p

◆ RefreshLegend()

void mpWindow::RefreshLegend ( void  )

Flag for refresh legend

◆ SaveScreenshot()

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.

Parameters
filenameFile name where to save the screenshot
typeimage type to be saved: see wxImage output file types for flags
imageSizeSet a size for the output image. Default is the same as the screen size
fitDecide whether to fit the plot into the size

◆ SetBound()

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!

Deprecated:
Incomplete! Use UpdateBBox!

◆ SetColourTheme()

void mpWindow::SetColourTheme ( const wxColour &  bgColour,
const wxColour &  drawColour,
const wxColour &  axesColour 
)

Set Color theme.

Provide colours to set a new colour theme.

Parameters
bgColourBackground colour
drawColourThe colour used to draw all elements in foreground, axes excluded
axesColourThe colour used to draw axes (but not their labels)

◆ SetDrawBox()

void mpWindow::SetDrawBox ( bool  drawbox)
inline

Set the draw of the box around the plot.

◆ SetExtraMargin()

void mpWindow::SetExtraMargin ( int  extra)
inline

Set the extra margin.

Parameters
extraExtra Margin

◆ SetLayerVisible() [1/2]

void mpWindow::SetLayerVisible ( const wxString &  name,
bool  viewable 
)

Sets the visibility of a layer by its name.

Parameters
nameThe layer name to set visibility
viewablethe view status to be set

◆ SetLayerVisible() [2/2]

void mpWindow::SetLayerVisible ( const unsigned int  position,
bool  viewable 
)

Sets the visibility of a layer by its position in layer list.

Parameters
positionThe layer position in layer list
viewablethe view status to be set

◆ SetMarginBottom()

void mpWindow::SetMarginBottom ( int  bottom)
inline

Set the bottom margin.

Parameters
bottomBottom Margin

◆ SetMarginLeft()

void mpWindow::SetMarginLeft ( int  left)
inline

Set the left margin.

Parameters
leftLeft Margin

◆ SetMarginRight()

void mpWindow::SetMarginRight ( int  right)
inline

Set the right margin.

Parameters
rightRight Margin

◆ SetMargins()

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.

Parameters
topTop border
rightRight border
bottomBottom border
leftLeft border

◆ SetMarginTop()

void mpWindow::SetMarginTop ( int  top)
inline

Set the top margin.

Parameters
topTop Margin

◆ SetMouseLeftDownAction()

void mpWindow::SetMouseLeftDownAction ( mpMouseButtonAction  action)
inline

Set the type of action for the left mouse button.

Parameters
Leftmouse button action

◆ SetMPScrollbars()

void mpWindow::SetMPScrollbars ( bool  status)

Enable/disable scrollbars.

Parameters
statusSet to true to show scrollbars

◆ SetOnDeleteLayer()

void mpWindow::SetOnDeleteLayer ( const mpOnDeleteLayer event)
inline

On delete layer event Allows the user to perform certain actions before deleting the layer.

The user can abort the deletion.

◆ SetOnUserMouseAction()

void mpWindow::SetOnUserMouseAction ( const mpOnUserMouseAction userMouseEventHandler)
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.

◆ SetPos()

void mpWindow::SetPos ( const double  posX,
const std::vector< double > &  posYList 
)
inline

Set current view's X and Y position and refresh display.

Parameters
posXNew position that corresponds to the center point of the view.
posYListNew positions that corresponds to the center point of the view. IMPORTANT: posYList items must be in the same order of Y axis list

◆ SetPosX()

void mpWindow::SetPosX ( const double  posX)
inline

Set current view's X position and refresh display.

Parameters
posXNew position that corresponds to the center point of the view.

◆ SetPosY()

void mpWindow::SetPosY ( const std::vector< double > &  posYList)
inline

Set current view's Y position and refresh display.

Parameters
posYListNew position that corresponds to the center point of the view. IMPORTANT: posYList items must be in the same order of Y axis list

◆ SetScaleX()

void mpWindow::SetScaleX ( const double  scaleX)
inline

Set current view's X scale and refresh display.

Parameters
scaleXNew scale, must not be 0.

◆ SetScaleXAndCenter()

void mpWindow::SetScaleXAndCenter ( double  scaleX)
protected

Set the m_scaleX directly to fixed zoom level, but also adjust m_posX to to make the zoom around center.

Parameters
scaleXvalue

◆ SetScaleY()

void mpWindow::SetScaleY ( const double  scaleY,
int  yAxisID 
)
inline

Set current view's Y scale and refresh display.

Parameters
scaleYNew scale, must not be 0.
yAxisIDY axis ID to set scale

◆ SetScaleYAndCenter()

void mpWindow::SetScaleYAndCenter ( double  scaleY,
int  yAxisID 
)
protected

Set the m_scaleY directly to fixed zoom level, but also adjust m_posY to to make the zoom around center.

Parameters
scaleYvalue
yAxisIDID used to specify which Y-axis to set

◆ SetScreen()

void mpWindow::SetScreen ( const int  scrX,
const int  scrY 
)
inline

Set current view's dimensions in device context units.

Needed by plotting functions. It doesn't refresh display.

Parameters
scrXNew position that corresponds to the center point of the view.
scrYNew position that corresponds to the center point of the view.

◆ UpdateBBox()

bool mpWindow::UpdateBBox ( )
protectedvirtual

Set bounding box 'm_bound' to contain all visible plots of this mpWindow.

Returns
true if there valid bounding box set in m_bounds.

◆ UpdateDesiredBoundingBox()

void mpWindow::UpdateDesiredBoundingBox ( mpAxisUpdate  update)
inline

Draws the mpWindow on a page for printing.

Parameters
printthe 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

◆ UpdateMargins()

void mpWindow::UpdateMargins ( )
inline

Update margins if e.g.

more axis have been added.

◆ x2p()

wxCoord mpWindow::x2p ( const double  x) const
inline

Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.

See also
p2x,p2y,y2p

◆ y2p()

wxCoord mpWindow::y2p ( const double  y,
int  yAxisID = 0 
)
inline

Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.

See also
p2x,p2y,x2p

◆ ZoomIn()

void mpWindow::ZoomIn ( const wxPoint &  centerPoint = wxDefaultPosition)

Zoom into current view and refresh display.

Parameters
centerPointThe point (pixel coordinates) that will stay in the same position on the screen after the zoom (by default, the center of the mpWindow).

◆ ZoomInY()

void mpWindow::ZoomInY ( std::optional< int >  yAxisID = std::nullopt)

Zoom in current view along Y around center and refresh display.

Parameters
OptionalY-axis ID used to specify which Y-axis to zoom

◆ ZoomOut()

void mpWindow::ZoomOut ( const wxPoint &  centerPoint = wxDefaultPosition)

Zoom out current view and refresh display.

Parameters
centerPointThe point (pixel coordinates) that will stay in the same position on the screen after the zoom (by default, the center of the mpWindow).

◆ ZoomOutY()

void mpWindow::ZoomOutY ( std::optional< int >  yAxisID = std::nullopt)

Zoom out current view along Y around center and refresh display.

Parameters
OptionalY-axis ID used to specify which Y-axis to zoom

Member Data Documentation

◆ m_zoomIncrementalFactor

double mpWindow::m_zoomIncrementalFactor = 1.5
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.