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 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 ZoomOut (const wxPoint &centerPoint=wxDefaultPosition)
 Zoom out current view and refresh display. More...
 
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.5
 This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse wheel. More...
 

Protected Member Functions

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 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_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::mpWindow ( )
inline

Definition at line 1046 of file mathplot.h.

References mpWindow.

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

Definition at line 1814 of file mathplot.cpp.

1815 {
1816  // Free all the layers:
1817  DelAllLayers( true, false );
1818 
1819  if( m_buff_bmp )
1820  {
1821  delete m_buff_bmp;
1822  m_buff_bmp = NULL;
1823  }
1824 }
void DelAllLayers(bool alsoDeleteObject, bool refreshDisplay=true)
Remove all layers from the plot.
Definition: mathplot.cpp:2537
wxBitmap * m_buff_bmp
Definition: mathplot.h:1503

Member Function Documentation

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

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

2494 {
2495  if( layer != NULL )
2496  {
2497  m_layers.push_back( layer );
2498 
2499  if( refreshDisplay )
2500  UpdateAll();
2501 
2502  return true;
2503  }
2504 
2505  ;
2506  return false;
2507 }
wxLayerList m_layers
Definition: mathplot.h:1474
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2841
void mpWindow::AdjustLimitedView ( )
protected

Definition at line 2204 of file mathplot.cpp.

