Make panel sim command only accessible from outside through workbook object
This commit is contained in:
parent
c11ee69499
commit
cd0c8a5676
|
@ -74,15 +74,6 @@ 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,
|
SIM_NOPLOT_PANEL::SIM_NOPLOT_PANEL( wxString aCommand, wxWindow* parent, wxWindowID id,
|
||||||
const wxPoint& pos, const wxSize& size, long style,
|
const wxPoint& pos, const wxSize& size, long style,
|
||||||
const wxString& name ) :
|
const wxString& name ) :
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#define __SIM_PLOT_PANEL_BASE_H
|
#define __SIM_PLOT_PANEL_BASE_H
|
||||||
|
|
||||||
#include "sim_types.h"
|
#include "sim_types.h"
|
||||||
|
#include "netlist_exporter_pspice_sim.h"
|
||||||
#include <wx/panel.h>
|
#include <wx/panel.h>
|
||||||
#include <wx/sizer.h>
|
#include <wx/sizer.h>
|
||||||
#include <wx/stattext.h>
|
#include <wx/stattext.h>
|
||||||
|
@ -34,6 +35,8 @@
|
||||||
|
|
||||||
class SIM_PANEL_BASE : public wxWindow
|
class SIM_PANEL_BASE : public wxWindow
|
||||||
{
|
{
|
||||||
|
friend class SIM_WORKBOOK;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SIM_PANEL_BASE();
|
SIM_PANEL_BASE();
|
||||||
SIM_PANEL_BASE( wxString aCommand );
|
SIM_PANEL_BASE( wxString aCommand );
|
||||||
|
@ -46,10 +49,21 @@ public:
|
||||||
|
|
||||||
SIM_TYPE GetType() const;
|
SIM_TYPE GetType() const;
|
||||||
|
|
||||||
void SetSimCommand( const wxString& aSimCommand );
|
protected:
|
||||||
|
// Some 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; }
|
const wxString& GetSimCommand() const { return m_simCommand; }
|
||||||
|
|
||||||
|
void 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;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxString m_simCommand;
|
wxString m_simCommand;
|
||||||
};
|
};
|
||||||
|
|
|
@ -472,7 +472,7 @@ void SIM_PLOT_FRAME::StartSimulation( const wxString& aSimCommand )
|
||||||
SIM_PANEL_BASE* plotPanel = currentPlotWindow();
|
SIM_PANEL_BASE* plotPanel = currentPlotWindow();
|
||||||
|
|
||||||
if( plotPanel && m_workbook->HasPlotPanel( plotPanel ) )
|
if( plotPanel && m_workbook->HasPlotPanel( plotPanel ) )
|
||||||
m_exporter->SetSimCommand( plotPanel->GetSimCommand() );
|
m_exporter->SetSimCommand( m_workbook->GetSimCommand( plotPanel ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1041,7 +1041,7 @@ bool SIM_PLOT_FRAME::saveWorkbook( const wxString& aPath )
|
||||||
for( const SIM_PANEL_BASE*& plotPanel : plotPanels )
|
for( const SIM_PANEL_BASE*& plotPanel : plotPanels )
|
||||||
{
|
{
|
||||||
file.AddLine( wxString::Format( "%d", plotPanel->GetType() ) );
|
file.AddLine( wxString::Format( "%d", plotPanel->GetType() ) );
|
||||||
file.AddLine( plotPanel->GetSimCommand() );
|
file.AddLine( m_workbook->GetSimCommand( plotPanel ) );
|
||||||
|
|
||||||
const SIM_PLOT_PANEL* panel = dynamic_cast<const SIM_PLOT_PANEL*>( plotPanel );
|
const SIM_PLOT_PANEL* panel = dynamic_cast<const SIM_PLOT_PANEL*>( plotPanel );
|
||||||
|
|
||||||
|
@ -1401,14 +1401,14 @@ void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_workbook->HasPlotPanel( plotPanelWindow ) )
|
if( m_workbook->HasPlotPanel( plotPanelWindow ) )
|
||||||
m_settingsDlg->SetSimCommand( plotPanelWindow->GetSimCommand() );
|
m_settingsDlg->SetSimCommand( m_workbook->GetSimCommand( plotPanelWindow ) );
|
||||||
|
|
||||||
if( m_settingsDlg->ShowModal() == wxID_OK )
|
if( m_settingsDlg->ShowModal() == wxID_OK )
|
||||||
{
|
{
|
||||||
wxString oldCommand;
|
wxString oldCommand;
|
||||||
|
|
||||||
if( m_workbook->HasPlotPanel( plotPanelWindow ) )
|
if( m_workbook->HasPlotPanel( plotPanelWindow ) )
|
||||||
oldCommand = plotPanelWindow->GetSimCommand();
|
oldCommand = m_workbook->GetSimCommand( plotPanelWindow );
|
||||||
else
|
else
|
||||||
oldCommand = wxString();
|
oldCommand = wxString();
|
||||||
|
|
||||||
|
@ -1428,7 +1428,7 @@ void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event )
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Update simulation command in the current plot
|
// Update simulation command in the current plot
|
||||||
plotPanelWindow->SetSimCommand( newCommand );
|
m_workbook->SetSimCommand( plotPanelWindow, newCommand );
|
||||||
}
|
}
|
||||||
|
|
||||||
m_simulator->Init();
|
m_simulator->Init();
|
||||||
|
|
|
@ -62,6 +62,16 @@ public:
|
||||||
m_plots.at( aPlotPanel ).pos = pos;
|
m_plots.at( aPlotPanel ).pos = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetSimCommand( SIM_PANEL_BASE* aPlotPanel, const wxString& aSimCommand )
|
||||||
|
{
|
||||||
|
aPlotPanel->SetSimCommand( aSimCommand );
|
||||||
|
}
|
||||||
|
|
||||||
|
const wxString& GetSimCommand( const SIM_PANEL_BASE* aPlotPanel )
|
||||||
|
{
|
||||||
|
return aPlotPanel->GetSimCommand();
|
||||||
|
}
|
||||||
|
|
||||||
void ClrModified() { m_flagModified = false; }
|
void ClrModified() { m_flagModified = false; }
|
||||||
bool IsModified() const { return m_flagModified; }
|
bool IsModified() const { return m_flagModified; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue