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 #include "sim_plot_frame.h"
28 
29 #include <algorithm>
30 #include <limits>
31 
32 static wxString formatFloat( double x, int nDigits )
33 {
34  wxString rv, fmt;
35 
36  if( nDigits )
37  {
38  fmt = wxT( "%.0Nf" );
39  fmt[3] = '0' + nDigits;
40  }
41  else
42  {
43  fmt = wxT( "%.0f" );
44  }
45 
46  rv.Printf( fmt, x );
47 
48  return rv;
49 }
50 
51 
52 static void getSISuffix( double x, const wxString& unit, int& power, wxString& suffix )
53 {
54  const int n_powers = 11;
55 
56  const struct
57  {
58  double exponent;
59  char suffix;
60  } powers[] =
61  {
62  { -18, 'a' },
63  { -15, 'f' },
64  { -12, 'p' },
65  { -9, 'n' },
66  { -6, 'u' },
67  { -3, 'm' },
68  { 0, 0 },
69  { 3, 'k' },
70  { 6, 'M' },
71  { 9, 'G' },
72  { 12, 'T' },
73  { 14, 'P' }
74  };
75 
76  power = 0;
77  suffix = unit;
78 
79  if( x == 0.0 )
80  return;
81 
82  for( int i = 0; i < n_powers - 1; i++ )
83  {
84  double r_cur = pow( 10, powers[i].exponent );
85 
86  if( fabs( x ) >= r_cur && fabs( x ) < r_cur * 1000.0 )
87  {
88  power = powers[i].exponent;
89 
90  if( powers[i].suffix )
91  suffix = wxString( powers[i].suffix ) + unit;
92  else
93  suffix = unit;
94 
95  return;
96  }
97  }
98 }
99 
100 
101 static int countDecimalDigits( double x, int maxDigits )
102 {
103  int64_t k = (int)( ( x - floor( x ) ) * pow( 10.0, (double) maxDigits ) );
104  int n = 0;
105 
106  while( k && ( ( k % 10LL ) == 0LL || ( k % 10LL ) == 9LL ) )
107  {
108  k /= 10LL;
109  }
110 
111  n = 0;
112 
113  while( k != 0LL )
114  {
115  n++;
116  k /= 10LL;
117  }
118 
119  return n;
120 }
121 
122 
123 static void formatSILabels( mpScaleBase* scale, const wxString& aUnit, int nDigits )
124 {
125  double maxVis = scale->AbsVisibleMaxValue();
126 
127  wxString suffix;
128  int power, digits = 0;
129 
130  getSISuffix( maxVis, aUnit, power, suffix );
131 
132  double sf = pow( 10.0, power );
133 
134  for( auto &l : scale->TickLabels() )
135  {
136  int k = countDecimalDigits( l.pos / sf, nDigits );
137 
138  digits = std::max( digits, k );
139  }
140 
141  for( auto &l : scale->TickLabels() )
142  {
143  l.label = formatFloat ( l.pos / sf, digits ) + suffix;
144  l.visible = true;
145  }
146 }
147 
148 
150 {
151 public:
152  FREQUENCY_LOG_SCALE( wxString name, int flags ) :
153  mpScaleXLog( name, flags ) {};
154 
155  void formatLabels() override
156  {
157  const wxString unit = wxT( "Hz" );
158  wxString suffix;
159  int power;
160 
161  for( auto &l : TickLabels() )
162  {
163  getSISuffix( l.pos, unit, power, suffix );
164  double sf = pow( 10.0, power );
165  int k = countDecimalDigits( l.pos / sf, 3 );
166 
167  l.label = formatFloat( l.pos / sf, k ) + suffix;
168  l.visible = true;
169  }
170  }
171 };
172 
173 
175 {
176 public:
177  FREQUENCY_LIN_SCALE( wxString name, int flags ) :
178  mpScaleX( name, flags, false , 0 ) {};
179 
180  void formatLabels() override
181  {
182  formatSILabels( this, wxT( "Hz" ), 3 );
183  }
184 };
185 
186 
187 class TIME_SCALE : public mpScaleX
188 {
189 public:
190  TIME_SCALE( wxString name, int flags ) :
191  mpScaleX( name, flags, false, 0 ) {};
192 
193  void formatLabels() override
194  {
195  formatSILabels( this, wxT( "s" ), 3 );
196  }
197 };
198 
199 
200 class VOLTAGE_SCALE_X : public mpScaleX
201 {
202 public:
203  VOLTAGE_SCALE_X( wxString name, int flags ) :
204  mpScaleX( name, flags, false, 0 ) {};
205 
206  void formatLabels() override
207  {
208  formatSILabels( this, wxT( "V" ), 3 );
209  }
210 };
211 
212 
213 class GAIN_SCALE : public mpScaleY
214 {
215 public:
216  GAIN_SCALE( wxString name, int flags ) :
217  mpScaleY( name, flags, false ) {};
218 
219  void formatLabels() override
220  {
221  formatSILabels( this, wxT( "dBV" ), 3 );
222  }
223 
224 };
225 
226 
227 class PHASE_SCALE : public mpScaleY
228 {
229 public:
230  PHASE_SCALE( wxString name, int flags ) :
231  mpScaleY( name, flags, false ) {};
232 
233  void formatLabels() override
234  {
235  formatSILabels( this, wxT( "\u00B0" ), 3 ); // degree sign
236  }
237 };
238 
239 
240 class VOLTAGE_SCALE_Y : public mpScaleY
241 {
242 public:
243  VOLTAGE_SCALE_Y( wxString name, int flags ) :
244  mpScaleY( name, flags, false ) {};
245 
246  void formatLabels() override
247  {
248  formatSILabels( this, wxT( "V" ), 3 );
249  }
250 };
251 
252 
253 class CURRENT_SCALE : public mpScaleY
254 {
255 public:
256  CURRENT_SCALE( wxString name, int flags ) :
257  mpScaleY( name, flags, false ) {};
258 
259  void formatLabels() override
260  {
261  formatSILabels( this, wxT( "A" ), 3 );
262  }
263 };
264 
265 
266 void CURSOR::Plot( wxDC& aDC, mpWindow& aWindow )
267 {
268  if( !m_window )
269  m_window = &aWindow;
270 
271  if( !m_visible )
272  return;
273 
274  const auto& dataX = m_trace->GetDataX();
275  const auto& dataY = m_trace->GetDataY();
276 
277  if( dataX.size() <= 1 )
278  return;
279 
280  if( m_updateRequired )
281  {
282  m_coords.x = m_trace->s2x( aWindow.p2x( m_dim.x ) );
283 
284  // Find the closest point coordinates
285  auto maxXIt = std::upper_bound( dataX.begin(), dataX.end(), m_coords.x );
286  int maxIdx = maxXIt - dataX.begin();
287  int minIdx = maxIdx - 1;
288 
289  // Out of bounds checks
290  if( minIdx < 0 )
291  {
292  minIdx = 0;
293  maxIdx = 1;
294  m_coords.x = dataX[0];
295  }
296  else if( maxIdx >= (int) dataX.size() )
297  {
298  maxIdx = dataX.size() - 1;
299  minIdx = maxIdx - 1;
300  m_coords.x = dataX[maxIdx];
301  }
302 
303  const double leftX = dataX[minIdx];
304  const double rightX = dataX[maxIdx];
305  const double leftY = dataY[minIdx];
306  const double rightY = dataY[maxIdx];
307 
308  // Linear interpolation
309  m_coords.y = leftY + ( rightY - leftY ) / ( rightX - leftX ) * ( m_coords.x - leftX );
310  m_updateRequired = false;
311 
312  // Notify the parent window about the changes
313  wxQueueEvent( aWindow.GetParent(), new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
314  }
315  else
316  {
317  m_updateRef = true;
318  }
319 
320  if( m_updateRef )
321  {
322  UpdateReference();
323  m_updateRef = false;
324  }
325 
326  // Line length in horizontal and vertical dimensions
327  const wxPoint cursorPos( aWindow.x2p( m_trace->x2s( m_coords.x ) ),
328  aWindow.y2p( m_trace->y2s( m_coords.y ) ) );
329 
330  wxCoord leftPx = m_drawOutsideMargins ? 0 : aWindow.GetMarginLeft();
331  wxCoord rightPx = m_drawOutsideMargins ? aWindow.GetScrX() : aWindow.GetScrX() - aWindow.GetMarginRight();
332  wxCoord topPx = m_drawOutsideMargins ? 0 : aWindow.GetMarginTop();
333  wxCoord bottomPx = m_drawOutsideMargins ? aWindow.GetScrY() : aWindow.GetScrY() - aWindow.GetMarginBottom();
334 
335  aDC.SetPen( wxPen( m_plotPanel->GetPlotColor( SIM_CURSOR_COLOR ), 1,
336  m_continuous ? wxPENSTYLE_SOLID : wxPENSTYLE_LONG_DASH ) );
337 
338  if( topPx < cursorPos.y && cursorPos.y < bottomPx )
339  aDC.DrawLine( leftPx, cursorPos.y, rightPx, cursorPos.y );
340 
341  if( leftPx < cursorPos.x && cursorPos.x < rightPx )
342  aDC.DrawLine( cursorPos.x, topPx, cursorPos.x, bottomPx );
343 }
344 
345 
346 bool CURSOR::Inside( wxPoint& aPoint )
347 {
348  if( !m_window )
349  return false;
350 
351  return ( std::abs( (double) aPoint.x - m_window->x2p( m_trace->x2s( m_coords.x ) ) ) <= DRAG_MARGIN )
352  || ( std::abs( (double) aPoint.y - m_window->y2p( m_trace->y2s( m_coords.y ) ) ) <= DRAG_MARGIN );
353 }
354 
355 
357 {
358  if( !m_window )
359  return;
360 
363 }
364 
365 
366 SIM_PLOT_PANEL::SIM_PLOT_PANEL( SIM_TYPE aType, wxWindow* parent, SIM_PLOT_FRAME* aMainFrame,
367  wxWindowID id, const wxPoint& pos,
368  const wxSize& size, long style, const wxString& name )
369  : mpWindow( parent, id, pos, size, style ),
370  m_colorIdx( 0 ),
371  m_axis_x( nullptr ),
372  m_axis_y1( nullptr ),
373  m_axis_y2( nullptr ),
374  m_dotted_cp( false ),
375  m_type( aType ),
376  m_masterFrame( aMainFrame )
377 {
378  LimitView( true );
379  SetMargins( 50, 80, 50, 80 );
380 
384 
385  switch( m_type )
386  {
387  case ST_AC:
388  m_axis_x = new FREQUENCY_LOG_SCALE( _( "Frequency" ), mpALIGN_BOTTOM );
389  m_axis_y1 = new GAIN_SCALE( _( "Gain" ), mpALIGN_LEFT );
390  m_axis_y2 = new PHASE_SCALE( _( "Phase" ), mpALIGN_RIGHT );
392  break;
393 
394  case ST_DC:
395  m_axis_x = new VOLTAGE_SCALE_X( _( "Voltage (swept)" ), mpALIGN_BOTTOM );
396  m_axis_y1 = new VOLTAGE_SCALE_Y( _( "Voltage (measured)" ), mpALIGN_LEFT );
397  m_axis_y2 = new CURRENT_SCALE( _( "Current" ), mpALIGN_RIGHT );
398  break;
399 
400  case ST_NOISE:
401  m_axis_x = new FREQUENCY_LOG_SCALE( _( "Frequency" ), mpALIGN_BOTTOM );
402  m_axis_y1 = new mpScaleY( _( "noise [(V or A)^2/Hz]" ), mpALIGN_LEFT );
403  break;
404 
405  case ST_TRANSIENT:
406  m_axis_x = new TIME_SCALE( _( "Time" ), mpALIGN_BOTTOM );
407  m_axis_y1 = new VOLTAGE_SCALE_Y( _( "Voltage" ), mpALIGN_LEFT );
408  m_axis_y2 = new CURRENT_SCALE( _( "Current" ), mpALIGN_RIGHT );
410  break;
411 
412  default:
413  // suppress warnings
414  break;
415  }
416 
417  if( m_axis_x )
418  {
419  m_axis_x->SetTicks( false );
421 
422  AddLayer( m_axis_x );
423  }
424 
425  if( m_axis_y1 )
426  {
427  m_axis_y1->SetTicks( false );
429  AddLayer( m_axis_y1 );
430  }
431 
432  if( m_axis_y2 )
433  {
434  m_axis_y2->SetTicks( false );
436  AddLayer( m_axis_y2 );
437  }
438 
439  // a mpInfoLegend displays le name of traces on the left top panel corner:
440  m_legend = new mpInfoLegend( wxRect( 0, 40, 200, 40 ), wxTRANSPARENT_BRUSH );
441  m_legend->SetVisible( false );
442  AddLayer( m_legend );
443 
444  EnableDoubleBuffer( true );
445  UpdateAll();
446 }
447 
448 
450 {
451  // ~mpWindow destroys all the added layers, so there is no need to destroy m_traces contents
452 }
453 
454 
456 {
457  // Update bg and fg colors:
461 
462  UpdateAll();
463 }
464 
465 
466 wxColour SIM_PLOT_PANEL::GetPlotColor( int aIndex )
467 {
468  return m_masterFrame->GetPlotColor( aIndex );
469 }
470 
471 
473 {
474  switch( aSimType )
475  {
476  case ST_AC:
477  case ST_DC:
478  case ST_TRANSIENT:
479  return true;
480 
481  default:
482  return false;
483  }
484 }
485 
486 
488 {
489  int flags = trace->GetFlags();
490  wxPenStyle penStyle = ( ( flags & SPT_AC_PHASE || flags & SPT_CURRENT ) && m_dotted_cp ) ?
491  wxPENSTYLE_DOT :
492  wxPENSTYLE_SOLID;
493  trace->SetPen( wxPen( trace->GetTraceColour(), 2, penStyle ) );
494 }
495 
496 
497 bool SIM_PLOT_PANEL::AddTrace( const wxString& aName, int aPoints,
498  const double* aX, const double* aY, SIM_PLOT_TYPE aFlags )
499 {
500  TRACE* trace = NULL;
501 
502  // Find previous entry, if there is one
503  auto prev = m_traces.find( aName );
504  bool addedNewEntry = ( prev == m_traces.end() );
505 
506  if( addedNewEntry )
507  {
508  if( m_type == ST_TRANSIENT )
509  {
510  bool hasVoltageTraces = false;
511 
512  for( const auto& tr : m_traces )
513  {
514  if( !( tr.second->GetFlags() & SPT_CURRENT ) )
515  {
516  hasVoltageTraces = true;
517  break;
518  }
519  }
520 
521  if( !hasVoltageTraces )
522  m_axis_y2->SetMasterScale( nullptr );
523  else
525  }
526 
527  // New entry
528  trace = new TRACE( aName );
529  trace->SetTraceColour( generateColor() );
530  UpdateTraceStyle( trace );
531  m_traces[aName] = trace;
532 
533  // It is a trick to keep legend & coords always on the top
534  for( mpLayer* l : m_topLevel )
535  DelLayer( l );
536 
537  AddLayer( (mpLayer*) trace );
538 
539  for( mpLayer* l : m_topLevel )
540  AddLayer( l );
541  }
542  else
543  {
544  trace = prev->second;
545  }
546 
547  std::vector<double> tmp( aY, aY + aPoints );
548 
549  if( m_type == ST_AC )
550  {
551  if( aFlags & SPT_AC_PHASE )
552  {
553  for( int i = 0; i < aPoints; i++ )
554  tmp[i] = tmp[i] * 180.0 / M_PI; // convert to degrees
555  }
556  else
557  {
558  for( int i = 0; i < aPoints; i++ )
559  tmp[i] = 20 * log( tmp[i] ) / log( 10.0 ); // convert to dB
560  }
561  }
562 
563  trace->SetData( std::vector<double>( aX, aX + aPoints ), tmp );
564 
565  if( aFlags & SPT_AC_PHASE || aFlags & SPT_CURRENT )
566  trace->SetScale( m_axis_x, m_axis_y2 );
567  else
568  trace->SetScale( m_axis_x, m_axis_y1 );
569 
570  trace->SetFlags( aFlags );
571 
572  UpdateAll();
573 
574  return addedNewEntry;
575 }
576 
577 
578 bool SIM_PLOT_PANEL::DeleteTrace( const wxString& aName )
579 {
580  auto it = m_traces.find( aName );
581 
582  if( it != m_traces.end() )
583  {
584  TRACE* trace = it->second;
585  m_traces.erase( it );
586 
587  if( CURSOR* cursor = trace->GetCursor() )
588  DelLayer( cursor, true );
589 
590  DelLayer( trace, true, true );
591  ResetScales();
592 
593  return true;
594  }
595 
596  return false;
597 }
598 
599 
601 {
602  for( auto& t : m_traces )
603  {
604  DeleteTrace( t.first );
605  }
606 
607  m_colorIdx = 0;
608  m_traces.clear();
609 }
610 
611 
612 bool SIM_PLOT_PANEL::HasCursorEnabled( const wxString& aName ) const
613 {
614  TRACE* t = GetTrace( aName );
615 
616  return t ? t->HasCursor() : false;
617 }
618 
619 
620 void SIM_PLOT_PANEL::EnableCursor( const wxString& aName, bool aEnable )
621 {
622  TRACE* t = GetTrace( aName );
623 
624  if( t == nullptr || t->HasCursor() == aEnable )
625  return;
626 
627  if( aEnable )
628  {
629  CURSOR* c = new CURSOR( t, this );
630  int plotCenter = GetMarginLeft() + ( GetXScreen() - GetMarginLeft() - GetMarginRight() ) / 2;
631  c->SetX( plotCenter );
632  t->SetCursor( c );
633  AddLayer( c );
634  }
635  else
636  {
637  CURSOR* c = t->GetCursor();
638  t->SetCursor( NULL );
639  DelLayer( c, true );
640  }
641 
642  // Notify the parent window about the changes
643  wxQueueEvent( GetParent(), new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
644 }
645 
646 
648 {
649  if( m_axis_x )
651 
652  if( m_axis_y1 )
654 
655  if( m_axis_y2 )
657 
658  for( auto t : m_traces )
659  t.second->UpdateScales();
660 }
661 
662 
664 {
665  const unsigned int colorCount = m_masterFrame->GetPlotColorCount() - SIM_TRACE_COLOR;
666 
667  for( int i = 0; i < (int)colorCount - 1; i++ )
668  {
669  const wxColour color = GetPlotColor( i+SIM_TRACE_COLOR );
670  bool hasColor = false;
671 
672  for( auto& t : m_traces )
673  {
674  TRACE* trace = t.second;
675 
676  if( trace->GetTraceColour() == color )
677  {
678  hasColor = true;
679  break;
680  }
681  }
682 
683  if( !hasColor )
684  return color;
685  }
686 
687  // If all colors are in use, choose a suitable color in list
688  int idx = m_traces.size() % colorCount;
689  return wxColour( GetPlotColor( idx + SIM_TRACE_COLOR ) );
690 }
691 
692 wxDEFINE_EVENT( EVT_SIM_CURSOR_UPDATE, wxCommandEvent );
GAIN_SCALE(wxString name, int flags)
void Plot(wxDC &aDC, mpWindow &aWindow) override
Plot method.
double s2x(double plotCoordX) const
Definition: mathplot.cpp:4102
#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)
static constexpr int DRAG_MARGIN
void SetNameAlign(int align)
Definition: mathplot.h:708
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,...
Definition: mathplot.h:1187
bool HasCursor() const
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
std::vector< TickLabel > & TickLabels()
Definition: mathplot.h:788
int GetXScreen(void) const
Definition: mathplot.h:1134
void formatLabels() override
int GetMarginBottom()
Definition: mathplot.h:1370
int color
Definition: DXF_plotter.cpp:61
const std::vector< double > & GetDataX() const
static bool IsPlottable(SIM_TYPE aSimType)
mpScaleXBase * m_axis_x
bool HasCursorEnabled(const wxString &aName) const
Returns true if the trace has cursor shown.
wxColour GetTraceColour()
void SetMasterScale(mpScaleY *masterScale)
Definition: mathplot.h:978
double y2s(double y) const
Definition: mathplot.cpp:4120
static int countDecimalDigits(double x, int maxDigits)
#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
SIM_PLOT_FRAME * m_masterFrame
VOLTAGE_SCALE_X(wxString name, int flags)
void formatLabels() override
TRACE * GetTrace(const wxString &aName) const
void SetPen(wxPen pen)
Set layer pen.
Definition: mathplot.h:276
SIM_PLOT_PANEL * m_plotPanel
void UpdateTraceStyle(TRACE *trace)
Update trace line style
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:1207
bool m_visible
Definition: mathplot.h:321
bool DeleteTrace(const wxString &aName)
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2836
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,...
Definition: mathplot.h:1202
void ResetDataRange()
Definition: mathplot.h:758
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:692
#define NULL
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
wxColor GetPlotColor(int aColorId)
int GetMarginTop()
Definition: mathplot.h:1366
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
int GetScrX(void) const
Get current view's X dimension in device context units.
Definition: mathplot.h:1133
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:940
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
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:3201
mpScaleY * m_axis_y2
void SetTicks(bool enable)
Set X axis ticks or grid.
Definition: mathplot.h:713
Subclass of SIM_PLOT_FRAME_BASE, which is generated by wxFormBuilder.
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
Implementing SIM_PLOT_FRAME_BASE.
mpWindow * m_window
SIM_PLOT_PANEL(SIM_TYPE aType, wxWindow *parent, SIM_PLOT_FRAME *aMainFrame, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxPanelNameStr)
bool m_drawOutsideMargins
Definition: mathplot.h:319
int GetMarginRight()
Definition: mathplot.h:1368
wxPoint m_reference
Definition: mathplot.h:395
int GetMarginLeft()
Definition: mathplot.h:1372
double x2s(double x) const
Definition: mathplot.cpp:4114
TIME_SCALE(wxString name, int flags)
static void formatSILabels(mpScaleBase *scale, const wxString &aUnit, int nDigits)
void UpdatePlotColors()
Update plot colors
const int scale
wxCoord x2p(double x)
Converts graph (floating point) coordinates into mpWindow (screen) pixel coordinates,...
Definition: mathplot.h:1197
const char * name
Definition: DXF_plotter.cpp:60
CURRENT_SCALE(wxString name, int flags)
int GetFlags() const
#define _(s)
Definition: 3d_actions.cpp:33
mpInfoLegend * m_legend
void SetX(int aX)
CURSOR * GetCursor() const
wxColour generateColor()
void LimitView(bool aEnable)
Limit zooming & panning to the area used by the plots.
Definition: mathplot.h:1424
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:1045
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
const std::vector< double > & GetDataY() const
void formatLabels() override
PHASE_SCALE(wxString name, 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:436
wxColour GetPlotColor(int aIndex)
A proxy to SIM_PLOT_FRAME::GetPlotColor()
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)
bool Inside(wxPoint &aPoint) override
Checks whether a point is inside the info box rectangle.
Cursor attached to a trace to follow its values:
void SetTraceColour(wxColour aColour)
void formatLabels() override
int GetScrY(void) const
Get current view's Y dimension in device context units.
Definition: mathplot.h:1142