From 6bc89ee180ed51ab80651aeabb772de730923656 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 21 Jan 2023 13:24:47 +0000 Subject: [PATCH] Don't disable run when there's no command: just ask for a command. --- eeschema/sim/sim_model_serializer.cpp | 2 ++ eeschema/sim/sim_plot_frame.cpp | 28 ++++++++++++++------------- eeschema/sim/sim_plot_frame.h | 2 +- 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/eeschema/sim/sim_model_serializer.cpp b/eeschema/sim/sim_model_serializer.cpp index fb4ed04730..a8b23ac30e 100644 --- a/eeschema/sim/sim_model_serializer.cpp +++ b/eeschema/sim/sim_model_serializer.cpp @@ -212,7 +212,9 @@ bool SIM_MODEL_SERIALIZER::ParseParams( const std::string& aParams ) for( const auto& node : root->children ) { if( node->is_type() ) + { paramName = node->string(); + } // TODO: Do something with number. // It doesn't seem too useful? else if( node->is_type() diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index 02e0978cc9..849a647ca6 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -375,8 +375,14 @@ void SIM_PLOT_FRAME::setSubWindowsSashSize() void SIM_PLOT_FRAME::StartSimulation( const wxString& aSimCommand ) { - wxCHECK_RET( m_circuitModel->CommandToSimType( GetCurrentSimCommand() ) != ST_UNKNOWN, - wxT( "Unknown simulation type" ) ); + if( m_circuitModel->CommandToSimType( GetCurrentSimCommand() ) == ST_UNKNOWN ) + { + if( !EditSimCommand() + || m_circuitModel->CommandToSimType( GetCurrentSimCommand() ) == ST_UNKNOWN ) + { + return; + } + } m_simConsole->Clear(); @@ -858,8 +864,7 @@ void SIM_PLOT_FRAME::applyTuners() } if( reporter.HasMessage() ) - DisplayErrorMessage( this, - _( "Could not apply tuned value(s):" ) + wxS( "\n\n" ) + errors ); + DisplayErrorMessage( this, _( "Could not apply tuned value(s):" ) + wxS( "\n" ) + errors ); } @@ -1226,7 +1231,7 @@ void SIM_PLOT_FRAME::onWorkbookClrModified( wxCommandEvent& event ) } -void SIM_PLOT_FRAME::EditSimCommand() +bool SIM_PLOT_FRAME::EditSimCommand() { SIM_PANEL_BASE* plotPanelWindow = getCurrentPlotWindow(); DIALOG_SIM_COMMAND dlg( this, m_circuitModel, m_simulator->Settings() ); @@ -1238,7 +1243,7 @@ void SIM_PLOT_FRAME::EditSimCommand() { DisplayErrorMessage( this, _( "Errors during netlist generation; simulation aborted.\n\n" ) + errors ); - return; + return false; } if( m_workbook->GetPageIndex( plotPanelWindow ) != wxNOT_FOUND ) @@ -1289,7 +1294,10 @@ void SIM_PLOT_FRAME::EditSimCommand() } m_simulator->Init(); + return true; } + + return false; } @@ -1427,12 +1435,6 @@ void SIM_PLOT_FRAME::setupUIConditions() return m_darkMode; }; - auto haveCommand = - [this]( const SELECTION& aSel ) - { - return m_circuitModel->CommandToSimType( GetCurrentSimCommand() ) != ST_UNKNOWN; - }; - auto simRunning = [this]( const SELECTION& aSel ) { @@ -1467,7 +1469,7 @@ void SIM_PLOT_FRAME::setupUIConditions() mgr->SetConditions( EE_ACTIONS::toggleDarkModePlots, CHECK( darkModePlotCondition ) ); mgr->SetConditions( EE_ACTIONS::simCommand, ENABLE( SELECTION_CONDITIONS::ShowAlways ) ); - mgr->SetConditions( EE_ACTIONS::runSimulation, ENABLE( haveCommand && !simRunning ) ); + mgr->SetConditions( EE_ACTIONS::runSimulation, ENABLE( !simRunning ) ); mgr->SetConditions( EE_ACTIONS::stopSimulation, ENABLE( simRunning ) ); mgr->SetConditions( EE_ACTIONS::addSignals, ENABLE( simFinished ) ); mgr->SetConditions( EE_ACTIONS::simProbe, ENABLE( simFinished ) ); diff --git a/eeschema/sim/sim_plot_frame.h b/eeschema/sim/sim_plot_frame.h index deeb034e15..e7ef9530da 100644 --- a/eeschema/sim/sim_plot_frame.h +++ b/eeschema/sim/sim_plot_frame.h @@ -77,7 +77,7 @@ public: * Shows a dialog for editing the current tab's simulation command, or creating a new tab * with a different simulation command type. */ - void EditSimCommand(); + bool EditSimCommand(); /** * Add a voltage plot for a given net name.