Cursors are updated on request instead of using update UI events Previously CPU was busy updating the list of cursors even though nothing was changing.
This commit is contained in:
parent
e364cfdbac
commit
8c138312fb
|
@ -86,6 +86,7 @@ SIM_PLOT_FRAME::SIM_PLOT_FRAME( KIWAY* aKiway, wxWindow* aParent )
|
|||
Connect( EVT_SIM_REPORT, wxCommandEventHandler( SIM_PLOT_FRAME::onSimReport ), NULL, this );
|
||||
Connect( EVT_SIM_STARTED, wxCommandEventHandler( SIM_PLOT_FRAME::onSimStarted ), NULL, this );
|
||||
Connect( EVT_SIM_FINISHED, wxCommandEventHandler( SIM_PLOT_FRAME::onSimFinished ), NULL, this );
|
||||
Connect( EVT_SIM_CURSOR_UPDATE, wxCommandEventHandler( SIM_PLOT_FRAME::onCursorUpdate ), NULL, this );
|
||||
|
||||
NewPlotPanel();
|
||||
}
|
||||
|
@ -216,6 +217,12 @@ void SIM_PLOT_FRAME::menuShowGridState( wxUpdateUIEvent& event )
|
|||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::onPlotChanged( wxNotebookEvent& event )
|
||||
{
|
||||
wxQueueEvent( this, new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::onSignalDblClick( wxCommandEvent& event )
|
||||
{
|
||||
int idx = m_signals->GetSelection();
|
||||
|
@ -253,29 +260,6 @@ void SIM_PLOT_FRAME::onSignalRClick( wxMouseEvent& event )
|
|||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::onCursorsUpdate( wxUpdateUIEvent& event )
|
||||
{
|
||||
wxSize size = m_cursors->GetClientSize();
|
||||
m_cursors->ClearAll();
|
||||
|
||||
const long SIGNAL_COL = m_cursors->AppendColumn( wxT( "Signal" ), wxLIST_FORMAT_LEFT, size.x / 2 );
|
||||
const long X_COL = m_cursors->AppendColumn( CurrentPlot()->GetLabelX(), wxLIST_FORMAT_LEFT, size.x / 4 );
|
||||
const long Y_COL = m_cursors->AppendColumn( CurrentPlot()->GetLabelY(), wxLIST_FORMAT_LEFT, size.x / 4 );
|
||||
|
||||
// Update cursor values
|
||||
for( const auto& trace : CurrentPlot()->GetTraces() )
|
||||
{
|
||||
if( CURSOR* cursor = trace.second->GetCursor() )
|
||||
{
|
||||
const wxRealPoint coords = cursor->GetCoords();
|
||||
long idx = m_cursors->InsertItem( SIGNAL_COL, trace.first );
|
||||
m_cursors->SetItem( idx, X_COL, wxString::Format( "%f", coords.x ) );
|
||||
m_cursors->SetItem( idx, Y_COL, wxString::Format( "%f", coords.y ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::onSimulate( wxCommandEvent& event )
|
||||
{
|
||||
if( isSimulationRunning() )
|
||||
|
@ -304,6 +288,29 @@ void SIM_PLOT_FRAME::onClose( wxCloseEvent& aEvent )
|
|||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::onCursorUpdate( wxCommandEvent& event )
|
||||
{
|
||||
wxSize size = m_cursors->GetClientSize();
|
||||
m_cursors->ClearAll();
|
||||
|
||||
const long SIGNAL_COL = m_cursors->AppendColumn( wxT( "Signal" ), wxLIST_FORMAT_LEFT, size.x / 2 );
|
||||
const long X_COL = m_cursors->AppendColumn( CurrentPlot()->GetLabelX(), wxLIST_FORMAT_LEFT, size.x / 4 );
|
||||
const long Y_COL = m_cursors->AppendColumn( CurrentPlot()->GetLabelY(), wxLIST_FORMAT_LEFT, size.x / 4 );
|
||||
|
||||
// Update cursor values
|
||||
for( const auto& trace : CurrentPlot()->GetTraces() )
|
||||
{
|
||||
if( CURSOR* cursor = trace.second->GetCursor() )
|
||||
{
|
||||
const wxRealPoint coords = cursor->GetCoords();
|
||||
long idx = m_cursors->InsertItem( SIGNAL_COL, trace.first );
|
||||
m_cursors->SetItem( idx, X_COL, wxString::Format( "%f", coords.x ) );
|
||||
m_cursors->SetItem( idx, Y_COL, wxString::Format( "%f", coords.y ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_FRAME::onSimStarted( wxCommandEvent& aEvent )
|
||||
{
|
||||
m_simulateBtn->SetLabel( wxT( "Stop" ) );
|
||||
|
@ -377,6 +384,7 @@ void SIM_PLOT_FRAME::SIGNAL_CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent )
|
|||
{
|
||||
case SHOW_SIGNAL:
|
||||
m_plotFrame->AddVoltagePlot( m_signal );
|
||||
plot->Fit();
|
||||
break;
|
||||
|
||||
break;
|
||||
|
|
|
@ -98,15 +98,17 @@ class SIM_PLOT_FRAME : public SIM_PLOT_FRAME_BASE
|
|||
void menuShowGridState( wxUpdateUIEvent& event ) override;
|
||||
|
||||
// Event handlers
|
||||
void onPlotChanged( wxNotebookEvent& event ) override;
|
||||
|
||||
void onSignalDblClick( wxCommandEvent& event ) override;
|
||||
void onSignalRClick( wxMouseEvent& event ) override;
|
||||
void onCursorsUpdate( wxUpdateUIEvent& event ) override;
|
||||
|
||||
void onSimulate( wxCommandEvent& event ) override;
|
||||
void onPlaceProbe( wxCommandEvent& event ) override;
|
||||
|
||||
void onClose( wxCloseEvent& aEvent );
|
||||
|
||||
void onCursorUpdate( wxCommandEvent& aEvent );
|
||||
void onSimStarted( wxCommandEvent& aEvent );
|
||||
void onSimFinished( wxCommandEvent& aEvent );
|
||||
void onSimReport( wxCommandEvent& aEvent );
|
||||
|
|
|
@ -73,6 +73,9 @@ void CURSOR::Plot( wxDC& aDC, mpWindow& aWindow )
|
|||
|
||||
m_coords.y = leftY + ( rightY - leftY ) / ( rightX - leftX ) * ( m_coords.x - leftX );
|
||||
m_updateRequired = false;
|
||||
|
||||
// Notify the parent window about the changes
|
||||
wxQueueEvent( aWindow.GetParent(), new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -228,6 +231,9 @@ void SIM_PLOT_PANEL::EnableCursor( const wxString& aName, bool aEnable )
|
|||
t->SetCursor( NULL );
|
||||
DelLayer( c, true );
|
||||
}
|
||||
|
||||
// Notify the parent window about the changes
|
||||
wxQueueEvent( GetParent(), new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
|
||||
}
|
||||
|
||||
|
||||
|
@ -252,3 +258,5 @@ wxColour SIM_PLOT_PANEL::generateColor()
|
|||
/// @todo generate shades to avoid repeating colors
|
||||
return wxColour( colors[m_colorIdx++ % colorCount] );
|
||||
}
|
||||
|
||||
wxDEFINE_EVENT( EVT_SIM_CURSOR_UPDATE, wxCommandEvent );
|
||||
|
|
|
@ -204,4 +204,6 @@ private:
|
|||
//mpInfoCoords* m_coords;
|
||||
};
|
||||
|
||||
wxDECLARE_EVENT( EVT_SIM_CURSOR_UPDATE, wxCommandEvent );
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue