KiCad PCB EDA Suite
Loading...
Searching...
No Matches
mpWindow Class Reference

Canvas for plotting mpLayer implementations. More...

#include <mathplot.h>

Inheritance diagram for mpWindow:

Classes

struct  DelegatingContructorTag
 
struct  MouseWheelActionSet
 Contains the set of modified mouse wheel actions that can be performed on the plot. More...
 

Public Types

enum class  MouseWheelAction {
  NONE , PAN_LEFT_RIGHT , PAN_RIGHT_LEFT , PAN_UP_DOWN ,
  ZOOM , ZOOM_HORIZONTALLY , ZOOM_VERTICALLY , COUNT
}
 Enumerates the possible mouse wheel actions that can be performed on the plot. More...
 

Public Member Functions

 mpWindow ()
 
 mpWindow (wxWindow *parent, wxWindowID id)
 
 ~mpWindow ()
 
wxMenu * GetPopupMenu ()
 Get reference to context menu of the plot canvas.
 
bool AddLayer (mpLayer *layer, bool refreshDisplay=true)
 Add a plot layer to the canvas.
 
bool DelLayer (mpLayer *layer, bool alsoDeleteObject=false, bool refreshDisplay=true)
 Remove a plot layer from the canvas.
 
void DelAllLayers (bool alsoDeleteObject, bool refreshDisplay=true)
 Remove all layers from the plot.
 
mpLayerGetLayer (int position) const
 
const mpLayerGetLayerByName (const wxString &name) const
 
mpLayerGetLayerByName (const wxString &name)
 
double GetScaleX () const
 Get current view's X scale.
 
double GetScaleY () const
 Get current view's Y scale.
 
double GetPosX () const
 Get current view's X position.
 
double GetPosY () const
 Get current view's Y position.
 
int GetScrX () const
 Get current view's X dimension in device context units.
 
int GetXScreen () const
 
int GetScrY () const
 Get current view's Y dimension in device context units.
 
int GetYScreen () const
 
void SetScaleX (double scaleX)
 Set current view's X scale and refresh display.
 
void SetScaleY (double scaleY)
 Set current view's Y scale and refresh display.
 
void SetPosX (double posX)
 Set current view's X position and refresh display.
 
void SetPosY (double posY)
 Set current view's Y position and refresh display.
 
void SetPos (double posX, double posY)
 Set current view's X and Y position and refresh display.
 
void SetScr (int scrX, int scrY)
 Set current view's dimensions in device context units.
 
double p2x (wxCoord pixelCoordX)
 Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
 
double p2y (wxCoord pixelCoordY)
 Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
 
wxCoord x2p (double x)
 Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.
 
wxCoord y2p (double y)
 Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.
 
void EnableDoubleBuffer (bool enabled)
 Enable/disable the double-buffering of the window, eliminating the flicker (default=disabled).
 
void EnableMousePanZoom (bool enabled)
 Enable/disable the feature of pan/zoom with the mouse (default=enabled)
 
void SetMouseWheelActions (const MouseWheelActionSet &s)
 Set the pan/zoom actions corresponding to mousewheel/trackpad events.
 
void Fit () override
 Set view to fit global bounding box of all plot layers and refresh display.
 
void Fit (double xMin, double xMax, double yMin, double yMax, const wxCoord *printSizeX=nullptr, const wxCoord *printSizeY=nullptr, wxOrientation directions=wxBOTH)
 Set view to fit a given bounding box and refresh display.
 
void ZoomIn (const wxPoint &centerPoint=wxDefaultPosition)
 Zoom into current view and refresh display.
 
void ZoomIn (const wxPoint &centerPoint, double zoomFactor, wxOrientation directions=wxBOTH)
 
void ZoomOut (const wxPoint &centerPoint=wxDefaultPosition)
 Zoom out current view and refresh display.
 
void ZoomOut (const wxPoint &centerPoint, double zoomFactor, wxOrientation directions=wxBOTH)
 
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 CountAllLayers () const
 Counts the number of plot layers, whether or not they have a bounding box.
 
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).
 
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).
 
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).
 
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).
 
void GetBoundingBox (double *bbox) const
 Returns the bounding box coordinates.
 
bool SaveScreenshot (wxImage &aImage, wxSize aImageSize=wxDefaultSize, bool aFit=false)
 Draw the window on a wxBitmap, then save it to a file.
 
void SetMargins (int top, int right, int bottom, int left)
 Set window margins, creating a blank area where some kinds of layers cannot draw.
 
void SetMarginTop (int top)
 Set the top margin.
 
void SetMarginRight (int right)
 Set the right margin.
 
void SetMarginBottom (int bottom)
 Set the bottom margin.
 
void SetMarginLeft (int left)
 Set the left margin.
 
int GetMarginTop () const
 
int GetMarginRight () const
 
int GetMarginBottom () const
 
int GetMarginLeft () const
 
mpInfoLayerIsInsideInfoLayer (wxPoint &point)
 Check if a given point is inside the area of a mpInfoLayer and eventually returns its pointer.
 
void SetLayerVisible (const wxString &name, bool viewable)
 Sets the visibility of a layer by its name.
 
bool IsLayerVisible (const wxString &name) const
 Check whether a layer with given name is visible.
 
void SetLayerVisible (const unsigned int position, bool viewable)
 Sets the visibility of a layer by its position in layer list.
 
bool IsLayerVisible (unsigned int position) const
 Check whether the layer at given position is visible.
 
void SetColourTheme (const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour)
 Set Color theme.
 
const wxColour & GetAxesColour ()
 Get axes draw colour.
 
void LimitView (bool aEnable)
 Enable limiting of zooming & panning to the area used by the plots.
 
void LockY (bool aLock)
 
bool GetYLocked () const
 
void ZoomUndo ()
 
void ZoomRedo ()
 
int UndoZoomStackSize () const
 
int RedoZoomStackSize () const
 
void AdjustLimitedView (wxOrientation directions=wxBOTH)
 Limits the zoomed or panned view to the area used by the plots.
 
void OnFit (wxCommandEvent &event)
 
void OnCenter (wxCommandEvent &event)
 

Static Public Attributes

static double zoomIncrementalFactor = 1.1
 This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse wheel.
 

Protected Member Functions

void pushZoomUndo (const std::array< double, 4 > &aZoom)
 
void OnPaint (wxPaintEvent &event)
 
void OnSize (wxSizeEvent &event)
 
void OnShowPopupMenu (wxMouseEvent &event)
 
void OnMouseMiddleDown (wxMouseEvent &event)
 
void onZoomIn (wxCommandEvent &event)
 
void onZoomOut (wxCommandEvent &event)
 
void onZoomUndo (wxCommandEvent &event)
 
void onZoomRedo (wxCommandEvent &event)
 
void onMouseWheel (wxMouseEvent &event)
 
void onMagnify (wxMouseEvent &event)
 
void onMouseMove (wxMouseEvent &event)
 
void onMouseLeftDown (wxMouseEvent &event)
 
void onMouseLeftRelease (wxMouseEvent &event)
 
void DoZoom (const wxPoint &centerPoint, double zoomFactor, wxOrientation directions)
 
void RecomputeDesiredX (double &min, double &max)
 
void RecomputeDesiredY (double &min, double &max)
 
wxOrientation ViewNeedsRefitting (wxOrientation directions) const
 
void PerformMouseWheelAction (wxMouseEvent &event, MouseWheelAction action)
 
virtual bool UpdateBBox ()
 Recalculate global layer bounding box, and save it in m_minX,...
 
virtual bool SetXView (double pos, double desiredMax, double desiredMin)
 Applies new X view coordinates depending on the settings.
 
virtual bool SetYView (double pos, double desiredMax, double desiredMin)
 Applies new Y view coordinates depending on the settings.
 

Static Protected Member Functions

static MouseWheelActionSet defaultMouseWheelActions ()
 

Protected Attributes

wxLayerList m_layers
 
wxMenu m_popmenu
 
wxColour m_bgColour
 
wxColour m_fgColour
 
wxColour m_axColour
 
double m_minX
 
double m_maxX
 
double m_minY
 
double m_maxY
 
double m_scaleX
 
double m_scaleY
 
double m_posX
 
double m_posY
 
int m_scrX
 
int m_scrY
 
int m_clickedX
 
int m_clickedY
 
bool m_yLocked
 
double m_desiredXmin
 These are updated in Fit, ZoomIn, ZoomOut, ZoomRect, SetXView, SetYView and may be different from the real borders (layer coordinates) only if lock aspect ratio is true.
 
double m_desiredXmax
 
double m_desiredYmin
 
double m_desiredYmax
 
double m_topBottomPlotGapFactor
 
double m_leftRightPlotGapFactor
 
int m_marginTop
 
int m_marginRight
 
int m_marginBottom
 
int m_marginLeft
 
int m_last_lx
 
int m_last_ly
 
wxMemoryDC m_buff_dc
 
wxBitmap * m_buff_bmp
 
bool m_enableDoubleBuffer
 
bool m_enableMouseNavigation
 
bool m_enableLimitedView
 
MouseWheelActionSet m_mouseWheelActions
 
wxPoint m_mouseMClick
 
wxPoint m_mouseLClick
 
mpInfoLayerm_movingInfoLayer
 
bool m_zooming
 
wxRect m_zoomRect
 
std::stack< std::array< double, 4 > > m_undoZoomStack
 
std::stack< std::array< double, 4 > > m_redoZoomStack
 

Private Member Functions

template<typename... Ts>
 mpWindow (DelegatingContructorTag, Ts &&... windowArgs)
 
void initializeGraphicsContext ()
 

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:

  • DoubleBuffering (Default=disabled): Can be set with EnableDoubleBuffer
  • Mouse based pan/zoom (Default=enabled): Can be set with EnableMousePanZoom.

The mouse commands can be visualized by the user through the popup menu, and are:

  • Mouse Move+CTRL: Pan (Move)
  • Mouse Wheel: Vertical scroll
  • Mouse Wheel+SHIFT: Horizontal scroll
  • Mouse Wheel UP+CTRL: Zoom in
  • Mouse Wheel DOWN+CTRL: Zoom out

Definition at line 907 of file mathplot.h.

Member Enumeration Documentation

◆ MouseWheelAction

enum class mpWindow::MouseWheelAction
strong

Enumerates the possible mouse wheel actions that can be performed on the plot.

Enumerator
NONE 
PAN_LEFT_RIGHT 
PAN_RIGHT_LEFT 
PAN_UP_DOWN 
ZOOM 
ZOOM_HORIZONTALLY 
ZOOM_VERTICALLY 
COUNT 

Definition at line 913 of file mathplot.h.

Constructor & Destructor Documentation

◆ mpWindow() [1/3]

mpWindow::mpWindow ( )

Definition at line 1371 of file mathplot.cpp.

◆ mpWindow() [2/3]

mpWindow::mpWindow ( wxWindow *  parent,
wxWindowID  id 
)

◆ ~mpWindow()

mpWindow::~mpWindow ( )

Definition at line 1403 of file mathplot.cpp.

References DelAllLayers(), and m_buff_bmp.

◆ mpWindow() [3/3]

template<typename... Ts>
mpWindow::mpWindow ( DelegatingContructorTag  ,
Ts &&...  windowArgs 
)
private

Definition at line 2479 of file mathplot.cpp.

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.

Definition at line 1970 of file mathplot.cpp.

References m_layers, and UpdateAll().

Referenced by SIM_PLOT_TAB::EnableCursor(), SIM_PLOT_TAB::EnsureThirdYAxisExists(), SIM_PLOT_TAB::GetOrAddTrace(), SIMULATOR_FRAME_UI::loadJsonWorkbook(), SIMULATOR_FRAME_UI::parseTraceParams(), SIM_PLOT_TAB::prepareDCAxes(), SIM_PLOT_TAB::SIM_PLOT_TAB(), and SIM_PLOT_TAB::updateAxes().

◆ AdjustLimitedView()

void mpWindow::AdjustLimitedView ( wxOrientation  directions = wxBOTH)

Limits the zoomed or panned view to the area used by the plots.

Definition at line 1710 of file mathplot.cpp.

References m_desiredXmax, m_desiredXmin, m_desiredYmax, m_desiredYmin, m_enableLimitedView, m_maxX, m_maxY, m_minX, m_minY, m_posX, and m_posY.

Referenced by DoZoom(), SetXView(), SetYView(), ZoomRect(), ZoomRedo(), and ZoomUndo().

◆ CountAllLayers()

unsigned int mpWindow::CountAllLayers ( ) const
inline

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

Returns
The number of layers in the mpWindow.

Definition at line 1150 of file mathplot.h.

Referenced by mpInfoLegend::Plot().

◆ defaultMouseWheelActions()

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

Definition at line 2011 of file mathplot.cpp.

References m_layers, and UpdateAll().

Referenced by ~mpWindow().

◆ DelLayer()

