eeschema: remove m_simCommand from SIM_WORKBOOK

This commit is contained in:
Sylwester Kocjan 2021-05-26 20:15:16 +02:00 committed by Wayne Stambaugh
parent 917e329bdf
commit b0e6bbb39c
5 changed files with 32 additions and 46 deletions

View File

@ -22,6 +22,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "confirm.h"
#include "sim_panel_base.h"
#include "sim_plot_frame.h"
@ -73,6 +74,15 @@ SIM_TYPE SIM_PANEL_BASE::GetType() const
}
void SIM_PANEL_BASE::SetSimCommand( const wxString& aSimCommand )
{
wxCHECK_RET( GetType() == NETLIST_EXPORTER_PSPICE_SIM::CommandToSimType( aSimCommand ),
"Cannot change the type of simulation of the existing plot panel" );
m_simCommand = aSimCommand;
}
SIM_NOPLOT_PANEL::SIM_NOPLOT_PANEL( wxString aCommand, wxWindow* parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, long style,
const wxString& name ) :

View File

@ -46,8 +46,12 @@ public:
SIM_TYPE GetType() const;
protected:
const wxString m_simCommand;
void SetSimCommand( const wxString& aSimCommand );
const wxString& GetSimCommand() const { return m_simCommand; }
private:
wxString m_simCommand;
};

View File

@ -461,7 +461,7 @@ void SIM_PLOT_FRAME::StartSimulation( const wxString& aSimCommand )
SIM_PANEL_BASE* plotPanel = currentPlotWindow();
if( plotPanel && m_workbook->HasPlotPanel( plotPanel ) )
m_exporter->SetSimCommand( m_workbook->GetSimCommand( plotPanel ) );
m_exporter->SetSimCommand( plotPanel->GetSimCommand() );
}
else
{
@ -948,9 +948,8 @@ bool SIM_PLOT_FRAME::loadWorkbook( const wxString& aPath )
}
wxString simCommand = file.GetNextLine();
SIM_PANEL_BASE* plotPanel = NewPlotPanel( simCommand );
m_workbook->SetSimCommand( plotPanel, simCommand );
StartSimulation( m_workbook->GetSimCommand( plotPanel ) );
NewPlotPanel( simCommand );
StartSimulation( simCommand );
// Perform simulation, so plots can be added with values
do
@ -1028,12 +1027,11 @@ bool SIM_PLOT_FRAME::saveWorkbook( const wxString& aPath )
for( const SIM_PANEL_BASE*& plotPanel : plotPanels )
{
SIM_WORKBOOK::PLOT_INFO plot = m_workbook->GetPlot( plotPanel );
file.AddLine( wxString::Format( "%d", plotPanel->GetType() ) );
file.AddLine( plot.m_simCommand );
file.AddLine( plotPanel->GetSimCommand() );
const SIM_PLOT_PANEL* panel = dynamic_cast<const SIM_PLOT_PANEL*>( plotPanel );
if( !panel )
file.AddLine( wxString::Format( "%llu", 0ull ) );
else
@ -1089,17 +1087,9 @@ void SIM_PLOT_FRAME::menuNewPlot( wxCommandEvent& aEvent )
if( SIM_PANEL_BASE::IsPlottable( type ) )
{
SIM_PLOT_PANEL* prevPlot = CurrentPlot();
SIM_PLOT_PANEL* newPlot =
dynamic_cast<SIM_PLOT_PANEL*>( NewPlotPanel( m_exporter->GetUsedSimCommand() ) );
// If the previous plot had the same type, copy the simulation command
if( prevPlot )
{
m_workbook->SetSimCommand( newPlot, m_workbook->GetSimCommand( prevPlot ) );
NewPlotPanel( m_exporter->GetUsedSimCommand() );
updateFrame();
}
}
}
@ -1404,14 +1394,14 @@ void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event )
}
if( m_workbook->HasPlotPanel( plotPanelWindow ) )
m_settingsDlg->SetSimCommand( m_workbook->GetSimCommand( plotPanelWindow ) );
m_settingsDlg->SetSimCommand( plotPanelWindow->GetSimCommand() );
if( m_settingsDlg->ShowModal() == wxID_OK )
{
wxString oldCommand;
if( m_workbook->HasPlotPanel( plotPanelWindow ) )
oldCommand = m_workbook->GetSimCommand( plotPanelWindow );
oldCommand = plotPanelWindow->GetSimCommand();
else
oldCommand = wxString();
@ -1428,8 +1418,12 @@ void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event )
{
plotPanelWindow = NewPlotPanel( newCommand );
}
else
{
// Update simulation command in the current plot
plotPanelWindow->SetSimCommand( newCommand );
}
m_workbook->SetSimCommand( plotPanelWindow, newCommand );
m_simulator->Init();
updateFrame();
}

View File

@ -386,9 +386,9 @@ void SIM_PLOT_PANEL::prepareDCAxes()
{
wxRegEx simCmd( "^.dc[[:space:]]+([[:alnum:]]+\\M).*", wxRE_ADVANCED | wxRE_ICASE );
if( simCmd.Matches( m_simCommand ) )
if( simCmd.Matches( GetSimCommand() ) )
{
switch( static_cast<char>( simCmd.GetMatch( m_simCommand.Lower(), 1 ).GetChar( 0 ) ) )
switch( static_cast<char>( simCmd.GetMatch( GetSimCommand().Lower(), 1 ).GetChar( 0 ) ) )
{
case 'v':
m_axis_x =

View File

@ -33,10 +33,6 @@ public:
struct PLOT_INFO
{
///< Spice directive used to execute the simulation
///< TODO: use SIM_PANEL_BASE::m_simCommand instead
wxString m_simCommand;
///< The current position of the plot in the notebook
unsigned int pos;
};
@ -66,24 +62,6 @@ public:
m_plots.at( aPlotPanel ).pos = pos;
}
void SetSimCommand( const SIM_PANEL_BASE* aPlotPanel, const wxString& aSimCommand )
{
if( m_plots.at( aPlotPanel ).m_simCommand != aSimCommand )
m_flagModified = true;
m_plots.at( aPlotPanel ).m_simCommand = aSimCommand;
}
const wxString& GetSimCommand( const SIM_PANEL_BASE* aPlotPanel ) const
{
return m_plots.at( aPlotPanel ).m_simCommand;
}
PLOT_INFO GetPlot( const SIM_PANEL_BASE* aPlotPanel ) const
{
return m_plots.at( aPlotPanel );
}
void ClrModified() { m_flagModified = false; }
bool IsModified() const { return m_flagModified; }