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 (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)
 
virtual ~SIM_PLOT_PANEL ()
 
void SetMasterFrame (SIM_PLOT_FRAME *aFrame)
 

set the pointer to the sim plot frame

More...
 
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
 
bool HasCursorEnabled (const wxString &aName) const
 

Returns true if the trace has cursor shown.

More...
 
void EnableCursor (const wxString &aName, bool aEnable)
 

Toggles cursor for a particular trace.

More...
 
void ResetScales ()
 

Resets scale ranges to fit the current traces

More...
 
void UpdateTraceStyle (TRACE *trace)
 

Update trace line style

More...
 
wxColour GetPlotColor (int aIndex)
 A proxy to SIM_PLOT_FRAME::GetPlotColor() More...
 
void UpdatePlotColors ()
 

Update plot colors

More...
 
mpWindowGetPlotWin () const
 

Getter for math plot window

More...
 
SIM_TYPE GetType () const
 

Static Public Member Functions

static bool IsPlottable (SIM_TYPE aSimType)
 

Private Member Functions

wxColour generateColor ()
 

More...
 

Private Attributes

unsigned int m_colorIdx
 
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 168 of file sim_plot_panel.h.

Constructor & Destructor Documentation

◆ SIM_PLOT_PANEL()

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

Definition at line 366 of file sim_plot_panel.cpp.

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 }
#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:2472
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:2820
unsigned int m_colorIdx
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:3108
class WXDLLIMPEXP_MATHPLOT mpScaleY
Definition: mathplot.h:108
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
SIM_TYPE GetType() const
const char * name
Definition: DXF_plotter.cpp:60
#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
wxColour GetPlotColor(int aIndex)
A proxy to SIM_PLOT_FRAME::GetPlotColor()
wxBoxSizer * m_sizer

References _, mpWindow::AddLayer(), mpWindow::EnableDoubleBuffer(), GetPlotColor(), 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, mpWindow::SetColourTheme(), mpWindow::SetMargins(), mpScaleY::SetMasterScale(), mpScaleBase::SetNameAlign(), mpScaleBase::SetTicks(), mpScaleY::SetTicks(), mpLayer::SetVisible(), SIM_AXIS_COLOR, SIM_BG_COLOR, SIM_FG_COLOR, ST_AC, ST_DC, ST_NOISE, ST_TRANSIENT, and mpWindow::UpdateAll().

◆ ~SIM_PLOT_PANEL()

SIM_PLOT_PANEL::~SIM_PLOT_PANEL ( )
virtual

Definition at line 452 of file sim_plot_panel.cpp.

453 {
454  // ~mpWindow destroys all the added layers, so there is no need to destroy m_traces contents
455 }

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 484 of file sim_plot_panel.cpp.

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 }
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:2489
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:2472
void UpdateTraceStyle(TRACE *trace)
Update trace line style
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820
#define NULL
std::vector< mpLayer * > m_topLevel
std::map< wxString, TRACE * > m_traces
mpScaleY * m_axis_y2
SIM_TYPE GetType() const
wxColour generateColor()
void SetTraceColour(wxColour aColour)

References mpWindow::AddLayer(), mpWindow::DelLayer(), generateColor(), SIM_PANEL_BASE::GetType(), m_axis_x, m_axis_y1, m_axis_y2, 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 587 of file sim_plot_panel.cpp.

588 {
589  for( auto& t : m_traces )
590  {
591  DeleteTrace( t.first );
592  }
593 
594  m_colorIdx = 0;
595  m_traces.clear();
596 }
bool DeleteTrace(const wxString &aName)
unsigned int m_colorIdx
std::map< wxString, TRACE * > m_traces

References DeleteTrace(), m_colorIdx, and m_traces.

◆ DeleteTrace()

bool SIM_PLOT_PANEL::DeleteTrace ( const wxString &  aName)

Definition at line 565 of file sim_plot_panel.cpp.

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 }
mpWindow * m_plotWin
bool DelLayer(mpLayer *layer, bool alsoDeleteObject=false, bool refreshDisplay=true)
Remove a plot layer from the canvas.
Definition: mathplot.cpp:2489
std::map< wxString, TRACE * > m_traces
void ResetScales()
Resets scale ranges to fit the current traces
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 
)

Toggles cursor for a particular trace.

Definition at line 607 of file sim_plot_panel.cpp.

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 }
mpWindow * m_plotWin
mpWindow * GetPlotWin() const
Getter for math plot window
bool HasCursor() const
bool DelLayer(mpLayer *layer, bool alsoDeleteObject=false, bool refreshDisplay=true)
Remove a plot layer from the canvas.
Definition: mathplot.cpp:2489
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:2472
TRACE * GetTrace(const wxString &aName) const
#define NULL
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(), mpWindow::DelLayer(), TRACE::GetCursor(), mpWindow::GetMarginLeft(), mpWindow::GetMarginRight(), GetPlotWin(), GetTrace(), mpWindow::GetXScreen(), TRACE::HasCursor(), m_plotWin, NULL, TRACE::SetCursor(), and CURSOR::SetX().

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

◆ generateColor()

wxColour SIM_PLOT_PANEL::generateColor ( )
private

Returns
a new color from the palette

Definition at line 653 of file sim_plot_panel.cpp.

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 }
int color
Definition: DXF_plotter.cpp:61
wxColour GetTraceColour()
SIM_PLOT_FRAME * m_masterFrame
std::map< wxString, TRACE * > m_traces
wxColour GetPlotColor(int aIndex)
A proxy to SIM_PLOT_FRAME::GetPlotColor()

References color, GetPlotColor(), SIM_PLOT_FRAME::GetPlotColorCount(), TRACE::GetTraceColour(), m_masterFrame, m_traces, and SIM_TRACE_COLOR.

Referenced by AddTrace().

◆ GetDottedCurrentPhase()

bool SIM_PLOT_PANEL::GetDottedCurrentPhase ( ) const
inline

Definition at line 262 of file sim_plot_panel.h.

263  {
264  return m_dotted_cp;
265  }

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 183 of file sim_plot_panel.h.

184  {
185  return m_axis_x ? m_axis_x->GetName() : "";
186  }
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 188 of file sim_plot_panel.h.

189  {
190  return m_axis_y1 ? m_axis_y1->GetName() : "";
191  }
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 193 of file sim_plot_panel.h.

194  {
195  return m_axis_y2 ? m_axis_y2->GetName() : "";
196  }
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().

◆ GetPlotColor()

wxColour SIM_PLOT_PANEL::GetPlotColor ( int  aIndex)

A proxy to SIM_PLOT_FRAME::GetPlotColor()

Returns
the color stored in m_colorList.
Parameters
aIndexis the index in list

Definition at line 468 of file sim_plot_panel.cpp.

469 {
470  return m_masterFrame->GetPlotColor( aIndex );
471 }
SIM_PLOT_FRAME * m_masterFrame
wxColor GetPlotColor(int aColorId)

References SIM_PLOT_FRAME::GetPlotColor(), and m_masterFrame.

Referenced by generateColor(), CURSOR::Plot(), SIM_PLOT_PANEL(), and UpdatePlotColors().

◆ GetPlotWin()

mpWindow* SIM_PLOT_PANEL::GetPlotWin ( ) const
inline

◆ GetTrace()

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

Definition at line 215 of file sim_plot_panel.h.

216  {
217  auto trace = m_traces.find( aName );
218 
219  return trace == m_traces.end() ? NULL : trace->second;
220  }
#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 210 of file sim_plot_panel.h.

211  {
212  return m_traces;
213  }
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
inlineinherited

◆ HasCursorEnabled()

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

Returns true if the trace has cursor shown.

Definition at line 599 of file sim_plot_panel.cpp.

600 {
601  TRACE* t = GetTrace( aName );
602 
603  return t ? t->HasCursor() : false;
604 }
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 230 of file sim_plot_panel.h.

231  {
232  if( !m_axis_x || !m_axis_y1 )
233  return false;
234 
235  assert( m_axis_x->GetTicks() == m_axis_y1->GetTicks() );
236  return !m_axis_x->GetTicks();
237  }
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 245 of file sim_plot_panel.h.

246  {
247  return m_legend->IsVisible();
248  }
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 54 of file sim_panel_base.cpp.

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

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().

◆ ResetScales()

void SIM_PLOT_PANEL::ResetScales ( )

Resets scale ranges to fit the current traces

Definition at line 637 of file sim_plot_panel.cpp.

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 }
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 250 of file sim_plot_panel.h.

251  {
252  m_dotted_cp = aEnable;
253 
254  for( const auto& tr : m_traces )
255  {
256  UpdateTraceStyle( tr.second );
257  }
258 
259  m_plotWin->UpdateAll();
260  }
mpWindow * m_plotWin
void UpdateTraceStyle(TRACE *trace)
Update trace line style
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820
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

set the pointer to the sim plot frame

Definition at line 178 of file sim_plot_panel.h.

179  {
180  m_masterFrame = aFrame;
181  }
SIM_PLOT_FRAME * m_masterFrame

References m_masterFrame.

◆ ShowGrid()

void SIM_PLOT_PANEL::ShowGrid ( bool  aEnable)
inline

Definition at line 222 of file sim_plot_panel.h.

223  {
224  m_axis_x->SetTicks( !aEnable );
225  m_axis_y1->SetTicks( !aEnable );
226  m_axis_y2->SetTicks( !aEnable );
227  m_plotWin->UpdateAll();
228  }
mpWindow * m_plotWin
mpScaleY * m_axis_y1
mpScaleXBase * m_axis_x
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820
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 239 of file sim_plot_panel.h.

240  {
241  m_legend->SetVisible( aEnable );
242  m_plotWin->UpdateAll();
243  }
mpWindow * m_plotWin
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820
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 205 of file sim_plot_panel.h.

206  {
207  return m_traces.count( aName ) > 0;
208  }
std::map< wxString, TRACE * > m_traces

References m_traces.

Referenced by SIM_PLOT_FRAME::removePlot().

◆ UpdatePlotColors()

void SIM_PLOT_PANEL::UpdatePlotColors ( )

Update plot colors

Definition at line 458 of file sim_plot_panel.cpp.

459 {
460  // Update bg and fg colors:
463 
464  m_plotWin->UpdateAll();
465 }
mpWindow * m_plotWin
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2820
void SetColourTheme(const wxColour &bgColour, const wxColour &drawColour, const wxColour &axesColour)
Set Color theme.
Definition: mathplot.cpp:3185
wxColour GetPlotColor(int aIndex)
A proxy to SIM_PLOT_FRAME::GetPlotColor()

References GetPlotColor(), m_plotWin, mpWindow::SetColourTheme(), SIM_AXIS_COLOR, SIM_BG_COLOR, SIM_FG_COLOR, and mpWindow::UpdateAll().

◆ UpdateTraceStyle()

void SIM_PLOT_PANEL::UpdateTraceStyle ( TRACE trace)

Update trace line style

Definition at line 474 of file sim_plot_panel.cpp.

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 }
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

Definition at line 311 of file sim_plot_panel.h.

Referenced by AddTrace(), GetLabelY2(), ResetScales(), ShowGrid(), and SIM_PLOT_PANEL().

◆ m_colorIdx

unsigned int SIM_PLOT_PANEL::m_colorIdx
private

Definition at line 300 of file sim_plot_panel.h.

Referenced by DeleteAllTraces().

◆ m_dotted_cp

bool SIM_PLOT_PANEL::m_dotted_cp
private

◆ m_legend

mpInfoLegend* SIM_PLOT_PANEL::m_legend
private

Definition at line 312 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 318 of file sim_plot_panel.h.

Referenced by generateColor(), GetPlotColor(), and SetMasterFrame().

◆ m_plotWin

◆ m_sizer

wxBoxSizer* SIM_PLOT_PANEL::m_sizer
private

Definition at line 304 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 316 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: