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

Canvas for plotting mpLayer implementations. More...

#include <mathplot.h>

Inheritance diagram for MathPlot::mpWindow:
Inheritance graph
[legend]
Collaboration diagram for MathPlot::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)
 Add a plot layer to the canvas. More...
 
bool DelLayer (mpLayer *layer, bool alsoDeleteObject, bool refreshDisplay=true)
 Remove a plot layer from the canvas. More...
 
void DelAllLayers (bool alsoDeleteObject, bool refreshDisplay=true)
 Remove all layers from the plot. More...
 
void DelAllPlot (bool alsoDeleteObject, mpFunctionType func=mpfAllType, bool refreshDisplay=true)
 Remove all plot layers. More...
 
mpLayerGetLayer (int position)
 
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, bool *isY2Axis)
 
mpLayerGetLayerByName (const wxString &name)
 
mpLayerGetLayerByClassName (const wxString &name)
 
void RefreshLegend (void)
 
mpScaleXGetLayerXAxis ()
 Get the first scale X layer (X axis) or NULL if not found. More...
 
mpScaleYGetLayerYAxis ()
 Get the first scale Y layer (Y axis) or NULL if not found. More...
 
mpScaleYGetLayerY2Axis ()
 Get the first scale Y2 layer (Y2 axis) 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)
 Set current view's Y scale and refresh display. More...
 
double GetScaleY (bool Y2=false) const
 Get current view's Y scale. More...
 
void SetBound ()
 Update bound for mpFX and mpFY when axis is scaled. More...
 
mpFloatRect Get_Bound (void) const
 Get bounding box encompassing all visible plots on this mpWindow. 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 double posY, const double posY2)
 Set current view's Y position and refresh display. More...
 
double GetPosY (bool Y2=false) const
 Get current view's Y position. More...
 
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 double posY, const double posY2)
 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, bool Y2=false) const
 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, bool Y2=false) const
 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 mpFloatRect &rect, wxCoord *printSizeX=NULL, wxCoord *printSizeY=NULL)
 Set view to fit a given bounding box and refresh display with UpdateAll(). 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 and refresh display.
 
void ZoomOutX ()
 Zoom out current view along X and refresh display.
 
void ZoomInY ()
 Zoom in current view along Y and refresh display.
 
void ZoomOutY ()
 Zoom out current view along Y and refresh display.
 
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 ()
 
mpFloatRect GetDesiredBoundingBox () const
 Draws the mpWindow on a page for printing. 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
 Returns 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 () const
 Returns 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 () const
 Returns 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...
 
void GetBoundingBox (double *bbox) const
 Returns the bounding box coordinates. More...
 
mpFloatRectGetBoundingBox (void)
 
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 SetMarginTop (int top)
 Set the top margin. More...
 
int GetMarginTop () const
 Get the top margin. More...
 
void SetMarginRight (int right)
 Set the right margin. More...
 
int GetMarginRight () const
 Get the right margin. More...
 
void SetMarginBottom (int bottom)
 Set the bottom margin. More...
 
int GetMarginBottom () const
 Get the bottom margin. More...
 
void SetMarginLeft (int left)
 Set the left margin. More...
 
int GetMarginLeft () const
 Get the left margin. 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...
 
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...
 
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 () const
 Log axis control. More...
 
bool IsLogYaxis () const
 
void SetLogXaxis (bool log)
 
void SetLogYaxis (bool log)
 
bool GetMagnetize () const
 
void SetMagnetize (bool mag)
 
void RefreshConfigWindow ()
 
MathPlotConfigDialogGetConfigWindow (bool Create=false)
 Give access to the config dialog window. More...
 
void Update_CountY2Axis (bool Y2Axis)
 
bool Y2AxisExist (void) const
 

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 OnConfiguration (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 DoZoomInXCalc (const int staticXpixel)
 
void DoZoomInYCalc (const int staticYpixel)
 
void DoZoomOutXCalc (const int staticXpixel)
 
void DoZoomOutYCalc (const int staticYpixel)
 
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.
 
mpScaleXm_XAxis
 Pointer to the optional X axis layer of this mpWindow.
 
mpScaleYm_YAxis
 Pointer to the optional Y axis layer of this mpWindow.
 
mpScaleYm_Y2Axis
 Pointer to the optional Y2 axis layer of this mpWindow.
 
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.
 
mpFloatRect m_bound
 Global layer bounding box in user coordinates. Does NOT include borders.
 
double m_scaleX
 Current view's X scale.
 
double m_scaleY
 Current view's Y scale.
 
double m_scaleY2
 Current view's Y2 scale.
 
double m_posX
 Current view's X position.
 
double m_posY
 Current view's Y position.
 
double m_posY2
 Current view's Y2 position.
 
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.
 
mpFloatRect m_desired
 These are updated in Fit() only (also Zoom) May be different from the real borders (layer coordinates) only if lock aspect ratio is true. More...
 
mpRect m_margin
 Margin around the plot. Default 50.
 
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 EXTRA_MARGIN.
 
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.
 
bool m_mouseMovedAfterRightClick
 
wxPoint m_mouseRClick
 For the right button "drag" feature.
 
wxPoint m_mouseLClick
 Starting coords for rectangular zoom selection.
 
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.
 
bool m_LogXaxis = false
 For logarithmic X axis.
 
bool m_LogYaxis = false
 For logarithmic X axis.
 
wxBitmap * m_Screenshot_bmp
 For clipboard, save and print.
 
MathPlotConfigDialogm_configWindow = NULL
 For the config dialog.
 
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 
)

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 refresh the display (UpdateAll) after adding the layer.
Return values
TRUESuccess
FALSEFailure due to out of memory.

◆ CountAllLayers()

