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 
359  m_reference.x = m_window->x2p( m_trace->x2s( m_coords.x ) );
360  m_reference.y = m_window->y2p( m_trace->y2s( m_coords.y ) );
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( _( "Frequency" ), mpALIGN_BOTTOM );
381  m_axis_y1 = new GAIN_SCALE( _( "Gain" ), mpALIGN_LEFT );
382  m_axis_y2 = new PHASE_SCALE( _( "Phase" ), mpALIGN_RIGHT );
384  break;
385 
386  case ST_DC:
387  m_axis_x = new VOLTAGE_SCALE_X( _( "Voltage (sweeped)" ), mpALIGN_BOTTOM );
388  m_axis_y1 = new VOLTAGE_SCALE_Y( _( "Voltage (measured)" ), mpALIGN_LEFT );
389  m_axis_y2 = new CURRENT_SCALE( _( "Current" ), mpALIGN_RIGHT );
390  break;
391 
392  case ST_NOISE:
393  m_axis_x = new FREQUENCY_LOG_SCALE( _( "Frequency" ), mpALIGN_BOTTOM );
394  m_axis_y1 = new mpScaleY( _( "noise [(V or A)^2/Hz]" ), mpALIGN_LEFT );
395  break;
396 
397  case ST_TRANSIENT:
398  m_axis_x = new TIME_SCALE( _( "Time" ), mpALIGN_BOTTOM );
399  m_axis_y1 = new VOLTAGE_SCALE_Y( _( "Voltage" ), mpALIGN_LEFT );
400  m_axis_y2 = new CURRENT_SCALE( _( "Current" ), mpALIGN_RIGHT );
402  break;
403 
404  default:
405  // suppress warnings
406  break;
407  }
408 
409  if( m_axis_x )
410  {
411  m_axis_x->SetTicks( false );
413 
414  AddLayer( m_axis_x );
415  }
416 
417  if( m_axis_y1 )
418  {
419  m_axis_y1->SetTicks( false );
421  AddLayer( m_axis_y1 );
422  }
423 
424  if( m_axis_y2 )
425  {
426  m_axis_y2->SetTicks( false );
428  AddLayer( m_axis_y2 );
429  }
430 
431  m_legend = new mpInfoLegend( wxRect( 0, 40, 200, 40 ), wxTRANSPARENT_BRUSH );
432  m_legend->SetVisible( false );
433  AddLayer( m_legend );
434  m_topLevel.push_back( m_legend );
435  SetColourTheme( *wxBLACK, *wxWHITE, grey );
436 
437  EnableDoubleBuffer( true );
438  UpdateAll();
439 }
440 
441 
443 {
444  // ~mpWindow destroys all the added layers, so there is no need to destroy m_traces contents
445 }
446 
447 
449 {
450  switch( aSimType )
451  {
452  case ST_AC:
453  case ST_DC:
454  case ST_TRANSIENT:
455  return true;
456 
457  default:
458  return false;
459  }
460 }
461 
462 
463 bool SIM_PLOT_PANEL::AddTrace( const wxString& aName, int aPoints,
464  const double* aX, const double* aY, SIM_PLOT_TYPE aFlags )
465 {
466  TRACE* trace = NULL;
467 
468  // Find previous entry, if there is one
469  auto prev = m_traces.find( aName );
470  bool addedNewEntry = ( prev == m_traces.end() );
471 
472  if( addedNewEntry )
473  {
474  if( m_type == ST_TRANSIENT )
475  {
476  bool hasVoltageTraces = false;
477 
478  for( auto tr : m_traces )
479  {
480  if( !( tr.second->GetFlags() & SPT_CURRENT ) )
481  {
482  hasVoltageTraces = true;
483  break;
484  }
485  }
486 
487  if( !hasVoltageTraces )
488  m_axis_y2->SetMasterScale( nullptr );
489  else
491  }
492 
493  // New entry
494  trace = new TRACE( aName );
495  trace->SetTraceColour( generateColor() );
496  trace->SetPen( wxPen( trace->GetTraceColour(), 2, wxPENSTYLE_SOLID ) );
497  m_traces[aName] = trace;
498 
499  // It is a trick to keep legend & coords always on the top
500  for( mpLayer* l : m_topLevel )
501  DelLayer( l );
502 
503  AddLayer( (mpLayer*) trace );
504 
505  for( mpLayer* l : m_topLevel )
506  AddLayer( l );
507  }
508  else
509  {
510  trace = prev->second;
511  }
512 
513  std::vector<double> tmp( aY, aY + aPoints );
514 
515  if( m_type == ST_AC )
516  {
517  if( aFlags & SPT_AC_PHASE )
518  {
519  for( int i = 0; i < aPoints; i++ )
520  tmp[i] = tmp[i] * 180.0 / M_PI; // convert to degrees
521  }
522  else
523  {
524  for( int i = 0; i < aPoints; i++ )
525  tmp[i] = 20 * log( tmp[i] ) / log( 10.0 ); // convert to dB
526  }
527  }
528 
529  trace->SetData( std::vector<double>( aX, aX + aPoints ), tmp );
530 
531  if( aFlags & SPT_AC_PHASE || aFlags & SPT_CURRENT )
532  trace->SetScale( m_axis_x, m_axis_y2 );
533  else
534  trace->SetScale( m_axis_x, m_axis_y1 );
535 
536  trace->SetFlags( aFlags );
537 
538  UpdateAll();
539 
540  return addedNewEntry;
541 }
542 
543 
544 bool SIM_PLOT_PANEL::DeleteTrace( const wxString& aName )
545 {
546  auto it = m_traces.find( aName );
547 
548  if( it != m_traces.end() )
549  {
550  TRACE* trace = it->second;
551  m_traces.erase( it );
552 
553  if( CURSOR* cursor = trace->GetCursor() )
554  DelLayer( cursor, true );
555 
556  DelLayer( trace, true, true );
557  ResetScales();
558 
559  return true;
560  }
561 
562  return false;
563 }
564 
565 
567 {
568  for( auto& t : m_traces )
569  {
570  DeleteTrace( t.first );
571  }
572 
573  m_colorIdx = 0;
574  m_traces.clear();
575 }
576 
577 
578 bool SIM_PLOT_PANEL::HasCursorEnabled( const wxString& aName ) const
579 {
580  TRACE* t = GetTrace( aName );
581 
582  return t ? t->HasCursor() : false;
583 }
584 
585 
586 void SIM_PLOT_PANEL::EnableCursor( const wxString& aName, bool aEnable )
587 {
588  TRACE* t = GetTrace( aName );
589 
590  if( t == nullptr || t->HasCursor() == aEnable )
591  return;
592 
593  if( aEnable )
594  {
595  CURSOR* c = new CURSOR( t );
596  int plotCenter = GetMarginLeft() + ( GetXScreen() - GetMarginLeft() - GetMarginRight() ) / 2;
597  c->SetX( plotCenter );
598  t->SetCursor( c );
599  AddLayer( c );
600  }
601  else
602  {
603  CURSOR* c = t->GetCursor();
604  t->SetCursor( NULL );
605  DelLayer( c, true );
606  }
607 
608  // Notify the parent window about the changes
609  wxQueueEvent( GetParent(), new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
610 }
611 
612 
614 {
615  if( m_axis_x )
617 
618  if( m_axis_y1 )
620 
621  if( m_axis_y2 )
623 
624  for( auto t : m_traces )
625  t.second->UpdateScales();
626 }
627 
628 
630 {
634 
635  const unsigned long colors[] = { 0x0000ff, 0x00ff00, 0xff0000, 0x00ffff, 0xff00ff, 0xffff000, 0xffffff };
636 
637  //const unsigned long colors[] = { 0xe3cea6, 0xb4781f, 0x8adfb2, 0x2ca033, 0x999afb, 0x1c1ae3, 0x6fbffd, 0x007fff, 0xd6b2ca, 0x9a3d6a };
638 
639  // hls
640  //const unsigned long colors[] = { 0x0f1689, 0x0f7289, 0x35890f, 0x0f8945, 0x89260f, 0x890f53, 0x89820f, 0x630f89 };
641 
642  // pastels, good for dark background
643  //const unsigned long colors[] = { 0x2fd8fe, 0x628dfa, 0x53d8a6, 0xa5c266, 0xb3b3b3, 0x94c3e4, 0xca9f8d, 0xac680e };
644 
645  const unsigned int colorCount = sizeof(colors) / sizeof(unsigned long);
646 
648  return wxColour( colors[m_colorIdx++ % colorCount] );
649 }
650 
651 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)
long trace
Definition: solve.cpp:232
void SetNameAlign(int align)
Definition: mathplot.h:706
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
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&#39;s Y dimension in device context units.
Definition: mathplot.h:1140
#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: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&#39;s X dimension in device context units.
Definition: mathplot.h:1131
void ResetScales()
Resets scale ranges to fit the current traces
void formatLabels() override
void formatLabels() override
bool m_drawOutsideMargins
Definition: mathplot.h:319
int GetMarginRight()
Definition: mathplot.h:1348
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
const char * name
Definition: DXF_plotter.cpp:61
#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)
size_t i
Definition: json11.cpp:597
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
mpLayerType m_type
Definition: mathplot.h:320
#define mpALIGN_BOTTOM
Aligns label to the bottom.
Definition: mathplot.h:484
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
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