Spice sim: remember last simulation, remove welcome page
Fixes https://gitlab.com/kicad/code/kicad/issues/8019
This commit is contained in:
parent
d1061b9683
commit
5410510bd4
|
@ -292,6 +292,7 @@ if( KICAD_SPICE )
|
||||||
sim/sim_plot_frame_base.cpp
|
sim/sim_plot_frame_base.cpp
|
||||||
sim/sim_plot_panel.cpp
|
sim/sim_plot_panel.cpp
|
||||||
sim/sim_panel_base.cpp
|
sim/sim_panel_base.cpp
|
||||||
|
sim/sim_workbook.cpp
|
||||||
sim/spice_simulator.cpp
|
sim/spice_simulator.cpp
|
||||||
sim/spice_value.cpp
|
sim/spice_value.cpp
|
||||||
dialogs/dialog_signal_list.cpp
|
dialogs/dialog_signal_list.cpp
|
||||||
|
|
|
@ -107,22 +107,6 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
TRACE_DESC::TRACE_DESC( const NETLIST_EXPORTER_PSPICE_SIM& aExporter, const wxString& aName,
|
|
||||||
SIM_PLOT_TYPE aType, const wxString& aParam ) :
|
|
||||||
m_name( aName ),
|
|
||||||
m_type( aType ),
|
|
||||||
m_param( aParam )
|
|
||||||
{
|
|
||||||
// Title generation
|
|
||||||
m_title = wxString::Format( "%s(%s)", aParam, aName );
|
|
||||||
|
|
||||||
if( aType & SPT_AC_MAG )
|
|
||||||
m_title += " (mag)";
|
|
||||||
else if( aType & SPT_AC_PHASE )
|
|
||||||
m_title += " (phase)";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Store the path of saved workbooks during the session
|
// Store the path of saved workbooks during the session
|
||||||
wxString SIM_PLOT_FRAME::m_savedWorkbooksPath;
|
wxString SIM_PLOT_FRAME::m_savedWorkbooksPath;
|
||||||
|
|
||||||
|
@ -130,7 +114,6 @@ wxString SIM_PLOT_FRAME::m_savedWorkbooksPath;
|
||||||
SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||||
SIM_PLOT_FRAME_BASE( aParent ),
|
SIM_PLOT_FRAME_BASE( aParent ),
|
||||||
m_lastSimPlot( nullptr ),
|
m_lastSimPlot( nullptr ),
|
||||||
m_welcomePanel( nullptr ),
|
|
||||||
m_plotNumber( 0 )
|
m_plotNumber( 0 )
|
||||||
{
|
{
|
||||||
SetKiway( this, aKiway );
|
SetKiway( this, aKiway );
|
||||||
|
@ -166,9 +149,7 @@ SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||||
m_simulator->Init();
|
m_simulator->Init();
|
||||||
|
|
||||||
if( m_savedWorkbooksPath.IsEmpty() )
|
if( m_savedWorkbooksPath.IsEmpty() )
|
||||||
{
|
|
||||||
m_savedWorkbooksPath = Prj().GetProjectPath();
|
m_savedWorkbooksPath = Prj().GetProjectPath();
|
||||||
}
|
|
||||||
|
|
||||||
m_reporter = new SIM_THREAD_REPORTER( this );
|
m_reporter = new SIM_THREAD_REPORTER( this );
|
||||||
m_simulator->SetReporter( m_reporter );
|
m_simulator->SetReporter( m_reporter );
|
||||||
|
@ -228,9 +209,6 @@ SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||||
m_plotNotebook->SetArtProvider( new wxAuiSimpleTabArt() );
|
m_plotNotebook->SetArtProvider( new wxAuiSimpleTabArt() );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
m_welcomePanel = new SIM_PANEL_BASE( wxEmptyString, m_plotNotebook, wxID_ANY );
|
|
||||||
m_plotNotebook->AddPage( m_welcomePanel, _( "Welcome!" ), 1, true );
|
|
||||||
|
|
||||||
// Ensure new items are taken in account by sizers:
|
// Ensure new items are taken in account by sizers:
|
||||||
Layout();
|
Layout();
|
||||||
|
|
||||||
|
@ -244,6 +222,8 @@ SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||||
|
|
||||||
// Ensure the window is on top
|
// Ensure the window is on top
|
||||||
Raise();
|
Raise();
|
||||||
|
|
||||||
|
initWorkbook();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -258,6 +238,32 @@ SIM_PLOT_FRAME::~SIM_PLOT_FRAME()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SIM_PLOT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
||||||
|
{
|
||||||
|
EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
|
||||||
|
wxASSERT( cfg );
|
||||||
|
|
||||||
|
if( cfg )
|
||||||
|
{
|
||||||
|
EDA_BASE_FRAME::LoadSettings( cfg );
|
||||||
|
|
||||||
|
// Read subwindows sizes (should be > 0 )
|
||||||
|
m_splitterLeftRightSashPosition = cfg->m_Simulator.plot_panel_width;
|
||||||
|
m_splitterPlotAndConsoleSashPosition = cfg->m_Simulator.plot_panel_height;
|
||||||
|
m_splitterSignalsSashPosition = cfg->m_Simulator.signal_panel_height;
|
||||||
|
m_splitterTuneValuesSashPosition = cfg->m_Simulator.cursors_panel_height;
|
||||||
|
m_plotUseWhiteBg = cfg->m_Simulator.white_background;
|
||||||
|
}
|
||||||
|
|
||||||
|
PROJECT_FILE& project = Prj().GetProjectFile();
|
||||||
|
|
||||||
|
NGSPICE* currentSim = dynamic_cast<NGSPICE*>( m_simulator.get() );
|
||||||
|
|
||||||
|
if( currentSim )
|
||||||
|
m_simulator->Settings() = project.m_SchematicSettings->m_NgspiceSimulatorSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void SIM_PLOT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
void SIM_PLOT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
||||||
{
|
{
|
||||||
EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
|
EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
|
||||||
|
@ -287,32 +293,6 @@ void SIM_PLOT_FRAME::SaveSettings( APP_SETTINGS_BASE* aCfg )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SIM_PLOT_FRAME::LoadSettings( APP_SETTINGS_BASE* aCfg )
|
|
||||||
{
|
|
||||||
EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
|
|
||||||
wxASSERT( cfg );
|
|
||||||
|
|
||||||
if( cfg )
|
|
||||||
{
|
|
||||||
EDA_BASE_FRAME::LoadSettings( cfg );
|
|
||||||
|
|
||||||
// Read subwindows sizes (should be > 0 )
|
|
||||||
m_splitterLeftRightSashPosition = cfg->m_Simulator.plot_panel_width;
|
|
||||||
m_splitterPlotAndConsoleSashPosition = cfg->m_Simulator.plot_panel_height;
|
|
||||||
m_splitterSignalsSashPosition = cfg->m_Simulator.signal_panel_height;
|
|
||||||
m_splitterTuneValuesSashPosition = cfg->m_Simulator.cursors_panel_height;
|
|
||||||
m_plotUseWhiteBg = cfg->m_Simulator.white_background;
|
|
||||||
}
|
|
||||||
|
|
||||||
PROJECT_FILE& project = Prj().GetProjectFile();
|
|
||||||
|
|
||||||
NGSPICE* currentSim = dynamic_cast<NGSPICE*>( m_simulator.get() );
|
|
||||||
|
|
||||||
if( currentSim )
|
|
||||||
m_simulator->Settings() = project.m_SchematicSettings->m_NgspiceSimulatorSettings;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
WINDOW_SETTINGS* SIM_PLOT_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg )
|
WINDOW_SETTINGS* SIM_PLOT_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg )
|
||||||
{
|
{
|
||||||
EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
|
EESCHEMA_SETTINGS* cfg = dynamic_cast<EESCHEMA_SETTINGS*>( aCfg );
|
||||||
|
@ -322,6 +302,25 @@ WINDOW_SETTINGS* SIM_PLOT_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SIM_PLOT_FRAME::initWorkbook()
|
||||||
|
{
|
||||||
|
m_workbook = std::make_unique<SIM_WORKBOOK>();
|
||||||
|
|
||||||
|
if( m_simulator->Settings()->GetWorkbookPath().IsEmpty() )
|
||||||
|
{
|
||||||
|
m_simulator->Settings()->SetWorkbookPath( Prj().GetProjectName() + ".wbk" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxFileName filename = m_simulator->Settings()->GetWorkbookPath();
|
||||||
|
filename.SetPath( Prj().GetProjectPath() );
|
||||||
|
|
||||||
|
if( !loadWorkbook( filename.GetFullPath() ) )
|
||||||
|
DisplayErrorMessage( this, _( "There was an error while opening the workbook file" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// A small helper struct to handle bitmaps initialisation in menus
|
// A small helper struct to handle bitmaps initialisation in menus
|
||||||
struct BM_MENU_INIT_ITEM
|
struct BM_MENU_INIT_ITEM
|
||||||
{
|
{
|
||||||
|
@ -426,8 +425,8 @@ void SIM_PLOT_FRAME::StartSimulation( const wxString& aSimCommand )
|
||||||
{
|
{
|
||||||
SIM_PANEL_BASE* plotPanel = currentPlotWindow();
|
SIM_PANEL_BASE* plotPanel = currentPlotWindow();
|
||||||
|
|
||||||
if( plotPanel && m_plots.count( plotPanel ) != 0 )
|
if( plotPanel && m_workbook->HasPlotPanel( plotPanel ) )
|
||||||
m_exporter->SetSimCommand( m_plots[plotPanel].m_simCommand );
|
m_exporter->SetSimCommand( m_workbook->GetSimCommand( plotPanel ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -436,7 +435,7 @@ void SIM_PLOT_FRAME::StartSimulation( const wxString& aSimCommand )
|
||||||
|
|
||||||
if( !m_exporter->Format( &formatter, m_settingsDlg->GetNetlistOptions() ) )
|
if( !m_exporter->Format( &formatter, m_settingsDlg->GetNetlistOptions() ) )
|
||||||
{
|
{
|
||||||
DisplayError( this, _( "There were errors during netlist export, aborted." ) );
|
DisplayErrorMessage( this, _( "There were errors during netlist export, aborted." ) );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -487,17 +486,11 @@ SIM_PANEL_BASE* SIM_PLOT_FRAME::NewPlotPanel( wxString aSimCommand )
|
||||||
plotPanel = dynamic_cast<SIM_PANEL_BASE*>( panel );
|
plotPanel = dynamic_cast<SIM_PANEL_BASE*>( panel );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_welcomePanel )
|
|
||||||
{
|
|
||||||
m_plotNotebook->DeletePage( 0 );
|
|
||||||
m_welcomePanel = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxString pageTitle( m_simulator->TypeToName( simType, true ) );
|
wxString pageTitle( m_simulator->TypeToName( simType, true ) );
|
||||||
pageTitle.Prepend( wxString::Format( _( "Plot%u - " ), (unsigned int) ++m_plotNumber ) );
|
pageTitle.Prepend( wxString::Format( _( "Plot%u - " ), (unsigned int) ++m_plotNumber ) );
|
||||||
|
|
||||||
|
m_workbook->AddPlotPanel( plotPanel );
|
||||||
m_plotNotebook->AddPage( dynamic_cast<wxWindow*>( plotPanel ), pageTitle, true );
|
m_plotNotebook->AddPage( dynamic_cast<wxWindow*>( plotPanel ), pageTitle, true );
|
||||||
m_plots[plotPanel] = PLOT_INFO();
|
|
||||||
|
|
||||||
return plotPanel;
|
return plotPanel;
|
||||||
}
|
}
|
||||||
|
@ -519,7 +512,7 @@ void SIM_PLOT_FRAME::AddTuner( SCH_COMPONENT* aComponent )
|
||||||
{
|
{
|
||||||
SIM_PANEL_BASE* plotPanel = currentPlotWindow();
|
SIM_PANEL_BASE* plotPanel = currentPlotWindow();
|
||||||
|
|
||||||
if( !plotPanel || plotPanel == m_welcomePanel )
|
if( !plotPanel )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// For now limit the tuner tool to RLC components
|
// For now limit the tuner tool to RLC components
|
||||||
|
@ -551,7 +544,7 @@ void SIM_PLOT_FRAME::AddTuner( SCH_COMPONENT* aComponent )
|
||||||
catch( const KI_PARAM_ERROR& e )
|
catch( const KI_PARAM_ERROR& e )
|
||||||
{
|
{
|
||||||
// Sorry, no bonus
|
// Sorry, no bonus
|
||||||
DisplayError( nullptr, e.What() );
|
DisplayErrorMessage( nullptr, e.What() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -656,12 +649,7 @@ void SIM_PLOT_FRAME::removePlot( const wxString& aPlotName, bool aErase )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( aErase )
|
if( aErase )
|
||||||
{
|
m_workbook->RemoveTrace( plotPanel, aPlotName );
|
||||||
auto& traceMap = m_plots[plotPanel].m_traces;
|
|
||||||
auto traceIt = traceMap.find( aPlotName );
|
|
||||||
wxASSERT( traceIt != traceMap.end() );
|
|
||||||
traceMap.erase( traceIt );
|
|
||||||
}
|
|
||||||
|
|
||||||
wxASSERT( plotPanel->TraceShown( aPlotName ) );
|
wxASSERT( plotPanel->TraceShown( aPlotName ) );
|
||||||
plotPanel->DeleteTrace( aPlotName );
|
plotPanel->DeleteTrace( aPlotName );
|
||||||
|
@ -772,9 +760,7 @@ bool SIM_PLOT_FRAME::updatePlot( const TRACE_DESC& aDescriptor, SIM_PLOT_PANEL*
|
||||||
|
|
||||||
if( aPanel->AddTrace( name, inner,
|
if( aPanel->AddTrace( name, inner,
|
||||||
sub_x.data(), sub_y.data(), aDescriptor.GetType() ) )
|
sub_x.data(), sub_y.data(), aDescriptor.GetType() ) )
|
||||||
{
|
m_workbook->AddTrace( aPanel, name, aDescriptor );
|
||||||
m_plots[aPanel].m_traces.insert( std::make_pair( name, aDescriptor ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
v = v + source2.m_vincrement;
|
v = v + source2.m_vincrement;
|
||||||
offset += inner;
|
offset += inner;
|
||||||
|
@ -786,9 +772,7 @@ bool SIM_PLOT_FRAME::updatePlot( const TRACE_DESC& aDescriptor, SIM_PLOT_PANEL*
|
||||||
|
|
||||||
if( aPanel->AddTrace( aDescriptor.GetTitle(), size,
|
if( aPanel->AddTrace( aDescriptor.GetTitle(), size,
|
||||||
data_x.data(), data_y.data(), aDescriptor.GetType() ) )
|
data_x.data(), data_y.data(), aDescriptor.GetType() ) )
|
||||||
{
|
m_workbook->AddTrace( aPanel, aDescriptor.GetTitle(), aDescriptor );
|
||||||
m_plots[aPanel].m_traces.insert( std::make_pair( aDescriptor.GetTitle(), aDescriptor ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -852,7 +836,7 @@ void SIM_PLOT_FRAME::updateSignalList()
|
||||||
// calculated from the trace name index
|
// calculated from the trace name index
|
||||||
int imgidx = 0;
|
int imgidx = 0;
|
||||||
|
|
||||||
for( const auto& trace : m_plots[plotPanel].m_traces )
|
for( const auto& trace : m_workbook->GetTraces( plotPanel ) )
|
||||||
{
|
{
|
||||||
m_signals->InsertItem( imgidx, trace.first, imgidx );
|
m_signals->InsertItem( imgidx, trace.first, imgidx );
|
||||||
imgidx++;
|
imgidx++;
|
||||||
|
@ -901,7 +885,7 @@ void SIM_PLOT_FRAME::applyTuners()
|
||||||
|
|
||||||
bool SIM_PLOT_FRAME::loadWorkbook( const wxString& aPath )
|
bool SIM_PLOT_FRAME::loadWorkbook( const wxString& aPath )
|
||||||
{
|
{
|
||||||
m_plots.clear();
|
m_workbook->Clear();
|
||||||
m_plotNotebook->DeleteAllPages();
|
m_plotNotebook->DeleteAllPages();
|
||||||
|
|
||||||
wxTextFile file( aPath );
|
wxTextFile file( aPath );
|
||||||
|
@ -912,7 +896,10 @@ bool SIM_PLOT_FRAME::loadWorkbook( const wxString& aPath )
|
||||||
long plotsCount;
|
long plotsCount;
|
||||||
|
|
||||||
if( !file.GetFirstLine().ToLong( &plotsCount ) ) // GetFirstLine instead of GetNextLine
|
if( !file.GetFirstLine().ToLong( &plotsCount ) ) // GetFirstLine instead of GetNextLine
|
||||||
|
{
|
||||||
|
file.Close();
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for( long i = 0; i < plotsCount; ++i )
|
for( long i = 0; i < plotsCount; ++i )
|
||||||
{
|
{
|
||||||
|
@ -923,8 +910,10 @@ bool SIM_PLOT_FRAME::loadWorkbook( const wxString& aPath )
|
||||||
|
|
||||||
wxString simCommand = file.GetNextLine();
|
wxString simCommand = file.GetNextLine();
|
||||||
SIM_PANEL_BASE* plotPanel = NewPlotPanel( simCommand );
|
SIM_PANEL_BASE* plotPanel = NewPlotPanel( simCommand );
|
||||||
m_plots[plotPanel].m_simCommand = simCommand;
|
m_workbook->SetSimCommand( plotPanel, simCommand );
|
||||||
StartSimulation( m_plots[plotPanel].m_simCommand );
|
StartSimulation( m_workbook->GetSimCommand( plotPanel ) );
|
||||||
|
//m_plots[plotPanel].m_simCommand = simCommand;
|
||||||
|
//StartSimulation( m_plots[plotPanel].m_simCommand );
|
||||||
|
|
||||||
// Perform simulation, so plots can be added with values
|
// Perform simulation, so plots can be added with values
|
||||||
do
|
do
|
||||||
|
@ -942,18 +931,25 @@ bool SIM_PLOT_FRAME::loadWorkbook( const wxString& aPath )
|
||||||
wxString name, param;
|
wxString name, param;
|
||||||
|
|
||||||
if( !file.GetNextLine().ToLong( &traceType ) )
|
if( !file.GetNextLine().ToLong( &traceType ) )
|
||||||
|
{
|
||||||
|
file.Close();
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
name = file.GetNextLine();
|
name = file.GetNextLine();
|
||||||
param = file.GetNextLine();
|
param = file.GetNextLine();
|
||||||
|
|
||||||
if( name.IsEmpty() || param.IsEmpty() )
|
if( name.IsEmpty() || param.IsEmpty() )
|
||||||
|
{
|
||||||
|
file.Close();
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
addPlot( name, (SIM_PLOT_TYPE) traceType, param );
|
addPlot( name, (SIM_PLOT_TYPE) traceType, param );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
file.Close();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -979,9 +975,19 @@ bool SIM_PLOT_FRAME::saveWorkbook( const wxString& aPath )
|
||||||
file.Create();
|
file.Create();
|
||||||
}
|
}
|
||||||
|
|
||||||
file.AddLine( wxString::Format( "%llu", m_plots.size() ) );
|
unsigned long plotCount = 0;
|
||||||
|
|
||||||
for( const std::pair<SIM_PANEL_BASE*, PLOT_INFO> plot : m_plots )
|
// XXX: Count all valid plots. Replace this once we move the workbook format to JSON or
|
||||||
|
// S-expressions.
|
||||||
|
for( const auto& plot : m_workbook->GetPlots() )
|
||||||
|
{
|
||||||
|
if( plot.first )
|
||||||
|
plotCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
file.AddLine( wxString::Format( "%llu", plotCount ) );
|
||||||
|
|
||||||
|
for( const auto& plot : m_workbook->GetPlots() )
|
||||||
{
|
{
|
||||||
if( plot.first )
|
if( plot.first )
|
||||||
{
|
{
|
||||||
|
@ -1001,6 +1007,10 @@ bool SIM_PLOT_FRAME::saveWorkbook( const wxString& aPath )
|
||||||
bool res = file.Write();
|
bool res = file.Write();
|
||||||
file.Close();
|
file.Close();
|
||||||
|
|
||||||
|
// Store the path of the last saved workbook. It will be used to restore the simulation if
|
||||||
|
// the frame is closed and then opened again.
|
||||||
|
m_simulator->Settings()->SetWorkbookPath( savePath );
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1038,7 +1048,8 @@ void SIM_PLOT_FRAME::menuNewPlot( wxCommandEvent& aEvent )
|
||||||
|
|
||||||
// If the previous plot had the same type, copy the simulation command
|
// If the previous plot had the same type, copy the simulation command
|
||||||
if( prevPlot )
|
if( prevPlot )
|
||||||
m_plots[newPlot].m_simCommand = m_plots[prevPlot].m_simCommand;
|
m_workbook->SetSimCommand( newPlot, m_workbook->GetSimCommand( prevPlot ) );
|
||||||
|
//m_plots[newPlot].m_simCommand = m_plots[prevPlot].m_simCommand;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1054,7 +1065,7 @@ void SIM_PLOT_FRAME::menuOpenWorkbook( wxCommandEvent& event )
|
||||||
m_savedWorkbooksPath = openDlg.GetDirectory();
|
m_savedWorkbooksPath = openDlg.GetDirectory();
|
||||||
|
|
||||||
if( !loadWorkbook( openDlg.GetPath() ) )
|
if( !loadWorkbook( openDlg.GetPath() ) )
|
||||||
DisplayError( this, _( "There was an error while opening the workbook file" ) );
|
DisplayErrorMessage( this, _( "There was an error while opening the workbook file" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1063,16 +1074,26 @@ void SIM_PLOT_FRAME::menuSaveWorkbook( wxCommandEvent& event )
|
||||||
if( !CurrentPlot() )
|
if( !CurrentPlot() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxFileDialog saveDlg( this, _( "Save Simulation Workbook" ), m_savedWorkbooksPath, "",
|
if ( !saveWorkbook( m_simulator->Settings()->GetWorkbookPath() ) )
|
||||||
WorkbookFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
DisplayErrorMessage( this, _( "There was an error while saving the workbook file" ) );
|
||||||
|
}
|
||||||
|
|
||||||
if( saveDlg.ShowModal() == wxID_CANCEL )
|
|
||||||
|
void SIM_PLOT_FRAME::menuSaveWorkbookAs( wxCommandEvent& event )
|
||||||
|
{
|
||||||
|
if( !CurrentPlot() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_savedWorkbooksPath = saveDlg.GetDirectory();
|
wxFileDialog saveAsDlg( this, _( "Save Simulation Workbook As" ), m_savedWorkbooksPath, "",
|
||||||
|
WorkbookFileWildcard(), wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
|
||||||
|
|
||||||
if( !saveWorkbook( saveDlg.GetPath() ) )
|
if( saveAsDlg.ShowModal() == wxID_CANCEL )
|
||||||
DisplayError( this, _( "There was an error while saving the workbook file" ) );
|
return;
|
||||||
|
|
||||||
|
m_savedWorkbooksPath = saveAsDlg.GetDirectory();
|
||||||
|
|
||||||
|
if( !saveWorkbook( saveAsDlg.GetPath() ) )
|
||||||
|
DisplayErrorMessage( this, _( "There was an error while saving the workbook file" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1217,9 +1238,6 @@ void SIM_PLOT_FRAME::menuWhiteBackground( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
wxWindow* curPage = m_plotNotebook->GetPage( page );
|
wxWindow* curPage = m_plotNotebook->GetPage( page );
|
||||||
|
|
||||||
if( curPage == m_welcomePanel )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// ensure it is truly a plot panel and not the (zero plots) placeholder
|
// ensure it is truly a plot panel and not the (zero plots) placeholder
|
||||||
// which is only SIM_PLOT_PANEL_BASE
|
// which is only SIM_PLOT_PANEL_BASE
|
||||||
SIM_PLOT_PANEL* panel = dynamic_cast<SIM_PLOT_PANEL*>( curPage );
|
SIM_PLOT_PANEL* panel = dynamic_cast<SIM_PLOT_PANEL*>( curPage );
|
||||||
|
@ -1242,7 +1260,7 @@ void SIM_PLOT_FRAME::onPlotClose( wxAuiNotebookEvent& event )
|
||||||
SIM_PANEL_BASE* plotPanel =
|
SIM_PANEL_BASE* plotPanel =
|
||||||
dynamic_cast<SIM_PANEL_BASE*>( m_plotNotebook->GetPage( idx ) );
|
dynamic_cast<SIM_PANEL_BASE*>( m_plotNotebook->GetPage( idx ) );
|
||||||
|
|
||||||
m_plots.erase( plotPanel );
|
m_workbook->RemovePlotPanel( plotPanel );
|
||||||
updateSignalList();
|
updateSignalList();
|
||||||
wxCommandEvent dummy;
|
wxCommandEvent dummy;
|
||||||
onCursorUpdate( dummy );
|
onCursorUpdate( dummy );
|
||||||
|
@ -1305,15 +1323,23 @@ void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event )
|
||||||
updateNetlistExporter();
|
updateNetlistExporter();
|
||||||
|
|
||||||
if( !m_exporter->ProcessNetlist( NET_ALL_FLAGS ) )
|
if( !m_exporter->ProcessNetlist( NET_ALL_FLAGS ) )
|
||||||
|
{
|
||||||
|
DisplayErrorMessage( this, _( "There were errors during netlist export, aborted." ) );
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if( plotPanelWindow != m_welcomePanel )
|
if( m_workbook->HasPlotPanel( plotPanelWindow ) )
|
||||||
m_settingsDlg->SetSimCommand( m_plots[plotPanelWindow].m_simCommand );
|
m_settingsDlg->SetSimCommand( m_workbook->GetSimCommand( plotPanelWindow ) );
|
||||||
|
|
||||||
if( m_settingsDlg->ShowModal() == wxID_OK )
|
if( m_settingsDlg->ShowModal() == wxID_OK )
|
||||||
{
|
{
|
||||||
wxString oldCommand = plotPanelWindow != m_welcomePanel ?
|
wxString oldCommand;
|
||||||
m_plots[plotPanelWindow].m_simCommand : wxString();
|
|
||||||
|
if( m_workbook->HasPlotPanel( plotPanelWindow ) )
|
||||||
|
oldCommand = m_workbook->GetSimCommand( plotPanelWindow );
|
||||||
|
else
|
||||||
|
oldCommand = wxString();
|
||||||
|
|
||||||
wxString newCommand = m_settingsDlg->GetSimCommand();
|
wxString newCommand = m_settingsDlg->GetSimCommand();
|
||||||
SIM_TYPE newSimType = NETLIST_EXPORTER_PSPICE_SIM::CommandToSimType( newCommand );
|
SIM_TYPE newSimType = NETLIST_EXPORTER_PSPICE_SIM::CommandToSimType( newCommand );
|
||||||
|
|
||||||
|
@ -1328,7 +1354,7 @@ void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event )
|
||||||
plotPanelWindow = NewPlotPanel( newCommand );
|
plotPanelWindow = NewPlotPanel( newCommand );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_plots[plotPanelWindow].m_simCommand = newCommand;
|
m_workbook->SetSimCommand( plotPanelWindow, newCommand );
|
||||||
m_simulator->Init();
|
m_simulator->Init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1441,14 +1467,19 @@ void SIM_PLOT_FRAME::onShowNetlist( wxCommandEvent& event )
|
||||||
|
|
||||||
void SIM_PLOT_FRAME::doCloseWindow()
|
void SIM_PLOT_FRAME::doCloseWindow()
|
||||||
{
|
{
|
||||||
SaveSettings( config() );
|
|
||||||
|
|
||||||
if( IsSimulationRunning() )
|
if( IsSimulationRunning() )
|
||||||
m_simulator->Stop();
|
m_simulator->Stop();
|
||||||
|
|
||||||
// Cancel a running simProbe or simTune tool
|
// Cancel a running simProbe or simTune tool
|
||||||
m_schematicFrame->GetToolManager()->RunAction( ACTIONS::cancelInteractive );
|
m_schematicFrame->GetToolManager()->RunAction( ACTIONS::cancelInteractive );
|
||||||
|
|
||||||
|
wxFileName filename = m_simulator->Settings()->GetWorkbookPath();
|
||||||
|
filename.SetPath( Prj().GetProjectPath() );
|
||||||
|
|
||||||
|
saveWorkbook( filename.GetFullPath() );
|
||||||
|
|
||||||
|
SaveSettings( config() );
|
||||||
|
|
||||||
Destroy();
|
Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1529,17 +1560,17 @@ void SIM_PLOT_FRAME::onSimFinished( wxCommandEvent& aEvent )
|
||||||
// If there are any signals plotted, update them
|
// If there are any signals plotted, update them
|
||||||
if( SIM_PANEL_BASE::IsPlottable( simType ) )
|
if( SIM_PANEL_BASE::IsPlottable( simType ) )
|
||||||
{
|
{
|
||||||
TRACE_MAP& traceMap = m_plots[plotPanelWindow].m_traces;
|
|
||||||
SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( plotPanelWindow );
|
SIM_PLOT_PANEL* plotPanel = dynamic_cast<SIM_PLOT_PANEL*>( plotPanelWindow );
|
||||||
|
|
||||||
wxCHECK_RET( plotPanel, "not a SIM_PLOT_PANEL" );
|
wxCHECK_RET( plotPanel, "not a SIM_PLOT_PANEL" );
|
||||||
|
|
||||||
for( auto it = traceMap.begin(); it != traceMap.end(); /* iteration occurs in the loop */)
|
|
||||||
|
for( auto it = m_workbook->TracesBegin( plotPanel );
|
||||||
|
it != m_workbook->TracesEnd( plotPanel ); )
|
||||||
{
|
{
|
||||||
if( !updatePlot( it->second, plotPanel ) )
|
if( !updatePlot( it->second, plotPanel ) )
|
||||||
{
|
{
|
||||||
removePlot( it->first, false );
|
removePlot( it->first, false );
|
||||||
it = traceMap.erase( it ); // remove a plot that does not exist anymore
|
it = m_workbook->RemoveTrace( plotPanel, it );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -55,62 +55,11 @@ class NETLIST_EXPORTER_PSPICE_SIM;
|
||||||
|
|
||||||
#include "sim_plot_panel.h"
|
#include "sim_plot_panel.h"
|
||||||
#include "sim_panel_base.h"
|
#include "sim_panel_base.h"
|
||||||
|
#include "sim_workbook.h"
|
||||||
|
|
||||||
class SIM_THREAD_REPORTER;
|
class SIM_THREAD_REPORTER;
|
||||||
class TUNER_SLIDER;
|
class TUNER_SLIDER;
|
||||||
|
|
||||||
|
|
||||||
///< Trace descriptor class
|
|
||||||
class TRACE_DESC
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TRACE_DESC( const NETLIST_EXPORTER_PSPICE_SIM& aExporter, const wxString& aName,
|
|
||||||
SIM_PLOT_TYPE aType, const wxString& aParam );
|
|
||||||
|
|
||||||
///< Modifies an existing TRACE_DESC simulation type
|
|
||||||
TRACE_DESC( const NETLIST_EXPORTER_PSPICE_SIM& aExporter,
|
|
||||||
const TRACE_DESC& aDescription, SIM_PLOT_TYPE aNewType )
|
|
||||||
: TRACE_DESC( aExporter, aDescription.GetName(), aNewType, aDescription.GetParam() )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
const wxString& GetTitle() const
|
|
||||||
{
|
|
||||||
return m_title;
|
|
||||||
}
|
|
||||||
|
|
||||||
const wxString& GetName() const
|
|
||||||
{
|
|
||||||
return m_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
const wxString& GetParam() const
|
|
||||||
{
|
|
||||||
return m_param;
|
|
||||||
}
|
|
||||||
|
|
||||||
SIM_PLOT_TYPE GetType() const
|
|
||||||
{
|
|
||||||
return m_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
// Three basic parameters
|
|
||||||
///< Name of the measured net/device
|
|
||||||
wxString m_name;
|
|
||||||
|
|
||||||
///< Type of the signal
|
|
||||||
SIM_PLOT_TYPE m_type;
|
|
||||||
|
|
||||||
///< Name of the signal parameter
|
|
||||||
wxString m_param;
|
|
||||||
|
|
||||||
// Generated data
|
|
||||||
///< Title displayed in the signal list/plot legend
|
|
||||||
wxString m_title;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementing SIM_PLOT_FRAME_BASE
|
* Implementing SIM_PLOT_FRAME_BASE
|
||||||
*/
|
*/
|
||||||
|
@ -189,6 +138,12 @@ public:
|
||||||
std::shared_ptr<SPICE_SIMULATOR_SETTINGS>& GetSimulatorSettings();
|
std::shared_ptr<SPICE_SIMULATOR_SETTINGS>& GetSimulatorSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
/**
|
||||||
|
* Load the currently active workbook stored in the project settings. If there is none,
|
||||||
|
* generate a filename for the currently active workbook and store it in the project settings.
|
||||||
|
*/
|
||||||
|
void initWorkbook();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Give icons to menuitems of the main menubar
|
* Give icons to menuitems of the main menubar
|
||||||
*/
|
*/
|
||||||
|
@ -276,6 +231,7 @@ private:
|
||||||
void menuNewPlot( wxCommandEvent& aEvent ) override;
|
void menuNewPlot( wxCommandEvent& aEvent ) override;
|
||||||
void menuOpenWorkbook( wxCommandEvent& event ) override;
|
void menuOpenWorkbook( wxCommandEvent& event ) override;
|
||||||
void menuSaveWorkbook( wxCommandEvent& event ) override;
|
void menuSaveWorkbook( wxCommandEvent& event ) override;
|
||||||
|
void menuSaveWorkbookAs( wxCommandEvent& event ) override;
|
||||||
|
|
||||||
void menuExit( wxCommandEvent& event ) override
|
void menuExit( wxCommandEvent& event ) override
|
||||||
{
|
{
|
||||||
|
@ -339,19 +295,8 @@ private:
|
||||||
std::shared_ptr<SPICE_SIMULATOR> m_simulator;
|
std::shared_ptr<SPICE_SIMULATOR> m_simulator;
|
||||||
SIM_THREAD_REPORTER* m_reporter;
|
SIM_THREAD_REPORTER* m_reporter;
|
||||||
|
|
||||||
typedef std::map<wxString, TRACE_DESC> TRACE_MAP;
|
///< Stores the data that can be preserved across simulator sessions
|
||||||
|
std::unique_ptr<SIM_WORKBOOK> m_workbook;
|
||||||
struct PLOT_INFO
|
|
||||||
{
|
|
||||||
///< Map of the traces displayed on the plot
|
|
||||||
TRACE_MAP m_traces;
|
|
||||||
|
|
||||||
///< Spice directive used to execute the simulation
|
|
||||||
wxString m_simCommand;
|
|
||||||
};
|
|
||||||
|
|
||||||
///< Map of plot panels and associated data
|
|
||||||
std::map<SIM_PANEL_BASE*, PLOT_INFO> m_plots;
|
|
||||||
|
|
||||||
///< List of currently displayed tuners
|
///< List of currently displayed tuners
|
||||||
std::list<TUNER_SLIDER*> m_tuners;
|
std::list<TUNER_SLIDER*> m_tuners;
|
||||||
|
@ -392,9 +337,6 @@ private:
|
||||||
///< A string to store the path of saved workbooks during a session
|
///< A string to store the path of saved workbooks during a session
|
||||||
static wxString m_savedWorkbooksPath;
|
static wxString m_savedWorkbooksPath;
|
||||||
|
|
||||||
///< Info panel
|
|
||||||
SIM_PANEL_BASE* m_welcomePanel;
|
|
||||||
|
|
||||||
// Variables for temporary storage:
|
// Variables for temporary storage:
|
||||||
int m_splitterLeftRightSashPosition;
|
int m_splitterLeftRightSashPosition;
|
||||||
int m_splitterPlotAndConsoleSashPosition;
|
int m_splitterPlotAndConsoleSashPosition;
|
||||||
|
|
|
@ -29,6 +29,10 @@ SIM_PLOT_FRAME_BASE::SIM_PLOT_FRAME_BASE( wxWindow* parent, wxWindowID id, const
|
||||||
m_saveWorkbook = new wxMenuItem( m_fileMenu, wxID_SAVE, wxString( _("Save Workbook") ) , wxEmptyString, wxITEM_NORMAL );
|
m_saveWorkbook = new wxMenuItem( m_fileMenu, wxID_SAVE, wxString( _("Save Workbook") ) , wxEmptyString, wxITEM_NORMAL );
|
||||||
m_fileMenu->Append( m_saveWorkbook );
|
m_fileMenu->Append( m_saveWorkbook );
|
||||||
|
|
||||||
|
wxMenuItem* m_saveWorkbookAs;
|
||||||
|
m_saveWorkbookAs = new wxMenuItem( m_fileMenu, wxID_SAVE_AS, wxString( _("Save Workbook As...") ) , wxEmptyString, wxITEM_NORMAL );
|
||||||
|
m_fileMenu->Append( m_saveWorkbookAs );
|
||||||
|
|
||||||
m_fileMenu->AppendSeparator();
|
m_fileMenu->AppendSeparator();
|
||||||
|
|
||||||
wxMenuItem* m_saveImage;
|
wxMenuItem* m_saveImage;
|
||||||
|
@ -271,6 +275,7 @@ SIM_PLOT_FRAME_BASE::SIM_PLOT_FRAME_BASE( wxWindow* parent, wxWindowID id, const
|
||||||
m_fileMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuNewPlot ), this, m_newPlot->GetId());
|
m_fileMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuNewPlot ), this, m_newPlot->GetId());
|
||||||
m_fileMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuOpenWorkbook ), this, m_openWorkbook->GetId());
|
m_fileMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuOpenWorkbook ), this, m_openWorkbook->GetId());
|
||||||
m_fileMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuSaveWorkbook ), this, m_saveWorkbook->GetId());
|
m_fileMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuSaveWorkbook ), this, m_saveWorkbook->GetId());
|
||||||
|
m_fileMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuSaveWorkbookAs ), this, m_saveWorkbookAs->GetId());
|
||||||
m_fileMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuSaveImage ), this, m_saveImage->GetId());
|
m_fileMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuSaveImage ), this, m_saveImage->GetId());
|
||||||
m_fileMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuSaveCsv ), this, m_saveCsv->GetId());
|
m_fileMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuSaveCsv ), this, m_saveCsv->GetId());
|
||||||
m_fileMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuExit ), this, m_exitSim->GetId());
|
m_fileMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuExit ), this, m_exitSim->GetId());
|
||||||
|
|
|
@ -76,7 +76,7 @@
|
||||||
<property name="window_extra_style"></property>
|
<property name="window_extra_style"></property>
|
||||||
<property name="window_name"></property>
|
<property name="window_name"></property>
|
||||||
<property name="window_style"></property>
|
<property name="window_style"></property>
|
||||||
<object class="wxMenu" expanded="0">
|
<object class="wxMenu" expanded="1">
|
||||||
<property name="label">File</property>
|
<property name="label">File</property>
|
||||||
<property name="name">m_fileMenu</property>
|
<property name="name">m_fileMenu</property>
|
||||||
<property name="permission">protected</property>
|
<property name="permission">protected</property>
|
||||||
|
@ -126,6 +126,20 @@
|
||||||
<property name="unchecked_bitmap"></property>
|
<property name="unchecked_bitmap"></property>
|
||||||
<event name="OnMenuSelection">menuSaveWorkbook</event>
|
<event name="OnMenuSelection">menuSaveWorkbook</event>
|
||||||
</object>
|
</object>
|
||||||
|
<object class="wxMenuItem" expanded="1">
|
||||||
|
<property name="bitmap"></property>
|
||||||
|
<property name="checked">0</property>
|
||||||
|
<property name="enabled">1</property>
|
||||||
|
<property name="help"></property>
|
||||||
|
<property name="id">wxID_SAVE_AS</property>
|
||||||
|
<property name="kind">wxITEM_NORMAL</property>
|
||||||
|
<property name="label">Save Workbook As...</property>
|
||||||
|
<property name="name">m_saveWorkbookAs</property>
|
||||||
|
<property name="permission">none</property>
|
||||||
|
<property name="shortcut"></property>
|
||||||
|
<property name="unchecked_bitmap"></property>
|
||||||
|
<event name="OnMenuSelection">menuSaveWorkbookAs</event>
|
||||||
|
</object>
|
||||||
<object class="separator" expanded="0">
|
<object class="separator" expanded="0">
|
||||||
<property name="name">m_separator1</property>
|
<property name="name">m_separator1</property>
|
||||||
<property name="permission">none</property>
|
<property name="permission">none</property>
|
||||||
|
@ -388,7 +402,7 @@
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="wxBoxSizer" expanded="1">
|
<object class="wxBoxSizer" expanded="0">
|
||||||
<property name="minimum_size"></property>
|
<property name="minimum_size"></property>
|
||||||
<property name="name">m_sizerMain</property>
|
<property name="name">m_sizerMain</property>
|
||||||
<property name="orient">wxVERTICAL</property>
|
<property name="orient">wxVERTICAL</property>
|
||||||
|
@ -455,11 +469,11 @@
|
||||||
<property name="window_style"></property>
|
<property name="window_style"></property>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
<object class="sizeritem" expanded="1">
|
<object class="sizeritem" expanded="0">
|
||||||
<property name="border">5</property>
|
<property name="border">5</property>
|
||||||
<property name="flag">wxEXPAND</property>
|
<property name="flag">wxEXPAND</property>
|
||||||
<property name="proportion">1</property>
|
<property name="proportion">1</property>
|
||||||
<object class="wxSplitterWindow" expanded="1">
|
<object class="wxSplitterWindow" expanded="0">
|
||||||
<property name="BottomDockable">1</property>
|
<property name="BottomDockable">1</property>
|
||||||
<property name="LeftDockable">1</property>
|
<property name="LeftDockable">1</property>
|
||||||
<property name="RightDockable">1</property>
|
<property name="RightDockable">1</property>
|
||||||
|
|
|
@ -32,18 +32,19 @@
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#define ID_SAVE_AS_IMAGE 1000
|
#define wxID_SAVE_AS 1000
|
||||||
#define ID_SAVE_AS_CSV 1001
|
#define ID_SAVE_AS_IMAGE 1001
|
||||||
#define ID_MENU_RUN_SIM 1002
|
#define ID_SAVE_AS_CSV 1002
|
||||||
#define ID_MENU_ADD_SIGNAL 1003
|
#define ID_MENU_RUN_SIM 1003
|
||||||
#define ID_MENU_PROBE_SIGNALS 1004
|
#define ID_MENU_ADD_SIGNAL 1004
|
||||||
#define ID_MENU_TUNE_SIGNALS 1005
|
#define ID_MENU_PROBE_SIGNALS 1005
|
||||||
#define ID_MENU_SHOW_NETLIST 1006
|
#define ID_MENU_TUNE_SIGNALS 1006
|
||||||
#define ID_MENU_SET_SIMUL 1007
|
#define ID_MENU_SHOW_NETLIST 1007
|
||||||
#define ID_MENU_SHOW_GRID 1008
|
#define ID_MENU_SET_SIMUL 1008
|
||||||
#define ID_MENU_SHOW_LEGEND 1009
|
#define ID_MENU_SHOW_GRID 1009
|
||||||
#define ID_MENU_DOTTED 1010
|
#define ID_MENU_SHOW_LEGEND 1010
|
||||||
#define ID_MENU_WHITE_BG 1011
|
#define ID_MENU_DOTTED 1011
|
||||||
|
#define ID_MENU_WHITE_BG 1012
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
/// Class SIM_PLOT_FRAME_BASE
|
/// Class SIM_PLOT_FRAME_BASE
|
||||||
|
@ -94,6 +95,7 @@ class SIM_PLOT_FRAME_BASE : public KIWAY_PLAYER
|
||||||
virtual void menuNewPlot( wxCommandEvent& event ) { event.Skip(); }
|
virtual void menuNewPlot( wxCommandEvent& event ) { event.Skip(); }
|
||||||
virtual void menuOpenWorkbook( wxCommandEvent& event ) { event.Skip(); }
|
virtual void menuOpenWorkbook( wxCommandEvent& event ) { event.Skip(); }
|
||||||
virtual void menuSaveWorkbook( wxCommandEvent& event ) { event.Skip(); }
|
virtual void menuSaveWorkbook( wxCommandEvent& event ) { event.Skip(); }
|
||||||
|
virtual void menuSaveWorkbookAs( wxCommandEvent& event ) { event.Skip(); }
|
||||||
virtual void menuSaveImage( wxCommandEvent& event ) { event.Skip(); }
|
virtual void menuSaveImage( wxCommandEvent& event ) { event.Skip(); }
|
||||||
virtual void menuSaveCsv( wxCommandEvent& event ) { event.Skip(); }
|
virtual void menuSaveCsv( wxCommandEvent& event ) { event.Skip(); }
|
||||||
virtual void menuExit( wxCommandEvent& event ) { event.Skip(); }
|
virtual void menuExit( wxCommandEvent& event ) { event.Skip(); }
|
||||||
|
|
|
@ -0,0 +1,100 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2021 Mikołaj Wielgus <wielgusmikolaj@gmail.com>
|
||||||
|
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sim/sim_workbook.h>
|
||||||
|
|
||||||
|
TRACE_DESC::TRACE_DESC( const NETLIST_EXPORTER_PSPICE_SIM& aExporter, const wxString& aName,
|
||||||
|
SIM_PLOT_TYPE aType, const wxString& aParam ) :
|
||||||
|
m_name( aName ),
|
||||||
|
m_type( aType ),
|
||||||
|
m_param( aParam )
|
||||||
|
{
|
||||||
|
// Title generation
|
||||||
|
m_title = wxString::Format( "%s(%s)", aParam, aName );
|
||||||
|
|
||||||
|
if( aType & SPT_AC_MAG )
|
||||||
|
m_title += " (mag)";
|
||||||
|
else if( aType & SPT_AC_PHASE )
|
||||||
|
m_title += " (phase)";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SIM_WORKBOOK::SIM_WORKBOOK() :
|
||||||
|
m_dirty( false )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SIM_WORKBOOK::Clear()
|
||||||
|
{
|
||||||
|
m_plots.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SIM_WORKBOOK::AddPlotPanel( SIM_PANEL_BASE* aPlotPanel )
|
||||||
|
{
|
||||||
|
wxASSERT( m_plots.count( aPlotPanel ) == 0 );
|
||||||
|
m_plots[aPlotPanel] = PLOT_INFO();
|
||||||
|
|
||||||
|
m_dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SIM_WORKBOOK::RemovePlotPanel( SIM_PANEL_BASE* aPlotPanel )
|
||||||
|
{
|
||||||
|
wxASSERT( m_plots.count( aPlotPanel ) == 1 );
|
||||||
|
m_plots.erase( aPlotPanel );
|
||||||
|
|
||||||
|
m_dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SIM_WORKBOOK::AddTrace( const SIM_PANEL_BASE* aPlotPanel, const wxString& aName,
|
||||||
|
const TRACE_DESC& aTrace )
|
||||||
|
{
|
||||||
|
// XXX: A plot is created automatically if there is none with this name yet.
|
||||||
|
m_plots[aPlotPanel].m_traces.insert(
|
||||||
|
std::make_pair( aName, aTrace ) );
|
||||||
|
|
||||||
|
m_dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void SIM_WORKBOOK::RemoveTrace( const SIM_PANEL_BASE* aPlotPanel, const wxString& aName )
|
||||||
|
{
|
||||||
|
auto& traceMap = m_plots[aPlotPanel].m_traces;
|
||||||
|
auto traceIt = traceMap.find( aName );
|
||||||
|
wxASSERT( traceIt != traceMap.end() );
|
||||||
|
traceMap.erase( traceIt );
|
||||||
|
|
||||||
|
m_dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
SIM_WORKBOOK::TRACE_MAP::const_iterator SIM_WORKBOOK::RemoveTrace( const SIM_PANEL_BASE* aPlotPanel,
|
||||||
|
TRACE_MAP::const_iterator aIt )
|
||||||
|
{
|
||||||
|
m_dirty = true;
|
||||||
|
return m_plots.at( aPlotPanel ).m_traces.erase( aIt );
|
||||||
|
}
|
|
@ -0,0 +1,151 @@
|
||||||
|
/*
|
||||||
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2021 Mikołaj Wielgus <wielgusmikolaj@gmail.com>
|
||||||
|
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, you may find one here:
|
||||||
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||||
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||||
|
* or you may write to the Free Software Foundation, Inc.,
|
||||||
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "dialog_sim_settings.h"
|
||||||
|
#include <sim/sim_panel_base.h>
|
||||||
|
#include <sim/sim_plot_panel.h>
|
||||||
|
|
||||||
|
|
||||||
|
///< Trace descriptor class
|
||||||
|
class TRACE_DESC
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TRACE_DESC( const NETLIST_EXPORTER_PSPICE_SIM& aExporter, const wxString& aName,
|
||||||
|
SIM_PLOT_TYPE aType, const wxString& aParam );
|
||||||
|
|
||||||
|
///< Modifies an existing TRACE_DESC simulation type
|
||||||
|
TRACE_DESC( const NETLIST_EXPORTER_PSPICE_SIM& aExporter,
|
||||||
|
const TRACE_DESC& aDescription, SIM_PLOT_TYPE aNewType )
|
||||||
|
: TRACE_DESC( aExporter, aDescription.GetName(), aNewType, aDescription.GetParam() )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const wxString& GetTitle() const
|
||||||
|
{
|
||||||
|
return m_title;
|
||||||
|
}
|
||||||
|
|
||||||
|
const wxString& GetName() const
|
||||||
|
{
|
||||||
|
return m_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
const wxString& GetParam() const
|
||||||
|
{
|
||||||
|
return m_param;
|
||||||
|
}
|
||||||
|
|
||||||
|
SIM_PLOT_TYPE GetType() const
|
||||||
|
{
|
||||||
|
return m_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Three basic parameters
|
||||||
|
///< Name of the measured net/device
|
||||||
|
wxString m_name;
|
||||||
|
|
||||||
|
///< Type of the signal
|
||||||
|
SIM_PLOT_TYPE m_type;
|
||||||
|
|
||||||
|
///< Name of the signal parameter
|
||||||
|
wxString m_param;
|
||||||
|
|
||||||
|
// Generated data
|
||||||
|
///< Title displayed in the signal list/plot legend
|
||||||
|
wxString m_title;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class SIM_WORKBOOK
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
typedef std::map<wxString, TRACE_DESC> TRACE_MAP;
|
||||||
|
|
||||||
|
struct PLOT_INFO
|
||||||
|
{
|
||||||
|
///< Map of the traces displayed on the plot
|
||||||
|
TRACE_MAP m_traces;
|
||||||
|
|
||||||
|
///< Spice directive used to execute the simulation
|
||||||
|
wxString m_simCommand;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef std::map<const SIM_PANEL_BASE*, PLOT_INFO> PLOT_MAP;
|
||||||
|
|
||||||
|
SIM_WORKBOOK();
|
||||||
|
|
||||||
|
void Clear();
|
||||||
|
|
||||||
|
void AddPlotPanel( SIM_PANEL_BASE* aPlotPanel );
|
||||||
|
void RemovePlotPanel( SIM_PANEL_BASE* aPlotPanel );
|
||||||
|
|
||||||
|
|
||||||
|
bool HasPlotPanel( SIM_PANEL_BASE* aPlotPanel ) const
|
||||||
|
{
|
||||||
|
return m_plots.count( aPlotPanel ) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddTrace( const SIM_PANEL_BASE* aPlotPanel, const wxString& aName,
|
||||||
|
const TRACE_DESC& aTrace );
|
||||||
|
void RemoveTrace( const SIM_PANEL_BASE* aPlotPanel, const wxString& aName );
|
||||||
|
TRACE_MAP::const_iterator RemoveTrace( const SIM_PANEL_BASE* aPlotPanel, TRACE_MAP::const_iterator aIt );
|
||||||
|
|
||||||
|
TRACE_MAP::const_iterator TracesBegin( const SIM_PANEL_BASE* aPlotPanel ) const
|
||||||
|
{
|
||||||
|
return m_plots.at( aPlotPanel ).m_traces.cbegin();
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACE_MAP::const_iterator TracesEnd( const SIM_PANEL_BASE* aPlotPanel ) const
|
||||||
|
{
|
||||||
|
return m_plots.at( aPlotPanel ).m_traces.cend();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetSimCommand( const SIM_PANEL_BASE* aPlotPanel, const wxString& aSimCommand )
|
||||||
|
{
|
||||||
|
m_plots.at( aPlotPanel ).m_simCommand = aSimCommand;
|
||||||
|
m_dirty = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const wxString& GetSimCommand( const SIM_PANEL_BASE* aPlotPanel ) const
|
||||||
|
{
|
||||||
|
return m_plots.at( aPlotPanel ).m_simCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
const PLOT_MAP GetPlots() const { return m_plots; }
|
||||||
|
|
||||||
|
const TRACE_MAP GetTraces( const SIM_PANEL_BASE* aPlotPanel ) const
|
||||||
|
{
|
||||||
|
return m_plots.at( aPlotPanel ).m_traces;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsDirty() const { return m_dirty; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
///< Dirty bit, indicates something in the workbook has changed
|
||||||
|
bool m_dirty;
|
||||||
|
|
||||||
|
///< Map of plot panels and associated data
|
||||||
|
std::map<const SIM_PANEL_BASE*, PLOT_INFO> m_plots;
|
||||||
|
};
|
|
@ -35,6 +35,13 @@ SPICE_SIMULATOR_SETTINGS::SPICE_SIMULATOR_SETTINGS( JSON_SETTINGS* aParent,
|
||||||
const std::string& aPath ) :
|
const std::string& aPath ) :
|
||||||
NESTED_SETTINGS( "simulator", spiceSettingsSchemaVersion, aParent, aPath )
|
NESTED_SETTINGS( "simulator", spiceSettingsSchemaVersion, aParent, aPath )
|
||||||
{
|
{
|
||||||
|
m_params.emplace_back( new PARAM<wxString>( "workbook_path", &m_workbookPath, "" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SPICE_SIMULATOR_SETTINGS::operator==( const SPICE_SIMULATOR_SETTINGS &aRhs ) const
|
||||||
|
{
|
||||||
|
return m_workbookPath == aRhs.m_workbookPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -57,5 +64,6 @@ bool NGSPICE_SIMULATOR_SETTINGS::operator==( const SPICE_SIMULATOR_SETTINGS& aRh
|
||||||
|
|
||||||
wxCHECK( settings, false );
|
wxCHECK( settings, false );
|
||||||
|
|
||||||
return m_modelMode == settings->m_modelMode;
|
return ( *static_cast<const SPICE_SIMULATOR_SETTINGS*>( this ) ) == aRhs
|
||||||
|
&& m_modelMode == settings->m_modelMode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,12 @@ public:
|
||||||
virtual bool operator==( const SPICE_SIMULATOR_SETTINGS& aRhs ) const = 0;
|
virtual bool operator==( const SPICE_SIMULATOR_SETTINGS& aRhs ) const = 0;
|
||||||
|
|
||||||
bool operator!=( const SPICE_SIMULATOR_SETTINGS& aRhs ) const { return !( *this == aRhs ); }
|
bool operator!=( const SPICE_SIMULATOR_SETTINGS& aRhs ) const { return !( *this == aRhs ); }
|
||||||
|
|
||||||
|
wxString GetWorkbookPath() const { return m_workbookPath; }
|
||||||
|
void SetWorkbookPath( wxString aPath ) { m_workbookPath = aPath; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxString m_workbookPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue