Straighten out some really confusing terminology in simulator GUI.

This commit is contained in:
Jeff Young 2023-07-09 23:00:25 +01:00
parent 7608350bdc
commit 8f9a67063a
13 changed files with 303 additions and 307 deletions

View File

@ -229,8 +229,8 @@ set( EESCHEMA_SIM_SRCS
sim/simulator_panel.cpp
sim/simulator_panel_base.cpp
sim/sim_plot_colors.cpp
sim/sim_plot_panel_base.cpp
sim/sim_plot_panel.cpp
sim/sim_tab.cpp
sim/sim_plot_tab.cpp
sim/sim_property.cpp
sim/spice_simulator.cpp
sim/spice_value.cpp

View File

@ -25,7 +25,7 @@
#include "sim_plot_colors.h"
#include "sim_plot_panel.h"
#include <sim/sim_plot_tab.h>
#include <wx/stc/stc.h>

View File

@ -26,7 +26,7 @@
*/
#include "sim_plot_colors.h"
#include "sim_plot_panel.h"
#include "sim_plot_tab.h"
#include "simulator_frame.h"
#include "core/kicad_algo.h"
@ -405,9 +405,8 @@ void CURSOR::UpdateReference()
}
SIM_PLOT_PANEL::SIM_PLOT_PANEL( const wxString& aSimCommand, unsigned aSimOptions,
wxWindow* parent ) :
SIM_PLOT_PANEL_BASE( aSimCommand, aSimOptions, parent ),
SIM_PLOT_TAB::SIM_PLOT_TAB( const wxString& aSimCommand, unsigned aSimOptions, wxWindow* parent ) :
SIM_TAB( aSimCommand, aSimOptions, parent ),
m_axis_x( nullptr ),
m_axis_y1( nullptr ),
m_axis_y2( nullptr ),
@ -437,13 +436,13 @@ SIM_PLOT_PANEL::SIM_PLOT_PANEL( const wxString& aSimCommand, unsigned aSimOption
}
SIM_PLOT_PANEL::~SIM_PLOT_PANEL()
SIM_PLOT_TAB::~SIM_PLOT_TAB()
{
// ~mpWindow destroys all the added layers, so there is no need to destroy m_traces contents
}
wxString SIM_PLOT_PANEL::GetUnitsX() const
wxString SIM_PLOT_TAB::GetUnitsX() const
{
LOG_SCALE<mpScaleXLog>* logScale = dynamic_cast<LOG_SCALE<mpScaleXLog>*>( m_axis_x );
LIN_SCALE<mpScaleX>* linScale = dynamic_cast<LIN_SCALE<mpScaleX>*>( m_axis_x );
@ -457,7 +456,7 @@ wxString SIM_PLOT_PANEL::GetUnitsX() const
}
wxString SIM_PLOT_PANEL::GetUnitsY1() const
wxString SIM_PLOT_TAB::GetUnitsY1() const
{
LIN_SCALE<mpScaleY>* linScale = dynamic_cast<LIN_SCALE<mpScaleY>*>( m_axis_y1 );
@ -468,7 +467,7 @@ wxString SIM_PLOT_PANEL::GetUnitsY1() const
}
wxString SIM_PLOT_PANEL::GetUnitsY2() const
wxString SIM_PLOT_TAB::GetUnitsY2() const
{
LIN_SCALE<mpScaleY>* linScale = dynamic_cast<LIN_SCALE<mpScaleY>*>( m_axis_y2 );
@ -479,7 +478,7 @@ wxString SIM_PLOT_PANEL::GetUnitsY2() const
}
wxString SIM_PLOT_PANEL::GetUnitsY3() const
wxString SIM_PLOT_TAB::GetUnitsY3() const
{
LIN_SCALE<mpScaleY>* linScale = dynamic_cast<LIN_SCALE<mpScaleY>*>( m_axis_y3 );
@ -490,7 +489,7 @@ wxString SIM_PLOT_PANEL::GetUnitsY3() const
}
void SIM_PLOT_PANEL::updateAxes( int aNewTraceType )
void SIM_PLOT_TAB::updateAxes( int aNewTraceType )
{
switch( GetSimType() )
{
@ -644,7 +643,7 @@ void SIM_PLOT_PANEL::updateAxes( int aNewTraceType )
}
void SIM_PLOT_PANEL::prepareDCAxes( int aNewTraceType )
void SIM_PLOT_TAB::prepareDCAxes( int aNewTraceType )
{
wxString sim_cmd = GetSimCommand().Lower();
wxString rem;
@ -746,7 +745,7 @@ void SIM_PLOT_PANEL::prepareDCAxes( int aNewTraceType )
}
void SIM_PLOT_PANEL::UpdatePlotColors()
void SIM_PLOT_TAB::UpdatePlotColors()
{
// Update bg and fg colors:
m_plotWin->SetColourTheme( m_colors.GetPlotColor( SIM_PLOT_COLORS::COLOR_SET::BACKGROUND ),
@ -767,14 +766,14 @@ void SIM_PLOT_PANEL::UpdatePlotColors()
}
void SIM_PLOT_PANEL::OnLanguageChanged()
void SIM_PLOT_TAB::OnLanguageChanged()
{
updateAxes();
m_plotWin->UpdateAll();
}
void SIM_PLOT_PANEL::UpdateTraceStyle( TRACE* trace )
void SIM_PLOT_TAB::UpdateTraceStyle( TRACE* trace )
{
int type = trace->GetType();
wxPenStyle penStyle = ( ( ( type & SPT_AC_PHASE ) || ( type & SPT_CURRENT ) ) && m_dotted_cp )
@ -784,7 +783,7 @@ void SIM_PLOT_PANEL::UpdateTraceStyle( TRACE* trace )
}
TRACE* SIM_PLOT_PANEL::AddTrace( const wxString& aVectorName, int aType )
TRACE* SIM_PLOT_TAB::AddTrace( const wxString& aVectorName, int aType )
{
TRACE* trace = GetTrace( aVectorName, aType );
@ -827,7 +826,7 @@ TRACE* SIM_PLOT_PANEL::AddTrace( const wxString& aVectorName, int aType )
}
void SIM_PLOT_PANEL::SetTraceData( TRACE* trace, unsigned int aPoints, const double* aX,
void SIM_PLOT_TAB::SetTraceData( TRACE* trace, unsigned int aPoints, const double* aX,
const double* aY )
{
std::vector<double> x( aX, aX + aPoints );
@ -879,7 +878,7 @@ void SIM_PLOT_PANEL::SetTraceData( TRACE* trace, unsigned int aPoints, const dou
}
void SIM_PLOT_PANEL::DeleteTrace( TRACE* aTrace )
void SIM_PLOT_TAB::DeleteTrace( TRACE* aTrace )
{
for( const auto& [ name, trace ] : m_traces )
{
@ -901,7 +900,7 @@ void SIM_PLOT_PANEL::DeleteTrace( TRACE* aTrace )
}
bool SIM_PLOT_PANEL::DeleteTrace( const wxString& aVectorName, int aTraceType )
bool SIM_PLOT_TAB::DeleteTrace( const wxString& aVectorName, int aTraceType )
{
if( TRACE* trace = GetTrace( aVectorName, aTraceType ) )
{
@ -913,7 +912,7 @@ bool SIM_PLOT_PANEL::DeleteTrace( const wxString& aVectorName, int aTraceType )
}
void SIM_PLOT_PANEL::EnableCursor( const wxString& aVectorName, int aType, int aCursorId,
void SIM_PLOT_TAB::EnableCursor( const wxString& aVectorName, int aType, int aCursorId,
bool aEnable, const wxString& aSignalName )
{
TRACE* t = GetTrace( aVectorName, aType );
@ -947,7 +946,7 @@ void SIM_PLOT_PANEL::EnableCursor( const wxString& aVectorName, int aType, int a
}
void SIM_PLOT_PANEL::ResetScales( bool aIncludeX )
void SIM_PLOT_TAB::ResetScales( bool aIncludeX )
{
if( m_axis_x && aIncludeX )
m_axis_x->ResetDataRange();

View File

@ -33,18 +33,18 @@
#include <widgets/mathplot.h>
#include <wx/colour.h>
#include <wx/sizer.h>
#include "sim_plot_panel_base.h"
#include "sim_tab.h"
#include "sim_plot_colors.h"
class SIMULATOR_FRAME;
class SIM_PLOT_PANEL;
class SIM_PLOT_TAB;
class TRACE;
/**
*
* The SIMULATOR_FRAME holds the main user-interface for running simulations.
*
* It contains a workbook with multiple tabs, each tab holding a SIM_PLOT_PANEL, a specific
* It contains a workbook with multiple tabs, each tab holding a SIM_PLOT_TAB, a specific
* simulation command (.TRAN, .AC, etc.), and simulation settings (save all currents, etc.).
*
* Each plot can have multiple TRACEs. While internally each TRACE can have multiple cursors,
@ -63,7 +63,7 @@ class TRACE;
class CURSOR : public mpInfoLayer
{
public:
CURSOR( TRACE* aTrace, SIM_PLOT_PANEL* aPlotPanel ) :
CURSOR( TRACE* aTrace, SIM_PLOT_TAB* aPlotTab ) :
mpInfoLayer( wxRect( 0, 0, DRAG_MARGIN, DRAG_MARGIN ), wxTRANSPARENT_BRUSH ),
m_trace( aTrace ),
m_updateRequired( true ),
@ -191,12 +191,12 @@ protected:
};
class SIM_PLOT_PANEL : public SIM_PLOT_PANEL_BASE
class SIM_PLOT_TAB : public SIM_TAB
{
public:
SIM_PLOT_PANEL( const wxString& aSimCommand, unsigned aSimOptions, wxWindow* parent );
SIM_PLOT_TAB( const wxString& aSimCommand, unsigned aSimOptions, wxWindow* parent );
virtual ~SIM_PLOT_PANEL();
virtual ~SIM_PLOT_TAB();
wxString GetLabelX() const
{

View File

@ -24,21 +24,20 @@
*/
#include "confirm.h"
#include "sim_plot_panel_base.h"
#include "sim_tab.h"
#include "simulator_frame.h"
#include "ngspice_circuit_model.h"
SIM_PLOT_PANEL_BASE::SIM_PLOT_PANEL_BASE() :
SIM_TAB::SIM_TAB() :
m_simCommand( wxEmptyString ),
m_simOptions( NETLIST_EXPORTER_SPICE::OPTION_DEFAULT_FLAGS )
{
}
SIM_PLOT_PANEL_BASE::SIM_PLOT_PANEL_BASE( const wxString& aSimCommand, unsigned aSimOptions,
wxWindow* parent ) :
SIM_TAB::SIM_TAB( const wxString& aSimCommand, unsigned aSimOptions, wxWindow* parent ) :
wxWindow( parent, wxID_ANY ),
m_simCommand( aSimCommand ),
m_simOptions( aSimOptions )
@ -46,12 +45,12 @@ SIM_PLOT_PANEL_BASE::SIM_PLOT_PANEL_BASE( const wxString& aSimCommand, unsigned
}
SIM_PLOT_PANEL_BASE::~SIM_PLOT_PANEL_BASE()
SIM_TAB::~SIM_TAB()
{
}
bool SIM_PLOT_PANEL_BASE::IsPlottable( SIM_TYPE aSimType )
bool SIM_TAB::IsPlottable( SIM_TYPE aSimType )
{
switch( aSimType )
{
@ -69,15 +68,15 @@ bool SIM_PLOT_PANEL_BASE::IsPlottable( SIM_TYPE aSimType )
}
SIM_TYPE SIM_PLOT_PANEL_BASE::GetSimType() const
SIM_TYPE SIM_TAB::GetSimType() const
{
return NGSPICE_CIRCUIT_MODEL::CommandToSimType( m_simCommand );
}
SIM_NOPLOT_PANEL::SIM_NOPLOT_PANEL( const wxString& aSimCommand, unsigned aSimOptions,
SIM_NOPLOT_TAB::SIM_NOPLOT_TAB( const wxString& aSimCommand, unsigned aSimOptions,
wxWindow* parent ) :
SIM_PLOT_PANEL_BASE( aSimCommand, aSimOptions, parent )
SIM_TAB( aSimCommand, aSimOptions, parent )
{
m_sizer = new wxBoxSizer( wxVERTICAL );
m_sizer->Add( 0, 1, 1, wxEXPAND, 5 );
@ -96,12 +95,12 @@ SIM_NOPLOT_PANEL::SIM_NOPLOT_PANEL( const wxString& aSimCommand, unsigned aSimOp
}
SIM_NOPLOT_PANEL::~SIM_NOPLOT_PANEL()
SIM_NOPLOT_TAB::~SIM_NOPLOT_TAB()
{
}
void SIM_NOPLOT_PANEL::OnLanguageChanged()
void SIM_NOPLOT_TAB::OnLanguageChanged()
{
m_textInfo->SetLabel( _( "Simulation provided no plots. Please refer to console window "
"for results." ) );

View File

@ -33,12 +33,12 @@
#include <wx/stattext.h>
class SIM_PLOT_PANEL_BASE : public wxWindow
class SIM_TAB : public wxWindow
{
public:
SIM_PLOT_PANEL_BASE();
SIM_PLOT_PANEL_BASE( const wxString& aSimCommand, unsigned aSimOptions, wxWindow* parent );
virtual ~SIM_PLOT_PANEL_BASE();
SIM_TAB();
SIM_TAB( const wxString& aSimCommand, unsigned aSimOptions, wxWindow* parent );
virtual ~SIM_TAB();
static bool IsPlottable( SIM_TYPE aSimType );
@ -66,12 +66,12 @@ private:
};
class SIM_NOPLOT_PANEL : public SIM_PLOT_PANEL_BASE
class SIM_NOPLOT_TAB : public SIM_TAB
{
public:
SIM_NOPLOT_PANEL( const wxString& aSimCommand, unsigned aSimOptions, wxWindow* parent );
SIM_NOPLOT_TAB( const wxString& aSimCommand, unsigned aSimOptions, wxWindow* parent );
virtual ~SIM_NOPLOT_PANEL();
virtual ~SIM_NOPLOT_TAB();
void OnLanguageChanged() override;

View File

@ -52,7 +52,7 @@
#include "ngspice.h"
#include <sim/simulator_frame.h>
#include <sim/simulator_panel.h>
#include <sim/sim_plot_panel.h>
#include <sim/sim_plot_tab.h>
#include <sim/spice_simulator.h>
#include <sim/spice_reporter.h>
#include <eeschema_settings.h>
@ -284,8 +284,8 @@ WINDOW_SETTINGS* SIMULATOR_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg )
wxString SIMULATOR_FRAME::GetCurrentSimCommand() const
{
if( m_panel->GetCurrentPlotPanel() )
return m_panel->GetCurrentPlotPanel()->GetSimCommand();
if( m_panel->GetCurrentSimTab() )
return m_panel->GetCurrentSimTab()->GetSimCommand();
else
return m_circuitModel->GetSchTextSimCommand();
}
@ -299,8 +299,8 @@ SIM_TYPE SIMULATOR_FRAME::GetCurrentSimType() const
int SIMULATOR_FRAME::GetCurrentOptions() const
{
if( SIM_PLOT_PANEL_BASE* plotPanel = m_panel->GetCurrentPlotPanel() )
return plotPanel->GetSimOptions();
if( SIM_TAB* simTab = m_panel->GetCurrentSimTab() )
return simTab->GetSimOptions();
else
return NETLIST_EXPORTER_SPICE::OPTION_DEFAULT_FLAGS;
}
@ -361,17 +361,17 @@ bool SIMULATOR_FRAME::LoadSimulator( const wxString& aSimCommand, unsigned aSimO
void SIMULATOR_FRAME::StartSimulation()
{
SIM_PLOT_PANEL_BASE* plotPanel = m_panel->GetCurrentPlotPanel();
SIM_TAB* simTab = m_panel->GetCurrentSimTab();
if( !plotPanel )
if( !simTab )
return;
if( plotPanel->GetSimCommand().Upper().StartsWith( wxT( "FFT" ) ) )
if( simTab->GetSimCommand().Upper().StartsWith( wxT( "FFT" ) ) )
{
wxString tranSpicePlot;
if( SIM_PLOT_PANEL_BASE* tranPlotPanel = m_panel->GetPlotPanel( ST_TRAN ) )
tranSpicePlot = tranPlotPanel->GetSpicePlotName();
if( SIM_TAB* tranPlotTab = m_panel->GetSimTab( ST_TRAN ) )
tranSpicePlot = tranPlotTab->GetSpicePlotName();
if( tranSpicePlot.IsEmpty() )
{
@ -382,7 +382,7 @@ void SIMULATOR_FRAME::StartSimulation()
{
m_simulator->Command( "setplot " + tranSpicePlot.ToStdString() );
wxArrayString commands = wxSplit( plotPanel->GetSimCommand(), '\n' );
wxArrayString commands = wxSplit( simTab->GetSimCommand(), '\n' );
for( const wxString& command : commands )
{
@ -390,7 +390,7 @@ void SIMULATOR_FRAME::StartSimulation()
m_simulator->Command( command.ToStdString() );
}
plotPanel->SetSpicePlotName( m_simulator->CurrentPlotName() );
simTab->SetSpicePlotName( m_simulator->CurrentPlotName() );
m_panel->OnSimRefresh( true );
#if 0
@ -403,21 +403,21 @@ void SIMULATOR_FRAME::StartSimulation()
}
else
{
if( m_panel->GetPlotIndex( plotPanel ) == 0
&& m_circuitModel->GetSchTextSimCommand() != plotPanel->GetLastSchTextSimCommand() )
if( m_panel->GetSimTabIndex( simTab ) == 0
&& m_circuitModel->GetSchTextSimCommand() != simTab->GetLastSchTextSimCommand() )
{
if( plotPanel->GetLastSchTextSimCommand().IsEmpty()
if( simTab->GetLastSchTextSimCommand().IsEmpty()
|| IsOK( this, _( "Schematic sheet simulation command directive has changed. "
"Do you wish to update the Simulation Command?" ) ) )
{
plotPanel->SetSimCommand( m_circuitModel->GetSchTextSimCommand() );
plotPanel->SetLastSchTextSimCommand( plotPanel->GetSimCommand() );
simTab->SetSimCommand( m_circuitModel->GetSchTextSimCommand() );
simTab->SetLastSchTextSimCommand( simTab->GetSimCommand() );
OnModify();
}
}
}
if( !LoadSimulator( plotPanel->GetSimCommand(), plotPanel->GetSimOptions() ) )
if( !LoadSimulator( simTab->GetSimCommand(), simTab->GetSimOptions() ) )
return;
std::unique_lock<std::mutex> simulatorLock( m_simulator->GetMutex(), std::try_to_lock );
@ -436,7 +436,7 @@ void SIMULATOR_FRAME::StartSimulation()
void SIMULATOR_FRAME::NewPlotPanel( const wxString& aSimCommand, unsigned aOptions )
{
m_panel->NewPlotPanel( aSimCommand, aOptions );
m_panel->NewSimTab( aSimCommand, aOptions );
}
@ -482,9 +482,9 @@ void SIMULATOR_FRAME::AddTuner( const SCH_SHEET_PATH& aSheetPath, SCH_SYMBOL* aS
}
SIM_PLOT_PANEL_BASE* SIMULATOR_FRAME::GetCurrentPlotPanel() const
SIM_TAB* SIMULATOR_FRAME::GetCurrentSimTab() const
{
return m_panel->GetCurrentPlotPanel();
return m_panel->GetCurrentSimTab();
}
@ -530,12 +530,12 @@ void SIMULATOR_FRAME::ToggleDarkModePlots()
bool SIMULATOR_FRAME::EditSimCommand()
{
SIM_PLOT_PANEL_BASE* plotPanel = m_panel->GetCurrentPlotPanel();
SIM_TAB* simTab = m_panel->GetCurrentSimTab();
DIALOG_SIM_COMMAND dlg( this, m_circuitModel, m_simulator->Settings() );
wxString errors;
WX_STRING_REPORTER reporter( &errors );
if( !plotPanel )
if( !simTab )
return false;
if( !m_circuitModel->ReadSchematicAndLibraries( NETLIST_EXPORTER_SPICE::OPTION_DEFAULT_FLAGS,
@ -545,13 +545,13 @@ bool SIMULATOR_FRAME::EditSimCommand()
+ errors );
}
dlg.SetSimCommand( plotPanel->GetSimCommand() );
dlg.SetSimOptions( plotPanel->GetSimOptions() );
dlg.SetSimCommand( simTab->GetSimCommand() );
dlg.SetSimOptions( simTab->GetSimOptions() );
if( dlg.ShowModal() == wxID_OK )
{
plotPanel->SetSimCommand( dlg.GetSimCommand() );
plotPanel->SetSimOptions( dlg.GetSimOptions() );
simTab->SetSimCommand( dlg.GetSimCommand() );
simTab->SetSimOptions( dlg.GetSimOptions() );
m_panel->OnPlotSettingsChanged();
OnModify();
return true;
@ -615,22 +615,22 @@ void SIMULATOR_FRAME::setupUIConditions()
auto showGridCondition =
[this]( const SELECTION& aSel )
{
SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() );
return plotPanel && plotPanel->IsGridShown();
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() );
return plotTab && plotTab->IsGridShown();
};
auto showLegendCondition =
[this]( const SELECTION& aSel )
{
SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() );
return plotPanel && plotPanel->IsLegendShown();
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() );
return plotTab && plotTab->IsLegendShown();
};
auto showDottedCondition =
[this]( const SELECTION& aSel )
{
SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() );
return plotPanel && plotPanel->GetDottedSecondary();
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() );
return plotTab && plotTab->GetDottedSecondary();
};
auto darkModePlotCondition =
@ -654,13 +654,13 @@ void SIMULATOR_FRAME::setupUIConditions()
auto haveSim =
[this]( const SELECTION& aSel )
{
return GetCurrentPlotPanel() != nullptr;
return GetCurrentSimTab() != nullptr;
};
auto havePlot =
[this]( const SELECTION& aSel )
{
return dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() ) != nullptr;
return dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() ) != nullptr;
};
#define ENABLE( x ) ACTION_CONDITIONS().Enable( x )

View File

@ -52,7 +52,7 @@ class ACTION_TOOLBAR;
*
* The SIMULATOR_FRAME holds the main user-interface for running simulations.
*
* It contains a workbook with multiple tabs, each tab holding a SIM_PLOT_PANEL, a specific
* It contains a workbook with multiple tabs, each tab holding a SIM_PLOT_TAB, a specific
* simulation command (.TRAN, .AC, etc.), and simulation settings (save all currents, etc.).
*
* Each plot can have multiple TRACEs. While internally each TRACE can have multiple cursors,
@ -132,7 +132,7 @@ public:
/**
* Return the current tab (or NULL if there is none).
*/
SIM_PLOT_PANEL_BASE* GetCurrentPlotPanel() const;
SIM_TAB* GetCurrentSimTab() const;
/**
* Toggle dark-mode of the plot tabs.

View File

@ -39,7 +39,7 @@
#include <pgm_base.h>
#include <sim/simulator_panel.h>
#include <sim/simulator_frame.h>
#include <sim/sim_plot_panel.h>
#include <sim/sim_plot_tab.h>
#include <sim/spice_simulator.h>
#include "fmt/format.h"
#include <dialogs/dialog_text_entry.h>
@ -134,7 +134,7 @@ void SIGNALS_GRID_TRICKS::showPopupMenu( wxMenu& menu, wxGridEvent& aEvent )
m_grid->SetGridCursor( m_menuRow, m_menuCol );
if( SIM_PLOT_PANEL_BASE* panel = m_parent->GetCurrentPlotPanel() )
if( SIM_TAB* panel = m_parent->GetCurrentSimTab() )
{
if( panel->GetSimType() == ST_TRAN || panel->GetSimType() == ST_AC
|| panel->GetSimType() == ST_DC || panel->GetSimType() == ST_SP )
@ -526,13 +526,13 @@ void SIMULATOR_PANEL::ShowChangedLanguage()
{
for( int ii = 0; ii < (int) m_plotNotebook->GetPageCount(); ++ii )
{
auto plot = dynamic_cast<SIM_PLOT_PANEL_BASE*>( m_plotNotebook->GetPage( ii ) );
SIM_TAB* simTab = dynamic_cast<SIM_TAB*>( m_plotNotebook->GetPage( ii ) );
wxCHECK( plot, /* void */ );
wxCHECK( simTab, /* void */ );
plot->OnLanguageChanged();
simTab->OnLanguageChanged();
wxString pageTitle( simulator()->TypeToName( plot->GetSimType(), true ) );
wxString pageTitle( simulator()->TypeToName( simTab->GetSimType(), true ) );
pageTitle.Prepend( wxString::Format( _( "Plot%u - " ), ii+1 /* 1-based */ ) );
m_plotNotebook->SetPageText( ii, pageTitle );
@ -595,7 +595,7 @@ void SIMULATOR_PANEL::InitWorkbook()
wxString schTextSimCommand = circuitModel()->GetSchTextSimCommand();
if( !schTextSimCommand.IsEmpty() )
NewPlotPanel( schTextSimCommand, NETLIST_EXPORTER_SPICE::OPTION_DEFAULT_FLAGS );
NewSimTab( schTextSimCommand, NETLIST_EXPORTER_SPICE::OPTION_DEFAULT_FLAGS );
rebuildSignalsList();
rebuildSignalsGrid( m_filter->GetValue() );
@ -628,7 +628,7 @@ void SIMULATOR_PANEL::rebuildSignalsGrid( wxString aFilter )
m_signalsGrid->ClearRows();
SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() );
SIM_PLOT_TAB* plotPanel = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() );
if( !plotPanel )
return;
@ -870,32 +870,31 @@ void SIMULATOR_PANEL::rebuildSignalsList()
}
SIM_PLOT_PANEL_BASE* SIMULATOR_PANEL::NewPlotPanel( const wxString& aSimCommand,
unsigned aSimOptions )
SIM_TAB* SIMULATOR_PANEL::NewSimTab( const wxString& aSimCommand, unsigned aSimOptions )
{
SIM_PLOT_PANEL_BASE* plotPanel = nullptr;
SIM_TAB* simTab = nullptr;
SIM_TYPE simType = NGSPICE_CIRCUIT_MODEL::CommandToSimType( aSimCommand );
if( SIM_PLOT_PANEL_BASE::IsPlottable( simType ) )
if( SIM_TAB::IsPlottable( simType ) )
{
SIM_PLOT_PANEL* panel = new SIM_PLOT_PANEL( aSimCommand, aSimOptions, m_plotNotebook );
plotPanel = panel;
SIM_PLOT_TAB* panel = new SIM_PLOT_TAB( aSimCommand, aSimOptions, m_plotNotebook );
simTab = panel;
COMMON_SETTINGS::INPUT cfg = Pgm().GetCommonSettings()->m_Input;
panel->GetPlotWin()->EnableMouseWheelPan( cfg.scroll_modifier_zoom != 0 );
}
else
{
plotPanel = new SIM_NOPLOT_PANEL( aSimCommand, aSimOptions, m_plotNotebook );
simTab = new SIM_NOPLOT_TAB( aSimCommand, aSimOptions, m_plotNotebook );
}
wxString pageTitle( simulator()->TypeToName( simType, true ) );
pageTitle.Prepend( wxString::Format( _( "Plot%u - " ), (unsigned int) ++m_plotNumber ) );
m_plotNotebook->AddPage( dynamic_cast<wxWindow*>( plotPanel ), pageTitle, true );
m_plotNotebook->AddPage( simTab, pageTitle, true );
m_simulatorFrame->OnModify();
return plotPanel;
return simTab;
}
@ -930,7 +929,7 @@ wxString vectorNameFromSignalId( int aUserDefinedSignalId )
* For user-defined signals we display the user-oriented signal name such as "V(out)-V(in)",
* but the simulator vector we actually have to plot will be "user0" or some-such.
*/
wxString SIMULATOR_PANEL::vectorNameFromSignalName( SIM_PLOT_PANEL* aPlotPanel,
wxString SIMULATOR_PANEL::vectorNameFromSignalName( SIM_PLOT_TAB* aPlotTab,
const wxString& aSignalName, int* aTraceType )
{
std::map<wxString, int> suffixes;
@ -940,7 +939,7 @@ wxString SIMULATOR_PANEL::vectorNameFromSignalName( SIM_PLOT_PANEL* aPlotPanel,
if( aTraceType )
{
if( aPlotPanel && aPlotPanel->GetSimType() == ST_NOISE )
if( aPlotTab && aPlotTab->GetSimType() == ST_NOISE )
{
if( getNoiseSource().Upper().StartsWith( 'I' ) )
*aTraceType = SPT_CURRENT;
@ -994,17 +993,17 @@ void SIMULATOR_PANEL::onSignalsGridCellChanged( wxGridEvent& aEvent )
int row = aEvent.GetRow();
int col = aEvent.GetCol();
wxString text = m_signalsGrid->GetCellValue( row, col );
SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() );
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() );
wxString signalName = m_signalsGrid->GetCellValue( row, COL_SIGNAL_NAME );
int traceType = SPT_UNKNOWN;
wxString vectorName = vectorNameFromSignalName( plotPanel, signalName, &traceType );
wxString vectorName = vectorNameFromSignalName( plotTab, signalName, &traceType );
if( col == COL_SIGNAL_SHOW )
{
if( text == wxS( "1" ) )
updateTrace( vectorName, traceType, plotPanel );
updateTrace( vectorName, traceType, plotTab );
else
plotPanel->DeleteTrace( vectorName, traceType );
plotTab->DeleteTrace( vectorName, traceType );
// Update enabled/visible states of other controls
updateSignalsGrid();
@ -1014,13 +1013,13 @@ void SIMULATOR_PANEL::onSignalsGridCellChanged( wxGridEvent& aEvent )
else if( col == COL_SIGNAL_COLOR )
{
KIGFX::COLOR4D color( m_signalsGrid->GetCellValue( row, COL_SIGNAL_COLOR ) );
TRACE* trace = plotPanel->GetTrace( vectorName, traceType );
TRACE* trace = plotTab->GetTrace( vectorName, traceType );
if( trace )
{
trace->SetTraceColour( color.ToColour() );
plotPanel->UpdateTraceStyle( trace );
plotPanel->UpdatePlotColors();
plotTab->UpdateTraceStyle( trace );
plotTab->UpdatePlotColors();
m_simulatorFrame->OnModify();
}
}
@ -1029,12 +1028,12 @@ void SIMULATOR_PANEL::onSignalsGridCellChanged( wxGridEvent& aEvent )
for( int ii = 0; ii < m_signalsGrid->GetNumberRows(); ++ii )
{
signalName = m_signalsGrid->GetCellValue( ii, COL_SIGNAL_NAME );
vectorName = vectorNameFromSignalName( plotPanel, signalName, &traceType );
vectorName = vectorNameFromSignalName( plotTab, signalName, &traceType );
int id = col == COL_CURSOR_1 ? 1 : 2;
bool enable = ii == row && text == wxS( "1" );
plotPanel->EnableCursor( vectorName, traceType, id, enable, signalName );
plotTab->EnableCursor( vectorName, traceType, id, enable, signalName );
m_simulatorFrame->OnModify();
}
@ -1049,9 +1048,9 @@ void SIMULATOR_PANEL::onCursorsGridCellChanged( wxGridEvent& aEvent )
if( m_SuppressGridEvents > 0 )
return;
SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() );
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() );
if( !plotPanel )
if( !plotTab )
return;
int row = aEvent.GetRow();
@ -1064,7 +1063,7 @@ void SIMULATOR_PANEL::onCursorsGridCellChanged( wxGridEvent& aEvent )
CURSOR* cursor1 = nullptr;
CURSOR* cursor2 = nullptr;
for( const auto& [name, trace] : plotPanel->GetTraces() )
for( const auto& [name, trace] : plotTab->GetTraces() )
{
if( CURSOR* cursor = trace->GetCursor( 1 ) )
cursor1 = cursor;
@ -1119,9 +1118,9 @@ void SIMULATOR_PANEL::DeleteMeasurement( int aRow )
void SIMULATOR_PANEL::onMeasurementsGridCellChanged( wxGridEvent& aEvent )
{
SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() );
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() );
if( !plotPanel )
if( !plotTab )
return;
int row = aEvent.GetRow();
@ -1185,9 +1184,9 @@ void SIMULATOR_PANEL::UpdateMeasurement( int aRow )
" +"
"([a-zA-Z])\\(([^\\)]+)\\)" ) );
SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() );
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() );
if( !plotPanel )
if( !plotTab )
return;
wxString text = m_measurementsGrid->GetCellValue( aRow, COL_MEASUREMENT );
@ -1198,7 +1197,7 @@ void SIMULATOR_PANEL::UpdateMeasurement( int aRow )
return;
}
wxString simType = simulator()->TypeToName( plotPanel->GetSimType(), true );
wxString simType = simulator()->TypeToName( plotTab->GetSimType(), true );
wxString resultName = wxString::Format( wxS( "meas_result_%u" ), aRow );
wxString result = wxS( "?" );
@ -1225,7 +1224,7 @@ void SIMULATOR_PANEL::UpdateMeasurement( int aRow )
units = wxS( "s" );
else if( func.StartsWith( wxS( "INTEG" ) ) )
{
switch( plotPanel->GetSimType() )
switch( plotTab->GetSimType() )
{
case SIM_TYPE::ST_TRAN:
if ( signalType == 'P' )
@ -1274,9 +1273,9 @@ void SIMULATOR_PANEL::UpdateMeasurement( int aRow )
void SIMULATOR_PANEL::AddTuner( const SCH_SHEET_PATH& aSheetPath, SCH_SYMBOL* aSymbol )
{
SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() );
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() );
if( !plotPanel )
if( !plotTab )
return;
wxString ref = aSymbol->GetRef( &aSheetPath );
@ -1360,12 +1359,12 @@ void SIMULATOR_PANEL::AddMeasurement( const wxString& aCmd )
return; // Don't create duplicates
}
SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() );
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() );
if( !plotPanel )
if( !plotTab )
return;
wxString simType = simulator()->TypeToName( plotPanel->GetSimType(), true );
wxString simType = simulator()->TypeToName( plotTab->GetSimType(), true );
int row;
for( row = 0; row < m_measurementsGrid->GetNumberRows(); ++row )
@ -1412,14 +1411,14 @@ const NGSPICE_CIRCUIT_MODEL* SIMULATOR_PANEL::GetExporter() const
void SIMULATOR_PANEL::AddTrace( const wxString& aName, SIM_TRACE_TYPE aType )
{
if( !GetCurrentPlotPanel() )
if( !GetCurrentSimTab() )
{
m_simConsole->AppendText( _( "Error: no current simulation.\n" ) );
m_simConsole->SetInsertionPointEnd();
return;
}
SIM_TYPE simType = NGSPICE_CIRCUIT_MODEL::CommandToSimType( GetCurrentPlotPanel()->GetSimCommand() );
SIM_TYPE simType = NGSPICE_CIRCUIT_MODEL::CommandToSimType( GetCurrentSimTab()->GetSimCommand() );
if( simType == ST_UNKNOWN )
{
@ -1427,29 +1426,29 @@ void SIMULATOR_PANEL::AddTrace( const wxString& aName, SIM_TRACE_TYPE aType )
m_simConsole->SetInsertionPointEnd();
return;
}
else if( !SIM_PLOT_PANEL_BASE::IsPlottable( simType ) )
else if( !SIM_TAB::IsPlottable( simType ) )
{
m_simConsole->AppendText( _( "Error: simulation type doesn't support plotting.\n" ) );
m_simConsole->SetInsertionPointEnd();
return;
}
SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() );
wxCHECK( plotPanel, /* void */ );
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() );
wxCHECK( plotTab, /* void */ );
if( simType == ST_AC )
{
updateTrace( aName, aType | SPT_AC_GAIN, plotPanel );
updateTrace( aName, aType | SPT_AC_PHASE, plotPanel );
updateTrace( aName, aType | SPT_AC_GAIN, plotTab );
updateTrace( aName, aType | SPT_AC_PHASE, plotTab );
}
else if( simType == ST_SP )
{
updateTrace( aName, aType | SPT_AC_GAIN, plotPanel );
updateTrace( aName, aType | SPT_AC_PHASE, plotPanel );
updateTrace( aName, aType | SPT_AC_GAIN, plotTab );
updateTrace( aName, aType | SPT_AC_PHASE, plotTab );
}
else
{
updateTrace( aName, aType, plotPanel );
updateTrace( aName, aType, plotTab );
}
updateSignalsGrid();
@ -1461,54 +1460,54 @@ void SIMULATOR_PANEL::SetUserDefinedSignals( const std::map<int, wxString>& aNew
{
for( size_t ii = 0; ii < m_plotNotebook->GetPageCount(); ++ii )
{
SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( m_plotNotebook->GetPage( ii ) );
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( m_plotNotebook->GetPage( ii ) );
if( !plotPanel )
if( !plotTab )
continue;
for( const auto& [ id, existingSignal ] : m_userDefinedSignals )
{
int traceType = SPT_UNKNOWN;
wxString vectorName = vectorNameFromSignalName( plotPanel, existingSignal, &traceType );
wxString vectorName = vectorNameFromSignalName( plotTab, existingSignal, &traceType );
if( aNewSignals.count( id ) == 0 )
{
if( plotPanel->GetSimType() == ST_AC )
if( plotTab->GetSimType() == ST_AC )
{
for( int subType : { SPT_AC_GAIN, SPT_AC_PHASE } )
plotPanel->DeleteTrace( vectorName, traceType | subType );
plotTab->DeleteTrace( vectorName, traceType | subType );
}
else if( plotPanel->GetSimType() == ST_SP )
else if( plotTab->GetSimType() == ST_SP )
{
for( int subType : { SPT_SP_AMP, SPT_AC_PHASE } )
plotPanel->DeleteTrace( vectorName, traceType | subType );
plotTab->DeleteTrace( vectorName, traceType | subType );
}
else
{
plotPanel->DeleteTrace( vectorName, traceType );
plotTab->DeleteTrace( vectorName, traceType );
}
}
else
{
if( plotPanel->GetSimType() == ST_AC )
if( plotTab->GetSimType() == ST_AC )
{
for( int subType : { SPT_AC_GAIN, SPT_AC_PHASE } )
{
if( TRACE* trace = plotPanel->GetTrace( vectorName, traceType | subType ) )
if( TRACE* trace = plotTab->GetTrace( vectorName, traceType | subType ) )
trace->SetName( aNewSignals.at( id ) );
}
}
else if( plotPanel->GetSimType() == ST_SP )
else if( plotTab->GetSimType() == ST_SP )
{
for( int subType : { SPT_SP_AMP, SPT_AC_PHASE } )
{
if( TRACE* trace = plotPanel->GetTrace( vectorName, traceType | subType ) )
if( TRACE* trace = plotTab->GetTrace( vectorName, traceType | subType ) )
trace->SetName( aNewSignals.at( id ) );
}
}
else
{
if( TRACE* trace = plotPanel->GetTrace( vectorName, traceType ) )
if( TRACE* trace = plotTab->GetTrace( vectorName, traceType ) )
trace->SetName( aNewSignals.at( id ) );
}
}
@ -1529,9 +1528,9 @@ void SIMULATOR_PANEL::SetUserDefinedSignals( const std::map<int, wxString>& aNew
void SIMULATOR_PANEL::updateTrace( const wxString& aVectorName, int aTraceType,
SIM_PLOT_PANEL* aPlotPanel )
SIM_PLOT_TAB* aPlotTab )
{
SIM_TYPE simType = NGSPICE_CIRCUIT_MODEL::CommandToSimType( aPlotPanel->GetSimCommand() );
SIM_TYPE simType = NGSPICE_CIRCUIT_MODEL::CommandToSimType( aPlotTab->GetSimCommand() );
aTraceType &= aTraceType & SPT_Y_AXIS_MASK;
aTraceType |= getXAxisType( simType );
@ -1541,7 +1540,7 @@ void SIMULATOR_PANEL::updateTrace( const wxString& aVectorName, int aTraceType,
if( aTraceType & SPT_POWER )
simVectorName = simVectorName.AfterFirst( '(' ).BeforeLast( ')' ) + wxS( ":power" );
if( !SIM_PLOT_PANEL_BASE::IsPlottable( simType ) )
if( !SIM_TAB::IsPlottable( simType ) )
{
// There is no plot to be shown
simulator()->Command( wxString::Format( wxT( "print %s" ), aVectorName ).ToStdString() );
@ -1599,7 +1598,7 @@ void SIMULATOR_PANEL::updateTrace( const wxString& aVectorName, int aTraceType,
SPICE_DC_PARAMS source1, source2;
if( simType == ST_DC
&& circuitModel()->ParseDCCommand( aPlotPanel->GetSimCommand(), &source1, &source2 )
&& circuitModel()->ParseDCCommand( aPlotTab->GetSimCommand(), &source1, &source2 )
&& !source2.m_source.IsEmpty() )
{
// Source 1 is the inner loop, so lets add traces for each Source 2 (outer loop) step
@ -1613,7 +1612,7 @@ void SIMULATOR_PANEL::updateTrace( const wxString& aVectorName, int aTraceType,
for( size_t idx = 0; idx <= outer; idx++ )
{
if( TRACE* trace = aPlotPanel->AddTrace( aVectorName, aTraceType ) )
if( TRACE* trace = aPlotTab->AddTrace( aVectorName, aTraceType ) )
{
if( data_y.size() >= size )
{
@ -1622,7 +1621,7 @@ void SIMULATOR_PANEL::updateTrace( const wxString& aVectorName, int aTraceType,
std::vector<double> sub_y( data_y.begin() + offset,
data_y.begin() + offset + inner );
aPlotPanel->SetTraceData( trace, inner, sub_x.data(), sub_y.data() );
aPlotTab->SetTraceData( trace, inner, sub_x.data(), sub_y.data() );
}
}
@ -1630,25 +1629,25 @@ void SIMULATOR_PANEL::updateTrace( const wxString& aVectorName, int aTraceType,
offset += inner;
}
}
else if( TRACE* trace = aPlotPanel->AddTrace( aVectorName, aTraceType ) )
else if( TRACE* trace = aPlotTab->AddTrace( aVectorName, aTraceType ) )
{
if( data_y.size() >= size )
aPlotPanel->SetTraceData( trace, size, data_x.data(), data_y.data() );
aPlotTab->SetTraceData( trace, size, data_x.data(), data_y.data() );
}
}
void SIMULATOR_PANEL::updateSignalsGrid()
{
SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() );
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() );
for( int row = 0; row < m_signalsGrid->GetNumberRows(); ++row )
{
wxString signalName = m_signalsGrid->GetCellValue( row, COL_SIGNAL_NAME );
int traceType = SPT_UNKNOWN;
wxString vectorName = vectorNameFromSignalName( plotPanel, signalName, &traceType );
wxString vectorName = vectorNameFromSignalName( plotTab, signalName, &traceType );
if( TRACE* trace = plotPanel ? plotPanel->GetTrace( vectorName, traceType ) : nullptr )
if( TRACE* trace = plotTab ? plotTab->GetTrace( vectorName, traceType ) : nullptr )
{
m_signalsGrid->SetCellValue( row, COL_SIGNAL_SHOW, wxS( "1" ) );
@ -1764,20 +1763,20 @@ void SIMULATOR_PANEL::applyTuners()
}
void SIMULATOR_PANEL::parseTraceParams( SIM_PLOT_PANEL* aPlotPanel, TRACE* aTrace,
void SIMULATOR_PANEL::parseTraceParams( SIM_PLOT_TAB* aPlotTab, TRACE* aTrace,
const wxString& aSignalName, const wxString& aParams )
{
auto addCursor =
[&]( int aCursorId, double x )
{
CURSOR* cursor = new CURSOR( aTrace, aPlotPanel );
CURSOR* cursor = new CURSOR( aTrace, aPlotTab );
cursor->SetName( aSignalName );
cursor->SetPen( wxPen( aTrace->GetTraceColour() ) );
cursor->SetCoordX( x );
aTrace->SetCursor( aCursorId, cursor );
aPlotPanel->GetPlotWin()->AddLayer( cursor );
aPlotTab->GetPlotWin()->AddLayer( cursor );
};
wxArrayString items = wxSplit( aParams, '|' );
@ -1789,7 +1788,7 @@ void SIMULATOR_PANEL::parseTraceParams( SIM_PLOT_PANEL* aPlotPanel, TRACE* aTrac
wxColour color;
color.Set( item );
aTrace->SetTraceColour( color );
aPlotPanel->UpdateTraceStyle( aTrace );
aPlotTab->UpdateTraceStyle( aTrace );
}
else if( item.StartsWith( wxS( "cursor1" ) ) )
{
@ -1829,11 +1828,11 @@ void SIMULATOR_PANEL::parseTraceParams( SIM_PLOT_PANEL* aPlotPanel, TRACE* aTrac
}
else if( item == wxS( "dottedSecondary" ) )
{
aPlotPanel->SetDottedSecondary( true );
aPlotTab->SetDottedSecondary( true );
}
else if( item == wxS( "hideGrid" ) )
{
aPlotPanel->ShowGrid( false );
aPlotTab->ShowGrid( false );
}
}
}
@ -1853,7 +1852,7 @@ bool SIMULATOR_PANEL::LoadWorkbook( const wxString& aPath )
long version = 1;
wxString firstLine = file.GetFirstLine();
wxString plotCountLine;
wxString pageCountLine;
if( firstLine.StartsWith( wxT( "version " ) ) )
{
@ -1865,16 +1864,16 @@ bool SIMULATOR_PANEL::LoadWorkbook( const wxString& aPath )
return false;
}
plotCountLine = file.GetNextLine();
pageCountLine = file.GetNextLine();
}
else
{
plotCountLine = firstLine;
pageCountLine = firstLine;
}
long plotsCount;
long pageCount;
if( !plotCountLine.ToLong( &plotsCount ) )
if( !pageCountLine.ToLong( &pageCount ) )
{
DISPLAY_LOAD_ERROR( "Error loading workbook: Line %d is not an integer." );
file.Close();
@ -1882,13 +1881,13 @@ bool SIMULATOR_PANEL::LoadWorkbook( const wxString& aPath )
return false;
}
std::map<SIM_PLOT_PANEL*, std::vector<std::tuple<long, wxString, wxString>>> traceInfo;
std::map<SIM_PLOT_TAB*, std::vector<std::tuple<long, wxString, wxString>>> traceInfo;
for( long i = 0; i < plotsCount; ++i )
for( long i = 0; i < pageCount; ++i )
{
long plotType, tracesCount;
long simType, tracesCount;
if( !file.GetNextLine().ToLong( &plotType ) )
if( !file.GetNextLine().ToLong( &simType ) )
{
DISPLAY_LOAD_ERROR( "Error loading workbook: Line %d is not an integer." );
file.Close();
@ -1929,8 +1928,8 @@ bool SIMULATOR_PANEL::LoadWorkbook( const wxString& aPath )
simCommand += line + wxT( "\n" );
}
SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( NewPlotPanel( simCommand,
simOptions ) );
SIM_TAB* simTab = NewSimTab( simCommand, simOptions );
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( simTab );
if( !file.GetNextLine().ToLong( &tracesCount ) )
{
@ -1940,8 +1939,8 @@ bool SIMULATOR_PANEL::LoadWorkbook( const wxString& aPath )
return false;
}
if( plotPanel )
traceInfo[ plotPanel ] = {};
if( plotTab )
traceInfo[plotTab] = {};
for( long j = 0; j < tracesCount; ++j )
{
@ -1968,8 +1967,8 @@ bool SIMULATOR_PANEL::LoadWorkbook( const wxString& aPath )
param = file.GetNextLine();
if( plotPanel )
traceInfo[ plotPanel ].emplace_back( std::make_tuple( traceType, name, param ) );
if( plotTab )
traceInfo[plotTab].emplace_back( std::make_tuple( traceType, name, param ) );
}
if( version > 4 )
@ -1983,8 +1982,8 @@ bool SIMULATOR_PANEL::LoadWorkbook( const wxString& aPath )
wxString measurement = file.GetNextLine();
wxString format = file.GetNextLine();
if( plotPanel )
plotPanel->Measurements().emplace_back( measurement, format );
if( plotTab )
plotTab->Measurements().emplace_back( measurement, format );
}
}
}
@ -1997,7 +1996,7 @@ bool SIMULATOR_PANEL::LoadWorkbook( const wxString& aPath )
m_userDefinedSignals[ ii ] = file.GetNextLine();
}
for( const auto& [ plotPanel, traceInfoVector ] : traceInfo )
for( const auto& [plotTab, traceInfoVector ] : traceInfo )
{
for( const auto& [ traceType, signalName, param ] : traceInfoVector )
{
@ -2012,32 +2011,32 @@ bool SIMULATOR_PANEL::LoadWorkbook( const wxString& aPath )
coords[0].ToLong( &x );
coords[1].ToLong( &y );
plotPanel->SetLegendPosition( wxPoint( (int) x, (int) y ) );
plotTab->SetLegendPosition( wxPoint( (int) x, (int) y ) );
}
plotPanel->ShowLegend( true );
plotTab->ShowLegend( true );
}
else
{
wxString vectorName = vectorNameFromSignalName( plotPanel, signalName, nullptr );
TRACE* trace = plotPanel->AddTrace( vectorName, (int) traceType );
wxString vectorName = vectorNameFromSignalName( plotTab, signalName, nullptr );
TRACE* trace = plotTab->AddTrace( vectorName, (int) traceType );
if( version >= 4 && trace )
parseTraceParams( plotPanel, trace, signalName, param );
parseTraceParams( plotTab, trace, signalName, param );
}
}
plotPanel->UpdatePlotColors();
plotTab->UpdatePlotColors();
}
if( SIM_PLOT_PANEL_BASE* plotPanel = GetCurrentPlotPanel() )
if( SIM_TAB* simTab = GetCurrentSimTab() )
{
m_simulatorFrame->LoadSimulator( plotPanel->GetSimCommand(), plotPanel->GetSimOptions() );
m_simulatorFrame->LoadSimulator( simTab->GetSimCommand(), simTab->GetSimOptions() );
if( version >= 5 )
{
plotPanel = dynamic_cast<SIM_PLOT_PANEL_BASE*>( m_plotNotebook->GetPage( 0 ) );
plotPanel->SetLastSchTextSimCommand( file.GetNextLine() );
simTab = dynamic_cast<SIM_TAB*>( m_plotNotebook->GetPage( 0 ) );
simTab->SetLastSchTextSimCommand( file.GetNextLine() );
}
}
@ -2085,18 +2084,18 @@ bool SIMULATOR_PANEL::SaveWorkbook( const wxString& aPath )
for( size_t i = 0; i < m_plotNotebook->GetPageCount(); i++ )
{
auto* basePanel = dynamic_cast<SIM_PLOT_PANEL_BASE*>( m_plotNotebook->GetPage( i ) );
SIM_TAB* simTab = dynamic_cast<SIM_TAB*>( m_plotNotebook->GetPage( i ) );
if( !basePanel )
if( !simTab )
{
file.AddLine( wxString::Format( wxT( "%llu" ), 0ull ) );
continue;
}
file.AddLine( wxString::Format( wxT( "%d" ), basePanel->GetSimType() ) );
file.AddLine( wxString::Format( wxT( "%d" ), simTab->GetSimType() ) );
wxString command = basePanel->GetSimCommand();
int options = basePanel->GetSimOptions();
wxString command = simTab->GetSimCommand();
int options = simTab->GetSimOptions();
if( options & NETLIST_EXPORTER_SPICE::OPTION_ADJUST_INCLUDE_PATHS )
command += wxT( "\n.kicad adjustpaths" );
@ -2112,17 +2111,17 @@ bool SIMULATOR_PANEL::SaveWorkbook( const wxString& aPath )
file.AddLine( EscapeString( command, CTX_LINE ) );
SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( basePanel );
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( simTab );
if( !plotPanel )
if( !plotTab )
{
file.AddLine( wxString::Format( wxT( "%llu" ), 0ull ) );
continue;
}
size_t traceCount = plotPanel->GetTraces().size();
size_t traceCount = plotTab->GetTraces().size();
if( plotPanel->IsLegendShown() )
if( plotTab->IsLegendShown() )
traceCount++;
file.AddLine( wxString::Format( wxT( "%llu" ), traceCount ) );
@ -2139,7 +2138,7 @@ bool SIMULATOR_PANEL::SaveWorkbook( const wxString& aPath )
return aVectorName;
};
for( const auto& [name, trace] : plotPanel->GetTraces() )
for( const auto& [name, trace] : plotTab->GetTraces() )
{
file.AddLine( wxString::Format( wxT( "%d" ), trace->GetType() ) );
file.AddLine( findSignalName( trace->GetName() ) );
@ -2169,27 +2168,26 @@ bool SIMULATOR_PANEL::SaveWorkbook( const wxString& aPath )
m_cursorFormats[2][1].ToString() );
}
if( plotPanel->GetDottedSecondary() )
if( plotTab->GetDottedSecondary() )
msg += wxS( "|dottedSecondary" );
if( !plotPanel->IsGridShown() )
if( !plotTab->IsGridShown() )
msg += wxS( "|hideGrid" );
file.AddLine( msg );
}
if( plotPanel->IsLegendShown() )
if( plotTab->IsLegendShown() )
{
file.AddLine( wxString::Format( wxT( "%d" ), SPT_UNKNOWN ) );
file.AddLine( wxT( "$LEGEND" ) );
file.AddLine( wxString::Format( wxT( "%d %d" ),
plotPanel->GetLegendPosition().x,
plotPanel->GetLegendPosition().y - 40 ) );
file.AddLine( wxString::Format( wxT( "%d %d" ), plotTab->GetLegendPosition().x,
plotTab->GetLegendPosition().y - 40 ) );
}
file.AddLine( wxString::Format( wxT( "%llu" ), plotPanel->Measurements().size() ) );
file.AddLine( wxString::Format( wxT( "%llu" ), plotTab->Measurements().size() ) );
for( const auto& [ measurement, format ] : plotPanel->Measurements() )
for( const auto& [ measurement, format ] : plotTab->Measurements() )
{
file.AddLine( measurement );
file.AddLine( format );
@ -2208,8 +2206,8 @@ bool SIMULATOR_PANEL::SaveWorkbook( const wxString& aPath )
if( m_plotNotebook->GetPageCount() > 0 )
{
auto* basePanel = dynamic_cast<SIM_PLOT_PANEL_BASE*>( m_plotNotebook->GetPage( 0 ) );
lastSchTextSimCommand = basePanel->GetLastSchTextSimCommand();
SIM_TAB* simTab = dynamic_cast<SIM_TAB*>( m_plotNotebook->GetPage( 0 ) );
lastSchTextSimCommand = simTab->GetLastSchTextSimCommand();
}
file.AddLine( lastSchTextSimCommand );
@ -2255,9 +2253,9 @@ wxString SIMULATOR_PANEL::getNoiseSource() const
SPICE_VALUE fStop;
bool saveAll;
if( GetCurrentPlotPanel() )
if( GetCurrentSimTab() )
{
circuitModel()->ParseNoiseCommand( GetCurrentPlotPanel()->GetSimCommand(), &output, &ref,
circuitModel()->ParseNoiseCommand( GetCurrentSimTab()->GetSimCommand(), &output, &ref,
&source, &scale, &pts, &fStart, &fStop, &saveAll );
}
@ -2272,17 +2270,17 @@ void SIMULATOR_PANEL::ToggleDarkModePlots()
// Rebuild the color list to plot traces
SIM_PLOT_COLORS::FillDefaultColorList( m_darkMode );
// Now send changes to all SIM_PLOT_PANEL
// Now send changes to all SIM_PLOT_TAB
for( size_t page = 0; page < m_plotNotebook->GetPageCount(); page++ )
{
wxWindow* curPage = m_plotNotebook->GetPage( page );
// ensure it is truly a plot panel and not the (zero plots) placeholder
// which is only SIM_PLOT_PANEL_BASE
SIM_PLOT_PANEL* panel = dynamic_cast<SIM_PLOT_PANEL*>( curPage );
// ensure it is truly a plot plotTab and not the (zero plots) placeholder
// which is only SIM_TAB
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( curPage );
if( panel )
panel->UpdatePlotColors();
if( plotTab )
plotTab->UpdatePlotColors();
}
}
@ -2300,7 +2298,7 @@ void SIMULATOR_PANEL::onPlotClosed( wxAuiNotebookEvent& event )
rebuildSignalsGrid( m_filter->GetValue() );
updatePlotCursors();
SIM_PLOT_PANEL_BASE* panel = GetCurrentPlotPanel();
SIM_TAB* panel = GetCurrentSimTab();
if( !panel || panel->GetSimType() != ST_OP )
{
@ -2315,9 +2313,9 @@ void SIMULATOR_PANEL::onPlotClosed( wxAuiNotebookEvent& event )
void SIMULATOR_PANEL::onPlotChanging( wxAuiNotebookEvent& event )
{
if( SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() ) )
if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() ) )
{
std::vector<std::pair<wxString, wxString>>& measurements = plotPanel->Measurements();
std::vector<std::pair<wxString, wxString>>& measurements = plotTab->Measurements();
measurements.clear();
@ -2350,8 +2348,8 @@ void SIMULATOR_PANEL::OnPlotSettingsChanged()
void SIMULATOR_PANEL::onPlotChanged( wxAuiNotebookEvent& event )
{
if( SIM_PLOT_PANEL_BASE* plotWindow = GetCurrentPlotPanel() )
simulator()->Command( "setplot " + plotWindow->GetSpicePlotName().ToStdString() );
if( SIM_TAB* simTab = GetCurrentSimTab() )
simulator()->Command( "setplot " + simTab->GetSpicePlotName().ToStdString() );
OnPlotSettingsChanged();
@ -2363,9 +2361,9 @@ void SIMULATOR_PANEL::rebuildMeasurementsGrid()
{
m_measurementsGrid->ClearRows();
if( SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() ) )
if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() ) )
{
for( const auto& [ measurement, format ] : plotPanel->Measurements() )
for( const auto& [ measurement, format ] : plotTab->Measurements() )
{
int row = m_measurementsGrid->GetNumberRows();
m_measurementsGrid->AppendRows();
@ -2373,8 +2371,8 @@ void SIMULATOR_PANEL::rebuildMeasurementsGrid()
m_measurementsGrid->SetCellValue( row, COL_MEASUREMENT_FORMAT, format );
}
if( plotPanel->GetSimType() == ST_TRAN || plotPanel->GetSimType() == ST_AC
|| plotPanel->GetSimType() == ST_DC || plotPanel->GetSimType() == ST_SP )
if( plotTab->GetSimType() == ST_TRAN || plotTab->GetSimType() == ST_AC
|| plotTab->GetSimType() == ST_DC || plotTab->GetSimType() == ST_SP )
{
m_measurementsGrid->AppendRows(); // Empty row at end
}
@ -2412,9 +2410,9 @@ void SIMULATOR_PANEL::updatePlotCursors()
m_cursorsGrid->ClearRows();
SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() );
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() );
if( !plotPanel )
if( !plotTab )
return;
// Update cursor values
@ -2429,22 +2427,22 @@ void SIMULATOR_PANEL::updatePlotCursors()
[&]( TRACE* aTrace ) -> wxString
{
if( ( aTrace->GetType() & SPT_AC_PHASE ) || ( aTrace->GetType() & SPT_CURRENT ) )
return plotPanel->GetUnitsY2();
return plotTab->GetUnitsY2();
else if( aTrace->GetType() & SPT_POWER )
return plotPanel->GetUnitsY3();
return plotTab->GetUnitsY3();
else
return plotPanel->GetUnitsY1();
return plotTab->GetUnitsY1();
};
auto getNameY =
[&]( TRACE* aTrace ) -> wxString
{
if( ( aTrace->GetType() & SPT_AC_PHASE ) || ( aTrace->GetType() & SPT_CURRENT ) )
return plotPanel->GetLabelY2();
return plotTab->GetLabelY2();
else if( aTrace->GetType() & SPT_POWER )
return plotPanel->GetLabelY3();
return plotTab->GetLabelY3();
else
return plotPanel->GetLabelY1();
return plotTab->GetLabelY1();
};
auto formatValue =
@ -2456,7 +2454,7 @@ void SIMULATOR_PANEL::updatePlotCursors()
return SPICE_VALUE( aValue ).ToString( m_cursorFormats[ aCursorId ][ aCol ] );
};
for( const auto& [name, trace] : plotPanel->GetTraces() )
for( const auto& [name, trace] : plotTab->GetTraces() )
{
if( CURSOR* cursor = trace->GetCursor( 1 ) )
{
@ -2467,7 +2465,7 @@ void SIMULATOR_PANEL::updatePlotCursors()
wxRealPoint coords = cursor->GetCoords();
int row = m_cursorsGrid->GetNumberRows();
m_cursorFormats[0][0].UpdateUnits( plotPanel->GetUnitsX() );
m_cursorFormats[0][0].UpdateUnits( plotTab->GetUnitsX() );
m_cursorFormats[0][1].UpdateUnits( cursor1Units );
m_cursorsGrid->AppendRows( 1 );
@ -2479,7 +2477,7 @@ void SIMULATOR_PANEL::updatePlotCursors()
}
}
for( const auto& [name, trace] : plotPanel->GetTraces() )
for( const auto& [name, trace] : plotTab->GetTraces() )
{
if( CURSOR* cursor = trace->GetCursor( 2 ) )
{
@ -2490,7 +2488,7 @@ void SIMULATOR_PANEL::updatePlotCursors()
wxRealPoint coords = cursor->GetCoords();
int row = m_cursorsGrid->GetNumberRows();
m_cursorFormats[1][0].UpdateUnits( plotPanel->GetUnitsX() );
m_cursorFormats[1][0].UpdateUnits( plotTab->GetUnitsX() );
m_cursorFormats[1][1].UpdateUnits( cursor2Units );
m_cursorsGrid->AppendRows( 1 );
@ -2507,7 +2505,7 @@ void SIMULATOR_PANEL::updatePlotCursors()
wxRealPoint coords = cursor2->GetCoords() - cursor1->GetCoords();
wxString signal;
m_cursorFormats[2][0].UpdateUnits( plotPanel->GetUnitsX() );
m_cursorFormats[2][0].UpdateUnits( plotTab->GetUnitsX() );
m_cursorFormats[2][1].UpdateUnits( cursor1Units );
if( cursor1->GetName() == cursor2->GetName() )
@ -2523,7 +2521,7 @@ void SIMULATOR_PANEL::updatePlotCursors()
}
// Set up the labels
m_cursorsGrid->SetColLabelValue( COL_CURSOR_X, plotPanel->GetLabelX() );
m_cursorsGrid->SetColLabelValue( COL_CURSOR_X, plotTab->GetLabelX() );
wxString valColName = _( "Value" );
@ -2550,8 +2548,8 @@ void SIMULATOR_PANEL::onPlotCursorUpdate( wxCommandEvent& aEvent )
void SIMULATOR_PANEL::OnSimUpdate()
{
if( SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() ) )
plotPanel->ResetScales( true );
if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() ) )
plotTab->ResetScales( true );
m_simConsole->Clear();
@ -2596,21 +2594,21 @@ std::vector<wxString> SIMULATOR_PANEL::Signals() const
void SIMULATOR_PANEL::OnSimRefresh( bool aFinal )
{
SIM_PLOT_PANEL_BASE* plotPanelBase = GetCurrentPlotPanel();
SIM_TAB* simTab = GetCurrentSimTab();
if( !plotPanelBase )
if( !simTab )
return;
SIM_TYPE simType = plotPanelBase->GetSimType();
SIM_TYPE simType = simTab->GetSimType();
std::vector<wxString> oldSignals = m_signals;
wxString msg;
plotPanelBase->SetSpicePlotName( simulator()->CurrentPlotName() );
simTab->SetSpicePlotName( simulator()->CurrentPlotName() );
applyUserDefinedSignals();
rebuildSignalsList();
// If there are any signals plotted, update them
if( SIM_PLOT_PANEL_BASE::IsPlottable( simType ) )
if( SIM_TAB::IsPlottable( simType ) )
{
if( simType == ST_NOISE && aFinal )
{
@ -2635,28 +2633,28 @@ void SIMULATOR_PANEL::OnSimRefresh( bool aFinal )
}
simulator()->Command( fmt::format( "setplot noise{}", number - 1 ) );
plotPanelBase->SetSpicePlotName( simulator()->CurrentPlotName() );
simTab->SetSpicePlotName( simulator()->CurrentPlotName() );
}
SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( plotPanelBase );
wxCHECK_RET( plotPanel, wxT( "not a SIM_PLOT_PANEL" ) );
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( simTab );
wxCHECK_RET( plotTab, wxT( "not a SIM_PLOT_TAB" ) );
// Map of TRACE* to { vectorName, traceType }
std::map<TRACE*, std::pair<wxString, int>> traceMap;
for( const auto& [ name, trace ] : plotPanel->GetTraces() )
for( const auto& [ name, trace ] : plotTab->GetTraces() )
traceMap[ trace ] = { wxEmptyString, SPT_UNKNOWN };
for( const wxString& signal : m_signals )
{
int traceType = SPT_UNKNOWN;
wxString vectorName = vectorNameFromSignalName( plotPanel, signal, &traceType );
wxString vectorName = vectorNameFromSignalName( plotTab, signal, &traceType );
if( simType == ST_AC )
{
for( int subType : { SPT_AC_GAIN, SPT_AC_PHASE } )
{
if( TRACE* trace = plotPanel->GetTrace( vectorName, traceType | subType ) )
if( TRACE* trace = plotTab->GetTrace( vectorName, traceType | subType ) )
traceMap[ trace ] = { vectorName, traceType };
}
}
@ -2664,13 +2662,13 @@ void SIMULATOR_PANEL::OnSimRefresh( bool aFinal )
{
for( int subType : { SPT_SP_AMP, SPT_AC_PHASE } )
{
if( TRACE* trace = plotPanel->GetTrace( vectorName, traceType | subType ) )
if( TRACE* trace = plotTab->GetTrace( vectorName, traceType | subType ) )
traceMap[trace] = { vectorName, traceType };
}
}
else
{
if( TRACE* trace = plotPanel->GetTrace( vectorName, traceType ) )
if( TRACE* trace = plotTab->GetTrace( vectorName, traceType ) )
traceMap[ trace ] = { vectorName, traceType };
}
}
@ -2680,24 +2678,24 @@ void SIMULATOR_PANEL::OnSimRefresh( bool aFinal )
for( const auto& [ trace, traceInfo ] : traceMap )
{
if( traceInfo.first.IsEmpty() )
plotPanel->DeleteTrace( trace );
plotTab->DeleteTrace( trace );
}
for( const auto& [ trace, traceInfo ] : traceMap )
{
if( !traceInfo.first.IsEmpty() )
updateTrace( traceInfo.first, traceInfo.second, plotPanel );
updateTrace( traceInfo.first, traceInfo.second, plotTab );
}
rebuildSignalsGrid( m_filter->GetValue() );
updateSignalsGrid();
plotPanel->GetPlotWin()->UpdateAll();
plotTab->GetPlotWin()->UpdateAll();
if( aFinal )
plotPanel->ResetScales( true );
plotTab->ResetScales( true );
plotPanel->GetPlotWin()->Fit();
plotTab->GetPlotWin()->Fit();
updatePlotCursors();

View File

@ -31,7 +31,7 @@
#include <sim/simulator_panel_base.h>
#include <sim/sim_types.h>
#include <sim/sim_plot_panel.h>
#include <sim/sim_plot_tab.h>
#include <wx/event.h>
@ -51,7 +51,7 @@ class TUNER_SLIDER;
*
* The SIMULATOR_PANEL holds the main user-interface for running simulations.
*
* It contains a workbook with multiple tabs, each tab holding a SIM_PLOT_PANEL, a specific
* It contains a workbook with multiple tabs, each tab holding a SIM_PLOT_TAB, a specific
* simulation command (.TRAN, .AC, etc.), and simulation settings (save all currents, etc.).
*
* Each plot can have multiple TRACEs. While internally each TRACE can have multiple cursors,
@ -73,13 +73,13 @@ public:
~SIMULATOR_PANEL();
/**
* Create a new plot tab for a given simulation type.
* Create a new simulation tab for a given simulation type.
*
* @param aSimCommand is requested simulation command.
* @param aSimOptions netlisting options
* @return The new plot panel.
*/
SIM_PLOT_PANEL_BASE* NewPlotPanel( const wxString& aSimCommand, unsigned aSimOptions );
SIM_TAB* NewSimTab( const wxString& aSimCommand, unsigned aSimOptions );
std::vector<wxString> SimPlotVectors() const;
@ -196,16 +196,16 @@ public:
/**
* Return the currently opened plot panel (or NULL if there is none).
*/
SIM_PLOT_PANEL_BASE* GetCurrentPlotPanel() const
SIM_TAB* GetCurrentSimTab() const
{
return dynamic_cast<SIM_PLOT_PANEL_BASE*>( m_plotNotebook->GetCurrentPage() );
return dynamic_cast<SIM_TAB*>( m_plotNotebook->GetCurrentPage() );
}
SIM_PLOT_PANEL_BASE* GetPlotPanel( SIM_TYPE aType ) const
SIM_TAB* GetSimTab( SIM_TYPE aType ) const
{
for( int ii = 0; ii < (int) m_plotNotebook->GetPageCount(); ++ii )
{
auto* candidate = dynamic_cast<SIM_PLOT_PANEL_BASE*>( m_plotNotebook->GetPage( ii ) );
SIM_TAB* candidate = dynamic_cast<SIM_TAB*>( m_plotNotebook->GetPage( ii ) );
if( candidate && candidate->GetSimType() == aType )
return candidate;
@ -214,7 +214,7 @@ public:
return nullptr;
}
int GetPlotIndex( SIM_PLOT_PANEL_BASE* aPlot ) const
int GetSimTabIndex( SIM_TAB* aPlot ) const
{
return m_plotNotebook->GetPageIndex( aPlot );
}
@ -229,18 +229,18 @@ private:
/**
* Get the simulator output vector name for a given signal name and type.
*/
wxString vectorNameFromSignalName( SIM_PLOT_PANEL* aPlotPanel, const wxString& aSignalName,
wxString vectorNameFromSignalName( SIM_PLOT_TAB* aPlotTab, const wxString& aSignalName,
int* aTraceType );
/**
* Update a trace in a particular SIM_PLOT_PANEL. If the panel does not contain the given
* Update a trace in a particular SIM_PLOT_TAB. If the panel does not contain the given
* trace, then add it.
*
* @param aVectorName is the SPICE vector name, such as "I(Net-C1-Pad1)".
* @param aTraceType describes the type of plot.
* @param aPlotPanel is the panel that should receive the update.
* @param aPlotTab is the tab that should receive the update.
*/
void updateTrace( const wxString& aVectorName, int aTraceType, SIM_PLOT_PANEL* aPlotPanel );
void updateTrace( const wxString& aVectorName, int aTraceType, SIM_PLOT_TAB* aPlotTab );
/**
* Rebuild the list of signals available from the netlist.
@ -286,7 +286,7 @@ private:
wxString getNoiseSource() const;
void parseTraceParams( SIM_PLOT_PANEL* aPlotPanel, TRACE* aTrace, const wxString& aSignalName,
void parseTraceParams( SIM_PLOT_TAB* aPlotTab, TRACE* aTrace, const wxString& aSignalName,
const wxString& aParams );
std::shared_ptr<SPICE_SIMULATOR> simulator() const;

View File

@ -154,7 +154,7 @@ int SIMULATOR_CONTROL::SaveWorkbook( const TOOL_EVENT& aEvent )
int SIMULATOR_CONTROL::ExportPlotAsPNG( const TOOL_EVENT& aEvent )
{
if( SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() ) )
if( SIM_PLOT_TAB* plotPanel = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentPlotPanel() ) )
{
wxFileDialog saveDlg( m_simulatorFrame, _( "Save Plot as Image" ), "", "",
PngFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
@ -169,15 +169,15 @@ int SIMULATOR_CONTROL::ExportPlotAsPNG( const TOOL_EVENT& aEvent )
}
SIM_PLOT_PANEL_BASE* SIMULATOR_CONTROL::GetCurrentPlotPanel()
SIM_TAB* SIMULATOR_CONTROL::GetCurrentPlotPanel()
{
return m_simulatorFrame->GetCurrentPlotPanel();
return m_simulatorFrame->GetCurrentSimTab();
}
int SIMULATOR_CONTROL::ExportPlotAsCSV( const TOOL_EVENT& aEvent )
{
if( SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() ) )
if( SIM_PLOT_TAB* plotPanel = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentPlotPanel() ) )
{
const wxChar SEPARATOR = ';';
@ -238,7 +238,7 @@ int SIMULATOR_CONTROL::Close( const TOOL_EVENT& aEvent )
int SIMULATOR_CONTROL::Zoom( const TOOL_EVENT& aEvent )
{
if( SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() ) )
if( SIM_PLOT_TAB* plotPanel = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentPlotPanel() ) )
{
if( aEvent.IsAction( &ACTIONS::zoomInCenter ) ) plotPanel->GetPlotWin()->ZoomIn();
else if( aEvent.IsAction( &ACTIONS::zoomOutCenter ) ) plotPanel->GetPlotWin()->ZoomOut();
@ -251,7 +251,7 @@ int SIMULATOR_CONTROL::Zoom( const TOOL_EVENT& aEvent )
int SIMULATOR_CONTROL::ToggleGrid( const TOOL_EVENT& aEvent )
{
if( SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() ) )
if( SIM_PLOT_TAB* plotPanel = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentPlotPanel() ) )
{
plotPanel->ShowGrid( !plotPanel->IsGridShown() );
m_simulatorFrame->OnModify();
@ -263,7 +263,7 @@ int SIMULATOR_CONTROL::ToggleGrid( const TOOL_EVENT& aEvent )
int SIMULATOR_CONTROL::ToggleLegend( const TOOL_EVENT& aEvent )
{
if( SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() ) )
if( SIM_PLOT_TAB* plotPanel = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentPlotPanel() ) )
{
plotPanel->ShowLegend( !plotPanel->IsLegendShown() );
m_simulatorFrame->OnModify();
@ -275,7 +275,7 @@ int SIMULATOR_CONTROL::ToggleLegend( const TOOL_EVENT& aEvent )
int SIMULATOR_CONTROL::ToggleDottedSecondary( const TOOL_EVENT& aEvent )
{
if( SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( GetCurrentPlotPanel() ) )
if( SIM_PLOT_TAB* plotPanel = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentPlotPanel() ) )
{
plotPanel->SetDottedSecondary( !plotPanel->GetDottedSecondary() );
m_simulatorFrame->OnModify();

View File

@ -30,7 +30,7 @@
class SIMULATOR_FRAME;
class NGSPICE_CIRCUIT_MODEL;
class SPICE_SIMULATOR;
class SIM_PLOT_PANEL_BASE;
class SIM_TAB;
/**
@ -85,7 +85,7 @@ private:
*/
wxString getDefaultPath();
SIM_PLOT_PANEL_BASE* GetCurrentPlotPanel();
SIM_TAB* GetCurrentPlotPanel();
///< Set up handlers for various events.
void setTransitions() override;

View File

@ -26,8 +26,8 @@
#define SIM_NOTEBOOK_H
#include "dialogs/dialog_sim_command.h"
#include "sim/sim_plot_panel_base.h"
#include "sim/sim_plot_panel.h"
#include "sim/sim_tab.h"
#include "sim/sim_plot_tab.h"
class SIM_NOTEBOOK : public wxAuiNotebook