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, const wxSize& size, long style, const wxString& name )
368  : SIM_PANEL_BASE( aType, parent, id, pos, size, style, name ),
369  m_colorIdx( 0 ),
370  m_axis_x( nullptr ),
371  m_axis_y1( nullptr ),
372  m_axis_y2( nullptr ),
373  m_dotted_cp( false ),
374  m_masterFrame( aMainFrame )
375 {
376  m_sizer = new wxBoxSizer( wxVERTICAL );
377  m_plotWin = new mpWindow( this, wxID_ANY, pos, size, style );
378 
379  m_plotWin->LimitView( true );
380  m_plotWin->SetMargins( 50, 80, 50, 80 );
381 
384 
385  switch( GetType() )
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 
423  }
424 
425  if( m_axis_y1 )
426  {
427  m_axis_y1->SetTicks( false );
430  }
431 
432  if( m_axis_y2 )
433  {
434  m_axis_y2->SetTicks( false );
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 );
443 
444  m_plotWin->EnableDoubleBuffer( true );
445  m_plotWin->UpdateAll();
446 
447  m_sizer->Add( m_plotWin, 1, wxALL | wxEXPAND, 1 );
448  SetSizer( m_sizer );
449 }
450 
451 
453 {
454  // ~mpWindow destroys all the added layers, so there is no need to destroy m_traces contents
455 }
456 
457 
459 {
460  // Update bg and fg colors:
463 
464  m_plotWin->UpdateAll();
465 }
466 
467 
468 wxColour SIM_PLOT_PANEL::GetPlotColor( int aIndex )
469 {
470  return m_masterFrame->GetPlotColor( aIndex );
471 }
472 
473 
475 {
476  int flags = trace->GetFlags();
477  wxPenStyle penStyle = ( ( flags & SPT_AC_PHASE || flags & SPT_CURRENT ) && m_dotted_cp ) ?
478  wxPENSTYLE_DOT :
479  wxPENSTYLE_SOLID;
480  trace->SetPen( wxPen( trace->GetTraceColour(), 2, penStyle ) );
481 }
482 
483 
484 bool SIM_PLOT_PANEL::AddTrace( const wxString& aName, int aPoints,
485  const double* aX, const double* aY, SIM_PLOT_TYPE aFlags )
486 {
487  TRACE* trace = NULL;
488 
489  // Find previous entry, if there is one
490  auto prev = m_traces.find( aName );
491  bool addedNewEntry = ( prev == m_traces.end() );
492 
493  if( addedNewEntry )
494  {
495  if( GetType() == ST_TRANSIENT )
496  {
497  bool hasVoltageTraces = false;
498 
499  for( const auto& tr : m_traces )
500  {
501  if( !( tr.second->GetFlags() & SPT_CURRENT ) )
502  {
503  hasVoltageTraces = true;
504  break;
505  }
506  }
507 
508  if( !hasVoltageTraces )
509  m_axis_y2->SetMasterScale( nullptr );
510  else
512  }
513 
514  // New entry
515  trace = new TRACE( aName );
516  trace->SetTraceColour( generateColor() );
517  UpdateTraceStyle( trace );
518  m_traces[aName] = trace;
519 
520  // It is a trick to keep legend & coords always on the top
521  for( mpLayer* l : m_topLevel )
522  m_plotWin->DelLayer( l );
523 
524  m_plotWin->AddLayer( (mpLayer*) trace );
525 
526  for( mpLayer* l : m_topLevel )
527  m_plotWin->AddLayer( l );
528  }
529  else
530  {
531  trace = prev->second;
532  }
533 
534  std::vector<double> tmp( aY, aY + aPoints );
535 
536  if( GetType() == ST_AC )
537  {
538  if( aFlags & SPT_AC_PHASE )
539  {
540  for( int i = 0; i < aPoints; i++ )
541  tmp[i] = tmp[i] * 180.0 / M_PI; // convert to degrees
542  }
543  else
544  {
545  for( int i = 0; i < aPoints; i++ )
546  tmp[i] = 20 * log( tmp[i] ) / log( 10.0 ); // convert to dB
547  }
548  }
549 
550  trace->SetData( std::vector<double>( aX, aX + aPoints ), tmp );
551 
552  if( ( aFlags & SPT_AC_PHASE ) || ( aFlags & SPT_CURRENT ) )
553  trace->SetScale( m_axis_x, m_axis_y2 );
554  else
555  trace->SetScale( m_axis_x, m_axis_y1 );
556 
557  trace->SetFlags( aFlags );
558 
559  m_plotWin->UpdateAll();
560 
561  return addedNewEntry;
562 }
563 
564 
565 bool SIM_PLOT_PANEL::DeleteTrace( const wxString& aName )
566 {
567  auto it = m_traces.find( aName );
568 
569  if( it != m_traces.end() )
570  {
571  TRACE* trace = it->second;
572  m_traces.erase( it );
573 
574  if( CURSOR* cursor = trace->GetCursor() )
575  m_plotWin->DelLayer( cursor, true );
576 
577  m_plotWin->DelLayer( trace, true, true );
578  ResetScales();
579 
580  return true;
581  }
582 
583  return false;
584 }
585 
586 
588 {
589  for( auto& t : m_traces )
590  {
591  DeleteTrace( t.first );
592  }
593 
594  m_colorIdx = 0;
595  m_traces.clear();
596 }
597 
598 
599 bool SIM_PLOT_PANEL::HasCursorEnabled( const wxString& aName ) const
600 {
601  TRACE* t = GetTrace( aName );
602 
603  return t ? t->HasCursor() : false;
604 }
605 
606 
607 void SIM_PLOT_PANEL::EnableCursor( const wxString& aName, bool aEnable )
608 {
609  TRACE* t = GetTrace( aName );
610 
611  if( t == nullptr || t->HasCursor() == aEnable )
612  return;
613 
614  if( aEnable )
615  {
616  CURSOR* c = new CURSOR( t, this );
617  int plotCenter = GetPlotWin()->GetMarginLeft()
619  - GetPlotWin()->GetMarginRight() )
620  / 2;
621  c->SetX( plotCenter );
622  t->SetCursor( c );
623  m_plotWin->AddLayer( c );
624  }
625  else
626  {
627  CURSOR* c = t->GetCursor();
628  t->SetCursor( NULL );
629  m_plotWin->DelLayer( c, true );
630  }
631 
632  // Notify the parent window about the changes
633  wxQueueEvent( GetParent(), new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
634 }
635 
636 
638 {
639  if( m_axis_x )
641 
642  if( m_axis_y1 )
644 
645  if( m_axis_y2 )
647 
648  for( auto t : m_traces )
649  t.second->UpdateScales();
650 }
651 
652 
654 {
655  const unsigned int colorCount = m_masterFrame->GetPlotColorCount() - SIM_TRACE_COLOR;
656 
657  for( int i = 0; i < (int)colorCount - 1; i++ )
658  {
659  const wxColour color = GetPlotColor( i+SIM_TRACE_COLOR );
660  bool hasColor = false;
661 
662  for( auto& t : m_traces )
663  {
664  TRACE* trace = t.second;
665 
666  if( trace->GetTraceColour() == color )
667  {
668  hasColor = true;
669  break;
670  }
671  }
672 
673  if( !hasColor )
674  return color;
675  }
676 
677  // If all colors are in use, choose a suitable color in list
678  int idx = m_traces.size() % colorCount;
679  return wxColour( GetPlotColor( idx + SIM_TRACE_COLOR ) );
680 }
681 
682 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:4086
#define mpALIGN_LEFT
Aligns label to the left.
Definition: mathplot.h:482
class WXDLLIMPEXP_MATHPLOT mpWindow
Definition: mathplot.h:109
wxDEFINE_EVENT(EVT_SIM_CURSOR_UPDATE, wxCommandEvent)
bool m_continuous
Definition: mathplot.h:319
static wxString formatFloat(double x, int nDigits)
static constexpr int DRAG_MARGIN
mpWindow * m_plotWin
void SetNameAlign(int align)
Definition: mathplot.h:710
const TRACE * m_trace
wxRealPoint m_coords
mpWindow * GetPlotWin() const
Getter for math plot window
mpScaleY * m_axis_y1
double p2x(wxCoord pixelCoordX)
Converts mpWindow (screen) pixel coordinates into graph (floating point) coordinates,...
Definition: mathplot.h:1189
bool HasCursor() const
bool DelLayer(mpLayer *layer, bool alsoDeleteObject=false, bool refreshDisplay=true)
Remove a plot layer from the canvas.
Definition: mathplot.cpp:2489
virtual void SetScale(mpScaleBase *scaleX, mpScaleBase *scaleY)
Definition: mathplot.cpp:4066
std::vector< TickLabel > & TickLabels()
Definition: mathplot.h:790
int GetXScreen(void) const
Definition: mathplot.h:1136
void formatLabels() override
int GetMarginBottom()
Definition: mathplot.h:1372
int color
Definition: DXF_plotter.cpp:61
const std::vector< double > & GetDataX() const
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:980
double y2s(double y) const
Definition: mathplot.cpp:4104
static int countDecimalDigits(double x, int maxDigits)
#define mpALIGN_RIGHT
Aligns label to the right.
Definition: mathplot.h:478
bool AddLayer(mpLayer *layer, bool refreshDisplay=true)
Add a plot layer to the canvas.
Definition: mathplot.cpp:2472
SIM_PLOT_FRAME * m_masterFrame
VOLTAGE_SCALE_X(wxString name, int flags)
void formatLabels() override
virtual ~SIM_PLOT_PANEL()
TRACE * GetTrace(const wxString &aName) const
void SetPen(wxPen pen)
Set layer pen.
Definition: mathplot.h:278
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:1209
bool m_visible
Definition: mathplot.h:323
bool DeleteTrace(const wxString &aName)
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820
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:1204
void ResetDataRange()
Definition: mathplot.h:760
Plot layer implementing a x-scale ruler.
Definition: mathplot.h:694
#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:303
wxColor GetPlotColor(int aColorId)
int GetMarginTop()
Definition: mathplot.h:1368
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:1135
Plot layer implementing a y-scale ruler.
Definition: mathplot.h:942
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:3108
class WXDLLIMPEXP_MATHPLOT mpScaleY
Definition: mathplot.h:108
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:3185
mpScaleY * m_axis_y2
void SetTicks(bool enable)
Set X axis ticks or grid.
Definition: mathplot.h:715
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:393
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:321
int GetMarginRight()
Definition: mathplot.h:1370
wxPoint m_reference
Definition: mathplot.h:397
int GetMarginLeft()
Definition: mathplot.h:1374
SIM_TYPE GetType() const
double x2s(double x) const
Definition: mathplot.cpp:4098
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:1199
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:1426
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:1047
void SetTicks(bool ticks)
Set Y axis ticks or grid.
Definition: mathplot.h:970
#define mpALIGN_BOTTOM
Aligns label to the bottom.
Definition: mathplot.h:486
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:438
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:44
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.
wxBoxSizer * m_sizer
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:1144