Make sure to create power axis when restoring state
Fixes https://gitlab.com/kicad/code/kicad/-/issues/16912
This commit is contained in:
parent
7929d7cda2
commit
ca6b40ef1c
|
@ -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:
|
||||
|
|
|
@ -353,6 +353,8 @@ public:
|
|||
|
||||
std::vector<std::pair<wxString, wxString>>& Measurements() { return m_measurements; }
|
||||
|
||||
void EnsureThirdYAxisExists();
|
||||
|
||||
public:
|
||||
wxPoint m_LastLegendPosition;
|
||||
|
||||
|
|
|
@ -1976,6 +1976,7 @@ bool SIMULATOR_FRAME_UI::loadJsonWorkbook( const wxString& aPath )
|
|||
|
||||
if( tab_js.contains( "fixedY3scale" ) )
|
||||
{
|
||||
plotTab->EnsureThirdYAxisExists();
|
||||
const nlohmann::json& scale_js = tab_js[ "fixedY3scale" ];
|
||||
plotTab->SetY3Scale( true, scale_js[ "min" ], scale_js[ "max" ] );
|
||||
plotTab->GetPlotWin()->LockY( true );
|
||||
|
|
Loading…
Reference in New Issue