KiCad PCB EDA Suite
mpWindow Class Reference

Canvas for plotting mpLayer implementations. More...

#include <mathplot.h>

Inheritance diagram for mpWindow:
SIM_PLOT_PANEL

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

Constructor & Destructor Documentation

◆ mpWindow() [1/2]

mpWindow::mpWindow ( )
inline

Definition at line 1046 of file mathplot.h.

1046 {}

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

1783 {
1784  // Free all the layers:
1785  DelAllLayers( true, false );
1786 
1787  if( m_buff_bmp )
1788  {
1789  delete m_buff_bmp;
1790  m_buff_bmp = NULL;
1791  }
1792 }
void DelAllLayers(bool alsoDeleteObject, bool refreshDisplay=true)
Remove all layers from the plot.
Definition: mathplot.cpp:2549
wxBitmap * m_buff_bmp
Definition: mathplot.h:1523

References DelAllLayers(), and m_buff_bmp.

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

2506 {
2507  if( layer != NULL )
2508  {
2509  m_layers.push_back( layer );
2510 
2511  if( refreshDisplay )
2512  UpdateAll();
2513 
2514  return true;
2515  }
2516 
2517  ;
2518  return false;
2519 }
wxLayerList m_layers
Definition: mathplot.h:1493
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2853

References m_layers, 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 2202 of file mathplot.cpp.

2203 {
2204  if( !m_enableLimitedView )
2205  return;
2206 
2207  // m_min and m_max are plot limits for curves
2208  // xMin, xMax, yMin, yMax are the full limits (plot limit + margin)
2209  const double xMin = m_minX - m_marginLeft / m_scaleX;
2210  const double xMax = m_maxX + m_marginRight / m_scaleX;
2211  const double yMin = m_minY - m_marginTop / m_scaleY;
2212  const double yMax = m_maxY + m_marginBottom / m_scaleY;
2213 
2214  if( m_desiredXmin < xMin )
2215  {
2216  double diff = xMin - m_desiredXmin;
2217  m_posX += diff;
2218  m_desiredXmax += diff;
2219  m_desiredXmin = xMin;
2220  }
2221 
2222  if( m_desiredXmax > xMax )
2223  {
2224  double diff = m_desiredXmax - xMax;
2225  m_posX -= diff;
2226  m_desiredXmin -= diff;
2227  m_desiredXmax = xMax;
2228  }
2229 
2230  if( m_desiredYmin < yMin )
2231  {
2232  double diff = yMin - m_desiredYmin;
2233  m_posY += diff;
2234  m_desiredYmax += diff;
2235  m_desiredYmin = yMin;
2236  }
2237 
2238  if( m_desiredYmax > yMax )
2239  {
2240  double diff = m_desiredYmax - yMax;
2241  m_posY -= diff;
2242  m_desiredYmin -= diff;
2243  m_desiredYmax = yMax;
2244  }
2245 }
int m_marginRight
Definition: mathplot.h:1519
int m_marginLeft
Definition: mathplot.h:1519
double m_desiredXmax
Definition: mathplot.h:1517
double m_scaleY
Definition: mathplot.h:1506
double m_posX
Definition: mathplot.h:1507
double m_minY
Definition: mathplot.h:1503
double m_scaleX
Definition: mathplot.h:1505
double m_desiredYmax
Definition: mathplot.h:1517
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1517
double m_posY
Definition: mathplot.h:1508
int m_marginTop
Definition: mathplot.h:1519
double m_minX
Definition: mathplot.h:1501
double m_desiredYmin
Definition: mathplot.h:1517
int m_marginBottom
Definition: mathplot.h:1519
bool m_enableLimitedView
Definition: mathplot.h:1527
double m_maxX
Definition: mathplot.h:1502
double m_maxY
Definition: mathplot.h:1504

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

1462  {
1463  return !( m_enableLimitedView
1464  && (desiredMax > m_maxX - m_marginRight / m_scaleX
1465  || desiredMin < m_minX - m_marginLeft / m_scaleX) );
1466  }
int m_marginRight
Definition: mathplot.h:1519
int m_marginLeft
Definition: mathplot.h:1519
double m_scaleX
Definition: mathplot.h:1505
double m_minX
Definition: mathplot.h:1501
bool m_enableLimitedView
Definition: mathplot.h:1527
double m_maxX
Definition: mathplot.h:1502

Referenced by ZoomOut().

◆ CheckYLimits()

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

Definition at line 1468 of file mathplot.h.

1469  {
1470  return !( m_enableLimitedView
1471  && (desiredMax > m_maxY + m_marginBottom / m_scaleY
1472  || desiredMin < m_minY + m_marginTop / m_scaleY) );
1473  }
double m_scaleY
Definition: mathplot.h:1506
double m_minY
Definition: mathplot.h:1503
int m_marginTop
Definition: mathplot.h:1519
int m_marginBottom
Definition: mathplot.h:1519
bool m_enableLimitedView
Definition: mathplot.h:1527
double m_maxY
Definition: mathplot.h:1504

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

1286 { return m_layers.size(); };
wxLayerList m_layers
Definition: mathplot.h:1493

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

3037 {
3038  // wxNode *node = m_layers.GetFirst();
3039  unsigned int layerNo = 0;
3040 
3041  for( wxLayerList::iterator li = m_layers.begin(); li != m_layers.end(); li++ ) // while(node)
3042  {
3043  if( (*li)->HasBBox() )
3044  layerNo++;
3045 
3046  // node = node->GetNext();
3047  }
3048 
3049  ;
3050  return layerNo;
3051 }
wxLayerList m_layers
Definition: mathplot.h:1493

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

2550 {
2551  while( m_layers.size()>0 )
2552  {
2553  // Also delete the object?
2554  if( alsoDeleteObject )
2555  delete m_layers[0];
2556 
2557  m_layers.erase( m_layers.begin() ); // this deleted the reference only
2558  }
2559 
2560  if( refreshDisplay )
2561  UpdateAll();
2562 }
wxLayerList m_layers
Definition: mathplot.h:1493
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2853

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

2525 {
2526  wxLayerList::iterator layIt;
2527 
2528  for( layIt = m_layers.begin(); layIt != m_layers.end(); layIt++ )
2529  {
2530  if( *layIt == layer )
2531  {
2532  // Also delete the object?
2533  if( alsoDeleteObject )
2534  delete *layIt;
2535 
2536  m_layers.erase( layIt ); // this deleted the reference only
2537 
2538  if( refreshDisplay )
2539  UpdateAll();
2540 
2541  return true;
2542  }
2543  }
2544 
2545  return false;
2546 }
wxLayerList m_layers
Definition: mathplot.h:1493
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2853

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

2901 {
2902  if( orientation == wxVERTICAL )
2903  {
2904  // Y axis
2905  // Get top margin in coord units
2906  double topMargin = m_marginTop / m_scaleY;
2907  // Calculate maximum Y coord to be shown in the graph
2908  double maxY = m_desiredYmax > m_maxY ? m_desiredYmax : m_maxY;
2909  // Set new position
2910  SetPosY( ( maxY - (position / m_scaleY) ) + topMargin );
2911  }
2912  else
2913  {
2914  // X Axis
2915  // Get left margin in coord units
2916  double leftMargin = m_marginLeft / m_scaleX;
2917  // Calculate minimum X coord to be shown in the graph
2918  double minX = (m_desiredXmin < m_minX) ? m_desiredXmin : m_minX;
2919  // Set new position
2920  SetPosX( ( minX + (position / m_scaleX) ) - leftMargin );
2921  }
2922 }
int m_marginLeft
Definition: mathplot.h:1519
double m_scaleY
Definition: mathplot.h:1506
double m_scaleX
Definition: mathplot.h:1505
void SetPosX(double posX)
Set current view's X position and refresh display.
Definition: mathplot.h:1162
void SetPosY(double posY)
Set current view's Y position and refresh display.
Definition: mathplot.h:1167
double m_desiredYmax
Definition: mathplot.h:1517
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1517
int m_marginTop
Definition: mathplot.h:1519
double m_minX
Definition: mathplot.h:1501
double m_maxY
Definition: mathplot.h:1504

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

2123 {
2124  // Preserve the position of the clicked point:
2125  double staticX = p2x( staticXpixel );
2126 
2127  // Zoom in:
2129  // Adjust the new m_posx
2130  m_posX = staticX - (staticXpixel / m_scaleX);
2131  // Adjust desired
2134 #ifdef MATHPLOT_DO_LOGGING
2135  wxLogMessage(
2136  "mpWindow::DoZoomInXCalc() prior X coord: (%f), new X coord: (%f) SHOULD BE EQUAL!!",
2137  staticX, p2x( staticXpixel ) );
2138 #endif
2139 }
int m_marginRight
Definition: mathplot.h:1519
int m_marginLeft
Definition: mathplot.h:1519
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1185
double m_desiredXmax
Definition: mathplot.h:1517
double m_posX
Definition: mathplot.h:1507
double m_scaleX
Definition: mathplot.h:1505
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1517
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:1344
int m_scrX
Definition: mathplot.h:1509

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

2143 {
2144  // Preserve the position of the clicked point:
2145  double staticY = p2y( staticYpixel );
2146 
2147  // Zoom in:
2149  // Adjust the new m_posy:
2150  m_posY = staticY + (staticYpixel / m_scaleY);
2151  // Adjust desired
2154 #ifdef MATHPLOT_DO_LOGGING
2155  wxLogMessage(
2156  "mpWindow::DoZoomInYCalc() prior Y coord: (%f), new Y coord: (%f) SHOULD BE EQUAL!!",
2157  staticY, p2y( staticYpixel ) );
2158 #endif
2159 }
double m_scaleY
Definition: mathplot.h:1506
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1190
double m_desiredYmax
Definition: mathplot.h:1517
double m_posY
Definition: mathplot.h:1508
int m_marginTop
Definition: mathplot.h:1519
double m_desiredYmin
Definition: mathplot.h:1517
int m_marginBottom
Definition: mathplot.h:1519
int m_scrY
Definition: mathplot.h:1510
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:1344

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

2163 {
2164  // Preserve the position of the clicked point:
2165  double staticX = p2x( staticXpixel );
2166 
2167  // Zoom out:
2169  // Adjust the new m_posx/y:
2170  m_posX = staticX - (staticXpixel / m_scaleX);
2171  // Adjust desired
2174 #ifdef MATHPLOT_DO_LOGGING
2175  wxLogMessage(
2176  "mpWindow::DoZoomOutXCalc() prior X coord: (%f), new X coord: (%f) SHOULD BE EQUAL!!",
2177  staticX, p2x( staticXpixel ) );
2178 #endif
2179 }
int m_marginRight
Definition: mathplot.h:1519
int m_marginLeft
Definition: mathplot.h:1519
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1185
double m_desiredXmax
Definition: mathplot.h:1517
double m_posX
Definition: mathplot.h:1507
double m_scaleX
Definition: mathplot.h:1505
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1517
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:1344
int m_scrX
Definition: mathplot.h:1509

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

2183 {
2184  // Preserve the position of the clicked point:
2185  double staticY = p2y( staticYpixel );
2186 
2187  // Zoom out:
2189  // Adjust the new m_posx/y:
2190  m_posY = staticY + (staticYpixel / m_scaleY);
2191  // Adjust desired
2194 #ifdef MATHPLOT_DO_LOGGING
2195  wxLogMessage(
2196  "mpWindow::DoZoomOutYCalc() prior Y coord: (%f), new Y coord: (%f) SHOULD BE EQUAL!!",
2197  staticY, p2y( staticYpixel ) );
2198 #endif
2199 }
double m_scaleY
Definition: mathplot.h:1506
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1190
double m_desiredYmax
Definition: mathplot.h:1517
double m_posY
Definition: mathplot.h:1508
int m_marginTop
Definition: mathplot.h:1519
double m_desiredYmin
Definition: mathplot.h:1517
int m_marginBottom
Definition: mathplot.h:1519
int m_scrY
Definition: mathplot.h:1510
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:1344

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

1205 { m_enableDoubleBuffer = enabled; }
bool m_enableDoubleBuffer
Definition: mathplot.h:1524

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

1209 { m_enableMouseNavigation = enabled; }
bool m_enableMouseNavigation
Definition: mathplot.h:1525

◆ EnableMouseWheelPan()

void mpWindow::EnableMouseWheelPan ( bool  enabled)
inline

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

Definition at line 1213 of file mathplot.h.

1213 { m_enableMouseWheelPan = enabled; }
bool m_enableMouseWheelPan
Definition: mathplot.h:1526

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

2032 {
2033  if( UpdateBBox() )
2034  Fit( m_minX, m_maxX, m_minY, m_maxY );
2035 }
double m_minY
Definition: mathplot.h:1503
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:2031
double m_minX
Definition: mathplot.h:1501
virtual bool UpdateBBox()
Recalculate global layer bounding box, and save it in m_minX,...
Definition: mathplot.cpp:2745
double m_maxX
Definition: mathplot.h:1502
double m_maxY
Definition: mathplot.h:1504

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

2041 {
2042  // Save desired borders:
2043  m_desiredXmin = xMin; m_desiredXmax = xMax;
2044  m_desiredYmin = yMin; m_desiredYmax = yMax;
2045 
2046  // Give a small margin to plot area
2047  double xExtra = fabs( xMax - xMin ) * 0.00;
2048  double yExtra = fabs( yMax - yMin ) * 0.03;
2049 
2050  xMin -= xExtra;
2051  xMax += xExtra;
2052  yMin -= yExtra;
2053  yMax += yExtra;
2054 
2055  if( printSizeX!=NULL && printSizeY!=NULL )
2056  {
2057  // Printer:
2058  m_scrX = *printSizeX;
2059  m_scrY = *printSizeY;
2060  }
2061  else
2062  {
2063  // Normal case (screen):
2064  GetClientSize( &m_scrX, &m_scrY );
2065  }
2066 
2067  double Ax, Ay;
2068 
2069  Ax = xMax - xMin;
2070  Ay = yMax - yMin;
2071 
2072  m_scaleX = (Ax!=0) ? (m_scrX - m_marginLeft - m_marginRight) / Ax : 1; // m_scaleX = (Ax!=0) ? m_scrX/Ax : 1;
2073  m_scaleY = (Ay!=0) ? (m_scrY - m_marginTop - m_marginBottom) / Ay : 1; // m_scaleY = (Ay!=0) ? m_scrY/Ay : 1;
2074 
2075  if( m_lockaspect )
2076  {
2077 #ifdef MATHPLOT_DO_LOGGING
2078  wxLogMessage( "mpWindow::Fit()(lock) m_scaleX=%f,m_scaleY=%f", m_scaleX, m_scaleY );
2079 #endif
2080  // Keep the lowest "scale" to fit the whole range required by that axis (to actually "fit"!):
2081  double s = m_scaleX < m_scaleY ? m_scaleX : m_scaleY;
2082  m_scaleX = s;
2083  m_scaleY = s;
2084  }
2085 
2086  // Adjusts corner coordinates: This should be simply:
2087  // m_posX = m_minX;
2088  // m_posY = m_maxY;
2089  // But account for centering if we have lock aspect:
2090  m_posX = (xMin + xMax) / 2 - ( (m_scrX - m_marginLeft - m_marginRight) / 2 + m_marginLeft ) /
2091  m_scaleX; // m_posX = (xMin+xMax)/2 - (m_scrX/2)/m_scaleX;
2092  // 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;
2093  m_posY = (yMin + yMax) / 2 + ( (m_scrY - m_marginTop - m_marginBottom) / 2 + m_marginTop ) /
2094  m_scaleY; // m_posY = (yMin+yMax)/2 + (m_scrY/2)/m_scaleY;
2095 
2096 #ifdef MATHPLOT_DO_LOGGING
2097  wxLogMessage(
2098  "mpWindow::Fit() m_desiredXmin=%f m_desiredXmax=%f m_desiredYmin=%f m_desiredYmax=%f",
2099  xMin,
2100  xMax,
2101  yMin,
2102  yMax );
2103  wxLogMessage(
2104  "mpWindow::Fit() m_scaleX = %f , m_scrX = %d,m_scrY=%d, Ax=%f, Ay=%f, m_posX=%f, m_posY=%f",
2105  m_scaleX,
2106  m_scrX,
2107  m_scrY,
2108  Ax,
2109  Ay,
2110  m_posX,
2111  m_posY );
2112 #endif
2113 
2114  // It is VERY IMPORTANT to DO NOT call Refresh if we are drawing to the printer!!
2115  // Otherwise, the DC dimensions will be those of the window instead of the printer device
2116  if( printSizeX==NULL || printSizeY==NULL )
2117  UpdateAll();
2118 }
int m_marginRight
Definition: mathplot.h:1519
int m_marginLeft
Definition: mathplot.h:1519
double m_desiredXmax
Definition: mathplot.h:1517
double m_scaleY
Definition: mathplot.h:1506
double m_posX
Definition: mathplot.h:1507
double m_scaleX
Definition: mathplot.h:1505
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2853
double m_desiredYmax
Definition: mathplot.h:1517
bool m_lockaspect
Definition: mathplot.h:1495
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1517
double m_posY
Definition: mathplot.h:1508
int m_marginTop
Definition: mathplot.h:1519
double m_desiredYmin
Definition: mathplot.h:1517
int m_marginBottom
Definition: mathplot.h:1519
int m_scrY
Definition: mathplot.h:1510
int m_scrX
Definition: mathplot.h:1509

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, and UpdateAll().

◆ GetAxesColour()

const wxColour& mpWindow::GetAxesColour ( )
inline

Get axes draw colour.

Returns
reference to axis colour used in theme

Definition at line 1419 of file mathplot.h.

1419 { return m_axColour; };
wxColour m_axColour
Definition: mathplot.h:1499

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

3075 {
3076  bbox[0] = m_minX;
3077  bbox[1] = m_maxX;
3078  bbox[2] = m_minY;
3079  bbox[3] = m_maxY;
3080 }
double m_minY
Definition: mathplot.h:1503
double m_minX
Definition: mathplot.h:1501
double m_maxX
Definition: mathplot.h:1502
double m_maxY
Definition: mathplot.h:1504

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

1305 { return m_desiredXmax; }
double m_desiredXmax
Definition: mathplot.h:1517

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

1299 { 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:1517

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

1317 { return m_desiredYmax; }
double m_desiredYmax
Definition: mathplot.h:1517

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

1311 { return m_desiredYmin; }
double m_desiredYmin
Definition: mathplot.h:1517

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

3055 {
3056  if( ( position >= (int) m_layers.size() ) || position < 0 )
3057  return NULL;
3058 
3059  return m_layers[position];
3060 }
wxLayerList m_layers
Definition: mathplot.h:1493

References m_layers.

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

3064 {
3065  for( wxLayerList::iterator it = m_layers.begin(); it!=m_layers.end(); it++ )
3066  if( !(*it)->GetName().Cmp( name ) )
3067  return *it;
3068 
3069 
3070  return NULL; // Not found
3071 }
wxLayerList m_layers
Definition: mathplot.h:1493
const char * name
Definition: DXF_plotter.cpp:61

References m_layers, and name.

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

1330 { return m_enableScrollBars; };
bool m_enableScrollBars
Definition: mathplot.h:1530

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

1056 { return &m_popmenu; }
wxMenu m_popmenu
Definition: mathplot.h:1494

◆ GetPosX()

double mpWindow::GetPosX ( void  ) const
inline

Definition at line 1116 of file mathplot.h.

1116 { return m_posX; }
double m_posX
Definition: mathplot.h:1507

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

◆ GetPosY()

double mpWindow::GetPosY ( void  ) const
inline

Definition at line 1123 of file mathplot.h.

1123 { return m_posY; }
double m_posY
Definition: mathplot.h:1508

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

◆ GetScaleX()

double mpWindow::GetScaleX ( void  ) const
inline

Definition at line 1102 of file mathplot.h.

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

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

◆ GetScaleY()

double mpWindow::GetScaleY ( void  ) const
inline

Definition at line 1109 of file mathplot.h.

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

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

1131 { return m_scrX; }
int m_scrX
Definition: mathplot.h:1509

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

1140 { return m_scrY; }
int m_scrY
Definition: mathplot.h:1510

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

1115 { return m_posX; }
double m_posX
Definition: mathplot.h:1507

◆ GetXscl()

double mpWindow::GetXscl ( )
inline

Get current view's X scale.

See rules for coordinate transformation

Returns
Scale

Definition at line 1101 of file mathplot.h.

1101 { return m_scaleX; }
double m_scaleX
Definition: mathplot.h:1505

◆ GetXScreen()

int mpWindow::GetXScreen ( void  ) const
inline

Definition at line 1132 of file mathplot.h.

1132 { return m_scrX; }
int m_scrX
Definition: mathplot.h:1509

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

1122 { return m_posY; }
double m_posY
Definition: mathplot.h:1508

◆ GetYscl()

double mpWindow::GetYscl ( ) const
inline

Get current view's Y scale.

See rules for coordinate transformation

Returns
Scale

Definition at line 1108 of file mathplot.h.

1108 { return m_scaleY; }
double m_scaleY
Definition: mathplot.h:1506

◆ GetYScreen()

int mpWindow::GetYScreen ( void  ) const
inline

Definition at line 1141 of file mathplot.h.

1141 { return m_scrY; }
int m_scrY
Definition: mathplot.h:1510

◆ IsAspectLocked()

bool mpWindow::IsAspectLocked ( )
inline

Checks whether the X/Y scale aspect is locked.

Return values
TRUELocked
FALSEUnlocked

Definition at line 1226 of file mathplot.h.

1226 { return m_lockaspect; }
bool m_lockaspect
Definition: mathplot.h:1495

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

3151 {
3152  wxLayerList::iterator li;
3153 
3154  for( li = m_layers.begin(); li != m_layers.end(); li++ )
3155  {
3156 #ifdef MATHPLOT_DO_LOGGING
3157  wxLogMessage( "mpWindow::IsInsideInfoLayer() examinining layer = %p", (*li) );
3158 #endif // MATHPLOT_DO_LOGGING
3159 
3160  if( (*li)->IsInfo() )
3161  {
3162  mpInfoLayer* tmpLyr = (mpInfoLayer*) (*li);
3163 #ifdef MATHPLOT_DO_LOGGING
3164  wxLogMessage( "mpWindow::IsInsideInfoLayer() layer = %p", (*li) );
3165 #endif // MATHPLOT_DO_LOGGING
3166 
3167  if( tmpLyr->Inside( point ) )
3168  {
3169  return tmpLyr;
3170  }
3171  }
3172  }
3173 
3174  return NULL;
3175 }
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:1493
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:334

References mpInfoLayer::Inside(), and m_layers.

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

3191 {
3192  mpLayer* lx = GetLayerByName( name );
3193 
3194  return (lx) ? lx->IsVisible() : false;
3195 }
bool IsVisible()
Checks whether the layer is visible or not.
Definition: mathplot.h:297
mpLayer * GetLayerByName(const wxString &name)
Definition: mathplot.cpp:3063
const char * name
Definition: DXF_plotter.cpp:61

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

3211 {
3212  mpLayer* lx = GetLayer( position );
3213 
3214  return (lx) ? lx->IsVisible() : false;
3215 }
mpLayer * GetLayer(int position)
Definition: mathplot.cpp:3054
bool IsVisible()
Checks whether the layer is visible or not.
Definition: mathplot.h:297

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

1423  {
1424  m_enableLimitedView = aEnable;
1425  }
bool m_enableLimitedView
Definition: mathplot.h:1527

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

2444 {
2445  m_lockaspect = enable;
2446  m_popmenu.Check( mpID_LOCKASPECT, enable );
2447 
2448  // Try to fit again with the new config:
2450 }
double m_desiredXmax
Definition: mathplot.h:1517
double m_desiredYmax
Definition: mathplot.h:1517
bool m_lockaspect
Definition: mathplot.h:1495
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1517
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:2031
double m_desiredYmin
Definition: mathplot.h:1517
wxMenu m_popmenu
Definition: mathplot.h:1494

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

2474 {
2475  GetClientSize( &m_scrX, &m_scrY );
2476  int centerX = (m_scrX - m_marginLeft - m_marginRight) / 2; // + m_marginLeft; // c.x = m_scrX/2;
2477  int centerY = (m_scrY - m_marginTop - m_marginBottom) / 2; // - m_marginTop; // c.y = m_scrY/2;
2478  SetPos( p2x( m_clickedX - centerX ), p2y( m_clickedY - centerY ) );
2479  // 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);
2480 }
int m_marginRight
Definition: mathplot.h:1519
int m_marginLeft
Definition: mathplot.h:1519
int m_clickedX
Definition: mathplot.h:1511
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1185
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1190
int m_marginTop
Definition: mathplot.h:1519
void SetPos(double posX, double posY)
Set current view's X and Y position and refresh display.
Definition: mathplot.h:1173
int m_clickedY
Definition: mathplot.h:1512
int m_marginBottom
Definition: mathplot.h:1519
int m_scrY
Definition: mathplot.h:1510
int m_scrX
Definition: mathplot.h:1509

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

2468 {
2469  Fit();
2470 }
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:2031

References Fit().

◆ OnLockAspect()

void mpWindow::OnLockAspect ( wxCommandEvent &  event)
protected

Definition at line 2461 of file mathplot.cpp.

2462 {
2464 }
bool m_lockaspect
Definition: mathplot.h:1495
void LockAspect(bool enable=TRUE)
Enable or disable X/Y scale aspect locking for the view.
Definition: mathplot.cpp:2443

References LockAspect(), and m_lockaspect.

◆ OnMagnify()

void mpWindow::OnMagnify ( wxMouseEvent &  event)
protected

◆ OnMouseLeftDown()

void mpWindow::OnMouseLeftDown ( wxMouseEvent &  event)
protected

Definition at line 1978 of file mathplot.cpp.

1979 {
1980  m_mouseLClick.x = event.GetX();
1981  m_mouseLClick.y = event.GetY();
1982  m_zooming = true;
1983 #ifdef MATHPLOT_DO_LOGGING
1984  wxLogMessage( "mpWindow::OnMouseLeftDown() X = %d , Y = %d", event.GetX(), event.GetY() ); /*m_mouseLClick.x, m_mouseLClick.y);*/
1985 #endif
1986  wxPoint pointClicked = event.GetPosition();
1987  m_movingInfoLayer = IsInsideInfoLayer( pointClicked );
1988 
1989  if( m_movingInfoLayer != NULL )
1990  {
1991 #ifdef MATHPLOT_DO_LOGGING
1992  wxLogMessage( "mpWindow::OnMouseLeftDown() started moving layer %lx",
1993  (long int) m_movingInfoLayer ); /*m_mouseLClick.x, m_mouseLClick.y);*/
1994 #endif
1995  }
1996 
1997  event.Skip();
1998 }
bool m_zooming
Definition: mathplot.h:1533
mpInfoLayer * IsInsideInfoLayer(wxPoint &point)
Check if a given point is inside the area of a mpInfoLayer and eventually returns its pointer.
Definition: mathplot.cpp:3150
wxPoint m_mouseLClick
Definition: mathplot.h:1529
mpInfoLayer * m_movingInfoLayer
Definition: mathplot.h:1532

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

◆ OnMouseLeftRelease()

void mpWindow::OnMouseLeftRelease ( wxMouseEvent &  event)
protected

Definition at line 2001 of file mathplot.cpp.

2002 {
2003  wxPoint release( event.GetX(), event.GetY() );
2004  wxPoint press( m_mouseLClick.x, m_mouseLClick.y );
2005 
2006  m_zooming = false;
2007 
2008  if( m_movingInfoLayer != NULL )
2009  {
2011  m_movingInfoLayer = NULL;
2012  }
2013  else
2014  {
2015  if( release != press )
2016  {
2017  ZoomRect( press, release );
2018  } /*else {
2019  * if (m_coordTooltip) {
2020  * wxString toolTipContent;
2021  * toolTipContent.Printf( "X = %f\nY = %f", p2x(event.GetX()), p2y(event.GetY()));
2022  * SetToolTip(toolTipContent);
2023  * }
2024  * } */
2025  }
2026 
2027  event.Skip();
2028 }
bool m_zooming
Definition: mathplot.h:1533
wxPoint m_mouseLClick
Definition: mathplot.h:1529
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:2420
mpInfoLayer * m_movingInfoLayer
Definition: mathplot.h:1532
virtual void UpdateReference()
Updates the rectangle reference point.
Definition: mathplot.cpp:148

References m_mouseLClick, m_movingInfoLayer, m_zooming, mpInfoLayer::UpdateReference(), and ZoomRect().

◆ OnMouseMiddleDown()

void mpWindow::OnMouseMiddleDown ( wxMouseEvent &  event)
protected

Definition at line 1797 of file mathplot.cpp.

1798 {
1799  m_mouseMClick.x = event.GetX();
1800  m_mouseMClick.y = event.GetY();
1801 }
wxPoint m_mouseMClick
Definition: mathplot.h:1528

References m_mouseMClick.

◆ OnMouseMove()

void mpWindow::OnMouseMove ( wxMouseEvent &  event)
protected

Definition at line 1878 of file mathplot.cpp.

1879 {
1881  {
1882  event.Skip();
1883  return;
1884  }
1885 
1886  if( event.m_middleDown )
1887  {
1888  // The change:
1889  int Ax = m_mouseMClick.x - event.GetX();
1890  int Ay = m_mouseMClick.y - event.GetY();
1891 
1892  // For the next event, use relative to this coordinates.
1893  m_mouseMClick.x = event.GetX();
1894  m_mouseMClick.y = event.GetY();
1895 
1896  double Ax_units = Ax / m_scaleX;
1897  double Ay_units = -Ay / m_scaleY;
1898 
1899  bool updateRequired = false;
1900  updateRequired |= SetXView( m_posX + Ax_units,
1901  m_desiredXmax + Ax_units,
1902  m_desiredXmin + Ax_units );
1903  updateRequired |= SetYView( m_posY + Ay_units,
1904  m_desiredYmax + Ay_units,
1905  m_desiredYmin + Ay_units );
1906 
1907  if( updateRequired )
1908  UpdateAll();
1909 
1910 #ifdef MATHPLOT_DO_LOGGING
1911  wxLogMessage( "[mpWindow::OnMouseMove] Ax:%i Ay:%i m_posX:%f m_posY:%f",
1912  Ax,
1913  Ay,
1914  m_posX,
1915  m_posY );
1916 #endif
1917  }
1918  else
1919  {
1920  if( event.m_leftDown )
1921  {
1922  if( m_movingInfoLayer == NULL )
1923  {
1924  wxClientDC dc( this );
1925  wxPen pen( m_fgColour, 1, wxPENSTYLE_DOT );
1926  dc.SetPen( pen );
1927  dc.SetBrush( *wxTRANSPARENT_BRUSH );
1928  dc.DrawRectangle( m_mouseLClick.x, m_mouseLClick.y,
1929  event.GetX() - m_mouseLClick.x, event.GetY() - m_mouseLClick.y );
1930  m_zooming = true;
1931  m_zoomRect.x = m_mouseLClick.x;
1932  m_zoomRect.y = m_mouseLClick.y;
1933  m_zoomRect.width = event.GetX() - m_mouseLClick.x;
1934  m_zoomRect.height = event.GetY() - m_mouseLClick.y;
1935  }
1936  else
1937  {
1938  wxPoint moveVector( event.GetX() - m_mouseLClick.x,
1939  event.GetY() - m_mouseLClick.y );
1940  m_movingInfoLayer->Move( moveVector );
1941  m_zooming = false;
1942  }
1943 
1944  UpdateAll();
1945  }
1946  else
1947  {
1948 #if 0
1949  wxLayerList::iterator li;
1950 
1951  for( li = m_layers.begin(); li != m_layers.end(); li++ )
1952  {
1953  if( (*li)->IsInfo() && (*li)->IsVisible() )
1954  {
1955  mpInfoLayer* tmpLyr = (mpInfoLayer*) (*li);
1956  tmpLyr->UpdateInfo( *this, event );
1957  // UpdateAll();
1958  RefreshRect( tmpLyr->GetRectangle() );
1959  }
1960  }
1961 
1962 #endif
1963  /* if (m_coordTooltip) {
1964  * wxString toolTipContent;
1965  * toolTipContent.Printf( "X = %f\nY = %f", p2x(event.GetX()), p2y(event.GetY()));
1966  * wxTipWindow** ptr = NULL;
1967  * wxRect rectBounds(event.GetX(), event.GetY(), 5, 5);
1968  * wxTipWindow* tip = new wxTipWindow(this, toolTipContent, 100, ptr, &rectBounds);
1969  *
1970  * } */
1971  }
1972  }
1973 
1974  event.Skip();
1975 }
bool m_zooming
Definition: mathplot.h:1533
virtual bool SetYView(double pos, double desiredMax, double desiredMin)
Applies new Y view coordinates depending on the settings.
Definition: mathplot.cpp:2262
double m_desiredXmax
Definition: mathplot.h:1517
double m_scaleY
Definition: mathplot.h:1506
bool m_enableMouseNavigation
Definition: mathplot.h:1525
double m_posX
Definition: mathplot.h:1507
wxPoint m_mouseMClick
Definition: mathplot.h:1528
double m_scaleX
Definition: mathplot.h:1505
wxLayerList m_layers
Definition: mathplot.h:1493
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2853
wxPoint m_mouseLClick
Definition: mathplot.h:1529
virtual void Move(wxPoint delta)
Moves the layer rectangle of given pixel deltas.
Definition: mathplot.cpp:141
double m_desiredYmax
Definition: mathplot.h:1517
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:334
wxRect m_zoomRect
Definition: mathplot.h:1534
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1517
mpInfoLayer * m_movingInfoLayer
Definition: mathplot.h:1532
wxColour m_fgColour
Definition: mathplot.h:1498
double m_posY
Definition: mathplot.h:1508
const wxRect & GetRectangle()
Returns the current rectangle coordinates.
Definition: mathplot.h:391
double m_desiredYmin
Definition: mathplot.h:1517
virtual bool SetXView(double pos, double desiredMax, double desiredMin)
Applies new X view coordinates depending on the settings.
Definition: mathplot.cpp:2248

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(), SetXView(), SetYView(), UpdateAll(), and mpInfoLayer::UpdateInfo().

◆ OnMouseWheel()

void mpWindow::OnMouseWheel ( wxMouseEvent &  event)
protected

Definition at line 1823 of file mathplot.cpp.

1824 {
1826  {
1827  event.Skip();
1828  return;
1829  }
1830 
1831  int change = event.GetWheelRotation();
1832  const int axis = event.GetWheelAxis();
1833  double changeUnitsX = change / m_scaleX;
1834  double changeUnitsY = change / m_scaleY;
1835 
1836  if( ( !m_enableMouseWheelPan && ( event.ControlDown() || event.ShiftDown() ) )
1837  || ( m_enableMouseWheelPan && !event.ControlDown() ) )
1838  {
1839  // Scrolling
1840  if( m_enableMouseWheelPan )
1841  {
1842  if( axis == wxMOUSE_WHEEL_HORIZONTAL || event.ShiftDown() )
1843  SetXView( m_posX + changeUnitsX, m_desiredXmax + changeUnitsX,
1844  m_desiredXmin + changeUnitsX );
1845  else
1846  SetYView( m_posY + changeUnitsY, m_desiredYmax + changeUnitsY,
1847  m_desiredYmin + changeUnitsY );
1848  }
1849  else
1850  {
1851  if( event.ControlDown() )
1852  SetXView( m_posX + changeUnitsX, m_desiredXmax + changeUnitsX,
1853  m_desiredXmin + changeUnitsX );
1854  else
1855  SetYView( m_posY + changeUnitsY, m_desiredYmax + changeUnitsY,
1856  m_desiredYmin + changeUnitsY );
1857  }
1858 
1859  UpdateAll();
1860  }
1861  else
1862  {
1863  // zoom in/out
1864  wxPoint clickPt( event.GetX(), event.GetY() );
1865 
1866  if( event.GetWheelRotation() > 0 )
1867  ZoomIn( clickPt );
1868  else
1869  ZoomOut( clickPt );
1870 
1871  return;
1872  }
1873 }
void ZoomOut(const wxPoint &centerPoint=wxDefaultPosition)
Zoom out current view and refresh display.
Definition: mathplot.cpp:2339
virtual bool SetYView(double pos, double desiredMax, double desiredMin)
Applies new Y view coordinates depending on the settings.
Definition: mathplot.cpp:2262
double m_desiredXmax
Definition: mathplot.h:1517
double m_scaleY
Definition: mathplot.h:1506
bool m_enableMouseNavigation
Definition: mathplot.h:1525
double m_posX
Definition: mathplot.h:1507
bool m_enableMouseWheelPan
Definition: mathplot.h:1526
double m_scaleX
Definition: mathplot.h:1505
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2853
double m_desiredYmax
Definition: mathplot.h:1517
void ZoomIn(const wxPoint &centerPoint=wxDefaultPosition)
Zoom into current view and refresh display.
Definition: mathplot.cpp:2276
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1517
double m_posY
Definition: mathplot.h:1508
double m_desiredYmin
Definition: mathplot.h:1517
virtual bool SetXView(double pos, double desiredMax, double desiredMin)
Applies new X view coordinates depending on the settings.
Definition: mathplot.cpp:2248

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

2566 {
2567  wxPaintDC dc( this );
2568 
2569  dc.GetSize( &m_scrX, &m_scrY ); // This is the size of the visible area only!
2570 
2571 #ifdef MATHPLOT_DO_LOGGING
2572  wxLogMessage( "[mpWindow::OnPaint] vis.area: x %i y%i", m_scrX, m_scrY );
2573 #endif
2574 
2575  // Selects direct or buffered draw:
2576  wxDC* trgDc;
2577 
2578  // J.L.Blanco @ Aug 2007: Added double buffer support
2579  if( m_enableDoubleBuffer )
2580  {
2581  if( m_last_lx!=m_scrX || m_last_ly!=m_scrY )
2582  {
2583  if( m_buff_bmp )
2584  delete m_buff_bmp;
2585 
2586  m_buff_bmp = new wxBitmap( m_scrX, m_scrY );
2587  m_buff_dc.SelectObject( *m_buff_bmp );
2588  m_last_lx = m_scrX;
2589  m_last_ly = m_scrY;
2590  }
2591 
2592  trgDc = &m_buff_dc;
2593  }
2594  else
2595  {
2596  trgDc = &dc;
2597  }
2598 
2599  // Draw background:
2600  // trgDc->SetDeviceOrigin(0,0);
2601  trgDc->SetPen( *wxTRANSPARENT_PEN );
2602  wxBrush brush( GetBackgroundColour() );
2603  trgDc->SetBrush( brush );
2604  trgDc->SetTextForeground( m_fgColour );
2605  trgDc->DrawRectangle( 0, 0, m_scrX, m_scrY );
2606 
2607  // Draw all the layers:
2608  // trgDc->SetDeviceOrigin( m_scrX>>1, m_scrY>>1); // Origin at the center
2609  wxLayerList::iterator li;
2610 
2611  for( li = m_layers.begin(); li != m_layers.end(); li++ )
2612  {
2613  (*li)->Plot( *trgDc, *this );
2614  }
2615 
2616  ;
2617 
2618  if( m_zooming )
2619  {
2620  wxPen pen( m_fgColour, 1, wxPENSTYLE_DOT );
2621  trgDc->SetPen( pen );
2622  trgDc->SetBrush( *wxTRANSPARENT_BRUSH );
2623  trgDc->DrawRectangle( m_zoomRect );
2624  }
2625 
2626  // If doublebuffer, draw now to the window:
2627  if( m_enableDoubleBuffer )
2628  {
2629  // trgDc->SetDeviceOrigin(0,0);
2630  // dc.SetDeviceOrigin(0,0); // Origin at the center
2631  dc.Blit( 0, 0, m_scrX, m_scrY, trgDc, 0, 0 );
2632  }
2633 
2634  /* if (m_coordTooltip) {
2635  * wxString toolTipContent;
2636  * wxPoint mousePoint = wxGetMousePosition();
2637  * toolTipContent.Printf( "X = %f\nY = %f", p2x(mousePoint.x), p2y(mousePoint.y));
2638  * SetToolTip(toolTipContent);
2639  * }*/
2640  // If scrollbars are enabled, refresh them
2641  if( m_enableScrollBars )
2642  {
2643  /* m_scroll.x = (int) floor((m_posX - m_minX)*m_scaleX);
2644  * m_scroll.y = (int) floor((m_maxY - m_posY )*m_scaleY);
2645  * Scroll(m_scroll.x, m_scroll.y);*/
2646  // Scroll(x2p(m_posX), y2p(m_posY));
2647  // SetVirtualSize((int) ((m_maxX - m_minX)*m_scaleX), (int) ((m_maxY - m_minY)*m_scaleY));
2648  // int centerX = (m_scrX - m_marginLeft - m_marginRight)/2; // + m_marginLeft; // c.x = m_scrX/2;
2649  // int centerY = (m_scrY - m_marginTop - m_marginBottom)/2; // - m_marginTop; // c.y = m_scrY/2;
2650  /*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);
2651  }
2652 }
wxMemoryDC m_buff_dc
Definition: mathplot.h:1522
bool m_enableScrollBars
Definition: mathplot.h:1530
bool m_zooming
Definition: mathplot.h:1533
wxLayerList m_layers
Definition: mathplot.h:1493
wxRect m_zoomRect
Definition: mathplot.h:1534
wxColour m_fgColour
Definition: mathplot.h:1498
int m_last_ly
Definition: mathplot.h:1521
int m_last_lx
Definition: mathplot.h:1521
int m_scrY
Definition: mathplot.h:1510
bool m_enableDoubleBuffer
Definition: mathplot.h:1524
int m_scrX
Definition: mathplot.h:1509
wxBitmap * m_buff_bmp
Definition: mathplot.h:1523

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

3012 {
3013  int scrollOrientation = event.GetOrientation();
3014  // Get thumb size
3015  int thumbSize = GetScrollThumb( scrollOrientation );
3016  // Get scroll range
3017  int scrollRange = GetScrollRange( scrollOrientation );
3018 
3019  DoScrollCalc( scrollRange - thumbSize, scrollOrientation );
3020 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2900

References DoScrollCalc().

◆ OnScrollLineDown()

void mpWindow::OnScrollLineDown ( wxScrollWinEvent &  event)
protected

Definition at line 2985 of file mathplot.cpp.

2986 {
2987  int scrollOrientation = event.GetOrientation();
2988  // Get position before page up
2989  int position = GetScrollPos( scrollOrientation );
2990  // Get thumb size
2991  int thumbSize = GetScrollThumb( scrollOrientation );
2992  // Get scroll range
2993  int scrollRange = GetScrollRange( scrollOrientation );
2994 
2995  // Need to adjust position by a page
2996  position += mpSCROLL_NUM_PIXELS_PER_LINE;
2997 
2998  if( position > (scrollRange - thumbSize) )
2999  position = scrollRange - thumbSize;
3000 
3001  DoScrollCalc( position, scrollOrientation );
3002 }
#define mpSCROLL_NUM_PIXELS_PER_LINE
Definition: mathplot.cpp:61
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2900

References DoScrollCalc(), and mpSCROLL_NUM_PIXELS_PER_LINE.

◆ OnScrollLineUp()

void mpWindow::OnScrollLineUp ( wxScrollWinEvent &  event)
protected

Definition at line 2969 of file mathplot.cpp.

2970 {
2971  int scrollOrientation = event.GetOrientation();
2972  // Get position before page up
2973  int position = GetScrollPos( scrollOrientation );
2974 
2975  // Need to adjust position by a line
2976  position -= mpSCROLL_NUM_PIXELS_PER_LINE;
2977 
2978  if( position < 0 )
2979  position = 0;
2980 
2981  DoScrollCalc( position, scrollOrientation );
2982 }
#define mpSCROLL_NUM_PIXELS_PER_LINE
Definition: mathplot.cpp:61
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2900

References DoScrollCalc(), and mpSCROLL_NUM_PIXELS_PER_LINE.

◆ OnScrollPageDown()

void mpWindow::OnScrollPageDown ( wxScrollWinEvent &  event)
protected

Definition at line 2949 of file mathplot.cpp.

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

References DoScrollCalc().

◆ OnScrollPageUp()

void mpWindow::OnScrollPageUp ( wxScrollWinEvent &  event)
protected

Definition at line 2931 of file mathplot.cpp.

2932 {
2933  int scrollOrientation = event.GetOrientation();
2934  // Get position before page up
2935  int position = GetScrollPos( scrollOrientation );
2936  // Get thumb size
2937  int thumbSize = GetScrollThumb( scrollOrientation );
2938 
2939  // Need to adjust position by a page
2940  position -= thumbSize;
2941 
2942  if( position < 0 )
2943  position = 0;
2944 
2945  DoScrollCalc( position, scrollOrientation );
2946 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2900

References DoScrollCalc().

◆ OnScrollThumbTrack()

void mpWindow::OnScrollThumbTrack ( wxScrollWinEvent &  event)
protected

Definition at line 2925 of file mathplot.cpp.

2926 {
2927  DoScrollCalc( event.GetPosition(), event.GetOrientation() );
2928 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2900

References DoScrollCalc().

◆ OnScrollTop()

void mpWindow::OnScrollTop ( wxScrollWinEvent &  event)
protected

Definition at line 3005 of file mathplot.cpp.

3006 {
3007  DoScrollCalc( 0, event.GetOrientation() );
3008 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2900

References DoScrollCalc().

◆ OnShowPopupMenu()

void mpWindow::OnShowPopupMenu ( wxMouseEvent &  event)
protected

Definition at line 2453 of file mathplot.cpp.

2454 {
2455  m_clickedX = event.GetX();
2456  m_clickedY = event.GetY();
2457  PopupMenu( &m_popmenu, event.GetX(), event.GetY() );
2458 }
int m_clickedX
Definition: mathplot.h:1511
int m_clickedY
Definition: mathplot.h:1512
wxMenu m_popmenu
Definition: mathplot.h:1494

References m_clickedX, m_clickedY, and m_popmenu.

◆ OnSize()

void mpWindow::OnSize ( wxSizeEvent &  event)
protected

Definition at line 2495 of file mathplot.cpp.

2496 {
2497  // Try to fit again with the new window size:
2499 #ifdef MATHPLOT_DO_LOGGING
2500  wxLogMessage( "mpWindow::OnSize() m_scrX = %d, m_scrY = %d", m_scrX, m_scrY );
2501 #endif // MATHPLOT_DO_LOGGING
2502 }
double m_desiredXmax
Definition: mathplot.h:1517
double m_desiredYmax
Definition: mathplot.h:1517
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1517
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:2031
double m_desiredYmin
Definition: mathplot.h:1517
int m_scrY
Definition: mathplot.h:1510
int m_scrX
Definition: mathplot.h:1509

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

2484 {
2485  ZoomIn( wxPoint( m_mouseMClick.x, m_mouseMClick.y ) );
2486 }
wxPoint m_mouseMClick
Definition: mathplot.h:1528
void ZoomIn(const wxPoint &centerPoint=wxDefaultPosition)
Zoom into current view and refresh display.
Definition: mathplot.cpp:2276

References m_mouseMClick, and ZoomIn().

◆ OnZoomOut()

void mpWindow::OnZoomOut ( wxCommandEvent &  event)
protected

Definition at line 2489 of file mathplot.cpp.

2490 {
2491  ZoomOut();
2492 }
void ZoomOut(const wxPoint &centerPoint=wxDefaultPosition)
Zoom out current view and refresh display.
Definition: mathplot.cpp:2339

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

1185 { return m_posX + pixelCoordX / m_scaleX; }
double m_posX
Definition: mathplot.h:1507
double m_scaleX
Definition: mathplot.h:1505

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

1190 { return m_posY - pixelCoordY / m_scaleY; }
double m_scaleY
Definition: mathplot.h:1506
double m_posY
Definition: mathplot.h:1508

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

3085 {
3086  int sizeX, sizeY;
3087  int bk_scrX, bk_scrY;
3088 
3089  if( imageSize == wxDefaultSize )
3090  {
3091  sizeX = m_scrX;
3092  sizeY = m_scrY;
3093  }
3094  else
3095  {
3096  sizeX = imageSize.x;
3097  sizeY = imageSize.y;
3098  bk_scrX = m_scrX;
3099  bk_scrY = m_scrY;
3100  SetScr( sizeX, sizeY );
3101  }
3102 
3103  wxBitmap screenBuffer( sizeX, sizeY );
3104  wxMemoryDC screenDC;
3105  screenDC.SelectObject( screenBuffer );
3106  screenDC.SetPen( *wxWHITE_PEN );
3107  screenDC.SetTextForeground( m_fgColour );
3108  wxBrush brush( GetBackgroundColour() );
3109  screenDC.SetBrush( brush );
3110  screenDC.DrawRectangle( 0, 0, sizeX, sizeY );
3111 
3112  if( fit )
3113  {
3114  Fit( m_minX, m_maxX, m_minY, m_maxY, &sizeX, &sizeY );
3115  }
3116  else
3117  {
3119  }
3120 
3121  // Draw all the layers:
3122  wxLayerList::iterator li;
3123 
3124  for( li = m_layers.begin(); li != m_layers.end(); li++ )
3125  (*li)->Plot( screenDC, *this );
3126 
3127  if( imageSize != wxDefaultSize )
3128  {
3129  // Restore dimensions
3130  SetScr( bk_scrX, bk_scrY );
3131  Fit( m_desiredXmin, m_desiredXmax, m_desiredYmin, m_desiredYmax, &bk_scrX, &bk_scrY );
3132  UpdateAll();
3133  }
3134 
3135  // Once drawing is complete, actually save screen shot
3136  wxImage screenImage = screenBuffer.ConvertToImage();
3137  return screenImage.SaveFile( filename, type );
3138 }
double m_desiredXmax
Definition: mathplot.h:1517
double m_minY
Definition: mathplot.h:1503
wxLayerList m_layers
Definition: mathplot.h:1493
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2853
double m_desiredYmax
Definition: mathplot.h:1517
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1517
wxColour m_fgColour
Definition: mathplot.h:1498
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:2031
double m_minX
Definition: mathplot.h:1501
double m_desiredYmin
Definition: mathplot.h:1517
void SetScr(int scrX, int scrY)
Set current view's dimensions in device context units.
Definition: mathplot.h:1180
int m_scrY
Definition: mathplot.h:1510
double m_maxX
Definition: mathplot.h:1502
int m_scrX
Definition: mathplot.h:1509
double m_maxY
Definition: mathplot.h:1504

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

3221 {
3222  SetBackgroundColour( bgColour );
3223  SetForegroundColour( drawColour );
3224  m_bgColour = bgColour;
3225  m_fgColour = drawColour;
3226  m_axColour = axesColour;
3227  // cycle between layers to set colours and properties to them
3228  wxLayerList::iterator li;
3229 
3230  for( li = m_layers.begin(); li != m_layers.end(); li++ )
3231  {
3232  if( (*li)->GetLayerType() == mpLAYER_AXIS )
3233  {
3234  wxPen axisPen = (*li)->GetPen(); // Get the old pen to modify only colour, not style or width
3235  axisPen.SetColour( axesColour );
3236  (*li)->SetPen( axisPen );
3237  }
3238 
3239  if( (*li)->GetLayerType() == mpLAYER_INFO )
3240  {
3241  wxPen infoPen = (*li)->GetPen(); // Get the old pen to modify only colour, not style or width
3242  infoPen.SetColour( drawColour );
3243  (*li)->SetPen( infoPen );
3244  }
3245  }
3246 }
wxColour m_axColour
Definition: mathplot.h:1499
wxLayerList m_layers
Definition: mathplot.h:1493
wxColour m_fgColour
Definition: mathplot.h:1498
wxColour m_bgColour
Definition: mathplot.h:1497

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

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

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

3179 {
3180  mpLayer* lx = GetLayerByName( name );
3181 
3182  if( lx )
3183  {
3184  lx->SetVisible( viewable );
3185  UpdateAll();
3186  }
3187 }
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2853
void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:301
mpLayer * GetLayerByName(const wxString &name)
Definition: mathplot.cpp:3063
const char * name
Definition: DXF_plotter.cpp:61

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

3199 {
3200  mpLayer* lx = GetLayer( position );
3201 
3202  if( lx )
3203  {
3204  lx->SetVisible( viewable );
3205  UpdateAll();
3206  }
3207 }
mpLayer * GetLayer(int position)
Definition: mathplot.cpp:3054
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2853
void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:301

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

◆ SetMarginBottom()

void mpWindow::SetMarginBottom ( int  bottom)
inline

Set the bottom margin.

Parameters
bottomBottom Margin

Definition at line 1359 of file mathplot.h.

1359 { m_marginBottom = bottom; };
int m_marginBottom
Definition: mathplot.h:1519

◆ SetMarginLeft()

void mpWindow::SetMarginLeft ( int  left)
inline

Set the left margin.

Parameters
leftLeft Margin

Definition at line 1361 of file mathplot.h.

1361 { m_marginLeft = left; };
int m_marginLeft
Definition: mathplot.h:1519

◆ SetMarginRight()

void mpWindow::SetMarginRight ( int  right)
inline

Set the right margin.

Parameters
rightRight Margin

Definition at line 1357 of file mathplot.h.

1357 { m_marginRight = right; };
int m_marginRight
Definition: mathplot.h:1519

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

3142 {
3143  m_marginTop = top;
3144  m_marginRight = right;
3145  m_marginBottom = bottom;
3146  m_marginLeft = left;
3147 }
int m_marginRight
Definition: mathplot.h:1519
int m_marginLeft
Definition: mathplot.h:1519
int m_marginTop
Definition: mathplot.h:1519
int m_marginBottom
Definition: mathplot.h:1519

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

1355 { m_marginTop = top; };
int m_marginTop
Definition: mathplot.h:1519

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

2705 {
2706  // Temporary behaviour: always disable scrollbars
2707  m_enableScrollBars = status; // false;
2708 
2709  if( status == false )
2710  {
2711  SetScrollbar( wxHORIZONTAL, 0, 0, 0 );
2712  SetScrollbar( wxVERTICAL, 0, 0, 0 );
2713  }
2714 
2715  // else the scroll bars will be updated in UpdateAll();
2716  UpdateAll();
2717 
2718  // EnableScrolling(false, false);
2719  // m_enableScrollBars = status;
2720  // EnableScrolling(status, status);
2721  /* m_scroll.x = (int) floor((m_posX - m_minX)*m_scaleX);
2722  * m_scroll.y = (int) floor((m_posY - m_minY)*m_scaleY);*/
2723  // int scrollWidth = (int) floor((m_maxX - m_minX)*m_scaleX) - m_scrX;
2724  // int scrollHeight = (int) floor((m_minY - m_maxY)*m_scaleY) - m_scrY;
2725 
2727  // m_scroll.y = (int) floor((m_maxY - m_posY /*- m_minY*/)*m_scaleY);
2728  // int scrollWidth = (int) floor(((m_maxX - m_minX) - (m_desiredXmax - m_desiredXmin))*m_scaleX);
2729  // int scrollHeight = (int) floor(((m_maxY - m_minY) - (m_desiredYmax - m_desiredYmin))*m_scaleY);
2730  // #ifdef MATHPLOT_DO_LOGGING
2731  // wxLogMessage( "mpWindow::SetMPScrollbars() scrollWidth = %d, scrollHeight = %d", scrollWidth, scrollHeight);
2732  // #endif
2733  // if(status) {
2734  // SetScrollbars(1,
2735  // 1,
2736  // scrollWidth,
2737  // scrollHeight,
2738  // m_scroll.x,
2739  // m_scroll.y);
2741  // }
2742  // Refresh(false);*/
2743 }
bool m_enableScrollBars
Definition: mathplot.h:1530
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2853

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

1173 { m_posX = posX; m_posY = posY; UpdateAll(); }
double m_posX
Definition: mathplot.h:1507
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2853
double m_posY
Definition: mathplot.h:1508

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

1162 { m_posX = posX; UpdateAll(); }
double m_posX
Definition: mathplot.h:1507
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2853

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

1167 { m_posY = posY; UpdateAll(); }
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2853
double m_posY
Definition: mathplot.h:1508

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

3026 {
3027  if( scaleX!=0 )
3028  m_scaleX = scaleX;
3029 
3030  UpdateAll();
3031 }
double m_scaleX
Definition: mathplot.h:1505
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2853

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

1152  {
1153  if( scaleY!=0 )
1154  m_scaleY = scaleY;
1155 
1156  UpdateAll();
1157  }
double m_scaleY
Definition: mathplot.h:1506
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2853

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

1180 { m_scrX = scrX; m_scrY = scrY; }
int m_scrY
Definition: mathplot.h:1510
int m_scrX
Definition: mathplot.h:1509

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

2249 {
2250  // if(!CheckXLimits(desiredMax, desiredMin))
2251  // return false;
2252 
2253  m_posX = pos;
2254  m_desiredXmax = desiredMax;
2255  m_desiredXmin = desiredMin;
2257 
2258  return true;
2259 }
double m_desiredXmax
Definition: mathplot.h:1517
double m_posX
Definition: mathplot.h:1507
void AdjustLimitedView()
Definition: mathplot.cpp:2202
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1517

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

2263 {
2264  // if(!CheckYLimits(desiredMax, desiredMin))
2265  // return false;
2266 
2267  m_posY = pos;
2268  m_desiredYmax = desiredMax;
2269  m_desiredYmin = desiredMin;
2271 
2272  return true;
2273 }
double m_desiredYmax
Definition: mathplot.h:1517
void AdjustLimitedView()
Definition: mathplot.cpp:2202
double m_posY
Definition: mathplot.h:1508
double m_desiredYmin
Definition: mathplot.h:1517

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

Referenced by OnMouseMove(), and OnMouseWheel().

◆ UpdateAll()

void mpWindow::UpdateAll ( )

Refresh display.

Definition at line 2853 of file mathplot.cpp.

2854 {
2855  if( UpdateBBox() )
2856  {
2857  if( m_enableScrollBars )
2858  {
2859  int cx, cy;
2860  GetClientSize( &cx, &cy );
2861  // Do x scroll bar
2862  {
2863  // Convert margin sizes from pixels to coordinates
2864  double leftMargin = m_marginLeft / m_scaleX;
2865  // Calculate the range in coords that we want to scroll over
2866  double maxX = (m_desiredXmax > m_maxX) ? m_desiredXmax : m_maxX;
2867  double minX = (m_desiredXmin < m_minX) ? m_desiredXmin : m_minX;
2868 
2869  if( (m_posX + leftMargin) < minX )
2870  minX = m_posX + leftMargin;
2871 
2872  // Calculate scroll bar size and thumb position
2873  int sizeX = (int) ( (maxX - minX) * m_scaleX );
2874  int thumbX = (int) ( ( (m_posX + leftMargin) - minX ) * m_scaleX );
2875  SetScrollbar( wxHORIZONTAL, thumbX, cx - (m_marginRight + m_marginLeft), sizeX );
2876  }
2877  // Do y scroll bar
2878  {
2879  // Convert margin sizes from pixels to coordinates
2880  double topMargin = m_marginTop / m_scaleY;
2881  // Calculate the range in coords that we want to scroll over
2882  double maxY = (m_desiredYmax > m_maxY) ? m_desiredYmax : m_maxY;
2883 
2884  if( (m_posY - topMargin) > maxY )
2885  maxY = m_posY - topMargin;
2886 
2887  double minY = (m_desiredYmin < m_minY) ? m_desiredYmin : m_minY;
2888  // Calculate scroll bar size and thumb position
2889  int sizeY = (int) ( (maxY - minY) * m_scaleY );
2890  int thumbY = (int) ( ( maxY - (m_posY - topMargin) ) * m_scaleY );
2891  SetScrollbar( wxVERTICAL, thumbY, cy - (m_marginTop + m_marginBottom), sizeY );
2892  }
2893  }
2894  }
2895 
2896  Refresh( false );
2897 }
int m_marginRight
Definition: mathplot.h:1519
bool m_enableScrollBars
Definition: mathplot.h:1530
int m_marginLeft
Definition: mathplot.h:1519
double m_desiredXmax
Definition: mathplot.h:1517
double m_scaleY
Definition: mathplot.h:1506
double m_posX
Definition: mathplot.h:1507
double m_minY
Definition: mathplot.h:1503
double m_scaleX
Definition: mathplot.h:1505
double m_desiredYmax
Definition: mathplot.h:1517
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:1517
double m_posY
Definition: mathplot.h:1508
int m_marginTop
Definition: mathplot.h:1519
double m_minX
Definition: mathplot.h:1501
double m_desiredYmin
Definition: mathplot.h:1517
int m_marginBottom
Definition: mathplot.h:1519
virtual bool UpdateBBox()
Recalculate global layer bounding box, and save it in m_minX,...
Definition: mathplot.cpp:2745
double m_maxX
Definition: mathplot.h:1502
double m_maxY
Definition: mathplot.h:1504

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(), SetLayerVisible(), SetMPScrollbars(), SetScaleX(), SIM_PLOT_PANEL::ShowGrid(), SIM_PLOT_PANEL::ShowLegend(), SIM_PLOT_PANEL::SIM_PLOT_PANEL(), 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 2745 of file mathplot.cpp.

2746 {
2747  m_minX = 0.0;
2748  m_maxX = 1.0;
2749  m_minY = 0.0;
2750  m_maxY = 1.0;
2751 
2752  return true;
2753 
2754 #if 0
2755  bool first = true;
2756 
2757  for( wxLayerList::iterator li = m_layers.begin(); li != m_layers.end(); li++ )
2758  {
2759  mpLayer* f = *li;
2760 
2761  if( f->HasBBox() )
2762  {
2763  if( first )
2764  {
2765  first = false;
2766  m_minX = f->GetMinX(); m_maxX = f->GetMaxX();
2767  m_minY = f->GetMinY(); m_maxY = f->GetMaxY();
2768  }
2769  else
2770  {
2771  if( f->GetMinX()<m_minX )
2772  m_minX = f->GetMinX();
2773 
2774  if( f->GetMaxX()>m_maxX )
2775  m_maxX = f->GetMaxX();
2776 
2777  if( f->GetMinY()<m_minY )
2778  m_minY = f->GetMinY();
2779 
2780  if( f->GetMaxY()>m_maxY )
2781  m_maxY = f->GetMaxY();
2782  }
2783  }
2784 
2785  // node = node->GetNext();
2786  }
2787 
2788 #ifdef MATHPLOT_DO_LOGGING
2789  wxLogDebug( wxT(
2790  "[mpWindow::UpdateBBox] Bounding box: Xmin = %f, Xmax = %f, Ymin = %f, YMax = %f" ), m_minX, m_maxX, m_minY,
2791  m_maxY );
2792 #endif // MATHPLOT_DO_LOGGING
2793 
2794  return first == false;
2795 #endif
2796 }
double m_minY
Definition: mathplot.h:1503
wxLayerList m_layers
Definition: mathplot.h:1493
virtual double GetMaxX()
Get inclusive right border of bounding box.
Definition: mathplot.h:179
virtual double GetMaxY()
Get inclusive top border of bounding box.
Definition: mathplot.h:189
virtual double GetMinX()
Get inclusive left border of bounding box.
Definition: mathplot.h:174
virtual double GetMinY()
Get inclusive bottom border of bounding box.
Definition: mathplot.h:184
double m_minX
Definition: mathplot.h:1501
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:160
double m_maxX
Definition: mathplot.h:1502
double m_maxY
Definition: mathplot.h:1504

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

1195 { return (wxCoord) ( (x - m_posX) * m_scaleX ); }
double m_posX
Definition: mathplot.h:1507
double m_scaleX
Definition: mathplot.h:1505

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

1200 { return (wxCoord) ( (m_posY - y) * m_scaleY ); }
double m_scaleY
Definition: mathplot.h:1506
double m_posY
Definition: mathplot.h:1508

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

2277 {
2278  ZoomIn( centerPoint, zoomIncrementalFactor );
2279 }
void ZoomIn(const wxPoint &centerPoint=wxDefaultPosition)
Zoom into current view and refresh display.
Definition: mathplot.cpp:2276
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:1344

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

2283 {
2284  wxPoint c( centerPoint );
2285 
2286  if( c == wxDefaultPosition )
2287  {
2288  GetClientSize( &m_scrX, &m_scrY );
2289  c.x = (m_scrX - m_marginLeft - m_marginRight) / 2 + m_marginLeft; // c.x = m_scrX/2;
2290  c.y = (m_scrY - m_marginTop - m_marginBottom) / 2 - m_marginTop; // c.y = m_scrY/2;
2291  }
2292  else
2293  {
2294  c.x = std::max( c.x, m_marginLeft );
2295  c.x = std::min( c.x, m_scrX - m_marginRight );
2296  c.y = std::max( c.y, m_marginTop );
2297  c.y = std::min( c.y, m_scrY - m_marginBottom );
2298  }
2299 
2300  // Preserve the position of the clicked point:
2301  double prior_layer_x = p2x( c.x );
2302  double prior_layer_y = p2y( c.y );
2303 
2304  // Zoom in:
2305  const double MAX_SCALE = 1e6;
2306  double newScaleX = m_scaleX * zoomFactor;
2307  double newScaleY = m_scaleY * zoomFactor;
2308 
2309  // Baaaaad things happen when you zoom in too much..
2310  if( newScaleX <= MAX_SCALE && newScaleY <= MAX_SCALE )
2311  {
2312  m_scaleX = newScaleX;
2313  m_scaleY = newScaleY;
2314  }
2315  else
2316  {
2317  return;
2318  }
2319 
2320  // Adjust the new m_posx/y:
2321  m_posX = prior_layer_x - c.x / m_scaleX;
2322  m_posY = prior_layer_y + c.y / m_scaleY;
2323 
2325  m_desiredXmax = m_posX + (m_scrX - m_marginLeft - m_marginRight) / m_scaleX; // m_desiredXmax = m_posX + m_scrX / m_scaleX;
2327  m_desiredYmin = m_posY - (m_scrY - m_marginTop - m_marginBottom) / m_scaleY; // m_desiredYmin = m_posY - m_scrY / m_scaleY;
2329 
2330 #ifdef MATHPLOT_DO_LOGGING
2331  wxLogMessage( "mpWindow::ZoomIn() prior coords: (%f,%f), new coords: (%f,%f) SHOULD BE EQUAL!!",
2332  prior_layer_x, prior_layer_y, p2x( c.x ), p2y( c.y ) );
2333 #endif
2334 
2335  UpdateAll();
2336 }
int m_marginRight
Definition: mathplot.h:1519
int m_marginLeft
Definition: mathplot.h:1519
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1185
double m_desiredXmax
Definition: mathplot.h:1517
double m_scaleY
Definition: mathplot.h:1506
double m_posX
Definition: mathplot.h:1507
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1190
double m_scaleX
Definition: mathplot.h:1505
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2853
double m_desiredYmax
Definition: mathplot.h:1517
void AdjustLimitedView()
Definition: mathplot.cpp:2202
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1517
#define MAX_SCALE
double m_posY
Definition: mathplot.h:1508
int m_marginTop
Definition: mathplot.h:1519
double m_desiredYmin
Definition: mathplot.h:1517
#define max(a, b)
Definition: auxiliary.h:86
int m_marginBottom
Definition: mathplot.h:1519
int m_scrY
Definition: mathplot.h:1510
int m_scrX
Definition: mathplot.h:1509
#define min(a, b)
Definition: auxiliary.h:85

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, MAX_SCALE, min, p2x(), p2y(), and UpdateAll().

◆ ZoomInX()

void mpWindow::ZoomInX ( )

Zoom in current view along X and refresh display.

Definition at line 2392 of file mathplot.cpp.

2393 {
2395  UpdateAll();
2396 }
double m_scaleX
Definition: mathplot.h:1505
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2853
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:1344

References m_scaleX, UpdateAll(), and zoomIncrementalFactor.

◆ ZoomInY()

void mpWindow::ZoomInY ( )

Zoom in current view along Y and refresh display.

Definition at line 2406 of file mathplot.cpp.

2407 {
2409  UpdateAll();
2410 }
double m_scaleY
Definition: mathplot.h:1506
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2853
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:1344

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

2340 {
2341  ZoomOut( centerPoint, zoomIncrementalFactor );
2342 }
void ZoomOut(const wxPoint &centerPoint=wxDefaultPosition)
Zoom out current view and refresh display.
Definition: mathplot.cpp:2339
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:1344

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

2346 {
2347  wxPoint c( centerPoint );
2348 
2349  if( c == wxDefaultPosition )
2350  {
2351  GetClientSize( &m_scrX, &m_scrY );
2352  c.x = (m_scrX - m_marginLeft - m_marginRight) / 2 + m_marginLeft; // c.x = m_scrX/2;
2353  c.y = (m_scrY - m_marginTop - m_marginBottom) / 2 - m_marginTop; // c.y = m_scrY/2;
2354  }
2355 
2356  // Preserve the position of the clicked point:
2357  double prior_layer_x = p2x( c.x );
2358  double prior_layer_y = p2y( c.y );
2359 
2360  // Zoom out:
2361  m_scaleX = m_scaleX / zoomFactor;
2362  m_scaleY = m_scaleY / zoomFactor;
2363 
2364  // Adjust the new m_posx/y:
2365  m_posX = prior_layer_x - c.x / m_scaleX;
2366  m_posY = prior_layer_y + c.y / m_scaleY;
2367 
2369  m_desiredXmax = m_posX + (m_scrX - m_marginLeft - m_marginRight) / m_scaleX; // m_desiredXmax = m_posX + m_scrX / m_scaleX;
2371  m_desiredYmin = m_posY - (m_scrY - m_marginTop - m_marginBottom) / m_scaleY; // m_desiredYmin = m_posY - m_scrY / m_scaleY;
2372 
2373  // printf("desired xmin %.1f ymin %.1f xmax %.1f ymax %.1f l %d\n", m_desiredXmin, m_desiredYmin, m_desiredXmax, m_desiredYmax, !!m_enableLimitedView);
2374  // printf("current xmin %.1f ymin %.1f xmax %.1f ymax %.1f\n", m_minX, m_minY, m_maxX, m_maxY);
2375 
2378  {
2379  // printf("call fit()\n");
2380  Fit();
2381  }
2382 
2383 #ifdef MATHPLOT_DO_LOGGING
2384  wxLogMessage(
2385  "mpWindow::ZoomOut() prior coords: (%f,%f), new coords: (%f,%f) SHOULD BE EQUAL!!",
2386  prior_layer_x, prior_layer_y, p2x( c.x ), p2y( c.y ) );
2387 #endif
2388  UpdateAll();
2389 }
int m_marginRight
Definition: mathplot.h:1519
int m_marginLeft
Definition: mathplot.h:1519
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1185
double m_desiredXmax
Definition: mathplot.h:1517
double m_scaleY
Definition: mathplot.h:1506
double m_posX
Definition: mathplot.h:1507
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1190
double m_scaleX
Definition: mathplot.h:1505
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2853
double m_desiredYmax
Definition: mathplot.h:1517
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1517
bool CheckYLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1468
double m_posY
Definition: mathplot.h:1508
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:2031
int m_marginTop
Definition: mathplot.h:1519
double m_desiredYmin
Definition: mathplot.h:1517
int m_marginBottom
Definition: mathplot.h:1519
int m_scrY
Definition: mathplot.h:1510
bool CheckXLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1461
int m_scrX
Definition: mathplot.h:1509

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(), and UpdateAll().

◆ ZoomOutX()

void mpWindow::ZoomOutX ( )

Zoom out current view along X and refresh display.

Definition at line 2399 of file mathplot.cpp.

2400 {
2402  UpdateAll();
2403 }
double m_scaleX
Definition: mathplot.h:1505
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2853
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:1344

References m_scaleX, UpdateAll(), and zoomIncrementalFactor.

◆ ZoomOutY()

void mpWindow::ZoomOutY ( )

Zoom out current view along Y and refresh display.

Definition at line 2413 of file mathplot.cpp.

2414 {
2416  UpdateAll();
2417 }
double m_scaleY
Definition: mathplot.h:1506
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2853
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:1344

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

2421 {
2422  // Compute the 2 corners in graph coordinates:
2423  double p0x = p2x( p0.x );
2424  double p0y = p2y( p0.y );
2425  double p1x = p2x( p1.x );
2426  double p1y = p2y( p1.y );
2427 
2428  // Order them:
2429  double zoom_x_min = p0x<p1x ? p0x : p1x;
2430  double zoom_x_max = p0x>p1x ? p0x : p1x;
2431  double zoom_y_min = p0y<p1y ? p0y : p1y;
2432  double zoom_y_max = p0y>p1y ? p0y : p1y;
2433 
2434 #ifdef MATHPLOT_DO_LOGGING
2435  wxLogMessage( "Zoom: (%f,%f)-(%f,%f)", zoom_x_min, zoom_y_min, zoom_x_max, zoom_y_max );
2436 #endif
2437 
2438  Fit( zoom_x_min, zoom_x_max, zoom_y_min, zoom_y_max );
2440 }
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1185
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1190
void AdjustLimitedView()
Definition: mathplot.cpp:2202
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:2031

References AdjustLimitedView(), Fit(), p2x(), and p2y().

Referenced by OnMouseLeftRelease().

Member Data Documentation

◆ m_axColour

wxColour mpWindow::m_axColour
protected

Definition at line 1499 of file mathplot.h.

Referenced by SetColourTheme().

◆ m_bgColour

wxColour mpWindow::m_bgColour
protected

Definition at line 1497 of file mathplot.h.

Referenced by SetColourTheme().

◆ m_buff_bmp

wxBitmap* mpWindow::m_buff_bmp
protected

Definition at line 1523 of file mathplot.h.

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

◆ m_buff_dc

wxMemoryDC mpWindow::m_buff_dc
protected

Definition at line 1522 of file mathplot.h.

Referenced by OnPaint().

◆ m_clickedX

int mpWindow::m_clickedX
protected

Definition at line 1511 of file mathplot.h.

Referenced by OnCenter(), and OnShowPopupMenu().

◆ m_clickedY

int mpWindow::m_clickedY
protected

Definition at line 1512 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 1517 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 1524 of file mathplot.h.

Referenced by OnPaint().

◆ m_enableLimitedView

bool mpWindow::m_enableLimitedView
protected

Definition at line 1527 of file mathplot.h.

Referenced by AdjustLimitedView().

◆ m_enableMouseNavigation

bool mpWindow::m_enableMouseNavigation
protected

Definition at line 1525 of file mathplot.h.

Referenced by OnMouseMove(), and OnMouseWheel().

◆ m_enableMouseWheelPan

bool mpWindow::m_enableMouseWheelPan
protected

Definition at line 1526 of file mathplot.h.

Referenced by OnMouseWheel().

◆ m_enableScrollBars

bool mpWindow::m_enableScrollBars
protected

Definition at line 1530 of file mathplot.h.

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

◆ m_fgColour

wxColour mpWindow::m_fgColour
protected

Definition at line 1498 of file mathplot.h.

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

◆ m_last_lx

int mpWindow::m_last_lx
protected

Definition at line 1521 of file mathplot.h.

Referenced by OnPaint().

◆ m_last_ly

int mpWindow::m_last_ly
protected

Definition at line 1521 of file mathplot.h.

Referenced by OnPaint().

◆ m_layers

◆ m_lockaspect

bool mpWindow::m_lockaspect
protected

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

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

◆ m_mouseMClick

wxPoint mpWindow::m_mouseMClick
protected

Definition at line 1528 of file mathplot.h.

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

◆ m_movingInfoLayer

mpInfoLayer* mpWindow::m_movingInfoLayer
protected

Definition at line 1532 of file mathplot.h.

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

◆ m_popmenu

wxMenu mpWindow::m_popmenu
protected

Definition at line 1494 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 1531 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 1533 of file mathplot.h.

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

◆ m_zoomRect

wxRect mpWindow::m_zoomRect
protected

Definition at line 1534 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 1344 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: