Simulator: Use SIM_WORKBOOK in place of wxAuiNotebook
SIM_WORKBOOK is now a subclass of wxAuiNotebook, removing the problem of having to maintain two separate workbook states.
This commit is contained in:
parent
cd0c8a5676
commit
28531a982d
|
@ -50,13 +50,13 @@ public:
|
|||
SIM_TYPE GetType() const;
|
||||
|
||||
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.
|
||||
// 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; }
|
||||
const wxString& getSimCommand() const { return m_simCommand; }
|
||||
|
||||
void SetSimCommand( const wxString& aSimCommand )
|
||||
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" );
|
||||
|
|
|
@ -206,7 +206,7 @@ SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
|||
|
||||
#ifndef wxHAS_NATIVE_TABART
|
||||
// Non-native default tab art has ulgy gradients we don't want
|
||||
m_plotNotebook->SetArtProvider( new wxAuiSimpleTabArt() );
|
||||
m_workbook->SetArtProvider( new wxAuiSimpleTabArt() );
|
||||
#endif
|
||||
|
||||
// Ensure new items are taken in account by sizers:
|
||||
|
@ -304,7 +304,7 @@ WINDOW_SETTINGS* SIM_PLOT_FRAME::GetWindowSettings( APP_SETTINGS_BASE* aCfg )
|
|||
|
||||
void SIM_PLOT_FRAME::initWorkbook()
|
||||
{
|
||||
m_workbook = std::make_unique<SIM_WORKBOOK>();
|
||||
m_workbook->DeleteAllPages();
|
||||
|
||||
if( !m_simulator->Settings()->GetWorkbookFilename().IsEmpty() )
|
||||
{
|
||||
|
@ -352,15 +352,6 @@ void SIM_PLOT_FRAME::updateTitle()
|
|||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::updateWorkbook()
|
||||
{
|
||||
// We need to keep track of the plot panel positions
|
||||
for( unsigned int i = 0; i < m_plotNotebook->GetPageCount(); i++ )
|
||||
m_workbook->SetPlotPanelPosition(
|
||||
dynamic_cast<SIM_PANEL_BASE*>( m_plotNotebook->GetPage( i ) ), i );
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::updateFrame()
|
||||
{
|
||||
updateTitle();
|
||||
|
@ -471,7 +462,7 @@ void SIM_PLOT_FRAME::StartSimulation( const wxString& aSimCommand )
|
|||
{
|
||||
SIM_PANEL_BASE* plotPanel = currentPlotWindow();
|
||||
|
||||
if( plotPanel && m_workbook->HasPlotPanel( plotPanel ) )
|
||||
if( plotPanel && m_workbook->GetPageIndex( plotPanel ) != wxNOT_FOUND )
|
||||
m_exporter->SetSimCommand( m_workbook->GetSimCommand( plotPanel ) );
|
||||
}
|
||||
else
|
||||
|
@ -518,7 +509,7 @@ SIM_PANEL_BASE* SIM_PLOT_FRAME::NewPlotPanel( wxString aSimCommand )
|
|||
if( SIM_PANEL_BASE::IsPlottable( simType ) )
|
||||
{
|
||||
SIM_PLOT_PANEL* panel;
|
||||
panel = new SIM_PLOT_PANEL( aSimCommand, m_plotNotebook, this, wxID_ANY );
|
||||
panel = new SIM_PLOT_PANEL( aSimCommand, m_workbook, this, wxID_ANY );
|
||||
|
||||
panel->GetPlotWin()->EnableMouseWheelPan(
|
||||
Pgm().GetCommonSettings()->m_Input.scroll_modifier_zoom != 0 );
|
||||
|
@ -528,16 +519,14 @@ SIM_PANEL_BASE* SIM_PLOT_FRAME::NewPlotPanel( wxString aSimCommand )
|
|||
else
|
||||
{
|
||||
SIM_NOPLOT_PANEL* panel;
|
||||
panel = new SIM_NOPLOT_PANEL( aSimCommand, m_plotNotebook, wxID_ANY );
|
||||
panel = new SIM_NOPLOT_PANEL( aSimCommand, m_workbook, wxID_ANY );
|
||||
plotPanel = dynamic_cast<SIM_PANEL_BASE*>( panel );
|
||||
}
|
||||
|
||||
wxString pageTitle( m_simulator->TypeToName( simType, true ) );
|
||||
pageTitle.Prepend( wxString::Format( _( "Plot%u - " ), (unsigned int) ++m_plotNumber ) );
|
||||
|
||||
m_workbook->AddPlotPanel( plotPanel );
|
||||
|
||||
m_plotNotebook->AddPage( dynamic_cast<wxWindow*>( plotPanel ), pageTitle, true );
|
||||
m_workbook->AddPage( dynamic_cast<wxWindow*>( plotPanel ), pageTitle, true );
|
||||
|
||||
updateFrame();
|
||||
return plotPanel;
|
||||
|
@ -687,18 +676,15 @@ void SIM_PLOT_FRAME::addPlot( const wxString& aName, SIM_PLOT_TYPE aType, const
|
|||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::removePlot( const wxString& aPlotName, bool aErase )
|
||||
void SIM_PLOT_FRAME::removePlot( const wxString& aPlotName )
|
||||
{
|
||||
SIM_PLOT_PANEL* plotPanel = CurrentPlot();
|
||||
|
||||
if( !plotPanel )
|
||||
return;
|
||||
|
||||
if( aErase )
|
||||
m_workbook->RemoveTrace( plotPanel, aPlotName );
|
||||
|
||||
wxASSERT( plotPanel->TraceShown( aPlotName ) );
|
||||
plotPanel->DeleteTrace( aPlotName );
|
||||
m_workbook->DeleteTrace( plotPanel, aPlotName );
|
||||
plotPanel->GetPlotWin()->Fit();
|
||||
|
||||
updateSignalList();
|
||||
|
@ -718,7 +704,7 @@ void SIM_PLOT_FRAME::updateNetlistExporter()
|
|||
|
||||
|
||||
bool SIM_PLOT_FRAME::updatePlot( const wxString& aName, SIM_PLOT_TYPE aType, const wxString& aParam,
|
||||
SIM_PLOT_PANEL* aPanel )
|
||||
SIM_PLOT_PANEL* aPlotPanel )
|
||||
{
|
||||
SIM_TYPE simType = m_exporter->GetSimType();
|
||||
wxString spiceVector = m_exporter->ComponentToVector( aName, aType, aParam );
|
||||
|
@ -803,8 +789,9 @@ bool SIM_PLOT_FRAME::updatePlot( const wxString& aName, SIM_PLOT_TYPE aType, con
|
|||
std::vector<double> sub_y( data_y.begin() + offset,
|
||||
data_y.begin() + offset + inner );
|
||||
|
||||
if( aPanel->AddTrace( name, inner, sub_x.data(), sub_y.data(), aType, aParam ) )
|
||||
m_workbook->AddTrace( aPanel, name );
|
||||
//if( aPlotPanel->AddTrace( name, inner, sub_x.data(), sub_y.data(), aType, aParam ) )
|
||||
m_workbook->AddTrace( aPlotPanel, name, inner, sub_x.data(), sub_y.data(), aType,
|
||||
aParam );
|
||||
|
||||
v = v + source2.m_vincrement;
|
||||
offset += inner;
|
||||
|
@ -814,9 +801,8 @@ bool SIM_PLOT_FRAME::updatePlot( const wxString& aName, SIM_PLOT_TYPE aType, con
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if( aPanel->AddTrace( aName, size, data_x.data(), data_y.data(), aType, aParam ) )
|
||||
m_workbook->AddTrace( aPanel, aName );
|
||||
|
||||
m_workbook->AddTrace( aPlotPanel, aName, size, data_x.data(), data_y.data(), aType, aParam );
|
||||
|
||||
updateFrame();
|
||||
return true;
|
||||
|
@ -930,8 +916,7 @@ void SIM_PLOT_FRAME::applyTuners()
|
|||
|
||||
bool SIM_PLOT_FRAME::loadWorkbook( const wxString& aPath )
|
||||
{
|
||||
m_workbook->Clear();
|
||||
m_plotNotebook->DeleteAllPages();
|
||||
m_workbook->DeleteAllPages();
|
||||
|
||||
wxTextFile file( aPath );
|
||||
|
||||
|
@ -1034,26 +1019,26 @@ bool SIM_PLOT_FRAME::saveWorkbook( const wxString& aPath )
|
|||
file.Create();
|
||||
}
|
||||
|
||||
std::vector<const SIM_PANEL_BASE*> plotPanels = m_workbook->GetSortedPlotPanels();
|
||||
file.AddLine( wxString::Format( "%llu", m_workbook->GetPageCount() ) );
|
||||
|
||||
file.AddLine( wxString::Format( "%llu", plotPanels.size() ) );
|
||||
|
||||
for( const SIM_PANEL_BASE*& plotPanel : plotPanels )
|
||||
for( size_t i = 0; i < m_workbook->GetPageCount(); i++ )
|
||||
{
|
||||
file.AddLine( wxString::Format( "%d", plotPanel->GetType() ) );
|
||||
file.AddLine( m_workbook->GetSimCommand( plotPanel ) );
|
||||
const SIM_PANEL_BASE* basePanel = dynamic_cast<const SIM_PANEL_BASE*>( m_workbook->GetPage( i ) );
|
||||
|
||||
const SIM_PLOT_PANEL* panel = dynamic_cast<const SIM_PLOT_PANEL*>( plotPanel );
|
||||
file.AddLine( wxString::Format( "%d", basePanel->GetType() ) );
|
||||
file.AddLine( m_workbook->GetSimCommand( basePanel ) );
|
||||
|
||||
if( !panel )
|
||||
const SIM_PLOT_PANEL* plotPanel = dynamic_cast<const SIM_PLOT_PANEL*>( basePanel );
|
||||
|
||||
if( !plotPanel )
|
||||
{
|
||||
file.AddLine( wxString::Format( "%llu", 0ull ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
file.AddLine( wxString::Format( "%llu", panel->GetTraces().size() ) );
|
||||
file.AddLine( wxString::Format( "%llu", plotPanel->GetTraces().size() ) );
|
||||
|
||||
for( const auto& trace : panel->GetTraces() )
|
||||
for( const auto& trace : plotPanel->GetTraces() )
|
||||
{
|
||||
file.AddLine( wxString::Format( "%d", trace.second->GetType() ) );
|
||||
file.AddLine( trace.second->GetName() );
|
||||
|
@ -1293,9 +1278,9 @@ void SIM_PLOT_FRAME::menuWhiteBackground( wxCommandEvent& event )
|
|||
SIM_PLOT_COLORS::FillDefaultColorList( GetPlotBgOpt() );
|
||||
|
||||
// Now send changes to all SIM_PLOT_PANEL
|
||||
for( size_t page = 0; page < m_plotNotebook->GetPageCount(); page++ )
|
||||
for( size_t page = 0; page < m_workbook->GetPageCount(); page++ )
|
||||
{
|
||||
wxWindow* curPage = m_plotNotebook->GetPage( page );
|
||||
wxWindow* curPage = m_workbook->GetPage( page );
|
||||
|
||||
// ensure it is truly a plot panel and not the (zero plots) placeholder
|
||||
// which is only SIM_PLOT_PANEL_BASE
|
||||
|
@ -1314,9 +1299,6 @@ void SIM_PLOT_FRAME::onPlotClose( wxAuiNotebookEvent& event )
|
|||
if( idx == wxNOT_FOUND )
|
||||
return;
|
||||
|
||||
SIM_PANEL_BASE* plotPanel = dynamic_cast<SIM_PANEL_BASE*>( m_plotNotebook->GetPage( idx ) );
|
||||
|
||||
m_workbook->RemovePlotPanel( plotPanel );
|
||||
wxCommandEvent dummy;
|
||||
onCursorUpdate( dummy );
|
||||
}
|
||||
|
@ -1324,7 +1306,6 @@ void SIM_PLOT_FRAME::onPlotClose( wxAuiNotebookEvent& event )
|
|||
|
||||
void SIM_PLOT_FRAME::onPlotClosed( wxAuiNotebookEvent& event )
|
||||
{
|
||||
updateWorkbook();
|
||||
updateFrame();
|
||||
}
|
||||
|
||||
|
@ -1335,14 +1316,12 @@ void SIM_PLOT_FRAME::onPlotChanged( wxAuiNotebookEvent& event )
|
|||
wxCommandEvent dummy;
|
||||
onCursorUpdate( dummy );
|
||||
|
||||
updateWorkbook();
|
||||
updateFrame();
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::onPlotDragged( wxAuiNotebookEvent& event )
|
||||
{
|
||||
updateWorkbook();
|
||||
updateFrame();
|
||||
}
|
||||
|
||||
|
@ -1400,14 +1379,14 @@ void SIM_PLOT_FRAME::onSettings( wxCommandEvent& event )
|
|||
return;
|
||||
}
|
||||
|
||||
if( m_workbook->HasPlotPanel( plotPanelWindow ) )
|
||||
if( m_workbook->GetPageIndex( plotPanelWindow ) != wxNOT_FOUND )
|
||||
m_settingsDlg->SetSimCommand( m_workbook->GetSimCommand( plotPanelWindow ) );
|
||||
|
||||
if( m_settingsDlg->ShowModal() == wxID_OK )
|
||||
{
|
||||
wxString oldCommand;
|
||||
|
||||
if( m_workbook->HasPlotPanel( plotPanelWindow ) )
|
||||
if( m_workbook->GetPageIndex( plotPanelWindow ) != wxNOT_FOUND )
|
||||
oldCommand = m_workbook->GetSimCommand( plotPanelWindow );
|
||||
else
|
||||
oldCommand = wxString();
|
||||
|
@ -1681,10 +1660,7 @@ void SIM_PLOT_FRAME::onSimFinished( wxCommandEvent& aEvent )
|
|||
for( auto& trace : traceInfo )
|
||||
{
|
||||
if( !updatePlot( trace.m_name, trace.m_type, trace.m_param, plotPanel ) )
|
||||
{
|
||||
removePlot( trace.m_name, false );
|
||||
m_workbook->RemoveTrace( plotPanel, trace.m_name );
|
||||
}
|
||||
removePlot( trace.m_name );
|
||||
}
|
||||
|
||||
updateSignalList();
|
||||
|
|
|
@ -149,11 +149,6 @@ private:
|
|||
*/
|
||||
void updateTitle();
|
||||
|
||||
/**
|
||||
* Update the workbook to match the changes in the frame.
|
||||
*/
|
||||
void updateWorkbook();
|
||||
|
||||
/**
|
||||
* Update the frame to match the changes to the workbook. Should be always called after the
|
||||
* workbook was modified.
|
||||
|
@ -170,7 +165,7 @@ private:
|
|||
*/
|
||||
SIM_PANEL_BASE* currentPlotWindow() const
|
||||
{
|
||||
return dynamic_cast<SIM_PANEL_BASE*>( m_plotNotebook->GetCurrentPage() );
|
||||
return dynamic_cast<SIM_PANEL_BASE*>( m_workbook->GetCurrentPage() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -186,9 +181,8 @@ private:
|
|||
* Remove a plot with a specific title.
|
||||
*
|
||||
* @param aPlotName is the full plot title (e.g. I(Net-C1-Pad1)).
|
||||
* @param aErase decides if plot should be removed from corresponding TRACE_MAP (see m_plots).
|
||||
*/
|
||||
void removePlot( const wxString& aPlotName, bool aErase = true );
|
||||
void removePlot( const wxString& aPlotName );
|
||||
|
||||
/**
|
||||
* Reload the current schematic for the netlist exporter.
|
||||
|
@ -204,7 +198,7 @@ private:
|
|||
* @return True if a plot was successfully added/updated.
|
||||
*/
|
||||
bool updatePlot( const wxString& aName, SIM_PLOT_TYPE aType, const wxString& aParam,
|
||||
SIM_PLOT_PANEL* aPanel );
|
||||
SIM_PLOT_PANEL* aPlotPanel );
|
||||
|
||||
/**
|
||||
* Update the list of currently plotted signals.
|
||||
|
@ -315,9 +309,6 @@ private:
|
|||
std::shared_ptr<SPICE_SIMULATOR> m_simulator;
|
||||
SIM_THREAD_REPORTER* m_reporter;
|
||||
|
||||
///< Stores the data that can be preserved across simulator sessions
|
||||
std::unique_ptr<SIM_WORKBOOK> m_workbook;
|
||||
|
||||
///< List of currently displayed tuners
|
||||
std::list<TUNER_SLIDER*> m_tuners;
|
||||
|
||||
|
|
|
@ -142,11 +142,11 @@ SIM_PLOT_FRAME_BASE::SIM_PLOT_FRAME_BASE( wxWindow* parent, wxWindowID id, const
|
|||
|
||||
m_sizerPlot = new wxBoxSizer( wxHORIZONTAL );
|
||||
|
||||
m_plotNotebook = new wxAuiNotebook( m_plotPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_CLOSE_ON_ALL_TABS|wxAUI_NB_MIDDLE_CLICK_CLOSE|wxAUI_NB_TAB_MOVE|wxAUI_NB_TAB_SPLIT|wxAUI_NB_TOP );
|
||||
m_plotNotebook->SetMinSize( wxSize( 200,-1 ) );
|
||||
m_workbook = new SIM_WORKBOOK( m_plotPanel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_CLOSE_ON_ALL_TABS|wxAUI_NB_MIDDLE_CLICK_CLOSE|wxAUI_NB_TAB_MOVE|wxAUI_NB_TAB_SPLIT|wxAUI_NB_TOP );
|
||||
m_workbook->SetMinSize( wxSize( 200,-1 ) );
|
||||
|
||||
|
||||
m_sizerPlot->Add( m_plotNotebook, 1, wxEXPAND, 5 );
|
||||
m_sizerPlot->Add( m_workbook, 1, wxEXPAND, 5 );
|
||||
|
||||
|
||||
m_plotPanel->SetSizer( m_sizerPlot );
|
||||
|
@ -290,10 +290,10 @@ SIM_PLOT_FRAME_BASE::SIM_PLOT_FRAME_BASE( wxWindow* parent, wxWindowID id, const
|
|||
this->Connect( m_showDotted->GetId(), wxEVT_UPDATE_UI, wxUpdateUIEventHandler( SIM_PLOT_FRAME_BASE::menuShowDottedUpdate ) );
|
||||
m_viewMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( SIM_PLOT_FRAME_BASE::menuWhiteBackground ), this, m_showWhiteBackground->GetId());
|
||||
this->Connect( m_showWhiteBackground->GetId(), wxEVT_UPDATE_UI, wxUpdateUIEventHandler( SIM_PLOT_FRAME_BASE::menuShowWhiteBackgroundUpdate ) );
|
||||
m_plotNotebook->Connect( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotDragged ), NULL, this );
|
||||
m_plotNotebook->Connect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotChanged ), NULL, this );
|
||||
m_plotNotebook->Connect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotClose ), NULL, this );
|
||||
m_plotNotebook->Connect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotClosed ), NULL, this );
|
||||
m_workbook->Connect( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotDragged ), NULL, this );
|
||||
m_workbook->Connect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotChanged ), NULL, this );
|
||||
m_workbook->Connect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotClose ), NULL, this );
|
||||
m_workbook->Connect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotClosed ), NULL, this );
|
||||
m_signals->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( SIM_PLOT_FRAME_BASE::onSignalDblClick ), NULL, this );
|
||||
m_signals->Connect( wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, wxListEventHandler( SIM_PLOT_FRAME_BASE::onSignalRClick ), NULL, this );
|
||||
}
|
||||
|
@ -305,10 +305,10 @@ SIM_PLOT_FRAME_BASE::~SIM_PLOT_FRAME_BASE()
|
|||
this->Disconnect( ID_MENU_SHOW_LEGEND, wxEVT_UPDATE_UI, wxUpdateUIEventHandler( SIM_PLOT_FRAME_BASE::menuShowLegendUpdate ) );
|
||||
this->Disconnect( ID_MENU_DOTTED, wxEVT_UPDATE_UI, wxUpdateUIEventHandler( SIM_PLOT_FRAME_BASE::menuShowDottedUpdate ) );
|
||||
this->Disconnect( ID_MENU_WHITE_BG, wxEVT_UPDATE_UI, wxUpdateUIEventHandler( SIM_PLOT_FRAME_BASE::menuShowWhiteBackgroundUpdate ) );
|
||||
m_plotNotebook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotDragged ), NULL, this );
|
||||
m_plotNotebook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotChanged ), NULL, this );
|
||||
m_plotNotebook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotClose ), NULL, this );
|
||||
m_plotNotebook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotClosed ), NULL, this );
|
||||
m_workbook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_END_DRAG, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotDragged ), NULL, this );
|
||||
m_workbook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotChanged ), NULL, this );
|
||||
m_workbook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotClose ), NULL, this );
|
||||
m_workbook->Disconnect( wxEVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED, wxAuiNotebookEventHandler( SIM_PLOT_FRAME_BASE::onPlotClosed ), NULL, this );
|
||||
m_signals->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( SIM_PLOT_FRAME_BASE::onSignalDblClick ), NULL, this );
|
||||
m_signals->Disconnect( wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, wxListEventHandler( SIM_PLOT_FRAME_BASE::onSignalRClick ), NULL, this );
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<object class="wxMenu" expanded="1">
|
||||
<object class="wxMenu" expanded="0">
|
||||
<property name="label">File</property>
|
||||
<property name="name">m_fileMenu</property>
|
||||
<property name="permission">protected</property>
|
||||
|
@ -191,7 +191,7 @@
|
|||
<event name="OnMenuSelection">menuExit</event>
|
||||
</object>
|
||||
</object>
|
||||
<object class="wxMenu" expanded="1">
|
||||
<object class="wxMenu" expanded="0">
|
||||
<property name="label">Simulation</property>
|
||||
<property name="name">m_simulationMenu</property>
|
||||
<property name="permission">protected</property>
|
||||
|
@ -286,7 +286,7 @@
|
|||
<property name="unchecked_bitmap"></property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="wxMenu" expanded="1">
|
||||
<object class="wxMenu" expanded="0">
|
||||
<property name="label">View</property>
|
||||
<property name="name">m_viewMenu</property>
|
||||
<property name="permission">protected</property>
|
||||
|
@ -469,11 +469,11 @@
|
|||
<property name="window_style"></property>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="wxSplitterWindow" expanded="1">
|
||||
<object class="wxSplitterWindow" expanded="0">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
|
@ -530,8 +530,8 @@
|
|||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style">wxBORDER_NONE</property>
|
||||
<object class="splitteritem" expanded="1">
|
||||
<object class="wxPanel" expanded="1">
|
||||
<object class="splitteritem" expanded="0">
|
||||
<object class="wxPanel" expanded="0">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
|
@ -582,16 +582,16 @@
|
|||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style">wxTAB_TRAVERSAL</property>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<object class="wxBoxSizer" expanded="0">
|
||||
<property name="minimum_size">-1,-1</property>
|
||||
<property name="name">m_sizer11</property>
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
<property name="permission">protected</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="wxSplitterWindow" expanded="1">
|
||||
<object class="wxSplitterWindow" expanded="0">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
|
@ -648,8 +648,8 @@
|
|||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<object class="splitteritem" expanded="1">
|
||||
<object class="wxPanel" expanded="1">
|
||||
<object class="splitteritem" expanded="0">
|
||||
<object class="wxPanel" expanded="0">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
|
@ -744,7 +744,7 @@
|
|||
<property name="minimize_button">0</property>
|
||||
<property name="minimum_size">200,-1</property>
|
||||
<property name="moveable">1</property>
|
||||
<property name="name">m_plotNotebook</property>
|
||||
<property name="name">m_workbook</property>
|
||||
<property name="pane_border">1</property>
|
||||
<property name="pane_position"></property>
|
||||
<property name="pane_size"></property>
|
||||
|
@ -755,7 +755,7 @@
|
|||
<property name="show">1</property>
|
||||
<property name="size"></property>
|
||||
<property name="style">wxAUI_NB_CLOSE_ON_ALL_TABS|wxAUI_NB_MIDDLE_CLICK_CLOSE|wxAUI_NB_TAB_MOVE|wxAUI_NB_TAB_SPLIT|wxAUI_NB_TOP</property>
|
||||
<property name="subclass"></property>
|
||||
<property name="subclass">SIM_WORKBOOK; sim_workbook.h; Not forward_declare</property>
|
||||
<property name="tab_ctrl_height">-1</property>
|
||||
<property name="toolbar_pane">0</property>
|
||||
<property name="tooltip"></property>
|
||||
|
@ -772,8 +772,8 @@
|
|||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="splitteritem" expanded="1">
|
||||
<object class="wxPanel" expanded="1">
|
||||
<object class="splitteritem" expanded="0">
|
||||
<object class="wxPanel" expanded="0">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
|
@ -901,8 +901,8 @@
|
|||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="splitteritem" expanded="1">
|
||||
<object class="wxPanel" expanded="1">
|
||||
<object class="splitteritem" expanded="0">
|
||||
<object class="wxPanel" expanded="0">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
|
@ -953,16 +953,16 @@
|
|||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style">wxTAB_TRAVERSAL</property>
|
||||
<object class="wxBoxSizer" expanded="1">
|
||||
<object class="wxBoxSizer" expanded="0">
|
||||
<property name="minimum_size"></property>
|
||||
<property name="name">m_sideSizer</property>
|
||||
<property name="orient">wxVERTICAL</property>
|
||||
<property name="permission">protected</property>
|
||||
<object class="sizeritem" expanded="1">
|
||||
<object class="sizeritem" expanded="0">
|
||||
<property name="border">5</property>
|
||||
<property name="flag">wxEXPAND</property>
|
||||
<property name="proportion">1</property>
|
||||
<object class="wxSplitterWindow" expanded="1">
|
||||
<object class="wxSplitterWindow" expanded="0">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
|
@ -1019,8 +1019,8 @@
|
|||
<property name="window_extra_style"></property>
|
||||
<property name="window_name"></property>
|
||||
<property name="window_style"></property>
|
||||
<object class="splitteritem" expanded="1">
|
||||
<object class="wxPanel" expanded="1">
|
||||
<object class="splitteritem" expanded="0">
|
||||
<object class="wxPanel" expanded="0">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
|
@ -1204,8 +1204,8 @@
|
|||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="splitteritem" expanded="1">
|
||||
<object class="wxPanel" expanded="1">
|
||||
<object class="splitteritem" expanded="0">
|
||||
<object class="wxPanel" expanded="0">
|
||||
<property name="BottomDockable">1</property>
|
||||
<property name="LeftDockable">1</property>
|
||||
<property name="RightDockable">1</property>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <wx/artprov.h>
|
||||
#include <wx/xrc/xmlres.h>
|
||||
#include <wx/intl.h>
|
||||
#include "sim_workbook.h"
|
||||
#include "kiway_player.h"
|
||||
#include <wx/string.h>
|
||||
#include <wx/bitmap.h>
|
||||
|
@ -72,7 +73,7 @@ class SIM_PLOT_FRAME_BASE : public KIWAY_PLAYER
|
|||
wxSplitterWindow* m_splitterPlotAndConsole;
|
||||
wxPanel* m_plotPanel;
|
||||
wxBoxSizer* m_sizerPlot;
|
||||
wxAuiNotebook* m_plotNotebook;
|
||||
SIM_WORKBOOK* m_workbook;
|
||||
wxPanel* m_panelConsole;
|
||||
wxBoxSizer* m_sizerConsole;
|
||||
wxTextCtrl* m_simConsole;
|
||||
|
|
|
@ -386,9 +386,9 @@ void SIM_PLOT_PANEL::prepareDCAxes()
|
|||
{
|
||||
wxRegEx simCmd( "^.dc[[:space:]]+([[:alnum:]]+\\M).*", wxRE_ADVANCED | wxRE_ICASE );
|
||||
|
||||
if( simCmd.Matches( GetSimCommand() ) )
|
||||
if( simCmd.Matches( getSimCommand() ) )
|
||||
{
|
||||
switch( static_cast<char>( simCmd.GetMatch( GetSimCommand().Lower(), 1 ).GetChar( 0 ) ) )
|
||||
switch( static_cast<char>( simCmd.GetMatch( getSimCommand().Lower(), 1 ).GetChar( 0 ) ) )
|
||||
{
|
||||
case 'v':
|
||||
m_axis_x =
|
||||
|
@ -441,7 +441,7 @@ void SIM_PLOT_PANEL::UpdateTraceStyle( TRACE* trace )
|
|||
}
|
||||
|
||||
|
||||
bool SIM_PLOT_PANEL::AddTrace( const wxString& aName, int aPoints, const double* aX,
|
||||
bool SIM_PLOT_PANEL::addTrace( const wxString& aName, int aPoints, const double* aX,
|
||||
const double* aY, SIM_PLOT_TYPE aType, const wxString& aParam )
|
||||
{
|
||||
TRACE* trace = NULL;
|
||||
|
@ -526,7 +526,7 @@ bool SIM_PLOT_PANEL::AddTrace( const wxString& aName, int aPoints, const double*
|
|||
}
|
||||
|
||||
|
||||
bool SIM_PLOT_PANEL::DeleteTrace( const wxString& aName )
|
||||
bool SIM_PLOT_PANEL::deleteTrace( const wxString& aName )
|
||||
{
|
||||
auto it = m_traces.find( aName );
|
||||
|
||||
|
@ -548,11 +548,11 @@ bool SIM_PLOT_PANEL::DeleteTrace( const wxString& aName )
|
|||
}
|
||||
|
||||
|
||||
void SIM_PLOT_PANEL::DeleteAllTraces()
|
||||
void SIM_PLOT_PANEL::deleteAllTraces()
|
||||
{
|
||||
for( auto& t : m_traces )
|
||||
{
|
||||
DeleteTrace( t.first );
|
||||
deleteTrace( t.first );
|
||||
}
|
||||
|
||||
m_traces.clear();
|
||||
|
|
|
@ -175,6 +175,8 @@ private:
|
|||
|
||||
class SIM_PLOT_PANEL : public SIM_PANEL_BASE
|
||||
{
|
||||
friend class SIM_WORKBOOK;
|
||||
|
||||
public:
|
||||
SIM_PLOT_PANEL( wxString aCommand, wxWindow* parent, SIM_PLOT_FRAME* aMainFrame, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||
|
@ -203,13 +205,6 @@ public:
|
|||
return m_axis_y2 ? m_axis_y2->GetName() : "";
|
||||
}
|
||||
|
||||
bool AddTrace( const wxString& aName, int aPoints, const double* aX, const double* aY,
|
||||
SIM_PLOT_TYPE aType, const wxString& aParam );
|
||||
|
||||
bool DeleteTrace( const wxString& aName );
|
||||
|
||||
void DeleteAllTraces();
|
||||
|
||||
bool TraceShown( const wxString& aName ) const
|
||||
{
|
||||
return m_traces.count( aName ) > 0;
|
||||
|
@ -293,6 +288,14 @@ public:
|
|||
return m_plotWin;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool addTrace( const wxString& aName, int aPoints, const double* aX, const double* aY,
|
||||
SIM_PLOT_TYPE aType, const wxString& aParam );
|
||||
|
||||
bool deleteTrace( const wxString& aName );
|
||||
|
||||
void deleteAllTraces();
|
||||
|
||||
private:
|
||||
///< @brief Construct the plot axes for DC simulation plot.
|
||||
void prepareDCAxes();
|
||||
|
|
|
@ -25,61 +25,53 @@
|
|||
#include <sim/sim_workbook.h>
|
||||
|
||||
|
||||
SIM_WORKBOOK::SIM_WORKBOOK() :
|
||||
m_flagModified( false )
|
||||
SIM_WORKBOOK::SIM_WORKBOOK() = default;
|
||||
|
||||
|
||||
SIM_WORKBOOK::SIM_WORKBOOK( wxWindow* aParent, wxWindowID aId, const wxPoint& aPos, const wxSize&
|
||||
aSize, long aStyle ) : wxAuiNotebook( aParent, aId, aPos, aSize, aStyle )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void SIM_WORKBOOK::Clear()
|
||||
bool SIM_WORKBOOK::AddPage( wxWindow* page, const wxString& caption, bool select, const wxBitmap& bitmap )
|
||||
{
|
||||
m_plots.clear();
|
||||
m_modified = true;
|
||||
return wxAuiNotebook::AddPage( page, caption, select, bitmap );
|
||||
}
|
||||
|
||||
|
||||
void SIM_WORKBOOK::AddPlotPanel( SIM_PANEL_BASE* aPlotPanel )
|
||||
bool SIM_WORKBOOK::AddPage( wxWindow* page, const wxString& text, bool select, int imageId )
|
||||
{
|
||||
wxASSERT( m_plots.count( aPlotPanel ) == 0 );
|
||||
m_plots[aPlotPanel] = PLOT_INFO();
|
||||
|
||||
m_flagModified = true;
|
||||
m_modified = true;
|
||||
return wxAuiNotebook::AddPage( page, text, select, imageId );
|
||||
}
|
||||
|
||||
|
||||
void SIM_WORKBOOK::RemovePlotPanel( SIM_PANEL_BASE* aPlotPanel )
|
||||
bool SIM_WORKBOOK::DeleteAllPages()
|
||||
{
|
||||
wxASSERT( m_plots.count( aPlotPanel ) == 1 );
|
||||
m_plots.erase( aPlotPanel );
|
||||
|
||||
m_flagModified = true;
|
||||
m_modified = true;
|
||||
return wxAuiNotebook::DeleteAllPages();
|
||||
}
|
||||
|
||||
|
||||
std::vector<const SIM_PANEL_BASE*> SIM_WORKBOOK::GetSortedPlotPanels() const
|
||||
bool SIM_WORKBOOK::DeletePage( size_t page )
|
||||
{
|
||||
std::vector<const SIM_PANEL_BASE*> plotPanels;
|
||||
|
||||
for( const auto& plot : m_plots )
|
||||
plotPanels.push_back( plot.first );
|
||||
|
||||
std::sort( plotPanels.begin(), plotPanels.end(),
|
||||
[&]( const SIM_PANEL_BASE*& a, const SIM_PANEL_BASE*& b )
|
||||
{
|
||||
return m_plots.at( a ).pos < m_plots.at( b ).pos;
|
||||
});
|
||||
|
||||
return plotPanels;
|
||||
m_modified = true;
|
||||
return wxAuiNotebook::DeletePage( page );
|
||||
}
|
||||
|
||||
|
||||
void SIM_WORKBOOK::AddTrace( const SIM_PANEL_BASE* aPlotPanel, const wxString& aName )
|
||||
void SIM_WORKBOOK::AddTrace( SIM_PLOT_PANEL* aPlotPanel, const wxString& aName, int aPoints, const
|
||||
double* aX, const double* aY, SIM_PLOT_TYPE aType, const wxString& aParam )
|
||||
{
|
||||
m_flagModified = true;
|
||||
aPlotPanel->addTrace( aName, aPoints, aX, aY, aType, aParam );
|
||||
m_modified = true;
|
||||
}
|
||||
|
||||
|
||||
void SIM_WORKBOOK::RemoveTrace( const SIM_PANEL_BASE* aPlotPanel, const wxString& aName )
|
||||
void SIM_WORKBOOK::DeleteTrace( SIM_PLOT_PANEL* aPlotPanel, const wxString& aName )
|
||||
{
|
||||
m_flagModified = true;
|
||||
aPlotPanel->deleteTrace( aName );
|
||||
m_modified = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,63 +22,52 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#ifndef __SIM_WORKBOOK__
|
||||
#define __SIM_WORKBOOK__
|
||||
|
||||
#include "dialog_sim_settings.h"
|
||||
#include <sim/sim_panel_base.h>
|
||||
#include <sim/sim_plot_panel.h>
|
||||
|
||||
|
||||
class SIM_WORKBOOK
|
||||
class SIM_WORKBOOK : public wxAuiNotebook
|
||||
{
|
||||
public:
|
||||
|
||||
struct PLOT_INFO
|
||||
{
|
||||
///< The current position of the plot in the notebook
|
||||
unsigned int pos;
|
||||
};
|
||||
|
||||
SIM_WORKBOOK();
|
||||
SIM_WORKBOOK( wxWindow* aParent, wxWindowID aId=wxID_ANY, const wxPoint&
|
||||
aPos=wxDefaultPosition, const wxSize& aSize=wxDefaultSize, long
|
||||
aStyle=wxAUI_NB_DEFAULT_STYLE );
|
||||
|
||||
void Clear();
|
||||
// Methods from wxAuiNotebook
|
||||
|
||||
bool AddPage( wxWindow* aPage, const wxString& aCaption, bool aSelect=false, const wxBitmap& aBitmap=wxNullBitmap );
|
||||
bool AddPage( wxWindow* aPage, const wxString& aText, bool aSelect, int aImageId ) override;
|
||||
|
||||
void AddPlotPanel( SIM_PANEL_BASE* aPlotPanel );
|
||||
void RemovePlotPanel( SIM_PANEL_BASE* aPlotPanel );
|
||||
bool DeleteAllPages() override;
|
||||
bool DeletePage( size_t aPage ) override;
|
||||
|
||||
std::vector<const SIM_PANEL_BASE*> GetSortedPlotPanels() const;
|
||||
|
||||
bool HasPlotPanel( SIM_PANEL_BASE* aPlotPanel ) const
|
||||
{
|
||||
return m_plots.count( aPlotPanel ) == 1;
|
||||
}
|
||||
|
||||
void AddTrace( const SIM_PANEL_BASE* aPlotPanel, const wxString& aName );
|
||||
void RemoveTrace( const SIM_PANEL_BASE* aPlotPanel, const wxString& aName );
|
||||
|
||||
void SetPlotPanelPosition( const SIM_PANEL_BASE* aPlotPanel, unsigned int pos )
|
||||
{
|
||||
if( pos != m_plots.at( aPlotPanel ).pos )
|
||||
m_flagModified = true;
|
||||
|
||||
m_plots.at( aPlotPanel ).pos = pos;
|
||||
}
|
||||
// Custom methods
|
||||
|
||||
void AddTrace( SIM_PLOT_PANEL* aPlotPanel, const wxString& aName, int aPoints, const double*
|
||||
aX, const double* aY, SIM_PLOT_TYPE aType, const wxString& aParam );
|
||||
void DeleteTrace( SIM_PLOT_PANEL* aPlotPanel, const wxString& aName );
|
||||
|
||||
void SetSimCommand( SIM_PANEL_BASE* aPlotPanel, const wxString& aSimCommand )
|
||||
{
|
||||
aPlotPanel->SetSimCommand( aSimCommand );
|
||||
aPlotPanel->setSimCommand( aSimCommand );
|
||||
}
|
||||
|
||||
const wxString& GetSimCommand( const SIM_PANEL_BASE* aPlotPanel )
|
||||
{
|
||||
return aPlotPanel->GetSimCommand();
|
||||
return aPlotPanel->getSimCommand();
|
||||
}
|
||||
|
||||
void ClrModified() { m_flagModified = false; }
|
||||
bool IsModified() const { return m_flagModified; }
|
||||
void ClrModified() { m_modified = false; }
|
||||
bool IsModified() const { return m_modified; }
|
||||
|
||||
private:
|
||||
///< Dirty bit, indicates something in the workbook has changed
|
||||
bool m_flagModified;
|
||||
|
||||
///< Map of plot panels and associated data
|
||||
std::map<const SIM_PANEL_BASE*, PLOT_INFO> m_plots;
|
||||
bool m_modified;
|
||||
};
|
||||
|
||||
#endif // __SIM_WORKBOOK__
|
||||
|
|
Loading…
Reference in New Issue