Make sure to create power axis when restoring state
Fixes https://gitlab.com/kicad/code/kicad/-/issues/16912
This commit is contained in:
@@ -469,18 +469,21 @@ SIM_PLOT_TAB::~SIM_PLOT_TAB()
|
||||
|
||||
void SIM_PLOT_TAB::SetY1Scale( bool aLock, double aMin, double aMax )
|
||||
{
|
||||
wxCHECK( m_axis_y1, /* void */ );
|
||||
m_axis_y1->SetAxisMinMax( aLock, aMin, aMax );
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_TAB::SetY2Scale( bool aLock, double aMin, double aMax )
|
||||
{
|
||||
wxCHECK( m_axis_y2, /* void */ );
|
||||
m_axis_y2->SetAxisMinMax( aLock, aMin, aMax );
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_TAB::SetY3Scale( bool aLock, double aMin, double aMax )
|
||||
{
|
||||
wxCHECK( m_axis_y3, /* void */ );
|
||||
m_axis_y3->SetAxisMinMax( aLock, aMin, aMax );
|
||||
}
|
||||
|
||||
@@ -772,15 +775,8 @@ void SIM_PLOT_TAB::prepareDCAxes( int aNewTraceType )
|
||||
m_axis_y1->SetName( _( "Voltage (measured)" ) );
|
||||
m_axis_y2->SetName( _( "Current" ) );
|
||||
|
||||
if( ( aNewTraceType & SPT_POWER ) && !m_axis_y3 )
|
||||
{
|
||||
m_plotWin->SetMargins( 30, 140, 45, 70 );
|
||||
|
||||
m_axis_y3 = new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "W" ), mpALIGN_FAR_RIGHT );
|
||||
m_axis_y3->SetNameAlign( mpALIGN_FAR_RIGHT );
|
||||
m_axis_y3->SetMasterScale( m_axis_y1 );
|
||||
m_plotWin->AddLayer( m_axis_y3 );
|
||||
}
|
||||
if( ( aNewTraceType & SPT_POWER ) )
|
||||
EnsureThirdYAxisExists();
|
||||
|
||||
if( m_axis_y3 )
|
||||
m_axis_y3->SetName( _( "Power" ) );
|
||||
@@ -788,6 +784,19 @@ void SIM_PLOT_TAB::prepareDCAxes( int aNewTraceType )
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_TAB::EnsureThirdYAxisExists()
|
||||
{
|
||||
if( !m_axis_y3 )
|
||||
{
|
||||
m_plotWin->SetMargins( 30, 140, 45, 70 );
|
||||
m_axis_y3 = new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "W" ), mpALIGN_FAR_RIGHT );
|
||||
m_axis_y3->SetNameAlign( mpALIGN_FAR_RIGHT );
|
||||
m_axis_y3->SetMasterScale( m_axis_y1 );
|
||||
m_plotWin->AddLayer( m_axis_y3 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_TAB::UpdatePlotColors()
|
||||
{
|
||||
// Update bg and fg colors:
|
||||
|
||||
Reference in New Issue
Block a user