bool mpWindow::DelLayer ( mpLayer layer,
bool  alsoDeleteObject = false,
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. Only the layer reference in the mpWindow is deleted, the layer object still exists!

Definition at line 1986 of file mathplot.cpp.

References m_layers, and UpdateAll().

Referenced by SIM_PLOT_TAB::DeleteTrace(), and SIM_PLOT_TAB::EnableCursor().

◆ DoZoom()

void mpWindow::DoZoom ( const wxPoint &  centerPoint,
double  zoomFactor,
wxOrientation  directions 
)
protected

◆ EnableDoubleBuffer()

void mpWindow::EnableDoubleBuffer ( bool  enabled)
inline

Enable/disable the double-buffering of the window, eliminating the flicker (default=disabled).

Definition at line 1099 of file mathplot.h.

Referenced by SIM_PLOT_TAB::SIM_PLOT_TAB().

◆ EnableMousePanZoom()

void mpWindow::EnableMousePanZoom ( bool  enabled)
inline

Enable/disable the feature of pan/zoom with the mouse (default=enabled)

Definition at line 1103 of file mathplot.h.

◆ Fit() [1/2]

void mpWindow::Fit ( )
override

Set view to fit global bounding box of all plot layers and refresh display.

Scale and position will be set to show all attached mpLayers. The X/Y scale aspect lock is taken into account.

Definition at line 1614 of file mathplot.cpp.

References Fit(), m_maxX, m_maxY, m_minX, m_minY, and UpdateBBox().

Referenced by DoZoom(), Fit(), OnFit(), SIMULATOR_FRAME_UI::OnSimRefresh(), OnSize(), SaveScreenshot(), ZoomRect(), ZoomRedo(), and ZoomUndo().

◆ Fit() [2/2]

void mpWindow::Fit ( double  xMin,
double  xMax,
double  yMin,
double  yMax,
const wxCoord *  printSizeX = nullptr,
const wxCoord *  printSizeY = nullptr,
wxOrientation  directions = wxBOTH 
)

Set view to fit a given bounding box and refresh display.

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.

Definition at line 1622 of file mathplot.cpp.

References m_desiredXmax, m_desiredXmin, m_desiredYmax, m_desiredYmin, m_leftRightPlotGapFactor, m_marginBottom, m_marginLeft, m_marginRight, m_marginTop, m_posX, m_posY, m_scaleX, m_scaleY, m_scrX, m_scrY, m_topBottomPlotGapFactor, and UpdateAll().

◆ GetAxesColour()

const wxColour & mpWindow::GetAxesColour ( )
inline

Get axes draw colour.

Returns
reference to axis colour used in theme

Definition at line 1255 of file mathplot.h.

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

Definition at line 2325 of file mathplot.cpp.

References m_maxX, m_maxY, m_minX, and m_minY.

◆ GetDesiredXmax()

double 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

Definition at line 1162 of file mathplot.h.

◆ 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

Definition at line 1156 of file mathplot.h.

◆ GetDesiredYmax()

double 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

Definition at line 1174 of file mathplot.h.

◆ GetDesiredYmin()

double 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

Definition at line 1168 of file mathplot.h.

◆ GetLayer()

mpLayer * mpWindow::GetLayer ( int  position) const

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

Definition at line 2304 of file mathplot.cpp.

References m_layers.

Referenced by IsLayerVisible(), mpInfoLegend::Plot(), and SetLayerVisible().

◆ GetLayerByName() [1/2]

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

Definition at line 994 of file mathplot.h.

References name.

◆ GetLayerByName() [2/2]

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

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.

Definition at line 2313 of file mathplot.cpp.

References m_layers, and name.

Referenced by IsLayerVisible(), and SetLayerVisible().

◆ GetMarginBottom()

int mpWindow::GetMarginBottom ( ) const
inline

◆ GetMarginLeft()

int mpWindow::GetMarginLeft ( ) const
inline

◆ GetMarginRight()

int mpWindow::GetMarginRight ( ) const
inline

◆ GetMarginTop()

int mpWindow::GetMarginTop ( ) const
inline

◆ GetPopupMenu()

wxMenu * mpWindow::GetPopupMenu ( )
inline

Get reference to context menu of the plot canvas.

Returns
Pointer to menu. The menu can be modified.

Definition at line 949 of file mathplot.h.

◆ GetPosX()

double mpWindow::GetPosX ( ) 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.

Definition at line 1015 of file mathplot.h.

Referenced by mpScaleXBase::Plot().

◆ GetPosY()

double mpWindow::GetPosY ( ) 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.

Definition at line 1021 of file mathplot.h.

Referenced by mpScaleY::Plot().

◆ GetScaleX()

double mpWindow::GetScaleX ( ) const
inline

Get current view's X scale.

See rules for coordinate transformation

Returns
Scale

Definition at line 1003 of file mathplot.h.

Referenced by mpScaleXBase::Plot().

◆ GetScaleY()

double mpWindow::GetScaleY ( ) const
inline

Get current view's Y scale.

See rules for coordinate transformation

Returns
Scale

Definition at line 1009 of file mathplot.h.

Referenced by mpScaleY::Plot().

◆ GetScrX()

int mpWindow::GetScrX ( ) 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.

Definition at line 1029 of file mathplot.h.

Referenced by mpScaleXBase::getVisibleDataRange(), CURSOR::Plot(), mpInfoLayer::Plot(), mpInfoLegend::Plot(), mpFX::Plot(), mpFY::Plot(), mpFXY::Plot(), mpScaleXBase::Plot(), and mpScaleY::Plot().

◆ GetScrY()

int mpWindow::GetScrY ( ) 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.

Definition at line 1038 of file mathplot.h.

Referenced by mpScaleY::getVisibleDataRange(), CURSOR::Plot(), mpInfoLayer::Plot(), mpInfoLegend::Plot(), mpFX::Plot(), mpFY::Plot(), mpFXY::Plot(), mpScaleXBase::Plot(), and mpScaleY::Plot().

◆ GetXScreen()

int mpWindow::GetXScreen ( ) const
inline

◆ GetYLocked()

bool mpWindow::GetYLocked ( ) const
inline

Definition at line 1264 of file mathplot.h.

◆ GetYScreen()

int mpWindow::GetYScreen ( ) const
inline

Definition at line 1039 of file mathplot.h.

Referenced by mpScaleY::recalculateTicks().

◆ initializeGraphicsContext()

void mpWindow::initializeGraphicsContext ( )
private

Definition at line 2516 of file mathplot.cpp.

References m_buff_dc.

Referenced by mpWindow().

◆ IsInsideInfoLayer()

mpInfoLayer * mpWindow::IsInsideInfoLayer ( 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

Definition at line 2394 of file mathplot.cpp.

References mpInfoLayer::Inside(), and m_layers.

Referenced by onMouseLeftDown().

◆ IsLayerVisible() [1/2]

bool mpWindow::IsLayerVisible ( const wxString &  name) const

Check whether a layer with given name is visible.

Parameters
nameThe layer name
Returns
layer visibility status

Definition at line 2421 of file mathplot.cpp.

References GetLayerByName(), and name.

◆ IsLayerVisible() [2/2]

bool mpWindow::IsLayerVisible ( unsigned int  position) const

Check whether the layer at given position is visible.

Parameters
positionThe layer position in layer list
Returns
layer visibility status

Definition at line 2440 of file mathplot.cpp.

References GetLayer().

◆ LimitView()

void mpWindow::LimitView ( bool  aEnable)
inline

Enable limiting of zooming & panning to the area used by the plots.

Definition at line 1258 of file mathplot.h.

Referenced by SIM_PLOT_TAB::SIM_PLOT_TAB().

◆ LockY()

void mpWindow::LockY ( bool  aLock)
inline

Definition at line 1263 of file mathplot.h.

Referenced by SIMULATOR_FRAME_UI::loadJsonWorkbook().

◆ OnCenter()

void mpWindow::OnCenter ( wxCommandEvent &  event)

◆ OnFit()

void mpWindow::OnFit ( wxCommandEvent &  event)

Definition at line 1910 of file mathplot.cpp.

References Fit(), m_desiredXmax, m_desiredXmin, m_desiredYmax, m_desiredYmin, and pushZoomUndo().

◆ onMagnify()

void mpWindow::onMagnify ( wxMouseEvent &  event)
protected

Definition at line 1422 of file mathplot.cpp.

References m_enableMouseNavigation, zoom, ZoomIn(), and ZoomOut().

◆ onMouseLeftDown()

void mpWindow::onMouseLeftDown ( wxMouseEvent &  event)
protected

Definition at line 1580 of file mathplot.cpp.

References IsInsideInfoLayer(), m_mouseLClick, m_movingInfoLayer, and m_zooming.

◆ onMouseLeftRelease()

void mpWindow::onMouseLeftRelease ( wxMouseEvent &  event)
protected

◆ OnMouseMiddleDown()

void mpWindow::OnMouseMiddleDown ( wxMouseEvent &  event)
protected

Definition at line 1415 of file mathplot.cpp.

References m_mouseMClick.

◆ onMouseMove()

◆ onMouseWheel()

◆ OnPaint()

void mpWindow::OnPaint ( wxPaintEvent &  event)
protected

◆ OnShowPopupMenu()

void mpWindow::OnShowPopupMenu ( wxMouseEvent &  event)
protected

◆ OnSize()

void mpWindow::OnSize ( wxSizeEvent &  event)
protected

Definition at line 1963 of file mathplot.cpp.

References Fit(), m_desiredXmax, m_desiredXmin, m_desiredYmax, and m_desiredYmin.

◆ onZoomIn()

void mpWindow::onZoomIn ( wxCommandEvent &  event)
protected

Definition at line 1939 of file mathplot.cpp.

References m_mouseMClick, and ZoomIn().

◆ onZoomOut()

void mpWindow::onZoomOut ( wxCommandEvent &  event)
protected

Definition at line 1945 of file mathplot.cpp.

References ZoomOut().

◆ onZoomRedo()

void mpWindow::onZoomRedo ( wxCommandEvent &  event)
protected

Definition at line 1957 of file mathplot.cpp.

References ZoomRedo().

◆ onZoomUndo()

void mpWindow::onZoomUndo ( wxCommandEvent &  event)
protected

Definition at line 1951 of file mathplot.cpp.

References ZoomUndo().

◆ p2x()

double mpWindow::p2x ( wxCoord  pixelCoordX)
inline

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

See also
p2y,x2p,y2p

Definition at line 1082 of file mathplot.h.

Referenced by DoZoom(), mpScaleXBase::getVisibleDataRange(), OnCenter(), CURSOR::Plot(), mpFX::Plot(), and ZoomRect().

◆ p2y()

double mpWindow::p2y ( wxCoord  pixelCoordY)
inline

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

See also
p2x,x2p,y2p

Definition at line 1086 of file mathplot.h.

Referenced by DoZoom(), mpScaleY::getVisibleDataRange(), OnCenter(), mpFY::Plot(), and ZoomRect().

◆ PerformMouseWheelAction()

void mpWindow::PerformMouseWheelAction ( wxMouseEvent &  event,
MouseWheelAction  action 
)
protected

◆ pushZoomUndo()

void mpWindow::pushZoomUndo ( const std::array< double, 4 > &  aZoom)
protected

Definition at line 1859 of file mathplot.cpp.

References m_redoZoomStack, and m_undoZoomStack.

Referenced by DoZoom(), OnFit(), and ZoomRect().

◆ RecomputeDesiredX()

void mpWindow::RecomputeDesiredX ( double &  min,
double &  max 
)
protected

Definition at line 2167 of file mathplot.cpp.

References m_desiredXmin, m_leftRightPlotGapFactor, m_marginLeft, m_marginRight, m_posX, m_scaleX, and m_scrX.

Referenced by DoZoom().

◆ RecomputeDesiredY()

void mpWindow::RecomputeDesiredY ( double &  min,
double &  max 
)
protected

Definition at line 2178 of file mathplot.cpp.

References m_desiredYmax, m_marginBottom, m_marginTop, m_posY, m_scaleY, m_scrY, and m_topBottomPlotGapFactor.

Referenced by DoZoom().

◆ RedoZoomStackSize()

int mpWindow::RedoZoomStackSize ( ) const
inline

Definition at line 1269 of file mathplot.h.

Referenced by SIMULATOR_FRAME::setupUIConditions().

◆ SaveScreenshot()

bool mpWindow::SaveScreenshot ( wxImage &  aImage,
wxSize  aImageSize = wxDefaultSize,
bool  aFit = false 
)

Draw the window on a wxBitmap, then save it to a file.

Parameters
aImagea wxImage where to save the screenshot
aImageSizeSet a size for the output image. Default is the same as the screen size
aFitDecide whether to fit the plot into the size

Definition at line 2334 of file mathplot.cpp.

References Fit(), m_desiredXmax, m_desiredXmin, m_desiredYmax, m_desiredYmin, m_fgColour, m_layers, m_maxX, m_maxY, m_minX, m_minY, m_scrX, m_scrY, SetScr(), and UpdateAll().

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

Definition at line 2449 of file mathplot.cpp.

References m_axColour, m_bgColour, m_fgColour, m_layers, mpLAYER_AXIS, and mpLAYER_INFO.

Referenced by SIM_PLOT_TAB::UpdatePlotColors().

◆ SetLayerVisible() [1/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

Definition at line 2430 of file mathplot.cpp.

References GetLayer(), and UpdateAll().

◆ SetLayerVisible() [2/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

Definition at line 2411 of file mathplot.cpp.

References GetLayerByName(), name, and UpdateAll().

◆ SetMarginBottom()

void mpWindow::SetMarginBottom ( int  bottom)
inline

Set the bottom margin.

Parameters
bottomBottom Margin

Definition at line 1208 of file mathplot.h.

◆ SetMarginLeft()

void mpWindow::SetMarginLeft ( int  left)
inline

Set the left margin.

Parameters
leftLeft Margin

Definition at line 1210 of file mathplot.h.

References left.

◆ SetMarginRight()

void mpWindow::SetMarginRight ( int  right)
inline

Set the right margin.

Parameters
rightRight Margin

Definition at line 1206 of file mathplot.h.

References right.

◆ 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

Definition at line 2385 of file mathplot.cpp.

References left, m_marginBottom, m_marginLeft, m_marginRight, m_marginTop, and right.

Referenced by SIM_PLOT_TAB::EnsureThirdYAxisExists(), SIMULATOR_FRAME_UI::loadJsonWorkbook(), SIM_PLOT_TAB::SIM_PLOT_TAB(), and SIM_PLOT_TAB::updateAxes().

◆ SetMarginTop()

void mpWindow::SetMarginTop ( int  top)
inline

Set the top margin.

Parameters
topTop Margin

Definition at line 1204 of file mathplot.h.

◆ SetMouseWheelActions()

void mpWindow::SetMouseWheelActions ( const MouseWheelActionSet s)
inline

Set the pan/zoom actions corresponding to mousewheel/trackpad events.

Definition at line 1106 of file mathplot.h.

Referenced by SIM_PLOT_TAB::ApplyPreferences().

◆ SetPos()

void mpWindow::SetPos ( double  posX,
double  posY 
)
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.

Definition at line 1071 of file mathplot.h.

Referenced by OnCenter().

◆ SetPosX()

void mpWindow::SetPosX ( double  posX)
inline

Set current view's X position and refresh display.

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

Definition at line 1060 of file mathplot.h.

◆ SetPosY()

void mpWindow::SetPosY ( double  posY)
inline

Set current view's Y position and refresh display.

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

Definition at line 1065 of file mathplot.h.

◆ SetScaleX()

void mpWindow::SetScaleX ( double  scaleX)

Set current view's X scale and refresh display.

Parameters
scaleXNew scale, must not be 0.

Definition at line 2293 of file mathplot.cpp.

References m_scaleX, and UpdateAll().

◆ SetScaleY()

void mpWindow::SetScaleY ( double  scaleY)
inline

Set current view's Y scale and refresh display.

Parameters
scaleYNew scale, must not be 0.

Definition at line 1049 of file mathplot.h.

◆ SetScr()

void mpWindow::SetScr ( int  scrX,
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.

Definition at line 1078 of file mathplot.h.

Referenced by SaveScreenshot().

◆ SetXView()

bool mpWindow::SetXView ( double  pos,
double  desiredMax,
double  desiredMin 
)
protectedvirtual

Applies new X view coordinates depending on the settings.

Returns
true if the changes were applied

Definition at line 1758 of file mathplot.cpp.

References AdjustLimitedView(), m_desiredXmax, m_desiredXmin, and m_posX.

Referenced by onMouseMove(), and PerformMouseWheelAction().

◆ SetYView()

bool mpWindow::SetYView ( double  pos,
double  desiredMax,
double  desiredMin 
)
protectedvirtual

Applies new Y view coordinates depending on the settings.

Returns
true if the changes were applied

Definition at line 1772 of file mathplot.cpp.

References AdjustLimitedView(), m_desiredYmax, m_desiredYmin, and m_posY.

Referenced by onMouseMove(), and PerformMouseWheelAction().

◆ UndoZoomStackSize()

int mpWindow::UndoZoomStackSize ( ) const
inline

Definition at line 1268 of file mathplot.h.

Referenced by SIMULATOR_FRAME::setupUIConditions().

◆ UpdateAll()

◆ UpdateBBox()

bool mpWindow::UpdateBBox ( )
protectedvirtual

Recalculate global layer bounding box, and save it in m_minX,...

Returns
true if there is any valid BBox information.

Definition at line 2275 of file mathplot.cpp.

References m_maxX, m_maxY, m_minX, and m_minY.

Referenced by Fit(), and UpdateAll().

◆ ViewNeedsRefitting()

wxOrientation mpWindow::ViewNeedsRefitting ( wxOrientation  directions) const
protected

◆ x2p()

wxCoord mpWindow::x2p ( double  x)
inline

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

See also
p2x,p2y,y2p

Definition at line 1090 of file mathplot.h.

Referenced by CURSOR::Inside(), CURSOR::Plot(), mpFY::Plot(), mpFXY::Plot(), mpScaleY::Plot(), CURSOR::SetCoordX(), and CURSOR::UpdateReference().

◆ y2p()

wxCoord mpWindow::y2p ( double  y)
inline

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

See also
p2x,p2y,x2p

Definition at line 1094 of file mathplot.h.

Referenced by CURSOR::Inside(), CURSOR::Plot(), mpFX::Plot(), mpFXY::Plot(), mpScaleXBase::Plot(), CURSOR::SetCoordX(), and CURSOR::UpdateReference().

◆ ZoomIn() [1/2]

void mpWindow::ZoomIn ( const wxPoint &  centerPoint,
double  zoomFactor,
wxOrientation  directions = wxBOTH 
)

Definition at line 1789 of file mathplot.cpp.

References DoZoom().

◆ ZoomIn() [2/2]

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

Definition at line 1783 of file mathplot.cpp.

References ZoomIn(), and zoomIncrementalFactor.

Referenced by onMagnify(), onZoomIn(), PerformMouseWheelAction(), and ZoomIn().

◆ ZoomOut() [1/2]

void mpWindow::ZoomOut ( const wxPoint &  centerPoint,
double  zoomFactor,
wxOrientation  directions = wxBOTH 
)

Definition at line 1801 of file mathplot.cpp.

References DoZoom().

◆ ZoomOut() [2/2]

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

Definition at line 1795 of file mathplot.cpp.

References zoomIncrementalFactor, and ZoomOut().

Referenced by onMagnify(), onZoomOut(), PerformMouseWheelAction(), and ZoomOut().

◆ ZoomRect()

void mpWindow::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)

Definition at line 1809 of file mathplot.cpp.

References AdjustLimitedView(), Fit(), m_desiredXmax, m_desiredXmin, m_desiredYmax, m_desiredYmin, m_marginBottom, m_marginLeft, m_marginRight, m_marginTop, m_maxX, m_maxY, m_minX, m_minY, m_scrX, m_scrY, m_yLocked, p2x(), p2y(), pushZoomUndo(), and ViewNeedsRefitting().

Referenced by onMouseLeftRelease().

◆ ZoomRedo()

void mpWindow::ZoomRedo ( )

◆ ZoomUndo()

void mpWindow::ZoomUndo ( )

Member Data Documentation

◆ m_axColour

wxColour mpWindow::m_axColour
protected

Definition at line 1326 of file mathplot.h.

Referenced by SetColourTheme().

◆ m_bgColour

wxColour mpWindow::m_bgColour
protected

Definition at line 1324 of file mathplot.h.

Referenced by mpWindow(), and SetColourTheme().

◆ m_buff_bmp

wxBitmap* mpWindow::m_buff_bmp
protected

Definition at line 1360 of file mathplot.h.

Referenced by OnPaint(), and ~mpWindow().

◆ m_buff_dc

wxMemoryDC mpWindow::m_buff_dc
protected

Definition at line 1359 of file mathplot.h.

Referenced by initializeGraphicsContext(), and OnPaint().

◆ m_clickedX

int mpWindow::m_clickedX
protected

Definition at line 1338 of file mathplot.h.

Referenced by OnCenter(), and OnShowPopupMenu().

◆ m_clickedY

int mpWindow::m_clickedY
protected

Definition at line 1339 of file mathplot.h.

Referenced by OnCenter(), and OnShowPopupMenu().

◆ m_desiredXmax

◆ m_desiredXmin

double mpWindow::m_desiredXmin
protected

These are updated in Fit, ZoomIn, ZoomOut, ZoomRect, SetXView, SetYView and may be different from the real borders (layer coordinates) only if lock aspect ratio is true.

Note
They use the plot area as their coordinate system, and not the layer coordinate system used by m_posX/Y.

Definition at line 1349 of file mathplot.h.

Referenced by AdjustLimitedView(), DoZoom(), Fit(), OnFit(), onMouseMove(), OnSize(), PerformMouseWheelAction(), RecomputeDesiredX(), SaveScreenshot(), SetXView(), ViewNeedsRefitting(), ZoomRect(), ZoomRedo(), and ZoomUndo().

◆ m_desiredYmax

◆ m_desiredYmin

◆ m_enableDoubleBuffer

bool mpWindow::m_enableDoubleBuffer
protected

Definition at line 1361 of file mathplot.h.

Referenced by OnPaint().

◆ m_enableLimitedView

bool mpWindow::m_enableLimitedView
protected

Definition at line 1363 of file mathplot.h.

Referenced by AdjustLimitedView(), and ViewNeedsRefitting().

◆ m_enableMouseNavigation

bool mpWindow::m_enableMouseNavigation
protected

Definition at line 1362 of file mathplot.h.

Referenced by onMagnify(), onMouseMove(), and onMouseWheel().

◆ m_fgColour

wxColour mpWindow::m_fgColour
protected

Definition at line 1325 of file mathplot.h.

Referenced by mpWindow(), onMouseMove(), OnPaint(), SaveScreenshot(), and SetColourTheme().

◆ m_last_lx

int mpWindow::m_last_lx
protected

Definition at line 1358 of file mathplot.h.

Referenced by OnPaint().

◆ m_last_ly

int mpWindow::m_last_ly
protected

Definition at line 1358 of file mathplot.h.

Referenced by OnPaint().

◆ m_layers

◆ m_leftRightPlotGapFactor

double mpWindow::m_leftRightPlotGapFactor
protected

Definition at line 1354 of file mathplot.h.

Referenced by Fit(), RecomputeDesiredX(), and ViewNeedsRefitting().

◆ m_marginBottom

int mpWindow::m_marginBottom
protected

Definition at line 1356 of file mathplot.h.

Referenced by DoZoom(), Fit(), OnCenter(), RecomputeDesiredY(), SetMargins(), and ZoomRect().

◆ m_marginLeft

int mpWindow::m_marginLeft
protected

Definition at line 1356 of file mathplot.h.

Referenced by DoZoom(), Fit(), OnCenter(), RecomputeDesiredX(), SetMargins(), and ZoomRect().

◆ m_marginRight

int mpWindow::m_marginRight
protected

Definition at line 1356 of file mathplot.h.

Referenced by DoZoom(), Fit(), OnCenter(), RecomputeDesiredX(), SetMargins(), and ZoomRect().

◆ m_marginTop

int mpWindow::m_marginTop
protected

Definition at line 1356 of file mathplot.h.

Referenced by DoZoom(), Fit(), OnCenter(), RecomputeDesiredY(), SetMargins(), and ZoomRect().

◆ m_maxX

double mpWindow::m_maxX
protected

◆ m_maxY

double mpWindow::m_maxY
protected

◆ m_minX

double mpWindow::m_minX
protected

◆ m_minY

double mpWindow::m_minY
protected

◆ m_mouseLClick

wxPoint mpWindow::m_mouseLClick
protected

Definition at line 1366 of file mathplot.h.

Referenced by onMouseLeftDown(), onMouseLeftRelease(), and onMouseMove().

◆ m_mouseMClick

wxPoint mpWindow::m_mouseMClick
protected

Definition at line 1365 of file mathplot.h.

Referenced by OnMouseMiddleDown(), onMouseMove(), and onZoomIn().

◆ m_mouseWheelActions

MouseWheelActionSet mpWindow::m_mouseWheelActions
protected

Definition at line 1364 of file mathplot.h.

Referenced by onMouseWheel().

◆ m_movingInfoLayer

mpInfoLayer* mpWindow::m_movingInfoLayer
protected

Definition at line 1367 of file mathplot.h.

Referenced by onMouseLeftDown(), onMouseLeftRelease(), and onMouseMove().

◆ m_popmenu

wxMenu mpWindow::m_popmenu
protected

Definition at line 1323 of file mathplot.h.

Referenced by mpWindow(), and OnShowPopupMenu().

◆ m_posX

double mpWindow::m_posX
protected

◆ m_posY

double mpWindow::m_posY
protected

◆ m_redoZoomStack

std::stack<std::array<double, 4> > mpWindow::m_redoZoomStack
protected

Definition at line 1371 of file mathplot.h.

Referenced by OnShowPopupMenu(), pushZoomUndo(), ZoomRedo(), and ZoomUndo().

◆ m_scaleX

double mpWindow::m_scaleX
protected

◆ m_scaleY

double mpWindow::m_scaleY
protected

Definition at line 1333 of file mathplot.h.

Referenced by DoZoom(), Fit(), onMouseMove(), PerformMouseWheelAction(), and RecomputeDesiredY().

◆ m_scrX

int mpWindow::m_scrX
protected

Definition at line 1336 of file mathplot.h.

Referenced by DoZoom(), Fit(), OnCenter(), OnPaint(), RecomputeDesiredX(), SaveScreenshot(), and ZoomRect().

◆ m_scrY

int mpWindow::m_scrY
protected

Definition at line 1337 of file mathplot.h.

Referenced by DoZoom(), Fit(), OnCenter(), OnPaint(), RecomputeDesiredY(), SaveScreenshot(), and ZoomRect().

◆ m_topBottomPlotGapFactor

double mpWindow::m_topBottomPlotGapFactor
protected

Definition at line 1353 of file mathplot.h.

Referenced by Fit(), RecomputeDesiredY(), and ViewNeedsRefitting().

◆ m_undoZoomStack

std::stack<std::array<double, 4> > mpWindow::m_undoZoomStack
protected

Definition at line 1370 of file mathplot.h.

Referenced by OnShowPopupMenu(), pushZoomUndo(), ZoomRedo(), and ZoomUndo().

◆ m_yLocked

bool mpWindow::m_yLocked
protected

Definition at line 1341 of file mathplot.h.

Referenced by DoZoom(), PerformMouseWheelAction(), and ZoomRect().

◆ m_zooming

bool mpWindow::m_zooming
protected

Definition at line 1368 of file mathplot.h.

Referenced by onMouseLeftDown(), onMouseLeftRelease(), onMouseMove(), and OnPaint().

◆ m_zoomRect

wxRect mpWindow::m_zoomRect
protected

Definition at line 1369 of file mathplot.h.

Referenced by onMouseMove(), and OnPaint().

◆ zoomIncrementalFactor

double mpWindow::zoomIncrementalFactor = 1.1
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.

Definition at line 1193 of file mathplot.h.

Referenced by PerformMouseWheelAction(), SIMULATOR_CONTROL::Zoom(), ZoomIn(), and ZoomOut().


The documentation for this class was generated from the following files: