Browse Source

Make sure to turn cursors off on hidden signals.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19310
pcb_db
Jeff Young 11 months ago
parent
commit
435ed59c82
  1. 44
      eeschema/sim/sim_plot_tab.cpp
  2. 6
      eeschema/sim/sim_plot_tab.h
  3. 23
      eeschema/sim/simulator_frame_ui.cpp

44
eeschema/sim/sim_plot_tab.cpp

@ -978,36 +978,34 @@ bool SIM_PLOT_TAB::DeleteTrace( const wxString& aVectorName, int aTraceType )
}
void SIM_PLOT_TAB::EnableCursor( const wxString& aVectorName, int aType, int aCursorId,
bool aEnable, const wxString& aSignalName )
void SIM_PLOT_TAB::EnableCursor( TRACE* aTrace, int aCursorId, const wxString& aSignalName )
{
TRACE* t = GetTrace( aVectorName, aType );
CURSOR* cursor = new CURSOR( aTrace, this );
mpWindow* win = GetPlotWin();
int width = win->GetXScreen() - win->GetMarginLeft() - win->GetMarginRight();
int center = win->GetMarginLeft() + KiROUND( width * ( aCursorId == 1 ? 0.4 : 0.6 ) );
if( t == nullptr || t->HasCursor( aCursorId ) == aEnable )
return;
cursor->SetName( aSignalName );
cursor->SetX( center );
if( aEnable )
{
CURSOR* cursor = new CURSOR( t, this );
mpWindow* win = GetPlotWin();
int width = win->GetXScreen() - win->GetMarginLeft() - win->GetMarginRight();
int center = win->GetMarginLeft() + KiROUND( width * ( aCursorId == 1 ? 0.4 : 0.6 ) );
aTrace->SetCursor( aCursorId, cursor );
m_plotWin->AddLayer( cursor );
cursor->SetName( aSignalName );
cursor->SetX( center );
// Notify the parent window about the changes
wxQueueEvent( this, new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
}
t->SetCursor( aCursorId, cursor );
m_plotWin->AddLayer( cursor );
}
else
void SIM_PLOT_TAB::DisableCursor( TRACE* aTrace, int aCursorId )
{
if( CURSOR* cursor = aTrace->GetCursor( aCursorId ) )
{
CURSOR* cursor = t->GetCursor( aCursorId );
t->SetCursor( aCursorId, nullptr );
m_plotWin->DelLayer( cursor, true );
}
aTrace->SetCursor( aCursorId, nullptr );
GetPlotWin()->DelLayer( cursor, true );
// Notify the parent window about the changes
wxQueueEvent( GetParent(), new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
// Notify the parent window about the changes
wxQueueEvent( this, new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
}
}

6
eeschema/sim/sim_plot_tab.h

@ -331,9 +331,9 @@ public:
return m_dotted_cp;
}
///< Toggle cursor for a particular trace.
void EnableCursor( const wxString& aVectorName, int aType, int aCursorId, bool aEnable,
const wxString& aSignalName );
///< Turn on/off the cursor for a particular trace.
void EnableCursor( TRACE* aTrace, int aCursorId, const wxString& aSignalName );
void DisableCursor( TRACE* aTrace, int aCursorId );
///< Reset scale ranges to fit the current traces.
void ResetScales( bool aIncludeX );

23
eeschema/sim/simulator_frame_ui.cpp

@ -1141,18 +1141,29 @@ void SIMULATOR_FRAME_UI::onSignalsGridCellChanged( wxGridEvent& aEvent )
}
else if( col == COL_CURSOR_1 || col == COL_CURSOR_2 )
{
for( int ii = 0; ii < m_signalsGrid->GetNumberRows(); ++ii )
int id = col == COL_CURSOR_1 ? 1 : 2;
TRACE* activeTrace = nullptr;
if( text == wxS( "1" ) )
{
signalName = m_signalsGrid->GetCellValue( ii, COL_SIGNAL_NAME );
signalName = m_signalsGrid->GetCellValue( row, COL_SIGNAL_NAME );
vectorName = vectorNameFromSignalName( plotTab, signalName, &traceType );
int id = col == COL_CURSOR_1 ? 1 : 2;
bool enable = ii == row && text == wxS( "1" );
plotTab->EnableCursor( vectorName, traceType, id, enable, signalName );
activeTrace = plotTab->GetTrace( vectorName, traceType );
plotTab->EnableCursor( activeTrace, id, signalName );
OnModify();
}
// Turn off cursor on other signals.
for( const auto& [name, trace] : plotTab->GetTraces() )
{
if( trace != activeTrace && trace->HasCursor( id ) )
{
plotTab->DisableCursor( trace, id );
OnModify();
}
}
// Update cursor checkboxes (which are really radio buttons)
updateSignalsGrid();
}

Loading…
Cancel
Save