KiCad PCB EDA Suite
sim_plot_panel.cpp
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2016 CERN
5  * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
8  * @author Maciej Suminski <maciej.suminski@cern.ch>
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 3
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, you may find one here:
22  * https://www.gnu.org/licenses/gpl-3.0.html
23  * or you may search the http://www.gnu.org website for the version 3 license,
24  * or you may write to the Free Software Foundation, Inc.,
25  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26  */
27 
28 #include "sim_plot_colors.h"
29 #include "sim_plot_panel.h"
30 #include "sim_plot_frame.h"
31 
32 #include <algorithm>
33 #include <limits>
34 
35 #include <wx/regex.h>
36 
37 
38 static wxString formatFloat( double x, int nDigits )
39 {
40  wxString rv, fmt;
41 
42  if( nDigits )
43  {
44  fmt.Printf( "%%.0%df", nDigits );
45  }
46  else
47  {
48  fmt = wxT( "%.0f" );
49  }
50 
51  rv.Printf( fmt, x );
52 
53  return rv;
54 }
55 
56 
57 static void getSISuffix( double x, const wxString& unit, int& power, wxString& suffix )
58 {
59  const int n_powers = 11;
60 
61  const struct
62  {
63  double exponent;
64  char suffix;
65  } powers[] =
66  {
67  { -18, 'a' },
68  { -15, 'f' },
69  { -12, 'p' },
70  { -9, 'n' },
71  { -6, 'u' },
72  { -3, 'm' },
73  { 0, 0 },
74  { 3, 'k' },
75  { 6, 'M' },
76  { 9, 'G' },
77  { 12, 'T' },
78  { 14, 'P' }
79  };
80 
81  power = 0;
82  suffix = unit;
83 
84  if( x == 0.0 )
85  return;
86 
87  for( int i = 0; i < n_powers - 1; i++ )
88  {
89  double r_cur = pow( 10, powers[i].exponent );
90 
91  if( fabs( x ) >= r_cur && fabs( x ) < r_cur * 1000.0 )
92  {
93  power = powers[i].exponent;
94 
95  if( powers[i].suffix )
96  suffix = wxString( powers[i].suffix ) + unit;
97  else
98  suffix = unit;
99 
100  return;
101  }
102  }
103 }
104 
105 
106 static int countDecimalDigits( double x, int maxDigits )
107 {
108  if( std::isnan( x ) )
109  {
110  // avoid trying to count the decimals of NaN
111  return 0;
112  }
113 
114  int64_t k = (int)( ( x - floor( x ) ) * pow( 10.0, (double) maxDigits ) );
115  int n = 0;
116 
117  while( k && ( ( k % 10LL ) == 0LL || ( k % 10LL ) == 9LL ) )
118  {
119  k /= 10LL;
120  }
121 
122  n = 0;
123 
124  while( k != 0LL )
125  {
126  n++;
127  k /= 10LL;
128  }
129 
130  return n;
131 }
132 
133 
134 template <typename parent>
135 class LIN_SCALE : public parent
136 {
137 public:
138  LIN_SCALE( wxString name, wxString unit, int flags ) : parent( name, flags ), m_unit( unit ){};
139 
140  void formatLabels() override
141  {
142  double maxVis = parent::AbsVisibleMaxValue();
143 
144  wxString suffix;
145  int power, digits = 0;
146  int constexpr DIGITS = 3;
147 
148  getSISuffix( maxVis, m_unit, power, suffix );
149 
150  double sf = pow( 10.0, power );
151 
152  for( auto& l : parent::TickLabels() )
153  {
154  int k = countDecimalDigits( l.pos / sf, DIGITS );
155 
156  digits = std::max( digits, k );
157  }
158 
159  for( auto& l : parent::TickLabels() )
160  {
161  l.label = formatFloat( l.pos / sf, digits ) + suffix;
162  l.visible = true;
163  }
164  }
165 
166 private:
167  const wxString m_unit;
168 };
169 
170 
171 template <typename parent>
172 class LOG_SCALE : public parent
173 {
174 public:
175  LOG_SCALE( wxString name, wxString unit, int flags ) : parent( name, flags ), m_unit( unit ){};
176 
177  void formatLabels() override
178  {
179  wxString suffix;
180  int power;
181 
182  for( auto& l : parent::TickLabels() )
183  {
184  getSISuffix( l.pos, m_unit, power, suffix );
185  double sf = pow( 10.0, power );
186  int k = countDecimalDigits( l.pos / sf, 3 );
187 
188  l.label = formatFloat( l.pos / sf, k ) + suffix;
189  l.visible = true;
190  }
191  }
192 
193 private:
194  const wxString m_unit;
195 };
196 
197 
198 void CURSOR::Plot( wxDC& aDC, mpWindow& aWindow )
199 {
200  if( !m_window )
201  m_window = &aWindow;
202 
203  if( !m_visible )
204  return;
205 
206  const auto& dataX = m_trace->GetDataX();
207  const auto& dataY = m_trace->GetDataY();
208 
209  if( dataX.size() <= 1 )
210  return;
211 
212  if( m_updateRequired )
213  {
214  m_coords.x = m_trace->s2x( aWindow.p2x( m_dim.x ) );
215 
216  // Find the closest point coordinates
217  auto maxXIt = std::upper_bound( dataX.begin(), dataX.end(), m_coords.x );
218  int maxIdx = maxXIt - dataX.begin();
219  int minIdx = maxIdx - 1;
220 
221  // Out of bounds checks
222  if( minIdx < 0 )
223  {
224  minIdx = 0;
225  maxIdx = 1;
226  m_coords.x = dataX[0];
227  }
228  else if( maxIdx >= (int) dataX.size() )
229  {
230  maxIdx = dataX.size() - 1;
231  minIdx = maxIdx - 1;
232  m_coords.x = dataX[maxIdx];
233  }
234 
235  const double leftX = dataX[minIdx];
236  const double rightX = dataX[maxIdx];
237  const double leftY = dataY[minIdx];
238  const double rightY = dataY[maxIdx];
239 
240  // Linear interpolation
241  m_coords.y = leftY + ( rightY - leftY ) / ( rightX - leftX ) * ( m_coords.x - leftX );
242  m_updateRequired = false;
243 
244  // Notify the parent window about the changes
245  wxQueueEvent( aWindow.GetParent(), new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
246  }
247  else
248  {
249  m_updateRef = true;
250  }
251 
252  if( m_updateRef )
253  {
254  UpdateReference();
255  m_updateRef = false;
256  }
257 
258  // Line length in horizontal and vertical dimensions
259  const wxPoint cursorPos( aWindow.x2p( m_trace->x2s( m_coords.x ) ),
260  aWindow.y2p( m_trace->y2s( m_coords.y ) ) );
261 
262  wxCoord leftPx = m_drawOutsideMargins ? 0 : aWindow.GetMarginLeft();
263  wxCoord rightPx = m_drawOutsideMargins ? aWindow.GetScrX() :
264  aWindow.GetScrX() - aWindow.GetMarginRight();
265  wxCoord topPx = m_drawOutsideMargins ? 0 : aWindow.GetMarginTop();
266  wxCoord bottomPx = m_drawOutsideMargins ? aWindow.GetScrY() :
267  aWindow.GetScrY() - aWindow.GetMarginBottom();
268 
269  wxPen pen = GetPen();
270  pen.SetStyle( m_continuous ? wxPENSTYLE_SOLID : wxPENSTYLE_LONG_DASH );
271  aDC.SetPen( pen );
272 
273  if( topPx < cursorPos.y && cursorPos.y < bottomPx )
274  aDC.DrawLine( leftPx, cursorPos.y, rightPx, cursorPos.y );
275 
276  if( leftPx < cursorPos.x && cursorPos.x < rightPx )
277  aDC.DrawLine( cursorPos.x, topPx, cursorPos.x, bottomPx );
278 }
279 
280 
281 bool CURSOR::Inside( wxPoint& aPoint )
282 {
283  if( !m_window )
284  return false;
285 
286  return ( std::abs( (double) aPoint.x -
287  m_window->x2p( m_trace->x2s( m_coords.x ) ) ) <= DRAG_MARGIN )
288  || ( std::abs( (double) aPoint.y -
289  m_window->y2p( m_trace->y2s( m_coords.y ) ) ) <= DRAG_MARGIN );
290 }
291 
292 
294 {
295  if( !m_window )
296  return;
297 
298  m_reference.x = m_window->x2p( m_trace->x2s( m_coords.x ) );
299  m_reference.y = m_window->y2p( m_trace->y2s( m_coords.y ) );
300 }
301 
302 
303 SIM_PLOT_PANEL::SIM_PLOT_PANEL( const wxString& aCommand, wxWindow* parent,
304  SIM_PLOT_FRAME* aMainFrame, wxWindowID id, const wxPoint& pos,
305  const wxSize& size, long style, const wxString& name )
306  : SIM_PANEL_BASE( aCommand, parent, id, pos, size, style, name ),
307  m_axis_x( nullptr ),
308  m_axis_y1( nullptr ),
309  m_axis_y2( nullptr ),
310  m_dotted_cp( false ),
311  m_masterFrame( aMainFrame )
312 {
313  m_sizer = new wxBoxSizer( wxVERTICAL );
314  m_plotWin = new mpWindow( this, wxID_ANY, pos, size, style );
315 
316  m_plotWin->LimitView( true );
317  m_plotWin->SetMargins( 50, 80, 50, 80 );
318 
320 
321  switch( GetType() )
322  {
323  case ST_AC:
324  m_axis_x = new LOG_SCALE<mpScaleXLog>( _( "Frequency" ), wxT( "Hz" ), mpALIGN_BOTTOM );
325  m_axis_y1 = new LIN_SCALE<mpScaleY>( _( "Gain" ), wxT( "dBV" ), mpALIGN_LEFT );
326  m_axis_y2 = new LIN_SCALE<mpScaleY>( _( "Phase" ), wxT( "\u00B0" ),
327  mpALIGN_RIGHT ); // degree sign
329  break;
330 
331  case ST_DC:
332  prepareDCAxes();
333  break;
334 
335  case ST_NOISE:
336  m_axis_x = new LOG_SCALE<mpScaleXLog>( _( "Frequency" ), wxT( "Hz" ), mpALIGN_BOTTOM );
337  m_axis_y1 = new mpScaleY( _( "noise [(V or A)^2/Hz]" ), mpALIGN_LEFT );
338  break;
339 
340  case ST_TRANSIENT:
341  m_axis_x = new LIN_SCALE<mpScaleX>( _( "Time" ), wxT( "s" ), mpALIGN_BOTTOM );
342  m_axis_y1 = new LIN_SCALE<mpScaleY>( _( "Voltage" ), wxT( "V" ), mpALIGN_LEFT );
343  m_axis_y2 = new LIN_SCALE<mpScaleY>( _( "Current" ), wxT( "A" ), mpALIGN_RIGHT );
345  break;
346 
347  default:
348  // suppress warnings
349  break;
350  }
351 
352  if( m_axis_x )
353  {
354  m_axis_x->SetTicks( false );
356 
358  }
359 
360  if( m_axis_y1 )
361  {
362  m_axis_y1->SetTicks( false );
365  }
366 
367  if( m_axis_y2 )
368  {
369  m_axis_y2->SetTicks( false );
372  }
373 
374  // a mpInfoLegend displays le name of traces on the left top panel corner:
375  m_legend = new mpInfoLegend( wxRect( 0, 40, 200, 40 ), wxTRANSPARENT_BRUSH );
376  m_legend->SetVisible( false );
378 
379  m_plotWin->EnableDoubleBuffer( true );
380  m_plotWin->UpdateAll();
381 
382  m_sizer->Add( m_plotWin, 1, wxALL | wxEXPAND, 1 );
383  SetSizer( m_sizer );
384 }
385 
386 
388 {
389  // ~mpWindow destroys all the added layers, so there is no need to destroy m_traces contents
390 }
391 
392 
394 {
395  wxRegEx simCmd( "^.dc[[:space:]]+([[:alnum:]]+\\M).*", wxRE_ADVANCED | wxRE_ICASE );
396 
397  if( simCmd.Matches( getSimCommand() ) )
398  {
399  switch( static_cast<char>( simCmd.GetMatch( getSimCommand().Lower(), 1 ).GetChar( 0 ) ) )
400  {
401  case 'v':
402  m_axis_x =
403  new LIN_SCALE<mpScaleX>( _( "Voltage (swept)" ), wxT( "V" ), mpALIGN_BOTTOM );
404  break;
405  case 'i':
406  m_axis_x =
407  new LIN_SCALE<mpScaleX>( _( "Current (swept)" ), wxT( "A" ), mpALIGN_BOTTOM );
408  break;
409  case 'r':
410  m_axis_x = new LIN_SCALE<mpScaleX>( _( "Resistance (swept)" ), wxT( "\u03A9" ),
411  mpALIGN_BOTTOM );
412  break;
413  case 't':
414  m_axis_x = new LIN_SCALE<mpScaleX>( _( "Temperature (swept)" ), wxT( "\u00B0C" ),
415  mpALIGN_BOTTOM );
416  break;
417  }
418 
419  m_axis_y1 = new LIN_SCALE<mpScaleY>( _( "Voltage (measured)" ), wxT( "V" ), mpALIGN_LEFT );
420  m_axis_y2 = new LIN_SCALE<mpScaleY>( _( "Current" ), wxT( "A" ), mpALIGN_RIGHT );
421  }
422 }
423 
424 
426 {
427  // Update bg and fg colors:
431 
432  // Update color of all traces
433  for( auto& t : m_traces )
434  if( t.second->GetCursor() )
435  t.second->GetCursor()->SetPen(
437 
438  m_plotWin->UpdateAll();
439 }
440 
441 
443 {
444  int type = trace->GetType();
445  wxPenStyle penStyle = ( ( type & SPT_AC_PHASE || type & SPT_CURRENT ) && m_dotted_cp )
446  ? wxPENSTYLE_DOT
447  : wxPENSTYLE_SOLID;
448  trace->SetPen( wxPen( trace->GetTraceColour(), 2, penStyle ) );
449 }
450 
451 
452 bool SIM_PLOT_PANEL::addTrace( const wxString& aTitle, const wxString& aName, int aPoints,
453  const double* aX, const double* aY, SIM_PLOT_TYPE aType,
454  const wxString& aParam )
455 {
456  TRACE* trace = nullptr;
457  wxString name = aTitle;
458 
459  // Find previous entry, if there is one
460  auto prev = m_traces.find( name );
461  bool addedNewEntry = ( prev == m_traces.end() );
462 
463  if( addedNewEntry )
464  {
465  if( GetType() == ST_TRANSIENT )
466  {
467  bool hasVoltageTraces = false;
468 
469  for( const auto& tr : m_traces )
470  {
471  if( !( tr.second->GetType() & SPT_CURRENT ) )
472  {
473  hasVoltageTraces = true;
474  break;
475  }
476  }
477 
478  if( !hasVoltageTraces )
479  m_axis_y2->SetMasterScale( nullptr );
480  else
482  }
483 
484  // New entry
485  trace = new TRACE( aName, aType, aParam );
487  UpdateTraceStyle( trace );
488  m_traces[name] = trace;
489 
490  // It is a trick to keep legend & coords always on the top
491  for( mpLayer* l : m_topLevel )
492  m_plotWin->DelLayer( l );
493 
494  m_plotWin->AddLayer( (mpLayer*) trace );
495 
496  for( mpLayer* l : m_topLevel )
497  m_plotWin->AddLayer( l );
498  }
499  else
500  {
501  trace = prev->second;
502  }
503 
504  std::vector<double> tmp( aY, aY + aPoints );
505 
506  if( GetType() == ST_AC )
507  {
508  if( aType & SPT_AC_PHASE )
509  {
510  for( int i = 0; i < aPoints; i++ )
511  tmp[i] = tmp[i] * 180.0 / M_PI; // convert to degrees
512  }
513  else
514  {
515  for( int i = 0; i < aPoints; i++ )
516  {
517  // log( 0 ) is not valid.
518  if( tmp[i] != 0 )
519  tmp[i] = 20 * log( tmp[i] ) / log( 10.0 ); // convert to dB
520  }
521  }
522  }
523 
524  trace->SetData( std::vector<double>( aX, aX + aPoints ), tmp );
525 
526  if( ( aType & SPT_AC_PHASE ) || ( aType & SPT_CURRENT ) )
527  trace->SetScale( m_axis_x, m_axis_y2 );
528  else
529  trace->SetScale( m_axis_x, m_axis_y1 );
530 
531  m_plotWin->UpdateAll();
532 
533  return addedNewEntry;
534 }
535 
536 
537 bool SIM_PLOT_PANEL::deleteTrace( const wxString& aName )
538 {
539  auto it = m_traces.find( aName );
540 
541  if( it != m_traces.end() )
542  {
543  TRACE* trace = it->second;
544  m_traces.erase( it );
545 
546  if( CURSOR* cursor = trace->GetCursor() )
547  m_plotWin->DelLayer( cursor, true );
548 
549  m_plotWin->DelLayer( trace, true, true );
550  ResetScales();
551 
552  return true;
553  }
554 
555  return false;
556 }
557 
558 
560 {
561  for( auto& t : m_traces )
562  {
563  deleteTrace( t.first );
564  }
565 
566  m_traces.clear();
567 }
568 
569 
570 bool SIM_PLOT_PANEL::HasCursorEnabled( const wxString& aName ) const
571 {
572  TRACE* t = GetTrace( aName );
573 
574  return t ? t->HasCursor() : false;
575 }
576 
577 
578 void SIM_PLOT_PANEL::EnableCursor( const wxString& aName, bool aEnable )
579 {
580  TRACE* t = GetTrace( aName );
581 
582  if( t == nullptr || t->HasCursor() == aEnable )
583  return;
584 
585  if( aEnable )
586  {
587  CURSOR* c = new CURSOR( t, this );
588  int plotCenter = GetPlotWin()->GetMarginLeft()
590  - GetPlotWin()->GetMarginRight() )
591  / 2;
592  c->SetX( plotCenter );
594  t->SetCursor( c );
595  m_plotWin->AddLayer( c );
596  }
597  else
598  {
599  CURSOR* c = t->GetCursor();
600  t->SetCursor( nullptr );
601  m_plotWin->DelLayer( c, true );
602  }
603 
604  // Notify the parent window about the changes
605  wxQueueEvent( GetParent(), new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
606 }
607 
608 
610 {
611  if( m_axis_x )
613 
614  if( m_axis_y1 )
616 
617  if( m_axis_y2 )
619 
620  for( auto t : m_traces )
621  t.second->UpdateScales();
622 }
623 
624 
625 wxDEFINE_EVENT( EVT_SIM_CURSOR_UPDATE, wxCommandEvent );
bool addTrace(const wxString &aTitle, const wxString &aName, int aPoints, const double *aX, const double *aY, SIM_PLOT_TYPE aType, const wxString &aParam)
void Plot(wxDC &aDC, mpWindow &aWindow) override
Plot method.
double s2x(double plotCoordX) const
Definition: mathplot.cpp:3542
#define mpALIGN_LEFT
Aligns label to the left.
Definition: mathplot.h:481
class WXDLLIMPEXP_MATHPLOT mpWindow
Definition: mathplot.h:108
int GetMarginBottom() const
Definition: mathplot.h:1375
wxDEFINE_EVENT(EVT_SIM_CURSOR_UPDATE, wxCommandEvent)
bool m_continuous
Definition: mathplot.h:318
static wxString formatFloat(double x, int nDigits)
static constexpr int DRAG_MARGIN
mpWindow * m_plotWin
void SetNameAlign(int align)
Definition: mathplot.h:709
const TRACE * m_trace
wxRealPoint m_coords
const wxString m_unit
mpWindow * GetPlotWin() const
mpScaleY * m_axis_y1
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1192
bool HasCursor() const
bool DelLayer(mpLayer *layer, bool alsoDeleteObject=false, bool refreshDisplay=true)
Remove a plot layer from the canvas.
Definition: mathplot.cpp:2273
virtual void SetScale(mpScaleBase *scaleX, mpScaleBase *scaleY)
Definition: mathplot.cpp:3523
int GetXScreen(void) const
Definition: mathplot.h:1139
const std::vector< double > & GetDataX() const
mpScaleXBase * m_axis_x
bool HasCursorEnabled(const wxString &aName) const
Toggle cursor for a particular trace.
wxColour GetTraceColour()
void SetMasterScale(mpScaleY *masterScale)
Definition: mathplot.h:979
double y2s(double y) const
Definition: mathplot.cpp:3560
static int countDecimalDigits(double x, int maxDigits)
#define mpALIGN_RIGHT
Aligns label to the right.
Definition: mathplot.h:477
bool AddLayer(mpLayer *layer, bool refreshDisplay=true)
Add a plot layer to the canvas.
Definition: mathplot.cpp:2256
virtual ~SIM_PLOT_PANEL()
set the pointer to the sim plot frame
TRACE * GetTrace(const wxString &aName) const
void SetPen(wxPen pen)
Set layer pen.
Definition: mathplot.h:277
void formatLabels() override
void UpdateTraceStyle(TRACE *trace)
void UpdateReference() override
Updates the rectangle reference point.
void EnableDoubleBuffer(bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=disabled).
Definition: mathplot.h:1212
bool m_visible
Definition: mathplot.h:322
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2403
void EnableCursor(const wxString &aName, bool aEnable)
Reset scale ranges to fit the current traces.
int GetMarginRight() const
Definition: mathplot.h:1373
wxColour GenerateColor(std::map< wxString, TRACE * > aTraces)
SIM_PLOT_COLORS m_colors
wxCoord y2p(double y)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
Definition: mathplot.h:1207
void ResetDataRange()
Definition: mathplot.h:759
void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:302
static void getSISuffix(double x, const wxString &unit, int &power, wxString &suffix)
std::vector< mpLayer * > m_topLevel
std::map< wxString, TRACE * > m_traces
const wxString & getSimCommand() const
int GetScrX(void) const
Get current view's X dimension in device context units.
Definition: mathplot.h:1138
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:2682
class WXDLLIMPEXP_MATHPLOT mpScaleY
Definition: mathplot.h:107
void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour)
Set Color theme.
Definition: mathplot.cpp:2748
mpScaleY * m_axis_y2
SIM_PLOT_TYPE GetType() const
void SetTicks(bool enable)
Set X axis ticks or grid.
Definition: mathplot.h:714
#define _(s)
Subclass of SIM_PLOT_FRAME_BASE, which is generated by wxFormBuilder.
int GetMarginTop() const
Definition: mathplot.h:1371
void ResetScales()
Update trace line style.
void formatLabels() override
bool m_updateRequired
wxRect m_dim
Definition: mathplot.h:392
Implementing SIM_PLOT_FRAME_BASE.
mpWindow * m_window
bool m_drawOutsideMargins
Definition: mathplot.h:320
wxColour GetPlotColor(enum COLOR_SET aColorId)
wxPoint m_reference
Definition: mathplot.h:396
SIM_TYPE GetType() const
double x2s(double x) const
Definition: mathplot.cpp:3554
void UpdatePlotColors()
Update plot colors
SIM_PLOT_PANEL(const wxString &aCommand, wxWindow *parent, SIM_PLOT_FRAME *aMainFrame, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxPanelNameStr)
wxCoord x2p(double x)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
Definition: mathplot.h:1202
const char * name
Definition: DXF_plotter.cpp:56
bool deleteTrace(const wxString &aName)
mpInfoLegend * m_legend
void SetX(int aX)
CURSOR * GetCursor() const
const wxString m_unit
void LimitView(bool aEnable)
Limit zooming & panning to the area used by the plots.
Definition: mathplot.h:1429
void SetData(const std::vector< double > &aX, const std::vector< double > &aY) override
Assigns new data set for the trace.
Canvas for plotting mpLayer implementations.
Definition: mathplot.h:1046
LOG_SCALE(wxString name, wxString unit, int flags)
void SetTicks(bool ticks)
Set Y axis ticks or grid.
Definition: mathplot.h:969
#define mpALIGN_BOTTOM
Aligns label to the bottom.
Definition: mathplot.h:485
const std::vector< double > & GetDataY() const
int GetMarginLeft() const
Definition: mathplot.h:1377
LIN_SCALE(wxString name, wxString unit, int flags)
Implements the legend to be added to the plot This layer allows you to add a legend to describe the p...
Definition: mathplot.h:437
void SetCursor(CURSOR *aCursor)
SIM_PLOT_TYPE
Definition: sim_types.h:46
bool m_updateRef
const wxPen & GetPen() const
Get pen set for this layer.
Definition: mathplot.h:248
Class is responsible for providing colors for traces on simulation plot.
bool Inside(wxPoint &aPoint) override
Checks whether a point is inside the info box rectangle.
wxBoxSizer * m_sizer
Cursor attached to a trace to follow its values:
void SetTraceColour(wxColour aColour)
int GetScrY(void) const
Get current view's Y dimension in device context units.
Definition: mathplot.h:1147