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
 
void SetDottedCurrentPhase (bool aEnable)
 
bool GetDottedCurrentPhase () 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...
 
void UpdateTraceStyle (TRACE *trace)
 

Update trace line style

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 EnableMouseWheelPan (bool enabled)
 Enable/disable trackpad friendly panning (2-axis scroll wheel) More...
 
void LockAspect (bool enable=TRUE)
 Enable or disable X/Y scale aspect locking for the view. More...
 
bool IsAspectLocked ()
 Checks whether the X/Y scale aspect is locked. More...
 
void Fit () override
 Set view to fit global bounding box of all plot layers and refresh display. More...
 
void Fit (double xMin, double xMax, double yMin, double yMax, wxCoord *printSizeX=NULL, wxCoord *printSizeY=NULL)
 Set view to fit a given bounding box and refresh display. More...
 
void ZoomIn (const wxPoint &centerPoint=wxDefaultPosition)
 Zoom into current view and refresh display. More...
 
void ZoomIn (const wxPoint &centerPoint, double zoomFactor)
 
void ZoomOut (const wxPoint &centerPoint=wxDefaultPosition)
 Zoom out current view and refresh display. More...
 
void ZoomOut (const wxPoint &centerPoint, double zoomFactor)
 
void ZoomInX ()
 Zoom in current view along X and refresh display. More...
 
void ZoomOutX ()
 Zoom out current view along X and refresh display. More...
 
void ZoomInY ()
 Zoom in current view along Y and refresh display. More...
 
void ZoomOutY ()
 Zoom out current view along Y and refresh display. More...
 
void ZoomRect (wxPoint p0, wxPoint p1)
 Zoom view fitting given coordinates to the window (p0 and p1 do not need to be in any specific order) More...
 
void UpdateAll ()
 Refresh display. More...
 
unsigned int CountLayers ()
 Counts the number of plot layers, excluding axes or text: this is to count only the layers which have a bounding box. More...
 
unsigned int CountAllLayers ()
 Counts the number of plot layers, whether or not they have a bounding box. More...
 
double GetDesiredXmin ()
 Returns the left-border layer coordinate that the user wants the mpWindow to show (it may be not exactly the actual shown coordinate in the case of locked aspect ratio). More...
 
double GetDesiredXmax ()
 Returns the right-border layer coordinate that the user wants the mpWindow to show (it may be not exactly the actual shown coordinate in the case of locked aspect ratio). More...
 
double GetDesiredYmin ()
 Returns the bottom-border layer coordinate that the user wants the mpWindow to show (it may be not exactly the actual shown coordinate in the case of locked aspect ratio). More...
 
double GetDesiredYmax ()
 Returns the top layer-border coordinate that the user wants the mpWindow to show (it may be not exactly the actual shown coordinate in the case of locked aspect ratio). More...
 
void GetBoundingBox (double *bbox)
 Returns the bounding box coordinates. More...
 
void SetMPScrollbars (bool status)
 Enable/disable scrollbars. More...
 
bool GetMPScrollbars ()
 Get scrollbars status. More...
 
bool SaveScreenshot (const wxString &filename, wxBitmapType type=wxBITMAP_TYPE_BMP, wxSize imageSize=wxDefaultSize, bool fit=false)
 Draw the window on a wxBitmap, then save it to a file. More...
 
void SetMargins (int top, int right, int bottom, int left)
 Set window margins, creating a blank area where some kinds of layers cannot draw. More...
 
void SetMarginTop (int top)
 Set the top margin. More...
 
void SetMarginRight (int right)
 Set the right margin. More...
 
void SetMarginBottom (int bottom)
 Set the bottom margin. More...
 
void SetMarginLeft (int left)
 Set the left margin. More...
 
int GetMarginTop ()
 
int GetMarginRight ()
 
int GetMarginBottom ()
 
int GetMarginLeft ()
 
mpInfoLayerIsInsideInfoLayer (wxPoint &point)
 Check if a given point is inside the area of a mpInfoLayer and eventually returns its pointer. More...
 
void SetLayerVisible (const wxString &name, bool viewable)
 Sets the visibility of a layer by its name. More...
 
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.1
 This value sets the zoom steps whenever the user clicks "Zoom in/out" or performs zoom with the mouse wheel. More...
 

Protected Member Functions

void OnPaint (wxPaintEvent &event)
 
void OnSize (wxSizeEvent &event)
 
void OnShowPopupMenu (wxMouseEvent &event)
 
void OnMouseMiddleDown (wxMouseEvent &event)
 
void OnCenter (wxCommandEvent &event)
 
void OnFit (wxCommandEvent &event)
 
void OnZoomIn (wxCommandEvent &event)
 
void OnZoomOut (wxCommandEvent &event)
 
void OnLockAspect (wxCommandEvent &event)
 
void OnMouseWheel (wxMouseEvent &event)
 
void OnMagnify (wxMouseEvent &event)
 
void OnMouseMove (wxMouseEvent &event)
 
void OnMouseLeftDown (wxMouseEvent &event)
 
void OnMouseLeftRelease (wxMouseEvent &event)
 
void OnScrollThumbTrack (wxScrollWinEvent &event)
 
void OnScrollPageUp (wxScrollWinEvent &event)
 
void OnScrollPageDown (wxScrollWinEvent &event)
 
void OnScrollLineUp (wxScrollWinEvent &event)
 
void OnScrollLineDown (wxScrollWinEvent &event)
 
void OnScrollTop (wxScrollWinEvent &event)
 
void OnScrollBottom (wxScrollWinEvent &event)
 
void DoScrollCalc (const int position, const int orientation)
 
void DoZoomInXCalc (const int staticXpixel)
 
void DoZoomInYCalc (const int staticYpixel)
 
void DoZoomOutXCalc (const int staticXpixel)
 
void DoZoomOutYCalc (const int staticYpixel)
 
bool CheckXLimits (double &desiredMax, double &desiredMin) const
 
bool CheckYLimits (double &desiredMax, double &desiredMin) const
 
void AdjustLimitedView ()
 
virtual bool UpdateBBox ()
 Recalculate global layer bounding box, and save it in m_minX,... More...
 
virtual bool SetXView (double pos, double desiredMax, double desiredMin)
 Applies new X view coordinates depending on the settings. More...
 
virtual bool SetYView (double pos, double desiredMax, double desiredMin)
 Applies new Y view coordinates depending on the settings. More...
 

Protected Attributes

wxLayerList m_layers
 
wxMenu m_popmenu
 
bool m_lockaspect
 
wxColour m_bgColour
 
wxColour m_fgColour
 
wxColour m_axColour
 
double m_minX
 
double m_maxX
 
double m_minY
 
double m_maxY
 
double m_scaleX
 
double m_scaleY
 
double m_posX
 
double m_posY
 
int m_scrX
 
int m_scrY
 
int m_clickedX
 
int m_clickedY
 
double m_desiredXmin
 These are updated in Fit() only, and may be different from the real borders (layer coordinates) only if lock aspect ratio is true. More...
 
double m_desiredXmax
 
double m_desiredYmin
 
double m_desiredYmax
 
int m_marginTop
 
int m_marginRight
 
int m_marginBottom
 
int m_marginLeft
 
int m_last_lx
 
int m_last_ly
 
wxMemoryDC m_buff_dc
 
wxBitmap * m_buff_bmp
 
bool m_enableDoubleBuffer
 
bool m_enableMouseNavigation
 
bool m_enableMouseWheelPan
 
bool m_enableLimitedView
 
wxPoint m_mouseMClick
 
wxPoint m_mouseLClick
 
bool m_enableScrollBars
 
wxPoint m_scroll
 
mpInfoLayerm_movingInfoLayer
 
bool m_zooming
 
wxRect m_zoomRect
 

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
 
bool m_dotted_cp
 
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 ),
367  m_colorIdx( 0 ),
368  m_axis_x( nullptr ),
369  m_axis_y1( nullptr ),
370  m_axis_y2( nullptr ),
371  m_dotted_cp( false ),
372  m_type( aType )
373 {
374  LimitView( true );
375  SetMargins( 50, 80, 50, 80 );
376 
377  wxColour grey( 130, 130, 130 );
378  wxColour dark( 10, 10, 10 );
379  SetColourTheme( dark, *wxWHITE, grey );
380  EnableDoubleBuffer( true );
381  UpdateAll();
382 
383  switch( m_type )
384  {
385  case ST_AC:
386  m_axis_x = new FREQUENCY_LOG_SCALE( _( "Frequency" ), mpALIGN_BOTTOM );
387  m_axis_y1 = new GAIN_SCALE( _( "Gain" ), mpALIGN_LEFT );
388  m_axis_y2 = new PHASE_SCALE( _( "Phase" ), mpALIGN_RIGHT );
390  break;
391 
392  case ST_DC:
393  m_axis_x = new VOLTAGE_SCALE_X( _( "Voltage (swept)" ), mpALIGN_BOTTOM );
394  m_axis_y1 = new VOLTAGE_SCALE_Y( _( "Voltage (measured)" ), mpALIGN_LEFT );
395  m_axis_y2 = new CURRENT_SCALE( _( "Current" ), mpALIGN_RIGHT );
396  break;
397 
398  case ST_NOISE:
399  m_axis_x = new FREQUENCY_LOG_SCALE( _( "Frequency" ), mpALIGN_BOTTOM );
400  m_axis_y1 = new mpScaleY( _( "noise [(V or A)^2/Hz]" ), mpALIGN_LEFT );
401  break;
402 
403  case ST_TRANSIENT:
404  m_axis_x = new TIME_SCALE( _( "Time" ), mpALIGN_BOTTOM );
405  m_axis_y1 = new VOLTAGE_SCALE_Y( _( "Voltage" ), mpALIGN_LEFT );
406  m_axis_y2 = new CURRENT_SCALE( _( "Current" ), mpALIGN_RIGHT );
408  break;
409 
410  default:
411  // suppress warnings
412  break;
413  }
414 
415  if( m_axis_x )
416  {
417  m_axis_x->SetTicks( false );
419 
420  AddLayer( m_axis_x );
421  }
422 
423  if( m_axis_y1 )
424  {
425  m_axis_y1->SetTicks( false );
427  AddLayer( m_axis_y1 );
428  }
429 
430  if( m_axis_y2 )
431  {
432  m_axis_y2->SetTicks( false );
434  AddLayer( m_axis_y2 );
435  }
436 
437  m_legend = new mpInfoLegend( wxRect( 0, 40, 200, 40 ), wxTRANSPARENT_BRUSH );
438  m_legend->SetVisible( false );
439  AddLayer( m_legend );
440  m_topLevel.push_back( m_legend );
441  SetColourTheme( dark, *wxWHITE, grey );
442 
443  EnableDoubleBuffer( true );
444  UpdateAll();
445 }
#define mpALIGN_LEFT
Aligns label to the left.
Definition: mathplot.h:480
void SetNameAlign(int align)
Definition: mathplot.h:708
mpScaleY * m_axis_y1
mpWindow()
Definition: mathplot.h:1048
const SIM_TYPE m_type
mpScaleXBase * m_axis_x
void SetMasterScale(mpScaleY *masterScale)
Definition: mathplot.h:978
#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:2488
void EnableDoubleBuffer(bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=disabled).
Definition: mathplot.h:1207
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836
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:3124
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:3201
mpScaleY * m_axis_y2
void SetTicks(bool enable)
Set X axis ticks or grid.
Definition: mathplot.h:713
#define _(s)
Definition: 3d_actions.cpp:31
mpInfoLegend * m_legend
void LimitView(bool aEnable)
Limit zooming & panning to the area used by the plots.
Definition: mathplot.h:1424
void SetTicks(bool ticks)
Set Y axis ticks or grid.
Definition: mathplot.h:968
#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 448 of file sim_plot_panel.cpp.

449 {
450  // ~mpWindow destroys all the added layers, so there is no need to destroy m_traces contents
451 }

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

2489 {
2490  if( layer != NULL )
2491  {
2492  m_layers.push_back( layer );
2493 
2494  if( refreshDisplay )
2495  UpdateAll();
2496 
2497  return true;
2498  }
2499 
2500  ;
2501  return false;
2502 }
wxLayerList m_layers
Definition: mathplot.h:1495
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836
#define NULL

References mpWindow::m_layers, NULL, 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 479 of file sim_plot_panel.cpp.

481 {
482  TRACE* trace = NULL;
483 
484  // Find previous entry, if there is one
485  auto prev = m_traces.find( aName );
486  bool addedNewEntry = ( prev == m_traces.end() );
487 
488  if( addedNewEntry )
489  {
490  if( m_type == ST_TRANSIENT )
491  {
492  bool hasVoltageTraces = false;
493 
494  for( const auto& tr : m_traces )
495  {
496  if( !( tr.second->GetFlags() & SPT_CURRENT ) )
497  {
498  hasVoltageTraces = true;
499  break;
500  }
501  }
502 
503  if( !hasVoltageTraces )
504  m_axis_y2->SetMasterScale( nullptr );
505  else
507  }
508 
509  // New entry
510  trace = new TRACE( aName );
511  trace->SetTraceColour( generateColor() );
512  UpdateTraceStyle( trace );
513  m_traces[aName] = trace;
514 
515  // It is a trick to keep legend & coords always on the top
516  for( mpLayer* l : m_topLevel )
517  DelLayer( l );
518 
519  AddLayer( (mpLayer*) trace );
520 
521  for( mpLayer* l : m_topLevel )
522  AddLayer( l );
523  }
524  else
525  {
526  trace = prev->second;
527  }
528 
529  std::vector<double> tmp( aY, aY + aPoints );
530 
531  if( m_type == ST_AC )
532  {
533  if( aFlags & SPT_AC_PHASE )
534  {
535  for( int i = 0; i < aPoints; i++ )
536  tmp[i] = tmp[i] * 180.0 / M_PI; // convert to degrees
537  }
538  else
539  {
540  for( int i = 0; i < aPoints; i++ )
541  tmp[i] = 20 * log( tmp[i] ) / log( 10.0 ); // convert to dB
542  }
543  }
544 
545  trace->SetData( std::vector<double>( aX, aX + aPoints ), tmp );
546 
547  if( aFlags & SPT_AC_PHASE || aFlags & SPT_CURRENT )
548  trace->SetScale( m_axis_x, m_axis_y2 );
549  else
550  trace->SetScale( m_axis_x, m_axis_y1 );
551 
552  trace->SetFlags( aFlags );
553 
554  UpdateAll();
555 
556  return addedNewEntry;
557 }
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:2505
virtual void SetScale(mpScaleBase *scaleX, mpScaleBase *scaleY)
Definition: mathplot.cpp:4082
mpScaleXBase * m_axis_x
void SetMasterScale(mpScaleY *masterScale)
Definition: mathplot.h:978
bool AddLayer(mpLayer *layer, bool refreshDisplay=true)
Add a plot layer to the canvas.
Definition: mathplot.cpp:2488
void UpdateTraceStyle(TRACE *trace)
Update trace line style
void SetFlags(int aFlags)
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836
#define NULL
std::vector< mpLayer * > m_topLevel
std::map< wxString, TRACE * > m_traces
mpScaleY * m_axis_y2
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(), m_axis_x, m_axis_y1, m_axis_y2, m_topLevel, m_traces, m_type, NULL, TRACE::SetData(), TRACE::SetFlags(), mpScaleY::SetMasterScale(), mpFXY::SetScale(), TRACE::SetTraceColour(), SPT_AC_PHASE, SPT_CURRENT, ST_AC, ST_TRANSIENT, mpWindow::UpdateAll(), and UpdateTraceStyle().

Referenced by SIM_PLOT_FRAME::updatePlot().

◆ AdjustLimitedView()

void mpWindow::AdjustLimitedView ( )
protectedinherited

Definition at line 2185 of file mathplot.cpp.

2186 {
2187  if( !m_enableLimitedView )
2188  return;
2189 
2190  // m_min and m_max are plot limits for curves
2191  // xMin, xMax, yMin, yMax are the full limits (plot limit + margin)
2192  const double xMin = m_minX - m_marginLeft / m_scaleX;
2193  const double xMax = m_maxX + m_marginRight / m_scaleX;
2194  const double yMin = m_minY - m_marginTop / m_scaleY;
2195  const double yMax = m_maxY + m_marginBottom / m_scaleY;
2196 
2197  if( m_desiredXmin < xMin )
2198  {
2199  double diff = xMin - m_desiredXmin;
2200  m_posX += diff;
2201  m_desiredXmax += diff;
2202  m_desiredXmin = xMin;
2203  }
2204 
2205  if( m_desiredXmax > xMax )
2206  {
2207  double diff = m_desiredXmax - xMax;
2208  m_posX -= diff;
2209  m_desiredXmin -= diff;
2210  m_desiredXmax = xMax;
2211  }
2212 
2213  if( m_desiredYmin < yMin )
2214  {
2215  double diff = yMin - m_desiredYmin;
2216  m_posY += diff;
2217  m_desiredYmax += diff;
2218  m_desiredYmin = yMin;
2219  }
2220 
2221  if( m_desiredYmax > yMax )
2222  {
2223  double diff = m_desiredYmax - yMax;
2224  m_posY -= diff;
2225  m_desiredYmin -= diff;
2226  m_desiredYmax = yMax;
2227  }
2228 }
int m_marginRight
Definition: mathplot.h:1521
int m_marginLeft
Definition: mathplot.h:1521
double m_desiredXmax
Definition: mathplot.h:1519
double m_scaleY
Definition: mathplot.h:1508
double m_posX
Definition: mathplot.h:1509
double m_minY
Definition: mathplot.h:1505
double m_scaleX
Definition: mathplot.h:1507
double m_desiredYmax
Definition: mathplot.h:1519
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1519
double m_posY
Definition: mathplot.h:1510
int m_marginTop
Definition: mathplot.h:1521
double m_minX
Definition: mathplot.h:1503
double m_desiredYmin
Definition: mathplot.h:1519
int m_marginBottom
Definition: mathplot.h:1521
bool m_enableLimitedView
Definition: mathplot.h:1529
double m_maxX
Definition: mathplot.h:1504
double m_maxY
Definition: mathplot.h:1506

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

1464  {
1465  return !( m_enableLimitedView
1466  && (desiredMax > m_maxX - m_marginRight / m_scaleX
1467  || desiredMin < m_minX - m_marginLeft / m_scaleX) );
1468  }
int m_marginRight
Definition: mathplot.h:1521
int m_marginLeft
Definition: mathplot.h:1521
double m_scaleX
Definition: mathplot.h:1507
double m_minX
Definition: mathplot.h:1503
bool m_enableLimitedView
Definition: mathplot.h:1529
double m_maxX
Definition: mathplot.h:1504

Referenced by mpWindow::ZoomOut().

◆ CheckYLimits()

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

Definition at line 1470 of file mathplot.h.

1471  {
1472  return !( m_enableLimitedView
1473  && (desiredMax > m_maxY + m_marginBottom / m_scaleY
1474  || desiredMin < m_minY + m_marginTop / m_scaleY) );
1475  }
double m_scaleY
Definition: mathplot.h:1508
double m_minY
Definition: mathplot.h:1505
int m_marginTop
Definition: mathplot.h:1521
int m_marginBottom
Definition: mathplot.h:1521
bool m_enableLimitedView
Definition: mathplot.h:1529
double m_maxY
Definition: mathplot.h:1506

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

1288 { return m_layers.size(); };
wxLayerList m_layers
Definition: mathplot.h:1495

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

3020 {
3021  // wxNode *node = m_layers.GetFirst();
3022  unsigned int layerNo = 0;
3023 
3024  for( wxLayerList::iterator li = m_layers.begin(); li != m_layers.end(); li++ ) // while(node)
3025  {
3026  if( (*li)->HasBBox() )
3027  layerNo++;
3028 
3029  // node = node->GetNext();
3030  }
3031 
3032  ;
3033  return layerNo;
3034 }
wxLayerList m_layers
Definition: mathplot.h:1495

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

2533 {
2534  while( m_layers.size()>0 )
2535  {
2536  // Also delete the object?
2537  if( alsoDeleteObject )
2538  delete m_layers[0];
2539 
2540  m_layers.erase( m_layers.begin() ); // this deleted the reference only
2541  }
2542 
2543  if( refreshDisplay )
2544  UpdateAll();
2545 }
wxLayerList m_layers
Definition: mathplot.h:1495
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836

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

Referenced by mpWindow::~mpWindow().

◆ DeleteAllTraces()

void SIM_PLOT_PANEL::DeleteAllTraces ( )

Definition at line 582 of file sim_plot_panel.cpp.

583 {
584  for( auto& t : m_traces )
585  {
586  DeleteTrace( t.first );
587  }
588 
589  m_colorIdx = 0;
590  m_traces.clear();
591 }
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 560 of file sim_plot_panel.cpp.

561 {
562  auto it = m_traces.find( aName );
563 
564  if( it != m_traces.end() )
565  {
566  TRACE* trace = it->second;
567  m_traces.erase( it );
568 
569  if( CURSOR* cursor = trace->GetCursor() )
570  DelLayer( cursor, true );
571 
572  DelLayer( trace, true, true );
573  ResetScales();
574 
575  return true;
576  }
577 
578  return false;
579 }
bool DelLayer(mpLayer *layer, bool alsoDeleteObject=false, bool refreshDisplay=true)
Remove a plot layer from the canvas.
Definition: mathplot.cpp:2505
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 2505 of file mathplot.cpp.

2508 {
2509  wxLayerList::iterator layIt;
2510 
2511  for( layIt = m_layers.begin(); layIt != m_layers.end(); layIt++ )
2512  {
2513  if( *layIt == layer )
2514  {
2515  // Also delete the object?
2516  if( alsoDeleteObject )
2517  delete *layIt;
2518 
2519  m_layers.erase( layIt ); // this deleted the reference only
2520 
2521  if( refreshDisplay )
2522  UpdateAll();
2523 
2524  return true;
2525  }
2526  }
2527 
2528  return false;
2529 }
wxLayerList m_layers
Definition: mathplot.h:1495
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836

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

2884 {
2885  if( orientation == wxVERTICAL )
2886  {
2887  // Y axis
2888  // Get top margin in coord units
2889  double topMargin = m_marginTop / m_scaleY;
2890  // Calculate maximum Y coord to be shown in the graph
2891  double maxY = m_desiredYmax > m_maxY ? m_desiredYmax : m_maxY;
2892  // Set new position
2893  SetPosY( ( maxY - (position / m_scaleY) ) + topMargin );
2894  }
2895  else
2896  {
2897  // X Axis
2898  // Get left margin in coord units
2899  double leftMargin = m_marginLeft / m_scaleX;
2900  // Calculate minimum X coord to be shown in the graph
2901  double minX = (m_desiredXmin < m_minX) ? m_desiredXmin : m_minX;
2902  // Set new position
2903  SetPosX( ( minX + (position / m_scaleX) ) - leftMargin );
2904  }
2905 }
int m_marginLeft
Definition: mathplot.h:1521
double m_scaleY
Definition: mathplot.h:1508
double m_scaleX
Definition: mathplot.h:1507
void SetPosX(double posX)
Set current view's X position and refresh display.
Definition: mathplot.h:1164
void SetPosY(double posY)
Set current view's Y position and refresh display.
Definition: mathplot.h:1169
double m_desiredYmax
Definition: mathplot.h:1519
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1519
int m_marginTop
Definition: mathplot.h:1521
double m_minX
Definition: mathplot.h:1503
double m_maxY
Definition: mathplot.h:1506

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

2106 {
2107  // Preserve the position of the clicked point:
2108  double staticX = p2x( staticXpixel );
2109 
2110  // Zoom in:
2112  // Adjust the new m_posx
2113  m_posX = staticX - (staticXpixel / m_scaleX);
2114  // Adjust desired
2117 #ifdef MATHPLOT_DO_LOGGING
2118  wxLogMessage(
2119  "mpWindow::DoZoomInXCalc() prior X coord: (%f), new X coord: (%f) SHOULD BE EQUAL!!",
2120  staticX, p2x( staticXpixel ) );
2121 #endif
2122 }
int m_marginRight
Definition: mathplot.h:1521
int m_marginLeft
Definition: mathplot.h:1521
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1187
double m_desiredXmax
Definition: mathplot.h:1519
double m_posX
Definition: mathplot.h:1509
double m_scaleX
Definition: mathplot.h:1507
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1519
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:1346
int m_scrX
Definition: mathplot.h:1511

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

2126 {
2127  // Preserve the position of the clicked point:
2128  double staticY = p2y( staticYpixel );
2129 
2130  // Zoom in:
2132  // Adjust the new m_posy:
2133  m_posY = staticY + (staticYpixel / m_scaleY);
2134  // Adjust desired
2137 #ifdef MATHPLOT_DO_LOGGING
2138  wxLogMessage(
2139  "mpWindow::DoZoomInYCalc() prior Y coord: (%f), new Y coord: (%f) SHOULD BE EQUAL!!",
2140  staticY, p2y( staticYpixel ) );
2141 #endif
2142 }
double m_scaleY
Definition: mathplot.h:1508
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1192
double m_desiredYmax
Definition: mathplot.h:1519
double m_posY
Definition: mathplot.h:1510
int m_marginTop
Definition: mathplot.h:1521
double m_desiredYmin
Definition: mathplot.h:1519
int m_marginBottom
Definition: mathplot.h:1521
int m_scrY
Definition: mathplot.h:1512
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:1346

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

2146 {
2147  // Preserve the position of the clicked point:
2148  double staticX = p2x( staticXpixel );
2149 
2150  // Zoom out:
2152  // Adjust the new m_posx/y:
2153  m_posX = staticX - (staticXpixel / m_scaleX);
2154  // Adjust desired
2157 #ifdef MATHPLOT_DO_LOGGING
2158  wxLogMessage(
2159  "mpWindow::DoZoomOutXCalc() prior X coord: (%f), new X coord: (%f) SHOULD BE EQUAL!!",
2160  staticX, p2x( staticXpixel ) );
2161 #endif
2162 }
int m_marginRight
Definition: mathplot.h:1521
int m_marginLeft
Definition: mathplot.h:1521
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1187
double m_desiredXmax
Definition: mathplot.h:1519
double m_posX
Definition: mathplot.h:1509
double m_scaleX
Definition: mathplot.h:1507
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1519
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:1346
int m_scrX
Definition: mathplot.h:1511

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

2166 {
2167  // Preserve the position of the clicked point:
2168  double staticY = p2y( staticYpixel );
2169 
2170  // Zoom out:
2172  // Adjust the new m_posx/y:
2173  m_posY = staticY + (staticYpixel / m_scaleY);
2174  // Adjust desired
2177 #ifdef MATHPLOT_DO_LOGGING
2178  wxLogMessage(
2179  "mpWindow::DoZoomOutYCalc() prior Y coord: (%f), new Y coord: (%f) SHOULD BE EQUAL!!",
2180  staticY, p2y( staticYpixel ) );
2181 #endif
2182 }
double m_scaleY
Definition: mathplot.h:1508
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1192
double m_desiredYmax
Definition: mathplot.h:1519
double m_posY
Definition: mathplot.h:1510
int m_marginTop
Definition: mathplot.h:1521
double m_desiredYmin
Definition: mathplot.h:1519
int m_marginBottom
Definition: mathplot.h:1521
int m_scrY
Definition: mathplot.h:1512
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:1346

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 602 of file sim_plot_panel.cpp.

603 {
604  TRACE* t = GetTrace( aName );
605 
606  if( t == nullptr || t->HasCursor() == aEnable )
607  return;
608 
609  if( aEnable )
610  {
611  CURSOR* c = new CURSOR( t );
612  int plotCenter = GetMarginLeft() + ( GetXScreen() - GetMarginLeft() - GetMarginRight() ) / 2;
613  c->SetX( plotCenter );
614  t->SetCursor( c );
615  AddLayer( c );
616  }
617  else
618  {
619  CURSOR* c = t->GetCursor();
620  t->SetCursor( NULL );
621  DelLayer( c, true );
622  }
623 
624  // Notify the parent window about the changes
625  wxQueueEvent( GetParent(), new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
626 }
bool HasCursor() const
bool DelLayer(mpLayer *layer, bool alsoDeleteObject=false, bool refreshDisplay=true)
Remove a plot layer from the canvas.
Definition: mathplot.cpp:2505
int GetXScreen(void) const
Definition: mathplot.h:1134
bool AddLayer(mpLayer *layer, bool refreshDisplay=true)
Add a plot layer to the canvas.
Definition: mathplot.cpp:2488
TRACE * GetTrace(const wxString &aName) const
#define NULL
int GetMarginRight()
Definition: mathplot.h:1368
int GetMarginLeft()
Definition: mathplot.h:1372
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(), NULL, 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 1207 of file mathplot.h.

1207 { m_enableDoubleBuffer = enabled; }
bool m_enableDoubleBuffer
Definition: mathplot.h:1526

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

1211 { m_enableMouseNavigation = enabled; }
bool m_enableMouseNavigation
Definition: mathplot.h:1527

◆ EnableMouseWheelPan()

void mpWindow::EnableMouseWheelPan ( bool  enabled)
inlineinherited

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

Definition at line 1215 of file mathplot.h.

1215 { m_enableMouseWheelPan = enabled; }
bool m_enableMouseWheelPan
Definition: mathplot.h:1528

Referenced by SIM_PLOT_FRAME::NewPlotPanel().

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

2015 {
2016  if( UpdateBBox() )
2017  Fit( m_minX, m_maxX, m_minY, m_maxY );
2018 }
double m_minY
Definition: mathplot.h:1505
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:2014
double m_minX
Definition: mathplot.h:1503
virtual bool UpdateBBox()
Recalculate global layer bounding box, and save it in m_minX,...
Definition: mathplot.cpp:2728
double m_maxX
Definition: mathplot.h:1504
double m_maxY
Definition: mathplot.h:1506

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

2024 {
2025  // Save desired borders:
2026  m_desiredXmin = xMin; m_desiredXmax = xMax;
2027  m_desiredYmin = yMin; m_desiredYmax = yMax;
2028 
2029  // Give a small margin to plot area
2030  double xExtra = fabs( xMax - xMin ) * 0.00;
2031  double yExtra = fabs( yMax - yMin ) * 0.03;
2032 
2033  xMin -= xExtra;
2034  xMax += xExtra;
2035  yMin -= yExtra;
2036  yMax += yExtra;
2037 
2038  if( printSizeX!=NULL && printSizeY!=NULL )
2039  {
2040  // Printer:
2041  m_scrX = *printSizeX;
2042  m_scrY = *printSizeY;
2043  }
2044  else
2045  {
2046  // Normal case (screen):
2047  GetClientSize( &m_scrX, &m_scrY );
2048  }
2049 
2050  double Ax, Ay;
2051 
2052  Ax = xMax - xMin;
2053  Ay = yMax - yMin;
2054 
2055  m_scaleX = (Ax!=0) ? (m_scrX - m_marginLeft - m_marginRight) / Ax : 1; // m_scaleX = (Ax!=0) ? m_scrX/Ax : 1;
2056  m_scaleY = (Ay!=0) ? (m_scrY - m_marginTop - m_marginBottom) / Ay : 1; // m_scaleY = (Ay!=0) ? m_scrY/Ay : 1;
2057 
2058  if( m_lockaspect )
2059  {
2060 #ifdef MATHPLOT_DO_LOGGING
2061  wxLogMessage( "mpWindow::Fit()(lock) m_scaleX=%f,m_scaleY=%f", m_scaleX, m_scaleY );
2062 #endif
2063  // Keep the lowest "scale" to fit the whole range required by that axis (to actually "fit"!):
2064  double s = m_scaleX < m_scaleY ? m_scaleX : m_scaleY;
2065  m_scaleX = s;
2066  m_scaleY = s;
2067  }
2068 
2069  // Adjusts corner coordinates: This should be simply:
2070  // m_posX = m_minX;
2071  // m_posY = m_maxY;
2072  // But account for centering if we have lock aspect:
2073  m_posX = (xMin + xMax) / 2 - ( (m_scrX - m_marginLeft - m_marginRight) / 2 + m_marginLeft ) /
2074  m_scaleX; // m_posX = (xMin+xMax)/2 - (m_scrX/2)/m_scaleX;
2075  // 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;
2076  m_posY = (yMin + yMax) / 2 + ( (m_scrY - m_marginTop - m_marginBottom) / 2 + m_marginTop ) /
2077  m_scaleY; // m_posY = (yMin+yMax)/2 + (m_scrY/2)/m_scaleY;
2078 
2079 #ifdef MATHPLOT_DO_LOGGING
2080  wxLogMessage(
2081  "mpWindow::Fit() m_desiredXmin=%f m_desiredXmax=%f m_desiredYmin=%f m_desiredYmax=%f",
2082  xMin,
2083  xMax,
2084  yMin,
2085  yMax );
2086  wxLogMessage(
2087  "mpWindow::Fit() m_scaleX = %f , m_scrX = %d,m_scrY=%d, Ax=%f, Ay=%f, m_posX=%f, m_posY=%f",
2088  m_scaleX,
2089  m_scrX,
2090  m_scrY,
2091  Ax,
2092  Ay,
2093  m_posX,
2094  m_posY );
2095 #endif
2096 
2097  // It is VERY IMPORTANT to DO NOT call Refresh if we are drawing to the printer!!
2098  // Otherwise, the DC dimensions will be those of the window instead of the printer device
2099  if( printSizeX==NULL || printSizeY==NULL )
2100  UpdateAll();
2101 }
int m_marginRight
Definition: mathplot.h:1521
int m_marginLeft
Definition: mathplot.h:1521
double m_desiredXmax
Definition: mathplot.h:1519
double m_scaleY
Definition: mathplot.h:1508
double m_posX
Definition: mathplot.h:1509
double m_scaleX
Definition: mathplot.h:1507
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836
#define NULL
double m_desiredYmax
Definition: mathplot.h:1519
bool m_lockaspect
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:1519
double m_posY
Definition: mathplot.h:1510
int m_marginTop
Definition: mathplot.h:1521
double m_desiredYmin
Definition: mathplot.h:1519
int m_marginBottom
Definition: mathplot.h:1521
int m_scrY
Definition: mathplot.h:1512
int m_scrX
Definition: mathplot.h:1511

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, NULL, 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

Definition at line 645 of file sim_plot_panel.cpp.

646 {
650 
651  // const unsigned long colors[] = { 0x0000ff, 0x00ff00, 0xff0000, 0x00ffff, 0xff00ff, 0xffff000, 0xffffff };
652 
653  const unsigned long colors[] = { 0xE41A1C, 0x377EB8, 0x4DAF4A, 0x984EA3, 0xFF7F00, 0xFFFF33, 0xA65628, 0xF781BF,
654  0x66C2A5, 0xFC8D62, 0x8DA0CB, 0xE78AC3, 0xA6D854, 0xFFD92F, 0xE5C494, 0xB3B3B3 };
655 
656  //const unsigned long colors[] = { 0xe3cea6, 0xb4781f, 0x8adfb2, 0x2ca033, 0x999afb, 0x1c1ae3, 0x6fbffd, 0x007fff, 0xd6b2ca, 0x9a3d6a };
657 
658  // hls
659  //const unsigned long colors[] = { 0x0f1689, 0x0f7289, 0x35890f, 0x0f8945, 0x89260f, 0x890f53, 0x89820f, 0x630f89 };
660 
661  // pastels, good for dark background
662  //const unsigned long colors[] = { 0x2fd8fe, 0x628dfa, 0x53d8a6, 0xa5c266, 0xb3b3b3, 0x94c3e4, 0xca9f8d, 0xac680e };
663 
664  const unsigned int colorCount = sizeof(colors) / sizeof(unsigned long);
665 
666  for( int i = 0; i < (int)colorCount - 1; i++ )
667  {
668  const wxColour color = wxColour( colors[i] );
669  bool hasColor = false;
670  for( auto& t : m_traces )
671  {
672  TRACE* trace = t.second;
673  if( trace->GetTraceColour() == color )
674  {
675  hasColor = true;
676  break;
677  }
678  }
679  if( !hasColor )
680  return color;
681  }
682  return wxColour( colors[m_traces.size() % colorCount] );
683 }
int color
Definition: DXF_plotter.cpp:61
wxColour GetTraceColour()
std::map< wxString, TRACE * > m_traces
static VRML_COLOR colors[VRML_COLOR_LAST]

References color, colors, TRACE::GetTraceColour(), and m_traces.

Referenced by AddTrace().

◆ GetAxesColour()

const wxColour& mpWindow::GetAxesColour ( )
inlineinherited

Get axes draw colour.

Returns
reference to axis colour used in theme

Definition at line 1421 of file mathplot.h.

1421 { return m_axColour; };
wxColour m_axColour
Definition: mathplot.h:1501

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

3058 {
3059  bbox[0] = m_minX;
3060  bbox[1] = m_maxX;
3061  bbox[2] = m_minY;
3062  bbox[3] = m_maxY;
3063 }
double m_minY
Definition: mathplot.h:1505
double m_minX
Definition: mathplot.h:1503
double m_maxX
Definition: mathplot.h:1504
double m_maxY
Definition: mathplot.h:1506

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

1307 { return m_desiredXmax; }
double m_desiredXmax
Definition: mathplot.h:1519

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

1301 { 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:1519

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

1319 { return m_desiredYmax; }
double m_desiredYmax
Definition: mathplot.h:1519

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

1313 { return m_desiredYmin; }
double m_desiredYmin
Definition: mathplot.h:1519

Referenced by mpPrintout::OnPrintPage().

◆ GetDottedCurrentPhase()

bool SIM_PLOT_PANEL::GetDottedCurrentPhase ( ) const
inline

Definition at line 257 of file sim_plot_panel.h.

258  {
259  return m_dotted_cp;
260  }

References m_dotted_cp.

Referenced by SIM_PLOT_FRAME::menuShowDotted(), and SIM_PLOT_FRAME::menuShowDottedUpdate().

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

3038 {
3039  if( ( position >= (int) m_layers.size() ) || position < 0 )
3040  return NULL;
3041 
3042  return m_layers[position];
3043 }
wxLayerList m_layers
Definition: mathplot.h:1495
#define NULL

References mpWindow::m_layers, and NULL.

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

3047 {
3048  for( wxLayerList::iterator it = m_layers.begin(); it!=m_layers.end(); it++ )
3049  if( !(*it)->GetName().Cmp( name ) )
3050  return *it;
3051 
3052 
3053  return NULL; // Not found
3054 }
wxLayerList m_layers
Definition: mathplot.h:1495
#define NULL
const char * name
Definition: DXF_plotter.cpp:60

References mpWindow::m_layers, name, and NULL.

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

1332 { return m_enableScrollBars; };
bool m_enableScrollBars
Definition: mathplot.h:1532

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

1058 { return &m_popmenu; }
wxMenu m_popmenu
Definition: mathplot.h:1496

◆ GetPosX()

double mpWindow::GetPosX ( void  ) const
inlineinherited

Definition at line 1118 of file mathplot.h.

1118 { return m_posX; }
double m_posX
Definition: mathplot.h:1509

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

◆ GetPosY()

double mpWindow::GetPosY ( void  ) const
inlineinherited

Definition at line 1125 of file mathplot.h.

1125 { return m_posY; }
double m_posY
Definition: mathplot.h:1510

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

◆ GetScaleX()

double mpWindow::GetScaleX ( void  ) const
inlineinherited

Definition at line 1104 of file mathplot.h.

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

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

◆ GetScaleY()

double mpWindow::GetScaleY ( void  ) const
inlineinherited

Definition at line 1111 of file mathplot.h.

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

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

1133 { return m_scrX; }
int m_scrX
Definition: mathplot.h:1511

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

1142 { return m_scrY; }
int m_scrY
Definition: mathplot.h:1512

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  }
#define NULL
std::map< wxString, TRACE * > m_traces

References m_traces, and NULL.

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

1117 { return m_posX; }
double m_posX
Definition: mathplot.h:1509

◆ GetXscl()

double mpWindow::GetXscl ( )
inlineinherited

Get current view's X scale.

See rules for coordinate transformation

Returns
Scale

Definition at line 1103 of file mathplot.h.

1103 { return m_scaleX; }
double m_scaleX
Definition: mathplot.h:1507

◆ GetXScreen()

int mpWindow::GetXScreen ( void  ) const
inlineinherited

Definition at line 1134 of file mathplot.h.

1134 { return m_scrX; }
int m_scrX
Definition: mathplot.h:1511

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

1124 { return m_posY; }
double m_posY
Definition: mathplot.h:1510

◆ GetYscl()

double mpWindow::GetYscl ( ) const
inlineinherited

Get current view's Y scale.

See rules for coordinate transformation

Returns
Scale

Definition at line 1110 of file mathplot.h.

1110 { return m_scaleY; }
double m_scaleY
Definition: mathplot.h:1508

◆ GetYScreen()

int mpWindow::GetYScreen ( void  ) const
inlineinherited

Definition at line 1143 of file mathplot.h.

1143 { return m_scrY; }
int m_scrY
Definition: mathplot.h:1512

◆ HasCursorEnabled()

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

Returns true if the trace has cursor shown.

Definition at line 594 of file sim_plot_panel.cpp.

595 {
596  TRACE* t = GetTrace( aName );
597 
598  return t ? t->HasCursor() : false;
599 }
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 1228 of file mathplot.h.

1228 { return m_lockaspect; }
bool m_lockaspect
Definition: mathplot.h:1497

◆ 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:972
bool GetTicks()
Get X axis ticks or grid.
Definition: mathplot.h:718

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

3134 {
3135  wxLayerList::iterator li;
3136 
3137  for( li = m_layers.begin(); li != m_layers.end(); li++ )
3138  {
3139 #ifdef MATHPLOT_DO_LOGGING
3140  wxLogMessage( "mpWindow::IsInsideInfoLayer() examinining layer = %p", (*li) );
3141 #endif // MATHPLOT_DO_LOGGING
3142 
3143  if( (*li)->IsInfo() )
3144  {
3145  mpInfoLayer* tmpLyr = (mpInfoLayer*) (*li);
3146 #ifdef MATHPLOT_DO_LOGGING
3147  wxLogMessage( "mpWindow::IsInsideInfoLayer() layer = %p", (*li) );
3148 #endif // MATHPLOT_DO_LOGGING
3149 
3150  if( tmpLyr->Inside( point ) )
3151  {
3152  return tmpLyr;
3153  }
3154  }
3155  }
3156 
3157  return NULL;
3158 }
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:1495
#define NULL
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(), mpWindow::m_layers, and NULL.

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

3174 {
3175  mpLayer* lx = GetLayerByName( name );
3176 
3177  return (lx) ? lx->IsVisible() : false;
3178 }
bool IsVisible()
Checks whether the layer is visible or not.
Definition: mathplot.h:297
mpLayer * GetLayerByName(const wxString &name)
Definition: mathplot.cpp:3046
const char * name
Definition: DXF_plotter.cpp:60

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

3194 {
3195  mpLayer* lx = GetLayer( position );
3196 
3197  return (lx) ? lx->IsVisible() : false;
3198 }
mpLayer * GetLayer(int position)
Definition: mathplot.cpp:3037
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 454 of file sim_plot_panel.cpp.

455 {
456  switch( aSimType )
457  {
458  case ST_AC:
459  case ST_DC:
460  case ST_TRANSIENT:
461  return true;
462 
463  default:
464  return false;
465  }
466 }

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

1425  {
1426  m_enableLimitedView = aEnable;
1427  }
bool m_enableLimitedView
Definition: mathplot.h:1529

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

2427 {
2428  m_lockaspect = enable;
2429  m_popmenu.Check( mpID_LOCKASPECT, enable );
2430 
2431  // Try to fit again with the new config:
2433 }
double m_desiredXmax
Definition: mathplot.h:1519
double m_desiredYmax
Definition: mathplot.h:1519
bool m_lockaspect
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:1519
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:2014
double m_desiredYmin
Definition: mathplot.h:1519
wxMenu m_popmenu
Definition: mathplot.h:1496

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

2457 {
2458  GetClientSize( &m_scrX, &m_scrY );
2459  int centerX = (m_scrX - m_marginLeft - m_marginRight) / 2; // + m_marginLeft; // c.x = m_scrX/2;
2460  int centerY = (m_scrY - m_marginTop - m_marginBottom) / 2; // - m_marginTop; // c.y = m_scrY/2;
2461  SetPos( p2x( m_clickedX - centerX ), p2y( m_clickedY - centerY ) );
2462  // 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);
2463 }
int m_marginRight
Definition: mathplot.h:1521
int m_marginLeft
Definition: mathplot.h:1521
int m_clickedX
Definition: mathplot.h:1513
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1187
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1192
int m_marginTop
Definition: mathplot.h:1521
void SetPos(double posX, double posY)
Set current view's X and Y position and refresh display.
Definition: mathplot.h:1175
int m_clickedY
Definition: mathplot.h:1514
int m_marginBottom
Definition: mathplot.h:1521
int m_scrY
Definition: mathplot.h:1512
int m_scrX
Definition: mathplot.h:1511

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

2451 {
2452  Fit();
2453 }
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:2014

References mpWindow::Fit().

◆ OnLockAspect()

void mpWindow::OnLockAspect ( wxCommandEvent &  event)
protectedinherited

Definition at line 2444 of file mathplot.cpp.

2445 {
2447 }
bool m_lockaspect
Definition: mathplot.h:1497
void LockAspect(bool enable=TRUE)
Enable or disable X/Y scale aspect locking for the view.
Definition: mathplot.cpp:2426

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

◆ OnMagnify()

void mpWindow::OnMagnify ( wxMouseEvent &  event)
protectedinherited

◆ OnMouseLeftDown()

void mpWindow::OnMouseLeftDown ( wxMouseEvent &  event)
protectedinherited

Definition at line 1961 of file mathplot.cpp.

1962 {
1963  m_mouseLClick.x = event.GetX();
1964  m_mouseLClick.y = event.GetY();
1965  m_zooming = true;
1966 #ifdef MATHPLOT_DO_LOGGING
1967  wxLogMessage( "mpWindow::OnMouseLeftDown() X = %d , Y = %d", event.GetX(), event.GetY() ); /*m_mouseLClick.x, m_mouseLClick.y);*/
1968 #endif
1969  wxPoint pointClicked = event.GetPosition();
1970  m_movingInfoLayer = IsInsideInfoLayer( pointClicked );
1971 
1972  if( m_movingInfoLayer != NULL )
1973  {
1974 #ifdef MATHPLOT_DO_LOGGING
1975  wxLogMessage( "mpWindow::OnMouseLeftDown() started moving layer %lx",
1976  (long int) m_movingInfoLayer ); /*m_mouseLClick.x, m_mouseLClick.y);*/
1977 #endif
1978  }
1979 
1980  event.Skip();
1981 }
bool m_zooming
Definition: mathplot.h:1535
mpInfoLayer * IsInsideInfoLayer(wxPoint &point)
Check if a given point is inside the area of a mpInfoLayer and eventually returns its pointer.
Definition: mathplot.cpp:3133
wxPoint m_mouseLClick
Definition: mathplot.h:1531
#define NULL
mpInfoLayer * m_movingInfoLayer
Definition: mathplot.h:1534

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

◆ OnMouseLeftRelease()

void mpWindow::OnMouseLeftRelease ( wxMouseEvent &  event)
protectedinherited

Definition at line 1984 of file mathplot.cpp.

1985 {
1986  wxPoint release( event.GetX(), event.GetY() );
1988 
1989  m_zooming = false;
1990 
1991  if( m_movingInfoLayer != NULL )
1992  {
1995  }
1996  else
1997  {
1998  if( release != press )
1999  {
2000  ZoomRect( press, release );
2001  } /*else {
2002  * if (m_coordTooltip) {
2003  * wxString toolTipContent;
2004  * toolTipContent.Printf( "X = %f\nY = %f", p2x(event.GetX()), p2y(event.GetY()));
2005  * SetToolTip(toolTipContent);
2006  * }
2007  * } */
2008  }
2009 
2010  event.Skip();
2011 }
bool m_zooming
Definition: mathplot.h:1535
wxPoint m_mouseLClick
Definition: mathplot.h:1531
#define NULL
void ZoomRect(wxPoint p0, wxPoint p1)
Zoom view fitting given coordinates to the window (p0 and p1 do not need to be in any specific order)
Definition: mathplot.cpp:2403
mpInfoLayer * m_movingInfoLayer
Definition: mathplot.h:1534
virtual void UpdateReference()
Updates the rectangle reference point.
Definition: mathplot.cpp:148

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

◆ OnMouseMiddleDown()

void mpWindow::OnMouseMiddleDown ( wxMouseEvent &  event)
protectedinherited

Definition at line 1780 of file mathplot.cpp.

1781 {
1782  m_mouseMClick.x = event.GetX();
1783  m_mouseMClick.y = event.GetY();
1784 }
wxPoint m_mouseMClick
Definition: mathplot.h:1530

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

◆ OnMouseMove()

void mpWindow::OnMouseMove ( wxMouseEvent &  event)
protectedinherited

Definition at line 1861 of file mathplot.cpp.

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

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

◆ OnMouseWheel()

void mpWindow::OnMouseWheel ( wxMouseEvent &  event)
protectedinherited

Definition at line 1806 of file mathplot.cpp.

1807 {
1809  {
1810  event.Skip();
1811  return;
1812  }
1813 
1814  int change = event.GetWheelRotation();
1815  const int axis = event.GetWheelAxis();
1816  double changeUnitsX = change / m_scaleX;
1817  double changeUnitsY = change / m_scaleY;
1818 
1819  if( ( !m_enableMouseWheelPan && ( event.ControlDown() || event.ShiftDown() ) )
1820  || ( m_enableMouseWheelPan && !event.ControlDown() ) )
1821  {
1822  // Scrolling
1823  if( m_enableMouseWheelPan )
1824  {
1825  if( axis == wxMOUSE_WHEEL_HORIZONTAL || event.ShiftDown() )
1826  SetXView( m_posX + changeUnitsX, m_desiredXmax + changeUnitsX,
1827  m_desiredXmin + changeUnitsX );
1828  else
1829  SetYView( m_posY + changeUnitsY, m_desiredYmax + changeUnitsY,
1830  m_desiredYmin + changeUnitsY );
1831  }
1832  else
1833  {
1834  if( event.ControlDown() )
1835  SetXView( m_posX + changeUnitsX, m_desiredXmax + changeUnitsX,
1836  m_desiredXmin + changeUnitsX );
1837  else
1838  SetYView( m_posY + changeUnitsY, m_desiredYmax + changeUnitsY,
1839  m_desiredYmin + changeUnitsY );
1840  }
1841 
1842  UpdateAll();
1843  }
1844  else
1845  {
1846  // zoom in/out
1847  wxPoint clickPt( event.GetX(), event.GetY() );
1848 
1849  if( event.GetWheelRotation() > 0 )
1850  ZoomIn( clickPt );
1851  else
1852  ZoomOut( clickPt );
1853 
1854  return;
1855  }
1856 }
void ZoomOut(const wxPoint &centerPoint=wxDefaultPosition)
Zoom out current view and refresh display.
Definition: mathplot.cpp:2322
virtual bool SetYView(double pos, double desiredMax, double desiredMin)
Applies new Y view coordinates depending on the settings.
Definition: mathplot.cpp:2245
double m_desiredXmax
Definition: mathplot.h:1519
double m_scaleY
Definition: mathplot.h:1508
bool m_enableMouseNavigation
Definition: mathplot.h:1527
double m_posX
Definition: mathplot.h:1509
bool m_enableMouseWheelPan
Definition: mathplot.h:1528
double m_scaleX
Definition: mathplot.h:1507
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836
double m_desiredYmax
Definition: mathplot.h:1519
void ZoomIn(const wxPoint &centerPoint=wxDefaultPosition)
Zoom into current view and refresh display.
Definition: mathplot.cpp:2259
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1519
double m_posY
Definition: mathplot.h:1510
double m_desiredYmin
Definition: mathplot.h:1519
virtual bool SetXView(double pos, double desiredMax, double desiredMin)
Applies new X view coordinates depending on the settings.
Definition: mathplot.cpp:2231

References mpWindow::m_desiredXmax, mpWindow::m_desiredXmin, mpWindow::m_desiredYmax, mpWindow::m_desiredYmin, mpWindow::m_enableMouseNavigation, mpWindow::m_enableMouseWheelPan, 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 2548 of file mathplot.cpp.

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

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

2995 {
2996  int scrollOrientation = event.GetOrientation();
2997  // Get thumb size
2998  int thumbSize = GetScrollThumb( scrollOrientation );
2999  // Get scroll range
3000  int scrollRange = GetScrollRange( scrollOrientation );
3001 
3002  DoScrollCalc( scrollRange - thumbSize, scrollOrientation );
3003 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2883

References mpWindow::DoScrollCalc().

◆ OnScrollLineDown()

void mpWindow::OnScrollLineDown ( wxScrollWinEvent &  event)
protectedinherited

Definition at line 2968 of file mathplot.cpp.

2969 {
2970  int scrollOrientation = event.GetOrientation();
2971  // Get position before page up
2972  int position = GetScrollPos( scrollOrientation );
2973  // Get thumb size
2974  int thumbSize = GetScrollThumb( scrollOrientation );
2975  // Get scroll range
2976  int scrollRange = GetScrollRange( scrollOrientation );
2977 
2978  // Need to adjust position by a page
2979  position += mpSCROLL_NUM_PIXELS_PER_LINE;
2980 
2981  if( position > (scrollRange - thumbSize) )
2982  position = scrollRange - thumbSize;
2983 
2984  DoScrollCalc( position, scrollOrientation );
2985 }
#define mpSCROLL_NUM_PIXELS_PER_LINE
Definition: mathplot.cpp:61
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2883

References mpWindow::DoScrollCalc(), and mpSCROLL_NUM_PIXELS_PER_LINE.

◆ OnScrollLineUp()

void mpWindow::OnScrollLineUp ( wxScrollWinEvent &  event)
protectedinherited

Definition at line 2952 of file mathplot.cpp.

2953 {
2954  int scrollOrientation = event.GetOrientation();
2955  // Get position before page up
2956  int position = GetScrollPos( scrollOrientation );
2957 
2958  // Need to adjust position by a line
2959  position -= mpSCROLL_NUM_PIXELS_PER_LINE;
2960 
2961  if( position < 0 )
2962  position = 0;
2963 
2964  DoScrollCalc( position, scrollOrientation );
2965 }
#define mpSCROLL_NUM_PIXELS_PER_LINE
Definition: mathplot.cpp:61
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2883

References mpWindow::DoScrollCalc(), and mpSCROLL_NUM_PIXELS_PER_LINE.

◆ OnScrollPageDown()

void mpWindow::OnScrollPageDown ( wxScrollWinEvent &  event)
protectedinherited

Definition at line 2932 of file mathplot.cpp.

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

References mpWindow::DoScrollCalc().

◆ OnScrollPageUp()

void mpWindow::OnScrollPageUp ( wxScrollWinEvent &  event)
protectedinherited

Definition at line 2914 of file mathplot.cpp.

2915 {
2916  int scrollOrientation = event.GetOrientation();
2917  // Get position before page up
2918  int position = GetScrollPos( scrollOrientation );
2919  // Get thumb size
2920  int thumbSize = GetScrollThumb( scrollOrientation );
2921 
2922  // Need to adjust position by a page
2923  position -= thumbSize;
2924 
2925  if( position < 0 )
2926  position = 0;
2927 
2928  DoScrollCalc( position, scrollOrientation );
2929 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2883

References mpWindow::DoScrollCalc().

◆ OnScrollThumbTrack()

void mpWindow::OnScrollThumbTrack ( wxScrollWinEvent &  event)
protectedinherited

Definition at line 2908 of file mathplot.cpp.

2909 {
2910  DoScrollCalc( event.GetPosition(), event.GetOrientation() );
2911 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2883

References mpWindow::DoScrollCalc().

◆ OnScrollTop()

void mpWindow::OnScrollTop ( wxScrollWinEvent &  event)
protectedinherited

Definition at line 2988 of file mathplot.cpp.

2989 {
2990  DoScrollCalc( 0, event.GetOrientation() );
2991 }
void DoScrollCalc(const int position, const int orientation)
Definition: mathplot.cpp:2883

References mpWindow::DoScrollCalc().

◆ OnShowPopupMenu()

void mpWindow::OnShowPopupMenu ( wxMouseEvent &  event)
protectedinherited

Definition at line 2436 of file mathplot.cpp.

2437 {
2438  m_clickedX = event.GetX();
2439  m_clickedY = event.GetY();
2440  PopupMenu( &m_popmenu, event.GetX(), event.GetY() );
2441 }
int m_clickedX
Definition: mathplot.h:1513
int m_clickedY
Definition: mathplot.h:1514
wxMenu m_popmenu
Definition: mathplot.h:1496

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

◆ OnSize()

void mpWindow::OnSize ( wxSizeEvent &  event)
protectedinherited

Definition at line 2478 of file mathplot.cpp.

2479 {
2480  // Try to fit again with the new window size:
2482 #ifdef MATHPLOT_DO_LOGGING
2483  wxLogMessage( "mpWindow::OnSize() m_scrX = %d, m_scrY = %d", m_scrX, m_scrY );
2484 #endif // MATHPLOT_DO_LOGGING
2485 }
double m_desiredXmax
Definition: mathplot.h:1519
double m_desiredYmax
Definition: mathplot.h:1519
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1519
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:2014
double m_desiredYmin
Definition: mathplot.h:1519
int m_scrY
Definition: mathplot.h:1512
int m_scrX
Definition: mathplot.h:1511

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

2467 {
2469 }
wxPoint m_mouseMClick
Definition: mathplot.h:1530
void ZoomIn(const wxPoint &centerPoint=wxDefaultPosition)
Zoom into current view and refresh display.
Definition: mathplot.cpp:2259

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

◆ OnZoomOut()

void mpWindow::OnZoomOut ( wxCommandEvent &  event)
protectedinherited

Definition at line 2472 of file mathplot.cpp.

2473 {
2474  ZoomOut();
2475 }
void ZoomOut(const wxPoint &centerPoint=wxDefaultPosition)
Zoom out current view and refresh display.
Definition: mathplot.cpp:2322

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

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

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

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

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 629 of file sim_plot_panel.cpp.

630 {
631  if( m_axis_x )
633 
634  if( m_axis_y1 )
636 
637  if( m_axis_y2 )
639 
640  for( auto t : m_traces )
641  t.second->UpdateScales();
642 }
mpScaleY * m_axis_y1
mpScaleXBase * m_axis_x
void ResetDataRange()
Definition: mathplot.h:758
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 3066 of file mathplot.cpp.

3068 {
3069  int sizeX, sizeY;
3070  int bk_scrX, bk_scrY;
3071 
3072  if( imageSize == wxDefaultSize )
3073  {
3074  sizeX = m_scrX;
3075  sizeY = m_scrY;
3076  }
3077  else
3078  {
3079  sizeX = imageSize.x;
3080  sizeY = imageSize.y;
3081  bk_scrX = m_scrX;
3082  bk_scrY = m_scrY;
3083  SetScr( sizeX, sizeY );
3084  }
3085 
3086  wxBitmap screenBuffer( sizeX, sizeY );
3087  wxMemoryDC screenDC;
3088  screenDC.SelectObject( screenBuffer );
3089  screenDC.SetPen( *wxWHITE_PEN );
3090  screenDC.SetTextForeground( m_fgColour );
3091  wxBrush brush( GetBackgroundColour() );
3092  screenDC.SetBrush( brush );
3093  screenDC.DrawRectangle( 0, 0, sizeX, sizeY );
3094 
3095  if( fit )
3096  {
3097  Fit( m_minX, m_maxX, m_minY, m_maxY, &sizeX, &sizeY );
3098  }
3099  else
3100  {
3102  }
3103 
3104  // Draw all the layers:
3105  wxLayerList::iterator li;
3106 
3107  for( li = m_layers.begin(); li != m_layers.end(); li++ )
3108  (*li)->Plot( screenDC, *this );
3109 
3110  if( imageSize != wxDefaultSize )
3111  {
3112  // Restore dimensions
3113  SetScr( bk_scrX, bk_scrY );
3114  Fit( m_desiredXmin, m_desiredXmax, m_desiredYmin, m_desiredYmax, &bk_scrX, &bk_scrY );
3115  UpdateAll();
3116  }
3117 
3118  // Once drawing is complete, actually save screen shot
3119  wxImage screenImage = screenBuffer.ConvertToImage();
3120  return screenImage.SaveFile( filename, type );
3121 }
double m_desiredXmax
Definition: mathplot.h:1519
double m_minY
Definition: mathplot.h:1505
wxLayerList m_layers
Definition: mathplot.h:1495
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836
double m_desiredYmax
Definition: mathplot.h:1519
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1519
wxColour m_fgColour
Definition: mathplot.h:1500
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:2014
double m_minX
Definition: mathplot.h:1503
double m_desiredYmin
Definition: mathplot.h:1519
void SetScr(int scrX, int scrY)
Set current view's dimensions in device context units.
Definition: mathplot.h:1182
int m_scrY
Definition: mathplot.h:1512
double m_maxX
Definition: mathplot.h:1504
int m_scrX
Definition: mathplot.h:1511
double m_maxY
Definition: mathplot.h:1506

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

3204 {
3205  SetBackgroundColour( bgColour );
3206  SetForegroundColour( drawColour );
3207  m_bgColour = bgColour;
3208  m_fgColour = drawColour;
3209  m_axColour = axesColour;
3210  // cycle between layers to set colours and properties to them
3211  wxLayerList::iterator li;
3212 
3213  for( li = m_layers.begin(); li != m_layers.end(); li++ )
3214  {
3215  if( (*li)->GetLayerType() == mpLAYER_AXIS )
3216  {
3217  wxPen axisPen = (*li)->GetPen(); // Get the old pen to modify only colour, not style or width
3218  axisPen.SetColour( axesColour );
3219  (*li)->SetPen( axisPen );
3220  }
3221 
3222  if( (*li)->GetLayerType() == mpLAYER_INFO )
3223  {
3224  wxPen infoPen = (*li)->GetPen(); // Get the old pen to modify only colour, not style or width
3225  infoPen.SetColour( drawColour );
3226  (*li)->SetPen( infoPen );
3227  }
3228  }
3229 }
wxColour m_axColour
Definition: mathplot.h:1501
wxLayerList m_layers
Definition: mathplot.h:1495
wxColour m_fgColour
Definition: mathplot.h:1500
wxColour m_bgColour
Definition: mathplot.h:1499

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

◆ SetDottedCurrentPhase()

void SIM_PLOT_PANEL::SetDottedCurrentPhase ( bool  aEnable)
inline

Definition at line 245 of file sim_plot_panel.h.

246  {
247  m_dotted_cp = aEnable;
248 
249  for( const auto& tr : m_traces )
250  {
251  UpdateTraceStyle( tr.second );
252  }
253 
254  UpdateAll();
255  }
void UpdateTraceStyle(TRACE *trace)
Update trace line style
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836
std::map< wxString, TRACE * > m_traces

References m_dotted_cp, m_traces, mpWindow::UpdateAll(), and UpdateTraceStyle().

Referenced by SIM_PLOT_FRAME::menuShowDotted().

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

3162 {
3163  mpLayer* lx = GetLayerByName( name );
3164 
3165  if( lx )
3166  {
3167  lx->SetVisible( viewable );
3168  UpdateAll();
3169  }
3170 }
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836
void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:301
mpLayer * GetLayerByName(const wxString &name)
Definition: mathplot.cpp:3046
const char * name
Definition: DXF_plotter.cpp:60

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

3182 {
3183  mpLayer* lx = GetLayer( position );
3184 
3185  if( lx )
3186  {
3187  lx->SetVisible( viewable );
3188  UpdateAll();
3189  }
3190 }
mpLayer * GetLayer(int position)
Definition: mathplot.cpp:3037
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836
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 1361 of file mathplot.h.

1361 { m_marginBottom = bottom; };
int m_marginBottom
Definition: mathplot.h:1521

◆ SetMarginLeft()

void mpWindow::SetMarginLeft ( int  left)
inlineinherited

Set the left margin.

Parameters
leftLeft Margin

Definition at line 1363 of file mathplot.h.

1363 { m_marginLeft = left; };
int m_marginLeft
Definition: mathplot.h:1521

◆ SetMarginRight()

void mpWindow::SetMarginRight ( int  right)
inlineinherited

Set the right margin.

Parameters
rightRight Margin

Definition at line 1359 of file mathplot.h.

1359 { m_marginRight = right; };
int m_marginRight
Definition: mathplot.h:1521

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

3125 {
3126  m_marginTop = top;
3127  m_marginRight = right;
3128  m_marginBottom = bottom;
3129  m_marginLeft = left;
3130 }
int m_marginRight
Definition: mathplot.h:1521
int m_marginLeft
Definition: mathplot.h:1521
int m_marginTop
Definition: mathplot.h:1521
int m_marginBottom
Definition: mathplot.h:1521

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

1357 { m_marginTop = top; };
int m_marginTop
Definition: mathplot.h:1521

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

2688 {
2689  // Temporary behaviour: always disable scrollbars
2690  m_enableScrollBars = status; // false;
2691 
2692  if( status == false )
2693  {
2694  SetScrollbar( wxHORIZONTAL, 0, 0, 0 );
2695  SetScrollbar( wxVERTICAL, 0, 0, 0 );
2696  }
2697 
2698  // else the scroll bars will be updated in UpdateAll();
2699  UpdateAll();
2700 
2701  // EnableScrolling(false, false);
2702  // m_enableScrollBars = status;
2703  // EnableScrolling(status, status);
2704  /* m_scroll.x = (int) floor((m_posX - m_minX)*m_scaleX);
2705  * m_scroll.y = (int) floor((m_posY - m_minY)*m_scaleY);*/
2706  // int scrollWidth = (int) floor((m_maxX - m_minX)*m_scaleX) - m_scrX;
2707  // int scrollHeight = (int) floor((m_minY - m_maxY)*m_scaleY) - m_scrY;
2708 
2710  // m_scroll.y = (int) floor((m_maxY - m_posY /*- m_minY*/)*m_scaleY);
2711  // int scrollWidth = (int) floor(((m_maxX - m_minX) - (m_desiredXmax - m_desiredXmin))*m_scaleX);
2712  // int scrollHeight = (int) floor(((m_maxY - m_minY) - (m_desiredYmax - m_desiredYmin))*m_scaleY);
2713  // #ifdef MATHPLOT_DO_LOGGING
2714  // wxLogMessage( "mpWindow::SetMPScrollbars() scrollWidth = %d, scrollHeight = %d", scrollWidth, scrollHeight);
2715  // #endif
2716  // if(status) {
2717  // SetScrollbars(1,
2718  // 1,
2719  // scrollWidth,
2720  // scrollHeight,
2721  // m_scroll.x,
2722  // m_scroll.y);
2724  // }
2725  // Refresh(false);*/
2726 }
bool m_enableScrollBars
Definition: mathplot.h:1532
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836

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

1175 { m_posX = posX; m_posY = posY; UpdateAll(); }
double m_posX
Definition: mathplot.h:1509
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836
double m_posY
Definition: mathplot.h:1510

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

1164 { m_posX = posX; UpdateAll(); }
double m_posX
Definition: mathplot.h:1509
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836

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

1169 { m_posY = posY; UpdateAll(); }
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836
double m_posY
Definition: mathplot.h:1510

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

3009 {
3010  if( scaleX!=0 )
3011  m_scaleX = scaleX;
3012 
3013  UpdateAll();
3014 }
double m_scaleX
Definition: mathplot.h:1507
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836

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

1154  {
1155  if( scaleY!=0 )
1156  m_scaleY = scaleY;
1157 
1158  UpdateAll();
1159  }
double m_scaleY
Definition: mathplot.h:1508
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836

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

1182 { m_scrX = scrX; m_scrY = scrY; }
int m_scrY
Definition: mathplot.h:1512
int m_scrX
Definition: mathplot.h:1511

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

2232 {
2233  // if(!CheckXLimits(desiredMax, desiredMin))
2234  // return false;
2235 
2236  m_posX = pos;
2237  m_desiredXmax = desiredMax;
2238  m_desiredXmin = desiredMin;
2240 
2241  return true;
2242 }
double m_desiredXmax
Definition: mathplot.h:1519
double m_posX
Definition: mathplot.h:1509
void AdjustLimitedView()
Definition: mathplot.cpp:2185
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1519

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

2246 {
2247  // if(!CheckYLimits(desiredMax, desiredMin))
2248  // return false;
2249 
2250  m_posY = pos;
2251  m_desiredYmax = desiredMax;
2252  m_desiredYmin = desiredMin;
2254 
2255  return true;
2256 }
double m_desiredYmax
Definition: mathplot.h:1519
void AdjustLimitedView()
Definition: mathplot.cpp:2185
double m_posY
Definition: mathplot.h:1510
double m_desiredYmin
Definition: mathplot.h:1519

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:2836
mpScaleY * m_axis_y2
void SetTicks(bool enable)
Set X axis ticks or grid.
Definition: mathplot.h:713
void SetTicks(bool ticks)
Set Y axis ticks or grid.
Definition: mathplot.h:968

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

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

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(), SetDottedCurrentPhase(), 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 2728 of file mathplot.cpp.

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

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

◆ UpdateTraceStyle()

void SIM_PLOT_PANEL::UpdateTraceStyle ( TRACE trace)

Update trace line style

Definition at line 469 of file sim_plot_panel.cpp.

470 {
471  int flags = trace->GetFlags();
472  wxPenStyle penStyle = ( ( flags & SPT_AC_PHASE || flags & SPT_CURRENT ) && m_dotted_cp ) ?
473  wxPENSTYLE_DOT :
474  wxPENSTYLE_SOLID;
475  trace->SetPen( wxPen( trace->GetTraceColour(), 2, penStyle ) );
476 }
wxColour GetTraceColour()
void SetPen(wxPen pen)
Set layer pen.
Definition: mathplot.h:276
int GetFlags() const

References TRACE::GetFlags(), TRACE::GetTraceColour(), m_dotted_cp, mpLayer::SetPen(), SPT_AC_PHASE, and SPT_CURRENT.

Referenced by AddTrace(), and SetDottedCurrentPhase().

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

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

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

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

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

◆ ZoomIn() [1/2]

void mpWindow::ZoomIn ( const wxPoint centerPoint = wxDefaultPosition)
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 2259 of file mathplot.cpp.

2260 {
2261  ZoomIn( centerPoint, zoomIncrementalFactor );
2262 }
void ZoomIn(const wxPoint &centerPoint=wxDefaultPosition)
Zoom into current view and refresh display.
Definition: mathplot.cpp:2259
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:1346

References mpWindow::zoomIncrementalFactor.

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

◆ ZoomIn() [2/2]

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

Definition at line 2265 of file mathplot.cpp.

2266 {
2267  wxPoint c( centerPoint );
2268 
2269  if( c == wxDefaultPosition )
2270  {
2271  GetClientSize( &m_scrX, &m_scrY );
2272  c.x = (m_scrX - m_marginLeft - m_marginRight) / 2 + m_marginLeft; // c.x = m_scrX/2;
2273  c.y = (m_scrY - m_marginTop - m_marginBottom) / 2 - m_marginTop; // c.y = m_scrY/2;
2274  }
2275  else
2276  {
2277  c.x = std::max( c.x, m_marginLeft );
2278  c.x = std::min( c.x, m_scrX - m_marginRight );
2279  c.y = std::max( c.y, m_marginTop );
2280  c.y = std::min( c.y, m_scrY - m_marginBottom );
2281  }
2282 
2283  // Preserve the position of the clicked point:
2284  double prior_layer_x = p2x( c.x );
2285  double prior_layer_y = p2y( c.y );
2286 
2287  // Zoom in:
2288  const double MAX_SCALE = 1e6;
2289  double newScaleX = m_scaleX * zoomFactor;
2290  double newScaleY = m_scaleY * zoomFactor;
2291 
2292  // Baaaaad things happen when you zoom in too much..
2293  if( newScaleX <= MAX_SCALE && newScaleY <= MAX_SCALE )
2294  {
2295  m_scaleX = newScaleX;
2296  m_scaleY = newScaleY;
2297  }
2298  else
2299  {
2300  return;
2301  }
2302 
2303  // Adjust the new m_posx/y:
2304  m_posX = prior_layer_x - c.x / m_scaleX;
2305  m_posY = prior_layer_y + c.y / m_scaleY;
2306 
2308  m_desiredXmax = m_posX + (m_scrX - m_marginLeft - m_marginRight) / m_scaleX; // m_desiredXmax = m_posX + m_scrX / m_scaleX;
2310  m_desiredYmin = m_posY - (m_scrY - m_marginTop - m_marginBottom) / m_scaleY; // m_desiredYmin = m_posY - m_scrY / m_scaleY;
2312 
2313 #ifdef MATHPLOT_DO_LOGGING
2314  wxLogMessage( "mpWindow::ZoomIn() prior coords: (%f,%f), new coords: (%f,%f) SHOULD BE EQUAL!!",
2315  prior_layer_x, prior_layer_y, p2x( c.x ), p2y( c.y ) );
2316 #endif
2317 
2318  UpdateAll();
2319 }
int m_marginRight
Definition: mathplot.h:1521
int m_marginLeft
Definition: mathplot.h:1521
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1187
double m_desiredXmax
Definition: mathplot.h:1519
double m_scaleY
Definition: mathplot.h:1508
double m_posX
Definition: mathplot.h:1509
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1192
double m_scaleX
Definition: mathplot.h:1507
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836
double m_desiredYmax
Definition: mathplot.h:1519
void AdjustLimitedView()
Definition: mathplot.cpp:2185
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1519
#define MAX_SCALE
double m_posY
Definition: mathplot.h:1510
int m_marginTop
Definition: mathplot.h:1521
double m_desiredYmin
Definition: mathplot.h:1519
int m_marginBottom
Definition: mathplot.h:1521
int m_scrY
Definition: mathplot.h:1512
int m_scrX
Definition: mathplot.h:1511

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_SCALE, mpWindow::p2x(), mpWindow::p2y(), mpWindow::UpdateAll(), wxPoint::x, and wxPoint::y.

◆ ZoomInX()

void mpWindow::ZoomInX ( )
inherited

Zoom in current view along X and refresh display.

Definition at line 2375 of file mathplot.cpp.

2376 {
2378  UpdateAll();
2379 }
double m_scaleX
Definition: mathplot.h:1507
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836
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:1346

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

2390 {
2392  UpdateAll();
2393 }
double m_scaleY
Definition: mathplot.h:1508
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836
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:1346

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

◆ ZoomOut() [1/2]

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

2323 {
2324  ZoomOut( centerPoint, zoomIncrementalFactor );
2325 }
void ZoomOut(const wxPoint &centerPoint=wxDefaultPosition)
Zoom out current view and refresh display.
Definition: mathplot.cpp:2322
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:1346

References mpWindow::zoomIncrementalFactor.

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

◆ ZoomOut() [2/2]

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

Definition at line 2328 of file mathplot.cpp.

2329 {
2330  wxPoint c( centerPoint );
2331 
2332  if( c == wxDefaultPosition )
2333  {
2334  GetClientSize( &m_scrX, &m_scrY );
2335  c.x = (m_scrX - m_marginLeft - m_marginRight) / 2 + m_marginLeft; // c.x = m_scrX/2;
2336  c.y = (m_scrY - m_marginTop - m_marginBottom) / 2 - m_marginTop; // c.y = m_scrY/2;
2337  }
2338 
2339  // Preserve the position of the clicked point:
2340  double prior_layer_x = p2x( c.x );
2341  double prior_layer_y = p2y( c.y );
2342 
2343  // Zoom out:
2344  m_scaleX = m_scaleX / zoomFactor;
2345  m_scaleY = m_scaleY / zoomFactor;
2346 
2347  // Adjust the new m_posx/y:
2348  m_posX = prior_layer_x - c.x / m_scaleX;
2349  m_posY = prior_layer_y + c.y / m_scaleY;
2350 
2352  m_desiredXmax = m_posX + (m_scrX - m_marginLeft - m_marginRight) / m_scaleX; // m_desiredXmax = m_posX + m_scrX / m_scaleX;
2354  m_desiredYmin = m_posY - (m_scrY - m_marginTop - m_marginBottom) / m_scaleY; // m_desiredYmin = m_posY - m_scrY / m_scaleY;
2355 
2356  // printf("desired xmin %.1f ymin %.1f xmax %.1f ymax %.1f l %d\n", m_desiredXmin, m_desiredYmin, m_desiredXmax, m_desiredYmax, !!m_enableLimitedView);
2357  // printf("current xmin %.1f ymin %.1f xmax %.1f ymax %.1f\n", m_minX, m_minY, m_maxX, m_maxY);
2358 
2361  {
2362  // printf("call fit()\n");
2363  Fit();
2364  }
2365 
2366 #ifdef MATHPLOT_DO_LOGGING
2367  wxLogMessage(
2368  "mpWindow::ZoomOut() prior coords: (%f,%f), new coords: (%f,%f) SHOULD BE EQUAL!!",
2369  prior_layer_x, prior_layer_y, p2x( c.x ), p2y( c.y ) );
2370 #endif
2371  UpdateAll();
2372 }
int m_marginRight
Definition: mathplot.h:1521
int m_marginLeft
Definition: mathplot.h:1521
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1187
double m_desiredXmax
Definition: mathplot.h:1519
double m_scaleY
Definition: mathplot.h:1508
double m_posX
Definition: mathplot.h:1509
double p2y(wxCoord pixelCoordY)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1192
double m_scaleX
Definition: mathplot.h:1507
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836
double m_desiredYmax
Definition: mathplot.h:1519
double m_desiredXmin
These are updated in Fit() only, and may be different from the real borders (layer coordinates) only ...
Definition: mathplot.h:1519
bool CheckYLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1470
double m_posY
Definition: mathplot.h:1510
void Fit() override
Set view to fit global bounding box of all plot layers and refresh display.
Definition: mathplot.cpp:2014
int m_marginTop
Definition: mathplot.h:1521
double m_desiredYmin
Definition: mathplot.h:1519
int m_marginBottom
Definition: mathplot.h:1521
int m_scrY
Definition: mathplot.h:1512
bool CheckXLimits(double &desiredMax, double &desiredMin) const
Definition: mathplot.h:1463
int m_scrX
Definition: mathplot.h:1511

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(), wxPoint::x, and wxPoint::y.

◆ ZoomOutX()

void mpWindow::ZoomOutX ( )
inherited

Zoom out current view along X and refresh display.

Definition at line 2382 of file mathplot.cpp.

2383 {
2385  UpdateAll();
2386 }
double m_scaleX
Definition: mathplot.h:1507
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836
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:1346

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

2397 {
2399  UpdateAll();
2400 }
double m_scaleY
Definition: mathplot.h:1508
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836
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:1346

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

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

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

Referenced by mpWindow::OnMouseLeftRelease().

Member Data Documentation

◆ m_axColour

wxColour mpWindow::m_axColour
protectedinherited

Definition at line 1501 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 286 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 1499 of file mathplot.h.

Referenced by mpWindow::SetColourTheme().

◆ m_buff_bmp

wxBitmap* mpWindow::m_buff_bmp
protectedinherited

Definition at line 1525 of file mathplot.h.

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

◆ m_buff_dc

wxMemoryDC mpWindow::m_buff_dc
protectedinherited

Definition at line 1524 of file mathplot.h.

Referenced by mpWindow::OnPaint().

◆ m_clickedX

int mpWindow::m_clickedX
protectedinherited

Definition at line 1513 of file mathplot.h.

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

◆ m_clickedY

int mpWindow::m_clickedY
protectedinherited

Definition at line 1514 of file mathplot.h.

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

◆ m_colorIdx

unsigned int SIM_PLOT_PANEL::m_colorIdx
private

Definition at line 279 of file sim_plot_panel.h.

Referenced by DeleteAllTraces().

◆ m_desiredXmax

◆ m_desiredXmin

double mpWindow::m_desiredXmin
protectedinherited

◆ m_desiredYmax

◆ m_desiredYmin

◆ m_dotted_cp

bool SIM_PLOT_PANEL::m_dotted_cp
private

◆ m_enableDoubleBuffer

bool mpWindow::m_enableDoubleBuffer
protectedinherited

Definition at line 1526 of file mathplot.h.

Referenced by mpWindow::OnPaint().

◆ m_enableLimitedView

bool mpWindow::m_enableLimitedView
protectedinherited

Definition at line 1529 of file mathplot.h.

Referenced by mpWindow::AdjustLimitedView().

◆ m_enableMouseNavigation

bool mpWindow::m_enableMouseNavigation
protectedinherited

Definition at line 1527 of file mathplot.h.

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

◆ m_enableMouseWheelPan

bool mpWindow::m_enableMouseWheelPan
protectedinherited

Definition at line 1528 of file mathplot.h.

Referenced by mpWindow::OnMouseWheel().

◆ m_enableScrollBars

bool mpWindow::m_enableScrollBars
protectedinherited

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

Referenced by mpWindow::OnPaint().

◆ m_last_ly

int mpWindow::m_last_ly
protectedinherited

Definition at line 1523 of file mathplot.h.

Referenced by mpWindow::OnPaint().

◆ m_layers

◆ m_legend

mpInfoLegend* SIM_PLOT_PANEL::m_legend
private

Definition at line 287 of file sim_plot_panel.h.

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

◆ m_lockaspect

bool mpWindow::m_lockaspect
protectedinherited

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

◆ m_scrX

◆ m_scrY

◆ m_topLevel

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

Definition at line 291 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 293 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 1536 of file mathplot.h.

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

◆ zoomIncrementalFactor

double mpWindow::zoomIncrementalFactor = 1.1
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 1346 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: