KiCad PCB EDA Suite
mpWindow Class Reference

Canvas for plotting mpLayer implementations. More...

#include <mathplot.h>

Inheritance diagram for mpWindow:

Public Member Functions

 mpWindow ()
 
 mpWindow (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long flags=0)
 
 ~mpWindow ()
 
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=false, 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...
 
mpLayerGetLayer (int position)
 
mpLayerGetLayerByName (const wxString &name)
 
double GetXscl ()
 Get current view's X scale. More...
 
double GetScaleX (void) const
 
double GetYscl () const
 Get current view's Y scale. More...
 
double GetScaleY (void) const
 
double GetXpos () const
 Get current view's X position. More...
 
double GetPosX (void) const
 
double GetYpos () const
 Get current view's Y position. More...
 
double GetPosY (void) const
 
int GetScrX (void) const
 Get current view's X dimension in device context units. More...
 
int GetXScreen (void) const
 
int GetScrY (void) const
 Get current view's Y dimension in device context units. More...
 
int GetYScreen (void) const
 
void SetScaleX (double scaleX)
 Set current view's X scale and refresh display. More...
 
void SetScaleY (double scaleY)
 Set current view's Y scale and refresh display. More...
 
void SetPosX (double posX)
 Set current view's X position and refresh display. More...
 
void SetPosY (double posY)
 Set current view's Y position and refresh display. More...
 
void SetPos (double posX, double posY)
 Set current view's X and Y position and refresh display. More...
 
void SetScr (int scrX, int scrY)
 Set current view's dimensions in device context units. More...
 
double p2x (wxCoord pixelCoordX)
 Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale. More...
 
double p2y (wxCoord pixelCoordY)
 Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale. More...
 
wxCoord x2p (double x)
 Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale. More...
 
wxCoord y2p (double y)
 Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale. More...
 
void EnableDoubleBuffer (bool enabled)
 Enable/disable the double-buffering of the window, eliminating the flicker (default=disabled). More...
 
void EnableMousePanZoom (bool enabled)
 Enable/disable the feature of pan/zoom with the mouse (default=enabled) More...
 
void EnableMouseWheelPan (bool enabled)
 Enable/disable trackpad friendly panning (2-axis scroll wheel) More...
 
void LockAspect (bool enable=TRUE)
 Enable or disable X/Y scale aspect locking for the view. More...
 
bool IsAspectLocked ()
 Checks whether the X/Y scale aspect is locked. More...
 
void Fit () override
 Set view to fit global bounding box of all plot layers and refresh display. More...
 
void Fit (double xMin, double xMax, double yMin, double yMax, wxCoord *printSizeX=NULL, wxCoord *printSizeY=NULL)
 Set view to fit a given bounding box and refresh display. More...
 
void ZoomIn (const wxPoint &centerPoint=wxDefaultPosition)
 Zoom into current view and refresh display. More...
 
void ZoomIn (const wxPoint &centerPoint, double zoomFactor)
 
void ZoomOut (const wxPoint &centerPoint=wxDefaultPosition)
 Zoom out current view and refresh display. More...
 
void ZoomOut (const wxPoint &centerPoint, double zoomFactor)
 
void ZoomInX ()
 Zoom in current view along X and refresh display. More...
 
void ZoomOutX ()
 Zoom out current view along X and refresh display. More...
 
void ZoomInY ()
 Zoom in current view along Y and refresh display. More...
 
void ZoomOutY ()
 Zoom out current view along Y and refresh display. More...
 
void ZoomRect (wxPoint p0, wxPoint p1)
 Zoom view fitting given coordinates to the window (p0 and p1 do not need to be in any specific order) More...
 
void UpdateAll ()
 Refresh display. More...
 
unsigned int CountLayers ()
 Counts the number of plot layers, excluding axes or text: 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...
 
double GetDesiredXmin ()
 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 ()
 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 ()
 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 ()
 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)
 Returns the bounding box coordinates. More...
 
void SetMPScrollbars (bool status)
 Enable/disable scrollbars. More...
 
bool GetMPScrollbars ()
 Get scrollbars status. More...
 
bool SaveScreenshot (const wxString &filename, wxBitmapType type=wxBITMAP_TYPE_BMP, wxSize imageSize=wxDefaultSize, bool fit=false)
 Draw the window on a wxBitmap, then save it to a file. More...
 
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...
 
void SetMarginRight (int right)
 Set the right margin. More...
 
void SetMarginBottom (int bottom)
 Set the bottom margin. More...
 
void SetMarginLeft (int left)
 Set the left margin. More...
 
int GetMarginTop ()
 
int GetMarginRight ()
 
int GetMarginBottom ()
 
int GetMarginLeft ()
 
mpInfoLayerIsInsideInfoLayer (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...
 
void SetLayerVisible (const unsigned int position, bool viewable)
 Sets the visibility of a layer by its position in layer list. More...
 
bool IsLayerVisible (const unsigned int position)
 Check whether the layer at given position is visible. More...
 
void SetColourTheme (const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour)
 Set Color theme. More...
 
const wxColour & GetAxesColour ()
 Get axes draw colour. More...
 
void LimitView (bool aEnable)
 Limit zooming & panning to the area used by the plots. More...
 

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

Protected Member Functions

void OnPaint (wxPaintEvent &event)
 
void OnSize (wxSizeEvent &event)
 
void OnShowPopupMenu (wxMouseEvent &event)
 
void OnMouseMiddleDown (wxMouseEvent &event)
 
void OnCenter (wxCommandEvent &event)
 
void OnFit (wxCommandEvent &event)
 
void OnZoomIn (wxCommandEvent &event)
 
void OnZoomOut (wxCommandEvent &event)
 
void OnLockAspect (wxCommandEvent &event)
 
void OnMouseWheel (wxMouseEvent &event)
 
void OnMagnify (wxMouseEvent &event)
 
void OnMouseMove (wxMouseEvent &event)
 
void OnMouseLeftDown (wxMouseEvent &event)
 
void OnMouseLeftRelease (wxMouseEvent &event)
 
void OnScrollThumbTrack (wxScrollWinEvent &event)
 
void OnScrollPageUp (wxScrollWinEvent &event)
 
void OnScrollPageDown (wxScrollWinEvent &event)
 
void OnScrollLineUp (wxScrollWinEvent &event)
 
void OnScrollLineDown (wxScrollWinEvent &event)
 
void OnScrollTop (wxScrollWinEvent &event)
 
void OnScrollBottom (wxScrollWinEvent &event)
 
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)
 
bool CheckXLimits (double &desiredMax, double &desiredMin) const
 
bool CheckYLimits (double &desiredMax, double &desiredMin) const
 
void AdjustLimitedView ()
 
virtual bool UpdateBBox ()
 Recalculate global layer bounding box, and save it in m_minX,... More...
 
virtual bool SetXView (double pos, double desiredMax, double desiredMin)
 Applies new X view coordinates depending on the settings. More...
 
virtual bool SetYView (double pos, double desiredMax, double desiredMin)
 Applies new Y view coordinates depending on the settings. More...
 

Protected Attributes

wxLayerList m_layers
 
wxMenu m_popmenu
 
bool m_lockaspect
 
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
 
double m_desiredXmin
 These are updated in Fit() only, and may be different from the real borders (layer coordinates) only if lock aspect ratio is true. More...
 
double m_desiredXmax
 
double m_desiredYmin
 
double m_desiredYmax
 
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_enableMouseWheelPan
 
bool m_enableLimitedView
 
wxPoint m_mouseMClick
 
wxPoint m_mouseLClick
 
bool m_enableScrollBars
 
wxPoint m_scroll
 
mpInfoLayerm_movingInfoLayer
 
bool m_zooming
 
wxRect m_zoomRect
 

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 1047 of file mathplot.h.

Constructor & Destructor Documentation

◆ mpWindow() [1/2]

mpWindow::mpWindow ( )
inline

Definition at line 1050 of file mathplot.h.

1050 {}

◆ mpWindow() [2/2]

mpWindow::mpWindow ( wxWindow *  parent,
wxWindowID  id,
const wxPoint pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  flags = 0 
)

◆ ~mpWindow()

mpWindow::~mpWindow ( )

Definition at line 1749 of file mathplot.cpp.

1750 {
1751  // Free all the layers:
1752  DelAllLayers( true, false );
1753 
1754  if( m_buff_bmp )
1755  {
1756  delete m_buff_bmp;
1757  m_buff_bmp = NULL;
1758  }
1759 }
#define NULL
void DelAllLayers(bool alsoDeleteObject, bool refreshDisplay=true)
Remove all layers from the plot.
Definition: mathplot.cpp:2516
wxBitmap * m_buff_bmp
Definition: mathplot.h:1527

References DelAllLayers(), m_buff_bmp, and NULL.

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 2472 of file mathplot.cpp.

2473 {
2474  if( layer != NULL )
2475  {
2476  m_layers.push_back( layer );
2477 
2478  if( refreshDisplay )
2479  UpdateAll();
2480 
2481  return true;
2482  }
2483 
2484  ;
2485  return false;
2486 }
wxLayerList m_layers
Definition: mathplot.h:1497
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820
#define NULL

References m_layers, NULL, and UpdateAll().

Referenced by SIM_PLOT_PANEL::AddTrace(), SIM_PLOT_PANEL::EnableCursor(), and SIM_PLOT_PANEL::SIM_PLOT_PANEL().

◆ AdjustLimitedView()

void mpWindow::AdjustLimitedView ( )
protected

Definition at line 2169 of file mathplot.cpp.

2170 {
2171  if( !m_enableLimitedView )
2172  return;
2173 
2174  // m_min and m_max are plot limits for curves
2175  // xMin, xMax, yMin, yMax are the full limits (plot limit + margin)
2176  const double xMin = m_minX - m_marginLeft / m_scaleX;
2177  const double xMax = m_maxX + m_marginRight / m_scaleX;
2178  const double yMin = m_minY - m_marginTop / m_scaleY;
2179  const double yMax = m_maxY + m_marginBottom / m_scaleY;
2180 
2181  if( m_desiredXmin < xMin )
2182  {
2183  double diff = xMin - m_desiredXmin;
2184  m_posX += diff;
2185  m_desiredXmax += diff;
2186  m_desiredXmin = xMin;
2187  }
2188 
2189  if( m_desiredXmax > xMax )
2190  {
2191  double diff = m_desiredXmax - xMax;
2192  m_posX -= diff;
2193  m_desiredXmin -= diff;
2194  m_desiredXmax = xMax;
2195  }
2196 
2197  if( m_desiredYmin < yMin )
2198  {
2199  double diff = yMin - m_desiredYmin;
2200  m_posY += diff;
2201  m_desiredYmax += diff;
2202  m_desiredYmin = yMin;
2203  }
2204 
2205  if( m_desiredYmax > yMax )
2206  {
2207  double diff = m_desiredYmax - yMax;
2208  m_posY -= diff;
2209  m_desiredYmin -= diff;
2210  m_desiredYmax = yMax;
2211  }
2212 }
int m_marginRight
Definition: mathplot.h:1523
int m_marginLeft
Definition: mathplot.h:1523
double m_desiredXmax
Definition: mathplot.h:1521
double m_scaleY
Definition: mathplot.h:1510
double m_posX
Definition: mathplot.h:1511
double m_minY
Definition: mathplot.h:1507
double m_scaleX
Definition: mathplot.h:1509
double m_desiredYmax
Definition: mathplot.h:1521
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1521
double m_posY
Definition: mathplot.h:1512
int m_marginTop
Definition: mathplot.h:1523
double m_minX
Definition: mathplot.h:1505
double m_desiredYmin
Definition: mathplot.h:1521
int m_marginBottom
Definition: mathplot.h:1523
bool m_enableLimitedView
Definition: mathplot.h:1531
double m_maxX
Definition: mathplot.h:1506
double m_maxY
Definition: mathplot.h:1508

References m_desiredXmax, m_desiredXmin, m_desiredYmax, m_desiredYmin, m_enableLimitedView, m_marginBottom, m_marginLeft, m_marginRight, m_marginTop, m_maxX, m_maxY, m_minX, m_minY, m_posX, m_posY, m_scaleX, and m_scaleY.

Referenced by SetXView(), SetYView(), ZoomIn(), and ZoomRect().

◆ CheckXLimits()

bool mpWindow::CheckXLimits ( double &  desiredMax,
double &  desiredMin 
) const
inlineprotected

Definition at line 1465 of file mathplot.h.

1466  {
1467  return !( m_enableLimitedView
1468  && (desiredMax > m_maxX - m_marginRight / m_scaleX
1469  || desiredMin < m_minX - m_marginLeft / m_scaleX) );
1470  }
int m_marginRight
Definition: mathplot.h:1523
int m_marginLeft
Definition: mathplot.h:1523
double m_scaleX
Definition: mathplot.h:1509
double m_minX
Definition: mathplot.h:1505
bool m_enableLimitedView
Definition: mathplot.h:1531
double m_maxX
Definition: mathplot.h:1506

Referenced by ZoomOut().

◆ CheckYLimits()

bool mpWindow::CheckYLimits ( double &  desiredMax,
double &  desiredMin 
) const
inlineprotected

Definition at line 1472 of file mathplot.h.

