Fixed a crash when a signal was removed
This commit is contained in:
parent
07b451f4b1
commit
973a3d7bcb
|
@ -290,6 +290,24 @@ void SIM_PLOT_FRAME::addPlot( const wxString& aName, SIM_PLOT_TYPE aType, const
|
|||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::removePlot( const wxString& aPlotName )
|
||||
{
|
||||
SIM_PLOT_PANEL* plotPanel = CurrentPlot();
|
||||
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 );
|
||||
plotPanel->Fit();
|
||||
|
||||
updateSignalList();
|
||||
updateCursors();
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::updateNetlistExporter()
|
||||
{
|
||||
m_exporter.reset( new NETLIST_EXPORTER_PSPICE_SIM( m_schematicFrame->BuildNetListBase(),
|
||||
|
@ -408,6 +426,12 @@ void SIM_PLOT_FRAME::updateTuners()
|
|||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::updateCursors()
|
||||
{
|
||||
wxQueueEvent( this, new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
|
||||
}
|
||||
|
||||
|
||||
SIM_PLOT_TYPE SIM_PLOT_FRAME::GetXAxisType( SIM_TYPE aType ) const
|
||||
{
|
||||
switch( aType )
|
||||
|
@ -554,33 +578,17 @@ void SIM_PLOT_FRAME::onPlotChanged( wxNotebookEvent& event )
|
|||
{
|
||||
updateSignalList();
|
||||
updateTuners();
|
||||
|
||||
// Update cursors
|
||||
wxQueueEvent( this, new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
|
||||
updateCursors();
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::onSignalDblClick( wxCommandEvent& event )
|
||||
{
|
||||
// Remove signal from the plot on double click
|
||||
// Remove signal from the plot panel when double clicked
|
||||
int idx = m_signals->GetSelection();
|
||||
SIM_PLOT_PANEL* plotPanel = CurrentPlot();
|
||||
|
||||
if( idx != wxNOT_FOUND )
|
||||
{
|
||||
const wxString& plotName = m_signals->GetString( idx );
|
||||
auto& traceMap = m_plots[plotPanel].m_traces;
|
||||
|
||||
auto traceIt = traceMap.find( plotName );
|
||||
wxASSERT( traceIt != traceMap.end() );
|
||||
traceMap.erase( traceIt );
|
||||
|
||||
wxASSERT( plotPanel->IsShown( plotName ) );
|
||||
plotPanel->DeleteTrace( plotName );
|
||||
plotPanel->Fit();
|
||||
|
||||
m_signals->Delete( idx );
|
||||
}
|
||||
removePlot( m_signals->GetString( idx ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -788,7 +796,7 @@ void SIM_PLOT_FRAME::SIGNAL_CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent )
|
|||
switch( aEvent.GetId() )
|
||||
{
|
||||
case HIDE_SIGNAL:
|
||||
plot->DeleteTrace( m_signal );
|
||||
m_plotFrame->removePlot( m_signal );
|
||||
break;
|
||||
|
||||
case SHOW_CURSOR:
|
||||
|
|
|
@ -136,18 +136,28 @@ class SIM_PLOT_FRAME : public SIM_PLOT_FRAME_BASE
|
|||
SIM_PLOT_PANEL* CurrentPlot() const;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Adds a new plot to the current panel.
|
||||
* @param aName is the device/net name.
|
||||
* @param aType describes the type of plot.
|
||||
* @param aParam is the parameter for the device/net (e.g. I, Id, V).
|
||||
*/
|
||||
void addPlot( const wxString& aName, SIM_PLOT_TYPE aType, const wxString& aParam );
|
||||
|
||||
/**
|
||||
* @brief Removes a plot with a specific title.
|
||||
* @param aPlotName is the full plot title (e.g. I(Net-C1-Pad1)).
|
||||
*/
|
||||
void removePlot( const wxString& aPlotName );
|
||||
|
||||
void updateNetlistExporter();
|
||||
|
||||
/**
|
||||
* @brief Updates plot in a particular SIM_PLOT_PANEL. If the panel does not contain
|
||||
* the plot, it will be added.
|
||||
* @param aName is the net/device name.
|
||||
* @param aType is the plot type (@see SIM_PLOT_TYPES).
|
||||
* @param aDescriptor contains the plot description.
|
||||
* @param aPanel is the panel that should receive the update.
|
||||
* @return True if a plot was successfully added/updated.
|
||||
* TODO update description
|
||||
*/
|
||||
bool updatePlot( const TRACE_DESC& aDescriptor, SIM_PLOT_PANEL* aPanel );
|
||||
|
||||
|
@ -161,6 +171,11 @@ class SIM_PLOT_FRAME : public SIM_PLOT_FRAME_BASE
|
|||
*/
|
||||
void updateTuners();
|
||||
|
||||
/**
|
||||
* @brief Updates the cursor values list.
|
||||
*/
|
||||
void updateCursors();
|
||||
|
||||
SIM_PLOT_TYPE GetXAxisType( SIM_TYPE aType ) const;
|
||||
|
||||
// Menu handlers
|
||||
|
|
Loading…
Reference in New Issue