Remove plots that are invalid after component removal

This commit is contained in:
Maciej Suminski 2016-08-11 14:42:09 +02:00
parent 672fd76995
commit ed8f555331
2 changed files with 26 additions and 8 deletions

View File

@ -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() );
}

View File

@ -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();