1473  {
1474  return !( m_enableLimitedView
1475  && (desiredMax > m_maxY + m_marginBottom / m_scaleY
1476  || desiredMin < m_minY + m_marginTop / m_scaleY) );
1477  }
double m_scaleY
Definition: mathplot.h:1510
double m_minY
Definition: mathplot.h:1507
int m_marginTop
Definition: mathplot.h:1523
int m_marginBottom
Definition: mathplot.h:1523
bool m_enableLimitedView
Definition: mathplot.h:1531
double m_maxY
Definition: mathplot.h:1508

Referenced by ZoomOut().

◆ CountAllLayers()

unsigned int mpWindow::CountAllLayers ( )
inline

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

Returns
The number of layers in the mpWindow.

Definition at line 1290 of file mathplot.h.

1290 { return m_layers.size(); };
wxLayerList m_layers
Definition: mathplot.h:1497

Referenced by mpPrintout::OnPrintPage(), and mpInfoLegend::Plot().

◆ CountLayers()

unsigned int mpWindow::CountLayers ( )

Counts the number of plot layers, excluding axes or text: this is to count only the layers which have a bounding box.

Returns
The number of profiles plotted.

Definition at line 3003 of file mathplot.cpp.

3004 {
3005  // wxNode *node = m_layers.GetFirst();
3006  unsigned int layerNo = 0;
3007 
3008  for( wxLayerList::iterator li = m_layers.begin(); li != m_layers.end(); li++ ) // while(node)
3009  {
3010  if( (*li)->HasBBox() )
3011  layerNo++;
3012 
3013  // node = node->GetNext();
3014  }
3015 
3016  ;
3017  return layerNo;
3018 }
wxLayerList m_layers
Definition: mathplot.h:1497

References m_layers.

◆ 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 2516 of file mathplot.cpp.

2517 {
2518  while( m_layers.size()>0 )
2519  {
2520  // Also delete the object?
2521  if( alsoDeleteObject )
2522  delete m_layers[0];
2523 
2524  m_layers.erase( m_layers.begin() ); // this deleted the reference only
2525  }
2526 
2527  if( refreshDisplay )
2528  UpdateAll();
2529 }
wxLayerList m_layers
Definition: mathplot.h:1497
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820

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 2489 of file mathplot.cpp.

2492 {
2493  wxLayerList::iterator layIt;
2494 
2495  for( layIt = m_layers.begin(); layIt != m_layers.end(); layIt++ )
2496  {
2497  if( *layIt == layer )
2498  {
2499  // Also delete the object?
2500  if( alsoDeleteObject )
2501  delete *layIt;
2502 
2503  m_layers.erase( layIt ); // this deleted the reference only
2504 
2505  if( refreshDisplay )
2506  UpdateAll();
2507 
2508  return true;
2509  }
2510  }
2511 
2512  return false;
2513 }
wxLayerList m_layers
Definition: mathplot.h:1497
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820

References m_layers, and UpdateAll().

Referenced by SIM_PLOT_PANEL::AddTrace(), SIM_PLOT_PANEL::DeleteTrace(), and SIM_PLOT_PANEL::EnableCursor().

◆ DoScrollCalc()

void mpWindow::DoScrollCalc ( const int  position,
const int  orientation 
)
protected

Definition at line 2867 of file mathplot.cpp.

2868 {
2869  if( orientation == wxVERTICAL )
2870  {
2871  // Y axis
2872  // Get top margin in coord units
2873  double topMargin = m_marginTop / m_scaleY;
2874  // Calculate maximum Y coord to be shown in the graph
2875  double maxY = m_desiredYmax > m_maxY ? m_desiredYmax : m_maxY;
2876  // Set new position
2877  SetPosY( ( maxY - (position / m_scaleY) ) + topMargin );
2878  }
2879  else
2880  {
2881  // X Axis
2882  // Get left margin in coord units
2883  double leftMargin = m_marginLeft / m_scaleX;
2884  // Calculate minimum X coord to be shown in the graph
2885  double minX = (m_desiredXmin < m_minX) ? m_desiredXmin : m_minX;
2886  // Set new position
2887  SetPosX( ( minX + (position / m_scaleX) ) - leftMargin );
2888  }
2889 }
int m_marginLeft
Definition: mathplot.h:1523
double m_scaleY
Definition: mathplot.h:1510
double m_scaleX
Definition: mathplot.h:1509
void SetPosX(double posX)
Set current view's X position and refresh display.
Definition: mathplot.h:1166
void SetPosY(double posY)
Set current view's Y position and refresh display.
Definition: mathplot.h:1171
double m_desiredYmax
Definition: mathplot.h:1521
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1521
int m_marginTop
Definition: mathplot.h:1523
double m_minX
Definition: mathplot.h:1505
double m_maxY
Definition: mathplot.h:1508

References m_desiredXmin, m_desiredYmax, m_marginLeft, m_marginTop, m_maxY, m_minX, m_scaleX, m_scaleY, SetPosX(), and SetPosY().

Referenced by OnScrollBottom(), OnScrollLineDown(), OnScrollLineUp(), OnScrollPageDown(), OnScrollPageUp(), OnScrollThumbTrack(), and OnScrollTop().

◆ DoZoomInXCalc()

void mpWindow::DoZoomInXCalc ( const int  staticXpixel)
protected

Definition at line 2089 of file mathplot.cpp.

2090 {
2091  // Preserve the position of the clicked point:
2092  double staticX = p2x( staticXpixel );
2093 
2094  // Zoom in:
2096  // Adjust the new m_posx
2097  m_posX = staticX - (staticXpixel / m_scaleX);
2098  // Adjust desired
2101 #ifdef MATHPLOT_DO_LOGGING
2102  wxLogMessage(
2103  "mpWindow::DoZoomInXCalc() prior X coord: (%f), new X coord: (%f) SHOULD BE EQUAL!!",
2104  staticX, p2x( staticXpixel ) );
2105 #endif
2106 }
int m_marginRight
Definition: mathplot.h:1523
int m_marginLeft
Definition: mathplot.h:1523
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1189
double m_desiredXmax
Definition: mathplot.h:1521
double m_posX
Definition: mathplot.h:1511
double m_scaleX
Definition: mathplot.h:1509
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1521
static double zoomIncrementalFactor
This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse...
Definition: mathplot.h:1348
int m_scrX
Definition: mathplot.h:1513

References m_desiredXmax, m_desiredXmin, m_marginLeft, m_marginRight, m_posX, m_scaleX, m_scrX, p2x(), and zoomIncrementalFactor.

◆ DoZoomInYCalc()

void mpWindow::DoZoomInYCalc ( const int  staticYpixel)
protected

Definition at line 2109 of file mathplot.cpp.

2110 {
2111  // Preserve the position of the clicked point:
2112  double staticY = p2y( staticYpixel );
2113 
2114  // Zoom in:
2116  // Adjust the new m_posy:
2117  m_posY = staticY + (staticYpixel / m_scaleY);
2118  // Adjust desired
2121 #ifdef MATHPLOT_DO_LOGGING
2122  wxLogMessage(
2123  "mpWindow::DoZoomInYCalc() prior Y coord: (%f), new Y coord: (%f) SHOULD BE EQUAL!!",
2124  staticY, p2y( staticYpixel ) );
2125 #endif
2126 }
double m_scaleY
Definition: mathplot.h:1510
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1194
double m_desiredYmax
Definition: mathplot.h:1521
double m_posY
Definition: mathplot.h:1512
int m_marginTop
Definition: mathplot.h:1523
double m_desiredYmin
Definition: mathplot.h:1521
int m_marginBottom
Definition: mathplot.h:1523
int m_scrY
Definition: mathplot.h:1514
static double zoomIncrementalFactor
This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse...
Definition: mathplot.h:1348

References m_desiredYmax, m_desiredYmin, m_marginBottom, m_marginTop, m_posY, m_scaleY, m_scrY, p2y(), and zoomIncrementalFactor.

◆ DoZoomOutXCalc()

void mpWindow::DoZoomOutXCalc ( const int  staticXpixel)
protected

Definition at line 2129 of file mathplot.cpp.

2130 {
2131  // Preserve the position of the clicked point:
2132  double staticX = p2x( staticXpixel );
2133 
2134  // Zoom out:
2136  // Adjust the new m_posx/y:
2137  m_posX = staticX - (staticXpixel / m_scaleX);
2138  // Adjust desired
2141 #ifdef MATHPLOT_DO_LOGGING
2142  wxLogMessage(
2143  "mpWindow::DoZoomOutXCalc() prior X coord: (%f), new X coord: (%f) SHOULD BE EQUAL!!",
2144  staticX, p2x( staticXpixel ) );
2145 #endif
2146 }
int m_marginRight
Definition: mathplot.h:1523
int m_marginLeft
Definition: mathplot.h:1523
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1189
double m_desiredXmax
Definition: mathplot.h:1521
double m_posX
Definition: mathplot.h:1511
double m_scaleX
Definition: mathplot.h:1509
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1521
static double zoomIncrementalFactor
This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse...
Definition: mathplot.h:1348
int m_scrX
Definition: mathplot.h:1513

References m_desiredXmax, m_desiredXmin, m_marginLeft, m_marginRight, m_posX, m_scaleX, m_scrX, p2x(), and zoomIncrementalFactor.

◆ DoZoomOutYCalc()

void mpWindow::DoZoomOutYCalc ( const int  staticYpixel)
protected

Definition at line 2149 of file mathplot.cpp.

2150 {
2151  // Preserve the position of the clicked point:
2152  double staticY = p2y( staticYpixel );
2153 
2154  // Zoom out:
2156  // Adjust the new m_posx/y:
2157  m_posY = staticY + (staticYpixel / m_scaleY);
2158  // Adjust desired
2161 #ifdef MATHPLOT_DO_LOGGING
2162  wxLogMessage(
2163  "mpWindow::DoZoomOutYCalc() prior Y coord: (%f), new Y coord: (%f) SHOULD BE EQUAL!!",
2164  staticY, p2y( staticYpixel ) );
2165 #endif
2166 }
double m_scaleY
Definition: mathplot.h:1510
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1194
double m_desiredYmax
Definition: mathplot.h:1521
double m_posY
Definition: mathplot.h:1512
int m_marginTop
Definition: mathplot.h:1523
double m_desiredYmin
Definition: mathplot.h:1521
int m_marginBottom
Definition: mathplot.h:1523
int m_scrY
Definition: mathplot.h:1514
static double zoomIncrementalFactor
This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse...
Definition: mathplot.h:1348

References m_desiredYmax, m_desiredYmin, m_marginBottom, m_marginTop, m_posY, m_scaleY, m_scrY, p2y(), and zoomIncrementalFactor.

◆ EnableDoubleBuffer()

void mpWindow::EnableDoubleBuffer ( bool  enabled)
inline

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

Definition at line 1209 of file mathplot.h.

1209 { m_enableDoubleBuffer = enabled; }
bool m_enableDoubleBuffer
Definition: mathplot.h:1528

Referenced by SIM_PLOT_PANEL::SIM_PLOT_PANEL().

◆ EnableMousePanZoom()

void mpWindow::EnableMousePanZoom ( bool  enabled)
inline

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

Definition at line 1213 of file mathplot.h.

1213 { m_enableMouseNavigation = enabled; }
bool m_enableMouseNavigation
Definition: mathplot.h:1529

◆ EnableMouseWheelPan()

void mpWindow::EnableMouseWheelPan ( bool  enabled)
inline

Enable/disable trackpad friendly panning (2-axis scroll wheel)

Definition at line 1217 of file mathplot.h.

1217 { m_enableMouseWheelPan = enabled; }
bool m_enableMouseWheelPan
Definition: mathplot.h:1530

Referenced by SIM_PLOT_FRAME::NewPlotPanel().

◆ 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 1998 of file mathplot.cpp.

1999 {
2000  if( UpdateBBox() )
2001  Fit( m_minX, m_maxX, m_minY, m_maxY );
2002 }
double m_minY
Definition: mathplot.h:1507
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:1998
double m_minX
Definition: mathplot.h:1505
virtual bool UpdateBBox()
Recalculate global layer bounding box, and save it in m_minX,...
Definition: mathplot.cpp:2712
double m_maxX
Definition: mathplot.h:1506
double m_maxY
Definition: mathplot.h:1508

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

Referenced by LockAspect(), SIM_PLOT_FRAME::menuZoomFit(), OnFit(), mpPrintout::OnPrintPage(), OnSize(), SIM_PLOT_FRAME::removePlot(), SaveScreenshot(), ZoomOut(), and ZoomRect().

◆ Fit() [2/2]

void mpWindow::Fit ( double  xMin,
double  xMax,
double  yMin,
double  yMax,
wxCoord *  printSizeX = NULL,
wxCoord *  printSizeY = NULL 
)

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 2006 of file mathplot.cpp.

2008 {
2009  // Save desired borders:
2010  m_desiredXmin = xMin; m_desiredXmax = xMax;
2011  m_desiredYmin = yMin; m_desiredYmax = yMax;
2012 
2013  // Give a small margin to plot area
2014  double xExtra = fabs( xMax - xMin ) * 0.00;
2015  double yExtra = fabs( yMax - yMin ) * 0.03;
2016 
2017  xMin -= xExtra;
2018  xMax += xExtra;
2019  yMin -= yExtra;
2020  yMax += yExtra;
2021 
2022  if( printSizeX!=NULL && printSizeY!=NULL )
2023  {
2024  // Printer:
2025  m_scrX = *printSizeX;
2026  m_scrY = *printSizeY;
2027  }
2028  else
2029  {
2030  // Normal case (screen):
2031  GetClientSize( &m_scrX, &m_scrY );
2032  }
2033 
2034  double Ax, Ay;
2035 
2036  Ax = xMax - xMin;
2037  Ay = yMax - yMin;
2038 
2039  m_scaleX = (Ax!=0) ? (m_scrX - m_marginLeft - m_marginRight) / Ax : 1; // m_scaleX = (Ax!=0) ? m_scrX/Ax : 1;
2040  m_scaleY = (Ay!=0) ? (m_scrY - m_marginTop - m_marginBottom) / Ay : 1; // m_scaleY = (Ay!=0) ? m_scrY/Ay : 1;
2041 
2042  if( m_lockaspect )
2043  {
2044 #ifdef MATHPLOT_DO_LOGGING
2045  wxLogMessage( "mpWindow::Fit()(lock) m_scaleX=%f,m_scaleY=%f", m_scaleX, m_scaleY );
2046 #endif
2047  // Keep the lowest "scale" to fit the whole range required by that axis (to actually "fit"!):
2048  double s = m_scaleX < m_scaleY ? m_scaleX : m_scaleY;
2049  m_scaleX = s;
2050  m_scaleY = s;
2051  }
2052 
2053  // Adjusts corner coordinates: This should be simply:
2054  // m_posX = m_minX;
2055  // m_posY = m_maxY;
2056  // But account for centering if we have lock aspect:
2057  m_posX = (xMin + xMax) / 2 - ( (m_scrX - m_marginLeft - m_marginRight) / 2 + m_marginLeft ) /
2058  m_scaleX; // m_posX = (xMin+xMax)/2 - (m_scrX/2)/m_scaleX;
2059  // m_posY = (yMin+yMax)/2 + ((m_scrY - m_marginTop - m_marginBottom)/2 - m_marginTop)/m_scaleY; // m_posY = (yMin+yMax)/2 + (m_scrY/2)/m_scaleY;
2060  m_posY = (yMin + yMax) / 2 + ( (m_scrY - m_marginTop - m_marginBottom) / 2 + m_marginTop ) /
2061  m_scaleY; // m_posY = (yMin+yMax)/2 + (m_scrY/2)/m_scaleY;
2062 
2063 #ifdef MATHPLOT_DO_LOGGING
2064  wxLogMessage(
2065  "mpWindow::Fit() m_desiredXmin=%f m_desiredXmax=%f m_desiredYmin=%f m_desiredYmax=%f",
2066  xMin,
2067  xMax,
2068  yMin,
2069  yMax );
2070  wxLogMessage(
2071  "mpWindow::Fit() m_scaleX = %f , m_scrX = %d,m_scrY=%d, Ax=%f, Ay=%f, m_posX=%f, m_posY=%f",
2072  m_scaleX,
2073  m_scrX,
2074  m_scrY,
2075  Ax,
2076  Ay,
2077  m_posX,
2078  m_posY );
2079 #endif
2080 
2081  // It is VERY IMPORTANT to DO NOT call Refresh if we are drawing to the printer!!
2082  // Otherwise, the DC dimensions will be those of the window instead of the printer device
2083  if( printSizeX==NULL || printSizeY==NULL )
2084  UpdateAll();
2085 }
int m_marginRight
Definition: mathplot.h:1523
int m_marginLeft
Definition: mathplot.h:1523
double m_desiredXmax
Definition: mathplot.h:1521
double m_scaleY
Definition: mathplot.h:1510
double m_posX
Definition: mathplot.h:1511
double m_scaleX
Definition: mathplot.h:1509
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820
#define NULL
double m_desiredYmax
Definition: mathplot.h:1521
bool m_lockaspect
Definition: mathplot.h:1499
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1521
double m_posY
Definition: mathplot.h:1512
int m_marginTop
Definition: mathplot.h:1523
double m_desiredYmin
Definition: mathplot.h:1521
int m_marginBottom
Definition: mathplot.h:1523
int m_scrY
Definition: mathplot.h:1514
int m_scrX
Definition: mathplot.h:1513

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

◆ GetAxesColour()

const wxColour& mpWindow::GetAxesColour ( )
inline

Get axes draw colour.

Returns
reference to axis colour used in theme

Definition at line 1423 of file mathplot.h.

1423 { return m_axColour; };
wxColour m_axColour
Definition: mathplot.h:1503

Referenced by mpPrintout::OnPrintPage().

◆ GetBoundingBox()

void mpWindow::GetBoundingBox ( double *  bbox)

Returns the bounding box coordinates.

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

Definition at line 3041 of file mathplot.cpp.

3042 {
3043  bbox[0] = m_minX;
3044  bbox[1] = m_maxX;
3045  bbox[2] = m_minY;
3046  bbox[3] = m_maxY;
3047 }
double m_minY
Definition: mathplot.h:1507
double m_minX
Definition: mathplot.h:1505
double m_maxX
Definition: mathplot.h:1506
double m_maxY
Definition: mathplot.h:1508

References m_maxX, m_maxY, m_minX, and m_minY.

◆ GetDesiredXmax()

double mpWindow::GetDesiredXmax ( )
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 1309 of file mathplot.h.

1309 { return m_desiredXmax; }
double m_desiredXmax
Definition: mathplot.h:1521

Referenced by mpPrintout::OnPrintPage().

◆ GetDesiredXmin()

double mpWindow::GetDesiredXmin ( )
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 1303 of file mathplot.h.

1303 { return m_desiredXmin; }
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1521

Referenced by mpPrintout::OnPrintPage().

◆ GetDesiredYmax()

double mpWindow::GetDesiredYmax ( )
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 1321 of file mathplot.h.

1321 { return m_desiredYmax; }
double m_desiredYmax
Definition: mathplot.h:1521

Referenced by mpPrintout::OnPrintPage().

◆ GetDesiredYmin()

double mpWindow::GetDesiredYmin ( )
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 1315 of file mathplot.h.

1315 { return m_desiredYmin; }
double m_desiredYmin
Definition: mathplot.h:1521

Referenced by mpPrintout::OnPrintPage().

◆ 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

Definition at line 3021 of file mathplot.cpp.

3022 {
3023  if( ( position >= (int) m_layers.size() ) || position < 0 )
3024  return NULL;
3025 
3026  return m_layers[position];
3027 }
wxLayerList m_layers
Definition: mathplot.h:1497
#define NULL

References m_layers, and NULL.

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

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

Definition at line 3030 of file mathplot.cpp.

3031 {
3032  for( wxLayerList::iterator it = m_layers.begin(); it!=m_layers.end(); it++ )
3033  if( !(*it)->GetName().Cmp( name ) )
3034  return *it;
3035 
3036 
3037  return NULL; // Not found
3038 }
wxLayerList m_layers
Definition: mathplot.h:1497
#define NULL
const char * name
Definition: DXF_plotter.cpp:60

References m_layers, name, and NULL.

Referenced by IsLayerVisible(), and SetLayerVisible().

◆ GetMarginBottom()

int mpWindow::GetMarginBottom ( )
inline

◆ GetMarginLeft()

int mpWindow::GetMarginLeft ( )
inline

◆ GetMarginRight()

int mpWindow::GetMarginRight ( )
inline

◆ GetMarginTop()

int mpWindow::GetMarginTop ( )
inline

◆ GetMPScrollbars()

bool mpWindow::GetMPScrollbars ( )
inline

Get scrollbars status.

Returns
true if scrollbars are visible

Definition at line 1334 of file mathplot.h.

1334 { return m_enableScrollBars; };
bool m_enableScrollBars
Definition: mathplot.h:1534

◆ 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 1060 of file mathplot.h.

1060 { return &m_popmenu; }
wxMenu m_popmenu
Definition: mathplot.h:1498

◆ GetPosX()

double mpWindow::GetPosX ( void  ) const
inline

Definition at line 1120 of file mathplot.h.

1120 { return m_posX; }
double m_posX
Definition: mathplot.h:1511

Referenced by mpScaleXBase::Plot(), mpMovableObject::Plot(), and mpBitmapLayer::Plot().

◆ GetPosY()

double mpWindow::GetPosY ( void  ) const
inline

Definition at line 1127 of file mathplot.h.

1127 { return m_posY; }
double m_posY
Definition: mathplot.h:1512

Referenced by mpScaleY::Plot(), mpMovableObject::Plot(), and mpBitmapLayer::Plot().

◆ GetScaleX()

double mpWindow::GetScaleX ( void  ) const
inline

Definition at line 1106 of file mathplot.h.

1106 { return m_scaleX; }; // Schaling's method: maybe another method esists with the same name
double m_scaleX
Definition: mathplot.h:1509

Referenced by mpScaleXBase::Plot(), mpMovableObject::Plot(), and mpBitmapLayer::Plot().

◆ GetScaleY()

double mpWindow::GetScaleY ( void  ) const
inline

Definition at line 1113 of file mathplot.h.

1113 { return m_scaleY; } // Schaling's method: maybe another method exists with the same name
double m_scaleY
Definition: mathplot.h:1510

Referenced by mpScaleY::Plot(), mpMovableObject::Plot(), and mpBitmapLayer::Plot().

◆ GetScrX()

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

Definition at line 1135 of file mathplot.h.

1135 { return m_scrX; }
int m_scrX
Definition: mathplot.h:1513

Referenced by mpScaleXBase::getVisibleDataRange(), mpPrintout::OnPrintPage(), CURSOR::Plot(), mpInfoLayer::Plot(), mpInfoCoords::Plot(), mpInfoLegend::Plot(), mpFX::Plot(), mpFY::Plot(), mpFXY::Plot(), mpProfile::Plot(), mpScaleXBase::Plot(), mpScaleY::Plot(), mpText::Plot(), mpMovableObject::Plot(), and mpBitmapLayer::Plot().

◆ GetScrY()

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

Definition at line 1144 of file mathplot.h.

1144 { return m_scrY; }
int m_scrY
Definition: mathplot.h:1514

Referenced by mpScaleY::getVisibleDataRange(), mpPrintout::OnPrintPage(), CURSOR::Plot(), mpInfoLayer::Plot(), mpInfoCoords::Plot(), mpInfoLegend::Plot(), mpFX::Plot(), mpFY::Plot(), mpFXY::Plot(), mpProfile::Plot(), mpScaleXBase::Plot(), mpScaleY::Plot(), mpText::Plot(), mpMovableObject::Plot(), and mpBitmapLayer::Plot().

◆ GetXpos()

double mpWindow::GetXpos ( ) 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 1119 of file mathplot.h.

1119 { return m_posX; }
double m_posX
Definition: mathplot.h:1511

◆ GetXscl()

double mpWindow::GetXscl ( )
inline

Get current view's X scale.

See rules for coordinate transformation

Returns
Scale

Definition at line 1105 of file mathplot.h.

1105 { return m_scaleX; }
double m_scaleX
Definition: mathplot.h:1509

◆ GetXScreen()

int mpWindow::GetXScreen ( void  ) const
inline

Definition at line 1136 of file mathplot.h.

1136 { return m_scrX; }
int m_scrX
Definition: mathplot.h:1513

Referenced by SIM_PLOT_PANEL::EnableCursor().

◆ GetYpos()

double mpWindow::GetYpos ( ) 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 1126 of file mathplot.h.

1126 { return m_posY; }
double m_posY
Definition: mathplot.h:1512

◆ GetYscl()

double mpWindow::GetYscl ( ) const
inline

Get current view's Y scale.

See rules for coordinate transformation

Returns
Scale

Definition at line 1112 of file mathplot.h.

1112 { return m_scaleY; }
double m_scaleY
Definition: mathplot.h:1510

◆ GetYScreen()

int mpWindow::GetYScreen ( void  ) const
inline

Definition at line 1145 of file mathplot.h.

1145 { return m_scrY; }
int m_scrY
Definition: mathplot.h:1514

◆ IsAspectLocked()

bool mpWindow::IsAspectLocked ( )
inline

Checks whether the X/Y scale aspect is locked.

Return values
TRUELocked
FALSEUnlocked

Definition at line 1230 of file mathplot.h.

1230 { return m_lockaspect; }
bool m_lockaspect
Definition: mathplot.h:1499

◆ 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 3117 of file mathplot.cpp.

3118 {
3119  wxLayerList::iterator li;
3120 
3121  for( li = m_layers.begin(); li != m_layers.end(); li++ )
3122  {
3123 #ifdef MATHPLOT_DO_LOGGING
3124  wxLogMessage( "mpWindow::IsInsideInfoLayer() examinining layer = %p", (*li) );
3125 #endif // MATHPLOT_DO_LOGGING
3126 
3127  if( (*li)->IsInfo() )
3128  {
3129  mpInfoLayer* tmpLyr = (mpInfoLayer*) (*li);
3130 #ifdef MATHPLOT_DO_LOGGING
3131  wxLogMessage( "mpWindow::IsInsideInfoLayer() layer = %p", (*li) );
3132 #endif // MATHPLOT_DO_LOGGING
3133 
3134  if( tmpLyr->Inside( point ) )
3135  {
3136  return tmpLyr;
3137  }
3138  }
3139  }
3140 
3141  return NULL;
3142 }
virtual bool Inside(wxPoint &point)
Checks whether a point is inside the info box rectangle.
Definition: mathplot.cpp:135
wxLayerList m_layers
Definition: mathplot.h:1497
#define NULL
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:336

References mpInfoLayer::Inside(), m_layers, and NULL.

Referenced by OnMouseLeftDown().

◆ 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

Definition at line 3157 of file mathplot.cpp.

3158 {
3159  mpLayer* lx = GetLayerByName( name );
3160 
3161  return (lx) ? lx->IsVisible() : false;
3162 }
bool IsVisible()
Checks whether the layer is visible or not.
Definition: mathplot.h:299
mpLayer * GetLayerByName(const wxString &name)
Definition: mathplot.cpp:3030
const char * name
Definition: DXF_plotter.cpp:60

References GetLayerByName(), mpLayer::IsVisible(), and name.

◆ 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

Definition at line 3177 of file mathplot.cpp.

3178 {
3179  mpLayer* lx = GetLayer( position );
3180 
3181  return (lx) ? lx->IsVisible() : false;
3182 }
mpLayer * GetLayer(int position)
Definition: mathplot.cpp:3021
bool IsVisible()
Checks whether the layer is visible or not.
Definition: mathplot.h:299

References GetLayer(), and mpLayer::IsVisible().

◆ LimitView()

void mpWindow::LimitView ( bool  aEnable)
inline

Limit zooming & panning to the area used by the plots.

Definition at line 1426 of file mathplot.h.

1427  {
1428  m_enableLimitedView = aEnable;
1429  }
bool m_enableLimitedView
Definition: mathplot.h:1531

Referenced by SIM_PLOT_PANEL::SIM_PLOT_PANEL().

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

Definition at line 2410 of file mathplot.cpp.

2411 {
2412  m_lockaspect = enable;
2413  m_popmenu.Check( mpID_LOCKASPECT, enable );
2414 
2415  // Try to fit again with the new config:
2417 }
double m_desiredXmax
Definition: mathplot.h:1521
double m_desiredYmax
Definition: mathplot.h:1521
bool m_lockaspect
Definition: mathplot.h:1499
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1521
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:1998
double m_desiredYmin
Definition: mathplot.h:1521
wxMenu m_popmenu
Definition: mathplot.h:1498

References Fit(), m_desiredXmax, m_desiredXmin, m_desiredYmax, m_desiredYmin, m_lockaspect, m_popmenu, and mpID_LOCKASPECT.

Referenced by OnLockAspect().

◆ OnCenter()

void mpWindow::OnCenter ( wxCommandEvent &  event)
protected

Definition at line 2440 of file mathplot.cpp.

2441 {
2442  GetClientSize( &m_scrX, &m_scrY );
2443  int centerX = (m_scrX - m_marginLeft - m_marginRight) / 2; // + m_marginLeft; // c.x = m_scrX/2;
2444  int centerY = (m_scrY - m_marginTop - m_marginBottom) / 2; // - m_marginTop; // c.y = m_scrY/2;
2445  SetPos( p2x( m_clickedX - centerX ), p2y( m_clickedY - centerY ) );
2446  // SetPos( p2x(m_clickedX-m_scrX/2), p2y(m_clickedY-m_scrY/2) ); //SetPos( (double)(m_clickedX-m_scrX/2) / m_scaleX + m_posX, (double)(m_scrY/2-m_clickedY) / m_scaleY + m_posY);
2447 }
int m_marginRight
Definition: mathplot.h:1523
int m_marginLeft
Definition: mathplot.h:1523
int m_clickedX
Definition: mathplot.h:1515
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1189
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1194
int m_marginTop
Definition: mathplot.h:1523
void SetPos(double posX, double posY)
Set current view's X and Y position and refresh display.
Definition: mathplot.h:1177
int m_clickedY
Definition: mathplot.h:1516
int m_marginBottom
Definition: mathplot.h:1523
int m_scrY
Definition: mathplot.h:1514
int m_scrX
Definition: mathplot.h:1513

References m_clickedX, m_clickedY, m_marginBottom, m_marginLeft, m_marginRight, m_marginTop, m_scrX, m_scrY, p2x(), p2y(), and SetPos().

◆ OnFit()

void mpWindow::OnFit ( wxCommandEvent &  event)
protected

Definition at line 2434 of file mathplot.cpp.

2435 {
2436  Fit();
2437 }
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:1998

References Fit().

◆ OnLockAspect()

void mpWindow::OnLockAspect ( wxCommandEvent &  event)
protected

Definition at line 2428 of file mathplot.cpp.

2429 {
2431 }
bool m_lockaspect
Definition: mathplot.h:1499
void LockAspect(bool enable=TRUE)
Enable or disable X/Y scale aspect locking for the view.
Definition: mathplot.cpp:2410

References LockAspect(), and m_lockaspect.

◆ OnMagnify()

void mpWindow::OnMagnify ( wxMouseEvent &  event)
protected

◆ OnMouseLeftDown()

void mpWindow::OnMouseLeftDown ( wxMouseEvent &  event)
protected

Definition at line 1945 of file mathplot.cpp.

1946 {
1947  m_mouseLClick.x = event.GetX();
1948  m_mouseLClick.y = event.GetY();
1949  m_zooming = true;
1950 #ifdef MATHPLOT_DO_LOGGING
1951  wxLogMessage( "mpWindow::OnMouseLeftDown() X = %d , Y = %d", event.GetX(), event.GetY() ); /*m_mouseLClick.x, m_mouseLClick.y);*/
1952 #endif
1953  wxPoint pointClicked = event.GetPosition();
1954  m_movingInfoLayer = IsInsideInfoLayer( pointClicked );
1955 
1956  if( m_movingInfoLayer != NULL )
1957  {
1958 #ifdef MATHPLOT_DO_LOGGING
1959  wxLogMessage( "mpWindow::OnMouseLeftDown() started moving layer %lx",
1960  (long int) m_movingInfoLayer ); /*m_mouseLClick.x, m_mouseLClick.y);*/
1961 #endif
1962  }
1963 
1964  event.Skip();
1965 }
bool m_zooming
Definition: mathplot.h:1537
mpInfoLayer * IsInsideInfoLayer(wxPoint &point)
Check if a given point is inside the area of a mpInfoLayer and eventually returns its pointer.
Definition: mathplot.cpp:3117
wxPoint m_mouseLClick
Definition: mathplot.h:1533
#define NULL
mpInfoLayer * m_movingInfoLayer
Definition: mathplot.h:1536

References IsInsideInfoLayer(), m_mouseLClick, m_movingInfoLayer, m_zooming, NULL, wxPoint::x, and wxPoint::y.

◆ OnMouseLeftRelease()

void mpWindow::OnMouseLeftRelease ( wxMouseEvent &  event)
protected

Definition at line 1968 of file mathplot.cpp.

1969 {
1970  wxPoint release( event.GetX(), event.GetY() );
1972 
1973  m_zooming = false;
1974 
1975  if( m_movingInfoLayer != NULL )
1976  {
1979  }
1980  else
1981  {
1982  if( release != press )
1983  {
1984  ZoomRect( press, release );
1985  } /*else {
1986  * if (m_coordTooltip) {
1987  * wxString toolTipContent;
1988  * toolTipContent.Printf( "X = %f\nY = %f", p2x(event.GetX()), p2y(event.GetY()));
1989  * SetToolTip(toolTipContent);
1990  * }
1991  * } */
1992  }
1993 
1994  event.Skip();
1995 }
bool m_zooming
Definition: mathplot.h:1537
wxPoint m_mouseLClick
Definition: mathplot.h:1533
#define NULL
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)
Definition: mathplot.cpp:2387
mpInfoLayer * m_movingInfoLayer
Definition: mathplot.h:1536
virtual void UpdateReference()
Updates the rectangle reference point.
Definition: mathplot.cpp:148

References m_mouseLClick, m_movingInfoLayer, m_zooming, NULL, mpInfoLayer::UpdateReference(), wxPoint::x, wxPoint::y, and ZoomRect().

◆ OnMouseMiddleDown()

void mpWindow::OnMouseMiddleDown ( wxMouseEvent &  event)
protected

Definition at line 1764 of file mathplot.cpp.

1765 {
1766  m_mouseMClick.x = event.GetX();
1767  m_mouseMClick.y = event.GetY();
1768 }
wxPoint m_mouseMClick
Definition: mathplot.h:1532

References m_mouseMClick, wxPoint::x, and wxPoint::y.

◆ OnMouseMove()

void mpWindow::OnMouseMove ( wxMouseEvent &  event)
protected

Definition at line 1845 of file mathplot.cpp.

1846 {
1848  {
1849  event.Skip();
1850  return;
1851  }
1852 
1853  if( event.m_middleDown )
1854  {
1855  // The change:
1856  int Ax = m_mouseMClick.x - event.GetX();
1857  int Ay = m_mouseMClick.y - event.GetY();
1858 
1859  // For the next event, use relative to this coordinates.
1860  m_mouseMClick.x = event.GetX();
1861  m_mouseMClick.y = event.GetY();
1862 
1863  double Ax_units = Ax / m_scaleX;
1864  double Ay_units = -Ay / m_scaleY;
1865 
1866  bool updateRequired = false;
1867  updateRequired |= SetXView( m_posX + Ax_units,
1868  m_desiredXmax + Ax_units,
1869  m_desiredXmin + Ax_units );
1870  updateRequired |= SetYView( m_posY + Ay_units,
1871  m_desiredYmax + Ay_units,
1872  m_desiredYmin + Ay_units );
1873 
1874  if( updateRequired )
1875  UpdateAll();
1876 
1877 #ifdef MATHPLOT_DO_LOGGING
1878  wxLogMessage( "[mpWindow::OnMouseMove] Ax:%i Ay:%i m_posX:%f m_posY:%f",
1879  Ax,
1880  Ay,
1881  m_posX,
1882  m_posY );
1883 #endif
1884  }
1885  else
1886  {
1887  if( event.m_leftDown )
1888  {
1889  if( m_movingInfoLayer == NULL )
1890  {
1891  wxClientDC dc( this );
1892  wxPen pen( m_fgColour, 1, wxPENSTYLE_DOT );
1893  dc.SetPen( pen );
1894  dc.SetBrush( *wxTRANSPARENT_BRUSH );
1895  dc.DrawRectangle( m_mouseLClick.x, m_mouseLClick.y,
1896  event.GetX() - m_mouseLClick.x, event.GetY() - m_mouseLClick.y );
1897  m_zooming = true;
1900  m_zoomRect.width = event.GetX() - m_mouseLClick.x;
1901  m_zoomRect.height = event.GetY() - m_mouseLClick.y;
1902  }
1903  else
1904  {
1905  wxPoint moveVector( event.GetX() - m_mouseLClick.x,
1906  event.GetY() - m_mouseLClick.y );
1907  m_movingInfoLayer->Move( moveVector );
1908  m_zooming = false;
1909  }
1910 
1911  UpdateAll();
1912  }
1913  else
1914  {
1915 #if 0
1916  wxLayerList::iterator li;
1917 
1918  for( li = m_layers.begin(); li != m_layers.end(); li++ )
1919  {
1920  if( (*li)->IsInfo() && (*li)->IsVisible() )
1921  {
1922  mpInfoLayer* tmpLyr = (mpInfoLayer*) (*li);
1923  tmpLyr->UpdateInfo( *this, event );
1924  // UpdateAll();
1925  RefreshRect( tmpLyr->GetRectangle() );
1926  }
1927  }
1928 
1929 #endif
1930  /* if (m_coordTooltip) {
1931  * wxString toolTipContent;
1932  * toolTipContent.Printf( "X = %f\nY = %f", p2x(event.GetX()), p2y(event.GetY()));
1933  * wxTipWindow** ptr = NULL;
1934  * wxRect rectBounds(event.GetX(), event.GetY(), 5, 5);
1935  * wxTipWindow* tip = new wxTipWindow(this, toolTipContent, 100, ptr, &rectBounds);
1936  *
1937  * } */
1938  }
1939  }
1940 
1941  event.Skip();
1942 }
bool m_zooming
Definition: mathplot.h:1537
virtual bool SetYView(double pos, double desiredMax, double desiredMin)
Applies new Y view coordinates depending on the settings.
Definition: mathplot.cpp:2229
double m_desiredXmax
Definition: mathplot.h:1521
double m_scaleY
Definition: mathplot.h:1510
bool m_enableMouseNavigation
Definition: mathplot.h:1529
double m_posX
Definition: mathplot.h:1511
wxPoint m_mouseMClick
Definition: mathplot.h:1532
double m_scaleX
Definition: mathplot.h:1509
wxLayerList m_layers
Definition: mathplot.h:1497
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820
wxPoint m_mouseLClick
Definition: mathplot.h:1533
virtual void Move(wxPoint delta)
Moves the layer rectangle of given pixel deltas.
Definition: mathplot.cpp:141
#define NULL
double m_desiredYmax
Definition: mathplot.h:1521
virtual void UpdateInfo(mpWindow &w, wxEvent &event)
Updates the content of the info box.
Definition: mathplot.cpp:130
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:336
wxRect m_zoomRect
Definition: mathplot.h:1538
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1521
mpInfoLayer * m_movingInfoLayer
Definition: mathplot.h:1536
wxColour m_fgColour
Definition: mathplot.h:1502
double m_posY
Definition: mathplot.h:1512
const wxRect & GetRectangle()
Returns the current rectangle coordinates.
Definition: mathplot.h:393
double m_desiredYmin
Definition: mathplot.h:1521
virtual bool SetXView(double pos, double desiredMax, double desiredMin)
Applies new X view coordinates depending on the settings.
Definition: mathplot.cpp:2215

References mpInfoLayer::GetRectangle(), 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(), NULL, SetXView(), SetYView(), UpdateAll(), mpInfoLayer::UpdateInfo(), wxPoint::x, and wxPoint::y.

◆ OnMouseWheel()

void mpWindow::OnMouseWheel ( wxMouseEvent &  event)
protected

Definition at line 1790 of file mathplot.cpp.

1791 {
1793  {
1794  event.Skip();
1795  return;
1796  }
1797 
1798  int change = event.GetWheelRotation();
1799  const int axis = event.GetWheelAxis();
1800  double changeUnitsX = change / m_scaleX;
1801  double changeUnitsY = change / m_scaleY;
1802 
1803  if( ( !m_enableMouseWheelPan && ( event.ControlDown() || event.ShiftDown() ) )
1804  || ( m_enableMouseWheelPan && !event.ControlDown() ) )
1805  {
1806  // Scrolling
1807  if( m_enableMouseWheelPan )
1808  {
1809  if( axis == wxMOUSE_WHEEL_HORIZONTAL || event.ShiftDown() )
1810  SetXView( m_posX + changeUnitsX, m_desiredXmax + changeUnitsX,
1811  m_desiredXmin + changeUnitsX );
1812  else
1813  SetYView( m_posY + changeUnitsY, m_desiredYmax + changeUnitsY,
1814  m_desiredYmin + changeUnitsY );
1815  }
1816  else
1817  {
1818  if( event.ControlDown() )
1819  SetXView( m_posX + changeUnitsX, m_desiredXmax + changeUnitsX,
1820  m_desiredXmin + changeUnitsX );
1821  else
1822  SetYView( m_posY + changeUnitsY, m_desiredYmax + changeUnitsY,
1823  m_desiredYmin + changeUnitsY );
1824  }
1825 
1826  UpdateAll();
1827  }
1828  else
1829  {
1830  // zoom in/out
1831  wxPoint clickPt( event.GetX(), event.GetY() );
1832 
1833  if( event.GetWheelRotation() > 0 )
1834  ZoomIn( clickPt );
1835  else
1836  ZoomOut( clickPt );
1837 
1838  return;
1839  }
1840 }
void ZoomOut(const wxPoint &centerPoint=wxDefaultPosition)
Zoom out current view and refresh display.
Definition: mathplot.cpp:2306
virtual bool SetYView(double pos, double desiredMax, double desiredMin)
Applies new Y view coordinates depending on the settings.
Definition: mathplot.cpp:2229
double m_desiredXmax
Definition: mathplot.h:1521
double m_scaleY
Definition: mathplot.h:1510
bool m_enableMouseNavigation
Definition: mathplot.h:1529
double m_posX
Definition: mathplot.h:1511
bool m_enableMouseWheelPan
Definition: mathplot.h:1530
double m_scaleX
Definition: mathplot.h:1509
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820
double m_desiredYmax
Definition: mathplot.h:1521
void ZoomIn(const wxPoint &centerPoint=wxDefaultPosition)
Zoom into current view and refresh display.
Definition: mathplot.cpp:2243
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1521
double m_posY
Definition: mathplot.h:1512
double m_desiredYmin
Definition: mathplot.h:1521
virtual bool SetXView(double pos, double desiredMax, double desiredMin)
Applies new X view coordinates depending on the settings.
Definition: mathplot.cpp:2215

References m_desiredXmax, m_desiredXmin, m_desiredYmax, m_desiredYmin, m_enableMouseNavigation, m_enableMouseWheelPan, m_posX, m_posY, m_scaleX, m_scaleY, SetXView(), SetYView(), UpdateAll(), ZoomIn(), and ZoomOut().

◆ OnPaint()

void mpWindow::OnPaint ( wxPaintEvent &  event)
protected

Definition at line 2532 of file mathplot.cpp.

2533 {
2534  wxPaintDC dc( this );
2535 
2536  dc.GetSize( &m_scrX, &m_scrY ); // This is the size of the visible area only!
2537 
2538 #ifdef MATHPLOT_DO_LOGGING
2539  wxLogMessage( "[mpWindow::OnPaint] vis.area: x %i y%i", m_scrX, m_scrY );
2540 #endif
2541 
2542  // Selects direct or buffered draw:
2543  wxDC* trgDc;
2544 
2545  // J.L.Blanco @ Aug 2007: Added double buffer support
2546  if( m_enableDoubleBuffer )
2547  {
2548  if( m_last_lx!=m_scrX || m_last_ly!=m_scrY )
2549  {
2550  if( m_buff_bmp )
2551  delete m_buff_bmp;
2552 
2553  m_buff_bmp = new wxBitmap( m_scrX, m_scrY );
2554  m_buff_dc.SelectObject( *m_buff_bmp );
2555  m_last_lx = m_scrX;
2556  m_last_ly = m_scrY;
2557  }
2558 
2559  trgDc = &m_buff_dc;
2560  }
2561  else
2562  {
2563  trgDc = &dc;
2564  }
2565 
2566  // Draw background:
2567  // trgDc->SetDeviceOrigin(0,0);
2568  trgDc->SetPen( *wxTRANSPARENT_PEN );
2569  wxBrush brush( GetBackgroundColour() );
2570  trgDc->SetBrush( brush );
2571  trgDc->SetTextForeground( m_fgColour );
2572  trgDc->DrawRectangle( 0, 0, m_scrX, m_scrY );
2573 
2574  // Draw all the layers:
2575  // trgDc->SetDeviceOrigin( m_scrX>>1, m_scrY>>1); // Origin at the center
2576  wxLayerList::iterator li;
2577 
2578  for( li = m_layers.begin(); li != m_layers.end(); li++ )
2579  {
2580  (*li)->Plot( *trgDc, *this );
2581  }
2582 
2583  ;
2584 
2585  if( m_zooming )
2586  {
2587  wxPen pen( m_fgColour, 1, wxPENSTYLE_DOT );
2588  trgDc->SetPen( pen );
2589  trgDc->SetBrush( *wxTRANSPARENT_BRUSH );
2590  trgDc->DrawRectangle( m_zoomRect );
2591  }
2592 
2593  // If doublebuffer, draw now to the window:
2594  if( m_enableDoubleBuffer )
2595  {
2596  // trgDc->SetDeviceOrigin(0,0);
2597  // dc.SetDeviceOrigin(0,0); // Origin at the center
2598  dc.Blit( 0, 0, m_scrX, m_scrY, trgDc, 0, 0 );
2599  }
2600 
2601  /* if (m_coordTooltip) {
2602  * wxString toolTipContent;
2603  * wxPoint mousePoint = wxGetMousePosition();
2604  * toolTipContent.Printf( "X = %f\nY = %f", p2x(mousePoint.x), p2y(mousePoint.y));
2605  * SetToolTip(toolTipContent);
2606  * }*/
2607  // If scrollbars are enabled, refresh them
2608  if( m_enableScrollBars )
2609  {
2610  /* m_scroll.x = (int) floor((m_posX - m_minX)*m_scaleX);
2611  * m_scroll.y = (int) floor((m_maxY - m_posY )*m_scaleY);
2612  * Scroll(m_scroll.x, m_scroll.y);*/
2613  // Scroll(x2p(m_posX), y2p(m_posY));
2614  // SetVirtualSize((int) ((m_maxX - m_minX)*m_scaleX), (int) ((m_maxY - m_minY)*m_scaleY));
2615  // int centerX = (m_scrX - m_marginLeft - m_marginRight)/2; // + m_marginLeft; // c.x = m_scrX/2;
2616  // int centerY = (m_scrY - m_marginTop - m_marginBottom)/2; // - m_marginTop; // c.y = m_scrY/2;
2617  /*SetScrollbars(1, 1, (int) ((m_maxX - m_minX)*m_scaleX), (int) ((m_maxY - m_minY)*m_scaleY));*/ // , x2p(m_posX + centerX/m_scaleX), y2p(m_posY - centerY/m_scaleY), true);
2618  }
2619 }
wxMemoryDC m_buff_dc
Definition: mathplot.h:1526
bool m_enableScrollBars
Definition: mathplot.h:1534
bool m_zooming
Definition: mathplot.h:1537
wxLayerList m_layers
Definition: mathplot.h:1497
wxRect m_zoomRect
Definition: mathplot.h:1538
wxColour m_fgColour
Definition: mathplot.h:1502
int m_last_ly
Definition: mathplot.h:1525
int m_last_lx
Definition: mathplot.h:1525
int m_scrY
Definition: mathplot.h:1514
bool m_enableDoubleBuffer
Definition: mathplot.h:1528
int m_scrX
Definition: mathplot.h:1513
wxBitmap * m_buff_bmp
Definition: mathplot.h:1527

References m_buff_bmp, m_buff_dc, m_enableDoubleBuffer, m_enableScrollBars, m_fgColour, m_last_lx, m_last_ly, m_layers, m_scrX, m_scrY, m_zooming, and m_zoomRect.

◆ OnScrollBottom()

void mpWindow::OnScrollBottom ( wxScrollWinEvent &  event)
protected

Definition at line 2978 of file mathplot.cpp.

