Revert "Manual reimplementation of 84c72b087c548829908d7fbbecfd2fa5968cc98b"
This reverts commit 7cc55d2d3a
.
This commit is contained in:
parent
7cc55d2d3a
commit
e2c0c6362f
|
@ -601,7 +601,7 @@ void DIALOG_SIM_COMMAND::updateDCUnits( wxChar aType, wxChoice* aSource,
|
|||
void DIALOG_SIM_COMMAND::loadDirectives()
|
||||
{
|
||||
if( m_circuitModel )
|
||||
m_customTxt->SetValue( m_circuitModel->GetSchTextSimCommand() );
|
||||
m_customTxt->SetValue( m_circuitModel->GetSheetSimCommand() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ SIM_PLOT_TYPE NGSPICE_CIRCUIT_MODEL::VectorToSignal( const std::string& aVector,
|
|||
}
|
||||
|
||||
|
||||
wxString NGSPICE_CIRCUIT_MODEL::GetSchTextSimCommand()
|
||||
wxString NGSPICE_CIRCUIT_MODEL::GetSheetSimCommand()
|
||||
{
|
||||
wxString simCmd;
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
{
|
||||
if( aCmd != m_simCommand )
|
||||
{
|
||||
m_lastSchTextSimCommand = GetSchTextSimCommand();
|
||||
m_lastSheetSimCommand = GetSheetSimCommand();
|
||||
m_simCommand = aCmd;
|
||||
}
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public:
|
|||
*/
|
||||
wxString GetSimCommand()
|
||||
{
|
||||
return m_simCommand.IsEmpty() ? GetSchTextSimCommand() : m_simCommand;
|
||||
return m_simCommand.IsEmpty() ? GetSheetSimCommand() : m_simCommand;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,14 +109,14 @@ public:
|
|||
/**
|
||||
* Return simulation command directives placed in schematic sheets (if any).
|
||||
*/
|
||||
wxString GetSchTextSimCommand();
|
||||
wxString GetSheetSimCommand();
|
||||
|
||||
/**
|
||||
* Return the sim command present as a sheet directive when the sim command override was last
|
||||
* updated.
|
||||
* @return
|
||||
*/
|
||||
wxString GetLastSchTextSimCommand() const { return m_lastSchTextSimCommand; }
|
||||
wxString GetLastSheetSimCommand() const { return m_lastSheetSimCommand; }
|
||||
|
||||
/**
|
||||
* Parse a two-source .dc command directive into its symbols.
|
||||
|
@ -148,7 +148,7 @@ private:
|
|||
wxString m_simCommand;
|
||||
|
||||
///< Value of schematic sheet simulation command when override was last updated
|
||||
wxString m_lastSchTextSimCommand;
|
||||
wxString m_lastSheetSimCommand;
|
||||
|
||||
int m_options;
|
||||
};
|
||||
|
|
|
@ -48,8 +48,14 @@ public:
|
|||
|
||||
SIM_TYPE GetType() const;
|
||||
|
||||
const wxString& GetSimCommand() const { return m_simCommand; }
|
||||
void SetSimCommand( const wxString& aSimCommand )
|
||||
protected:
|
||||
// We use `protected` here because members should be accessible from outside only through a
|
||||
// workbook object, to prevent anyone from modifying the state without its knowledge. Otherwise
|
||||
// we risk some things not getting saved.
|
||||
|
||||
const wxString& getSimCommand() const { return m_simCommand; }
|
||||
|
||||
void setSimCommand( const wxString& aSimCommand )
|
||||
{
|
||||
wxCHECK_RET( GetType() == NGSPICE_CIRCUIT_MODEL::CommandToSimType( aSimCommand ),
|
||||
"Cannot change the type of simulation of the existing plot panel" );
|
||||
|
@ -57,8 +63,8 @@ public:
|
|||
m_simCommand = aSimCommand;
|
||||
}
|
||||
|
||||
int GetSimOptions() const { return m_simOptions; }
|
||||
void SetSimOptions( int aOptions ) { m_simOptions = aOptions; }
|
||||
const int getSimOptions() const { return m_simOptions; }
|
||||
void setSimOptions( int aOptions ) { m_simOptions = aOptions; }
|
||||
|
||||
private:
|
||||
wxString m_simCommand;
|
||||
|
|
|
@ -446,41 +446,15 @@ void SIM_PLOT_FRAME::setSubWindowsSashSize()
|
|||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::StartSimulation()
|
||||
void SIM_PLOT_FRAME::StartSimulation( const wxString& aSimCommand )
|
||||
{
|
||||
if( m_circuitModel->CommandToSimType( GetCurrentSimCommand() ) == ST_UNKNOWN )
|
||||
{
|
||||
if( !EditSimCommand() )
|
||||
return;
|
||||
wxCHECK_RET( m_circuitModel->CommandToSimType( getCurrentSimCommand() ) != ST_UNKNOWN,
|
||||
wxT( "Unknown simulation type" ) );
|
||||
|
||||
if( m_circuitModel->CommandToSimType( GetCurrentSimCommand() ) == ST_UNKNOWN )
|
||||
return;
|
||||
}
|
||||
m_simConsole->Clear();
|
||||
|
||||
wxString schTextSimCommand = m_circuitModel->GetSchTextSimCommand();
|
||||
SIM_TYPE schTextSimType = NGSPICE_CIRCUIT_MODEL::CommandToSimType( schTextSimCommand );
|
||||
SIM_PANEL_BASE* plotWindow = getCurrentPlotWindow();
|
||||
|
||||
if( !plotWindow )
|
||||
{
|
||||
plotWindow = NewPlotPanel( schTextSimCommand, m_circuitModel->GetSimOptions() );
|
||||
m_workbook->SetSimCommand( plotWindow, schTextSimCommand );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_circuitModel->SetSimCommandOverride( m_workbook->GetSimCommand( plotWindow ) );
|
||||
|
||||
if( plotWindow->GetType() == schTextSimType
|
||||
&& schTextSimCommand != m_circuitModel->GetLastSchTextSimCommand() )
|
||||
{
|
||||
if( IsOK( this, _( "Schematic sheet simulation command directive has changed. "
|
||||
"Do you wish to update the Simulation Command?" ) ) )
|
||||
{
|
||||
m_circuitModel->SetSimCommandOverride( wxEmptyString );
|
||||
m_workbook->SetSimCommand( plotWindow, schTextSimCommand );
|
||||
}
|
||||
}
|
||||
}
|
||||
if( aSimCommand != wxEmptyString )
|
||||
m_circuitModel->SetSimCommandOverride( aSimCommand );
|
||||
|
||||
m_circuitModel->SetSimOptions( getCurrentOptions() );
|
||||
|
||||
|
@ -501,14 +475,33 @@ void SIM_PLOT_FRAME::StartSimulation()
|
|||
return;
|
||||
}
|
||||
|
||||
SIM_PANEL_BASE* plotWindow = getCurrentPlotWindow();
|
||||
wxString sheetSimCommand = m_circuitModel->GetSheetSimCommand();
|
||||
|
||||
if( plotWindow
|
||||
&& plotWindow->GetType() == NGSPICE_CIRCUIT_MODEL::CommandToSimType( sheetSimCommand ) )
|
||||
{
|
||||
if( m_circuitModel->GetSimCommandOverride().IsEmpty() )
|
||||
{
|
||||
m_workbook->SetSimCommand( plotWindow, sheetSimCommand );
|
||||
}
|
||||
else if( sheetSimCommand != m_circuitModel->GetLastSheetSimCommand() )
|
||||
{
|
||||
if( IsOK( this, _( "Schematic sheet simulation command directive has changed. Do you "
|
||||
"wish to update the Simulation Command?" ) ) )
|
||||
{
|
||||
m_circuitModel->SetSimCommandOverride( wxEmptyString );
|
||||
m_workbook->SetSimCommand( plotWindow, sheetSimCommand );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_lock<std::mutex> simulatorLock( m_simulator->GetMutex(), std::try_to_lock );
|
||||
|
||||
if( simulatorLock.owns_lock() )
|
||||
{
|
||||
wxBusyCursor toggle;
|
||||
|
||||
m_simConsole->Clear();
|
||||
|
||||
applyTuners();
|
||||
|
||||
// Prevents memory leak on succeding simulations by deleting old vectors
|
||||
|
@ -1031,7 +1024,7 @@ bool SIM_PLOT_FRAME::loadWorkbook( const wxString& aPath )
|
|||
}
|
||||
|
||||
NewPlotPanel( simCommand, simOptions );
|
||||
StartSimulation();
|
||||
StartSimulation( simCommand );
|
||||
|
||||
// Perform simulation, so plots can be added with values
|
||||
do
|
||||
|
@ -1565,7 +1558,7 @@ void SIM_PLOT_FRAME::onSimulate( wxCommandEvent& event )
|
|||
}
|
||||
|
||||
|
||||
bool SIM_PLOT_FRAME::EditSimCommand()
|
||||
void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event )
|
||||
{
|
||||
SIM_PANEL_BASE* plotPanelWindow = getCurrentPlotWindow();
|
||||
DIALOG_SIM_COMMAND dlg( this, m_circuitModel, m_simulator->Settings() );
|
||||
|
@ -1577,7 +1570,7 @@ bool SIM_PLOT_FRAME::EditSimCommand()
|
|||
{
|
||||
DisplayErrorMessage( this, _( "Errors during netlist generation; simulation aborted.\n\n" )
|
||||
+ errors );
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
|
||||
if( m_workbook->GetPageIndex( plotPanelWindow ) != wxNOT_FOUND )
|
||||
|
@ -1628,10 +1621,7 @@ bool SIM_PLOT_FRAME::EditSimCommand()
|
|||
}
|
||||
|
||||
m_simulator->Init();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent );
|
||||
~SIM_PLOT_FRAME();
|
||||
|
||||
void StartSimulation();
|
||||
void StartSimulation( const wxString& aSimCommand = wxEmptyString );
|
||||
|
||||
/**
|
||||
* Create a new plot panel for a given simulation type and adds it to the main notebook.
|
||||
|
@ -137,27 +137,9 @@ public:
|
|||
|
||||
WINDOW_SETTINGS* GetWindowSettings( APP_SETTINGS_BASE* aCfg ) override;
|
||||
|
||||
wxString GetCurrentSimCommand() const
|
||||
{
|
||||
if( getCurrentPlotWindow() )
|
||||
return getCurrentPlotWindow()->GetSimCommand();
|
||||
else
|
||||
return m_circuitModel->GetSchTextSimCommand();
|
||||
}
|
||||
|
||||
int GetCurrentOptions() const
|
||||
{
|
||||
if( getCurrentPlotWindow() )
|
||||
return getCurrentPlotWindow()->GetSimOptions();
|
||||
else
|
||||
return m_circuitModel->GetSimOptions();
|
||||
}
|
||||
|
||||
// Simulator doesn't host a tool framework
|
||||
wxWindow* GetToolCanvas() const override { return nullptr; }
|
||||
|
||||
bool EditSimCommand();
|
||||
|
||||
private:
|
||||
/**
|
||||
* Load the currently active workbook stored in the project settings. If there is none,
|
||||
|
@ -253,7 +235,7 @@ private:
|
|||
wxString getCurrentSimCommand() const
|
||||
{
|
||||
if( getCurrentPlotWindow() == nullptr )
|
||||
return m_circuitModel->GetSchTextSimCommand();
|
||||
return m_circuitModel->GetSheetSimCommand();
|
||||
else
|
||||
return m_workbook->GetSimCommand( getCurrentPlotWindow() );
|
||||
}
|
||||
|
@ -314,10 +296,7 @@ private:
|
|||
void onWorkbookClrModified( wxCommandEvent& event );
|
||||
|
||||
void onSimulate( wxCommandEvent& event );
|
||||
void onSettings( wxCommandEvent& event )
|
||||
{
|
||||
EditSimCommand();
|
||||
}
|
||||
void onSettings( wxCommandEvent& event );
|
||||
void onAddSignal( wxCommandEvent& event );
|
||||
void onProbe( wxCommandEvent& event );
|
||||
void onTune( wxCommandEvent& event );
|
||||
|
|
|
@ -400,7 +400,7 @@ void SIM_PLOT_PANEL::updateAxes()
|
|||
|
||||
void SIM_PLOT_PANEL::prepareDCAxes()
|
||||
{
|
||||
wxString sim_cmd = GetSimCommand().Lower();
|
||||
wxString sim_cmd = getSimCommand().Lower();
|
||||
wxString rem;
|
||||
|
||||
if( sim_cmd.StartsWith( ".dc", &rem ) )
|
||||
|
|
|
@ -54,24 +54,24 @@ public:
|
|||
|
||||
void SetSimCommand( SIM_PANEL_BASE* aPlotPanel, const wxString& aSimCommand )
|
||||
{
|
||||
aPlotPanel->SetSimCommand( aSimCommand );
|
||||
aPlotPanel->setSimCommand( aSimCommand );
|
||||
setModified();
|
||||
}
|
||||
|
||||
const wxString& GetSimCommand( const SIM_PANEL_BASE* aPlotPanel )
|
||||
{
|
||||
return aPlotPanel->GetSimCommand();
|
||||
return aPlotPanel->getSimCommand();
|
||||
}
|
||||
|
||||
void SetSimOptions( SIM_PANEL_BASE* aPlotPanel, int aOptions )
|
||||
{
|
||||
aPlotPanel->SetSimOptions( aOptions );
|
||||
aPlotPanel->setSimOptions( aOptions );
|
||||
setModified();
|
||||
}
|
||||
|
||||
int GetSimOptions( const SIM_PANEL_BASE* aPlotPanel )
|
||||
{
|
||||
return aPlotPanel->GetSimOptions();
|
||||
return aPlotPanel->getSimOptions();
|
||||
}
|
||||
|
||||
void ClrModified();
|
||||
|
|
Loading…
Reference in New Issue