2205 {
2206  if( !m_enableLimitedView )
2207  return;
2208 
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:1499
int m_marginLeft
Definition: mathplot.h:1499
double m_desiredXmax
Definition: mathplot.h:1497
double m_scaleY
Definition: mathplot.h:1487
double m_posX
Definition: mathplot.h:1488
double m_minY
Definition: mathplot.h:1484
double m_scaleX
Definition: mathplot.h:1486
double m_desiredYmax
Definition: mathplot.h:1497
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1497
double m_posY
Definition: mathplot.h:1489
int m_marginTop
Definition: mathplot.h:1499
double m_minX
Definition: mathplot.h:1482
double m_desiredYmin
Definition: mathplot.h:1497
int m_marginBottom
Definition: mathplot.h:1499
bool m_enableLimitedView
Definition: mathplot.h:1506
double m_maxX
Definition: mathplot.h:1483
double m_maxY
Definition: mathplot.h:1485
bool mpWindow::CheckXLimits ( double &  desiredMax,
double &  desiredMin 
) const
inlineprotected

Definition at line 1442 of file mathplot.h.

1443  {
1444  return !( m_enableLimitedView
1445  && (desiredMax > m_maxX - m_marginRight / m_scaleX
1446  || desiredMin < m_minX - m_marginLeft / m_scaleX) );
1447  }
int m_marginRight
Definition: mathplot.h:1499
int m_marginLeft
Definition: mathplot.h:1499
double m_scaleX
Definition: mathplot.h:1486
double m_minX
Definition: mathplot.h:1482
bool m_enableLimitedView
Definition: mathplot.h:1506
double m_maxX
Definition: mathplot.h:1483
bool mpWindow::CheckYLimits ( double &  desiredMax,
double &  desiredMin 
) const
inlineprotected

Definition at line 1449 of file mathplot.h.

1450  {
1451  return !( m_enableLimitedView
1452  && (desiredMax > m_maxY + m_marginBottom / m_scaleY
1453  || desiredMin < m_minY + m_marginTop / m_scaleY) );
1454  }
double m_scaleY
Definition: mathplot.h:1487
double m_minY
Definition: mathplot.h:1484
int m_marginTop
Definition: mathplot.h:1499
int m_marginBottom
Definition: mathplot.h:1499
bool m_enableLimitedView
Definition: mathplot.h:1506
double m_maxY
Definition: mathplot.h:1485
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 1276 of file mathplot.h.

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

1276 { return m_layers.size(); };
wxLayerList m_layers
Definition: mathplot.h:1474
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 3024 of file mathplot.cpp.

3025 {
3026  // wxNode *node = m_layers.GetFirst();
3027  unsigned int layerNo = 0;
3028 
3029  for( wxLayerList::iterator li = m_layers.begin(); li != m_layers.end(); li++ ) // while(node)
3030  {
3031  if( (*li)->HasBBox() )
3032  layerNo++;
3033 
3034  // node = node->GetNext();
3035  }
3036 
3037  ;
3038  return layerNo;
3039 }
wxLayerList m_layers
Definition: mathplot.h:1474
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 2537 of file mathplot.cpp.

2538 {
2539  while( m_layers.size()>0 )
2540  {
2541  // Also delete the object?
2542  if( alsoDeleteObject )
2543  delete m_layers[0];
2544 
2545  m_layers.erase( m_layers.begin() ); // this deleted the reference only
2546  }
2547 
2548  if( refreshDisplay )
2549  UpdateAll();
2550 }
wxLayerList m_layers
Definition: mathplot.h:1474
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2841
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 2510 of file mathplot.cpp.

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

2513 {
2514  wxLayerList::iterator layIt;
2515 
2516  for( layIt = m_layers.begin(); layIt != m_layers.end(); layIt++ )
2517  {
2518  if( *layIt == layer )
2519  {
2520  // Also delete the object?
2521  if( alsoDeleteObject )
2522  delete *layIt;
2523 
2524  m_layers.erase( layIt ); // this deleted the reference only
2525 
2526  if( refreshDisplay )
2527  UpdateAll();
2528 
2529  return true;
2530  }
2531  }
2532 
2533  return false;
2534 }
wxLayerList m_layers
Definition: mathplot.h:1474
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2841
void mpWindow::DoScrollCalc ( const int  position,
const int  orientation 
)
protected

Definition at line 2888 of file mathplot.cpp.

2889 {
2890  if( orientation == wxVERTICAL )
2891  {
2892  // Y axis
2893  // Get top margin in coord units
2894  double topMargin = m_marginTop / m_scaleY;
2895  // Calculate maximum Y coord to be shown in the graph
2896  double maxY = m_desiredYmax > m_maxY ? m_desiredYmax : m_maxY;
2897  // Set new position
2898  SetPosY( ( maxY - (position / m_scaleY) ) + topMargin );
2899  }
2900  else
2901  {
2902  // X Axis
2903  // Get left margin in coord units
2904  double leftMargin = m_marginLeft / m_scaleX;
2905  // Calculate minimum X coord to be shown in the graph
2906  double minX = (m_desiredXmin < m_minX) ? m_desiredXmin : m_minX;
2907  // Set new position
2908  SetPosX( ( minX + (position / m_scaleX) ) - leftMargin );
2909  }
2910 }
int m_marginLeft
Definition: mathplot.h:1499
double m_scaleY
Definition: mathplot.h:1487
double m_scaleX
Definition: mathplot.h:1486
void SetPosX(double posX)
Set current view&#39;s X position and refresh display.
Definition: mathplot.h:1162
void SetPosY(double posY)
Set current view&#39;s Y position and refresh display.
Definition: mathplot.h:1167
double m_desiredYmax
Definition: mathplot.h:1497
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1497
int m_marginTop
Definition: mathplot.h:1499
double m_minX
Definition: mathplot.h:1482
double m_maxY
Definition: mathplot.h:1485
void mpWindow::DoZoomInXCalc ( const int  staticXpixel)
protected

Definition at line 2124 of file mathplot.cpp.

2125 {
2126  // Preserve the position of the clicked point:
2127  double staticX = p2x( staticXpixel );
2128 
2129  // Zoom in:
2131  // Adjust the new m_posx
2132  m_posX = staticX - (staticXpixel / m_scaleX);
2133  // Adjust desired
2136 #ifdef MATHPLOT_DO_LOGGING
2137  wxLogMessage(
2138  "mpWindow::DoZoomInXCalc() prior X coord: (%f), new X coord: (%f) SHOULD BE EQUAL!!",
2139  staticX, p2x( staticXpixel ) );
2140 #endif
2141 }
int m_marginRight
Definition: mathplot.h:1499
int m_marginLeft
Definition: mathplot.h:1499
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:1185
double m_desiredXmax
Definition: mathplot.h:1497
double m_posX
Definition: mathplot.h:1488
double m_scaleX
Definition: mathplot.h:1486
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1497
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:1327
int m_scrX
Definition: mathplot.h:1490
void mpWindow::DoZoomInYCalc ( const int  staticYpixel)
protected

Definition at line 2144 of file mathplot.cpp.

2145 {
2146  // Preserve the position of the clicked point:
2147  double staticY = p2y( staticYpixel );
2148 
2149  // Zoom in:
2151  // Adjust the new m_posy:
2152  m_posY = staticY + (staticYpixel / m_scaleY);
2153  // Adjust desired
2156 #ifdef MATHPLOT_DO_LOGGING
2157  wxLogMessage(
2158  "mpWindow::DoZoomInYCalc() prior Y coord: (%f), new Y coord: (%f) SHOULD BE EQUAL!!",
2159  staticY, p2y( staticYpixel ) );
2160 #endif
2161 }
double m_scaleY
Definition: mathplot.h:1487
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:1190
double m_desiredYmax
Definition: mathplot.h:1497
double m_posY
Definition: mathplot.h:1489
int m_marginTop
Definition: mathplot.h:1499
double m_desiredYmin
Definition: mathplot.h:1497
int m_marginBottom
Definition: mathplot.h:1499
int m_scrY
Definition: mathplot.h:1491
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:1327
void mpWindow::DoZoomOutXCalc ( const int  staticXpixel)
protected

Definition at line 2164 of file mathplot.cpp.

2165 {
2166  // Preserve the position of the clicked point:
2167  double staticX = p2x( staticXpixel );
2168 
2169  // Zoom out:
2171  // Adjust the new m_posx/y:
2172  m_posX = staticX - (staticXpixel / m_scaleX);
2173  // Adjust desired
2176 #ifdef MATHPLOT_DO_LOGGING
2177  wxLogMessage(
2178  "mpWindow::DoZoomOutXCalc() prior X coord: (%f), new X coord: (%f) SHOULD BE EQUAL!!",
2179  staticX, p2x( staticXpixel ) );
2180 #endif
2181 }
int m_marginRight
Definition: mathplot.h:1499
int m_marginLeft
Definition: mathplot.h:1499
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:1185
double m_desiredXmax
Definition: mathplot.h:1497
double m_posX
Definition: mathplot.h:1488
double m_scaleX
Definition: mathplot.h:1486
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1497
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:1327
int m_scrX
Definition: mathplot.h:1490
void mpWindow::DoZoomOutYCalc ( const int  staticYpixel)
protected

Definition at line 2184 of file mathplot.cpp.

2185 {
2186  // Preserve the position of the clicked point:
2187  double staticY = p2y( staticYpixel );
2188 
2189  // Zoom out:
2191  // Adjust the new m_posx/y:
2192  m_posY = staticY + (staticYpixel / m_scaleY);
2193  // Adjust desired
2196 #ifdef MATHPLOT_DO_LOGGING
2197  wxLogMessage(
2198  "mpWindow::DoZoomOutYCalc() prior Y coord: (%f), new Y coord: (%f) SHOULD BE EQUAL!!",
2199  staticY, p2y( staticYpixel ) );
2200 #endif
2201 }
double m_scaleY
Definition: mathplot.h:1487
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:1190
double m_desiredYmax
Definition: mathplot.h:1497
double m_posY
Definition: mathplot.h:1489
int m_marginTop
Definition: mathplot.h:1499
double m_desiredYmin
Definition: mathplot.h:1497
int m_marginBottom
Definition: mathplot.h:1499
int m_scrY
Definition: mathplot.h:1491
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:1327
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.

Referenced by SIM_PLOT_PANEL::SIM_PLOT_PANEL().

1205 { m_enableDoubleBuffer = enabled; }
bool m_enableDoubleBuffer
Definition: mathplot.h:1504
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:1505
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 2033 of file mathplot.cpp.

Referenced by SIM_PLOT_FRAME::menuZoomFit(), mpPrintout::OnPrintPage(), and SIM_PLOT_FRAME::removePlot().

2034 {
2035  if( UpdateBBox() )
2036  Fit( m_minX, m_maxX, m_minY, m_maxY );
2037 }
double m_minY
Definition: mathplot.h:1484
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:2033
double m_minX
Definition: mathplot.h:1482
virtual bool UpdateBBox()
Recalculate global layer bounding box, and save it in m_minX,...
Definition: mathplot.cpp:2733
double m_maxX
Definition: mathplot.h:1483
double m_maxY
Definition: mathplot.h:1485
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 2041 of file mathplot.cpp.

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

Get axes draw colour.

Returns
reference to axis colour used in theme

Definition at line 1401 of file mathplot.h.

Referenced by mpPrintout::OnPrintPage().

1401 { return m_axColour; };
wxColour m_axColour
Definition: mathplot.h:1480
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 3062 of file mathplot.cpp.

3063 {
3064  bbox[0] = m_minX;
3065  bbox[1] = m_maxX;
3066  bbox[2] = m_minY;
3067  bbox[3] = m_maxY;
3068 }
double m_minY
Definition: mathplot.h:1484
double m_minX
Definition: mathplot.h:1482
double m_maxX
Definition: mathplot.h:1483
double m_maxY
Definition: mathplot.h:1485
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 1293 of file mathplot.h.

Referenced by mpPrintout::OnPrintPage().

1293 { return m_desiredXmax; }
double m_desiredXmax
Definition: mathplot.h:1497
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 1288 of file mathplot.h.

Referenced by mpPrintout::OnPrintPage().

1288 { 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:1497
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 1303 of file mathplot.h.

Referenced by mpPrintout::OnPrintPage().

1303 { return m_desiredYmax; }
double m_desiredYmax
Definition: mathplot.h:1497
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 1298 of file mathplot.h.

Referenced by mpPrintout::OnPrintPage().

1298 { return m_desiredYmin; }
double m_desiredYmin
Definition: mathplot.h:1497
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 3042 of file mathplot.cpp.

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

3043 {
3044  if( ( position >= (int) m_layers.size() ) || position < 0 )
3045  return NULL;
3046 
3047  return m_layers[position];
3048 }
wxLayerList m_layers
Definition: mathplot.h:1474
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 3051 of file mathplot.cpp.

3052 {
3053  for( wxLayerList::iterator it = m_layers.begin(); it!=m_layers.end(); it++ )
3054  if( !(*it)->GetName().Cmp( name ) )
3055  return *it;
3056 
3057 
3058  return NULL; // Not found
3059 }
wxLayerList m_layers
Definition: mathplot.h:1474
const char * name
Definition: DXF_plotter.cpp:61
int mpWindow::GetMarginBottom ( )
inline
int mpWindow::GetMarginLeft ( )
inline
int mpWindow::GetMarginRight ( )
inline
int mpWindow::GetMarginTop ( )
inline
bool mpWindow::GetMPScrollbars ( )
inline

Get scrollbars status.

Returns
true if scrollbars are visible

Definition at line 1315 of file mathplot.h.

1315 { return m_enableScrollBars; };
bool m_enableScrollBars
Definition: mathplot.h:1509
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.

References GetLayer(), and name.

1056 { return &m_popmenu; }
wxMenu m_popmenu
Definition: mathplot.h:1475
double mpWindow::GetPosX ( void  ) const
inline

Definition at line 1116 of file mathplot.h.

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

1116 { return m_posX; }
double m_posX
Definition: mathplot.h:1488
double mpWindow::GetPosY ( void  ) const
inline

Definition at line 1123 of file mathplot.h.

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

1123 { return m_posY; }
double m_posY
Definition: mathplot.h:1489
double mpWindow::GetScaleX ( void  ) const
inline

Definition at line 1102 of file mathplot.h.

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

1102 { return m_scaleX; }; // Schaling's method: maybe another method esists with the same name
double m_scaleX
Definition: mathplot.h:1486
double mpWindow::GetScaleY ( void  ) const
inline

Definition at line 1109 of file mathplot.h.

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

1109 { return m_scaleY; } // Schaling's method: maybe another method exists with the same name
double m_scaleY
Definition: mathplot.h:1487
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.

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

1131 { return m_scrX; }
int m_scrX
Definition: mathplot.h:1490
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.

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

1140 { return m_scrY; }
int m_scrY
Definition: mathplot.h:1491
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:1488
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:1486
int mpWindow::GetXScreen ( void  ) const
inline

Definition at line 1132 of file mathplot.h.

Referenced by SIM_PLOT_PANEL::EnableCursor().

1132 { return m_scrX; }
int m_scrX
Definition: mathplot.h:1490
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:1489
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:1487
int mpWindow::GetYScreen ( void  ) const
inline

Definition at line 1141 of file mathplot.h.

1141 { return m_scrY; }
int m_scrY
Definition: mathplot.h:1491
bool mpWindow::IsAspectLocked ( )
inline

Checks whether the X/Y scale aspect is locked.

Return values
TRUELocked
FALSEUnlocked

Definition at line 1222 of file mathplot.h.

1222 { return m_lockaspect; }
bool m_lockaspect
Definition: mathplot.h:1476
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 3137 of file mathplot.cpp.

References mpInfoLayer::Inside().

3138 {
3139  wxLayerList::iterator li;
3140 
3141  for( li = m_layers.begin(); li != m_layers.end(); li++ )
3142  {
3143 #ifdef MATHPLOT_DO_LOGGING
3144  wxLogMessage( "mpWindow::IsInsideInfoLayer() examinining layer = %p", (*li) );
3145 #endif // MATHPLOT_DO_LOGGING
3146 
3147  if( (*li)->IsInfo() )
3148  {
3149  mpInfoLayer* tmpLyr = (mpInfoLayer*) (*li);
3150 #ifdef MATHPLOT_DO_LOGGING
3151  wxLogMessage( "mpWindow::IsInsideInfoLayer() layer = %p", (*li) );
3152 #endif // MATHPLOT_DO_LOGGING
3153 
3154  if( tmpLyr->Inside( point ) )
3155  {
3156  return tmpLyr;
3157  }
3158  }
3159  }
3160 
3161  return NULL;
3162 }
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:1474
Base class to create small rectangular info boxes mpInfoLayer is the base class to create a small rec...
Definition: mathplot.h:334
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 3177 of file mathplot.cpp.

References mpLayer::IsVisible().

3178 {
3179  mpLayer* lx = GetLayerByName( name );
3180 
3181  return (lx) ? lx->IsVisible() : false;
3182 }
bool IsVisible()
Checks whether the layer is visible or not.
Definition: mathplot.h:297
mpLayer * GetLayerByName(const wxString &name)
Definition: mathplot.cpp:3051
const char * name
Definition: DXF_plotter.cpp:61
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 3197 of file mathplot.cpp.

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

3198 {
3199  mpLayer* lx = GetLayer( position );
3200 
3201  return (lx) ? lx->IsVisible() : false;
3202 }
mpLayer * GetLayer(int position)
Definition: mathplot.cpp:3042
bool IsVisible()
Checks whether the layer is visible or not.
Definition: mathplot.h:297
void mpWindow::LimitView ( bool  aEnable)
inline

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

Definition at line 1404 of file mathplot.h.

Referenced by SIM_PLOT_PANEL::SIM_PLOT_PANEL().

1405  {
1406  m_enableLimitedView = aEnable;
1407  }
bool m_enableLimitedView
Definition: mathplot.h:1506
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 2431 of file mathplot.cpp.

References mpID_LOCKASPECT.

2432 {
2433  m_lockaspect = enable;
2434  m_popmenu.Check( mpID_LOCKASPECT, enable );
2435 
2436  // Try to fit again with the new config:
2438 }
double m_desiredXmax
Definition: mathplot.h:1497
double m_desiredYmax
Definition: mathplot.h:1497
bool m_lockaspect
Definition: mathplot.h:1476
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1497
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:2033
double m_desiredYmin
Definition: mathplot.h:1497
wxMenu m_popmenu
Definition: mathplot.h:1475
void mpWindow::OnCenter ( wxCommandEvent &  event)
protected

Definition at line 2461 of file mathplot.cpp.

2462 {
2463  GetClientSize( &m_scrX, &m_scrY );
2464  int centerX = (m_scrX - m_marginLeft - m_marginRight) / 2; // + m_marginLeft; // c.x = m_scrX/2;
2465  int centerY = (m_scrY - m_marginTop - m_marginBottom) / 2; // - m_marginTop; // c.y = m_scrY/2;
2466  SetPos( p2x( m_clickedX - centerX ), p2y( m_clickedY - centerY ) );
2467  // 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);
2468 }
int m_marginRight
Definition: mathplot.h:1499
int m_marginLeft
Definition: mathplot.h:1499
int m_clickedX
Definition: mathplot.h:1492
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:1185
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:1190
int m_marginTop
Definition: mathplot.h:1499
void SetPos(double posX, double posY)
Set current view&#39;s X and Y position and refresh display.
Definition: mathplot.h:1173
int m_clickedY
Definition: mathplot.h:1493
int m_marginBottom
Definition: mathplot.h:1499
int m_scrY
Definition: mathplot.h:1491
int m_scrX
Definition: mathplot.h:1490
void mpWindow::OnFit ( wxCommandEvent &  event)
protected

Definition at line 2455 of file mathplot.cpp.

2456 {
2457  Fit();
2458 }
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:2033
void mpWindow::OnLockAspect ( wxCommandEvent &  event)
protected

Definition at line 2449 of file mathplot.cpp.

2450 {
2452 }
bool m_lockaspect
Definition: mathplot.h:1476
void LockAspect(bool enable=TRUE)
Enable or disable X/Y scale aspect locking for the view.
Definition: mathplot.cpp:2431
void mpWindow::OnMouseLeftDown ( wxMouseEvent &  event)
protected

Definition at line 1980 of file mathplot.cpp.

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

Definition at line 2003 of file mathplot.cpp.

2004 {
2005  wxPoint release( event.GetX(), event.GetY() );
2007 
2008  m_zooming = false;
2009 
2010  if( m_movingInfoLayer != NULL )
2011  {
2013  m_movingInfoLayer = NULL;
2014  }
2015  else
2016  {
2017  if( release != press )
2018  {
2019  ZoomRect( press, release );
2020  } /*else {
2021  * if (m_coordTooltip) {
2022  * wxString toolTipContent;
2023  * toolTipContent.Printf( "X = %f\nY = %f", p2x(event.GetX()), p2y(event.GetY()));
2024  * SetToolTip(toolTipContent);
2025  * }
2026  * } */
2027  }
2028 
2029  event.Skip();
2030 }
bool m_zooming
Definition: mathplot.h:1512
wxPoint m_mouseLClick
Definition: mathplot.h:1508
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:2408
mpInfoLayer * m_movingInfoLayer
Definition: mathplot.h:1511
virtual void UpdateReference()
Updates the rectangle reference point.
Definition: mathplot.cpp:148
void mpWindow::OnMouseMiddleDown ( wxMouseEvent &  event)
protected

Definition at line 1829 of file mathplot.cpp.

1830 {
1831  m_mouseMClick.x = event.GetX();
1832  m_mouseMClick.y = event.GetY();
1833 }
wxPoint m_mouseMClick
Definition: mathplot.h:1507
void mpWindow::OnMouseMove ( wxMouseEvent &  event)
protected

Definition at line 1880 of file mathplot.cpp.

References mpInfoLayer::GetRectangle(), and mpInfoLayer::UpdateInfo().

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

Definition at line 1838 of file mathplot.cpp.

1839 {
1841  {
1842  event.Skip();
1843  return;
1844  }
1845 
1846  // Scroll vertically or horizontally (this is SHIFT is hold down).
1847  int change = -event.GetWheelRotation(); // Opposite direction (More intuitive)!
1848  double changeUnitsX = change / m_scaleX;
1849  double changeUnitsY = change / m_scaleY;
1850 
1851  if( event.m_controlDown )
1852  {
1853  // horizontal scroll
1854  SetXView( m_posX + changeUnitsX, m_desiredXmax + changeUnitsX,
1855  m_desiredXmin + changeUnitsX );
1856  }
1857  else if( event.m_shiftDown )
1858  {
1859  // vertical scroll
1860  SetYView( m_posY - changeUnitsY, m_desiredYmax - changeUnitsY,
1861  m_desiredYmin - changeUnitsY );
1862  }
1863  else
1864  {
1865  // zoom in/out
1866  wxPoint clickPt( event.GetX(), event.GetY() );
1867 
1868  if( event.GetWheelRotation() > 0 )
1869  ZoomIn( clickPt );
1870  else
1871  ZoomOut( clickPt );
1872  }
1873 
1874  UpdateAll();
1875 }
void ZoomOut(const wxPoint &centerPoint=wxDefaultPosition)
Zoom out current view and refresh display.
Definition: mathplot.cpp:2333
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:1497
double m_scaleY
Definition: mathplot.h:1487
bool m_enableMouseNavigation
Definition: mathplot.h:1505
double m_posX
Definition: mathplot.h:1488
double m_scaleX
Definition: mathplot.h:1486
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2841
double m_desiredYmax
Definition: mathplot.h:1497
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:1497
double m_posY
Definition: mathplot.h:1489
double m_desiredYmin
Definition: mathplot.h:1497
virtual bool SetXView(double pos, double desiredMax, double desiredMin)
Applies new X view coordinates depending on the settings.
Definition: mathplot.cpp:2248
void mpWindow::OnPaint ( wxPaintEvent &  event)
protected

Definition at line 2553 of file mathplot.cpp.

Referenced by mpScaleY::Plot().

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

Definition at line 2999 of file mathplot.cpp.

Referenced by mpScaleY::Plot().

3000 {
3001  int scrollOrientation = event.GetOrientation();
3002  // Get thumb size
3003  int thumbSize = GetScrollThumb( scrollOrientation );
3004  // Get scroll range
3005  int scrollRange = GetScrollRange( scrollOrientation );
3006 
3007  DoScrollCalc( scrollRange - thumbSize, scrollOrientation );
3008 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2888
void mpWindow::OnScrollLineDown ( wxScrollWinEvent &  event)
protected

Definition at line 2973 of file mathplot.cpp.

References mpSCROLL_NUM_PIXELS_PER_LINE.

Referenced by mpScaleY::Plot().

2974 {
2975  int scrollOrientation = event.GetOrientation();
2976  // Get position before page up
2977  int position = GetScrollPos( scrollOrientation );
2978  // Get thumb size
2979  int thumbSize = GetScrollThumb( scrollOrientation );
2980  // Get scroll range
2981  int scrollRange = GetScrollRange( scrollOrientation );
2982 
2983  // Need to adjust position by a page
2984  position += mpSCROLL_NUM_PIXELS_PER_LINE;
2985 
2986  if( position > (scrollRange - thumbSize) )
2987  position = scrollRange - thumbSize;
2988 
2989  DoScrollCalc( position, scrollOrientation );
2990 }
#define mpSCROLL_NUM_PIXELS_PER_LINE
Definition: mathplot.cpp:61
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2888
void mpWindow::OnScrollLineUp ( wxScrollWinEvent &  event)
protected

Definition at line 2957 of file mathplot.cpp.

References mpSCROLL_NUM_PIXELS_PER_LINE.

Referenced by mpScaleY::Plot().

2958 {
2959  int scrollOrientation = event.GetOrientation();
2960  // Get position before page up
2961  int position = GetScrollPos( scrollOrientation );
2962 
2963  // Need to adjust position by a line
2964  position -= mpSCROLL_NUM_PIXELS_PER_LINE;
2965 
2966  if( position < 0 )
2967  position = 0;
2968 
2969  DoScrollCalc( position, scrollOrientation );
2970 }
#define mpSCROLL_NUM_PIXELS_PER_LINE
Definition: mathplot.cpp:61
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2888
void mpWindow::OnScrollPageDown ( wxScrollWinEvent &  event)
protected

Definition at line 2937 of file mathplot.cpp.

Referenced by mpScaleY::Plot().

2938 {
2939  int scrollOrientation = event.GetOrientation();
2940  // Get position before page up
2941  int position = GetScrollPos( scrollOrientation );
2942  // Get thumb size
2943  int thumbSize = GetScrollThumb( scrollOrientation );
2944  // Get scroll range
2945  int scrollRange = GetScrollRange( scrollOrientation );
2946 
2947  // Need to adjust position by a page
2948  position += thumbSize;
2949 
2950  if( position > (scrollRange - thumbSize) )
2951  position = scrollRange - thumbSize;
2952 
2953  DoScrollCalc( position, scrollOrientation );
2954 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2888
void mpWindow::OnScrollPageUp ( wxScrollWinEvent &  event)
protected

Definition at line 2919 of file mathplot.cpp.

Referenced by mpScaleY::Plot().

2920 {
2921  int scrollOrientation = event.GetOrientation();
2922  // Get position before page up
2923  int position = GetScrollPos( scrollOrientation );
2924  // Get thumb size
2925  int thumbSize = GetScrollThumb( scrollOrientation );
2926 
2927  // Need to adjust position by a page
2928  position -= thumbSize;
2929 
2930  if( position < 0 )
2931  position = 0;
2932 
2933  DoScrollCalc( position, scrollOrientation );
2934 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2888
void mpWindow::OnScrollThumbTrack ( wxScrollWinEvent &  event)
protected

Definition at line 2913 of file mathplot.cpp.

Referenced by mpScaleY::Plot().

2914 {
2915  DoScrollCalc( event.GetPosition(), event.GetOrientation() );
2916 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2888
void mpWindow::OnScrollTop ( wxScrollWinEvent &  event)
protected

Definition at line 2993 of file mathplot.cpp.

Referenced by mpScaleY::Plot().

2994 {
2995  DoScrollCalc( 0, event.GetOrientation() );
2996 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2888
void mpWindow::OnShowPopupMenu ( wxMouseEvent &  event)
protected

Definition at line 2441 of file mathplot.cpp.

2442 {
2443  m_clickedX = event.GetX();
2444  m_clickedY = event.GetY();
2445  PopupMenu( &m_popmenu, event.GetX(), event.GetY() );
2446 }
int m_clickedX
Definition: mathplot.h:1492
int m_clickedY
Definition: mathplot.h:1493
wxMenu m_popmenu
Definition: mathplot.h:1475
void mpWindow::OnSize ( wxSizeEvent &  event)
protected

Definition at line 2483 of file mathplot.cpp.

Referenced by mpScaleY::Plot().

2484 {
2485  // Try to fit again with the new window size:
2487 #ifdef MATHPLOT_DO_LOGGING
2488  wxLogMessage( "mpWindow::OnSize() m_scrX = %d, m_scrY = %d", m_scrX, m_scrY );
2489 #endif // MATHPLOT_DO_LOGGING
2490 }
double m_desiredXmax
Definition: mathplot.h:1497
double m_desiredYmax
Definition: mathplot.h:1497
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1497
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:2033
double m_desiredYmin
Definition: mathplot.h:1497
int m_scrY
Definition: mathplot.h:1491
int m_scrX
Definition: mathplot.h:1490
void mpWindow::OnZoomIn ( wxCommandEvent &  event)
protected

Definition at line 2471 of file mathplot.cpp.

2472 {
2474 }
wxPoint m_mouseMClick
Definition: mathplot.h:1507
void ZoomIn(const wxPoint &centerPoint=wxDefaultPosition)
Zoom into current view and refresh display.
Definition: mathplot.cpp:2276
void mpWindow::OnZoomOut ( wxCommandEvent &  event)
protected

Definition at line 2477 of file mathplot.cpp.

2478 {
2479  ZoomOut();
2480 }
void ZoomOut(const wxPoint &centerPoint=wxDefaultPosition)
Zoom out current view and refresh display.
Definition: mathplot.cpp:2333
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.

Referenced by mpScaleXBase::getVisibleDataRange(), CURSOR::Plot(), mpFX::Plot(), and mpProfile::Plot().

1185 { return m_posX + pixelCoordX / m_scaleX; }
double m_posX
Definition: mathplot.h:1488
double m_scaleX
Definition: mathplot.h:1486
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.

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

1190 { return m_posY - pixelCoordY / m_scaleY; }
double m_scaleY
Definition: mathplot.h:1487
double m_posY
Definition: mathplot.h:1489
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 3071 of file mathplot.cpp.

Referenced by SIM_PLOT_FRAME::menuSaveImage().

3073 {
3074  int sizeX, sizeY;
3075  int bk_scrX, bk_scrY;
3076 
3077  if( imageSize == wxDefaultSize )
3078  {
3079  sizeX = m_scrX;
3080  sizeY = m_scrY;
3081  }
3082  else
3083  {
3084  sizeX = imageSize.x;
3085  sizeY = imageSize.y;
3086  bk_scrX = m_scrX;
3087  bk_scrY = m_scrY;
3088  SetScr( sizeX, sizeY );
3089  }
3090 
3091  wxBitmap screenBuffer( sizeX, sizeY );
3092  wxMemoryDC screenDC;
3093  screenDC.SelectObject( screenBuffer );
3094  screenDC.SetPen( *wxTRANSPARENT_PEN );
3095  wxBrush brush( GetBackgroundColour() );
3096  screenDC.SetBrush( brush );
3097  screenDC.DrawRectangle( 0, 0, sizeX, sizeY );
3098 
3099  if( fit )
3100  {
3101  Fit( m_minX, m_maxX, m_minY, m_maxY, &sizeX, &sizeY );
3102  }
3103  else
3104  {
3106  }
3107 
3108  // Draw all the layers:
3109  wxLayerList::iterator li;
3110 
3111  for( li = m_layers.begin(); li != m_layers.end(); li++ )
3112  (*li)->Plot( screenDC, *this );
3113 
3114  if( imageSize != wxDefaultSize )
3115  {
3116  // Restore dimensions
3117  SetScr( bk_scrX, bk_scrY );
3118  Fit( m_desiredXmin, m_desiredXmax, m_desiredYmin, m_desiredYmax, &bk_scrX, &bk_scrY );
3119  UpdateAll();
3120  }
3121 
3122  // Once drawing is complete, actually save screen shot
3123  wxImage screenImage = screenBuffer.ConvertToImage();
3124  return screenImage.SaveFile( filename, type );
3125 }
double m_desiredXmax
Definition: mathplot.h:1497
double m_minY
Definition: mathplot.h:1484
wxLayerList m_layers
Definition: mathplot.h:1474
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2841
double m_desiredYmax
Definition: mathplot.h:1497
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1497
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:2033
double m_minX
Definition: mathplot.h:1482
double m_desiredYmin
Definition: mathplot.h:1497
void SetScr(int scrX, int scrY)
Set current view&#39;s dimensions in device context units.
Definition: mathplot.h:1180
int m_scrY
Definition: mathplot.h:1491
double m_maxX
Definition: mathplot.h:1483
int m_scrX
Definition: mathplot.h:1490
double m_maxY
Definition: mathplot.h:1485
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 3205 of file mathplot.cpp.

References mpLAYER_AXIS, and mpLAYER_INFO.

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

3208 {
3209  SetBackgroundColour( bgColour );
3210  SetForegroundColour( drawColour );
3211  m_bgColour = bgColour;
3212  m_fgColour = drawColour;
3213  m_axColour = axesColour;
3214  // cycle between layers to set colours and properties to them
3215  wxLayerList::iterator li;
3216 
3217  for( li = m_layers.begin(); li != m_layers.end(); li++ )
3218  {
3219  if( (*li)->GetLayerType() == mpLAYER_AXIS )
3220  {
3221  wxPen axisPen = (*li)->GetPen(); // Get the old pen to modify only colour, not style or width
3222  axisPen.SetColour( axesColour );
3223  (*li)->SetPen( axisPen );
3224  }
3225 
3226  if( (*li)->GetLayerType() == mpLAYER_INFO )
3227  {
3228  wxPen infoPen = (*li)->GetPen(); // Get the old pen to modify only colour, not style or width
3229  infoPen.SetColour( drawColour );
3230  (*li)->SetPen( infoPen );
3231  }
3232  }
3233 }
wxColour m_axColour
Definition: mathplot.h:1480
wxLayerList m_layers
Definition: mathplot.h:1474
wxColour m_fgColour
Definition: mathplot.h:1479
wxColour m_bgColour
Definition: mathplot.h:1478
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 3165 of file mathplot.cpp.

References mpLayer::SetVisible().

3166 {
3167  mpLayer* lx = GetLayerByName( name );
3168 
3169  if( lx )
3170  {
3171  lx->SetVisible( viewable );
3172  UpdateAll();
3173  }
3174 }
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2841
void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:301
mpLayer * GetLayerByName(const wxString &name)
Definition: mathplot.cpp:3051
const char * name
Definition: DXF_plotter.cpp:61
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 3185 of file mathplot.cpp.

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

3186 {
3187  mpLayer* lx = GetLayer( position );
3188 
3189  if( lx )
3190  {
3191  lx->SetVisible( viewable );
3192  UpdateAll();
3193  }
3194 }
mpLayer * GetLayer(int position)
Definition: mathplot.cpp:3042
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2841
void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:301
void mpWindow::SetMarginBottom ( int  bottom)
inline

Set the bottom margin.

Parameters
bottomBottom Margin

Definition at line 1341 of file mathplot.h.

1341 { m_marginBottom = bottom; };
int m_marginBottom
Definition: mathplot.h:1499
void mpWindow::SetMarginLeft ( int  left)
inline

Set the left margin.

Parameters
leftLeft Margin

Definition at line 1343 of file mathplot.h.

1343 { m_marginLeft = left; };
int m_marginLeft
Definition: mathplot.h:1499
void mpWindow::SetMarginRight ( int  right)
inline

Set the right margin.

Parameters
rightRight Margin

Definition at line 1339 of file mathplot.h.

1339 { m_marginRight = right; };
int m_marginRight
Definition: mathplot.h:1499
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 3128 of file mathplot.cpp.

Referenced by SIM_PLOT_PANEL::SIM_PLOT_PANEL().

3129 {
3130  m_marginTop = top;
3131  m_marginRight = right;
3132  m_marginBottom = bottom;
3133  m_marginLeft = left;
3134 }
int m_marginRight
Definition: mathplot.h:1499
int m_marginLeft
Definition: mathplot.h:1499
int m_marginTop
Definition: mathplot.h:1499
int m_marginBottom
Definition: mathplot.h:1499
void mpWindow::SetMarginTop ( int  top)
inline

Set the top margin.

Parameters
topTop Margin

Definition at line 1337 of file mathplot.h.

1337 { m_marginTop = top; };
int m_marginTop
Definition: mathplot.h:1499
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 2692 of file mathplot.cpp.

2693 {
2694  // Temporary behaviour: always disable scrollbars
2695  m_enableScrollBars = status; // false;
2696 
2697  if( status == false )
2698  {
2699  SetScrollbar( wxHORIZONTAL, 0, 0, 0 );
2700  SetScrollbar( wxVERTICAL, 0, 0, 0 );
2701  }
2702 
2703  // else the scroll bars will be updated in UpdateAll();
2704  UpdateAll();
2705 
2706  // EnableScrolling(false, false);
2707  // m_enableScrollBars = status;
2708  // EnableScrolling(status, status);
2709  /* m_scroll.x = (int) floor((m_posX - m_minX)*m_scaleX);
2710  * m_scroll.y = (int) floor((m_posY - m_minY)*m_scaleY);*/
2711  // int scrollWidth = (int) floor((m_maxX - m_minX)*m_scaleX) - m_scrX;
2712  // int scrollHeight = (int) floor((m_minY - m_maxY)*m_scaleY) - m_scrY;
2713 
2715  // m_scroll.y = (int) floor((m_maxY - m_posY /*- m_minY*/)*m_scaleY);
2716  // int scrollWidth = (int) floor(((m_maxX - m_minX) - (m_desiredXmax - m_desiredXmin))*m_scaleX);
2717  // int scrollHeight = (int) floor(((m_maxY - m_minY) - (m_desiredYmax - m_desiredYmin))*m_scaleY);
2718  // #ifdef MATHPLOT_DO_LOGGING
2719  // wxLogMessage( "mpWindow::SetMPScrollbars() scrollWidth = %d, scrollHeight = %d", scrollWidth, scrollHeight);
2720  // #endif
2721  // if(status) {
2722  // SetScrollbars(1,
2723  // 1,
2724  // scrollWidth,
2725  // scrollHeight,
2726  // m_scroll.x,
2727  // m_scroll.y);
2729  // }
2730  // Refresh(false);*/
2731 }
bool m_enableScrollBars
Definition: mathplot.h:1509
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2841
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:1488
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2841
double m_posY
Definition: mathplot.h:1489
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:1488
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2841
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:2841
double m_posY
Definition: mathplot.h:1489
void mpWindow::SetScaleX ( double  scaleX)

Set current view's X scale and refresh display.

Parameters
scaleXNew scale, must not be 0.

Definition at line 3013 of file mathplot.cpp.

3014 {
3015  if( scaleX!=0 )
3016  m_scaleX = scaleX;
3017 
3018  UpdateAll();
3019 }
double m_scaleX
Definition: mathplot.h:1486
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2841
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:1487
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2841
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:1491
int m_scrX
Definition: mathplot.h:1490
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:1497
double m_posX
Definition: mathplot.h:1488
void AdjustLimitedView()
Definition: mathplot.cpp:2204
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1497
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:1497
void AdjustLimitedView()
Definition: mathplot.cpp:2204
double m_posY
Definition: mathplot.h:1489
double m_desiredYmin
Definition: mathplot.h:1497
void mpWindow::UpdateAll ( )

Refresh display.

Definition at line 2841 of file mathplot.cpp.

References Refresh().

Referenced by SIM_PLOT_PANEL::AddTrace(), mpPrintout::OnPrintPage(), SIM_PLOT_FRAME::onSimFinished(), and SIM_PLOT_PANEL::SIM_PLOT_PANEL().

2842 {
2843  if( UpdateBBox() )
2844  {
2845  if( m_enableScrollBars )
2846  {
2847  int cx, cy;
2848  GetClientSize( &cx, &cy );
2849  // Do x scroll bar
2850  {
2851  // Convert margin sizes from pixels to coordinates
2852  double leftMargin = m_marginLeft / m_scaleX;
2853  // Calculate the range in coords that we want to scroll over
2854  double maxX = (m_desiredXmax > m_maxX) ? m_desiredXmax : m_maxX;
2855  double minX = (m_desiredXmin < m_minX) ? m_desiredXmin : m_minX;
2856 
2857  if( (m_posX + leftMargin) < minX )
2858  minX = m_posX + leftMargin;
2859 
2860  // Calculate scroll bar size and thumb position
2861  int sizeX = (int) ( (maxX - minX) * m_scaleX );
2862  int thumbX = (int) ( ( (m_posX + leftMargin) - minX ) * m_scaleX );
2863  SetScrollbar( wxHORIZONTAL, thumbX, cx - (m_marginRight + m_marginLeft), sizeX );
2864  }
2865  // Do y scroll bar
2866  {
2867  // Convert margin sizes from pixels to coordinates
2868  double topMargin = m_marginTop / m_scaleY;
2869  // Calculate the range in coords that we want to scroll over
2870  double maxY = (m_desiredYmax > m_maxY) ? m_desiredYmax : m_maxY;
2871 
2872  if( (m_posY - topMargin) > maxY )
2873  maxY = m_posY - topMargin;
2874 
2875  double minY = (m_desiredYmin < m_minY) ? m_desiredYmin : m_minY;
2876  // Calculate scroll bar size and thumb position
2877  int sizeY = (int) ( (maxY - minY) * m_scaleY );
2878  int thumbY = (int) ( ( maxY - (m_posY - topMargin) ) * m_scaleY );
2879  SetScrollbar( wxVERTICAL, thumbY, cy - (m_marginTop + m_marginBottom), sizeY );
2880  }
2881  }
2882  }
2883 
2884  Refresh( false );
2885 }
int m_marginRight
Definition: mathplot.h:1499
bool m_enableScrollBars
Definition: mathplot.h:1509
int m_marginLeft
Definition: mathplot.h:1499
double m_desiredXmax
Definition: mathplot.h:1497
double m_scaleY
Definition: mathplot.h:1487
double m_posX
Definition: mathplot.h:1488
double m_minY
Definition: mathplot.h:1484
double m_scaleX
Definition: mathplot.h:1486
double m_desiredYmax
Definition: mathplot.h:1497
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:1497
double m_posY
Definition: mathplot.h:1489
int m_marginTop
Definition: mathplot.h:1499
double m_minX
Definition: mathplot.h:1482
double m_desiredYmin
Definition: mathplot.h:1497
int m_marginBottom
Definition: mathplot.h:1499
virtual bool UpdateBBox()
Recalculate global layer bounding box, and save it in m_minX,...
Definition: mathplot.cpp:2733
double m_maxX
Definition: mathplot.h:1483
double m_maxY
Definition: mathplot.h:1485
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 2733 of file mathplot.cpp.

References mpLayer::GetMaxX(), mpLayer::GetMaxY(), mpLayer::GetMinX(), mpLayer::GetMinY(), and mpLayer::HasBBox().

2734 {
2735  m_minX = 0.0;
2736  m_maxX = 1.0;
2737  m_minY = 0.0;
2738  m_maxY = 1.0;
2739 
2740  return true;
2741 
2742 #if 0
2743  bool first = true;
2744 
2745  for( wxLayerList::iterator li = m_layers.begin(); li != m_layers.end(); li++ )
2746  {
2747  mpLayer* f = *li;
2748 
2749  if( f->HasBBox() )
2750  {
2751  if( first )
2752  {
2753  first = false;
2754  m_minX = f->GetMinX(); m_maxX = f->GetMaxX();
2755  m_minY = f->GetMinY(); m_maxY = f->GetMaxY();
2756  }
2757  else
2758  {
2759  if( f->GetMinX()<m_minX )
2760  m_minX = f->GetMinX();
2761 
2762  if( f->GetMaxX()>m_maxX )
2763  m_maxX = f->GetMaxX();
2764 
2765  if( f->GetMinY()<m_minY )
2766  m_minY = f->GetMinY();
2767 
2768  if( f->GetMaxY()>m_maxY )
2769  m_maxY = f->GetMaxY();
2770  }
2771  }
2772 
2773  // node = node->GetNext();
2774  }
2775 
2776 #ifdef MATHPLOT_DO_LOGGING
2777  wxLogDebug( wxT(
2778  "[mpWindow::UpdateBBox] Bounding box: Xmin = %f, Xmax = %f, Ymin = %f, YMax = %f" ), m_minX, m_maxX, m_minY,
2779  m_maxY );
2780 #endif // MATHPLOT_DO_LOGGING
2781 
2782  return first == false;
2783 #endif
2784 }
double m_minY
Definition: mathplot.h:1484
wxLayerList m_layers
Definition: mathplot.h:1474
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:1482
virtual bool HasBBox()
Check whether this layer has a bounding box.
Definition: mathplot.h:160
double m_maxX
Definition: mathplot.h:1483
double m_maxY
Definition: mathplot.h:1485
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.

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

1195 { return (wxCoord) ( (x - m_posX) * m_scaleX ); }
double m_posX
Definition: mathplot.h:1488
double m_scaleX
Definition: mathplot.h:1486
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.

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

1200 { return (wxCoord) ( (m_posY - y) * m_scaleY ); }
double m_scaleY
Definition: mathplot.h:1487
double m_posY
Definition: mathplot.h:1489
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.

References max, MAX_SCALE, min, wxPoint::x, and wxPoint::y.

Referenced by SIM_PLOT_FRAME::menuZoomIn().

2277 {
2278  wxPoint c( centerPoint );
2279 
2280  if( c == wxDefaultPosition )
2281  {
2282  GetClientSize( &m_scrX, &m_scrY );
2283  c.x = (m_scrX - m_marginLeft - m_marginRight) / 2 + m_marginLeft; // c.x = m_scrX/2;
2284  c.y = (m_scrY - m_marginTop - m_marginBottom) / 2 - m_marginTop; // c.y = m_scrY/2;
2285  }
2286  else
2287  {
2288  c.x = std::max( c.x, m_marginLeft );
2289  c.x = std::min( c.x, m_scrX - m_marginRight );
2290  c.y = std::max( c.y, m_marginTop );
2291  c.y = std::min( c.y, m_scrY - m_marginBottom );
2292  }
2293 
2294  // Preserve the position of the clicked point:
2295  double prior_layer_x = p2x( c.x );
2296  double prior_layer_y = p2y( c.y );
2297 
2298  // Zoom in:
2299  const double MAX_SCALE = 1e6;
2300  double newScaleX = m_scaleX * zoomIncrementalFactor;
2301  double newScaleY = m_scaleY * zoomIncrementalFactor;
2302 
2303  // Baaaaad things happen when you zoom in too much..
2304  if( newScaleX <= MAX_SCALE && newScaleY <= MAX_SCALE )
2305  {
2306  m_scaleX = newScaleX;
2307  m_scaleY = newScaleY;
2308  }
2309  else
2310  {
2311  return;
2312  }
2313 
2314  // Adjust the new m_posx/y:
2315  m_posX = prior_layer_x - c.x / m_scaleX;
2316  m_posY = prior_layer_y + c.y / m_scaleY;
2317 
2319  m_desiredXmax = m_posX + (m_scrX - m_marginLeft - m_marginRight) / m_scaleX; // m_desiredXmax = m_posX + m_scrX / m_scaleX;
2321  m_desiredYmin = m_posY - (m_scrY - m_marginTop - m_marginBottom) / m_scaleY; // m_desiredYmin = m_posY - m_scrY / m_scaleY;
2323 
2324 #ifdef MATHPLOT_DO_LOGGING
2325  wxLogMessage( "mpWindow::ZoomIn() prior coords: (%f,%f), new coords: (%f,%f) SHOULD BE EQUAL!!",
2326  prior_layer_x, prior_layer_y, p2x( c.x ), p2y( c.y ) );
2327 #endif
2328 
2329  UpdateAll();
2330 }
int m_marginRight
Definition: mathplot.h:1499
int m_marginLeft
Definition: mathplot.h:1499
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:1185
double m_desiredXmax
Definition: mathplot.h:1497
double m_scaleY
Definition: mathplot.h:1487
double m_posX
Definition: mathplot.h:1488
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:1190
double m_scaleX
Definition: mathplot.h:1486
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2841
double m_desiredYmax
Definition: mathplot.h:1497
void AdjustLimitedView()
Definition: mathplot.cpp:2204
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1497
#define MAX_SCALE
double m_posY
Definition: mathplot.h:1489
int m_marginTop
Definition: mathplot.h:1499
double m_desiredYmin
Definition: mathplot.h:1497
#define max(a, b)
Definition: auxiliary.h:86
int m_marginBottom
Definition: mathplot.h:1499
int m_scrY
Definition: mathplot.h:1491
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:1327
int m_scrX
Definition: mathplot.h:1490
#define min(a, b)
Definition: auxiliary.h:85
void mpWindow::ZoomInX ( )

Zoom in current view along X and refresh display.

Definition at line 2380 of file mathplot.cpp.

2381 {
2383  UpdateAll();
2384 }
double m_scaleX
Definition: mathplot.h:1486
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2841
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:1327
void mpWindow::ZoomInY ( )

Zoom in current view along Y and refresh display.

Definition at line 2394 of file mathplot.cpp.

2395 {
2397  UpdateAll();
2398 }
double m_scaleY
Definition: mathplot.h:1487
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2841
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:1327
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 2333 of file mathplot.cpp.

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

Referenced by SIM_PLOT_FRAME::menuZoomOut().

2334 {
2335  wxPoint c( centerPoint );
2336 
2337  if( c == wxDefaultPosition )
2338  {
2339  GetClientSize( &m_scrX, &m_scrY );
2340  c.x = (m_scrX - m_marginLeft - m_marginRight) / 2 + m_marginLeft; // c.x = m_scrX/2;
2341  c.y = (m_scrY - m_marginTop - m_marginBottom) / 2 - m_marginTop; // c.y = m_scrY/2;
2342  }
2343 
2344  // Preserve the position of the clicked point:
2345  double prior_layer_x = p2x( c.x );
2346  double prior_layer_y = p2y( c.y );
2347 
2348  // Zoom out:
2351 
2352  // Adjust the new m_posx/y:
2353  m_posX = prior_layer_x - c.x / m_scaleX;
2354  m_posY = prior_layer_y + c.y / m_scaleY;
2355 
2357  m_desiredXmax = m_posX + (m_scrX - m_marginLeft - m_marginRight) / m_scaleX; // m_desiredXmax = m_posX + m_scrX / m_scaleX;
2359  m_desiredYmin = m_posY - (m_scrY - m_marginTop - m_marginBottom) / m_scaleY; // m_desiredYmin = m_posY - m_scrY / m_scaleY;
2360 
2361  // printf("desired xmin %.1f ymin %.1f xmax %.1f ymax %.1f l %d\n", m_desiredXmin, m_desiredYmin, m_desiredXmax, m_desiredYmax, !!m_enableLimitedView);
2362  // printf("current xmin %.1f ymin %.1f xmax %.1f ymax %.1f\n", m_minX, m_minY, m_maxX, m_maxY);
2363 
2365  m_desiredXmin ) || !CheckYLimits( m_desiredYmax, m_desiredYmin ) )
2366  {
2367  // printf("call fit()\n");
2368  Fit();
2369  }
2370 
2371 #ifdef MATHPLOT_DO_LOGGING
2372  wxLogMessage(
2373  "mpWindow::ZoomOut() prior coords: (%f,%f), new coords: (%f,%f) SHOULD BE EQUAL!!",
2374  prior_layer_x, prior_layer_y, p2x( c.x ), p2y( c.y ) );
2375 #endif
2376  UpdateAll();
2377 }
int m_marginRight
Definition: mathplot.h:1499
int m_marginLeft
Definition: mathplot.h:1499
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:1185
double m_desiredXmax
Definition: mathplot.h:1497
double m_scaleY
Definition: mathplot.h:1487
double m_posX
Definition: mathplot.h:1488
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:1190
double m_scaleX
Definition: mathplot.h:1486
bool CheckXLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1442
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2841
double m_desiredYmax
Definition: mathplot.h:1497
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1497
double m_posY
Definition: mathplot.h:1489
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:2033
int m_marginTop
Definition: mathplot.h:1499
double m_desiredYmin
Definition: mathplot.h:1497
bool CheckYLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1449
int m_marginBottom
Definition: mathplot.h:1499
int m_scrY
Definition: mathplot.h:1491
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:1327
int m_scrX
Definition: mathplot.h:1490
void mpWindow::ZoomOutX ( )

Zoom out current view along X and refresh display.

Definition at line 2387 of file mathplot.cpp.

2388 {
2390  UpdateAll();
2391 }
double m_scaleX
Definition: mathplot.h:1486
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2841
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:1327
void mpWindow::ZoomOutY ( )

Zoom out current view along Y and refresh display.

Definition at line 2401 of file mathplot.cpp.

2402 {
2404  UpdateAll();
2405 }
double m_scaleY
Definition: mathplot.h:1487
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2841
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:1327
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 2408 of file mathplot.cpp.

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

2409 {
2410  // Compute the 2 corners in graph coordinates:
2411  double p0x = p2x( p0.x );
2412  double p0y = p2y( p0.y );
2413  double p1x = p2x( p1.x );
2414  double p1y = p2y( p1.y );
2415 
2416  // Order them:
2417  double zoom_x_min = p0x<p1x ? p0x : p1x;
2418  double zoom_x_max = p0x>p1x ? p0x : p1x;
2419  double zoom_y_min = p0y<p1y ? p0y : p1y;
2420  double zoom_y_max = p0y>p1y ? p0y : p1y;
2421 
2422 #ifdef MATHPLOT_DO_LOGGING
2423  wxLogMessage( "Zoom: (%f,%f)-(%f,%f)", zoom_x_min, zoom_y_min, zoom_x_max, zoom_y_max );
2424 #endif
2425 
2426  Fit( zoom_x_min, zoom_x_max, zoom_y_min, zoom_y_max );
2428 }
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:1185
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:1190
void AdjustLimitedView()
Definition: mathplot.cpp:2204
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:2033

Member Data Documentation

wxColour mpWindow::m_axColour
protected

Definition at line 1480 of file mathplot.h.

wxColour mpWindow::m_bgColour
protected

Definition at line 1478 of file mathplot.h.

wxBitmap* mpWindow::m_buff_bmp
protected

Definition at line 1503 of file mathplot.h.

wxMemoryDC mpWindow::m_buff_dc
protected

Definition at line 1502 of file mathplot.h.

int mpWindow::m_clickedX
protected

Definition at line 1492 of file mathplot.h.

int mpWindow::m_clickedY
protected

Definition at line 1493 of file mathplot.h.

double mpWindow::m_desiredXmax
protected

Definition at line 1497 of file mathplot.h.

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

double mpWindow::m_desiredYmax
protected

Definition at line 1497 of file mathplot.h.

double mpWindow::m_desiredYmin
protected

Definition at line 1497 of file mathplot.h.

bool mpWindow::m_enableDoubleBuffer
protected

Definition at line 1504 of file mathplot.h.

bool mpWindow::m_enableLimitedView
protected

Definition at line 1506 of file mathplot.h.

bool mpWindow::m_enableMouseNavigation
protected

Definition at line 1505 of file mathplot.h.

bool mpWindow::m_enableScrollBars
protected

Definition at line 1509 of file mathplot.h.

wxColour mpWindow::m_fgColour
protected

Definition at line 1479 of file mathplot.h.

int mpWindow::m_last_lx
protected

Definition at line 1501 of file mathplot.h.

int mpWindow::m_last_ly
protected

Definition at line 1501 of file mathplot.h.

wxLayerList mpWindow::m_layers
protected

Definition at line 1474 of file mathplot.h.

bool mpWindow::m_lockaspect
protected

Definition at line 1476 of file mathplot.h.

int mpWindow::m_marginBottom
protected

Definition at line 1499 of file mathplot.h.

int mpWindow::m_marginLeft
protected

Definition at line 1499 of file mathplot.h.

int mpWindow::m_marginRight
protected

Definition at line 1499 of file mathplot.h.

int mpWindow::m_marginTop
protected

Definition at line 1499 of file mathplot.h.

double mpWindow::m_maxX
protected

Definition at line 1483 of file mathplot.h.

double mpWindow::m_maxY
protected

Definition at line 1485 of file mathplot.h.

double mpWindow::m_minX
protected

Definition at line 1482 of file mathplot.h.

double mpWindow::m_minY
protected

Definition at line 1484 of file mathplot.h.

wxPoint mpWindow::m_mouseLClick
protected

Definition at line 1508 of file mathplot.h.

wxPoint mpWindow::m_mouseMClick
protected

Definition at line 1507 of file mathplot.h.

mpInfoLayer* mpWindow::m_movingInfoLayer
protected

Definition at line 1511 of file mathplot.h.

wxMenu mpWindow::m_popmenu
protected

Definition at line 1475 of file mathplot.h.

double mpWindow::m_posX
protected

Definition at line 1488 of file mathplot.h.

double mpWindow::m_posY
protected

Definition at line 1489 of file mathplot.h.

double mpWindow::m_scaleX
protected

Definition at line 1486 of file mathplot.h.

double mpWindow::m_scaleY
protected

Definition at line 1487 of file mathplot.h.

wxPoint mpWindow::m_scroll
protected

Definition at line 1510 of file mathplot.h.

int mpWindow::m_scrX
protected

Definition at line 1490 of file mathplot.h.

int mpWindow::m_scrY
protected

Definition at line 1491 of file mathplot.h.

bool mpWindow::m_zooming
protected

Definition at line 1512 of file mathplot.h.

wxRect mpWindow::m_zoomRect
protected

Definition at line 1513 of file mathplot.h.

double mpWindow::zoomIncrementalFactor = 1.5
static

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

It must be a number above unity. This number is used for zoom in, and its inverse for zoom out. Set to 1.5 by default.

Definition at line 1327 of file mathplot.h.


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