KiCad PCB EDA Suite
SIM_PLOT_PANEL Class Reference

#include <sim_plot_panel.h>

Inheritance diagram for SIM_PLOT_PANEL:
mpWindow

Public Member Functions

 SIM_PLOT_PANEL (SIM_TYPE aType, wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxPanelNameStr)
 
 ~SIM_PLOT_PANEL ()
 
SIM_TYPE GetType () const
 
wxString GetLabelX () const
 
wxString GetLabelY1 () const
 
wxString GetLabelY2 () const
 
bool AddTrace (const wxString &aName, int aPoints, const double *aX, const double *aY, SIM_PLOT_TYPE aFlags)
 
bool DeleteTrace (const wxString &aName)
 
void DeleteAllTraces ()
 
bool TraceShown (const wxString &aName) const
 
const std::map< wxString, TRACE * > & GetTraces () const
 
TRACEGetTrace (const wxString &aName) const
 
void ShowGrid (bool aEnable)
 
bool IsGridShown () const
 
void ShowLegend (bool aEnable)
 
bool IsLegendShown () const
 
bool HasCursorEnabled (const wxString &aName) const
 

Returns true if the trace has cursor shown.

More...
 
void EnableCursor (const wxString &aName, bool aEnable)
 

Toggles cursor for a particular trace.

More...
 
void ResetScales ()
 

Resets scale ranges to fit the current traces

More...
 
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...
 
void SetLayerVisible (const unsigned int position, bool viewable)
 Sets the visibility of a layer by its position in layer list. More...
 
bool IsLayerVisible (const wxString &name)
 Check whether a layer with given name is visible. 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 Member Functions

static bool IsPlottable (SIM_TYPE aSimType)
 

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
 

Private Member Functions

wxColour generateColor ()
 

Returns a new color from the palette

More...
 

Private Attributes

unsigned int m_colorIdx
 
std::map< wxString, TRACE * > m_traces
 
mpScaleXBasem_axis_x
 
mpScaleYm_axis_y1
 
mpScaleYm_axis_y2
 
mpInfoLegendm_legend
 
std::vector< mpLayer * > m_topLevel
 
const SIM_TYPE m_type
 

Detailed Description

Definition at line 163 of file sim_plot_panel.h.

Constructor & Destructor Documentation

◆ SIM_PLOT_PANEL()

SIM_PLOT_PANEL::SIM_PLOT_PANEL ( SIM_TYPE  aType,
wxWindow *  parent,
wxWindowID  id,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = 0,
const wxString &  name = wxPanelNameStr 
)

Definition at line 364 of file sim_plot_panel.cpp.

366  : mpWindow( parent, id, pos, size, style ), m_colorIdx( 0 ),
367  m_axis_x( nullptr ), m_axis_y1( nullptr ), m_axis_y2( nullptr ), m_type( aType )
368 {
369  LimitView( true );
370  SetMargins( 50, 80, 50, 80 );
371 
372  wxColour grey( 96, 96, 96 );
373  SetColourTheme( *wxBLACK, *wxWHITE, grey );
374  EnableDoubleBuffer( true );
375  UpdateAll();
376 
377  switch( m_type )
378  {
379  case ST_AC:
380  m_axis_x = new FREQUENCY_LOG_SCALE( _( "Frequency" ), mpALIGN_BOTTOM );
381  m_axis_y1 = new GAIN_SCALE( _( "Gain" ), mpALIGN_LEFT );
382  m_axis_y2 = new PHASE_SCALE( _( "Phase" ), mpALIGN_RIGHT );
384  break;
385 
386  case ST_DC:
387  m_axis_x = new VOLTAGE_SCALE_X( _( "Voltage (swept)" ), mpALIGN_BOTTOM );
388  m_axis_y1 = new VOLTAGE_SCALE_Y( _( "Voltage (measured)" ), mpALIGN_LEFT );
389  m_axis_y2 = new CURRENT_SCALE( _( "Current" ), mpALIGN_RIGHT );
390  break;
391 
392  case ST_NOISE:
393  m_axis_x = new FREQUENCY_LOG_SCALE( _( "Frequency" ), mpALIGN_BOTTOM );
394  m_axis_y1 = new mpScaleY( _( "noise [(V or A)^2/Hz]" ), mpALIGN_LEFT );
395  break;
396 
397  case ST_TRANSIENT:
398  m_axis_x = new TIME_SCALE( _( "Time" ), mpALIGN_BOTTOM );
399  m_axis_y1 = new VOLTAGE_SCALE_Y( _( "Voltage" ), mpALIGN_LEFT );
400  m_axis_y2 = new CURRENT_SCALE( _( "Current" ), mpALIGN_RIGHT );
402  break;
403 
404  default:
405  // suppress warnings
406  break;
407  }
408 
409  if( m_axis_x )
410  {
411  m_axis_x->SetTicks( false );
413 
414  AddLayer( m_axis_x );
415  }
416 
417  if( m_axis_y1 )
418  {
419  m_axis_y1->SetTicks( false );
421  AddLayer( m_axis_y1 );
422  }
423 
424  if( m_axis_y2 )
425  {
426  m_axis_y2->SetTicks( false );
428  AddLayer( m_axis_y2 );
429  }
430 
431  m_legend = new mpInfoLegend( wxRect( 0, 40, 200, 40 ), wxTRANSPARENT_BRUSH );
432  m_legend->SetVisible( false );
433  AddLayer( m_legend );
434  m_topLevel.push_back( m_legend );
435  SetColourTheme( *wxBLACK, *wxWHITE, grey );
436 
437  EnableDoubleBuffer( true );
438  UpdateAll();
439 }
#define mpALIGN_LEFT
Aligns label to the left.
Definition: mathplot.h:480
void SetNameAlign(int align)
Definition: mathplot.h:706
mpScaleY * m_axis_y1
mpWindow()
Definition: mathplot.h:1046
const SIM_TYPE m_type
mpScaleXBase * m_axis_x
void SetMasterScale(mpScaleY *masterScale)
Definition: mathplot.h:976
#define mpALIGN_RIGHT
Aligns label to the right.
Definition: mathplot.h:476
bool AddLayer(mpLayer *layer, bool refreshDisplay=true)
Add a plot layer to the canvas.
Definition: mathplot.cpp:2455
void EnableDoubleBuffer(bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=disabled).
Definition: mathplot.h:1205
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2803
unsigned int m_colorIdx
void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:301
std::vector< mpLayer * > m_topLevel
void SetMargins(int top, int right, int bottom, int left)
Set window margins, creating a blank area where some kinds of layers cannot draw.
Definition: mathplot.cpp:3091
class WXDLLIMPEXP_MATHPLOT mpScaleY
Definition: mathplot.h:106
void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour)
Set Color theme.
Definition: mathplot.cpp:3168
mpScaleY * m_axis_y2
void SetTicks(bool enable)
Set X axis ticks or grid.
Definition: mathplot.h:711
#define _(s)
mpInfoLegend * m_legend
void LimitView(bool aEnable)
Limit zooming & panning to the area used by the plots.
Definition: mathplot.h:1404
void SetTicks(bool ticks)
Set Y axis ticks or grid.
Definition: mathplot.h:966
#define mpALIGN_BOTTOM
Aligns label to the bottom.
Definition: mathplot.h:484
Implements the legend to be added to the plot This layer allows you to add a legend to describe the p...
Definition: mathplot.h:436

References _, mpWindow::AddLayer(), mpWindow::EnableDoubleBuffer(), mpWindow::LimitView(), m_axis_x, m_axis_y1, m_axis_y2, m_legend, m_topLevel, m_type, mpALIGN_BOTTOM, mpALIGN_LEFT, mpALIGN_RIGHT, mpScaleY, mpWindow::SetColourTheme(), mpWindow::SetMargins(), mpScaleY::SetMasterScale(), mpScaleBase::SetNameAlign(), mpScaleBase::SetTicks(), mpScaleY::SetTicks(), mpLayer::SetVisible(), ST_AC, ST_DC, ST_NOISE, ST_TRANSIENT, and mpWindow::UpdateAll().

◆ ~SIM_PLOT_PANEL()

SIM_PLOT_PANEL::~SIM_PLOT_PANEL ( )

Definition at line 442 of file sim_plot_panel.cpp.

443 {
444  // ~mpWindow destroys all the added layers, so there is no need to destroy m_traces contents
445 }

Member Function Documentation

◆ AddLayer()

bool mpWindow::AddLayer ( mpLayer layer,
bool  refreshDisplay = true 
)
inherited

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

2456 {
2457  if( layer != NULL )
2458  {
2459  m_layers.push_back( layer );
2460 
2461  if( refreshDisplay )
2462  UpdateAll();
2463 
2464  return true;
2465  }
2466 
2467  ;
2468  return false;
2469 }
wxLayerList m_layers
Definition: mathplot.h:1474
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2803

References mpWindow::m_layers, and mpWindow::UpdateAll().

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

◆ AddTrace()

bool SIM_PLOT_PANEL::AddTrace ( const wxString &  aName,
int  aPoints,
const double *  aX,
const double *  aY,
SIM_PLOT_TYPE  aFlags 
)

Definition at line 463 of file sim_plot_panel.cpp.

465 {
466  TRACE* trace = NULL;
467 
468  // Find previous entry, if there is one
469  auto prev = m_traces.find( aName );
470  bool addedNewEntry = ( prev == m_traces.end() );
471 
472  if( addedNewEntry )
473  {
474  if( m_type == ST_TRANSIENT )
475  {
476  bool hasVoltageTraces = false;
477 
478  for( auto tr : m_traces )
479  {
480  if( !( tr.second->GetFlags() & SPT_CURRENT ) )
481  {
482  hasVoltageTraces = true;
483  break;
484  }
485  }
486 
487  if( !hasVoltageTraces )
488  m_axis_y2->SetMasterScale( nullptr );
489  else
491  }
492 
493  // New entry
494  trace = new TRACE( aName );
495  trace->SetTraceColour( generateColor() );
496  trace->SetPen( wxPen( trace->GetTraceColour(), 2, wxPENSTYLE_SOLID ) );
497  m_traces[aName] = trace;
498 
499  // It is a trick to keep legend & coords always on the top
500  for( mpLayer* l : m_topLevel )
501  DelLayer( l );
502 
503  AddLayer( (mpLayer*) trace );
504 
505  for( mpLayer* l : m_topLevel )
506  AddLayer( l );
507  }
508  else
509  {
510  trace = prev->second;
511  }
512 
513  std::vector<double> tmp( aY, aY + aPoints );
514 
515  if( m_type == ST_AC )
516  {
517  if( aFlags & SPT_AC_PHASE )
518  {
519  for( int i = 0; i < aPoints; i++ )
520  tmp[i] = tmp[i] * 180.0 / M_PI; // convert to degrees
521  }
522  else
523  {
524  for( int i = 0; i < aPoints; i++ )
525  tmp[i] = 20 * log( tmp[i] ) / log( 10.0 ); // convert to dB
526  }
527  }
528 
529  trace->SetData( std::vector<double>( aX, aX + aPoints ), tmp );
530 
531  if( aFlags & SPT_AC_PHASE || aFlags & SPT_CURRENT )
532  trace->SetScale( m_axis_x, m_axis_y2 );
533  else
534  trace->SetScale( m_axis_x, m_axis_y1 );
535 
536  trace->SetFlags( aFlags );
537 
538  UpdateAll();
539 
540  return addedNewEntry;
541 }
mpScaleY * m_axis_y1
const SIM_TYPE m_type
bool DelLayer(mpLayer *layer, bool alsoDeleteObject=false, bool refreshDisplay=true)
Remove a plot layer from the canvas.
Definition: mathplot.cpp:2472
virtual void SetScale(mpScaleBase *scaleX, mpScaleBase *scaleY)
Definition: mathplot.cpp:4044
mpScaleXBase * m_axis_x
wxColour GetTraceColour()
void SetMasterScale(mpScaleY *masterScale)
Definition: mathplot.h:976
bool AddLayer(mpLayer *layer, bool refreshDisplay=true)
Add a plot layer to the canvas.
Definition: mathplot.cpp:2455
void SetPen(wxPen pen)
Set layer pen.
Definition: mathplot.h:276
void SetFlags(int aFlags)
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2803
std::vector< mpLayer * > m_topLevel
std::map< wxString, TRACE * > m_traces
mpScaleY * m_axis_y2
size_t i
Definition: json11.cpp:597
wxColour generateColor()
Returns a new color from the palette
void SetData(const std::vector< double > &aX, const std::vector< double > &aY) override
Assigns new data set for the trace.
void SetTraceColour(wxColour aColour)

References mpWindow::AddLayer(), mpWindow::DelLayer(), generateColor(), TRACE::GetTraceColour(), i, m_axis_x, m_axis_y1, m_axis_y2, m_topLevel, m_traces, m_type, TRACE::SetData(), TRACE::SetFlags(), mpScaleY::SetMasterScale(), mpLayer::SetPen(), mpFXY::SetScale(), TRACE::SetTraceColour(), SPT_AC_PHASE, SPT_CURRENT, ST_AC, ST_TRANSIENT, and mpWindow::UpdateAll().

Referenced by SIM_PLOT_FRAME::updatePlot().

◆ AdjustLimitedView()

void mpWindow::AdjustLimitedView ( )
protectedinherited

Definition at line 2166 of file mathplot.cpp.

2167 {
2168  if( !m_enableLimitedView )
2169  return;
2170 
2171  const double xMin = m_minX - m_marginLeft / m_scaleX;
2172  const double xMax = m_maxX - m_marginRight / m_scaleX;
2173  const double yMin = m_minY + m_marginTop / m_scaleY;
2174  const double yMax = m_maxY + m_marginBottom / m_scaleY;
2175 
2176  if( m_desiredXmin < xMin )
2177  {
2178  double diff = xMin - m_desiredXmin;
2179  m_posX += diff;
2180  m_desiredXmax += diff;
2181  m_desiredXmin = xMin;
2182  }
2183 
2184  if( m_desiredXmax > xMax )
2185  {
2186  double diff = m_desiredXmax - xMax;
2187  m_posX -= diff;
2188  m_desiredXmin -= diff;
2189  m_desiredXmax = xMax;
2190  }
2191 
2192  if( m_desiredYmin < yMin )
2193  {
2194  double diff = yMin - m_desiredYmin;
2195  m_posY += diff;
2196  m_desiredYmax += diff;
2197  m_desiredYmin = yMin;
2198  }
2199 
2200  if( m_desiredYmax > yMax )
2201  {
2202  double diff = m_desiredYmax - yMax;
2203  m_posY -= diff;
2204  m_desiredYmin -= diff;
2205  m_desiredYmax = yMax;
2206  }
2207 }
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

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

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

◆ CheckXLimits()

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

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

Referenced by mpWindow::ZoomOut().

◆ CheckYLimits()

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

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

Referenced by mpWindow::ZoomOut().

◆ CountAllLayers()

unsigned int mpWindow::CountAllLayers ( )
inlineinherited

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.

1276 { return m_layers.size(); };
wxLayerList m_layers
Definition: mathplot.h:1474

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

◆ CountLayers()

unsigned int mpWindow::CountLayers ( )
inherited

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

2987 {
2988  // wxNode *node = m_layers.GetFirst();
2989  unsigned int layerNo = 0;
2990 
2991  for( wxLayerList::iterator li = m_layers.begin(); li != m_layers.end(); li++ ) // while(node)
2992  {
2993  if( (*li)->HasBBox() )
2994  layerNo++;
2995 
2996  // node = node->GetNext();
2997  }
2998 
2999  ;
3000  return layerNo;
3001 }
wxLayerList m_layers
Definition: mathplot.h:1474

References mpWindow::m_layers.

◆ DelAllLayers()

void mpWindow::DelAllLayers ( bool  alsoDeleteObject,
bool  refreshDisplay = true 
)
inherited

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

2500 {
2501  while( m_layers.size()>0 )
2502  {
2503  // Also delete the object?
2504  if( alsoDeleteObject )
2505  delete m_layers[0];
2506 
2507  m_layers.erase( m_layers.begin() ); // this deleted the reference only
2508  }
2509 
2510  if( refreshDisplay )
2511  UpdateAll();
2512 }
wxLayerList m_layers
Definition: mathplot.h:1474
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2803

References mpWindow::m_layers, and mpWindow::UpdateAll().

Referenced by mpWindow::~mpWindow().

◆ DeleteAllTraces()

void SIM_PLOT_PANEL::DeleteAllTraces ( )

Definition at line 566 of file sim_plot_panel.cpp.

567 {
568  for( auto& t : m_traces )
569  {
570  DeleteTrace( t.first );
571  }
572 
573  m_colorIdx = 0;
574  m_traces.clear();
575 }
bool DeleteTrace(const wxString &aName)
unsigned int m_colorIdx
std::map< wxString, TRACE * > m_traces

References DeleteTrace(), m_colorIdx, and m_traces.

◆ DeleteTrace()

bool SIM_PLOT_PANEL::DeleteTrace ( const wxString &  aName)

Definition at line 544 of file sim_plot_panel.cpp.

545 {
546  auto it = m_traces.find( aName );
547 
548  if( it != m_traces.end() )
549  {
550  TRACE* trace = it->second;
551  m_traces.erase( it );
552 
553  if( CURSOR* cursor = trace->GetCursor() )
554  DelLayer( cursor, true );
555 
556  DelLayer( trace, true, true );
557  ResetScales();
558 
559  return true;
560  }
561 
562  return false;
563 }
bool DelLayer(mpLayer *layer, bool alsoDeleteObject=false, bool refreshDisplay=true)
Remove a plot layer from the canvas.
Definition: mathplot.cpp:2472
std::map< wxString, TRACE * > m_traces
void ResetScales()
Resets scale ranges to fit the current traces
CURSOR * GetCursor() const
Cursor attached to a trace to follow its values:

References mpWindow::DelLayer(), TRACE::GetCursor(), m_traces, and ResetScales().

Referenced by DeleteAllTraces(), and SIM_PLOT_FRAME::removePlot().

◆ DelLayer()

bool mpWindow::DelLayer ( mpLayer layer,
bool  alsoDeleteObject = false,
bool  refreshDisplay = true 
)
inherited

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

2475 {
2476  wxLayerList::iterator layIt;
2477 
2478  for( layIt = m_layers.begin(); layIt != m_layers.end(); layIt++ )
2479  {
2480  if( *layIt == layer )
2481  {
2482  // Also delete the object?
2483  if( alsoDeleteObject )
2484  delete *layIt;
2485 
2486  m_layers.erase( layIt ); // this deleted the reference only
2487 
2488  if( refreshDisplay )
2489  UpdateAll();
2490 
2491  return true;
2492  }
2493  }
2494 
2495  return false;
2496 }
wxLayerList m_layers
Definition: mathplot.h:1474
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2803

References mpWindow::m_layers, and mpWindow::UpdateAll().

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

◆ DoScrollCalc()

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

Definition at line 2850 of file mathplot.cpp.

2851 {
2852  if( orientation == wxVERTICAL )
2853  {
2854  // Y axis
2855  // Get top margin in coord units
2856  double topMargin = m_marginTop / m_scaleY;
2857  // Calculate maximum Y coord to be shown in the graph
2858  double maxY = m_desiredYmax > m_maxY ? m_desiredYmax : m_maxY;
2859  // Set new position
2860  SetPosY( ( maxY - (position / m_scaleY) ) + topMargin );
2861  }
2862  else
2863  {
2864  // X Axis
2865  // Get left margin in coord units
2866  double leftMargin = m_marginLeft / m_scaleX;
2867  // Calculate minimum X coord to be shown in the graph
2868  double minX = (m_desiredXmin < m_minX) ? m_desiredXmin : m_minX;
2869  // Set new position
2870  SetPosX( ( minX + (position / m_scaleX) ) - leftMargin );
2871  }
2872 }
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's X position and refresh display.
Definition: mathplot.h:1162
void SetPosY(double posY)
Set current view's Y position and refresh display.
Definition: mathplot.h:1167
double m_desiredYmax
Definition: mathplot.h: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

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

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

◆ DoZoomInXCalc()

void mpWindow::DoZoomInXCalc ( const int  staticXpixel)
protectedinherited

Definition at line 2086 of file mathplot.cpp.

2087 {
2088  // Preserve the position of the clicked point:
2089  double staticX = p2x( staticXpixel );
2090 
2091  // Zoom in:
2093  // Adjust the new m_posx
2094  m_posX = staticX - (staticXpixel / m_scaleX);
2095  // Adjust desired
2098 #ifdef MATHPLOT_DO_LOGGING
2099  wxLogMessage(
2100  "mpWindow::DoZoomInXCalc() prior X coord: (%f), new X coord: (%f) SHOULD BE EQUAL!!",
2101  staticX, p2x( staticXpixel ) );
2102 #endif
2103 }
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,...
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

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

◆ DoZoomInYCalc()

void mpWindow::DoZoomInYCalc ( const int  staticYpixel)
protectedinherited

Definition at line 2106 of file mathplot.cpp.

2107 {
2108  // Preserve the position of the clicked point:
2109  double staticY = p2y( staticYpixel );
2110 
2111  // Zoom in:
2113  // Adjust the new m_posy:
2114  m_posY = staticY + (staticYpixel / m_scaleY);
2115  // Adjust desired
2118 #ifdef MATHPLOT_DO_LOGGING
2119  wxLogMessage(
2120  "mpWindow::DoZoomInYCalc() prior Y coord: (%f), new Y coord: (%f) SHOULD BE EQUAL!!",
2121  staticY, p2y( staticYpixel ) );
2122 #endif
2123 }
double m_scaleY
Definition: mathplot.h:1487
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
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

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

◆ DoZoomOutXCalc()

void mpWindow::DoZoomOutXCalc ( const int  staticXpixel)
protectedinherited

Definition at line 2126 of file mathplot.cpp.

2127 {
2128  // Preserve the position of the clicked point:
2129  double staticX = p2x( staticXpixel );
2130 
2131  // Zoom out:
2133  // Adjust the new m_posx/y:
2134  m_posX = staticX - (staticXpixel / m_scaleX);
2135  // Adjust desired
2138 #ifdef MATHPLOT_DO_LOGGING
2139  wxLogMessage(
2140  "mpWindow::DoZoomOutXCalc() prior X coord: (%f), new X coord: (%f) SHOULD BE EQUAL!!",
2141  staticX, p2x( staticXpixel ) );
2142 #endif
2143 }
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,...
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

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

◆ DoZoomOutYCalc()

void mpWindow::DoZoomOutYCalc ( const int  staticYpixel)
protectedinherited

Definition at line 2146 of file mathplot.cpp.

2147 {
2148  // Preserve the position of the clicked point:
2149  double staticY = p2y( staticYpixel );
2150 
2151  // Zoom out:
2153  // Adjust the new m_posx/y:
2154  m_posY = staticY + (staticYpixel / m_scaleY);
2155  // Adjust desired
2158 #ifdef MATHPLOT_DO_LOGGING
2159  wxLogMessage(
2160  "mpWindow::DoZoomOutYCalc() prior Y coord: (%f), new Y coord: (%f) SHOULD BE EQUAL!!",
2161  staticY, p2y( staticYpixel ) );
2162 #endif
2163 }
double m_scaleY
Definition: mathplot.h:1487
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
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

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

◆ EnableCursor()

void SIM_PLOT_PANEL::EnableCursor ( const wxString &  aName,
bool  aEnable 
)

Toggles cursor for a particular trace.

Definition at line 586 of file sim_plot_panel.cpp.

587 {
588  TRACE* t = GetTrace( aName );
589 
590  if( t == nullptr || t->HasCursor() == aEnable )
591  return;
592 
593  if( aEnable )
594  {
595  CURSOR* c = new CURSOR( t );
596  int plotCenter = GetMarginLeft() + ( GetXScreen() - GetMarginLeft() - GetMarginRight() ) / 2;
597  c->SetX( plotCenter );
598  t->SetCursor( c );
599  AddLayer( c );
600  }
601  else
602  {
603  CURSOR* c = t->GetCursor();
604  t->SetCursor( NULL );
605  DelLayer( c, true );
606  }
607 
608  // Notify the parent window about the changes
609  wxQueueEvent( GetParent(), new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
610 }
bool HasCursor() const
bool DelLayer(mpLayer *layer, bool alsoDeleteObject=false, bool refreshDisplay=true)
Remove a plot layer from the canvas.
Definition: mathplot.cpp:2472
int GetXScreen(void) const
Definition: mathplot.h:1132
bool AddLayer(mpLayer *layer, bool refreshDisplay=true)
Add a plot layer to the canvas.
Definition: mathplot.cpp:2455
TRACE * GetTrace(const wxString &aName) const
int GetMarginRight()
Definition: mathplot.h:1348
int GetMarginLeft()
Definition: mathplot.h:1352
void SetX(int aX)
CURSOR * GetCursor() const
void SetCursor(CURSOR *aCursor)
Cursor attached to a trace to follow its values:

References mpWindow::AddLayer(), mpWindow::DelLayer(), TRACE::GetCursor(), mpWindow::GetMarginLeft(), mpWindow::GetMarginRight(), GetTrace(), mpWindow::GetXScreen(), TRACE::HasCursor(), TRACE::SetCursor(), and CURSOR::SetX().

Referenced by SIM_PLOT_FRAME::SIGNAL_CONTEXT_MENU::onMenuEvent().

◆ EnableDoubleBuffer()

void mpWindow::EnableDoubleBuffer ( bool  enabled)
inlineinherited

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

Definition at line 1205 of file mathplot.h.

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

Referenced by SIM_PLOT_PANEL().

◆ EnableMousePanZoom()

void mpWindow::EnableMousePanZoom ( bool  enabled)
inlineinherited

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

◆ Fit() [1/2]

void mpWindow::Fit ( )
overrideinherited

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

1996 {
1997  if( UpdateBBox() )
1998  Fit( m_minX, m_maxX, m_minY, m_maxY );
1999 }
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:1995
double m_minX
Definition: mathplot.h:1482
virtual bool UpdateBBox()
Recalculate global layer bounding box, and save it in m_minX,...
Definition: mathplot.cpp:2695
double m_maxX
Definition: mathplot.h:1483
double m_maxY
Definition: mathplot.h:1485

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

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

◆ Fit() [2/2]

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

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

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

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

◆ generateColor()

wxColour SIM_PLOT_PANEL::generateColor ( )
private

Returns a new color from the palette

Todo:
have a look at: http://stanford.edu/~mwaskom/software/seaborn/tutorial/color_palettes.html https://github.com/Gnuplotting/gnuplot-palettes
Todo:
generate shades to avoid repeating colors

Definition at line 629 of file sim_plot_panel.cpp.

630 {
634 
635  const unsigned long colors[] = { 0x0000ff, 0x00ff00, 0xff0000, 0x00ffff, 0xff00ff, 0xffff000, 0xffffff };
636 
637  //const unsigned long colors[] = { 0xe3cea6, 0xb4781f, 0x8adfb2, 0x2ca033, 0x999afb, 0x1c1ae3, 0x6fbffd, 0x007fff, 0xd6b2ca, 0x9a3d6a };
638 
639  // hls
640  //const unsigned long colors[] = { 0x0f1689, 0x0f7289, 0x35890f, 0x0f8945, 0x89260f, 0x890f53, 0x89820f, 0x630f89 };
641 
642  // pastels, good for dark background
643  //const unsigned long colors[] = { 0x2fd8fe, 0x628dfa, 0x53d8a6, 0xa5c266, 0xb3b3b3, 0x94c3e4, 0xca9f8d, 0xac680e };
644 
645  const unsigned int colorCount = sizeof(colors) / sizeof(unsigned long);
646 
648  return wxColour( colors[m_colorIdx++ % colorCount] );
649 }
unsigned int m_colorIdx
static VRML_COLOR colors[VRML_COLOR_LAST]

References colors, and m_colorIdx.

Referenced by AddTrace().

◆ GetAxesColour()

const wxColour& mpWindow::GetAxesColour ( )
inlineinherited

Get axes draw colour.

Returns
reference to axis colour used in theme

Definition at line 1401 of file mathplot.h.

1401 { return m_axColour; };
wxColour m_axColour
Definition: mathplot.h:1480

Referenced by mpPrintout::OnPrintPage().

◆ GetBoundingBox()

void mpWindow::GetBoundingBox ( double *  bbox)
inherited

Returns the bounding box coordinates.

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

Definition at line 3024 of file mathplot.cpp.

3025 {
3026  bbox[0] = m_minX;
3027  bbox[1] = m_maxX;
3028  bbox[2] = m_minY;
3029  bbox[3] = m_maxY;
3030 }
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

References mpWindow::m_maxX, mpWindow::m_maxY, mpWindow::m_minX, and mpWindow::m_minY.

◆ GetDesiredXmax()

double mpWindow::GetDesiredXmax ( )
inlineinherited

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.

1293 { return m_desiredXmax; }
double m_desiredXmax
Definition: mathplot.h:1497

Referenced by mpPrintout::OnPrintPage().

◆ GetDesiredXmin()

double mpWindow::GetDesiredXmin ( )
inlineinherited

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.

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

Referenced by mpPrintout::OnPrintPage().

◆ GetDesiredYmax()

double mpWindow::GetDesiredYmax ( )
inlineinherited

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.

1303 { return m_desiredYmax; }
double m_desiredYmax
Definition: mathplot.h:1497

Referenced by mpPrintout::OnPrintPage().

◆ GetDesiredYmin()

double mpWindow::GetDesiredYmin ( )
inlineinherited

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.

1298 { return m_desiredYmin; }
double m_desiredYmin
Definition: mathplot.h:1497

Referenced by mpPrintout::OnPrintPage().

◆ GetLabelX()

wxString SIM_PLOT_PANEL::GetLabelX ( ) const
inline

Definition at line 178 of file sim_plot_panel.h.

179  {
180  return m_axis_x ? m_axis_x->GetName() : "";
181  }
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:237
mpScaleXBase * m_axis_x

References mpLayer::GetName(), and m_axis_x.

Referenced by SIM_PLOT_FRAME::onCursorUpdate().

◆ GetLabelY1()

wxString SIM_PLOT_PANEL::GetLabelY1 ( ) const
inline

Definition at line 183 of file sim_plot_panel.h.

184  {
185  return m_axis_y1 ? m_axis_y1->GetName() : "";
186  }
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:237
mpScaleY * m_axis_y1

References mpLayer::GetName(), and m_axis_y1.

Referenced by SIM_PLOT_FRAME::onCursorUpdate().

◆ GetLabelY2()

wxString SIM_PLOT_PANEL::GetLabelY2 ( ) const
inline

Definition at line 188 of file sim_plot_panel.h.

189  {
190  return m_axis_y2 ? m_axis_y2->GetName() : "";
191  }
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:237
mpScaleY * m_axis_y2

References mpLayer::GetName(), and m_axis_y2.

Referenced by SIM_PLOT_FRAME::onCursorUpdate().

◆ GetLayer()

mpLayer * mpWindow::GetLayer ( int  position)
inherited

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

3005 {
3006  if( ( position >= (int) m_layers.size() ) || position < 0 )
3007  return NULL;
3008 
3009  return m_layers[position];
3010 }
wxLayerList m_layers
Definition: mathplot.h:1474

References mpWindow::m_layers.

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

◆ GetLayerByName()

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

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

3014 {
3015  for( wxLayerList::iterator it = m_layers.begin(); it!=m_layers.end(); it++ )
3016  if( !(*it)->GetName().Cmp( name ) )
3017  return *it;
3018 
3019 
3020  return NULL; // Not found
3021 }
wxLayerList m_layers
Definition: mathplot.h:1474
const char * name
Definition: DXF_plotter.cpp:61

References mpWindow::m_layers, and name.

Referenced by mpWindow::IsLayerVisible(), and mpWindow::SetLayerVisible().

◆ GetMarginBottom()

int mpWindow::GetMarginBottom ( )
inlineinherited

◆ GetMarginLeft()

int mpWindow::GetMarginLeft ( )
inlineinherited

◆ GetMarginRight()

int mpWindow::GetMarginRight ( )
inlineinherited

◆ GetMarginTop()

int mpWindow::GetMarginTop ( )
inlineinherited

◆ GetMPScrollbars()

bool mpWindow::GetMPScrollbars ( )
inlineinherited

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

◆ GetPopupMenu()

wxMenu* mpWindow::GetPopupMenu ( )
inlineinherited

Get reference to context menu of the plot canvas.

Returns
Pointer to menu. The menu can be modified.

Definition at line 1056 of file mathplot.h.

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

◆ GetPosX()

double mpWindow::GetPosX ( void  ) const
inlineinherited

Definition at line 1116 of file mathplot.h.

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

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

◆ GetPosY()

double mpWindow::GetPosY ( void  ) const
inlineinherited

Definition at line 1123 of file mathplot.h.

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

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

◆ GetScaleX()

double mpWindow::GetScaleX ( void  ) const
inlineinherited

Definition at line 1102 of file mathplot.h.

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

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

◆ GetScaleY()

double mpWindow::GetScaleY ( void  ) const
inlineinherited

Definition at line 1109 of file mathplot.h.

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

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

◆ GetScrX()

int mpWindow::GetScrX ( void  ) const
inlineinherited

Get current view's X dimension in device context units.

Usually this is equal to wxDC::GetSize, but it might differ thus mpLayer implementations should rely on the value returned by the function. See rules for coordinate transformation

Returns
X dimension.

Definition at line 1131 of file mathplot.h.

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

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

◆ GetScrY()

int mpWindow::GetScrY ( void  ) const
inlineinherited

Get current view's Y dimension in device context units.

Usually this is equal to wxDC::GetSize, but it might differ thus mpLayer implementations should rely on the value returned by the function. See rules for coordinate transformation

Returns
Y dimension.

Definition at line 1140 of file mathplot.h.

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

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

◆ GetTrace()

TRACE* SIM_PLOT_PANEL::GetTrace ( const wxString &  aName) const
inline

Definition at line 210 of file sim_plot_panel.h.

211  {
212  auto trace = m_traces.find( aName );
213 
214  return trace == m_traces.end() ? NULL : trace->second;
215  }
std::map< wxString, TRACE * > m_traces

References m_traces.

Referenced by EnableCursor(), HasCursorEnabled(), and SIM_PLOT_FRAME::SIGNAL_CONTEXT_MENU::SIGNAL_CONTEXT_MENU().

◆ GetTraces()

const std::map<wxString, TRACE*>& SIM_PLOT_PANEL::GetTraces ( ) const
inline

Definition at line 205 of file sim_plot_panel.h.

206  {
207  return m_traces;
208  }
std::map< wxString, TRACE * > m_traces

References m_traces.

Referenced by SIM_PLOT_FRAME::menuSaveCsv(), and SIM_PLOT_FRAME::onCursorUpdate().

◆ GetType()

SIM_TYPE SIM_PLOT_PANEL::GetType ( ) const
inline

Definition at line 171 of file sim_plot_panel.h.

172  {
173  return m_type;
174  }
const SIM_TYPE m_type

References m_type.

Referenced by SIM_PLOT_FRAME::addPlot(), SIM_PLOT_FRAME::onAddSignal(), SIM_PLOT_FRAME::onSettings(), and SIM_PLOT_FRAME::onSimFinished().

◆ GetXpos()

double mpWindow::GetXpos ( ) const
inlineinherited

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

◆ GetXscl()

double mpWindow::GetXscl ( )
inlineinherited

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

◆ GetXScreen()

int mpWindow::GetXScreen ( void  ) const
inlineinherited

Definition at line 1132 of file mathplot.h.

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

Referenced by EnableCursor().

◆ GetYpos()

double mpWindow::GetYpos ( ) const
inlineinherited

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

◆ GetYscl()

double mpWindow::GetYscl ( ) const
inlineinherited

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

◆ GetYScreen()

int mpWindow::GetYScreen ( void  ) const
inlineinherited

Definition at line 1141 of file mathplot.h.

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

◆ HasCursorEnabled()

bool SIM_PLOT_PANEL::HasCursorEnabled ( const wxString &  aName) const

Returns true if the trace has cursor shown.

Definition at line 578 of file sim_plot_panel.cpp.

579 {
580  TRACE* t = GetTrace( aName );
581 
582  return t ? t->HasCursor() : false;
583 }
bool HasCursor() const
TRACE * GetTrace(const wxString &aName) const

References GetTrace(), and TRACE::HasCursor().

◆ IsAspectLocked()

bool mpWindow::IsAspectLocked ( )
inlineinherited

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

◆ IsGridShown()

bool SIM_PLOT_PANEL::IsGridShown ( ) const
inline

Definition at line 225 of file sim_plot_panel.h.

226  {
227  if( !m_axis_x || !m_axis_y1 )
228  return false;
229 
230  assert( m_axis_x->GetTicks() == m_axis_y1->GetTicks() );
231  return !m_axis_x->GetTicks();
232  }
mpScaleY * m_axis_y1
mpScaleXBase * m_axis_x
bool GetTicks()
Get Y axis ticks or grid.
Definition: mathplot.h:970
bool GetTicks()
Get X axis ticks or grid.
Definition: mathplot.h:716

References mpScaleBase::GetTicks(), mpScaleY::GetTicks(), m_axis_x, and m_axis_y1.

Referenced by SIM_PLOT_FRAME::menuShowGrid(), and SIM_PLOT_FRAME::menuShowGridUpdate().

◆ IsInsideInfoLayer()

mpInfoLayer * mpWindow::IsInsideInfoLayer ( wxPoint &  point)
inherited

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

3101 {
3102  wxLayerList::iterator li;
3103 
3104  for( li = m_layers.begin(); li != m_layers.end(); li++ )
3105  {
3106 #ifdef MATHPLOT_DO_LOGGING
3107  wxLogMessage( "mpWindow::IsInsideInfoLayer() examinining layer = %p", (*li) );
3108 #endif // MATHPLOT_DO_LOGGING
3109 
3110  if( (*li)->IsInfo() )
3111  {
3112  mpInfoLayer* tmpLyr = (mpInfoLayer*) (*li);
3113 #ifdef MATHPLOT_DO_LOGGING
3114  wxLogMessage( "mpWindow::IsInsideInfoLayer() layer = %p", (*li) );
3115 #endif // MATHPLOT_DO_LOGGING
3116 
3117  if( tmpLyr->Inside( point ) )
3118  {
3119  return tmpLyr;
3120  }
3121  }
3122  }
3123 
3124  return NULL;
3125 }
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

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

Referenced by mpWindow::OnMouseLeftDown().

◆ IsLayerVisible() [1/2]

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

Check whether a layer with given name is visible.

Parameters
nameThe layer name
Returns
layer visibility status

Definition at line 3140 of file mathplot.cpp.

3141 {
3142  mpLayer* lx = GetLayerByName( name );
3143 
3144  return (lx) ? lx->IsVisible() : false;
3145 }
bool IsVisible()
Checks whether the layer is visible or not.
Definition: mathplot.h:297
mpLayer * GetLayerByName(const wxString &name)
Definition: mathplot.cpp:3013
const char * name
Definition: DXF_plotter.cpp:61

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

◆ IsLayerVisible() [2/2]

bool mpWindow::IsLayerVisible ( const unsigned int  position)
inherited

Check whether the layer at given position is visible.

Parameters
positionThe layer position in layer list
Returns
layer visibility status

Definition at line 3160 of file mathplot.cpp.

3161 {
3162  mpLayer* lx = GetLayer( position );
3163 
3164  return (lx) ? lx->IsVisible() : false;
3165 }
mpLayer * GetLayer(int position)
Definition: mathplot.cpp:3004
bool IsVisible()
Checks whether the layer is visible or not.
Definition: mathplot.h:297

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

◆ IsLegendShown()

bool SIM_PLOT_PANEL::IsLegendShown ( ) const
inline

Definition at line 240 of file sim_plot_panel.h.

241  {
242  return m_legend->IsVisible();
243  }
bool IsVisible()
Checks whether the layer is visible or not.
Definition: mathplot.h:297
mpInfoLegend * m_legend

References mpLayer::IsVisible(), and m_legend.

Referenced by SIM_PLOT_FRAME::menuShowLegend(), and SIM_PLOT_FRAME::menuShowLegendUpdate().

◆ IsPlottable()

bool SIM_PLOT_PANEL::IsPlottable ( SIM_TYPE  aSimType)
static

Definition at line 448 of file sim_plot_panel.cpp.

449 {
450  switch( aSimType )
451  {
452  case ST_AC:
453  case ST_DC:
454  case ST_TRANSIENT:
455  return true;
456 
457  default:
458  return false;
459  }
460 }

References ST_AC, ST_DC, and ST_TRANSIENT.

Referenced by SIM_PLOT_FRAME::addPlot(), SIM_PLOT_FRAME::menuNewPlot(), SIM_PLOT_FRAME::onSimFinished(), and SIM_PLOT_FRAME::updatePlot().

◆ LimitView()

void mpWindow::LimitView ( bool  aEnable)
inlineinherited

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

Definition at line 1404 of file mathplot.h.

1405  {
1406  m_enableLimitedView = aEnable;
1407  }
bool m_enableLimitedView
Definition: mathplot.h:1506

Referenced by SIM_PLOT_PANEL().

◆ LockAspect()

void mpWindow::LockAspect ( bool  enable = TRUE)
inherited

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

2394 {
2395  m_lockaspect = enable;
2396  m_popmenu.Check( mpID_LOCKASPECT, enable );
2397 
2398  // Try to fit again with the new config:
2400 }
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:1995
double m_desiredYmin
Definition: mathplot.h:1497
wxMenu m_popmenu
Definition: mathplot.h:1475

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

Referenced by mpWindow::OnLockAspect().

◆ OnCenter()

void mpWindow::OnCenter ( wxCommandEvent &  event)
protectedinherited

Definition at line 2423 of file mathplot.cpp.

2424 {
2425  GetClientSize( &m_scrX, &m_scrY );
2426  int centerX = (m_scrX - m_marginLeft - m_marginRight) / 2; // + m_marginLeft; // c.x = m_scrX/2;
2427  int centerY = (m_scrY - m_marginTop - m_marginBottom) / 2; // - m_marginTop; // c.y = m_scrY/2;
2428  SetPos( p2x( m_clickedX - centerX ), p2y( m_clickedY - centerY ) );
2429  // 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);
2430 }
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,...
Definition: mathplot.h:1185
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1190
int m_marginTop
Definition: mathplot.h:1499
void SetPos(double posX, double posY)
Set current view's X and Y position and refresh display.
Definition: mathplot.h:1173
int m_clickedY
Definition: mathplot.h:1493
int m_marginBottom
Definition: mathplot.h:1499
int m_scrY
Definition: mathplot.h:1491
int m_scrX
Definition: mathplot.h:1490

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

◆ OnFit()

void mpWindow::OnFit ( wxCommandEvent &  event)
protectedinherited

Definition at line 2417 of file mathplot.cpp.

2418 {
2419  Fit();
2420 }
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:1995

References mpWindow::Fit().

◆ OnLockAspect()

void mpWindow::OnLockAspect ( wxCommandEvent &  event)
protectedinherited

Definition at line 2411 of file mathplot.cpp.

2412 {
2414 }
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:2393

References mpWindow::LockAspect(), and mpWindow::m_lockaspect.

◆ OnMouseLeftDown()

void mpWindow::OnMouseLeftDown ( wxMouseEvent &  event)
protectedinherited

Definition at line 1942 of file mathplot.cpp.

1943 {
1944  m_mouseLClick.x = event.GetX();
1945  m_mouseLClick.y = event.GetY();
1946  m_zooming = true;
1947 #ifdef MATHPLOT_DO_LOGGING
1948  wxLogMessage( "mpWindow::OnMouseLeftDown() X = %d , Y = %d", event.GetX(), event.GetY() ); /*m_mouseLClick.x, m_mouseLClick.y);*/
1949 #endif
1950  wxPoint pointClicked = event.GetPosition();
1951  m_movingInfoLayer = IsInsideInfoLayer( pointClicked );
1952 
1953  if( m_movingInfoLayer != NULL )
1954  {
1955 #ifdef MATHPLOT_DO_LOGGING
1956  wxLogMessage( "mpWindow::OnMouseLeftDown() started moving layer %lx",
1957  (long int) m_movingInfoLayer ); /*m_mouseLClick.x, m_mouseLClick.y);*/
1958 #endif
1959  }
1960 
1961  event.Skip();
1962 }
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:3100
wxPoint m_mouseLClick
Definition: mathplot.h:1508
mpInfoLayer * m_movingInfoLayer
Definition: mathplot.h:1511

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

◆ OnMouseLeftRelease()

void mpWindow::OnMouseLeftRelease ( wxMouseEvent &  event)
protectedinherited

Definition at line 1965 of file mathplot.cpp.

1966 {
1967  wxPoint release( event.GetX(), event.GetY() );
1968  wxPoint press( m_mouseLClick.x, m_mouseLClick.y );
1969 
1970  m_zooming = false;
1971 
1972  if( m_movingInfoLayer != NULL )
1973  {
1975  m_movingInfoLayer = NULL;
1976  }
1977  else
1978  {
1979  if( release != press )
1980  {
1981  ZoomRect( press, release );
1982  } /*else {
1983  * if (m_coordTooltip) {
1984  * wxString toolTipContent;
1985  * toolTipContent.Printf( "X = %f\nY = %f", p2x(event.GetX()), p2y(event.GetY()));
1986  * SetToolTip(toolTipContent);
1987  * }
1988  * } */
1989  }
1990 
1991  event.Skip();
1992 }
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:2370
mpInfoLayer * m_movingInfoLayer
Definition: mathplot.h:1511
virtual void UpdateReference()
Updates the rectangle reference point.
Definition: mathplot.cpp:148

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

◆ OnMouseMiddleDown()

void mpWindow::OnMouseMiddleDown ( wxMouseEvent &  event)
protectedinherited

Definition at line 1791 of file mathplot.cpp.

1792 {
1793  m_mouseMClick.x = event.GetX();
1794  m_mouseMClick.y = event.GetY();
1795 }
wxPoint m_mouseMClick
Definition: mathplot.h:1507

References mpWindow::m_mouseMClick.

◆ OnMouseMove()

void mpWindow::OnMouseMove ( wxMouseEvent &  event)
protectedinherited

Definition at line 1842 of file mathplot.cpp.

1843 {
1845  {
1846  event.Skip();
1847  return;
1848  }
1849 
1850  if( event.m_middleDown )
1851  {
1852  // The change:
1853  int Ax = m_mouseMClick.x - event.GetX();
1854  int Ay = m_mouseMClick.y - event.GetY();
1855 
1856  // For the next event, use relative to this coordinates.
1857  m_mouseMClick.x = event.GetX();
1858  m_mouseMClick.y = event.GetY();
1859 
1860  double Ax_units = Ax / m_scaleX;
1861  double Ay_units = -Ay / m_scaleY;
1862 
1863  bool updateRequired = false;
1864  updateRequired |= SetXView( m_posX + Ax_units,
1865  m_desiredXmax + Ax_units,
1866  m_desiredXmin + Ax_units );
1867  updateRequired |= SetYView( m_posY + Ay_units,
1868  m_desiredYmax + Ay_units,
1869  m_desiredYmin + Ay_units );
1870 
1871  if( updateRequired )
1872  UpdateAll();
1873 
1874 #ifdef MATHPLOT_DO_LOGGING
1875  wxLogMessage( "[mpWindow::OnMouseMove] Ax:%i Ay:%i m_posX:%f m_posY:%f",
1876  Ax,
1877  Ay,
1878  m_posX,
1879  m_posY );
1880 #endif
1881  }
1882  else
1883  {
1884  if( event.m_leftDown )
1885  {
1886  if( m_movingInfoLayer == NULL )
1887  {
1888  wxClientDC dc( this );
1889  wxPen pen( m_fgColour, 1, wxPENSTYLE_DOT );
1890  dc.SetPen( pen );
1891  dc.SetBrush( *wxTRANSPARENT_BRUSH );
1892  dc.DrawRectangle( m_mouseLClick.x, m_mouseLClick.y,
1893  event.GetX() - m_mouseLClick.x, event.GetY() - m_mouseLClick.y );
1894  m_zooming = true;
1895  m_zoomRect.x = m_mouseLClick.x;
1896  m_zoomRect.y = m_mouseLClick.y;
1897  m_zoomRect.width = event.GetX() - m_mouseLClick.x;
1898  m_zoomRect.height = event.GetY() - m_mouseLClick.y;
1899  }
1900  else
1901  {
1902  wxPoint moveVector( event.GetX() - m_mouseLClick.x,
1903  event.GetY() - m_mouseLClick.y );
1904  m_movingInfoLayer->Move( moveVector );
1905  m_zooming = false;
1906  }
1907 
1908  UpdateAll();
1909  }
1910  else
1911  {
1912 #if 0
1913  wxLayerList::iterator li;
1914 
1915  for( li = m_layers.begin(); li != m_layers.end(); li++ )
1916  {
1917  if( (*li)->IsInfo() && (*li)->IsVisible() )
1918  {
1919  mpInfoLayer* tmpLyr = (mpInfoLayer*) (*li);
1920  tmpLyr->UpdateInfo( *this, event );
1921  // UpdateAll();
1922  RefreshRect( tmpLyr->GetRectangle() );
1923  }
1924  }
1925 
1926 #endif
1927  /* if (m_coordTooltip) {
1928  * wxString toolTipContent;
1929  * toolTipContent.Printf( "X = %f\nY = %f", p2x(event.GetX()), p2y(event.GetY()));
1930  * wxTipWindow** ptr = NULL;
1931  * wxRect rectBounds(event.GetX(), event.GetY(), 5, 5);
1932  * wxTipWindow* tip = new wxTipWindow(this, toolTipContent, 100, ptr, &rectBounds);
1933  *
1934  * } */
1935  }
1936  }
1937 
1938  event.Skip();
1939 }
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:2224
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:2803
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:2210

References mpInfoLayer::GetRectangle(), mpWindow::m_desiredXmax, mpWindow::m_desiredXmin, mpWindow::m_desiredYmax, mpWindow::m_desiredYmin, mpWindow::m_enableMouseNavigation, mpWindow::m_fgColour, mpWindow::m_layers, mpWindow::m_mouseLClick, mpWindow::m_mouseMClick, mpWindow::m_movingInfoLayer, mpWindow::m_posX, mpWindow::m_posY, mpWindow::m_scaleX, mpWindow::m_scaleY, mpWindow::m_zooming, mpWindow::m_zoomRect, mpInfoLayer::Move(), mpWindow::SetXView(), mpWindow::SetYView(), mpWindow::UpdateAll(), and mpInfoLayer::UpdateInfo().

◆ OnMouseWheel()

void mpWindow::OnMouseWheel ( wxMouseEvent &  event)
protectedinherited

Definition at line 1800 of file mathplot.cpp.

1801 {
1803  {
1804  event.Skip();
1805  return;
1806  }
1807 
1808  // Scroll vertically or horizontally (this is SHIFT is hold down).
1809  int change = -event.GetWheelRotation(); // Opposite direction (More intuitive)!
1810  double changeUnitsX = change / m_scaleX;
1811  double changeUnitsY = change / m_scaleY;
1812 
1813  if( event.m_controlDown )
1814  {
1815  // horizontal scroll
1816  SetXView( m_posX + changeUnitsX, m_desiredXmax + changeUnitsX,
1817  m_desiredXmin + changeUnitsX );
1818  }
1819  else if( event.m_shiftDown )
1820  {
1821  // vertical scroll
1822  SetYView( m_posY - changeUnitsY, m_desiredYmax - changeUnitsY,
1823  m_desiredYmin - changeUnitsY );
1824  }
1825  else
1826  {
1827  // zoom in/out
1828  wxPoint clickPt( event.GetX(), event.GetY() );
1829 
1830  if( event.GetWheelRotation() > 0 )
1831  ZoomIn( clickPt );
1832  else
1833  ZoomOut( clickPt );
1834  }
1835 
1836  UpdateAll();
1837 }
void ZoomOut(const wxPoint &centerPoint=wxDefaultPosition)
Zoom out current view and refresh display.
Definition: mathplot.cpp:2295
virtual bool SetYView(double pos, double desiredMax, double desiredMin)
Applies new Y view coordinates depending on the settings.
Definition: mathplot.cpp:2224
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:2803
double m_desiredYmax
Definition: mathplot.h:1497
void ZoomIn(const wxPoint &centerPoint=wxDefaultPosition)
Zoom into current view and refresh display.
Definition: mathplot.cpp:2238
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:2210

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

◆ OnPaint()

void mpWindow::OnPaint ( wxPaintEvent &  event)
protectedinherited

Definition at line 2515 of file mathplot.cpp.

2516 {
2517  wxPaintDC dc( this );
2518 
2519  dc.GetSize( &m_scrX, &m_scrY ); // This is the size of the visible area only!
2520 
2521 #ifdef MATHPLOT_DO_LOGGING
2522  wxLogMessage( "[mpWindow::OnPaint] vis.area: x %i y%i", m_scrX, m_scrY );
2523 #endif
2524 
2525  // Selects direct or buffered draw:
2526  wxDC* trgDc;
2527 
2528  // J.L.Blanco @ Aug 2007: Added double buffer support
2529  if( m_enableDoubleBuffer )
2530  {
2531  if( m_last_lx!=m_scrX || m_last_ly!=m_scrY )
2532  {
2533  if( m_buff_bmp )
2534  delete m_buff_bmp;
2535 
2536  m_buff_bmp = new wxBitmap( m_scrX, m_scrY );
2537  m_buff_dc.SelectObject( *m_buff_bmp );
2538  m_last_lx = m_scrX;
2539  m_last_ly = m_scrY;
2540  }
2541 
2542  trgDc = &m_buff_dc;
2543  }
2544  else
2545  {
2546  trgDc = &dc;
2547  }
2548 
2549  // Draw background:
2550  // trgDc->SetDeviceOrigin(0,0);
2551  trgDc->SetPen( *wxTRANSPARENT_PEN );
2552  wxBrush brush( GetBackgroundColour() );
2553  trgDc->SetBrush( brush );
2554  trgDc->SetTextForeground( m_fgColour );
2555  trgDc->DrawRectangle( 0, 0, m_scrX, m_scrY );
2556 
2557  // Draw all the layers:
2558  // trgDc->SetDeviceOrigin( m_scrX>>1, m_scrY>>1); // Origin at the center
2559  wxLayerList::iterator li;
2560 
2561  for( li = m_layers.begin(); li != m_layers.end(); li++ )
2562  {
2563  (*li)->Plot( *trgDc, *this );
2564  }
2565 
2566  ;
2567 
2568  if( m_zooming )
2569  {
2570  wxPen pen( m_fgColour, 1, wxPENSTYLE_DOT );
2571  trgDc->SetPen( pen );
2572  trgDc->SetBrush( *wxTRANSPARENT_BRUSH );
2573  trgDc->DrawRectangle( m_zoomRect );
2574  }
2575 
2576  // If doublebuffer, draw now to the window:
2577  if( m_enableDoubleBuffer )
2578  {
2579  // trgDc->SetDeviceOrigin(0,0);
2580  // dc.SetDeviceOrigin(0,0); // Origin at the center
2581  dc.Blit( 0, 0, m_scrX, m_scrY, trgDc, 0, 0 );
2582  }
2583 
2584  /* if (m_coordTooltip) {
2585  * wxString toolTipContent;
2586  * wxPoint mousePoint = wxGetMousePosition();
2587  * toolTipContent.Printf( "X = %f\nY = %f", p2x(mousePoint.x), p2y(mousePoint.y));
2588  * SetToolTip(toolTipContent);
2589  * }*/
2590  // If scrollbars are enabled, refresh them
2591  if( m_enableScrollBars )
2592  {
2593  /* m_scroll.x = (int) floor((m_posX - m_minX)*m_scaleX);
2594  * m_scroll.y = (int) floor((m_maxY - m_posY )*m_scaleY);
2595  * Scroll(m_scroll.x, m_scroll.y);*/
2596  // Scroll(x2p(m_posX), y2p(m_posY));
2597  // SetVirtualSize((int) ((m_maxX - m_minX)*m_scaleX), (int) ((m_maxY - m_minY)*m_scaleY));
2598  // int centerX = (m_scrX - m_marginLeft - m_marginRight)/2; // + m_marginLeft; // c.x = m_scrX/2;
2599  // int centerY = (m_scrY - m_marginTop - m_marginBottom)/2; // - m_marginTop; // c.y = m_scrY/2;
2600  /*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);
2601  }
2602 }
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

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

◆ OnScrollBottom()

void mpWindow::OnScrollBottom ( wxScrollWinEvent &  event)
protectedinherited

Definition at line 2961 of file mathplot.cpp.

2962 {
2963  int scrollOrientation = event.GetOrientation();
2964  // Get thumb size
2965  int thumbSize = GetScrollThumb( scrollOrientation );
2966  // Get scroll range
2967  int scrollRange = GetScrollRange( scrollOrientation );
2968 
2969  DoScrollCalc( scrollRange - thumbSize, scrollOrientation );
2970 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2850

References mpWindow::DoScrollCalc().

◆ OnScrollLineDown()

void mpWindow::OnScrollLineDown ( wxScrollWinEvent &  event)
protectedinherited

Definition at line 2935 of file mathplot.cpp.

2936 {
2937  int scrollOrientation = event.GetOrientation();
2938  // Get position before page up
2939  int position = GetScrollPos( scrollOrientation );
2940  // Get thumb size
2941  int thumbSize = GetScrollThumb( scrollOrientation );
2942  // Get scroll range
2943  int scrollRange = GetScrollRange( scrollOrientation );
2944 
2945  // Need to adjust position by a page
2946  position += mpSCROLL_NUM_PIXELS_PER_LINE;
2947 
2948  if( position > (scrollRange - thumbSize) )
2949  position = scrollRange - thumbSize;
2950 
2951  DoScrollCalc( position, scrollOrientation );
2952 }
#define mpSCROLL_NUM_PIXELS_PER_LINE
Definition: mathplot.cpp:61
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2850

References mpWindow::DoScrollCalc(), and mpSCROLL_NUM_PIXELS_PER_LINE.

◆ OnScrollLineUp()

void mpWindow::OnScrollLineUp ( wxScrollWinEvent &  event)
protectedinherited

Definition at line 2919 of file mathplot.cpp.

2920 {
2921  int scrollOrientation = event.GetOrientation();
2922  // Get position before page up
2923  int position = GetScrollPos( scrollOrientation );
2924 
2925  // Need to adjust position by a line
2926  position -= mpSCROLL_NUM_PIXELS_PER_LINE;
2927 
2928  if( position < 0 )
2929  position = 0;
2930 
2931  DoScrollCalc( position, scrollOrientation );
2932 }
#define mpSCROLL_NUM_PIXELS_PER_LINE
Definition: mathplot.cpp:61
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2850

References mpWindow::DoScrollCalc(), and mpSCROLL_NUM_PIXELS_PER_LINE.

◆ OnScrollPageDown()

void mpWindow::OnScrollPageDown ( wxScrollWinEvent &  event)
protectedinherited

Definition at line 2899 of file mathplot.cpp.

2900 {
2901  int scrollOrientation = event.GetOrientation();
2902  // Get position before page up
2903  int position = GetScrollPos( scrollOrientation );
2904  // Get thumb size
2905  int thumbSize = GetScrollThumb( scrollOrientation );
2906  // Get scroll range
2907  int scrollRange = GetScrollRange( scrollOrientation );
2908 
2909  // Need to adjust position by a page
2910  position += thumbSize;
2911 
2912  if( position > (scrollRange - thumbSize) )
2913  position = scrollRange - thumbSize;
2914 
2915  DoScrollCalc( position, scrollOrientation );
2916 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2850

References mpWindow::DoScrollCalc().

◆ OnScrollPageUp()

void mpWindow::OnScrollPageUp ( wxScrollWinEvent &  event)
protectedinherited

Definition at line 2881 of file mathplot.cpp.

2882 {
2883  int scrollOrientation = event.GetOrientation();
2884  // Get position before page up
2885  int position = GetScrollPos( scrollOrientation );
2886  // Get thumb size
2887  int thumbSize = GetScrollThumb( scrollOrientation );
2888 
2889  // Need to adjust position by a page
2890  position -= thumbSize;
2891 
2892  if( position < 0 )
2893  position = 0;
2894 
2895  DoScrollCalc( position, scrollOrientation );
2896 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2850

References mpWindow::DoScrollCalc().

◆ OnScrollThumbTrack()

void mpWindow::OnScrollThumbTrack ( wxScrollWinEvent &  event)
protectedinherited

Definition at line 2875 of file mathplot.cpp.

2876 {
2877  DoScrollCalc( event.GetPosition(), event.GetOrientation() );
2878 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2850

References mpWindow::DoScrollCalc().

◆ OnScrollTop()

void mpWindow::OnScrollTop ( wxScrollWinEvent &  event)
protectedinherited

Definition at line 2955 of file mathplot.cpp.

2956 {
2957  DoScrollCalc( 0, event.GetOrientation() );
2958 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2850

References mpWindow::DoScrollCalc().

◆ OnShowPopupMenu()

void mpWindow::OnShowPopupMenu ( wxMouseEvent &  event)
protectedinherited

Definition at line 2403 of file mathplot.cpp.

2404 {
2405  m_clickedX = event.GetX();
2406  m_clickedY = event.GetY();
2407  PopupMenu( &m_popmenu, event.GetX(), event.GetY() );
2408 }
int m_clickedX
Definition: mathplot.h:1492
int m_clickedY
Definition: mathplot.h:1493
wxMenu m_popmenu
Definition: mathplot.h:1475

References mpWindow::m_clickedX, mpWindow::m_clickedY, and mpWindow::m_popmenu.

◆ OnSize()

void mpWindow::OnSize ( wxSizeEvent &  event)
protectedinherited

Definition at line 2445 of file mathplot.cpp.

2446 {
2447  // Try to fit again with the new window size:
2449 #ifdef MATHPLOT_DO_LOGGING
2450  wxLogMessage( "mpWindow::OnSize() m_scrX = %d, m_scrY = %d", m_scrX, m_scrY );
2451 #endif // MATHPLOT_DO_LOGGING
2452 }
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:1995
double m_desiredYmin
Definition: mathplot.h:1497
int m_scrY
Definition: mathplot.h:1491
int m_scrX
Definition: mathplot.h:1490

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

◆ OnZoomIn()

void mpWindow::OnZoomIn ( wxCommandEvent &  event)
protectedinherited

Definition at line 2433 of file mathplot.cpp.

2434 {
2435  ZoomIn( wxPoint( m_mouseMClick.x, m_mouseMClick.y ) );
2436 }
wxPoint m_mouseMClick
Definition: mathplot.h:1507
void ZoomIn(const wxPoint &centerPoint=wxDefaultPosition)
Zoom into current view and refresh display.
Definition: mathplot.cpp:2238

References mpWindow::m_mouseMClick, and mpWindow::ZoomIn().

◆ OnZoomOut()

void mpWindow::OnZoomOut ( wxCommandEvent &  event)
protectedinherited

Definition at line 2439 of file mathplot.cpp.

2440 {
2441  ZoomOut();
2442 }
void ZoomOut(const wxPoint &centerPoint=wxDefaultPosition)
Zoom out current view and refresh display.
Definition: mathplot.cpp:2295

References mpWindow::ZoomOut().

◆ p2x()

double mpWindow::p2x ( wxCoord  pixelCoordX)
inlineinherited

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

See also
p2y,x2p,y2p

Definition at line 1185 of file mathplot.h.

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

Referenced by mpWindow::DoZoomInXCalc(), mpWindow::DoZoomOutXCalc(), mpScaleXBase::getVisibleDataRange(), mpWindow::OnCenter(), CURSOR::Plot(), mpFX::Plot(), mpProfile::Plot(), mpWindow::ZoomIn(), mpWindow::ZoomOut(), and mpWindow::ZoomRect().

◆ p2y()

double mpWindow::p2y ( wxCoord  pixelCoordY)
inlineinherited

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

See also
p2x,x2p,y2p

Definition at line 1190 of file mathplot.h.

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

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

◆ ResetScales()

void SIM_PLOT_PANEL::ResetScales ( )

Resets scale ranges to fit the current traces

Definition at line 613 of file sim_plot_panel.cpp.

614 {
615  if( m_axis_x )
617 
618  if( m_axis_y1 )
620 
621  if( m_axis_y2 )
623 
624  for( auto t : m_traces )
625  t.second->UpdateScales();
626 }
mpScaleY * m_axis_y1
mpScaleXBase * m_axis_x
void ResetDataRange()
Definition: mathplot.h:756
std::map< wxString, TRACE * > m_traces
mpScaleY * m_axis_y2

References m_axis_x, m_axis_y1, m_axis_y2, m_traces, and mpScaleBase::ResetDataRange().

Referenced by DeleteTrace(), and SIM_PLOT_FRAME::onSimFinished().

◆ SaveScreenshot()

bool mpWindow::SaveScreenshot ( const wxString &  filename,
wxBitmapType  type = wxBITMAP_TYPE_BMP,
wxSize  imageSize = wxDefaultSize,
bool  fit = false 
)
inherited

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

3035 {
3036  int sizeX, sizeY;
3037  int bk_scrX, bk_scrY;
3038 
3039  if( imageSize == wxDefaultSize )
3040  {
3041  sizeX = m_scrX;
3042  sizeY = m_scrY;
3043  }
3044  else
3045  {
3046  sizeX = imageSize.x;
3047  sizeY = imageSize.y;
3048  bk_scrX = m_scrX;
3049  bk_scrY = m_scrY;
3050  SetScr( sizeX, sizeY );
3051  }
3052 
3053  wxBitmap screenBuffer( sizeX, sizeY );
3054  wxMemoryDC screenDC;
3055  screenDC.SelectObject( screenBuffer );
3056  screenDC.SetPen( *wxWHITE_PEN );
3057  screenDC.SetTextForeground( m_fgColour );
3058  wxBrush brush( GetBackgroundColour() );
3059  screenDC.SetBrush( brush );
3060  screenDC.DrawRectangle( 0, 0, sizeX, sizeY );
3061 
3062  if( fit )
3063  {
3064  Fit( m_minX, m_maxX, m_minY, m_maxY, &sizeX, &sizeY );
3065  }
3066  else
3067  {
3069  }
3070 
3071  // Draw all the layers:
3072  wxLayerList::iterator li;
3073 
3074  for( li = m_layers.begin(); li != m_layers.end(); li++ )
3075  (*li)->Plot( screenDC, *this );
3076 
3077  if( imageSize != wxDefaultSize )
3078  {
3079  // Restore dimensions
3080  SetScr( bk_scrX, bk_scrY );
3081  Fit( m_desiredXmin, m_desiredXmax, m_desiredYmin, m_desiredYmax, &bk_scrX, &bk_scrY );
3082  UpdateAll();
3083  }
3084 
3085  // Once drawing is complete, actually save screen shot
3086  wxImage screenImage = screenBuffer.ConvertToImage();
3087  return screenImage.SaveFile( filename, type );
3088 }
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:2803
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
wxColour m_fgColour
Definition: mathplot.h:1479
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:1995
double m_minX
Definition: mathplot.h:1482
double m_desiredYmin
Definition: mathplot.h:1497
void SetScr(int scrX, int scrY)
Set current view's dimensions in device context units.
Definition: mathplot.h:1180
int m_scrY
Definition: mathplot.h:1491
double m_maxX
Definition: mathplot.h:1483
int m_scrX
Definition: mathplot.h:1490
double m_maxY
Definition: mathplot.h:1485

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

Referenced by SIM_PLOT_FRAME::menuSaveImage().

◆ SetColourTheme()

void mpWindow::SetColourTheme ( const wxColour &  bgColour,
const wxColour &  drawColour,
const wxColour &  axesColour 
)
inherited

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

3171 {
3172  SetBackgroundColour( bgColour );
3173  SetForegroundColour( drawColour );
3174  m_bgColour = bgColour;
3175  m_fgColour = drawColour;
3176  m_axColour = axesColour;
3177  // cycle between layers to set colours and properties to them
3178  wxLayerList::iterator li;
3179 
3180  for( li = m_layers.begin(); li != m_layers.end(); li++ )
3181  {
3182  if( (*li)->GetLayerType() == mpLAYER_AXIS )
3183  {
3184  wxPen axisPen = (*li)->GetPen(); // Get the old pen to modify only colour, not style or width
3185  axisPen.SetColour( axesColour );
3186  (*li)->SetPen( axisPen );
3187  }
3188 
3189  if( (*li)->GetLayerType() == mpLAYER_INFO )
3190  {
3191  wxPen infoPen = (*li)->GetPen(); // Get the old pen to modify only colour, not style or width
3192  infoPen.SetColour( drawColour );
3193  (*li)->SetPen( infoPen );
3194  }
3195  }
3196 }
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

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

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

◆ SetLayerVisible() [1/2]

void mpWindow::SetLayerVisible ( const wxString &  name,
bool  viewable 
)
inherited

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

3129 {
3130  mpLayer* lx = GetLayerByName( name );
3131 
3132  if( lx )
3133  {
3134  lx->SetVisible( viewable );
3135  UpdateAll();
3136  }
3137 }
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2803
void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:301
mpLayer * GetLayerByName(const wxString &name)
Definition: mathplot.cpp:3013
const char * name
Definition: DXF_plotter.cpp:61

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

◆ SetLayerVisible() [2/2]

void mpWindow::SetLayerVisible ( const unsigned int  position,
bool  viewable 
)
inherited

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

3149 {
3150  mpLayer* lx = GetLayer( position );
3151 
3152  if( lx )
3153  {
3154  lx->SetVisible( viewable );
3155  UpdateAll();
3156  }
3157 }
mpLayer * GetLayer(int position)
Definition: mathplot.cpp:3004
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2803
void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:301

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

◆ SetMarginBottom()

void mpWindow::SetMarginBottom ( int  bottom)
inlineinherited

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

◆ SetMarginLeft()

void mpWindow::SetMarginLeft ( int  left)
inlineinherited

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

◆ SetMarginRight()

void mpWindow::SetMarginRight ( int  right)
inlineinherited

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

◆ SetMargins()

void mpWindow::SetMargins ( int  top,
int  right,
int  bottom,
int  left 
)
inherited

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

3092 {
3093  m_marginTop = top;
3094  m_marginRight = right;
3095  m_marginBottom = bottom;
3096  m_marginLeft = left;
3097 }
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

References mpWindow::m_marginBottom, mpWindow::m_marginLeft, mpWindow::m_marginRight, and mpWindow::m_marginTop.

Referenced by SIM_PLOT_PANEL().

◆ SetMarginTop()

void mpWindow::SetMarginTop ( int  top)
inlineinherited

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

◆ SetMPScrollbars()

void mpWindow::SetMPScrollbars ( bool  status)
inherited

Enable/disable scrollbars.

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

Definition at line 2654 of file mathplot.cpp.

2655 {
2656  // Temporary behaviour: always disable scrollbars
2657  m_enableScrollBars = status; // false;
2658 
2659  if( status == false )
2660  {
2661  SetScrollbar( wxHORIZONTAL, 0, 0, 0 );
2662  SetScrollbar( wxVERTICAL, 0, 0, 0 );
2663  }
2664 
2665  // else the scroll bars will be updated in UpdateAll();
2666  UpdateAll();
2667 
2668  // EnableScrolling(false, false);
2669  // m_enableScrollBars = status;
2670  // EnableScrolling(status, status);
2671  /* m_scroll.x = (int) floor((m_posX - m_minX)*m_scaleX);
2672  * m_scroll.y = (int) floor((m_posY - m_minY)*m_scaleY);*/
2673  // int scrollWidth = (int) floor((m_maxX - m_minX)*m_scaleX) - m_scrX;
2674  // int scrollHeight = (int) floor((m_minY - m_maxY)*m_scaleY) - m_scrY;
2675 
2677  // m_scroll.y = (int) floor((m_maxY - m_posY /*- m_minY*/)*m_scaleY);
2678  // int scrollWidth = (int) floor(((m_maxX - m_minX) - (m_desiredXmax - m_desiredXmin))*m_scaleX);
2679  // int scrollHeight = (int) floor(((m_maxY - m_minY) - (m_desiredYmax - m_desiredYmin))*m_scaleY);
2680  // #ifdef MATHPLOT_DO_LOGGING
2681  // wxLogMessage( "mpWindow::SetMPScrollbars() scrollWidth = %d, scrollHeight = %d", scrollWidth, scrollHeight);
2682  // #endif
2683  // if(status) {
2684  // SetScrollbars(1,
2685  // 1,
2686  // scrollWidth,
2687  // scrollHeight,
2688  // m_scroll.x,
2689  // m_scroll.y);
2691  // }
2692  // Refresh(false);*/
2693 }
bool m_enableScrollBars
Definition: mathplot.h:1509
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2803

References mpWindow::m_enableScrollBars, and mpWindow::UpdateAll().

◆ SetPos()

void mpWindow::SetPos ( double  posX,
double  posY 
)
inlineinherited

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:2803
double m_posY
Definition: mathplot.h:1489

Referenced by mpWindow::OnCenter().

◆ SetPosX()

void mpWindow::SetPosX ( double  posX)
inlineinherited

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:2803

Referenced by mpWindow::DoScrollCalc().

◆ SetPosY()

void mpWindow::SetPosY ( double  posY)
inlineinherited

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:2803
double m_posY
Definition: mathplot.h:1489

Referenced by mpWindow::DoScrollCalc().

◆ SetScaleX()

void mpWindow::SetScaleX ( double  scaleX)
inherited

Set current view's X scale and refresh display.

Parameters
scaleXNew scale, must not be 0.

Definition at line 2975 of file mathplot.cpp.

2976 {
2977  if( scaleX!=0 )
2978  m_scaleX = scaleX;
2979 
2980  UpdateAll();
2981 }
double m_scaleX
Definition: mathplot.h:1486
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2803

References mpWindow::m_scaleX, and mpWindow::UpdateAll().

◆ SetScaleY()

void mpWindow::SetScaleY ( double  scaleY)
inlineinherited

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:2803

◆ SetScr()

void mpWindow::SetScr ( int  scrX,
int  scrY 
)
inlineinherited

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

Referenced by mpWindow::SaveScreenshot().

◆ SetXView()

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

Applies new X view coordinates depending on the settings.

Returns
true if the changes were applied

Definition at line 2210 of file mathplot.cpp.

2211 {
2212  // if(!CheckXLimits(desiredMax, desiredMin))
2213  // return false;
2214 
2215  m_posX = pos;
2216  m_desiredXmax = desiredMax;
2217  m_desiredXmin = desiredMin;
2219 
2220  return true;
2221 }
double m_desiredXmax
Definition: mathplot.h:1497
double m_posX
Definition: mathplot.h:1488
void AdjustLimitedView()
Definition: mathplot.cpp:2166
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1497

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

Referenced by mpWindow::OnMouseMove(), and mpWindow::OnMouseWheel().

◆ SetYView()

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

Applies new Y view coordinates depending on the settings.

Returns
true if the changes were applied

Definition at line 2224 of file mathplot.cpp.

2225 {
2226  // if(!CheckYLimits(desiredMax, desiredMin))
2227  // return false;
2228 
2229  m_posY = pos;
2230  m_desiredYmax = desiredMax;
2231  m_desiredYmin = desiredMin;
2233 
2234  return true;
2235 }
double m_desiredYmax
Definition: mathplot.h:1497
void AdjustLimitedView()
Definition: mathplot.cpp:2166
double m_posY
Definition: mathplot.h:1489
double m_desiredYmin
Definition: mathplot.h:1497

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

Referenced by mpWindow::OnMouseMove(), and mpWindow::OnMouseWheel().

◆ ShowGrid()

void SIM_PLOT_PANEL::ShowGrid ( bool  aEnable)
inline

Definition at line 217 of file sim_plot_panel.h.

218  {
219  m_axis_x->SetTicks( !aEnable );
220  m_axis_y1->SetTicks( !aEnable );
221  m_axis_y2->SetTicks( !aEnable );
222  UpdateAll();
223  }
mpScaleY * m_axis_y1
mpScaleXBase * m_axis_x
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2803
mpScaleY * m_axis_y2
void SetTicks(bool enable)
Set X axis ticks or grid.
Definition: mathplot.h:711
void SetTicks(bool ticks)
Set Y axis ticks or grid.
Definition: mathplot.h:966

References m_axis_x, m_axis_y1, m_axis_y2, mpScaleBase::SetTicks(), mpScaleY::SetTicks(), and mpWindow::UpdateAll().

Referenced by SIM_PLOT_FRAME::menuShowGrid().

◆ ShowLegend()

void SIM_PLOT_PANEL::ShowLegend ( bool  aEnable)
inline

Definition at line 234 of file sim_plot_panel.h.

235  {
236  m_legend->SetVisible( aEnable );
237  UpdateAll();
238  }
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2803
void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:301
mpInfoLegend * m_legend

References m_legend, mpLayer::SetVisible(), and mpWindow::UpdateAll().

Referenced by SIM_PLOT_FRAME::menuShowLegend().

◆ TraceShown()

bool SIM_PLOT_PANEL::TraceShown ( const wxString &  aName) const
inline

Definition at line 200 of file sim_plot_panel.h.

201  {
202  return m_traces.count( aName ) > 0;
203  }
std::map< wxString, TRACE * > m_traces

References m_traces.

Referenced by SIM_PLOT_FRAME::removePlot().

◆ UpdateAll()

void mpWindow::UpdateAll ( )
inherited

Refresh display.

Definition at line 2803 of file mathplot.cpp.

2804 {
2805  if( UpdateBBox() )
2806  {
2807  if( m_enableScrollBars )
2808  {
2809  int cx, cy;
2810  GetClientSize( &cx, &cy );
2811  // Do x scroll bar
2812  {
2813  // Convert margin sizes from pixels to coordinates
2814  double leftMargin = m_marginLeft / m_scaleX;
2815  // Calculate the range in coords that we want to scroll over
2816  double maxX = (m_desiredXmax > m_maxX) ? m_desiredXmax : m_maxX;
2817  double minX = (m_desiredXmin < m_minX) ? m_desiredXmin : m_minX;
2818 
2819  if( (m_posX + leftMargin) < minX )
2820  minX = m_posX + leftMargin;
2821 
2822  // Calculate scroll bar size and thumb position
2823  int sizeX = (int) ( (maxX - minX) * m_scaleX );
2824  int thumbX = (int) ( ( (m_posX + leftMargin) - minX ) * m_scaleX );
2825  SetScrollbar( wxHORIZONTAL, thumbX, cx - (m_marginRight + m_marginLeft), sizeX );
2826  }
2827  // Do y scroll bar
2828  {
2829  // Convert margin sizes from pixels to coordinates
2830  double topMargin = m_marginTop / m_scaleY;
2831  // Calculate the range in coords that we want to scroll over
2832  double maxY = (m_desiredYmax > m_maxY) ? m_desiredYmax : m_maxY;
2833 
2834  if( (m_posY - topMargin) > maxY )
2835  maxY = m_posY - topMargin;
2836 
2837  double minY = (m_desiredYmin < m_minY) ? m_desiredYmin : m_minY;
2838  // Calculate scroll bar size and thumb position
2839  int sizeY = (int) ( (maxY - minY) * m_scaleY );
2840  int thumbY = (int) ( ( maxY - (m_posY - topMargin) ) * m_scaleY );
2841  SetScrollbar( wxVERTICAL, thumbY, cy - (m_marginTop + m_marginBottom), sizeY );
2842  }
2843  }
2844  }
2845 
2846  Refresh( false );
2847 }
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:2695
double m_maxX
Definition: mathplot.h:1483
double m_maxY
Definition: mathplot.h:1485

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

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

◆ UpdateBBox()

bool mpWindow::UpdateBBox ( )
protectedvirtualinherited

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

Returns
true if there is any valid BBox information.

Definition at line 2695 of file mathplot.cpp.

2696 {
2697  m_minX = 0.0;
2698  m_maxX = 1.0;
2699  m_minY = 0.0;
2700  m_maxY = 1.0;
2701 
2702  return true;
2703 
2704 #if 0
2705  bool first = true;
2706 
2707  for( wxLayerList::iterator li = m_layers.begin(); li != m_layers.end(); li++ )
2708  {
2709  mpLayer* f = *li;
2710 
2711  if( f->HasBBox() )
2712  {
2713  if( first )
2714  {
2715  first = false;
2716  m_minX = f->GetMinX(); m_maxX = f->GetMaxX();
2717  m_minY = f->GetMinY(); m_maxY = f->GetMaxY();
2718  }
2719  else
2720  {
2721  if( f->GetMinX()<m_minX )
2722  m_minX = f->GetMinX();
2723 
2724  if( f->GetMaxX()>m_maxX )
2725  m_maxX = f->GetMaxX();
2726 
2727  if( f->GetMinY()<m_minY )
2728  m_minY = f->GetMinY();
2729 
2730  if( f->GetMaxY()>m_maxY )
2731  m_maxY = f->GetMaxY();
2732  }
2733  }
2734 
2735  // node = node->GetNext();
2736  }
2737 
2738 #ifdef MATHPLOT_DO_LOGGING
2739  wxLogDebug( wxT(
2740  "[mpWindow::UpdateBBox] Bounding box: Xmin = %f, Xmax = %f, Ymin = %f, YMax = %f" ), m_minX, m_maxX, m_minY,
2741  m_maxY );
2742 #endif // MATHPLOT_DO_LOGGING
2743 
2744  return first == false;
2745 #endif
2746 }
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

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

Referenced by mpWindow::Fit(), and mpWindow::UpdateAll().

◆ x2p()

wxCoord mpWindow::x2p ( double  x)
inlineinherited

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

See also
p2x,p2y,y2p

Definition at line 1195 of file mathplot.h.

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

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

◆ y2p()

wxCoord mpWindow::y2p ( double  y)
inlineinherited

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

See also
p2x,p2y,x2p

Definition at line 1200 of file mathplot.h.

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

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

◆ ZoomIn()

void mpWindow::ZoomIn ( const wxPoint &  centerPoint = wxDefaultPosition)
inherited

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

2239 {
2240  wxPoint c( centerPoint );
2241 
2242  if( c == wxDefaultPosition )
2243  {
2244  GetClientSize( &m_scrX, &m_scrY );
2245  c.x = (m_scrX - m_marginLeft - m_marginRight) / 2 + m_marginLeft; // c.x = m_scrX/2;
2246  c.y = (m_scrY - m_marginTop - m_marginBottom) / 2 - m_marginTop; // c.y = m_scrY/2;
2247  }
2248  else
2249  {
2250  c.x = std::max( c.x, m_marginLeft );
2251  c.x = std::min( c.x, m_scrX - m_marginRight );
2252  c.y = std::max( c.y, m_marginTop );
2253  c.y = std::min( c.y, m_scrY - m_marginBottom );
2254  }
2255 
2256  // Preserve the position of the clicked point:
2257  double prior_layer_x = p2x( c.x );
2258  double prior_layer_y = p2y( c.y );
2259 
2260  // Zoom in:
2261  const double MAX_SCALE = 1e6;
2262  double newScaleX = m_scaleX * zoomIncrementalFactor;
2263  double newScaleY = m_scaleY * zoomIncrementalFactor;
2264 
2265  // Baaaaad things happen when you zoom in too much..
2266  if( newScaleX <= MAX_SCALE && newScaleY <= MAX_SCALE )
2267  {
2268  m_scaleX = newScaleX;
2269  m_scaleY = newScaleY;
2270  }
2271  else
2272  {
2273  return;
2274  }
2275 
2276  // Adjust the new m_posx/y:
2277  m_posX = prior_layer_x - c.x / m_scaleX;
2278  m_posY = prior_layer_y + c.y / m_scaleY;
2279 
2281  m_desiredXmax = m_posX + (m_scrX - m_marginLeft - m_marginRight) / m_scaleX; // m_desiredXmax = m_posX + m_scrX / m_scaleX;
2283  m_desiredYmin = m_posY - (m_scrY - m_marginTop - m_marginBottom) / m_scaleY; // m_desiredYmin = m_posY - m_scrY / m_scaleY;
2285 
2286 #ifdef MATHPLOT_DO_LOGGING
2287  wxLogMessage( "mpWindow::ZoomIn() prior coords: (%f,%f), new coords: (%f,%f) SHOULD BE EQUAL!!",
2288  prior_layer_x, prior_layer_y, p2x( c.x ), p2y( c.y ) );
2289 #endif
2290 
2291  UpdateAll();
2292 }
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,...
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,...
Definition: mathplot.h:1190
double m_scaleX
Definition: mathplot.h:1486
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2803
double m_desiredYmax
Definition: mathplot.h:1497
void AdjustLimitedView()
Definition: mathplot.cpp:2166
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

References mpWindow::AdjustLimitedView(), mpWindow::m_desiredXmax, mpWindow::m_desiredXmin, mpWindow::m_desiredYmax, mpWindow::m_desiredYmin, mpWindow::m_marginBottom, mpWindow::m_marginLeft, mpWindow::m_marginRight, mpWindow::m_marginTop, mpWindow::m_posX, mpWindow::m_posY, mpWindow::m_scaleX, mpWindow::m_scaleY, mpWindow::m_scrX, mpWindow::m_scrY, max, MAX_SCALE, min, mpWindow::p2x(), mpWindow::p2y(), mpWindow::UpdateAll(), and mpWindow::zoomIncrementalFactor.

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

◆ ZoomInX()

void mpWindow::ZoomInX ( )
inherited

Zoom in current view along X and refresh display.

Definition at line 2342 of file mathplot.cpp.

2343 {
2345  UpdateAll();
2346 }
double m_scaleX
Definition: mathplot.h:1486
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2803
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

References mpWindow::m_scaleX, mpWindow::UpdateAll(), and mpWindow::zoomIncrementalFactor.

◆ ZoomInY()

void mpWindow::ZoomInY ( )
inherited

Zoom in current view along Y and refresh display.

Definition at line 2356 of file mathplot.cpp.

2357 {
2359  UpdateAll();
2360 }
double m_scaleY
Definition: mathplot.h:1487
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2803
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

References mpWindow::m_scaleY, mpWindow::UpdateAll(), and mpWindow::zoomIncrementalFactor.

◆ ZoomOut()

void mpWindow::ZoomOut ( const wxPoint &  centerPoint = wxDefaultPosition)
inherited

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

2296 {
2297  wxPoint c( centerPoint );
2298 
2299  if( c == wxDefaultPosition )
2300  {
2301  GetClientSize( &m_scrX, &m_scrY );
2302  c.x = (m_scrX - m_marginLeft - m_marginRight) / 2 + m_marginLeft; // c.x = m_scrX/2;
2303  c.y = (m_scrY - m_marginTop - m_marginBottom) / 2 - m_marginTop; // c.y = m_scrY/2;
2304  }
2305 
2306  // Preserve the position of the clicked point:
2307  double prior_layer_x = p2x( c.x );
2308  double prior_layer_y = p2y( c.y );
2309 
2310  // Zoom out:
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;
2322 
2323  // printf("desired xmin %.1f ymin %.1f xmax %.1f ymax %.1f l %d\n", m_desiredXmin, m_desiredYmin, m_desiredXmax, m_desiredYmax, !!m_enableLimitedView);
2324  // printf("current xmin %.1f ymin %.1f xmax %.1f ymax %.1f\n", m_minX, m_minY, m_maxX, m_maxY);
2325 
2328  {
2329  // printf("call fit()\n");
2330  Fit();
2331  }
2332 
2333 #ifdef MATHPLOT_DO_LOGGING
2334  wxLogMessage(
2335  "mpWindow::ZoomOut() prior coords: (%f,%f), new coords: (%f,%f) SHOULD BE EQUAL!!",
2336  prior_layer_x, prior_layer_y, p2x( c.x ), p2y( c.y ) );
2337 #endif
2338  UpdateAll();
2339 }
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,...
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,...
Definition: mathplot.h:1190
double m_scaleX
Definition: mathplot.h:1486
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2803
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
bool CheckYLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1449
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:1995
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
bool CheckXLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1442
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

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

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

◆ ZoomOutX()

void mpWindow::ZoomOutX ( )
inherited

Zoom out current view along X and refresh display.

Definition at line 2349 of file mathplot.cpp.

2350 {
2352  UpdateAll();
2353 }
double m_scaleX
Definition: mathplot.h:1486
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2803
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

References mpWindow::m_scaleX, mpWindow::UpdateAll(), and mpWindow::zoomIncrementalFactor.

◆ ZoomOutY()

void mpWindow::ZoomOutY ( )
inherited

Zoom out current view along Y and refresh display.

Definition at line 2363 of file mathplot.cpp.

2364 {
2366  UpdateAll();
2367 }
double m_scaleY
Definition: mathplot.h:1487
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2803
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

References mpWindow::m_scaleY, mpWindow::UpdateAll(), and mpWindow::zoomIncrementalFactor.

◆ ZoomRect()

void mpWindow::ZoomRect ( wxPoint  p0,
wxPoint  p1 
)
inherited

Zoom view fitting given coordinates to the window (p0 and p1 do not need to be in any specific order)

Definition at line 2370 of file mathplot.cpp.

2371 {
2372  // Compute the 2 corners in graph coordinates:
2373  double p0x = p2x( p0.x );
2374  double p0y = p2y( p0.y );
2375  double p1x = p2x( p1.x );
2376  double p1y = p2y( p1.y );
2377 
2378  // Order them:
2379  double zoom_x_min = p0x<p1x ? p0x : p1x;
2380  double zoom_x_max = p0x>p1x ? p0x : p1x;
2381  double zoom_y_min = p0y<p1y ? p0y : p1y;
2382  double zoom_y_max = p0y>p1y ? p0y : p1y;
2383 
2384 #ifdef MATHPLOT_DO_LOGGING
2385  wxLogMessage( "Zoom: (%f,%f)-(%f,%f)", zoom_x_min, zoom_y_min, zoom_x_max, zoom_y_max );
2386 #endif
2387 
2388  Fit( zoom_x_min, zoom_x_max, zoom_y_min, zoom_y_max );
2390 }
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1185
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1190
void AdjustLimitedView()
Definition: mathplot.cpp:2166
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:1995

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

Referenced by mpWindow::OnMouseLeftRelease().

Member Data Documentation

◆ m_axColour

wxColour mpWindow::m_axColour
protectedinherited

Definition at line 1480 of file mathplot.h.

Referenced by mpWindow::SetColourTheme().

◆ m_axis_x

mpScaleXBase* SIM_PLOT_PANEL::m_axis_x
private

◆ m_axis_y1

mpScaleY* SIM_PLOT_PANEL::m_axis_y1
private

◆ m_axis_y2

mpScaleY* SIM_PLOT_PANEL::m_axis_y2
private

Definition at line 266 of file sim_plot_panel.h.

Referenced by AddTrace(), GetLabelY2(), ResetScales(), ShowGrid(), and SIM_PLOT_PANEL().

◆ m_bgColour

wxColour mpWindow::m_bgColour
protectedinherited

Definition at line 1478 of file mathplot.h.

Referenced by mpWindow::SetColourTheme().

◆ m_buff_bmp

wxBitmap* mpWindow::m_buff_bmp
protectedinherited

Definition at line 1503 of file mathplot.h.

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

◆ m_buff_dc

wxMemoryDC mpWindow::m_buff_dc
protectedinherited

Definition at line 1502 of file mathplot.h.

Referenced by mpWindow::OnPaint().

◆ m_clickedX

int mpWindow::m_clickedX
protectedinherited

Definition at line 1492 of file mathplot.h.

Referenced by mpWindow::OnCenter(), and mpWindow::OnShowPopupMenu().

◆ m_clickedY

int mpWindow::m_clickedY
protectedinherited

Definition at line 1493 of file mathplot.h.

Referenced by mpWindow::OnCenter(), and mpWindow::OnShowPopupMenu().

◆ m_colorIdx

unsigned int SIM_PLOT_PANEL::m_colorIdx
private

Definition at line 259 of file sim_plot_panel.h.

Referenced by DeleteAllTraces(), and generateColor().

◆ m_desiredXmax

◆ m_desiredXmin

double mpWindow::m_desiredXmin
protectedinherited

◆ m_desiredYmax

◆ m_desiredYmin

◆ m_enableDoubleBuffer

bool mpWindow::m_enableDoubleBuffer
protectedinherited

Definition at line 1504 of file mathplot.h.

Referenced by mpWindow::OnPaint().

◆ m_enableLimitedView

bool mpWindow::m_enableLimitedView
protectedinherited

Definition at line 1506 of file mathplot.h.

Referenced by mpWindow::AdjustLimitedView().

◆ m_enableMouseNavigation

bool mpWindow::m_enableMouseNavigation
protectedinherited

Definition at line 1505 of file mathplot.h.

Referenced by mpWindow::OnMouseMove(), and mpWindow::OnMouseWheel().

◆ m_enableScrollBars

bool mpWindow::m_enableScrollBars
protectedinherited

Definition at line 1509 of file mathplot.h.

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

◆ m_fgColour

wxColour mpWindow::m_fgColour
protectedinherited

◆ m_last_lx

int mpWindow::m_last_lx
protectedinherited

Definition at line 1501 of file mathplot.h.

Referenced by mpWindow::OnPaint().

◆ m_last_ly

int mpWindow::m_last_ly
protectedinherited

Definition at line 1501 of file mathplot.h.

Referenced by mpWindow::OnPaint().

◆ m_layers

◆ m_legend

mpInfoLegend* SIM_PLOT_PANEL::m_legend
private

Definition at line 267 of file sim_plot_panel.h.

Referenced by IsLegendShown(), ShowLegend(), and SIM_PLOT_PANEL().

◆ m_lockaspect

bool mpWindow::m_lockaspect
protectedinherited

Definition at line 1476 of file mathplot.h.

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

◆ m_marginBottom

◆ m_marginLeft

◆ m_marginRight

◆ m_marginTop

◆ m_maxX

double mpWindow::m_maxX
protectedinherited

◆ m_maxY

◆ m_minX

◆ m_minY

double mpWindow::m_minY
protectedinherited

◆ m_mouseLClick

wxPoint mpWindow::m_mouseLClick
protectedinherited

◆ m_mouseMClick

wxPoint mpWindow::m_mouseMClick
protectedinherited

◆ m_movingInfoLayer

mpInfoLayer* mpWindow::m_movingInfoLayer
protectedinherited

◆ m_popmenu

wxMenu mpWindow::m_popmenu
protectedinherited

Definition at line 1475 of file mathplot.h.

Referenced by mpWindow::LockAspect(), and mpWindow::OnShowPopupMenu().

◆ m_posX

◆ m_posY

◆ m_scaleX

◆ m_scaleY

◆ m_scroll

wxPoint mpWindow::m_scroll
protectedinherited

Definition at line 1510 of file mathplot.h.

◆ m_scrX

◆ m_scrY

◆ m_topLevel

std::vector<mpLayer*> SIM_PLOT_PANEL::m_topLevel
private

Definition at line 269 of file sim_plot_panel.h.

Referenced by AddTrace(), and SIM_PLOT_PANEL().

◆ m_traces

std::map<wxString, TRACE*> SIM_PLOT_PANEL::m_traces
private

◆ m_type

const SIM_TYPE SIM_PLOT_PANEL::m_type
private

Definition at line 271 of file sim_plot_panel.h.

Referenced by AddTrace(), GetType(), and SIM_PLOT_PANEL().

◆ m_zooming

bool mpWindow::m_zooming
protectedinherited

◆ m_zoomRect

wxRect mpWindow::m_zoomRect
protectedinherited

Definition at line 1513 of file mathplot.h.

Referenced by mpWindow::OnMouseMove(), and mpWindow::OnPaint().

◆ zoomIncrementalFactor

double mpWindow::zoomIncrementalFactor = 1.5
staticinherited

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.

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


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