unsigned int MathPlot::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 ( bool  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.

◆ DelAllPlot()

void mpWindow::DelAllPlot ( bool  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.

◆ DelLayer()

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

Remove a plot layer from the canvas.

Parameters
layerPointer to layer. The mpLayer object will be destructed using delete.
alsoDeleteObjectIf set to true, the mpLayer object will be also "deleted", not just removed from the internal list.
refreshDisplayStates whether to refresh the display (UpdateAll) after removing the layer.
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!

◆ DesiredBoundsHaveChanged()

virtual void MathPlot::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.

◆ 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 mpFloatRect rect,
wxCoord *  printSizeX = NULL,
wxCoord *  printSizeY = NULL 
)

Set view to fit a given bounding box and refresh display with UpdateAll().

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.

◆ Get_Bound()

mpFloatRect MathPlot::mpWindow::Get_Bound ( void  ) const
inline

Get bounding box encompassing all visible plots on this mpWindow.

◆ GetAxesColour()

const wxColour& MathPlot::mpWindow::GetAxesColour ( ) const
inline

Get axes draw colour.

Returns
reference to axis colour used in theme

◆ GetBoundingBox()

void mpWindow::GetBoundingBox ( double *  bbox) const

Returns the bounding box coordinates.

Parameters
bboxPointer to a 6-element double array where to store bounding box coordinates.

◆ GetClosestPlot()

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

Search the point of the layer plot nearest a point

◆ GetConfigWindow()

MathPlotConfigDialog * mpWindow::GetConfigWindow ( bool  Create = false)

Give access to the config dialog window.

Parameters
Create. Create the dialog if not exist (default false)

◆ GetDesiredBoundingBox()

mpFloatRect MathPlot::mpWindow::GetDesiredBoundingBox ( ) const
inline

Draws the mpWindow on a page for printing.

Parameters
printthe mpPrintout where to print the graph Get the 'desired' user-coordinate bounding box for the currently displayed view (set by Fit or Zoom operations).
See also
Fit, Zoom

◆ GetDesiredXmax()

double MathPlot::mpWindow::GetDesiredXmax ( ) const
inline

Returns 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 MathPlot::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 MathPlot::mpWindow::GetDesiredYmax ( ) const
inline

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

See also
Fit, Zoom

◆ GetDesiredYmin()

double MathPlot::mpWindow::GetDesiredYmin ( ) const
inline

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

See also
Fit, Zoom

◆ GetDrawBox()

bool MathPlot::mpWindow::GetDrawBox ( ) const
inline

Get the draw of the box around the plot.

◆ 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

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

◆ GetLayerY2Axis()

mpScaleY * mpWindow::GetLayerY2Axis ( )

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

Get the first scale Y2 layer (Y2 axis).

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

◆ GetLayerYAxis()

mpScaleY * mpWindow::GetLayerYAxis ( )

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

Get the first scale Y layer (Y axis).

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

◆ GetMarginBottom()

int MathPlot::mpWindow::GetMarginBottom ( ) const
inline

Get the bottom margin.

Parameters
bottomBottom Margin

◆ GetMarginLeft()

int MathPlot::mpWindow::GetMarginLeft ( ) const
inline

Get the left margin.

Parameters
leftLeft Margin

◆ GetMarginRight()

int MathPlot::mpWindow::GetMarginRight ( ) const
inline

Get the right margin.

Parameters
rightRight Margin

◆ GetMarginTop()

int MathPlot::mpWindow::GetMarginTop ( ) const
inline

Get the top margin.

Parameters
topTop Margin

◆ GetMPScrollbars()

bool MathPlot::mpWindow::GetMPScrollbars ( ) const
inline

Get scrollbars status.

Returns
true if scrollbars are visible

◆ GetPlotBoundaries()

mpRect MathPlot::mpWindow::GetPlotBoundaries ( bool  with_margin) const
inline

Get the boundaries of the plot.

◆ GetPlotHeight()

int MathPlot::mpWindow::GetPlotHeight ( ) const
inline

Get the height of the plot.

◆ GetPlotWidth()

int MathPlot::mpWindow::GetPlotWidth ( ) const
inline

Get the width of the plot.

◆ GetPopupMenu()

wxMenu* MathPlot::mpWindow::GetPopupMenu ( )
inline

Get reference to context menu of the plot canvas.

Returns
Pointer to menu. The menu can be modified.

◆ GetPosX()

double MathPlot::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 MathPlot::mpWindow::GetPosY ( bool  Y2 = false) const
inline

Get current view's Y position.

See rules for coordinate transformation

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

◆ GetScaleX()

double MathPlot::mpWindow::GetScaleX ( void  ) const
inline

Get current view's X scale.

See rules for coordinate transformation

Returns
Scale

◆ GetScaleY()

double MathPlot::mpWindow::GetScaleY ( bool  Y2 = false) const
inline

Get current view's Y scale.

See rules for coordinate transformation

Returns
Scale

◆ GetScreenX()

int MathPlot::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 MathPlot::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 MathPlot::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

◆ 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

◆ IsLogXaxis()

bool MathPlot::mpWindow::IsLogXaxis ( ) const
inline

Log axis control.

It is an axis property but as we need to control the bound and the scale, it is easiest to declare this property here

◆ IsRepainting()

bool MathPlot::mpWindow::IsRepainting ( ) const
inline

Checks if we are repainting.

Return values
TRUE
FALSE

◆ 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 MathPlot::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 MathPlot::mpWindow::p2y ( const wxCoord  pixelCoordY,
bool  Y2 = false 
) const
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! Use UpdateBBox!

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 MathPlot::mpWindow::SetDrawBox ( bool  drawbox)
inline

Set the draw of the box around the plot.

◆ 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 MathPlot::mpWindow::SetMarginBottom ( int  bottom)
inline

Set the bottom margin.

Parameters
bottomBottom Margin

◆ SetMarginLeft()

void MathPlot::mpWindow::SetMarginLeft ( int  left)
inline

Set the left margin.

Parameters
leftLeft Margin

◆ SetMarginRight()

void MathPlot::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 MathPlot::mpWindow::SetMarginTop ( int  top)
inline

Set the top margin.

Parameters
topTop Margin

◆ SetMPScrollbars()

void mpWindow::SetMPScrollbars ( bool  status)

Enable/disable scrollbars.

Parameters
statusSet to true to show scrollbars

◆ SetOnDeleteLayer()

void MathPlot::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 MathPlot::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 MathPlot::mpWindow::SetPos ( const double  posX,
const double  posY,
const double  posY2 
)
inline

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

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

◆ SetPosX()

void MathPlot::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 MathPlot::mpWindow::SetPosY ( const double  posY,
const double  posY2 
)
inline

Set current view's Y position and refresh display.

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

◆ SetScaleX()

void MathPlot::mpWindow::SetScaleX ( const double  scaleX)
inline

Set current view's X scale and refresh display.

Parameters
scaleXNew scale, must not be 0.

◆ SetScaleY()

void MathPlot::mpWindow::SetScaleY ( const double  scaleY)
inline

Set current view's Y scale and refresh display.

Parameters
scaleYNew scale, must not be 0.

◆ SetScreen()

void MathPlot::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.

◆ x2p()

wxCoord MathPlot::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 MathPlot::mpWindow::y2p ( const double  y,
bool  Y2 = false 
) const
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).

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

Member Data Documentation

◆ m_desired

mpFloatRect MathPlot::mpWindow::m_desired
protected

These are updated in Fit() only (also Zoom) May be different from the real borders (layer coordinates) only if lock aspect ratio is true.

ToDo: Set in Zoom, Fit(mpFloatRect), used in scrolling and?

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