diff --git a/eeschema/sim/sim_plot_panel.cpp b/eeschema/sim/sim_plot_panel.cpp index 9245a5e2c6..7dda9938db 100644 --- a/eeschema/sim/sim_plot_panel.cpp +++ b/eeschema/sim/sim_plot_panel.cpp @@ -455,6 +455,25 @@ bool SIM_PLOT_PANEL::AddTrace( const wxString& aName, int aPoints, if( addedNewEntry ) { + if ( m_type == ST_TRANSIENT ) + { + bool hasVoltageTraces = false; + + for( auto t : m_traces ) + { + if ( ! (t.second->GetFlags() & SPT_CURRENT ) ) + { + hasVoltageTraces = true; + break; + } + } + + if ( !hasVoltageTraces ) + m_axis_y2->SetMasterScale( nullptr ); + else + m_axis_y2->SetMasterScale( m_axis_y1 ); + } + // New entry t = new TRACE( aName ); t->SetPen( wxPen( generateColor(), 2, wxSOLID ) ); @@ -497,6 +516,8 @@ bool SIM_PLOT_PANEL::AddTrace( const wxString& aName, int aPoints, else t->SetScale( m_axis_x, m_axis_y1 ); + t->SetFlags( aFlags ); + UpdateAll(); return addedNewEntry; diff --git a/eeschema/sim/sim_plot_panel.h b/eeschema/sim/sim_plot_panel.h index bd337ab0ec..6db406a705 100644 --- a/eeschema/sim/sim_plot_panel.h +++ b/eeschema/sim/sim_plot_panel.h @@ -86,7 +86,7 @@ class TRACE : public mpFXYVector { public: TRACE( const wxString& aName ) : - mpFXYVector( aName ), m_cursor( nullptr ) + mpFXYVector( aName ), m_cursor( nullptr ), m_flags(0) { SetContinuity( true ); SetDrawOutsideMargins( false ); @@ -127,8 +127,19 @@ public: return m_cursor; } + void SetFlags ( int aFlags ) + { + m_flags = aFlags; + } + + int GetFlags() const + { + return m_flags; + } + protected: CURSOR* m_cursor; + int m_flags; };