2979 {
2980  int scrollOrientation = event.GetOrientation();
2981  // Get thumb size
2982  int thumbSize = GetScrollThumb( scrollOrientation );
2983  // Get scroll range
2984  int scrollRange = GetScrollRange( scrollOrientation );
2985 
2986  DoScrollCalc( scrollRange - thumbSize, scrollOrientation );
2987 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2867

References DoScrollCalc().

◆ OnScrollLineDown()

void mpWindow::OnScrollLineDown ( wxScrollWinEvent &  event)
protected

Definition at line 2952 of file mathplot.cpp.

2953 {
2954  int scrollOrientation = event.GetOrientation();
2955  // Get position before page up
2956  int position = GetScrollPos( scrollOrientation );
2957  // Get thumb size
2958  int thumbSize = GetScrollThumb( scrollOrientation );
2959  // Get scroll range
2960  int scrollRange = GetScrollRange( scrollOrientation );
2961 
2962  // Need to adjust position by a page
2963  position += mpSCROLL_NUM_PIXELS_PER_LINE;
2964 
2965  if( position > (scrollRange - thumbSize) )
2966  position = scrollRange - thumbSize;
2967 
2968  DoScrollCalc( position, scrollOrientation );
2969 }
#define mpSCROLL_NUM_PIXELS_PER_LINE
Definition: mathplot.cpp:61
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2867

References DoScrollCalc(), and mpSCROLL_NUM_PIXELS_PER_LINE.

◆ OnScrollLineUp()

void mpWindow::OnScrollLineUp ( wxScrollWinEvent &  event)
protected

Definition at line 2936 of file mathplot.cpp.

2937 {
2938  int scrollOrientation = event.GetOrientation();
2939  // Get position before page up
2940  int position = GetScrollPos( scrollOrientation );
2941 
2942  // Need to adjust position by a line
2943  position -= mpSCROLL_NUM_PIXELS_PER_LINE;
2944 
2945  if( position < 0 )
2946  position = 0;
2947 
2948  DoScrollCalc( position, scrollOrientation );
2949 }
#define mpSCROLL_NUM_PIXELS_PER_LINE
Definition: mathplot.cpp:61
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2867

References DoScrollCalc(), and mpSCROLL_NUM_PIXELS_PER_LINE.

◆ OnScrollPageDown()

void mpWindow::OnScrollPageDown ( wxScrollWinEvent &  event)
protected

Definition at line 2916 of file mathplot.cpp.

2917 {
2918  int scrollOrientation = event.GetOrientation();
2919  // Get position before page up
2920  int position = GetScrollPos( scrollOrientation );
2921  // Get thumb size
2922  int thumbSize = GetScrollThumb( scrollOrientation );
2923  // Get scroll range
2924  int scrollRange = GetScrollRange( scrollOrientation );
2925 
2926  // Need to adjust position by a page
2927  position += thumbSize;
2928 
2929  if( position > (scrollRange - thumbSize) )
2930  position = scrollRange - thumbSize;
2931 
2932  DoScrollCalc( position, scrollOrientation );
2933 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2867

References DoScrollCalc().

◆ OnScrollPageUp()

void mpWindow::OnScrollPageUp ( wxScrollWinEvent &  event)
protected

Definition at line 2898 of file mathplot.cpp.

2899 {
2900  int scrollOrientation = event.GetOrientation();
2901  // Get position before page up
2902  int position = GetScrollPos( scrollOrientation );
2903  // Get thumb size
2904  int thumbSize = GetScrollThumb( scrollOrientation );
2905 
2906  // Need to adjust position by a page
2907  position -= thumbSize;
2908 
2909  if( position < 0 )
2910  position = 0;
2911 
2912  DoScrollCalc( position, scrollOrientation );
2913 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2867

References DoScrollCalc().

◆ OnScrollThumbTrack()

void mpWindow::OnScrollThumbTrack ( wxScrollWinEvent &  event)
protected

Definition at line 2892 of file mathplot.cpp.

2893 {
2894  DoScrollCalc( event.GetPosition(), event.GetOrientation() );
2895 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2867

References DoScrollCalc().

◆ OnScrollTop()

void mpWindow::OnScrollTop ( wxScrollWinEvent &  event)
protected

Definition at line 2972 of file mathplot.cpp.

2973 {
2974  DoScrollCalc( 0, event.GetOrientation() );
2975 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2867

References DoScrollCalc().

◆ OnShowPopupMenu()

void mpWindow::OnShowPopupMenu ( wxMouseEvent &  event)
protected

Definition at line 2420 of file mathplot.cpp.

2421 {
2422  m_clickedX = event.GetX();
2423  m_clickedY = event.GetY();
2424  PopupMenu( &m_popmenu, event.GetX(), event.GetY() );
2425 }
int m_clickedX
Definition: mathplot.h:1515
int m_clickedY
Definition: mathplot.h:1516
wxMenu m_popmenu
Definition: mathplot.h:1498

References m_clickedX, m_clickedY, and m_popmenu.

◆ OnSize()

void mpWindow::OnSize ( wxSizeEvent &  event)
protected

Definition at line 2462 of file mathplot.cpp.

2463 {
2464  // Try to fit again with the new window size:
2466 #ifdef MATHPLOT_DO_LOGGING
2467  wxLogMessage( "mpWindow::OnSize() m_scrX = %d, m_scrY = %d", m_scrX, m_scrY );
2468 #endif // MATHPLOT_DO_LOGGING
2469 }
double m_desiredXmax
Definition: mathplot.h:1521
double m_desiredYmax
Definition: mathplot.h:1521
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1521
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:1998
double m_desiredYmin
Definition: mathplot.h:1521
int m_scrY
Definition: mathplot.h:1514
int m_scrX
Definition: mathplot.h:1513

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

◆ OnZoomIn()

void mpWindow::OnZoomIn ( wxCommandEvent &  event)
protected

Definition at line 2450 of file mathplot.cpp.

2451 {
2453 }
wxPoint m_mouseMClick
Definition: mathplot.h:1532
void ZoomIn(const wxPoint &centerPoint=wxDefaultPosition)
Zoom into current view and refresh display.
Definition: mathplot.cpp:2243

References m_mouseMClick, wxPoint::x, wxPoint::y, and ZoomIn().

◆ OnZoomOut()

void mpWindow::OnZoomOut ( wxCommandEvent &  event)
protected

Definition at line 2456 of file mathplot.cpp.

2457 {
2458  ZoomOut();
2459 }
void ZoomOut(const wxPoint &centerPoint=wxDefaultPosition)
Zoom out current view and refresh display.
Definition: mathplot.cpp:2306

References ZoomOut().

◆ 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 1189 of file mathplot.h.

1189 { return m_posX + pixelCoordX / m_scaleX; }
double m_posX
Definition: mathplot.h:1511
double m_scaleX
Definition: mathplot.h:1509

Referenced by DoZoomInXCalc(), DoZoomOutXCalc(), mpScaleXBase::getVisibleDataRange(), OnCenter(), CURSOR::Plot(), mpFX::Plot(), mpProfile::Plot(), ZoomIn(), ZoomOut(), 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 1194 of file mathplot.h.

1194 { return m_posY - pixelCoordY / m_scaleY; }
double m_scaleY
Definition: mathplot.h:1510
double m_posY
Definition: mathplot.h:1512

Referenced by DoZoomInYCalc(), DoZoomOutYCalc(), mpScaleY::getVisibleDataRange(), OnCenter(), mpFY::Plot(), ZoomIn(), ZoomOut(), and ZoomRect().

◆ SaveScreenshot()

bool mpWindow::SaveScreenshot ( const wxString &  filename,
wxBitmapType  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

Definition at line 3050 of file mathplot.cpp.

3052 {
3053  int sizeX, sizeY;
3054  int bk_scrX, bk_scrY;
3055 
3056  if( imageSize == wxDefaultSize )
3057  {
3058  sizeX = m_scrX;
3059  sizeY = m_scrY;
3060  }
3061  else
3062  {
3063  sizeX = imageSize.x;
3064  sizeY = imageSize.y;
3065  bk_scrX = m_scrX;
3066  bk_scrY = m_scrY;
3067  SetScr( sizeX, sizeY );
3068  }
3069 
3070  wxBitmap screenBuffer( sizeX, sizeY );
3071  wxMemoryDC screenDC;
3072  screenDC.SelectObject( screenBuffer );
3073  screenDC.SetPen( *wxWHITE_PEN );
3074  screenDC.SetTextForeground( m_fgColour );
3075  wxBrush brush( GetBackgroundColour() );
3076  screenDC.SetBrush( brush );
3077  screenDC.DrawRectangle( 0, 0, sizeX, sizeY );
3078 
3079  if( fit )
3080  {
3081  Fit( m_minX, m_maxX, m_minY, m_maxY, &sizeX, &sizeY );
3082  }
3083  else
3084  {
3086  }
3087 
3088  // Draw all the layers:
3089  wxLayerList::iterator li;
3090 
3091  for( li = m_layers.begin(); li != m_layers.end(); li++ )
3092  (*li)->Plot( screenDC, *this );
3093 
3094  if( imageSize != wxDefaultSize )
3095  {
3096  // Restore dimensions
3097  SetScr( bk_scrX, bk_scrY );
3098  Fit( m_desiredXmin, m_desiredXmax, m_desiredYmin, m_desiredYmax, &bk_scrX, &bk_scrY );
3099  UpdateAll();
3100  }
3101 
3102  // Once drawing is complete, actually save screen shot
3103  wxImage screenImage = screenBuffer.ConvertToImage();
3104  return screenImage.SaveFile( filename, type );
3105 }
double m_desiredXmax
Definition: mathplot.h:1521
double m_minY
Definition: mathplot.h:1507
wxLayerList m_layers
Definition: mathplot.h:1497
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820
double m_desiredYmax
Definition: mathplot.h:1521
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1521
wxColour m_fgColour
Definition: mathplot.h:1502
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:1998
double m_minX
Definition: mathplot.h:1505
double m_desiredYmin
Definition: mathplot.h:1521
void SetScr(int scrX, int scrY)
Set current view's dimensions in device context units.
Definition: mathplot.h:1184
int m_scrY
Definition: mathplot.h:1514
double m_maxX
Definition: mathplot.h:1506
int m_scrX
Definition: mathplot.h:1513
double m_maxY
Definition: mathplot.h:1508

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

Referenced by SIM_PLOT_FRAME::menuSaveImage().

◆ 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 3185 of file mathplot.cpp.

3188 {
3189  SetBackgroundColour( bgColour );
3190  SetForegroundColour( drawColour );
3191  m_bgColour = bgColour;
3192  m_fgColour = drawColour;
3193  m_axColour = axesColour;
3194  // cycle between layers to set colours and properties to them
3195  wxLayerList::iterator li;
3196 
3197  for( li = m_layers.begin(); li != m_layers.end(); li++ )
3198  {
3199  if( (*li)->GetLayerType() == mpLAYER_AXIS )
3200  {
3201  wxPen axisPen = (*li)->GetPen(); // Get the old pen to modify only colour, not style or width
3202  axisPen.SetColour( axesColour );
3203  (*li)->SetPen( axisPen );
3204  }
3205 
3206  if( (*li)->GetLayerType() == mpLAYER_INFO )
3207  {
3208  wxPen infoPen = (*li)->GetPen(); // Get the old pen to modify only colour, not style or width
3209  infoPen.SetColour( drawColour );
3210  (*li)->SetPen( infoPen );
3211  }
3212  }
3213 }
wxColour m_axColour
Definition: mathplot.h:1503
wxLayerList m_layers
Definition: mathplot.h:1497
wxColour m_fgColour
Definition: mathplot.h:1502
wxColour m_bgColour
Definition: mathplot.h:1501

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

Referenced by mpPrintout::OnPrintPage(), SIM_PLOT_PANEL::SIM_PLOT_PANEL(), and SIM_PLOT_PANEL::UpdatePlotColors().

◆ 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

Definition at line 3145 of file mathplot.cpp.

3146 {
3147  mpLayer* lx = GetLayerByName( name );
3148 
3149  if( lx )
3150  {
3151  lx->SetVisible( viewable );
3152  UpdateAll();
3153  }
3154 }
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820
void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:303
mpLayer * GetLayerByName(const wxString &name)
Definition: mathplot.cpp:3030
const char * name
Definition: DXF_plotter.cpp:60

References GetLayerByName(), name, mpLayer::SetVisible(), and UpdateAll().

◆ 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

Definition at line 3165 of file mathplot.cpp.

3166 {
3167  mpLayer* lx = GetLayer( position );
3168 
3169  if( lx )
3170  {
3171  lx->SetVisible( viewable );
3172  UpdateAll();
3173  }
3174 }
mpLayer * GetLayer(int position)
Definition: mathplot.cpp:3021
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820
void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:303

References GetLayer(), mpLayer::SetVisible(), and UpdateAll().

◆ SetMarginBottom()

void mpWindow::SetMarginBottom ( int  bottom)
inline

Set the bottom margin.

Parameters
bottomBottom Margin

Definition at line 1363 of file mathplot.h.

1363 { m_marginBottom = bottom; };
int m_marginBottom
Definition: mathplot.h:1523

◆ SetMarginLeft()

void mpWindow::SetMarginLeft ( int  left)
inline

Set the left margin.

Parameters
leftLeft Margin

Definition at line 1365 of file mathplot.h.

1365 { m_marginLeft = left; };
int m_marginLeft
Definition: mathplot.h:1523

◆ SetMarginRight()

void mpWindow::SetMarginRight ( int  right)
inline

Set the right margin.

Parameters
rightRight Margin

Definition at line 1361 of file mathplot.h.

1361 { m_marginRight = right; };
int m_marginRight
Definition: mathplot.h:1523

◆ 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 3108 of file mathplot.cpp.

3109 {
3110  m_marginTop = top;
3111  m_marginRight = right;
3112  m_marginBottom = bottom;
3113  m_marginLeft = left;
3114 }
int m_marginRight
Definition: mathplot.h:1523
int m_marginLeft
Definition: mathplot.h:1523
int m_marginTop
Definition: mathplot.h:1523
int m_marginBottom
Definition: mathplot.h:1523

References m_marginBottom, m_marginLeft, m_marginRight, and m_marginTop.

Referenced by SIM_PLOT_PANEL::SIM_PLOT_PANEL().

◆ SetMarginTop()

void mpWindow::SetMarginTop ( int  top)
inline

Set the top margin.

Parameters
topTop Margin

Definition at line 1359 of file mathplot.h.

1359 { m_marginTop = top; };
int m_marginTop
Definition: mathplot.h:1523

◆ SetMPScrollbars()

void mpWindow::SetMPScrollbars ( bool  status)

Enable/disable scrollbars.

Parameters
statusSet to true to show scrollbars
  • m_scroll.x = (int) floor((m_posX - m_minX)*m_scaleX);

Definition at line 2671 of file mathplot.cpp.

2672 {
2673  // Temporary behaviour: always disable scrollbars
2674  m_enableScrollBars = status; // false;
2675 
2676  if( status == false )
2677  {
2678  SetScrollbar( wxHORIZONTAL, 0, 0, 0 );
2679  SetScrollbar( wxVERTICAL, 0, 0, 0 );
2680  }
2681 
2682  // else the scroll bars will be updated in UpdateAll();
2683  UpdateAll();
2684 
2685  // EnableScrolling(false, false);
2686  // m_enableScrollBars = status;
2687  // EnableScrolling(status, status);
2688  /* m_scroll.x = (int) floor((m_posX - m_minX)*m_scaleX);
2689  * m_scroll.y = (int) floor((m_posY - m_minY)*m_scaleY);*/
2690  // int scrollWidth = (int) floor((m_maxX - m_minX)*m_scaleX) - m_scrX;
2691  // int scrollHeight = (int) floor((m_minY - m_maxY)*m_scaleY) - m_scrY;
2692 
2694  // m_scroll.y = (int) floor((m_maxY - m_posY /*- m_minY*/)*m_scaleY);
2695  // int scrollWidth = (int) floor(((m_maxX - m_minX) - (m_desiredXmax - m_desiredXmin))*m_scaleX);
2696  // int scrollHeight = (int) floor(((m_maxY - m_minY) - (m_desiredYmax - m_desiredYmin))*m_scaleY);
2697  // #ifdef MATHPLOT_DO_LOGGING
2698  // wxLogMessage( "mpWindow::SetMPScrollbars() scrollWidth = %d, scrollHeight = %d", scrollWidth, scrollHeight);
2699  // #endif
2700  // if(status) {
2701  // SetScrollbars(1,
2702  // 1,
2703  // scrollWidth,
2704  // scrollHeight,
2705  // m_scroll.x,
2706  // m_scroll.y);
2708  // }
2709  // Refresh(false);*/
2710 }
bool m_enableScrollBars
Definition: mathplot.h:1534
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820

References m_enableScrollBars, and UpdateAll().

◆ 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 1177 of file mathplot.h.

1177 { m_posX = posX; m_posY = posY; UpdateAll(); }
double m_posX
Definition: mathplot.h:1511
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820
double m_posY
Definition: mathplot.h:1512

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 1166 of file mathplot.h.

1166 { m_posX = posX; UpdateAll(); }
double m_posX
Definition: mathplot.h:1511
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820

Referenced by DoScrollCalc().

◆ 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 1171 of file mathplot.h.

1171 { m_posY = posY; UpdateAll(); }
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820
double m_posY
Definition: mathplot.h:1512

Referenced by DoScrollCalc().

◆ 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 2992 of file mathplot.cpp.

2993 {
2994  if( scaleX!=0 )
2995  m_scaleX = scaleX;
2996 
2997  UpdateAll();
2998 }
double m_scaleX
Definition: mathplot.h:1509
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820

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 1155 of file mathplot.h.

1156  {
1157  if( scaleY!=0 )
1158  m_scaleY = scaleY;
1159 
1160  UpdateAll();
1161  }
double m_scaleY
Definition: mathplot.h:1510
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820

◆ 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 1184 of file mathplot.h.

1184 { m_scrX = scrX; m_scrY = scrY; }
int m_scrY
Definition: mathplot.h:1514
int m_scrX
Definition: mathplot.h:1513

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 2215 of file mathplot.cpp.

2216 {
2217  // if(!CheckXLimits(desiredMax, desiredMin))
2218  // return false;
2219 
2220  m_posX = pos;
2221  m_desiredXmax = desiredMax;
2222  m_desiredXmin = desiredMin;
2224 
2225  return true;
2226 }
double m_desiredXmax
Definition: mathplot.h:1521
double m_posX
Definition: mathplot.h:1511
void AdjustLimitedView()
Definition: mathplot.cpp:2169
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1521

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

Referenced by OnMouseMove(), and OnMouseWheel().

◆ 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 2229 of file mathplot.cpp.

2230 {
2231  // if(!CheckYLimits(desiredMax, desiredMin))
2232  // return false;
2233 
2234  m_posY = pos;
2235  m_desiredYmax = desiredMax;
2236  m_desiredYmin = desiredMin;
2238 
2239  return true;
2240 }
double m_desiredYmax
Definition: mathplot.h:1521
void AdjustLimitedView()
Definition: mathplot.cpp:2169
double m_posY
Definition: mathplot.h:1512
double m_desiredYmin
Definition: mathplot.h:1521

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

Referenced by OnMouseMove(), and OnMouseWheel().

◆ UpdateAll()

void mpWindow::UpdateAll ( )

Refresh display.

Definition at line 2820 of file mathplot.cpp.

2821 {
2822  if( UpdateBBox() )
2823  {
2824  if( m_enableScrollBars )
2825  {
2826  int cx, cy;
2827  GetClientSize( &cx, &cy );
2828  // Do x scroll bar
2829  {
2830  // Convert margin sizes from pixels to coordinates
2831  double leftMargin = m_marginLeft / m_scaleX;
2832  // Calculate the range in coords that we want to scroll over
2833  double maxX = (m_desiredXmax > m_maxX) ? m_desiredXmax : m_maxX;
2834  double minX = (m_desiredXmin < m_minX) ? m_desiredXmin : m_minX;
2835 
2836  if( (m_posX + leftMargin) < minX )
2837  minX = m_posX + leftMargin;
2838 
2839  // Calculate scroll bar size and thumb position
2840  int sizeX = (int) ( (maxX - minX) * m_scaleX );
2841  int thumbX = (int) ( ( (m_posX + leftMargin) - minX ) * m_scaleX );
2842  SetScrollbar( wxHORIZONTAL, thumbX, cx - (m_marginRight + m_marginLeft), sizeX );
2843  }
2844  // Do y scroll bar
2845  {
2846  // Convert margin sizes from pixels to coordinates
2847  double topMargin = m_marginTop / m_scaleY;
2848  // Calculate the range in coords that we want to scroll over
2849  double maxY = (m_desiredYmax > m_maxY) ? m_desiredYmax : m_maxY;
2850 
2851  if( (m_posY - topMargin) > maxY )
2852  maxY = m_posY - topMargin;
2853 
2854  double minY = (m_desiredYmin < m_minY) ? m_desiredYmin : m_minY;
2855  // Calculate scroll bar size and thumb position
2856  int sizeY = (int) ( (maxY - minY) * m_scaleY );
2857  int thumbY = (int) ( ( maxY - (m_posY - topMargin) ) * m_scaleY );
2858  SetScrollbar( wxVERTICAL, thumbY, cy - (m_marginTop + m_marginBottom), sizeY );
2859  }
2860  }
2861  }
2862 
2863  Refresh( false );
2864 }
int m_marginRight
Definition: mathplot.h:1523
bool m_enableScrollBars
Definition: mathplot.h:1534
int m_marginLeft
Definition: mathplot.h:1523
double m_desiredXmax
Definition: mathplot.h:1521
double m_scaleY
Definition: mathplot.h:1510
double m_posX
Definition: mathplot.h:1511
double m_minY
Definition: mathplot.h:1507
double m_scaleX
Definition: mathplot.h:1509
double m_desiredYmax
Definition: mathplot.h:1521
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1521
double m_posY
Definition: mathplot.h:1512
int m_marginTop
Definition: mathplot.h:1523
double m_minX
Definition: mathplot.h:1505
double m_desiredYmin
Definition: mathplot.h:1521
int m_marginBottom
Definition: mathplot.h:1523
virtual bool UpdateBBox()
Recalculate global layer bounding box, and save it in m_minX,...
Definition: mathplot.cpp:2712
double m_maxX
Definition: mathplot.h:1506
double m_maxY
Definition: mathplot.h:1508

References m_desiredXmax, m_desiredXmin, m_desiredYmax, m_desiredYmin, m_enableScrollBars, m_marginBottom, m_marginLeft, m_marginRight, m_marginTop, m_maxX, m_maxY, m_minX, m_minY, m_posX, m_posY, m_scaleX, m_scaleY, Refresh(), and UpdateBBox().

Referenced by AddLayer(), SIM_PLOT_PANEL::AddTrace(), DelAllLayers(), DelLayer(), Fit(), OnMouseMove(), OnMouseWheel(), mpPrintout::OnPrintPage(), SIM_PLOT_FRAME::onSimFinished(), SaveScreenshot(), SIM_PLOT_PANEL::SetDottedCurrentPhase(), SetLayerVisible(), SetMPScrollbars(), SetScaleX(), SIM_PLOT_PANEL::ShowGrid(), SIM_PLOT_PANEL::ShowLegend(), SIM_PLOT_PANEL::SIM_PLOT_PANEL(), SIM_PLOT_PANEL::UpdatePlotColors(), ZoomIn(), ZoomInX(), ZoomInY(), ZoomOut(), ZoomOutX(), and ZoomOutY().

◆ 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 2712 of file mathplot.cpp.

2713 {
2714  m_minX = 0.0;
2715  m_maxX = 1.0;
2716  m_minY = 0.0;
2717  m_maxY = 1.0;
2718 
2719  return true;
2720 
2721 #if 0
2722  bool first = true;
2723 
2724  for( wxLayerList::iterator li = m_layers.begin(); li != m_layers.end(); li++ )
2725  {
2726  mpLayer* f = *li;
2727 
2728  if( f->HasBBox() )
2729  {
2730  if( first )
2731  {
2732  first = false;
2733  m_minX = f->GetMinX(); m_maxX = f->GetMaxX();
2734  m_minY = f->GetMinY(); m_maxY = f->GetMaxY();
2735  }
2736  else
2737  {
2738  if( f->GetMinX()<m_minX )
2739  m_minX = f->GetMinX();
2740 
2741  if( f->GetMaxX()>m_maxX )
2742  m_maxX = f->GetMaxX();
2743 
2744  if( f->GetMinY()<m_minY )
2745  m_minY = f->GetMinY();
2746 
2747  if( f->GetMaxY()>m_maxY )
2748  m_maxY = f->GetMaxY();
2749  }
2750  }
2751 
2752  // node = node->GetNext();
2753  }
2754 
2755 #ifdef MATHPLOT_DO_LOGGING
2756  wxLogDebug( wxT(
2757  "[mpWindow::UpdateBBox] Bounding box: Xmin = %f, Xmax = %f, Ymin = %f, YMax = %f" ), m_minX, m_maxX, m_minY,
2758  m_maxY );
2759 #endif // MATHPLOT_DO_LOGGING
2760 
2761  return first == false;
2762 #endif
2763 }
double m_minY
Definition: mathplot.h:1507
wxLayerList m_layers
Definition: mathplot.h:1497
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:181
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:191
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:176
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:186
double m_minX
Definition: mathplot.h:1505
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:162
double m_maxX
Definition: mathplot.h:1506
double m_maxY
Definition: mathplot.h:1508

References mpLayer::GetMaxX(), mpLayer::GetMaxY(), mpLayer::GetMinX(), mpLayer::GetMinY(), mpLayer::HasBBox(), m_layers, m_maxX, m_maxY, m_minX, and m_minY.

Referenced by Fit(), and UpdateAll().

◆ 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 1199 of file mathplot.h.

1199 { return (wxCoord) ( (x - m_posX) * m_scaleX ); }
double m_posX
Definition: mathplot.h:1511
double m_scaleX
Definition: mathplot.h:1509

Referenced by CURSOR::Inside(), CURSOR::Plot(), mpFY::Plot(), mpFXY::Plot(), mpScaleY::Plot(), mpMovableObject::Plot(), mpBitmapLayer::Plot(), 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 1204 of file mathplot.h.

1204 { return (wxCoord) ( (m_posY - y) * m_scaleY ); }
double m_scaleY
Definition: mathplot.h:1510
double m_posY
Definition: mathplot.h:1512

Referenced by CURSOR::Inside(), CURSOR::Plot(), mpFX::Plot(), mpFXY::Plot(), mpProfile::Plot(), mpScaleXBase::Plot(), mpMovableObject::Plot(), mpBitmapLayer::Plot(), and CURSOR::UpdateReference().

◆ ZoomIn() [1/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 2243 of file mathplot.cpp.

2244 {
2245  ZoomIn( centerPoint, zoomIncrementalFactor );
2246 }
void ZoomIn(const wxPoint &centerPoint=wxDefaultPosition)
Zoom into current view and refresh display.
Definition: mathplot.cpp:2243
static double zoomIncrementalFactor
This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse...
Definition: mathplot.h:1348

References zoomIncrementalFactor.

Referenced by SIM_PLOT_FRAME::menuZoomIn(), OnMouseWheel(), and OnZoomIn().

◆ ZoomIn() [2/2]

void mpWindow::ZoomIn ( const wxPoint centerPoint,
double  zoomFactor 
)

Definition at line 2249 of file mathplot.cpp.

2250 {
2251  wxPoint c( centerPoint );
2252 
2253  if( c == wxDefaultPosition )
2254  {
2255  GetClientSize( &m_scrX, &m_scrY );
2256  c.x = (m_scrX - m_marginLeft - m_marginRight) / 2 + m_marginLeft; // c.x = m_scrX/2;
2257  c.y = (m_scrY - m_marginTop - m_marginBottom) / 2 - m_marginTop; // c.y = m_scrY/2;
2258  }
2259  else
2260  {
2261  c.x = std::max( c.x, m_marginLeft );
2262  c.x = std::min( c.x, m_scrX - m_marginRight );
2263  c.y = std::max( c.y, m_marginTop );
2264  c.y = std::min( c.y, m_scrY - m_marginBottom );
2265  }
2266 
2267  // Preserve the position of the clicked point:
2268  double prior_layer_x = p2x( c.x );
2269  double prior_layer_y = p2y( c.y );
2270 
2271  // Zoom in:
2272  const double MAX_SCALE = 1e6;
2273  double newScaleX = m_scaleX * zoomFactor;
2274  double newScaleY = m_scaleY * zoomFactor;
2275 
2276  // Baaaaad things happen when you zoom in too much..
2277  if( newScaleX <= MAX_SCALE && newScaleY <= MAX_SCALE )
2278  {
2279  m_scaleX = newScaleX;
2280  m_scaleY = newScaleY;
2281  }
2282  else
2283  {
2284  return;
2285  }
2286 
2287  // Adjust the new m_posx/y:
2288  m_posX = prior_layer_x - c.x / m_scaleX;
2289  m_posY = prior_layer_y + c.y / m_scaleY;
2290 
2292  m_desiredXmax = m_posX + (m_scrX - m_marginLeft - m_marginRight) / m_scaleX; // m_desiredXmax = m_posX + m_scrX / m_scaleX;
2294  m_desiredYmin = m_posY - (m_scrY - m_marginTop - m_marginBottom) / m_scaleY; // m_desiredYmin = m_posY - m_scrY / m_scaleY;
2296 
2297 #ifdef MATHPLOT_DO_LOGGING
2298  wxLogMessage( "mpWindow::ZoomIn() prior coords: (%f,%f), new coords: (%f,%f) SHOULD BE EQUAL!!",
2299  prior_layer_x, prior_layer_y, p2x( c.x ), p2y( c.y ) );
2300 #endif
2301 
2302  UpdateAll();
2303 }
#define MAX_SCALE
Definition: panel_prev_3d.h:48
int m_marginRight
Definition: mathplot.h:1523
int m_marginLeft
Definition: mathplot.h:1523
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1189
double m_desiredXmax
Definition: mathplot.h:1521
double m_scaleY
Definition: mathplot.h:1510
double m_posX
Definition: mathplot.h:1511
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1194
double m_scaleX
Definition: mathplot.h:1509
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820
double m_desiredYmax
Definition: mathplot.h:1521
void AdjustLimitedView()
Definition: mathplot.cpp:2169
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1521
double m_posY
Definition: mathplot.h:1512
int m_marginTop
Definition: mathplot.h:1523
double m_desiredYmin
Definition: mathplot.h:1521
int m_marginBottom
Definition: mathplot.h:1523
int m_scrY
Definition: mathplot.h:1514
int m_scrX
Definition: mathplot.h:1513

References AdjustLimitedView(), m_desiredXmax, m_desiredXmin, m_desiredYmax, m_desiredYmin, m_marginBottom, m_marginLeft, m_marginRight, m_marginTop, m_posX, m_posY, m_scaleX, m_scaleY, m_scrX, m_scrY, MAX_SCALE, p2x(), p2y(), UpdateAll(), wxPoint::x, and wxPoint::y.

◆ ZoomInX()

void mpWindow::ZoomInX ( )

Zoom in current view along X and refresh display.

Definition at line 2359 of file mathplot.cpp.

2360 {
2362  UpdateAll();
2363 }
double m_scaleX
Definition: mathplot.h:1509
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820
static double zoomIncrementalFactor
This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse...
Definition: mathplot.h:1348

References m_scaleX, UpdateAll(), and zoomIncrementalFactor.

◆ ZoomInY()

void mpWindow::ZoomInY ( )

Zoom in current view along Y and refresh display.

Definition at line 2373 of file mathplot.cpp.

2374 {
2376  UpdateAll();
2377 }
double m_scaleY
Definition: mathplot.h:1510
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820
static double zoomIncrementalFactor
This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse...
Definition: mathplot.h:1348

References m_scaleY, UpdateAll(), and zoomIncrementalFactor.

◆ ZoomOut() [1/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 2306 of file mathplot.cpp.

2307 {
2308  ZoomOut( centerPoint, zoomIncrementalFactor );
2309 }
void ZoomOut(const wxPoint &centerPoint=wxDefaultPosition)
Zoom out current view and refresh display.
Definition: mathplot.cpp:2306
static double zoomIncrementalFactor
This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse...
Definition: mathplot.h:1348

References zoomIncrementalFactor.

Referenced by SIM_PLOT_FRAME::menuZoomOut(), OnMouseWheel(), and OnZoomOut().

◆ ZoomOut() [2/2]

void mpWindow::ZoomOut ( const wxPoint centerPoint,
double  zoomFactor 
)

Definition at line 2312 of file mathplot.cpp.

2313 {
2314  wxPoint c( centerPoint );
2315 
2316  if( c == wxDefaultPosition )
2317  {
2318  GetClientSize( &m_scrX, &m_scrY );
2319  c.x = (m_scrX - m_marginLeft - m_marginRight) / 2 + m_marginLeft; // c.x = m_scrX/2;
2320  c.y = (m_scrY - m_marginTop - m_marginBottom) / 2 - m_marginTop; // c.y = m_scrY/2;
2321  }
2322 
2323  // Preserve the position of the clicked point:
2324  double prior_layer_x = p2x( c.x );
2325  double prior_layer_y = p2y( c.y );
2326 
2327  // Zoom out:
2328  m_scaleX = m_scaleX / zoomFactor;
2329  m_scaleY = m_scaleY / zoomFactor;
2330 
2331  // Adjust the new m_posx/y:
2332  m_posX = prior_layer_x - c.x / m_scaleX;
2333  m_posY = prior_layer_y + c.y / m_scaleY;
2334 
2336  m_desiredXmax = m_posX + (m_scrX - m_marginLeft - m_marginRight) / m_scaleX; // m_desiredXmax = m_posX + m_scrX / m_scaleX;
2338  m_desiredYmin = m_posY - (m_scrY - m_marginTop - m_marginBottom) / m_scaleY; // m_desiredYmin = m_posY - m_scrY / m_scaleY;
2339 
2340  // printf("desired xmin %.1f ymin %.1f xmax %.1f ymax %.1f l %d\n", m_desiredXmin, m_desiredYmin, m_desiredXmax, m_desiredYmax, !!m_enableLimitedView);
2341  // printf("current xmin %.1f ymin %.1f xmax %.1f ymax %.1f\n", m_minX, m_minY, m_maxX, m_maxY);
2342 
2345  {
2346  // printf("call fit()\n");
2347  Fit();
2348  }
2349 
2350 #ifdef MATHPLOT_DO_LOGGING
2351  wxLogMessage(
2352  "mpWindow::ZoomOut() prior coords: (%f,%f), new coords: (%f,%f) SHOULD BE EQUAL!!",
2353  prior_layer_x, prior_layer_y, p2x( c.x ), p2y( c.y ) );
2354 #endif
2355  UpdateAll();
2356 }
int m_marginRight
Definition: mathplot.h:1523
int m_marginLeft
Definition: mathplot.h:1523
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1189
double m_desiredXmax
Definition: mathplot.h:1521
double m_scaleY
Definition: mathplot.h:1510
double m_posX
Definition: mathplot.h:1511
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1194
double m_scaleX
Definition: mathplot.h:1509
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820
double m_desiredYmax
Definition: mathplot.h:1521
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1521
bool CheckYLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1472
double m_posY
Definition: mathplot.h:1512
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:1998
int m_marginTop
Definition: mathplot.h:1523
double m_desiredYmin
Definition: mathplot.h:1521
int m_marginBottom
Definition: mathplot.h:1523
int m_scrY
Definition: mathplot.h:1514
bool CheckXLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1465
int m_scrX
Definition: mathplot.h:1513

References CheckXLimits(), CheckYLimits(), Fit(), m_desiredXmax, m_desiredXmin, m_desiredYmax, m_desiredYmin, m_marginBottom, m_marginLeft, m_marginRight, m_marginTop, m_posX, m_posY, m_scaleX, m_scaleY, m_scrX, m_scrY, p2x(), p2y(), UpdateAll(), wxPoint::x, and wxPoint::y.

◆ ZoomOutX()

void mpWindow::ZoomOutX ( )

Zoom out current view along X and refresh display.

Definition at line 2366 of file mathplot.cpp.

2367 {
2369  UpdateAll();
2370 }
double m_scaleX
Definition: mathplot.h:1509
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820
static double zoomIncrementalFactor
This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse...
Definition: mathplot.h:1348

References m_scaleX, UpdateAll(), and zoomIncrementalFactor.

◆ ZoomOutY()

void mpWindow::ZoomOutY ( )

Zoom out current view along Y and refresh display.

Definition at line 2380 of file mathplot.cpp.

2381 {
2383  UpdateAll();
2384 }
double m_scaleY
Definition: mathplot.h:1510
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820
static double zoomIncrementalFactor
This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse...
Definition: mathplot.h:1348

References m_scaleY, UpdateAll(), and zoomIncrementalFactor.

◆ 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 2387 of file mathplot.cpp.

2388 {
2389  // Compute the 2 corners in graph coordinates:
2390  double p0x = p2x( p0.x );
2391  double p0y = p2y( p0.y );
2392  double p1x = p2x( p1.x );
2393  double p1y = p2y( p1.y );
2394 
2395  // Order them:
2396  double zoom_x_min = p0x<p1x ? p0x : p1x;
2397  double zoom_x_max = p0x>p1x ? p0x : p1x;
2398  double zoom_y_min = p0y<p1y ? p0y : p1y;
2399  double zoom_y_max = p0y>p1y ? p0y : p1y;
2400 
2401 #ifdef MATHPLOT_DO_LOGGING
2402  wxLogMessage( "Zoom: (%f,%f)-(%f,%f)", zoom_x_min, zoom_y_min, zoom_x_max, zoom_y_max );
2403 #endif
2404 
2405  Fit( zoom_x_min, zoom_x_max, zoom_y_min, zoom_y_max );
2407 }
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1189
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1194
void AdjustLimitedView()
Definition: mathplot.cpp:2169
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:1998

References AdjustLimitedView(), Fit(), p2x(), p2y(), wxPoint::x, and wxPoint::y.

Referenced by OnMouseLeftRelease().

Member Data Documentation

◆ m_axColour

wxColour mpWindow::m_axColour
protected

Definition at line 1503 of file mathplot.h.

Referenced by SetColourTheme().

◆ m_bgColour

wxColour mpWindow::m_bgColour
protected

Definition at line 1501 of file mathplot.h.

Referenced by SetColourTheme().

◆ m_buff_bmp

wxBitmap* mpWindow::m_buff_bmp
protected

Definition at line 1527 of file mathplot.h.

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

◆ m_buff_dc

wxMemoryDC mpWindow::m_buff_dc
protected

Definition at line 1526 of file mathplot.h.

Referenced by OnPaint().

◆ m_clickedX

int mpWindow::m_clickedX
protected

Definition at line 1515 of file mathplot.h.

Referenced by OnCenter(), and OnShowPopupMenu().

◆ m_clickedY

int mpWindow::m_clickedY
protected

Definition at line 1516 of file mathplot.h.

Referenced by OnCenter(), and OnShowPopupMenu().

◆ m_desiredXmax

double mpWindow::m_desiredXmax
protected

◆ m_desiredXmin

double mpWindow::m_desiredXmin
protected

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

Definition at line 1521 of file mathplot.h.

Referenced by AdjustLimitedView(), DoScrollCalc(), DoZoomInXCalc(), DoZoomOutXCalc(), Fit(), LockAspect(), OnMouseMove(), OnMouseWheel(), OnSize(), SaveScreenshot(), SetXView(), UpdateAll(), ZoomIn(), and ZoomOut().

◆ m_desiredYmax

◆ m_desiredYmin

double mpWindow::m_desiredYmin
protected

◆ m_enableDoubleBuffer

bool mpWindow::m_enableDoubleBuffer
protected

Definition at line 1528 of file mathplot.h.

Referenced by OnPaint().

◆ m_enableLimitedView

bool mpWindow::m_enableLimitedView
protected

Definition at line 1531 of file mathplot.h.

Referenced by AdjustLimitedView().

◆ m_enableMouseNavigation

bool mpWindow::m_enableMouseNavigation
protected

Definition at line 1529 of file mathplot.h.

Referenced by OnMouseMove(), and OnMouseWheel().

◆ m_enableMouseWheelPan

bool mpWindow::m_enableMouseWheelPan
protected

Definition at line 1530 of file mathplot.h.

Referenced by OnMouseWheel().

◆ m_enableScrollBars

bool mpWindow::m_enableScrollBars
protected

Definition at line 1534 of file mathplot.h.

Referenced by OnPaint(), SetMPScrollbars(), and UpdateAll().

◆ m_fgColour

wxColour mpWindow::m_fgColour
protected

Definition at line 1502 of file mathplot.h.

Referenced by OnMouseMove(), OnPaint(), SaveScreenshot(), and SetColourTheme().

◆ m_last_lx

int mpWindow::m_last_lx
protected

Definition at line 1525 of file mathplot.h.

Referenced by OnPaint().

◆ m_last_ly

int mpWindow::m_last_ly
protected

Definition at line 1525 of file mathplot.h.

Referenced by OnPaint().

◆ m_layers

◆ m_lockaspect

bool mpWindow::m_lockaspect
protected

Definition at line 1499 of file mathplot.h.

Referenced by Fit(), LockAspect(), and OnLockAspect().

◆ m_marginBottom

int mpWindow::m_marginBottom
protected

◆ m_marginLeft

int mpWindow::m_marginLeft
protected

◆ m_marginRight

int mpWindow::m_marginRight
protected

◆ m_marginTop

int mpWindow::m_marginTop
protected

◆ 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 1533 of file mathplot.h.

Referenced by OnMouseLeftDown(), OnMouseLeftRelease(), and OnMouseMove().

◆ m_mouseMClick

wxPoint mpWindow::m_mouseMClick
protected

Definition at line 1532 of file mathplot.h.

Referenced by OnMouseMiddleDown(), OnMouseMove(), and OnZoomIn().

◆ m_movingInfoLayer

mpInfoLayer* mpWindow::m_movingInfoLayer
protected

Definition at line 1536 of file mathplot.h.

Referenced by OnMouseLeftDown(), OnMouseLeftRelease(), and OnMouseMove().

◆ m_popmenu

wxMenu mpWindow::m_popmenu
protected

Definition at line 1498 of file mathplot.h.

Referenced by LockAspect(), and OnShowPopupMenu().

◆ m_posX

double mpWindow::m_posX
protected

◆ m_posY

double mpWindow::m_posY
protected

◆ m_scaleX

◆ m_scaleY

double mpWindow::m_scaleY
protected

◆ m_scroll

wxPoint mpWindow::m_scroll
protected

Definition at line 1535 of file mathplot.h.

◆ m_scrX

int mpWindow::m_scrX
protected

◆ m_scrY

int mpWindow::m_scrY
protected

◆ m_zooming

bool mpWindow::m_zooming
protected

Definition at line 1537 of file mathplot.h.

Referenced by OnMouseLeftDown(), OnMouseLeftRelease(), OnMouseMove(), and OnPaint().

◆ m_zoomRect

wxRect mpWindow::m_zoomRect
protected

Definition at line 1538 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 1348 of file mathplot.h.

Referenced by DoZoomInXCalc(), DoZoomInYCalc(), DoZoomOutXCalc(), DoZoomOutYCalc(), ZoomIn(), ZoomInX(), ZoomInY(), ZoomOut(), ZoomOutX(), and ZoomOutY().


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