KiCad PCB EDA Suite
|
Canvas for plotting mpLayer implementations. More...
#include <mathplot.h>
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. | |
mpLayer * | GetLayer (int position) const |
const mpLayer * | GetLayerByName (const wxString &name) const |
mpLayer * | GetLayerByName (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 ¢erPoint=wxDefaultPosition) |
Zoom into current view and refresh display. | |
void | ZoomIn (const wxPoint ¢erPoint, double zoomFactor, wxOrientation directions=wxBOTH) |
void | ZoomOut (const wxPoint ¢erPoint=wxDefaultPosition) |
Zoom out current view and refresh display. | |
void | ZoomOut (const wxPoint ¢erPoint, 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 |
mpInfoLayer * | IsInsideInfoLayer (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 ¢erPoint, 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 |
mpInfoLayer * | m_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 () |
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:
Definition at line 907 of file mathplot.h.
|
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.
mpWindow::mpWindow | ( | ) |
Definition at line 1371 of file mathplot.cpp.
mpWindow::mpWindow | ( | wxWindow * | parent, |
wxWindowID | id | ||
) |
Definition at line 1376 of file mathplot.cpp.
References _, initializeGraphicsContext(), m_bgColour, m_fgColour, m_layers, m_popmenu, mpID_CENTER, mpID_FIT, mpID_ZOOM_IN, mpID_ZOOM_OUT, mpID_ZOOM_REDO, mpID_ZOOM_UNDO, and UpdateAll().
mpWindow::~mpWindow | ( | ) |
Definition at line 1403 of file mathplot.cpp.
References DelAllLayers(), and m_buff_bmp.
|
private |
Definition at line 2479 of file mathplot.cpp.
bool mpWindow::AddLayer | ( | mpLayer * | layer, |
bool | refreshDisplay = true |
||
) |
Add a plot layer to the canvas.
layer | Pointer to layer. The mpLayer object will get under control of mpWindow, i.e. it will be delete'd on mpWindow destruction |
refreshDisplay | States whether to refresh the display (UpdateAll) after adding the layer. |
true | Success |
false | Failure 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().
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().
|
inline |
Counts the number of plot layers, whether or not they have a bounding box.
Definition at line 1150 of file mathplot.h.
Referenced by mpInfoLegend::Plot().
|
staticprotected |
Definition at line 1927 of file mathplot.cpp.
References mpWindow::MouseWheelActionSet::horizontal, NONE, PAN_LEFT_RIGHT, PAN_UP_DOWN, mpWindow::MouseWheelActionSet::verticalUnmodified, mpWindow::MouseWheelActionSet::verticalWithAlt, mpWindow::MouseWheelActionSet::verticalWithCtrl, mpWindow::MouseWheelActionSet::verticalWithShift, and ZOOM.
void mpWindow::DelAllLayers | ( | bool | alsoDeleteObject, |
bool | refreshDisplay = true |
||
) |
Remove all layers from the plot.
alsoDeleteObject | If set to true, the mpLayer objects will be also "deleted", not just removed from the internal list. |
refreshDisplay | States whether to refresh the display (UpdateAll) after removing the layers. |
Definition at line 2011 of file mathplot.cpp.
References m_layers, and UpdateAll().
Referenced by ~mpWindow().
bool mpWindow::DelLayer | ( | mpLayer * | layer, |
bool | alsoDeleteObject = false , |
||
bool | refreshDisplay = true |
||
) |
Remove a plot layer from the canvas.
layer | Pointer to layer. The mpLayer object will be destructed using delete. |
alsoDeleteObject | If set to true, the mpLayer object will be also "deleted", not just removed from the internal list. |
refreshDisplay | States whether to refresh the display (UpdateAll) after removing the layer. |
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().
|
protected |
Definition at line 2084 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_posX, m_posY, m_scaleX, m_scaleY, m_scrX, m_scrY, m_yLocked, MAX_SCALE, p2x(), p2y(), pushZoomUndo(), RecomputeDesiredX(), RecomputeDesiredY(), UpdateAll(), and ViewNeedsRefitting().
|
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().
|
inline |
Enable/disable the feature of pan/zoom with the mouse (default=enabled)
Definition at line 1103 of file mathplot.h.
|
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().
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().
|
inline |
Get axes draw colour.
Definition at line 1255 of file mathplot.h.
void mpWindow::GetBoundingBox | ( | double * | bbox | ) | 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).
Definition at line 1162 of file mathplot.h.
|
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).
Definition at line 1156 of file mathplot.h.
|
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).
Definition at line 1174 of file mathplot.h.
|
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).
Definition at line 1168 of file mathplot.h.
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!
position | position of the layer in the layers list |
Definition at line 2304 of file mathplot.cpp.
References m_layers.
Referenced by IsLayerVisible(), mpInfoLegend::Plot(), and SetLayerVisible().
|
inline |
Definition at line 994 of file mathplot.h.
References name.
const mpLayer * mpWindow::GetLayerByName | ( | const wxString & | name | ) | const |
Get the layer by its name (case sensitive).
name | The name of the layer to retrieve |
Definition at line 2313 of file mathplot.cpp.
References m_layers, and name.
Referenced by IsLayerVisible(), and SetLayerVisible().
|
inline |
Definition at line 1217 of file mathplot.h.
Referenced by mpScaleY::getVisibleDataRange(), CURSOR::Plot(), mpFX::Plot(), mpFY::Plot(), mpFXY::Plot(), mpScaleXBase::Plot(), mpScaleY::Plot(), and SIMULATOR_FRAME_UI::SaveWorkbook().
|
inline |
Definition at line 1219 of file mathplot.h.
Referenced by SIM_PLOT_TAB::EnableCursor(), mpScaleXBase::getVisibleDataRange(), CURSOR::Plot(), mpFX::Plot(), mpFY::Plot(), mpFXY::Plot(), mpScaleXBase::Plot(), mpScaleY::Plot(), and SIMULATOR_FRAME_UI::SaveWorkbook().
|
inline |
Definition at line 1215 of file mathplot.h.
Referenced by SIM_PLOT_TAB::EnableCursor(), mpScaleXBase::getVisibleDataRange(), CURSOR::Plot(), mpFX::Plot(), mpFY::Plot(), mpFXY::Plot(), mpScaleXBase::Plot(), mpScaleY::Plot(), and SIMULATOR_FRAME_UI::SaveWorkbook().
|
inline |
Definition at line 1213 of file mathplot.h.
Referenced by mpScaleY::getVisibleDataRange(), CURSOR::Plot(), mpFX::Plot(), mpFY::Plot(), mpFXY::Plot(), mpScaleXBase::Plot(), mpScaleY::Plot(), and SIMULATOR_FRAME_UI::SaveWorkbook().
|
inline |
Get reference to context menu of the plot canvas.
Definition at line 949 of file mathplot.h.
|
inline |
Get current view's X position.
See rules for coordinate transformation
Definition at line 1015 of file mathplot.h.
Referenced by mpScaleXBase::Plot().
|
inline |
Get current view's Y position.
See rules for coordinate transformation
Definition at line 1021 of file mathplot.h.
Referenced by mpScaleY::Plot().
|
inline |
Get current view's X scale.
See rules for coordinate transformation
Definition at line 1003 of file mathplot.h.
Referenced by mpScaleXBase::Plot().
|
inline |
Get current view's Y scale.
See rules for coordinate transformation
Definition at line 1009 of file mathplot.h.
Referenced by mpScaleY::Plot().
|
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
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().
|
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
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().
|
inline |
Definition at line 1030 of file mathplot.h.
Referenced by SIM_PLOT_TAB::EnableCursor(), mpScaleX::recalculateTicks(), and mpScaleXLog::recalculateTicks().
|
inline |
Definition at line 1264 of file mathplot.h.
|
inline |
Definition at line 1039 of file mathplot.h.
Referenced by mpScaleY::recalculateTicks().
|
private |
mpInfoLayer * mpWindow::IsInsideInfoLayer | ( | wxPoint & | point | ) |
Check if a given point is inside the area of a mpInfoLayer and eventually returns its pointer.
point | The position to be checked |
Definition at line 2394 of file mathplot.cpp.
References mpInfoLayer::Inside(), and m_layers.
Referenced by onMouseLeftDown().
bool mpWindow::IsLayerVisible | ( | const wxString & | name | ) | const |
Check whether a layer with given name is visible.
name | The layer name |
Definition at line 2421 of file mathplot.cpp.
References GetLayerByName(), and name.
bool mpWindow::IsLayerVisible | ( | unsigned int | position | ) | const |
Check whether the layer at given position is visible.
position | The layer position in layer list |
Definition at line 2440 of file mathplot.cpp.
References GetLayer().
|
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().
|
inline |
Definition at line 1263 of file mathplot.h.
Referenced by SIMULATOR_FRAME_UI::loadJsonWorkbook().
void mpWindow::OnCenter | ( | wxCommandEvent & | event | ) |
Definition at line 1918 of file mathplot.cpp.
References m_clickedX, m_clickedY, m_marginBottom, m_marginLeft, m_marginRight, m_marginTop, m_scrX, m_scrY, p2x(), p2y(), and SetPos().
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().
|
protected |
Definition at line 1422 of file mathplot.cpp.
References m_enableMouseNavigation, zoom, ZoomIn(), and ZoomOut().
|
protected |
Definition at line 1580 of file mathplot.cpp.
References IsInsideInfoLayer(), m_mouseLClick, m_movingInfoLayer, and m_zooming.
|
protected |
Definition at line 1592 of file mathplot.cpp.
References m_mouseLClick, m_movingInfoLayer, m_zooming, mpInfoLayer::UpdateReference(), and ZoomRect().
|
protected |
Definition at line 1415 of file mathplot.cpp.
References m_mouseMClick.
|
protected |
Definition at line 1486 of file mathplot.cpp.
References cursor, mpInfoLayer::Inside(), m_desiredXmax, m_desiredXmin, m_desiredYmax, m_desiredYmin, m_enableMouseNavigation, m_fgColour, m_layers, m_mouseLClick, m_mouseMClick, m_movingInfoLayer, m_posX, m_posY, m_scaleX, m_scaleY, m_zooming, m_zoomRect, mpInfoLayer::Move(), SetXView(), SetYView(), and UpdateAll().
|
protected |
Definition at line 1442 of file mathplot.cpp.
References mpWindow::MouseWheelActionSet::horizontal, m_enableMouseNavigation, m_mouseWheelActions, NONE, PerformMouseWheelAction(), mpWindow::MouseWheelActionSet::verticalUnmodified, mpWindow::MouseWheelActionSet::verticalWithAlt, mpWindow::MouseWheelActionSet::verticalWithCtrl, and mpWindow::MouseWheelActionSet::verticalWithShift.
|
protected |
Definition at line 2027 of file mathplot.cpp.
References m_buff_bmp, m_buff_dc, m_enableDoubleBuffer, m_fgColour, m_last_lx, m_last_ly, m_layers, m_scrX, m_scrY, m_zooming, and m_zoomRect.
|
protected |
Definition at line 1898 of file mathplot.cpp.
References m_clickedX, m_clickedY, m_popmenu, m_redoZoomStack, m_undoZoomStack, mpID_ZOOM_REDO, and mpID_ZOOM_UNDO.
|
protected |
Definition at line 1963 of file mathplot.cpp.
References Fit(), m_desiredXmax, m_desiredXmin, m_desiredYmax, and m_desiredYmin.
|
protected |
Definition at line 1939 of file mathplot.cpp.
References m_mouseMClick, and ZoomIn().
|
protected |
Definition at line 1945 of file mathplot.cpp.
References ZoomOut().
|
protected |
Definition at line 1957 of file mathplot.cpp.
References ZoomRedo().
|
protected |
Definition at line 1951 of file mathplot.cpp.
References ZoomUndo().
|
inline |
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition at line 1082 of file mathplot.h.
Referenced by DoZoom(), mpScaleXBase::getVisibleDataRange(), OnCenter(), CURSOR::Plot(), mpFX::Plot(), and ZoomRect().
|
inline |
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition at line 1086 of file mathplot.h.
Referenced by DoZoom(), mpScaleY::getVisibleDataRange(), OnCenter(), mpFY::Plot(), and ZoomRect().
|
protected |
Definition at line 2217 of file mathplot.cpp.
References m_desiredXmax, m_desiredXmin, m_desiredYmax, m_desiredYmin, m_posX, m_posY, m_scaleX, m_scaleY, m_yLocked, NONE, PAN_LEFT_RIGHT, PAN_RIGHT_LEFT, PAN_UP_DOWN, SetXView(), SetYView(), UpdateAll(), ZOOM, ZOOM_HORIZONTALLY, ZOOM_VERTICALLY, ZoomIn(), zoomIncrementalFactor, and ZoomOut().
Referenced by onMouseWheel().
|
protected |
Definition at line 1859 of file mathplot.cpp.
References m_redoZoomStack, and m_undoZoomStack.
Referenced by DoZoom(), OnFit(), and ZoomRect().
|
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().
|
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().
|
inline |
Definition at line 1269 of file mathplot.h.
Referenced by SIMULATOR_FRAME::setupUIConditions().
bool mpWindow::SaveScreenshot | ( | wxImage & | aImage, |
wxSize | aImageSize = wxDefaultSize , |
||
bool | aFit = false |
||
) |
Draw the window on a wxBitmap, then save it to a file.
aImage | a wxImage where to save the screenshot |
aImageSize | Set a size for the output image. Default is the same as the screen size |
aFit | Decide 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().
void mpWindow::SetColourTheme | ( | const wxColour & | bgColour, |
const wxColour & | drawColour, | ||
const wxColour & | axesColour | ||
) |
Set Color theme.
Provide colours to set a new colour theme.
bgColour | Background colour |
drawColour | The colour used to draw all elements in foreground, axes excluded |
axesColour | The colour used to draw axes (but not their labels) |
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().
void mpWindow::SetLayerVisible | ( | const unsigned int | position, |
bool | viewable | ||
) |
Sets the visibility of a layer by its position in layer list.
position | The layer position in layer list |
viewable | the view status to be set |
Definition at line 2430 of file mathplot.cpp.
References GetLayer(), and UpdateAll().
void mpWindow::SetLayerVisible | ( | const wxString & | name, |
bool | viewable | ||
) |
Sets the visibility of a layer by its name.
name | The layer name to set visibility |
viewable | the view status to be set |
Definition at line 2411 of file mathplot.cpp.
References GetLayerByName(), name, and UpdateAll().
|
inline |
|
inline |
Set the left margin.
left | Left Margin |
Definition at line 1210 of file mathplot.h.
References left.
|
inline |
Set the right margin.
right | Right Margin |
Definition at line 1206 of file mathplot.h.
References right.
void mpWindow::SetMargins | ( | int | top, |
int | right, | ||
int | bottom, | ||
int | left | ||
) |
Set window margins, creating a blank area where some kinds of layers cannot draw.
This is useful for example to draw axes outside the area where the plots are drawn.
top | Top border |
right | Right border |
bottom | Bottom border |
left | Left border |
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().
|
inline |
|
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().
|
inline |
Set current view's X and Y position and refresh display.
posX | New position that corresponds to the center point of the view. |
posY | New position that corresponds to the center point of the view. |
Definition at line 1071 of file mathplot.h.
Referenced by OnCenter().
|
inline |
Set current view's X position and refresh display.
posX | New position that corresponds to the center point of the view. |
Definition at line 1060 of file mathplot.h.
|
inline |
Set current view's Y position and refresh display.
posY | New position that corresponds to the center point of the view. |
Definition at line 1065 of file mathplot.h.
void mpWindow::SetScaleX | ( | double | scaleX | ) |
Set current view's X scale and refresh display.
scaleX | New scale, must not be 0. |
Definition at line 2293 of file mathplot.cpp.
References m_scaleX, and UpdateAll().
|
inline |
Set current view's Y scale and refresh display.
scaleY | New scale, must not be 0. |
Definition at line 1049 of file mathplot.h.
|
inline |
Set current view's dimensions in device context units.
Needed by plotting functions. It doesn't refresh display.
scrX | New position that corresponds to the center point of the view. |
scrY | New position that corresponds to the center point of the view. |
Definition at line 1078 of file mathplot.h.
Referenced by SaveScreenshot().
|
protectedvirtual |
Applies new X view coordinates depending on the settings.
Definition at line 1758 of file mathplot.cpp.
References AdjustLimitedView(), m_desiredXmax, m_desiredXmin, and m_posX.
Referenced by onMouseMove(), and PerformMouseWheelAction().
|
protectedvirtual |
Applies new Y view coordinates depending on the settings.
Definition at line 1772 of file mathplot.cpp.
References AdjustLimitedView(), m_desiredYmax, m_desiredYmin, and m_posY.
Referenced by onMouseMove(), and PerformMouseWheelAction().
|
inline |
Definition at line 1268 of file mathplot.h.
Referenced by SIMULATOR_FRAME::setupUIConditions().
void mpWindow::UpdateAll | ( | ) |
Refresh display.
Definition at line 2286 of file mathplot.cpp.
References Refresh(), and UpdateBBox().
Referenced by AddLayer(), DelAllLayers(), DelLayer(), DoZoom(), Fit(), mpWindow(), SIM_PLOT_TAB::OnLanguageChanged(), onMouseMove(), SIMULATOR_FRAME_UI::onSignalsGridCellChanged(), SIMULATOR_FRAME_UI::OnSimRefresh(), PerformMouseWheelAction(), SaveScreenshot(), SIM_PLOT_TAB::SetDottedSecondary(), SetLayerVisible(), SetScaleX(), SIM_PLOT_TAB::ShowGrid(), SIM_PLOT_TAB::ShowLegend(), SIM_PLOT_TAB::SIM_PLOT_TAB(), and SIM_PLOT_TAB::UpdatePlotColors().
|
protectedvirtual |
Recalculate global layer bounding box, and save it in m_minX,...
Definition at line 2275 of file mathplot.cpp.
References m_maxX, m_maxY, m_minX, and m_minY.
Referenced by Fit(), and UpdateAll().
|
protected |
Definition at line 2189 of file mathplot.cpp.
References m_desiredXmax, m_desiredXmin, m_desiredYmax, m_desiredYmin, m_enableLimitedView, m_leftRightPlotGapFactor, m_maxX, m_maxY, m_minX, m_minY, and m_topBottomPlotGapFactor.
Referenced by DoZoom(), and ZoomRect().
|
inline |
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.
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().
|
inline |
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.
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().
void mpWindow::ZoomIn | ( | const wxPoint & | centerPoint, |
double | zoomFactor, | ||
wxOrientation | directions = wxBOTH |
||
) |
Definition at line 1789 of file mathplot.cpp.
References DoZoom().
void mpWindow::ZoomIn | ( | const wxPoint & | centerPoint = wxDefaultPosition | ) |
Zoom into current view and refresh display.
centerPoint | The point (pixel coordinates) that will stay in the same position on the screen after the zoom (by default, the center of the mpWindow). |
Definition at line 1783 of file mathplot.cpp.
References ZoomIn(), and zoomIncrementalFactor.
Referenced by onMagnify(), onZoomIn(), PerformMouseWheelAction(), and ZoomIn().
void mpWindow::ZoomOut | ( | const wxPoint & | centerPoint, |
double | zoomFactor, | ||
wxOrientation | directions = wxBOTH |
||
) |
Definition at line 1801 of file mathplot.cpp.
References DoZoom().
void mpWindow::ZoomOut | ( | const wxPoint & | centerPoint = wxDefaultPosition | ) |
Zoom out current view and refresh display.
centerPoint | The point (pixel coordinates) that will stay in the same position on the screen after the zoom (by default, the center of the mpWindow). |
Definition at line 1795 of file mathplot.cpp.
References zoomIncrementalFactor, and ZoomOut().
Referenced by onMagnify(), onZoomOut(), PerformMouseWheelAction(), and ZoomOut().
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().
void mpWindow::ZoomRedo | ( | ) |
Definition at line 1883 of file mathplot.cpp.
References AdjustLimitedView(), Fit(), m_desiredXmax, m_desiredXmin, m_desiredYmax, m_desiredYmin, m_redoZoomStack, m_undoZoomStack, and zoom.
Referenced by onZoomRedo().
void mpWindow::ZoomUndo | ( | ) |
Definition at line 1868 of file mathplot.cpp.
References AdjustLimitedView(), Fit(), m_desiredXmax, m_desiredXmin, m_desiredYmax, m_desiredYmin, m_redoZoomStack, m_undoZoomStack, and zoom.
Referenced by onZoomUndo().
|
protected |
Definition at line 1326 of file mathplot.h.
Referenced by SetColourTheme().
|
protected |
Definition at line 1324 of file mathplot.h.
Referenced by mpWindow(), and SetColourTheme().
|
protected |
Definition at line 1360 of file mathplot.h.
Referenced by OnPaint(), and ~mpWindow().
|
protected |
Definition at line 1359 of file mathplot.h.
Referenced by initializeGraphicsContext(), and OnPaint().
|
protected |
Definition at line 1338 of file mathplot.h.
Referenced by OnCenter(), and OnShowPopupMenu().
|
protected |
Definition at line 1339 of file mathplot.h.
Referenced by OnCenter(), and OnShowPopupMenu().
|
protected |
Definition at line 1349 of file mathplot.h.
Referenced by AdjustLimitedView(), DoZoom(), Fit(), OnFit(), onMouseMove(), OnSize(), PerformMouseWheelAction(), SaveScreenshot(), SetXView(), ViewNeedsRefitting(), ZoomRect(), ZoomRedo(), and ZoomUndo().
|
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.
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().
|
protected |
Definition at line 1349 of file mathplot.h.
Referenced by AdjustLimitedView(), DoZoom(), Fit(), OnFit(), onMouseMove(), OnSize(), PerformMouseWheelAction(), RecomputeDesiredY(), SaveScreenshot(), SetYView(), ViewNeedsRefitting(), ZoomRect(), ZoomRedo(), and ZoomUndo().
|
protected |
Definition at line 1349 of file mathplot.h.
Referenced by AdjustLimitedView(), DoZoom(), Fit(), OnFit(), onMouseMove(), OnSize(), PerformMouseWheelAction(), SaveScreenshot(), SetYView(), ViewNeedsRefitting(), ZoomRect(), ZoomRedo(), and ZoomUndo().
|
protected |
Definition at line 1361 of file mathplot.h.
Referenced by OnPaint().
|
protected |
Definition at line 1363 of file mathplot.h.
Referenced by AdjustLimitedView(), and ViewNeedsRefitting().
|
protected |
Definition at line 1362 of file mathplot.h.
Referenced by onMagnify(), onMouseMove(), and onMouseWheel().
|
protected |
Definition at line 1325 of file mathplot.h.
Referenced by mpWindow(), onMouseMove(), OnPaint(), SaveScreenshot(), and SetColourTheme().
|
protected |
Definition at line 1358 of file mathplot.h.
Referenced by OnPaint().
|
protected |
Definition at line 1358 of file mathplot.h.
Referenced by OnPaint().
|
protected |
Definition at line 1322 of file mathplot.h.
Referenced by AddLayer(), DelAllLayers(), DelLayer(), GetLayer(), GetLayerByName(), IsInsideInfoLayer(), mpWindow(), onMouseMove(), OnPaint(), SaveScreenshot(), and SetColourTheme().
|
protected |
Definition at line 1354 of file mathplot.h.
Referenced by Fit(), RecomputeDesiredX(), and ViewNeedsRefitting().
|
protected |
Definition at line 1356 of file mathplot.h.
Referenced by DoZoom(), Fit(), OnCenter(), RecomputeDesiredY(), SetMargins(), and ZoomRect().
|
protected |
Definition at line 1356 of file mathplot.h.
Referenced by DoZoom(), Fit(), OnCenter(), RecomputeDesiredX(), SetMargins(), and ZoomRect().
|
protected |
Definition at line 1356 of file mathplot.h.
Referenced by DoZoom(), Fit(), OnCenter(), RecomputeDesiredX(), SetMargins(), and ZoomRect().
|
protected |
Definition at line 1356 of file mathplot.h.
Referenced by DoZoom(), Fit(), OnCenter(), RecomputeDesiredY(), SetMargins(), and ZoomRect().
|
protected |
Definition at line 1329 of file mathplot.h.
Referenced by AdjustLimitedView(), DoZoom(), Fit(), GetBoundingBox(), SaveScreenshot(), UpdateBBox(), ViewNeedsRefitting(), and ZoomRect().
|
protected |
Definition at line 1331 of file mathplot.h.
Referenced by AdjustLimitedView(), DoZoom(), Fit(), GetBoundingBox(), SaveScreenshot(), UpdateBBox(), ViewNeedsRefitting(), and ZoomRect().
|
protected |
Definition at line 1328 of file mathplot.h.
Referenced by AdjustLimitedView(), DoZoom(), Fit(), GetBoundingBox(), SaveScreenshot(), UpdateBBox(), ViewNeedsRefitting(), and ZoomRect().
|
protected |
Definition at line 1330 of file mathplot.h.
Referenced by AdjustLimitedView(), DoZoom(), Fit(), GetBoundingBox(), SaveScreenshot(), UpdateBBox(), ViewNeedsRefitting(), and ZoomRect().
|
protected |
Definition at line 1366 of file mathplot.h.
Referenced by onMouseLeftDown(), onMouseLeftRelease(), and onMouseMove().
|
protected |
Definition at line 1365 of file mathplot.h.
Referenced by OnMouseMiddleDown(), onMouseMove(), and onZoomIn().
|
protected |
Definition at line 1364 of file mathplot.h.
Referenced by onMouseWheel().
|
protected |
Definition at line 1367 of file mathplot.h.
Referenced by onMouseLeftDown(), onMouseLeftRelease(), and onMouseMove().
|
protected |
Definition at line 1323 of file mathplot.h.
Referenced by mpWindow(), and OnShowPopupMenu().
|
protected |
Definition at line 1334 of file mathplot.h.
Referenced by AdjustLimitedView(), DoZoom(), Fit(), onMouseMove(), PerformMouseWheelAction(), RecomputeDesiredX(), and SetXView().
|
protected |
Definition at line 1335 of file mathplot.h.
Referenced by AdjustLimitedView(), DoZoom(), Fit(), onMouseMove(), PerformMouseWheelAction(), RecomputeDesiredY(), and SetYView().
|
protected |
Definition at line 1371 of file mathplot.h.
Referenced by OnShowPopupMenu(), pushZoomUndo(), ZoomRedo(), and ZoomUndo().
|
protected |
Definition at line 1332 of file mathplot.h.
Referenced by DoZoom(), Fit(), onMouseMove(), PerformMouseWheelAction(), RecomputeDesiredX(), and SetScaleX().
|
protected |
Definition at line 1333 of file mathplot.h.
Referenced by DoZoom(), Fit(), onMouseMove(), PerformMouseWheelAction(), and RecomputeDesiredY().
|
protected |
Definition at line 1336 of file mathplot.h.
Referenced by DoZoom(), Fit(), OnCenter(), OnPaint(), RecomputeDesiredX(), SaveScreenshot(), and ZoomRect().
|
protected |
Definition at line 1337 of file mathplot.h.
Referenced by DoZoom(), Fit(), OnCenter(), OnPaint(), RecomputeDesiredY(), SaveScreenshot(), and ZoomRect().
|
protected |
Definition at line 1353 of file mathplot.h.
Referenced by Fit(), RecomputeDesiredY(), and ViewNeedsRefitting().
|
protected |
Definition at line 1370 of file mathplot.h.
Referenced by OnShowPopupMenu(), pushZoomUndo(), ZoomRedo(), and ZoomUndo().
|
protected |
Definition at line 1341 of file mathplot.h.
Referenced by DoZoom(), PerformMouseWheelAction(), and ZoomRect().
|
protected |
Definition at line 1368 of file mathplot.h.
Referenced by onMouseLeftDown(), onMouseLeftRelease(), onMouseMove(), and OnPaint().
|
protected |
Definition at line 1369 of file mathplot.h.
Referenced by onMouseMove(), and OnPaint().
|
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().