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 (const 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 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
 Toggle cursor for a particular trace. More...
 
void EnableCursor (const wxString &aName, bool aEnable)
 Reset 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 Member Functions

bool addTrace (const wxString &aTitle, const wxString &aName, int aPoints, const double *aX, const double *aY, SIM_PLOT_TYPE aType, const wxString &aParam)
 
bool deleteTrace (const wxString &aName)
 
void deleteAllTraces ()
 
const wxString & getSimCommand () const
 
void setSimCommand (const wxString &aSimCommand)
 

Private Member Functions

void prepareDCAxes ()
 < More...
 
void updateAxes ()
 

Create/Ensure axes are available for plotting

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
 

Friends

class SIM_WORKBOOK
 

Detailed Description

Definition at line 176 of file sim_plot_panel.h.

Constructor & Destructor Documentation

◆ SIM_PLOT_PANEL()

SIM_PLOT_PANEL::SIM_PLOT_PANEL ( const 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 301 of file sim_plot_panel.cpp.

304  : SIM_PANEL_BASE( aCommand, parent, id, pos, size, style, name ),
305  m_axis_x( nullptr ),
306  m_axis_y1( nullptr ),
307  m_axis_y2( nullptr ),
308  m_dotted_cp( false ),
309  m_masterFrame( aMainFrame )
310 {
311  m_sizer = new wxBoxSizer( wxVERTICAL );
312  m_plotWin = new mpWindow( this, wxID_ANY, pos, size, style );
313 
314  m_plotWin->LimitView( true );
315  m_plotWin->SetMargins( 50, 80, 50, 80 );
316 
318 
319  updateAxes();
320 
321  // a mpInfoLegend displays le name of traces on the left top panel corner:
322  m_legend = new mpInfoLegend( wxRect( 0, 40, 200, 40 ), wxTRANSPARENT_BRUSH );
323  m_legend->SetVisible( false );
325 
326  m_plotWin->EnableDoubleBuffer( true );
327  m_plotWin->UpdateAll();
328 
329  m_sizer->Add( m_plotWin, 1, wxALL | wxEXPAND, 1 );
330  SetSizer( m_sizer );
331 }
class WXDLLIMPEXP_MATHPLOT mpWindow
Definition: mathplot.h:108
mpWindow * m_plotWin
mpScaleY * m_axis_y1
mpScaleXBase * m_axis_x
bool AddLayer(mpLayer *layer, bool refreshDisplay=true)
Add a plot layer to the canvas.
Definition: mathplot.cpp:2256
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:1212
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2403
void SetVisible(bool show)
Sets layer visibility.
Definition: mathplot.h:302
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:2682
mpScaleY * m_axis_y2
void updateAxes()
Create/Ensure axes are available for plotting
void UpdatePlotColors()
Update plot colors
const char * name
Definition: DXF_plotter.cpp:56
mpInfoLegend * m_legend
void LimitView(bool aEnable)
Limit zooming & panning to the area used by the plots.
Definition: mathplot.h:1429
Implements the legend to be added to the plot This layer allows you to add a legend to describe the p...
Definition: mathplot.h:437
wxBoxSizer * m_sizer

References mpWindow::AddLayer(), mpWindow::EnableDoubleBuffer(), mpWindow::LimitView(), m_legend, m_plotWin, m_sizer, mpWindow, mpWindow::SetMargins(), mpLayer::SetVisible(), mpWindow::UpdateAll(), updateAxes(), and UpdatePlotColors().

◆ ~SIM_PLOT_PANEL()

SIM_PLOT_PANEL::~SIM_PLOT_PANEL ( )
virtual

set the pointer to the sim plot frame

Definition at line 334 of file sim_plot_panel.cpp.

335 {
336  // ~mpWindow destroys all the added layers, so there is no need to destroy m_traces contents
337 }

Member Function Documentation

◆ addTrace()

bool SIM_PLOT_PANEL::addTrace ( const wxString &  aTitle,
const wxString &  aName,
int  aPoints,
const double *  aX,
const double *  aY,
SIM_PLOT_TYPE  aType,
const wxString &  aParam 
)
protected

Definition at line 472 of file sim_plot_panel.cpp.

475 {
476  TRACE* trace = nullptr;
477  wxString name = aTitle;
478 
479  updateAxes();
480 
481  // Find previous entry, if there is one
482  auto prev = m_traces.find( name );
483  bool addedNewEntry = ( prev == m_traces.end() );
484 
485  if( addedNewEntry )
486  {
487  if( GetType() == ST_TRANSIENT )
488  {
489  bool hasVoltageTraces = false;
490 
491  for( const auto& tr : m_traces )
492  {
493  if( !( tr.second->GetType() & SPT_CURRENT ) )
494  {
495  hasVoltageTraces = true;
496  break;
497  }
498  }
499 
500  if( !hasVoltageTraces )
501  m_axis_y2->SetMasterScale( nullptr );
502  else
504  }
505 
506  // New entry
507  trace = new TRACE( aName, aType, aParam );
509  UpdateTraceStyle( trace );
510  m_traces[name] = trace;
511 
512  // It is a trick to keep legend & coords always on the top
513  for( mpLayer* l : m_topLevel )
514  m_plotWin->DelLayer( l );
515 
516  m_plotWin->AddLayer( (mpLayer*) trace );
517 
518  for( mpLayer* l : m_topLevel )
519  m_plotWin->AddLayer( l );
520  }
521  else
522  {
523  trace = prev->second;
524  }
525 
526  std::vector<double> tmp( aY, aY + aPoints );
527 
528  if( GetType() == ST_AC )
529  {
530  if( aType & SPT_AC_PHASE )
531  {
532  for( int i = 0; i < aPoints; i++ )
533  tmp[i] = tmp[i] * 180.0 / M_PI; // convert to degrees
534  }
535  else
536  {
537  for( int i = 0; i < aPoints; i++ )
538  {
539  // log( 0 ) is not valid.
540  if( tmp[i] != 0 )
541  tmp[i] = 20 * log( tmp[i] ) / log( 10.0 ); // convert to dB
542  }
543  }
544  }
545 
546  trace->SetData( std::vector<double>( aX, aX + aPoints ), tmp );
547 
548  if( ( aType & SPT_AC_PHASE ) || ( aType & SPT_CURRENT ) )
549  trace->SetScale( m_axis_x, m_axis_y2 );
550  else
551  trace->SetScale( m_axis_x, m_axis_y1 );
552 
553  m_plotWin->UpdateAll();
554 
555  return addedNewEntry;
556 }
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:2273
mpScaleXBase * m_axis_x
void SetMasterScale(mpScaleY *masterScale)
Definition: mathplot.h:979
bool AddLayer(mpLayer *layer, bool refreshDisplay=true)
Add a plot layer to the canvas.
Definition: mathplot.cpp:2256
void UpdateTraceStyle(TRACE *trace)
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2403
wxColour GenerateColor(std::map< wxString, TRACE * > aTraces)
SIM_PLOT_COLORS m_colors
std::vector< mpLayer * > m_topLevel
std::map< wxString, TRACE * > m_traces
mpScaleY * m_axis_y2
void updateAxes()
Create/Ensure axes are available for plotting
SIM_TYPE GetType() const
const char * name
Definition: DXF_plotter.cpp:56
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, name, TRACE::SetData(), mpScaleY::SetMasterScale(), mpFXY::SetScale(), TRACE::SetTraceColour(), SPT_AC_PHASE, SPT_CURRENT, ST_AC, ST_TRANSIENT, mpWindow::UpdateAll(), updateAxes(), and UpdateTraceStyle().

Referenced by SIM_WORKBOOK::AddTrace().

◆ deleteAllTraces()

void SIM_PLOT_PANEL::deleteAllTraces ( )
protected

Definition at line 581 of file sim_plot_panel.cpp.

582 {
583  for( auto& t : m_traces )
584  {
585  deleteTrace( t.first );
586  }
587 
588  m_traces.clear();
589 }
std::map< wxString, TRACE * > m_traces
bool deleteTrace(const wxString &aName)

References deleteTrace(), and m_traces.

◆ deleteTrace()

bool SIM_PLOT_PANEL::deleteTrace ( const wxString &  aName)
protected

Definition at line 559 of file sim_plot_panel.cpp.

560 {
561  auto it = m_traces.find( aName );
562 
563  if( it != m_traces.end() )
564  {
565  TRACE* trace = it->second;
566  m_traces.erase( it );
567 
568  if( CURSOR* cursor = trace->GetCursor() )
569  m_plotWin->DelLayer( cursor, true );
570 
571  m_plotWin->DelLayer( trace, true, true );
572  ResetScales();
573 
574  return true;
575  }
576 
577  return false;
578 }
mpWindow * m_plotWin
bool DelLayer(mpLayer *layer, bool alsoDeleteObject=false, bool refreshDisplay=true)
Remove a plot layer from the canvas.
Definition: mathplot.cpp:2273
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 cursor, mpWindow::DelLayer(), TRACE::GetCursor(), m_plotWin, m_traces, and ResetScales().

Referenced by deleteAllTraces(), and SIM_WORKBOOK::DeleteTrace().

◆ EnableCursor()

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

Reset scale ranges to fit the current traces.

Definition at line 600 of file sim_plot_panel.cpp.

601 {
602  TRACE* t = GetTrace( aName );
603 
604  if( t == nullptr || t->HasCursor() == aEnable )
605  return;
606 
607  if( aEnable )
608  {
609  CURSOR* c = new CURSOR( t, this );
610  int plotCenter = GetPlotWin()->GetMarginLeft()
612  - GetPlotWin()->GetMarginRight() )
613  / 2;
614  c->SetX( plotCenter );
616  t->SetCursor( c );
617  m_plotWin->AddLayer( c );
618  }
619  else
620  {
621  CURSOR* c = t->GetCursor();
622  t->SetCursor( nullptr );
623  m_plotWin->DelLayer( c, true );
624  }
625 
626  // Notify the parent window about the changes
627  wxQueueEvent( GetParent(), new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
628 }
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:2273
int GetXScreen(void) const
Definition: mathplot.h:1139
bool AddLayer(mpLayer *layer, bool refreshDisplay=true)
Add a plot layer to the canvas.
Definition: mathplot.cpp:2256
void SetPen(wxPen pen)
Set layer pen.
Definition: mathplot.h:277
TRACE * GetTrace(const wxString &aName) const
int GetMarginRight() const
Definition: mathplot.h:1373
SIM_PLOT_COLORS m_colors
wxColour GetPlotColor(enum COLOR_SET aColorId)
void SetX(int aX)
CURSOR * GetCursor() const
int GetMarginLeft() const
Definition: mathplot.h:1377
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, TRACE::SetCursor(), mpLayer::SetPen(), and CURSOR::SetX().

◆ GetDottedCurrentPhase()

bool SIM_PLOT_PANEL::GetDottedCurrentPhase ( ) const
inline

Returns true if the trace has cursor shown.

Definition at line 266 of file sim_plot_panel.h.

References m_dotted_cp.

◆ GetLabelX()

wxString SIM_PLOT_PANEL::GetLabelX ( ) const
inline

Definition at line 194 of file sim_plot_panel.h.

195  {
196  return m_axis_x ? m_axis_x->GetName() : "";
197  }
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:238
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 199 of file sim_plot_panel.h.

200  {
201  return m_axis_y1 ? m_axis_y1->GetName() : "";
202  }
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:238
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 204 of file sim_plot_panel.h.

205  {
206  return m_axis_y2 ? m_axis_y2->GetName() : "";
207  }
const wxString & GetName() const
Get layer name.
Definition: mathplot.h:238
mpScaleY * m_axis_y2

References mpLayer::GetName(), and m_axis_y2.

Referenced by SIM_PLOT_FRAME::onCursorUpdate().

◆ GetPlotWin()

◆ getSimCommand()

const wxString& SIM_PANEL_BASE::getSimCommand ( ) const
inlineprotectedinherited

Definition at line 57 of file sim_panel_base.h.

57 { return m_simCommand; }
wxString m_simCommand

References SIM_PANEL_BASE::m_simCommand.

Referenced by SIM_WORKBOOK::GetSimCommand(), and prepareDCAxes().

◆ GetTrace()

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

Definition at line 219 of file sim_plot_panel.h.

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

References m_traces.

Referenced by EnableCursor(), and HasCursorEnabled().

◆ GetTraces()

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

◆ GetType()

◆ HasCursorEnabled()

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

Toggle cursor for a particular trace.

Definition at line 592 of file sim_plot_panel.cpp.

593 {
594  TRACE* t = GetTrace( aName );
595 
596  return t ? t->HasCursor() : false;
597 }
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 234 of file sim_plot_panel.h.

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

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

◆ IsLegendShown()

bool SIM_PLOT_PANEL::IsLegendShown ( ) const
inline

Definition at line 249 of file sim_plot_panel.h.

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

References mpLayer::IsVisible(), and m_legend.

◆ IsPlottable()

bool SIM_PANEL_BASE::IsPlottable ( SIM_TYPE  aSimType)
staticinherited

Definition at line 57 of file sim_panel_base.cpp.

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

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

400 {
401  wxString sim_cmd = getSimCommand().Lower();
402  wxString rem;
403 
404  if( sim_cmd.StartsWith( ".dc", &rem ) )
405  {
406  wxChar ch;
407 
408  rem.Trim( false );
409 
410  try
411  {
412  ch = rem.GetChar( 0 );
413  }
414  catch( ... )
415  {;}
416 
417  switch( ch )
418  {
419  // Make sure that we have a reliable default (even if incorrectly labeled)
420  default:
421  case 'v':
422  m_axis_x =
423  new LIN_SCALE<mpScaleX>( _( "Voltage (swept)" ), wxT( "V" ), mpALIGN_BOTTOM );
424  break;
425  case 'i':
426  m_axis_x =
427  new LIN_SCALE<mpScaleX>( _( "Current (swept)" ), wxT( "A" ), mpALIGN_BOTTOM );
428  break;
429  case 'r':
430  m_axis_x = new LIN_SCALE<mpScaleX>( _( "Resistance (swept)" ), wxT( "\u03A9" ),
431  mpALIGN_BOTTOM );
432  break;
433  case 't':
434  m_axis_x = new LIN_SCALE<mpScaleX>( _( "Temperature (swept)" ), wxT( "\u00B0C" ),
435  mpALIGN_BOTTOM );
436  break;
437  }
438 
439  m_axis_y1 = new LIN_SCALE<mpScaleY>( _( "Voltage (measured)" ), wxT( "V" ), mpALIGN_LEFT );
440  m_axis_y2 = new LIN_SCALE<mpScaleY>( _( "Current" ), wxT( "A" ), mpALIGN_RIGHT );
441  }
442 }
#define mpALIGN_LEFT
Aligns label to the left.
Definition: mathplot.h:481
mpScaleY * m_axis_y1
mpScaleXBase * m_axis_x
#define mpALIGN_RIGHT
Aligns label to the right.
Definition: mathplot.h:477
const wxString & getSimCommand() const
mpScaleY * m_axis_y2
#define _(s)
#define mpALIGN_BOTTOM
Aligns label to the bottom.
Definition: mathplot.h:485

References _, SIM_PANEL_BASE::getSimCommand(), m_axis_x, m_axis_y1, m_axis_y2, mpALIGN_BOTTOM, mpALIGN_LEFT, and mpALIGN_RIGHT.

Referenced by updateAxes().

◆ ResetScales()

void SIM_PLOT_PANEL::ResetScales ( )

Update trace line style.

Definition at line 631 of file sim_plot_panel.cpp.

632 {
633  if( m_axis_x )
635 
636  if( m_axis_y1 )
638 
639  if( m_axis_y2 )
641 
642  for( auto t : m_traces )
643  t.second->UpdateScales();
644 }
mpScaleY * m_axis_y1
mpScaleXBase * m_axis_x
void ResetDataRange()
Definition: mathplot.h:759
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 254 of file sim_plot_panel.h.

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

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

◆ SetMasterFrame()

void SIM_PLOT_PANEL::SetMasterFrame ( SIM_PLOT_FRAME aFrame)
inline

Definition at line 189 of file sim_plot_panel.h.

190  {
191  m_masterFrame = aFrame;
192  }
SIM_PLOT_FRAME * m_masterFrame

References m_masterFrame.

◆ setSimCommand()

void SIM_PANEL_BASE::setSimCommand ( const wxString &  aSimCommand)
inlineprotectedinherited

Definition at line 59 of file sim_panel_base.h.

60  {
61  wxCHECK_RET( GetType() == NETLIST_EXPORTER_PSPICE_SIM::CommandToSimType( aSimCommand ),
62  "Cannot change the type of simulation of the existing plot panel" );
63 
64  m_simCommand = aSimCommand;
65  }
static SIM_TYPE CommandToSimType(const wxString &aCmd)
Return simulation type basing on a simulation command directive.
wxString m_simCommand
SIM_TYPE GetType() const

References NETLIST_EXPORTER_PSPICE_SIM::CommandToSimType(), SIM_PANEL_BASE::GetType(), and SIM_PANEL_BASE::m_simCommand.

Referenced by SIM_WORKBOOK::SetSimCommand().

◆ ShowGrid()

void SIM_PLOT_PANEL::ShowGrid ( bool  aEnable)
inline

Definition at line 226 of file sim_plot_panel.h.

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

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

◆ ShowLegend()

void SIM_PLOT_PANEL::ShowLegend ( bool  aEnable)
inline

Definition at line 243 of file sim_plot_panel.h.

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

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

◆ TraceShown()

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

Definition at line 209 of file sim_plot_panel.h.

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

References m_traces.

Referenced by SIM_PLOT_FRAME::removePlot().

◆ updateAxes()

void SIM_PLOT_PANEL::updateAxes ( )
private

Create/Ensure axes are available for plotting

Definition at line 340 of file sim_plot_panel.cpp.

341 {
342  if( m_axis_x )
343  return;
344 
345  switch( GetType() )
346  {
347  case ST_AC:
348  m_axis_x = new LOG_SCALE<mpScaleXLog>( _( "Frequency" ), wxT( "Hz" ), mpALIGN_BOTTOM );
349  m_axis_y1 = new LIN_SCALE<mpScaleY>( _( "Gain" ), wxT( "dBV" ), mpALIGN_LEFT );
350  m_axis_y2 = new LIN_SCALE<mpScaleY>( _( "Phase" ), wxT( "\u00B0" ),
351  mpALIGN_RIGHT ); // degree sign
353  break;
354 
355  case ST_DC:
356  prepareDCAxes();
357  break;
358 
359  case ST_NOISE:
360  m_axis_x = new LOG_SCALE<mpScaleXLog>( _( "Frequency" ), wxT( "Hz" ), mpALIGN_BOTTOM );
361  m_axis_y1 = new mpScaleY( _( "noise [(V or A)^2/Hz]" ), mpALIGN_LEFT );
362  break;
363 
364  case ST_TRANSIENT:
365  m_axis_x = new LIN_SCALE<mpScaleX>( _( "Time" ), wxT( "s" ), mpALIGN_BOTTOM );
366  m_axis_y1 = new LIN_SCALE<mpScaleY>( _( "Voltage" ), wxT( "V" ), mpALIGN_LEFT );
367  m_axis_y2 = new LIN_SCALE<mpScaleY>( _( "Current" ), wxT( "A" ), mpALIGN_RIGHT );
369  break;
370 
371  default:
372  // suppress warnings
373  break;
374  }
375 
376  if( m_axis_x )
377  {
378  m_axis_x->SetTicks( false );
380 
382  }
383 
384  if( m_axis_y1 )
385  {
386  m_axis_y1->SetTicks( false );
389  }
390 
391  if( m_axis_y2 )
392  {
393  m_axis_y2->SetTicks( false );
396  }
397 }
#define mpALIGN_LEFT
Aligns label to the left.
Definition: mathplot.h:481
mpWindow * m_plotWin
void SetNameAlign(int align)
Definition: mathplot.h:709
mpScaleY * m_axis_y1
mpScaleXBase * m_axis_x
void SetMasterScale(mpScaleY *masterScale)
Definition: mathplot.h:979
#define mpALIGN_RIGHT
Aligns label to the right.
Definition: mathplot.h:477
bool AddLayer(mpLayer *layer, bool refreshDisplay=true)
Add a plot layer to the canvas.
Definition: mathplot.cpp:2256
class WXDLLIMPEXP_MATHPLOT mpScaleY
Definition: mathplot.h:107
mpScaleY * m_axis_y2
void SetTicks(bool enable)
Set X axis ticks or grid.
Definition: mathplot.h:714
#define _(s)
SIM_TYPE GetType() const
void SetTicks(bool ticks)
Set Y axis ticks or grid.
Definition: mathplot.h:969
#define mpALIGN_BOTTOM
Aligns label to the bottom.
Definition: mathplot.h:485

References _, mpWindow::AddLayer(), SIM_PANEL_BASE::GetType(), m_axis_x, m_axis_y1, m_axis_y2, m_plotWin, mpALIGN_BOTTOM, mpALIGN_LEFT, mpALIGN_RIGHT, mpScaleY, prepareDCAxes(), mpScaleY::SetMasterScale(), mpScaleBase::SetNameAlign(), mpScaleBase::SetTicks(), mpScaleY::SetTicks(), ST_AC, ST_DC, ST_NOISE, and ST_TRANSIENT.

Referenced by addTrace(), and SIM_PLOT_PANEL().

◆ UpdatePlotColors()

void SIM_PLOT_PANEL::UpdatePlotColors ( )

Update plot colors

Getter for math plot window

Definition at line 445 of file sim_plot_panel.cpp.

446 {
447  // Update bg and fg colors:
451 
452  // Update color of all traces
453  for( auto& t : m_traces )
454  if( t.second->GetCursor() )
455  t.second->GetCursor()->SetPen(
457 
458  m_plotWin->UpdateAll();
459 }
mpWindow * m_plotWin
void UpdateAll()
Refresh display.
Definition: mathplot.cpp:2403
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:2748
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 462 of file sim_plot_panel.cpp.

463 {
464  int type = trace->GetType();
465  wxPenStyle penStyle = ( ( ( type & SPT_AC_PHASE ) || ( type & SPT_CURRENT ) ) && m_dotted_cp )
466  ? wxPENSTYLE_DOT
467  : wxPENSTYLE_SOLID;
468  trace->SetPen( wxPen( trace->GetTraceColour(), 2, penStyle ) );
469 }
wxColour GetTraceColour()
void SetPen(wxPen pen)
Set layer pen.
Definition: mathplot.h:277
SIM_PLOT_TYPE GetType() const

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

Referenced by addTrace(), and SetDottedCurrentPhase().

Friends And Related Function Documentation

◆ SIM_WORKBOOK

friend class SIM_WORKBOOK
friend

Definition at line 178 of file sim_plot_panel.h.

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

Referenced by addTrace(), GetLabelY2(), prepareDCAxes(), ResetScales(), ShowGrid(), and updateAxes().

◆ m_colors

SIM_PLOT_COLORS SIM_PLOT_PANEL::m_colors
private

Definition at line 307 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 319 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 325 of file sim_plot_panel.h.

Referenced by SetMasterFrame().

◆ m_plotWin

◆ m_sizer

wxBoxSizer* SIM_PLOT_PANEL::m_sizer
private

Definition at line 311 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 323 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: