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  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
6  * @author Maciej Suminski <maciej.suminski@cern.ch>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * https://www.gnu.org/licenses/gpl-3.0.html
21  * or you may search the http://www.gnu.org website for the version 3 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #include "sim_plot_panel.h"
27 
28 #include <algorithm>
29 #include <limits>
30 
31 static wxString formatFloat( double x, int nDigits )
32 {
33  wxString rv, fmt;
34 
35  if( nDigits )
36  {
37  fmt = wxT( "%.0Nf" );
38  fmt[3] = '0' + nDigits;
39  }
40  else
41  {
42  fmt = wxT( "%.0f" );
43  }
44 
45  rv.Printf( fmt, x );
46 
47  return rv;
48 }
49 
50 
51 static void getSISuffix( double x, const wxString& unit, int& power, wxString& suffix )
52 {
53  const int n_powers = 11;
54 
55  const struct
56  {
57  double exponent;
58  char suffix;
59  } powers[] =
60  {
61  { -18, 'a' },
62  { -15, 'f' },
63  { -12, 'p' },
64  { -9, 'n' },
65  { -6, 'u' },
66  { -3, 'm' },
67  { 0, 0 },
68  { 3, 'k' },
69  { 6, 'M' },
70  { 9, 'G' },
71  { 12, 'T' },
72  { 14, 'P' }
73  };
74 
75  power = 0;
76  suffix = unit;
77 
78  if( x == 0.0 )
79  return;
80 
81  for( int i = 0; i < n_powers - 1; i++ )
82  {
83  double r_cur = pow( 10, powers[i].exponent );
84 
85  if( fabs( x ) >= r_cur && fabs( x ) < r_cur * 1000.0 )
86  {
87  power = powers[i].exponent;
88 
89  if( powers[i].suffix )
90  suffix = wxString( powers[i].suffix ) + unit;
91  else
92  suffix = unit;
93 
94  return;
95  }
96  }
97 }
98 
99 
100 static int countDecimalDigits( double x, int maxDigits )
101 {
102  int64_t k = (int)( ( x - floor( x ) ) * pow( 10.0, (double) maxDigits ) );
103  int n = 0;
104 
105  while( k && ( ( k % 10LL ) == 0LL || ( k % 10LL ) == 9LL ) )
106  {
107  k /= 10LL;
108  }
109 
110  n = 0;
111 
112  while( k != 0LL )
113  {
114  n++;
115  k /= 10LL;
116  }
117 
118  return n;
119 }
120 
121 
122 static void formatSILabels( mpScaleBase* scale, const wxString& aUnit, int nDigits )
123 {
124  double maxVis = scale->AbsVisibleMaxValue();
125 
126  wxString suffix;
127  int power, digits = 0;
128 
129  getSISuffix( maxVis, aUnit, power, suffix );
130 
131  double sf = pow( 10.0, power );
132 
133  for( auto &l : scale->TickLabels() )
134  {
135  int k = countDecimalDigits( l.pos / sf, nDigits );
136 
137  digits = std::max( digits, k );
138  }
139 
140  for( auto &l : scale->TickLabels() )
141  {
142  l.label = formatFloat ( l.pos / sf, digits ) + suffix;
143  l.visible = true;
144  }
145 }
146 
147 
149 {
150 public:
151  FREQUENCY_LOG_SCALE( wxString name, int flags ) :
152  mpScaleXLog( name, flags ) {};
153 
154  void formatLabels() override
155  {
156  const wxString unit = wxT( "Hz" );
157  wxString suffix;
158  int power;
159 
160  for( auto &l : TickLabels() )
161  {
162  getSISuffix( l.pos, unit, power, suffix );
163  double sf = pow( 10.0, power );
164  int k = countDecimalDigits( l.pos / sf, 3 );
165 
166  l.label = formatFloat( l.pos / sf, k ) + suffix;
167  l.visible = true;
168  }
169  }
170 };
171 
172 
174 {
175 public:
176  FREQUENCY_LIN_SCALE( wxString name, int flags ) :
177  mpScaleX( name, flags, false , 0 ) {};
178 
179  void formatLabels() override
180  {
181  formatSILabels( this, wxT( "Hz" ), 3 );
182  }
183 };
184 
185 
186 class TIME_SCALE : public mpScaleX
187 {
188 public:
189  TIME_SCALE( wxString name, int flags ) :
190  mpScaleX( name, flags, false, 0 ) {};
191 
192  void formatLabels() override
193  {
194  formatSILabels( this, wxT( "s" ), 3 );
195  }
196 };
197 
198 
199 class VOLTAGE_SCALE_X : public mpScaleX
200 {
201 public:
202  VOLTAGE_SCALE_X( wxString name, int flags ) :
203  mpScaleX( name, flags, false, 0 ) {};
204 
205  void formatLabels() override
206  {
207  formatSILabels( this, wxT( "V" ), 3 );
208  }
209 };
210 
211 
212 class GAIN_SCALE : public mpScaleY
213 {
214 public:
215  GAIN_SCALE( wxString name, int flags ) :
216  mpScaleY( name, flags, false ) {};
217 
218  void formatLabels() override
219  {
220  formatSILabels( this, wxT( "dB" ), 3 );
221  }
222 
223 };
224 
225 
226 class PHASE_SCALE : public mpScaleY
227 {
228 public:
229  PHASE_SCALE( wxString name, int flags ) :
230  mpScaleY( name, flags, false ) {};
231 
232  void formatLabels() override
233  {
234  formatSILabels( this, wxT( "\u00B0" ), 3 ); // degree sign
235  }
236 };
237 
238 
239 class VOLTAGE_SCALE_Y : public mpScaleY
240 {
241 public:
242  VOLTAGE_SCALE_Y( wxString name, int flags ) :
243  mpScaleY( name, flags, false ) {};
244 
245  void formatLabels() override
246  {
247  formatSILabels( this, wxT( "V" ), 3 );
248  }
249 };
250 
251 
252 class CURRENT_SCALE : public mpScaleY
253 {
254 public:
255  CURRENT_SCALE( wxString name, int flags ) :
256  mpScaleY( name, flags, false ) {};
257 
258  void formatLabels() override
259  {
260  formatSILabels( this, wxT( "A" ), 3 );
261  }
262 };
263 
264 
265 void CURSOR::Plot( wxDC& aDC, mpWindow& aWindow )
266 {
267  if( !m_window )
268  m_window = &aWindow;
269 
270  if( !m_visible )
271  return;
272 
273  const auto& dataX = m_trace->GetDataX();
274  const auto& dataY = m_trace->GetDataY();
275 
276  if( dataX.size() <= 1 )
277  return;
278 
279  if( m_updateRequired )
280  {
281  m_coords.x = m_trace->s2x( aWindow.p2x( m_dim.x ) );
282 
283  // Find the closest point coordinates
284  auto maxXIt = std::upper_bound( dataX.begin(), dataX.end(), m_coords.x );
285  int maxIdx = maxXIt - dataX.begin();
286  int minIdx = maxIdx - 1;
287 
288  // Out of bounds checks
289  if( minIdx < 0 )
290  {
291  minIdx = 0;
292  maxIdx = 1;
293  m_coords.x = dataX[0];
294  }
295  else if( maxIdx >= (int) dataX.size() )
296  {
297  maxIdx = dataX.size() - 1;
298  minIdx = maxIdx - 1;
299  m_coords.x = dataX[maxIdx];
300  }
301 
302  const double leftX = dataX[minIdx];
303  const double rightX = dataX[maxIdx];
304  const double leftY = dataY[minIdx];
305  const double rightY = dataY[maxIdx];
306 
307  // Linear interpolation
308  m_coords.y = leftY + ( rightY - leftY ) / ( rightX - leftX ) * ( m_coords.x - leftX );
309  m_updateRequired = false;
310 
311  // Notify the parent window about the changes
312  wxQueueEvent( aWindow.GetParent(), new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
313  }
314  else
315  {
316  m_updateRef = true;
317  }
318 
319  if( m_updateRef )
320  {
321  UpdateReference();
322  m_updateRef = false;
323  }
324 
325  // Line length in horizontal and vertical dimensions
326  const wxPoint cursorPos( aWindow.x2p( m_trace->x2s( m_coords.x ) ),
327  aWindow.y2p( m_trace->y2s( m_coords.y ) ) );
328 
329  wxCoord leftPx = m_drawOutsideMargins ? 0 : aWindow.GetMarginLeft();
330  wxCoord rightPx = m_drawOutsideMargins ? aWindow.GetScrX() : aWindow.GetScrX() - aWindow.GetMarginRight();
331  wxCoord topPx = m_drawOutsideMargins ? 0 : aWindow.GetMarginTop();
332  wxCoord bottomPx = m_drawOutsideMargins ? aWindow.GetScrY() : aWindow.GetScrY() - aWindow.GetMarginBottom();
333 
334  aDC.SetPen( wxPen( *wxWHITE, 1, m_continuous ? wxPENSTYLE_SOLID : wxPENSTYLE_LONG_DASH ) );
335 
336  if( topPx < cursorPos.y && cursorPos.y < bottomPx )
337  aDC.DrawLine( leftPx, cursorPos.y, rightPx, cursorPos.y );
338 
339  if( leftPx < cursorPos.x && cursorPos.x < rightPx )
340  aDC.DrawLine( cursorPos.x, topPx, cursorPos.x, bottomPx );
341 }
342 
343 
344 bool CURSOR::Inside( wxPoint& aPoint )
345 {
346  if( !m_window )
347  return false;
348 
349  return ( std::abs( (double) aPoint.x - m_window->x2p( m_trace->x2s( m_coords.x ) ) ) <= DRAG_MARGIN )
350  || ( std::abs( (double) aPoint.y - m_window->y2p( m_trace->y2s( m_coords.y ) ) ) <= DRAG_MARGIN );
351 }
352 
353 
355 {
356  if( !m_window )
357  return;
358 
361 }
362 
363 
364 SIM_PLOT_PANEL::SIM_PLOT_PANEL( SIM_TYPE aType, wxWindow* parent, wxWindowID id, const wxPoint& pos,
365  const wxSize& size, long style, const wxString& name )
366  : mpWindow( parent, id, pos, size, style ), m_colorIdx( 0 ),
367  m_axis_x( nullptr ), m_axis_y1( nullptr ), m_axis_y2( nullptr ), m_type( aType )
368 {
369  LimitView( true );
370  SetMargins( 50, 80, 50, 80 );
371 
372  wxColour grey( 96, 96, 96 );
373  SetColourTheme( *wxBLACK, *wxWHITE, grey );
374  EnableDoubleBuffer( true );
375  UpdateAll();
376 
377  switch( m_type )
378  {
379  case ST_AC:
380  m_axis_x = new FREQUENCY_LOG_SCALE( wxT( "Frequency" ), mpALIGN_BOTTOM );
381  m_axis_y1 = new GAIN_SCALE( wxT( "Gain" ), mpALIGN_LEFT );
382  m_axis_y2 = new PHASE_SCALE( wxT( "Phase" ), mpALIGN_RIGHT );
384  break;
385 
386  case ST_DC:
387  m_axis_x = new VOLTAGE_SCALE_X( wxT( "Voltage (sweeped)" ), mpALIGN_BOTTOM );
388  m_axis_y1 = new VOLTAGE_SCALE_Y( wxT( "Voltage (measured)" ), mpALIGN_LEFT );
389  break;
390 
391  case ST_NOISE:
392  m_axis_x = new FREQUENCY_LOG_SCALE( wxT( "Frequency" ), mpALIGN_BOTTOM );
393  m_axis_y1 = new mpScaleY( wxT( "noise [(V or A)^2/Hz]" ), mpALIGN_LEFT );
394  break;
395 
396  case ST_TRANSIENT:
397  m_axis_x = new TIME_SCALE( wxT( "Time" ), mpALIGN_BOTTOM );
398  m_axis_y1 = new VOLTAGE_SCALE_Y( wxT( "Voltage" ), mpALIGN_LEFT );
399  m_axis_y2 = new CURRENT_SCALE( wxT( "Current" ), mpALIGN_RIGHT );
401  break;
402 
403  default:
404  // suppress warnings
405  break;
406  }
407 
408  if( m_axis_x )
409  {
410  m_axis_x->SetTicks( false );
412 
413  AddLayer( m_axis_x );
414  }
415 
416  if( m_axis_y1 )
417  {
418  m_axis_y1->SetTicks( false );
420  AddLayer( m_axis_y1 );
421  }
422 
423  if( m_axis_y2 )
424  {
425  m_axis_y2->SetTicks( false );
427  AddLayer( m_axis_y2 );
428  }
429 
430  m_legend = new mpInfoLegend( wxRect( 0, 40, 200, 40 ), wxTRANSPARENT_BRUSH );
431  m_legend->SetVisible( false );
432  AddLayer( m_legend );
433  m_topLevel.push_back( m_legend );
434  SetColourTheme( *wxBLACK, *wxWHITE, grey );
435 
436  EnableDoubleBuffer( true );
437  UpdateAll();
438 }
439 
440 
442 {
443  // ~mpWindow destroys all the added layers, so there is no need to destroy m_traces contents
444 }
445 
446 
448 {
449  switch( aSimType )
450  {
451  case ST_AC:
452  case ST_DC:
453  case ST_TRANSIENT:
454  return true;
455 
456  default:
457  return false;
458  }
459 }
460 
461 
462 bool SIM_PLOT_PANEL::AddTrace( const wxString& aName, int aPoints,
463  const double* aX, const double* aY, SIM_PLOT_TYPE aFlags )
464 {
465  TRACE* trace = NULL;
466 
467  // Find previous entry, if there is one
468  auto prev = m_traces.find( aName );
469  bool addedNewEntry = ( prev == m_traces.end() );
470 
471  if( addedNewEntry )
472  {
473  if( m_type == ST_TRANSIENT )
474  {
475  bool hasVoltageTraces = false;
476 
477  for( auto tr : m_traces )
478  {
479  if( !( tr.second->GetFlags() & SPT_CURRENT ) )
480  {
481  hasVoltageTraces = true;
482  break;
483  }
484  }
485 
486  if( !hasVoltageTraces )
487  m_axis_y2->SetMasterScale( nullptr );
488  else
490  }
491 
492  // New entry
493  trace = new TRACE( aName );
494  trace->SetTraceColour( generateColor() );
495  trace->SetPen( wxPen( trace->GetTraceColour(), 2, wxPENSTYLE_SOLID ) );
496  m_traces[aName] = trace;
497 
498  // It is a trick to keep legend & coords always on the top
499  for( mpLayer* l : m_topLevel )
500  DelLayer( l );
501 
502  AddLayer( (mpLayer*) trace );
503 
504  for( mpLayer* l : m_topLevel )
505  AddLayer( l );
506  }
507  else
508  {
509  trace = prev->second;
510  }
511 
512  std::vector<double> tmp( aY, aY + aPoints );
513 
514  if( m_type == ST_AC )
515  {
516  if( aFlags & SPT_AC_PHASE )
517  {
518  for( int i = 0; i < aPoints; i++ )
519  tmp[i] = tmp[i] * 180.0 / M_PI; // convert to degrees
520  }
521  else
522  {
523  for( int i = 0; i < aPoints; i++ )
524  tmp[i] = 20 * log( tmp[i] ) / log( 10.0 ); // convert to dB
525  }
526  }
527 
528  trace->SetData( std::vector<double>( aX, aX + aPoints ), tmp );
529 
530  if( aFlags & SPT_AC_PHASE || aFlags & SPT_CURRENT )
531  trace->SetScale( m_axis_x, m_axis_y2 );
532  else
533  trace->SetScale( m_axis_x, m_axis_y1 );
534 
535  trace->SetFlags( aFlags );
536 
537  UpdateAll();
538 
539  return addedNewEntry;
540 }
541 
542 
543 bool SIM_PLOT_PANEL::DeleteTrace( const wxString& aName )
544 {
545  auto it = m_traces.find( aName );
546 
547  if( it != m_traces.end() )
548  {
549  TRACE* trace = it->second;
550  m_traces.erase( it );
551 
552  if( CURSOR* cursor = trace->GetCursor() )
553  DelLayer( cursor, true );
554 
555  DelLayer( trace, true, true );
556  ResetScales();
557 
558  return true;
559  }
560 
561  return false;
562 }
563 
564 
566 {
567  for( auto& t : m_traces )
568  {
569  DeleteTrace( t.first );
570  }
571 
572  m_colorIdx = 0;
573  m_traces.clear();
574 }
575 
576 
577 bool SIM_PLOT_PANEL::HasCursorEnabled( const wxString& aName ) const
578 {
579  TRACE* t = GetTrace( aName );
580 
581  return t ? t->HasCursor() : false;
582 }
583 
584 
585 void SIM_PLOT_PANEL::EnableCursor( const wxString& aName, bool aEnable )
586 {
587  TRACE* t = GetTrace( aName );
588 
589  if( t == nullptr || t->HasCursor() == aEnable )
590  return;
591 
592  if( aEnable )
593  {
594  CURSOR* c = new CURSOR( t );
595  int plotCenter = GetMarginLeft() + ( GetXScreen() - GetMarginLeft() - GetMarginRight() ) / 2;
596  c->SetX( plotCenter );
597  t->SetCursor( c );
598  AddLayer( c );
599  }
600  else
601  {
602  CURSOR* c = t->GetCursor();
603  t->SetCursor( NULL );
604  DelLayer( c, true );
605  }
606 
607  // Notify the parent window about the changes
608  wxQueueEvent( GetParent(), new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
609 }
610 
611 
613 {
614  if( m_axis_x )
616 
617  if( m_axis_y1 )
619 
620  if( m_axis_y2 )
622 
623  for( auto t : m_traces )
624  t.second->UpdateScales();
625 }
626 
627 
629 {
633 
634  const unsigned long colors[] = { 0x0000ff, 0x00ff00, 0xff0000, 0x00ffff, 0xff00ff, 0xffff000, 0xffffff };
635 
636  //const unsigned long colors[] = { 0xe3cea6, 0xb4781f, 0x8adfb2, 0x2ca033, 0x999afb, 0x1c1ae3, 0x6fbffd, 0x007fff, 0xd6b2ca, 0x9a3d6a };
637 
638  // hls
639  //const unsigned long colors[] = { 0x0f1689, 0x0f7289, 0x35890f, 0x0f8945, 0x89260f, 0x890f53, 0x89820f, 0x630f89 };
640 
641  // pastels, good for dark background
642  //const unsigned long colors[] = { 0x2fd8fe, 0x628dfa, 0x53d8a6, 0xa5c266, 0xb3b3b3, 0x94c3e4, 0xca9f8d, 0xac680e };
643 
644  const unsigned int colorCount = sizeof(colors) / sizeof(unsigned long);
645 
647  return wxColour( colors[m_colorIdx++ % colorCount] );
648 }
649 
650 wxDEFINE_EVENT( EVT_SIM_CURSOR_UPDATE, wxCommandEvent );
GAIN_SCALE(wxString name, int flags)
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)
void Plot(wxDC &aDC, mpWindow &aWindow) override
Plot method.
#define mpALIGN_LEFT
Aligns label to the left.
Definition: mathplot.h:480
wxDEFINE_EVENT(EVT_SIM_CURSOR_UPDATE, wxCommandEvent)
bool m_continuous
Definition: mathplot.h:317
static wxString formatFloat(double x, int nDigits)
double y2s(double y) const
Definition: mathplot.cpp:4090
long trace
Definition: solve.cpp:232
static constexpr int DRAG_MARGIN
void SetNameAlign(int align)
Definition: mathplot.h:706
const TRACE * m_trace
wxRealPoint m_coords
mpScaleY * m_axis_y1
const SIM_TYPE m_type
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates, using current mpWindow position and scale.
Definition: mathplot.h:1185
const std::vector< double > & GetDataY() const
bool DelLayer(mpLayer *layer, bool alsoDeleteObject=false, bool refreshDisplay=true)
Remove a plot layer from the canvas.
Definition: mathplot.cpp:2483
virtual void SetScale(mpScaleBase *scaleX, mpScaleBase *scaleY)
Definition: mathplot.cpp:4052
std::vector< TickLabel > & TickLabels()
Definition: mathplot.h:786
void formatLabels() override
int GetMarginBottom()
Definition: mathplot.h:1350
static bool IsPlottable(SIM_TYPE aSimType)
CURSOR * GetCursor() const
mpScaleXBase * m_axis_x
wxColour GetTraceColour()
void SetMasterScale(mpScaleY *masterScale)
Definition: mathplot.h:976
static int countDecimalDigits(double x, int maxDigits)
int GetScrY(void) const
Get current view's Y dimension in device context units.
Definition: mathplot.h:1140
#define mpALIGN_RIGHT
Aligns label to the right.
Definition: mathplot.h:476
double s2x(double plotCoordX) const
Definition: mathplot.cpp:4072
bool AddLayer(mpLayer *layer, bool refreshDisplay=true)
Add a plot layer to the canvas.
Definition: mathplot.cpp:2466
VOLTAGE_SCALE_X(wxString name, int flags)
void formatLabels() override
#define abs(a)
Definition: auxiliary.h:84
void SetPen(wxPen pen)
Set layer pen.
Definition: mathplot.h:276
void UpdateReference() override
Updates the rectangle reference point.
void SetFlags(int aFlags)
void EnableDoubleBuffer(bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=disabled).
Definition: mathplot.h:1205
bool m_visible
Definition: mathplot.h:321
bool DeleteTrace(const wxString &aName)
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2814
void EnableCursor(const wxString &aName, bool aEnable)
Toggles cursor for a particular trace.
wxCoord y2p(double y)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.
Definition: mathplot.h:1200
void ResetDataRange()
Definition: mathplot.h:756
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:690
unsigned int m_colorIdx
void formatLabels() override
FREQUENCY_LIN_SCALE(wxString name, int flags)
void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:301
int GetMarginTop()
Definition: mathplot.h:1346
static void getSISuffix(double x, const wxString &unit, int &power, wxString &suffix)
std::vector< mpLayer * > m_topLevel
SIM_TYPE
Possible simulation types
Definition: sim_types.h:29
std::map< wxString, TRACE * > m_traces
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:938
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:3101
class WXDLLIMPEXP_MATHPLOT mpScaleY
Definition: mathplot.h:106
bool AddTrace(const wxString &aName, int aPoints, const double *aX, const double *aY, SIM_PLOT_TYPE aFlags)
void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour)
Set Color theme.
Definition: mathplot.cpp:3178
mpScaleY * m_axis_y2
void SetTicks(bool enable)
Set X axis ticks or grid.
Definition: mathplot.h:711
int GetScrX(void) const
Get current view's X dimension in device context units.
Definition: mathplot.h:1131
void ResetScales()
Resets scale ranges to fit the current traces
void formatLabels() override
bool m_updateRequired
void formatLabels() override
wxRect m_dim
Definition: mathplot.h:391
mpWindow * m_window
bool m_drawOutsideMargins
Definition: mathplot.h:319
int GetMarginRight()
Definition: mathplot.h:1348
wxPoint m_reference
Definition: mathplot.h:395
int GetMarginLeft()
Definition: mathplot.h:1352
bool HasCursor() const
TIME_SCALE(wxString name, int flags)
static void formatSILabels(mpScaleBase *scale, const wxString &aUnit, int nDigits)
const int scale
wxCoord x2p(double x)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates, using current mpWindow position and scale.
Definition: mathplot.h:1195
#define max(a, b)
Definition: auxiliary.h:86
CURRENT_SCALE(wxString name, int flags)
double AbsVisibleMaxValue() const
Definition: mathplot.h:766
TRACE * GetTrace(const wxString &aName) const
mpInfoLegend * m_legend
void SetX(int aX)
wxColour generateColor()
Returns a new color from the palette
void LimitView(bool aEnable)
Limit zooming & panning to the area used by the plots.
Definition: mathplot.h:1404
VOLTAGE_SCALE_Y(wxString name, int flags)
void formatLabels() override
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:1043
void SetTicks(bool ticks)
Set Y axis ticks or grid.
Definition: mathplot.h:966
const char * name
#define mpALIGN_BOTTOM
Aligns label to the bottom.
Definition: mathplot.h:484
const std::vector< double > & GetDataX() const
void formatLabels() override
PHASE_SCALE(wxString name, int flags)
int GetXScreen(void) const
Definition: mathplot.h:1132
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
void SetCursor(CURSOR *aCursor)
SIM_PLOT_TYPE
Possible plot types
Definition: sim_types.h:35
bool m_updateRef
FREQUENCY_LOG_SCALE(wxString name, int flags)
static VRML_COLOR colors[VRML_COLOR_LAST]
bool Inside(wxPoint &aPoint) override
Checks whether a point is inside the info box rectangle.
bool HasCursorEnabled(const wxString &aName) const
Returns true if the trace has cursor shown.
Cursor attached to a trace to follow its values:
void SetTraceColour(wxColour aColour)
void formatLabels() override
double x2s(double x) const
Definition: mathplot.cpp:4084