From ed8f55533150bbe9e3c62a84bcf52acf9c878c92 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Thu, 11 Aug 2016 14:42:09 +0200 Subject: [PATCH] Remove plots that are invalid after component removal --- eeschema/sim/sim_plot_frame.cpp | 31 ++++++++++++++++++++++++------- eeschema/sim/sim_plot_frame.h | 3 ++- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index 8fb6b87fd7..684fe99dd7 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -316,14 +316,17 @@ void SIM_PLOT_FRAME::addPlot( const wxString& aName, SIM_PLOT_TYPE aType, const } -void SIM_PLOT_FRAME::removePlot( const wxString& aPlotName ) +void SIM_PLOT_FRAME::removePlot( const wxString& aPlotName, bool aErase ) { SIM_PLOT_PANEL* plotPanel = CurrentPlot(); - auto& traceMap = m_plots[plotPanel].m_traces; - auto traceIt = traceMap.find( aPlotName ); - wxASSERT( traceIt != traceMap.end() ); - traceMap.erase( traceIt ); + if( aErase ) + { + auto& traceMap = m_plots[plotPanel].m_traces; + auto traceIt = traceMap.find( aPlotName ); + wxASSERT( traceIt != traceMap.end() ); + traceMap.erase( traceIt ); + } wxASSERT( plotPanel->IsShown( aPlotName ) ); plotPanel->DeleteTrace( aPlotName ); @@ -799,9 +802,22 @@ void SIM_PLOT_FRAME::onSimFinished( wxCommandEvent& aEvent ) // If there are any signals plotted, update them if( SIM_PLOT_PANEL::IsPlottable( simType ) ) { - for( const auto& trace : m_plots[plotPanel].m_traces ) - updatePlot( trace.second, plotPanel ); + TRACE_MAP& traceMap = m_plots[plotPanel].m_traces; + for( auto it = traceMap.begin(); it != traceMap.end(); /* iteration occurs in the loop */) + { + if( !updatePlot( it->second, plotPanel ) ) + { + removePlot( it->first, false ); + it = traceMap.erase( it ); // remove a plot that does not exist anymore + } + else + { + ++it; + } + } + + updateSignalList(); plotPanel->UpdateAll(); plotPanel->ResetScales(); } @@ -811,6 +827,7 @@ void SIM_PLOT_FRAME::onSimFinished( wxCommandEvent& aEvent ) for( const auto& net : m_exporter->GetNetIndexMap() ) { int node = net.second; + if( node > 0 ) m_simulator->Command( wxString::Format( "print v(%d)", node ).ToStdString() ); } diff --git a/eeschema/sim/sim_plot_frame.h b/eeschema/sim/sim_plot_frame.h index 07b8ac961e..4e1bce9d83 100644 --- a/eeschema/sim/sim_plot_frame.h +++ b/eeschema/sim/sim_plot_frame.h @@ -148,8 +148,9 @@ class SIM_PLOT_FRAME : public SIM_PLOT_FRAME_BASE /** * @brief Removes 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 ); + void removePlot( const wxString& aPlotName, bool aErase = true ); void updateNetlistExporter();