Fix sim bug running a command the first time when no command in doc.

Fixes https://gitlab.com/kicad/code/kicad/issues/11366
This commit is contained in:
Jeff Young 2022-12-23 18:20:20 +00:00
parent bfd3b40672
commit 8069e5d5d6
1 changed files with 13 additions and 8 deletions

View File

@ -1511,20 +1511,25 @@ void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event )
const wxString& newCommand = dlg.GetSimCommand(); const wxString& newCommand = dlg.GetSimCommand();
SIM_TYPE newSimType = NGSPICE_CIRCUIT_MODEL::CommandToSimType( newCommand ); SIM_TYPE newSimType = NGSPICE_CIRCUIT_MODEL::CommandToSimType( newCommand );
// If it is a new simulation type, open a new plot if( !plotPanelWindow )
// For the DC sim, check if sweep source type has changed (char 4 will contain 'v', {
// 'i', 'r' or 't'. m_circuitModel->SetSimCommandOverride( newCommand );
if( !plotPanelWindow plotPanelWindow = NewPlotPanel( newCommand );
|| ( plotPanelWindow && plotPanelWindow->GetType() != newSimType ) }
|| ( newSimType == ST_DC // If it is a new simulation type, open a new plot. For the DC sim, check if sweep
&& oldCommand.Lower().GetChar( 4 ) != newCommand.Lower().GetChar( 4 ) ) ) // source type has changed (char 4 will contain 'v', 'i', 'r' or 't'.
else if( plotPanelWindow->GetType() != newSimType
|| ( newSimType == ST_DC
&& oldCommand.Lower().GetChar( 4 ) != newCommand.Lower().GetChar( 4 ) ) )
{ {
plotPanelWindow = NewPlotPanel( newCommand ); plotPanelWindow = NewPlotPanel( newCommand );
} }
else else
{ {
if( m_workbook->GetPageIndex( plotPanelWindow ) == 0 )
m_circuitModel->SetSimCommandOverride( newCommand );
// Update simulation command in the current plot // Update simulation command in the current plot
m_circuitModel->SetSimCommandOverride( newCommand );
m_workbook->SetSimCommand( plotPanelWindow, newCommand ); m_workbook->SetSimCommand( plotPanelWindow, newCommand );
} }