KiCad PCB EDA Suite
SIM_PLOT_PANEL Class Reference

#include <sim_plot_panel.h>

Inheritance diagram for SIM_PLOT_PANEL:
SIM_PANEL_BASE

Public Member Functions

 SIM_PLOT_PANEL (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)
 
virtual ~SIM_PLOT_PANEL ()
 set the pointer to the sim plot frame More...
 
void SetMasterFrame (SIM_PLOT_FRAME *aFrame)
 
wxString GetLabelX () const
 
wxString GetLabelY1 () const
 
wxString GetLabelY2 () const
 
bool AddTrace (const wxString &aName, int aPoints, const double *aX, const double *aY, SIM_PLOT_TYPE aFlags)
 
bool DeleteTrace (const wxString &aName)
 
void DeleteAllTraces ()
 
bool TraceShown (const wxString &aName) const
 
const std::map< wxString, TRACE * > & GetTraces () const
 
TRACEGetTrace (const wxString &aName) const
 
void ShowGrid (bool aEnable)
 
bool IsGridShown () const
 
void ShowLegend (bool aEnable)
 
bool IsLegendShown () const
 
void SetDottedCurrentPhase (bool aEnable)
 
bool GetDottedCurrentPhase () const
 Returns true if the trace has cursor shown. More...
 
bool HasCursorEnabled (const wxString &aName) const
 Toggles cursor for a particular trace. More...
 
void EnableCursor (const wxString &aName, bool aEnable)
 Resets scale ranges to fit the current traces. More...
 
void ResetScales ()
 Update trace line style. More...
 
void UpdateTraceStyle (TRACE *trace)
 
void UpdatePlotColors ()
 

Update plot colors

More...
 
mpWindowGetPlotWin () const
 
SIM_TYPE GetType () const
 

Static Public Member Functions

static bool IsPlottable (SIM_TYPE aSimType)
 

Protected Attributes

const wxString m_simCommand
 

Private Member Functions

void prepareDCAxes ()
 < More...
 

Private Attributes

SIM_PLOT_COLORS m_colors
 
mpWindowm_plotWin
 
wxBoxSizer * m_sizer
 
std::map< wxString, TRACE * > m_traces
 
mpScaleXBasem_axis_x
 
mpScaleYm_axis_y1
 
mpScaleYm_axis_y2
 
mpInfoLegendm_legend
 
bool m_dotted_cp
 
std::vector< mpLayer * > m_topLevel
 
SIM_PLOT_FRAMEm_masterFrame
 

Detailed Description

Definition at line 171 of file sim_plot_panel.h.

Constructor & Destructor Documentation

◆ SIM_PLOT_PANEL()

SIM_PLOT_PANEL::SIM_PLOT_PANEL ( 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 
)

Definition at line 296 of file sim_plot_panel.cpp.

298  : SIM_PANEL_BASE( aCommand, parent, id, pos, size, style, name ),
299  m_axis_x( nullptr ),
300  m_axis_y1( nullptr ),
301  m_axis_y2( nullptr ),
302  m_dotted_cp( false ),
303  m_masterFrame( aMainFrame )
304 {
305  m_sizer = new wxBoxSizer( wxVERTICAL );
306  m_plotWin = new mpWindow( this, wxID_ANY, pos, size, style );
307 
308  m_plotWin->LimitView( true );
309  m_plotWin->SetMargins( 50, 80, 50, 80 );
310 
312 
313  switch( GetType() )
314  {
315  case ST_AC:
316  m_axis_x = new LOG_SCALE<mpScaleXLog>( _( "Frequency" ), wxT( "Hz" ), mpALIGN_BOTTOM );
317  m_axis_y1 = new LIN_SCALE<mpScaleY>( _( "Gain" ), wxT( "dBV" ), mpALIGN_LEFT );
318  m_axis_y2 = new LIN_SCALE<mpScaleY>( _( "Phase" ), wxT( "\u00B0" ),
319  mpALIGN_RIGHT ); // degree sign
321  break;
322 
323  case ST_DC:
324  prepareDCAxes();
325  break;
326 
327  case ST_NOISE:
328  m_axis_x = new LOG_SCALE<mpScaleXLog>( _( "Frequency" ), wxT( "Hz" ), mpALIGN_BOTTOM );
329  m_axis_y1 = new mpScaleY( _( "noise [(V or A)^2/Hz]" ), mpALIGN_LEFT );
330  break;
331 
332  case ST_TRANSIENT:
333  m_axis_x = new LIN_SCALE<mpScaleX>( _( "Time" ), wxT( "s" ), mpALIGN_BOTTOM );
334  m_axis_y1 = new LIN_SCALE<mpScaleY>( _( "Voltage" ), wxT( "V" ), mpALIGN_LEFT );
335  m_axis_y2 = new LIN_SCALE<mpScaleY>( _( "Current" ), wxT( "A" ), mpALIGN_RIGHT );
337  break;
338 
339  default:
340  // suppress warnings
341  break;
342  }
343 
344  if( m_axis_x )
345  {
346  m_axis_x->SetTicks( false );
348 
350  }
351 
352  if( m_axis_y1 )
353  {
354  m_axis_y1->SetTicks( false );
357  }
358 
359  if( m_axis_y2 )
360  {
361  m_axis_y2->SetTicks( false );
364  }
365 
366  // a mpInfoLegend displays le name of traces on the left top panel corner:
367  m_legend = new mpInfoLegend( wxRect( 0, 40, 200, 40 ), wxTRANSPARENT_BRUSH );
368  m_legend->SetVisible( false );
370 
371  m_plotWin->EnableDoubleBuffer( true );
372  m_plotWin->UpdateAll();
373 
374  m_sizer->Add( m_plotWin, 1, wxALL | wxEXPAND, 1 );
375  SetSizer( m_sizer );
376 }
#define mpALIGN_LEFT
Aligns label to the left.
Definition: mathplot.h:482
class WXDLLIMPEXP_MATHPLOT mpWindow
Definition: mathplot.h:109
mpWindow * m_plotWin
void SetNameAlign(int align)
Definition: mathplot.h:710
mpScaleY * m_axis_y1
mpScaleXBase * m_axis_x
void SetMasterScale(mpScaleY *masterScale)
Definition: mathplot.h:980
#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:2426
SIM_PLOT_FRAME * m_masterFrame
void EnableDoubleBuffer(bool enabled)
Enable/disable the double-buffering of the window, eliminating the flicker (default=disabled).
Definition: mathplot.h:1209
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2750
void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:303
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:3038
class WXDLLIMPEXP_MATHPLOT mpScaleY
Definition: mathplot.h:108
mpScaleY * m_axis_y2
void SetTicks(bool enable)
Set X axis ticks or grid.
Definition: mathplot.h:715
SIM_TYPE GetType() const
void UpdatePlotColors()
Update plot colors
const char * name
Definition: DXF_plotter.cpp:59
#define _(s)
Definition: 3d_actions.cpp:33
mpInfoLegend * m_legend
void LimitView(bool aEnable)
Limit zooming & panning to the area used by the plots.
Definition: mathplot.h:1426
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
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
wxBoxSizer * m_sizer

References _, mpWindow::AddLayer(), mpWindow::EnableDoubleBuffer(), SIM_PANEL_BASE::GetType(), mpWindow::LimitView(), m_axis_x, m_axis_y1, m_axis_y2, m_legend, m_plotWin, m_sizer, mpALIGN_BOTTOM, mpALIGN_LEFT, mpALIGN_RIGHT, mpScaleY, mpWindow, prepareDCAxes(), mpWindow::SetMargins(), mpScaleY::SetMasterScale(), mpScaleBase::SetNameAlign(), mpScaleBase::SetTicks(), mpScaleY::SetTicks(), mpLayer::SetVisible(), ST_AC, ST_DC, ST_NOISE, ST_TRANSIENT, mpWindow::UpdateAll(), and UpdatePlotColors().

◆ ~SIM_PLOT_PANEL()

SIM_PLOT_PANEL::~SIM_PLOT_PANEL ( )
virtual

set the pointer to the sim plot frame

Definition at line 379 of file sim_plot_panel.cpp.

380 {
381  // ~mpWindow destroys all the added layers, so there is no need to destroy m_traces contents
382 }

Member Function Documentation

◆ AddTrace()

bool SIM_PLOT_PANEL::AddTrace ( const wxString &  aName,
int  aPoints,
const double *  aX,
const double *  aY,
SIM_PLOT_TYPE  aFlags 
)

Definition at line 444 of file sim_plot_panel.cpp.

446 {
447  TRACE* trace = NULL;
448 
449  // Find previous entry, if there is one
450  auto prev = m_traces.find( aName );
451  bool addedNewEntry = ( prev == m_traces.end() );
452 
453  if( addedNewEntry )
454  {
455  if( GetType() == ST_TRANSIENT )
456  {
457  bool hasVoltageTraces = false;
458 
459  for( const auto& tr : m_traces )
460  {
461  if( !( tr.second->GetFlags() & SPT_CURRENT ) )
462  {
463  hasVoltageTraces = true;
464  break;
465  }
466  }
467 
468  if( !hasVoltageTraces )
469  m_axis_y2->SetMasterScale( nullptr );
470  else
472  }
473 
474  // New entry
475  trace = new TRACE( aName );
477  UpdateTraceStyle( trace );
478  m_traces[aName] = trace;
479 
480  // It is a trick to keep legend & coords always on the top
481  for( mpLayer* l : m_topLevel )
482  m_plotWin->DelLayer( l );
483 
484  m_plotWin->AddLayer( (mpLayer*) trace );
485 
486  for( mpLayer* l : m_topLevel )
487  m_plotWin->AddLayer( l );
488  }
489  else
490  {
491  trace = prev->second;
492  }
493 
494  std::vector<double> tmp( aY, aY + aPoints );
495 
496  if( GetType() == ST_AC )
497  {
498  if( aFlags & SPT_AC_PHASE )
499  {
500  for( int i = 0; i < aPoints; i++ )
501  tmp[i] = tmp[i] * 180.0 / M_PI; // convert to degrees
502  }
503  else
504  {
505  for( int i = 0; i < aPoints; i++ )
506  tmp[i] = 20 * log( tmp[i] ) / log( 10.0 ); // convert to dB
507  }
508  }
509 
510  trace->SetData( std::vector<double>( aX, aX + aPoints ), tmp );
511 
512  if( ( aFlags & SPT_AC_PHASE ) || ( aFlags & SPT_CURRENT ) )
513  trace->SetScale( m_axis_x, m_axis_y2 );
514  else
515  trace->SetScale( m_axis_x, m_axis_y1 );
516 
517  trace->SetFlags( aFlags );
518 
519  m_plotWin->UpdateAll();
520 
521  return addedNewEntry;
522 }
mpWindow * m_plotWin
mpScaleY * m_axis_y1
bool DelLayer(mpLayer *layer, bool alsoDeleteObject=false, bool refreshDisplay=true)
Remove a plot layer from the canvas.
Definition: mathplot.cpp:2443
mpScaleXBase * m_axis_x
void SetMasterScale(mpScaleY *masterScale)
Definition: mathplot.h:980
bool AddLayer(mpLayer *layer, bool refreshDisplay=true)
Add a plot layer to the canvas.
Definition: mathplot.cpp:2426
void UpdateTraceStyle(TRACE *trace)
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2750
wxColour GenerateColor(std::map< wxString, TRACE * > aTraces)
SIM_PLOT_COLORS m_colors
#define NULL
std::vector< mpLayer * > m_topLevel
std::map< wxString, TRACE * > m_traces
mpScaleY * m_axis_y2
SIM_TYPE GetType() const
void SetTraceColour(wxColour aColour)

References mpWindow::AddLayer(), mpWindow::DelLayer(), SIM_PLOT_COLORS::GenerateColor(), SIM_PANEL_BASE::GetType(), m_axis_x, m_axis_y1, m_axis_y2, m_colors, m_plotWin, m_topLevel, m_traces, NULL, TRACE::SetData(), TRACE::SetFlags(), mpScaleY::SetMasterScale(), mpFXY::SetScale(), TRACE::SetTraceColour(), SPT_AC_PHASE, SPT_CURRENT, ST_AC, ST_TRANSIENT, mpWindow::UpdateAll(), and UpdateTraceStyle().

Referenced by SIM_PLOT_FRAME::updatePlot().

◆ DeleteAllTraces()

void SIM_PLOT_PANEL::DeleteAllTraces ( )

Definition at line 547 of file sim_plot_panel.cpp.

548 {
549  for( auto& t : m_traces )
550  {
551  DeleteTrace( t.first );
552  }
553 
554  m_traces.clear();
555 }
bool DeleteTrace(const wxString &aName)
std::map< wxString, TRACE * > m_traces

References DeleteTrace(), and m_traces.

◆ DeleteTrace()

bool SIM_PLOT_PANEL::DeleteTrace ( const wxString &  aName)

Definition at line 525 of file sim_plot_panel.cpp.

526 {
527  auto it = m_traces.find( aName );
528 
529  if( it != m_traces.end() )
530  {
531  TRACE* trace = it->second;
532  m_traces.erase( it );
533 
534  if( CURSOR* cursor = trace->GetCursor() )
535  m_plotWin->DelLayer( cursor, true );
536 
537  m_plotWin->DelLayer( trace, true, true );
538  ResetScales();
539 
540  return true;
541  }
542 
543  return false;
544 }
mpWindow * m_plotWin
bool DelLayer(mpLayer *layer, bool alsoDeleteObject=false, bool refreshDisplay=true)
Remove a plot layer from the canvas.
Definition: mathplot.cpp:2443
std::map< wxString, TRACE * > m_traces
void ResetScales()
Update trace line style.
CURSOR * GetCursor() const
Cursor attached to a trace to follow its values:

References mpWindow::DelLayer(), TRACE::GetCursor(), m_plotWin, m_traces, and ResetScales().

Referenced by DeleteAllTraces(), and SIM_PLOT_FRAME::removePlot().

◆ EnableCursor()

void SIM_PLOT_PANEL::EnableCursor ( const wxString &  aName,
bool  aEnable 
)

Resets scale ranges to fit the current traces.

Definition at line 566 of file sim_plot_panel.cpp.

567 {
568  TRACE* t = GetTrace( aName );
569 
570  if( t == nullptr || t->HasCursor() == aEnable )
571  return;
572 
573  if( aEnable )
574  {
575  CURSOR* c = new CURSOR( t, this );
576  int plotCenter = GetPlotWin()->GetMarginLeft()
578  - GetPlotWin()->GetMarginRight() )
579  / 2;
580  c->SetX( plotCenter );
582  t->SetCursor( c );
583  m_plotWin->AddLayer( c );
584  }
585  else
586  {
587  CURSOR* c = t->GetCursor();
588  t->SetCursor( NULL );
589  m_plotWin->DelLayer( c, true );
590  }
591 
592  // Notify the parent window about the changes
593  wxQueueEvent( GetParent(), new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
594 }
mpWindow * m_plotWin
mpWindow * GetPlotWin() const
bool HasCursor() const
bool DelLayer(mpLayer *layer, bool alsoDeleteObject=false, bool refreshDisplay=true)
Remove a plot layer from the canvas.
Definition: mathplot.cpp:2443
int GetXScreen(void) const
Definition: mathplot.h:1136
bool AddLayer(mpLayer *layer, bool refreshDisplay=true)
Add a plot layer to the canvas.
Definition: mathplot.cpp:2426
void SetPen(wxPen pen)
Set layer pen.
Definition: mathplot.h:278
TRACE * GetTrace(const wxString &aName) const
SIM_PLOT_COLORS m_colors
#define NULL
wxColour GetPlotColor(enum COLOR_SET aColorId)
int GetMarginRight()
Definition: mathplot.h:1370
int GetMarginLeft()
Definition: mathplot.h:1374
void SetX(int aX)
CURSOR * GetCursor() const
void SetCursor(CURSOR *aCursor)
Cursor attached to a trace to follow its values:

References mpWindow::AddLayer(), SIM_PLOT_COLORS::CURSOR, mpWindow::DelLayer(), TRACE::GetCursor(), mpWindow::GetMarginLeft(), mpWindow::GetMarginRight(), SIM_PLOT_COLORS::GetPlotColor(), GetPlotWin(), GetTrace(), mpWindow::GetXScreen(), TRACE::HasCursor(), m_colors, m_plotWin, NULL, TRACE::SetCursor(), mpLayer::SetPen(), and CURSOR::SetX().

Referenced by SIM_PLOT_FRAME::SIGNAL_CONTEXT_MENU::onMenuEvent().

◆ GetDottedCurrentPhase()

bool SIM_PLOT_PANEL::GetDottedCurrentPhase ( ) const
inline

Returns true if the trace has cursor shown.

Definition at line 265 of file sim_plot_panel.h.

References m_dotted_cp.

Referenced by SIM_PLOT_FRAME::menuShowDotted(), and SIM_PLOT_FRAME::menuShowDottedUpdate().

◆ GetLabelX()

wxString SIM_PLOT_PANEL::GetLabelX ( ) const
inline

Definition at line 186 of file sim_plot_panel.h.

187  {
188  return m_axis_x ? m_axis_x->GetName() : "";
189  }
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:239
mpScaleXBase * m_axis_x

References mpLayer::GetName(), and m_axis_x.

Referenced by SIM_PLOT_FRAME::onCursorUpdate().

◆ GetLabelY1()

wxString SIM_PLOT_PANEL::GetLabelY1 ( ) const
inline

Definition at line 191 of file sim_plot_panel.h.

192  {
193  return m_axis_y1 ? m_axis_y1->GetName() : "";
194  }
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:239
mpScaleY * m_axis_y1

References mpLayer::GetName(), and m_axis_y1.

Referenced by SIM_PLOT_FRAME::onCursorUpdate().

◆ GetLabelY2()

wxString SIM_PLOT_PANEL::GetLabelY2 ( ) const
inline

Definition at line 196 of file sim_plot_panel.h.

197  {
198  return m_axis_y2 ? m_axis_y2->GetName() : "";
199  }
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:239
mpScaleY * m_axis_y2

References mpLayer::GetName(), and m_axis_y2.

Referenced by SIM_PLOT_FRAME::onCursorUpdate().

◆ GetPlotWin()

◆ GetTrace()

TRACE* SIM_PLOT_PANEL::GetTrace ( const wxString &  aName) const
inline

Definition at line 218 of file sim_plot_panel.h.

219  {
220  auto trace = m_traces.find( aName );
221 
222  return trace == m_traces.end() ? NULL : trace->second;
223  }
#define NULL
std::map< wxString, TRACE * > m_traces

References m_traces, and NULL.

Referenced by EnableCursor(), HasCursorEnabled(), and SIM_PLOT_FRAME::SIGNAL_CONTEXT_MENU::SIGNAL_CONTEXT_MENU().

◆ GetTraces()

const std::map<wxString, TRACE*>& SIM_PLOT_PANEL::GetTraces ( ) const
inline

Definition at line 213 of file sim_plot_panel.h.

214  {
215  return m_traces;
216  }
std::map< wxString, TRACE * > m_traces

References m_traces.

Referenced by SIM_PLOT_FRAME::menuSaveCsv(), and SIM_PLOT_FRAME::onCursorUpdate().

◆ GetType()

SIM_TYPE SIM_PANEL_BASE::GetType ( ) const
inherited

◆ HasCursorEnabled()

bool SIM_PLOT_PANEL::HasCursorEnabled ( const wxString &  aName) const

Toggles cursor for a particular trace.

Definition at line 558 of file sim_plot_panel.cpp.

559 {
560  TRACE* t = GetTrace( aName );
561 
562  return t ? t->HasCursor() : false;
563 }
bool HasCursor() const
TRACE * GetTrace(const wxString &aName) const

References GetTrace(), and TRACE::HasCursor().

◆ IsGridShown()

bool SIM_PLOT_PANEL::IsGridShown ( ) const
inline

Definition at line 233 of file sim_plot_panel.h.

234  {
235  if( !m_axis_x || !m_axis_y1 )
236  return false;
237 
238  assert( m_axis_x->GetTicks() == m_axis_y1->GetTicks() );
239  return !m_axis_x->GetTicks();
240  }
mpScaleY * m_axis_y1
mpScaleXBase * m_axis_x
bool GetTicks()
Get Y axis ticks or grid.
Definition: mathplot.h:974
bool GetTicks()
Get X axis ticks or grid.
Definition: mathplot.h:720

References mpScaleBase::GetTicks(), mpScaleY::GetTicks(), m_axis_x, and m_axis_y1.

Referenced by SIM_PLOT_FRAME::menuShowGrid(), and SIM_PLOT_FRAME::menuShowGridUpdate().

◆ IsLegendShown()

bool SIM_PLOT_PANEL::IsLegendShown ( ) const
inline

Definition at line 248 of file sim_plot_panel.h.

249  {
250  return m_legend->IsVisible();
251  }
bool IsVisible()
Checks whether the layer is visible or not.
Definition: mathplot.h:299
mpInfoLegend * m_legend

References mpLayer::IsVisible(), and m_legend.

Referenced by SIM_PLOT_FRAME::menuShowLegend(), and SIM_PLOT_FRAME::menuShowLegendUpdate().

◆ IsPlottable()

bool SIM_PANEL_BASE::IsPlottable ( SIM_TYPE  aSimType)
staticinherited

Definition at line 55 of file sim_panel_base.cpp.

56 {
57  switch( aSimType )
58  {
59  case ST_AC:
60  case ST_DC:
61  case ST_TRANSIENT:
62  return true;
63 
64  default:
65  return false;
66  }
67 }

References ST_AC, ST_DC, and ST_TRANSIENT.

Referenced by SIM_PLOT_FRAME::addPlot(), SIM_PLOT_FRAME::menuNewPlot(), SIM_PLOT_FRAME::NewPlotPanel(), SIM_PLOT_FRAME::onSimFinished(), and SIM_PLOT_FRAME::updatePlot().

◆ prepareDCAxes()

void SIM_PLOT_PANEL::prepareDCAxes ( )
private

<

Construct the plot axes for DC simulation plot.

Definition at line 385 of file sim_plot_panel.cpp.

386 {
387  wxRegEx simCmd( "^.dc[[:space:]]+([[:alnum:]]+\\M).*", wxRE_ADVANCED | wxRE_ICASE );
388 
389  if( simCmd.Matches( m_simCommand ) )
390  {
391  switch( static_cast<char>( simCmd.GetMatch( m_simCommand.Lower(), 1 ).GetChar( 0 ) ) )
392  {
393  case 'v':
394  m_axis_x =
395  new LIN_SCALE<mpScaleX>( _( "Voltage (swept)" ), wxT( "V" ), mpALIGN_BOTTOM );
396  break;
397  case 'i':
398  m_axis_x =
399  new LIN_SCALE<mpScaleX>( _( "Current (swept)" ), wxT( "A" ), mpALIGN_BOTTOM );
400  break;
401  case 'r':
402  m_axis_x = new LIN_SCALE<mpScaleX>( _( "Resistance (swept)" ), wxT( "\u03A9" ),
403  mpALIGN_BOTTOM );
404  break;
405  case 't':
406  m_axis_x = new LIN_SCALE<mpScaleX>( _( "Temperature (swept)" ), wxT( "\u00B0C" ),
407  mpALIGN_BOTTOM );
408  break;
409  }
410 
411  m_axis_y1 = new LIN_SCALE<mpScaleY>( _( "Voltage (measured)" ), wxT( "V" ), mpALIGN_LEFT );
412  m_axis_y2 = new LIN_SCALE<mpScaleY>( _( "Current" ), wxT( "A" ), mpALIGN_RIGHT );
413  }
414 }
#define mpALIGN_LEFT
Aligns label to the left.
Definition: mathplot.h:482
mpScaleY * m_axis_y1
mpScaleXBase * m_axis_x
#define mpALIGN_RIGHT
Aligns label to the right.
Definition: mathplot.h:478
mpScaleY * m_axis_y2
const wxString m_simCommand
#define _(s)
Definition: 3d_actions.cpp:33
#define mpALIGN_BOTTOM
Aligns label to the bottom.
Definition: mathplot.h:486

References _, m_axis_x, m_axis_y1, m_axis_y2, SIM_PANEL_BASE::m_simCommand, mpALIGN_BOTTOM, mpALIGN_LEFT, and mpALIGN_RIGHT.

Referenced by SIM_PLOT_PANEL().

◆ ResetScales()

void SIM_PLOT_PANEL::ResetScales ( )

Update trace line style.

Definition at line 597 of file sim_plot_panel.cpp.

598 {
599  if( m_axis_x )
601 
602  if( m_axis_y1 )
604 
605  if( m_axis_y2 )
607 
608  for( auto t : m_traces )
609  t.second->UpdateScales();
610 }
mpScaleY * m_axis_y1
mpScaleXBase * m_axis_x
void ResetDataRange()
Definition: mathplot.h:760
std::map< wxString, TRACE * > m_traces
mpScaleY * m_axis_y2

References m_axis_x, m_axis_y1, m_axis_y2, m_traces, and mpScaleBase::ResetDataRange().

Referenced by DeleteTrace(), and SIM_PLOT_FRAME::onSimFinished().

◆ SetDottedCurrentPhase()

void SIM_PLOT_PANEL::SetDottedCurrentPhase ( bool  aEnable)
inline

Definition at line 253 of file sim_plot_panel.h.

254  {
255  m_dotted_cp = aEnable;
256 
257  for( const auto& tr : m_traces )
258  {
259  UpdateTraceStyle( tr.second );
260  }
261 
262  m_plotWin->UpdateAll();
263  }
mpWindow * m_plotWin
void UpdateTraceStyle(TRACE *trace)
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2750
std::map< wxString, TRACE * > m_traces

References m_dotted_cp, m_plotWin, m_traces, mpWindow::UpdateAll(), and UpdateTraceStyle().

Referenced by SIM_PLOT_FRAME::menuShowDotted().

◆ SetMasterFrame()

void SIM_PLOT_PANEL::SetMasterFrame ( SIM_PLOT_FRAME aFrame)
inline

Definition at line 181 of file sim_plot_panel.h.

182  {
183  m_masterFrame = aFrame;
184  }
SIM_PLOT_FRAME * m_masterFrame

References m_masterFrame.

◆ ShowGrid()

void SIM_PLOT_PANEL::ShowGrid ( bool  aEnable)
inline

Definition at line 225 of file sim_plot_panel.h.

226  {
227  m_axis_x->SetTicks( !aEnable );
228  m_axis_y1->SetTicks( !aEnable );
229  m_axis_y2->SetTicks( !aEnable );
230  m_plotWin->UpdateAll();
231  }
mpWindow * m_plotWin
mpScaleY * m_axis_y1
mpScaleXBase * m_axis_x
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2750
mpScaleY * m_axis_y2
void SetTicks(bool enable)
Set X axis ticks or grid.
Definition: mathplot.h:715
void SetTicks(bool ticks)
Set Y axis ticks or grid.
Definition: mathplot.h:970

References m_axis_x, m_axis_y1, m_axis_y2, m_plotWin, mpScaleBase::SetTicks(), mpScaleY::SetTicks(), and mpWindow::UpdateAll().

Referenced by SIM_PLOT_FRAME::menuShowGrid().

◆ ShowLegend()

void SIM_PLOT_PANEL::ShowLegend ( bool  aEnable)
inline

Definition at line 242 of file sim_plot_panel.h.

243  {
244  m_legend->SetVisible( aEnable );
245  m_plotWin->UpdateAll();
246  }
mpWindow * m_plotWin
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2750
void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:303
mpInfoLegend * m_legend

References m_legend, m_plotWin, mpLayer::SetVisible(), and mpWindow::UpdateAll().

Referenced by SIM_PLOT_FRAME::menuShowLegend().

◆ TraceShown()

bool SIM_PLOT_PANEL::TraceShown ( const wxString &  aName) const
inline

Definition at line 208 of file sim_plot_panel.h.

209  {
210  return m_traces.count( aName ) > 0;
211  }
std::map< wxString, TRACE * > m_traces

References m_traces.

Referenced by SIM_PLOT_FRAME::removePlot().

◆ UpdatePlotColors()

void SIM_PLOT_PANEL::UpdatePlotColors ( )

Update plot colors

Getter for math plot window

Definition at line 417 of file sim_plot_panel.cpp.

418 {
419  // Update bg and fg colors:
423 
424  // Update color of all traces
425  for( auto& t : m_traces )
426  if( t.second->GetCursor() )
427  t.second->GetCursor()->SetPen(
429 
430  m_plotWin->UpdateAll();
431 }
mpWindow * m_plotWin
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2750
SIM_PLOT_COLORS m_colors
std::map< wxString, TRACE * > m_traces
void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour)
Set Color theme.
Definition: mathplot.cpp:3108
wxColour GetPlotColor(enum COLOR_SET aColorId)

References SIM_PLOT_COLORS::AXIS, SIM_PLOT_COLORS::BACKGROUND, SIM_PLOT_COLORS::CURSOR, SIM_PLOT_COLORS::FOREGROUND, SIM_PLOT_COLORS::GetPlotColor(), m_colors, m_plotWin, m_traces, mpWindow::SetColourTheme(), and mpWindow::UpdateAll().

Referenced by SIM_PLOT_FRAME::menuWhiteBackground(), and SIM_PLOT_PANEL().

◆ UpdateTraceStyle()

void SIM_PLOT_PANEL::UpdateTraceStyle ( TRACE trace)

Definition at line 434 of file sim_plot_panel.cpp.

435 {
436  int flags = trace->GetFlags();
437  wxPenStyle penStyle = ( ( flags & SPT_AC_PHASE || flags & SPT_CURRENT ) && m_dotted_cp ) ?
438  wxPENSTYLE_DOT :
439  wxPENSTYLE_SOLID;
440  trace->SetPen( wxPen( trace->GetTraceColour(), 2, penStyle ) );
441 }
wxColour GetTraceColour()
void SetPen(wxPen pen)
Set layer pen.
Definition: mathplot.h:278
int GetFlags() const

References TRACE::GetFlags(), TRACE::GetTraceColour(), m_dotted_cp, mpLayer::SetPen(), SPT_AC_PHASE, and SPT_CURRENT.

Referenced by AddTrace(), and SetDottedCurrentPhase().

Member Data Documentation

◆ m_axis_x

mpScaleXBase* SIM_PLOT_PANEL::m_axis_x
private

◆ m_axis_y1

mpScaleY* SIM_PLOT_PANEL::m_axis_y1
private

◆ m_axis_y2

mpScaleY* SIM_PLOT_PANEL::m_axis_y2
private

◆ m_colors

SIM_PLOT_COLORS SIM_PLOT_PANEL::m_colors
private

Definition at line 295 of file sim_plot_panel.h.

Referenced by AddTrace(), EnableCursor(), and UpdatePlotColors().

◆ m_dotted_cp

bool SIM_PLOT_PANEL::m_dotted_cp
private

◆ m_legend

mpInfoLegend* SIM_PLOT_PANEL::m_legend
private

Definition at line 307 of file sim_plot_panel.h.

Referenced by IsLegendShown(), ShowLegend(), and SIM_PLOT_PANEL().

◆ m_masterFrame

SIM_PLOT_FRAME* SIM_PLOT_PANEL::m_masterFrame
private

Definition at line 313 of file sim_plot_panel.h.

Referenced by SetMasterFrame().

◆ m_plotWin

◆ m_simCommand

const wxString SIM_PANEL_BASE::m_simCommand
protectedinherited

Definition at line 50 of file sim_panel_base.h.

Referenced by SIM_PANEL_BASE::GetType(), and prepareDCAxes().

◆ m_sizer

wxBoxSizer* SIM_PLOT_PANEL::m_sizer
private

Definition at line 299 of file sim_plot_panel.h.

Referenced by SIM_PLOT_PANEL().

◆ m_topLevel

std::vector<mpLayer*> SIM_PLOT_PANEL::m_topLevel
private

Definition at line 311 of file sim_plot_panel.h.

Referenced by AddTrace().

◆ m_traces

std::map<wxString, TRACE*> SIM_PLOT_PANEL::m_traces
private

The documentation for this class was generated from the following files: