Cleanup a bit

This commit is contained in:
aris-kimi 2025-06-27 22:48:05 +03:00
parent 1d7053ea62
commit 5b84d63a9b
7 changed files with 220 additions and 193 deletions

View File

@ -193,14 +193,16 @@ void DIALOG_SIM_COMMAND::SetPlotSettings( const SIM_TAB* aSimTab )
{ {
if( const SIM_PLOT_TAB* plotTab = dynamic_cast<const SIM_PLOT_TAB*>( aSimTab ) ) if( const SIM_PLOT_TAB* plotTab = dynamic_cast<const SIM_PLOT_TAB*>( aSimTab ) )
{ {
if( !plotTab->getPlotsVector()[0]->GetLabelY1().IsEmpty() ) SIM_PLOT_DIAGRAM* plotDiagram = plotTab->GetDefaultPlot();
if( !plotDiagram->GetLabelY1().IsEmpty() )
{ {
m_bSizerY1->Show( true ); m_bSizerY1->Show( true );
m_lockY1->SetLabel( wxString::Format( m_lockY1->GetLabel(), plotTab->getPlotsVector()[0]->GetLabelY1() ) ); m_lockY1->SetLabel( wxString::Format( m_lockY1->GetLabel(), plotDiagram->GetLabelY1() ) );
m_y1Units->SetLabel( plotTab->getPlotsVector()[0]->GetUnitsY1() ); m_y1Units->SetLabel( plotDiagram->GetUnitsY1() );
double min = 0.0, max = 0.0; double min = 0.0, max = 0.0;
bool locked = plotTab->getPlotsVector()[0]->GetY1Scale( &min, &max ); bool locked = plotDiagram->GetY1Scale( &min, &max );
m_lockY1->SetValue( locked ); m_lockY1->SetValue( locked );
if( !std::isnan( min ) ) if( !std::isnan( min ) )
@ -210,14 +212,14 @@ void DIALOG_SIM_COMMAND::SetPlotSettings( const SIM_TAB* aSimTab )
m_y1Max->SetValue( SIM_VALUE::Normalize( max ) ); m_y1Max->SetValue( SIM_VALUE::Normalize( max ) );
} }
if( !plotTab->getPlotsVector()[0]->GetLabelY2().IsEmpty() ) if( !plotDiagram->GetLabelY2().IsEmpty() )
{ {
m_bSizerY2->Show( true ); m_bSizerY2->Show( true );
m_lockY2->SetLabel( wxString::Format( m_lockY2->GetLabel(), plotTab->getPlotsVector()[0]->GetLabelY2() ) ); m_lockY2->SetLabel( wxString::Format( m_lockY2->GetLabel(), plotDiagram->GetLabelY2() ) );
m_y2Units->SetLabel( plotTab->getPlotsVector()[0]->GetUnitsY2() ); m_y2Units->SetLabel( plotDiagram->GetUnitsY2() );
double min = 0.0, max = 0.0; double min = 0.0, max = 0.0;
bool locked = plotTab->getPlotsVector()[0]->GetY2Scale( &min, &max ); bool locked = plotDiagram->GetY2Scale( &min, &max );
m_lockY2->SetValue( locked ); m_lockY2->SetValue( locked );
if( !std::isnan( min ) ) if( !std::isnan( min ) )
@ -227,14 +229,14 @@ void DIALOG_SIM_COMMAND::SetPlotSettings( const SIM_TAB* aSimTab )
m_y2Max->SetValue( SIM_VALUE::Normalize( max ) ); m_y2Max->SetValue( SIM_VALUE::Normalize( max ) );
} }
if( !plotTab->getPlotsVector()[0]->GetLabelY3().IsEmpty() ) if( !plotDiagram->GetLabelY3().IsEmpty() )
{ {
m_bSizerY3->Show( true ); m_bSizerY3->Show( true );
m_lockY3->SetLabel( wxString::Format( m_lockY3->GetLabel(), plotTab->getPlotsVector()[0]->GetLabelY3() ) ); m_lockY3->SetLabel( wxString::Format( m_lockY3->GetLabel(), plotDiagram->GetLabelY3() ) );
m_y3Units->SetLabel( plotTab->getPlotsVector()[0]->GetUnitsY3() ); m_y3Units->SetLabel( plotDiagram->GetUnitsY3() );
double min = 0.0, max = 0.0; double min = 0.0, max = 0.0;
bool locked = plotTab->getPlotsVector()[0]->GetY3Scale( &min, &max ); bool locked = plotDiagram->GetY3Scale( &min, &max );
m_lockY3->SetValue( locked ); m_lockY3->SetValue( locked );
if( !std::isnan( min ) ) if( !std::isnan( min ) )
@ -244,9 +246,9 @@ void DIALOG_SIM_COMMAND::SetPlotSettings( const SIM_TAB* aSimTab )
m_y3Max->SetValue( SIM_VALUE::Normalize( max ) ); m_y3Max->SetValue( SIM_VALUE::Normalize( max ) );
} }
m_grid->SetValue( plotTab->getPlotsVector()[0]->IsGridShown() ); m_grid->SetValue( plotDiagram->IsGridShown() );
m_legend->SetValue( plotTab->getPlotsVector()[0]->IsLegendShown() ); m_legend->SetValue( plotDiagram->IsLegendShown() );
m_dottedSecondary->SetValue( plotTab->getPlotsVector()[0]->GetDottedSecondary() ); m_dottedSecondary->SetValue( plotDiagram->GetDottedSecondary() );
#define GET_STR( val ) EDA_UNIT_UTILS::UI::MessageTextFromValue( unityScale, EDA_UNITS::UNSCALED, \ #define GET_STR( val ) EDA_UNIT_UTILS::UI::MessageTextFromValue( unityScale, EDA_UNITS::UNSCALED, \
val, false /* no units */ ) val, false /* no units */ )
@ -526,34 +528,38 @@ void DIALOG_SIM_COMMAND::ApplySettings( SIM_TAB* aTab )
if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( aTab ) ) if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( aTab ) )
{ {
if( !plotTab->getPlotsVector()[0]->GetLabelY1().IsEmpty() ) SIM_PLOT_DIAGRAM* plotDiagram = plotTab->GetDefaultPlot();
// clang-format off
if( !plotDiagram->GetLabelY1().IsEmpty() )
{ {
plotTab->getPlotsVector()[0]->SetY1Scale( m_lockY1->GetValue(), plotDiagram->SetY1Scale( m_lockY1->GetValue(),
SIM_VALUE::ToDouble( m_y1Min->GetValue().ToStdString() ), SIM_VALUE::ToDouble( m_y1Min->GetValue().ToStdString() ),
SIM_VALUE::ToDouble( m_y1Max->GetValue().ToStdString() ) ); SIM_VALUE::ToDouble( m_y1Max->GetValue().ToStdString() ) );
} }
if( !plotTab->getPlotsVector()[0]->GetLabelY2().IsEmpty() ) if( !plotDiagram->GetLabelY2().IsEmpty() )
{ {
plotTab->getPlotsVector()[0]->SetY2Scale( m_lockY2->GetValue(), plotDiagram->SetY2Scale( m_lockY2->GetValue(),
SIM_VALUE::ToDouble( m_y2Min->GetValue().ToStdString() ), SIM_VALUE::ToDouble( m_y2Min->GetValue().ToStdString() ),
SIM_VALUE::ToDouble( m_y2Max->GetValue().ToStdString() ) ); SIM_VALUE::ToDouble( m_y2Max->GetValue().ToStdString() ) );
} }
if( !plotTab->getPlotsVector()[0]->GetLabelY3().IsEmpty() ) if( !plotDiagram->GetLabelY3().IsEmpty() )
{ {
plotTab->getPlotsVector()[0]->SetY3Scale( m_lockY3->GetValue(), plotDiagram->SetY3Scale( m_lockY3->GetValue(),
SIM_VALUE::ToDouble( m_y3Min->GetValue().ToStdString() ), SIM_VALUE::ToDouble( m_y3Min->GetValue().ToStdString() ),
SIM_VALUE::ToDouble( m_y3Max->GetValue().ToStdString() ) ); SIM_VALUE::ToDouble( m_y3Max->GetValue().ToStdString() ) );
} }
plotTab->GetPlotWin()->LockY( m_lockY1->GetValue() plotTab->GetPlotWin()->LockY( m_lockY1->GetValue()
|| m_lockY2->GetValue() || m_lockY2->GetValue()
|| m_lockY3->GetValue() ); || m_lockY3->GetValue() );
// clang-format on
plotTab->getPlotsVector()[0]->ShowGrid( m_grid->GetValue() ); plotDiagram->ShowGrid( m_grid->GetValue() );
plotTab->getPlotsVector()[0]->ShowLegend( m_legend->GetValue() ); plotDiagram->ShowLegend( m_legend->GetValue() );
plotTab->getPlotsVector()[0]->SetDottedSecondary( m_dottedSecondary->GetValue() ); plotDiagram->SetDottedSecondary( m_dottedSecondary->GetValue() );
plotTab->GetPlotWin()->SetMarginLeft( TO_INT( m_marginLeft ) ); plotTab->GetPlotWin()->SetMarginLeft( TO_INT( m_marginLeft ) );
plotTab->GetPlotWin()->SetMarginRight( TO_INT( m_marginRight ) ); plotTab->GetPlotWin()->SetMarginRight( TO_INT( m_marginRight ) );

View File

@ -59,7 +59,7 @@ void SIMULATOR_FRAME_UI::parseTraceParams( SIM_PLOT_TAB* aPlotTab, TRACE* aTrace
wxColour color; wxColour color;
color.Set( item ); color.Set( item );
aTrace->SetTraceColour( color ); aTrace->SetTraceColour( color );
aPlotTab->getPlotsVector()[0]->UpdateTraceStyle( aTrace ); aPlotTab->GetDefaultPlot()->UpdateTraceStyle( aTrace );
} }
else if( item.StartsWith( wxS( "cursor1" ) ) ) else if( item.StartsWith( wxS( "cursor1" ) ) )
{ {
@ -99,11 +99,11 @@ void SIMULATOR_FRAME_UI::parseTraceParams( SIM_PLOT_TAB* aPlotTab, TRACE* aTrace
} }
else if( item == wxS( "dottedSecondary" ) ) else if( item == wxS( "dottedSecondary" ) )
{ {
aPlotTab->getPlotsVector()[0]->SetDottedSecondary( true ); aPlotTab->GetDefaultPlot()->SetDottedSecondary( true );
} }
else if( item == wxS( "hideGrid" ) ) else if( item == wxS( "hideGrid" ) )
{ {
aPlotTab->getPlotsVector()[0]->ShowGrid( false ); aPlotTab->GetDefaultPlot()->ShowGrid( false );
} }
} }
} }
@ -315,10 +315,10 @@ bool SIMULATOR_FRAME_UI::loadLegacyWorkbook( const wxString& aPath )
coords[0].ToLong( &x ); coords[0].ToLong( &x );
coords[1].ToLong( &y ); coords[1].ToLong( &y );
plotTab->getPlotsVector()[0]->SetLegendPosition( wxPoint( (int) x, (int) y ) ); plotTab->GetDefaultPlot()->SetLegendPosition( wxPoint( (int) x, (int) y ) );
} }
plotTab->getPlotsVector()[0]->ShowLegend( true ); plotTab->GetDefaultPlot()->ShowLegend( true );
} }
else else
{ {
@ -330,7 +330,7 @@ bool SIMULATOR_FRAME_UI::loadLegacyWorkbook( const wxString& aPath )
} }
} }
plotTab->UpdatePlotColors(); plotTab->UpdatePlotColorsFor( plotTab->GetDefaultPlot()->m_plotWin );
} }
if( SIM_TAB* simTab = GetCurrentSimTab() ) if( SIM_TAB* simTab = GetCurrentSimTab() )

View File

@ -448,6 +448,23 @@ SIM_PLOT_DIAGRAM::SIM_PLOT_DIAGRAM( wxWindow* aParent ) :
m_sizerBox = new wxStaticBoxSizer( wxVERTICAL, m_parent , sizerLabel ); m_sizerBox = new wxStaticBoxSizer( wxVERTICAL, m_parent , sizerLabel );
*/ */
m_sizerBox = new wxBoxSizer( wxVERTICAL ); m_sizerBox = new wxBoxSizer( wxVERTICAL );
m_plotWin = new mpWindow( m_parent, wxID_ANY );
m_plotWin->LimitView( true );
m_plotWin->SetMargins( 30, 70, 45, 70 );
// a mpInfoLegend displays le name of traces on the left top panel corner:
m_legend = new mpInfoLegend( wxRect( 0, 0, 200, 40 ), wxTRANSPARENT_BRUSH );
m_legend->SetVisible( false );
m_plotWin->AddLayer( m_legend );
m_LastLegendPosition = m_legend->GetPosition();
m_plotWin->EnableDoubleBuffer( true );
m_plotWin->UpdateAll();
m_sizerBox->Add( m_plotWin, 1, wxALL | wxEXPAND, 1 );
} }
@ -461,28 +478,11 @@ SIM_PLOT_TAB::SIM_PLOT_TAB( const wxString& aSimCommand, wxWindow* parent ) :
SIM_TAB( aSimCommand, parent ) SIM_TAB( aSimCommand, parent )
{ {
m_plotsVector.clear(); m_plotsVector.clear();
m_plotsVector.emplace_back( new SIM_PLOT_DIAGRAM( this ) ); // Keep one entry as the main plot for now.
m_sizerTop = new wxBoxSizer( wxVERTICAL ); m_sizerTop = new wxBoxSizer( wxVERTICAL );
m_sizerTop = m_plotsVector[0]->m_sizerBox;
m_plotsVector[0]->m_plotWin = new mpWindow( this, wxID_ANY );
m_plotsVector[0]->m_plotWin->LimitView( true ); makeNewPlotDiagram(); // Add the only main plot for now.
m_plotsVector[0]->m_plotWin->SetMargins( 30, 70, 45, 70 );
UpdatePlotColors();
updateAxes();
// a mpInfoLegend displays le name of traces on the left top panel corner:
m_plotsVector[0]->m_legend = new mpInfoLegend( wxRect( 0, 0, 200, 40 ), wxTRANSPARENT_BRUSH );
m_plotsVector[0]->m_legend->SetVisible( false );
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_legend );
m_plotsVector[0]->m_LastLegendPosition = m_plotsVector[0]->m_legend->GetPosition();
m_plotsVector[0]->m_plotWin->EnableDoubleBuffer( true );
m_plotsVector[0]->m_plotWin->UpdateAll();
m_plotsVector[0]->m_sizerBox->Add( m_plotsVector[0]->m_plotWin, 1, wxALL | wxEXPAND, 1 );
SetSizer( m_sizerTop ); SetSizer( m_sizerTop );
} }
@ -496,10 +496,18 @@ SIM_PLOT_TAB::~SIM_PLOT_TAB()
m_plotsVector.pop_back(); m_plotsVector.pop_back();
delete plot; delete plot;
} }
}
m_plotsVector.clear();
// ~mpWindow destroys all the added layers, so there is no need to destroy m_traces contents void SIM_PLOT_TAB::makeNewPlotDiagram()
{
m_plotsVector.emplace_back( new SIM_PLOT_DIAGRAM( this ) ); // Keep one entry as the main plot for now.
m_plotsVector.shrink_to_fit();
UpdatePlotColorsFor( m_plotsVector[m_plotsVector.size() - 1]->m_plotWin );
updateAxesFor( SIM_TRACE_TYPE::SPT_UNKNOWN, m_plotsVector[m_plotsVector.size() - 1] );
m_sizerTop->Add( m_plotsVector[m_plotsVector.size() - 1]->m_sizerBox, 1, wxALL | wxEXPAND, 1 );
} }
@ -571,52 +579,52 @@ wxString SIM_PLOT_DIAGRAM::GetUnitsY3() const
} }
void SIM_PLOT_TAB::updateAxes( int aNewTraceType ) void SIM_PLOT_TAB::updateAxesFor( int aNewTraceType, SIM_PLOT_DIAGRAM* aPlotDiagram )
{ {
switch( GetSimType() ) switch( GetSimType() )
{ {
case ST_AC: case ST_AC:
if( !m_plotsVector[0]->m_axis_x ) if( !aPlotDiagram->m_axis_x )
{ {
m_plotsVector[0]->SetAxisX( new LOG_SCALE<mpScaleXLog>( wxEmptyString, wxT( "Hz" ), mpALIGN_BOTTOM ) ); aPlotDiagram->SetAxisX( new LOG_SCALE<mpScaleXLog>( wxEmptyString, wxT( "Hz" ), mpALIGN_BOTTOM ) );
m_plotsVector[0]->m_axis_x->SetNameAlign( mpALIGN_BOTTOM ); aPlotDiagram->m_axis_x->SetNameAlign( mpALIGN_BOTTOM );
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_x ); aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_x );
m_plotsVector[0]->SetAxisY1( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "dB" ), mpALIGN_LEFT ) ); aPlotDiagram->SetAxisY1( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "dB" ), mpALIGN_LEFT ) );
m_plotsVector[0]->m_axis_y1->SetNameAlign( mpALIGN_LEFT ); aPlotDiagram->m_axis_y1->SetNameAlign( mpALIGN_LEFT );
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_y1 ); aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_y1 );
m_plotsVector[0]->SetAxisY2( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "°" ), mpALIGN_RIGHT ) ); aPlotDiagram->SetAxisY2( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "°" ), mpALIGN_RIGHT ) );
m_plotsVector[0]->m_axis_y2->SetNameAlign( mpALIGN_RIGHT ); aPlotDiagram->m_axis_y2->SetNameAlign( mpALIGN_RIGHT );
m_plotsVector[0]->m_axis_y2->SetMasterScale( m_plotsVector[0]->m_axis_y1 ); aPlotDiagram->m_axis_y2->SetMasterScale( aPlotDiagram->m_axis_y1 );
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_y2 ); aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_y2 );
} }
m_plotsVector[0]->m_axis_x->SetName( _( "Frequency" ) ); aPlotDiagram->m_axis_x->SetName( _( "Frequency" ) );
m_plotsVector[0]->m_axis_y1->SetName( _( "Gain" ) ); aPlotDiagram->m_axis_y1->SetName( _( "Gain" ) );
m_plotsVector[0]->m_axis_y2->SetName( _( "Phase" ) ); aPlotDiagram->m_axis_y2->SetName( _( "Phase" ) );
break; break;
case ST_SP: case ST_SP:
if( !m_plotsVector[0]->m_axis_x ) if( !aPlotDiagram->m_axis_x )
{ {
m_plotsVector[0]->SetAxisX( new LOG_SCALE<mpScaleXLog>( wxEmptyString, wxT( "Hz" ), mpALIGN_BOTTOM ) ); aPlotDiagram->SetAxisX( new LOG_SCALE<mpScaleXLog>( wxEmptyString, wxT( "Hz" ), mpALIGN_BOTTOM ) );
m_plotsVector[0]->m_axis_x->SetNameAlign( mpALIGN_BOTTOM ); aPlotDiagram->m_axis_x->SetNameAlign( mpALIGN_BOTTOM );
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_x ); aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_x );
m_plotsVector[0]->SetAxisY1( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "" ), mpALIGN_LEFT ) ); aPlotDiagram->SetAxisY1( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "" ), mpALIGN_LEFT ) );
m_plotsVector[0]->m_axis_y1->SetNameAlign( mpALIGN_LEFT ); aPlotDiagram->m_axis_y1->SetNameAlign( mpALIGN_LEFT );
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_y1 ); aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_y1 );
m_plotsVector[0]->SetAxisY2( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "°" ), mpALIGN_RIGHT ) ); aPlotDiagram->SetAxisY2( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "°" ), mpALIGN_RIGHT ) );
m_plotsVector[0]->m_axis_y2->SetNameAlign( mpALIGN_RIGHT ); aPlotDiagram->m_axis_y2->SetNameAlign( mpALIGN_RIGHT );
m_plotsVector[0]->m_axis_y2->SetMasterScale( m_plotsVector[0]->m_axis_y1 ); aPlotDiagram->m_axis_y2->SetMasterScale( aPlotDiagram->m_axis_y1 );
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_y2 ); aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_y2 );
} }
m_plotsVector[0]->m_axis_x->SetName( _( "Frequency" ) ); aPlotDiagram->m_axis_x->SetName( _( "Frequency" ) );
m_plotsVector[0]->m_axis_y1->SetName( _( "Amplitude" ) ); aPlotDiagram->m_axis_y1->SetName( _( "Amplitude" ) );
m_plotsVector[0]->m_axis_y2->SetName( _( "Phase" ) ); aPlotDiagram->m_axis_y2->SetName( _( "Phase" ) );
break; break;
case ST_DC: case ST_DC:
@ -624,85 +632,85 @@ void SIM_PLOT_TAB::updateAxes( int aNewTraceType )
break; break;
case ST_NOISE: case ST_NOISE:
if( !m_plotsVector[0]->m_axis_x ) if( !aPlotDiagram->m_axis_x )
{ {
m_plotsVector[0]->SetAxisX( new LOG_SCALE<mpScaleXLog>( wxEmptyString, wxT( "Hz" ), mpALIGN_BOTTOM ) ); aPlotDiagram->SetAxisX( new LOG_SCALE<mpScaleXLog>( wxEmptyString, wxT( "Hz" ), mpALIGN_BOTTOM ) );
m_plotsVector[0]->m_axis_x->SetNameAlign( mpALIGN_BOTTOM ); aPlotDiagram->m_axis_x->SetNameAlign( mpALIGN_BOTTOM );
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_x ); aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_x );
if( ( aNewTraceType & SPT_CURRENT ) == 0 ) if( ( aNewTraceType & SPT_CURRENT ) == 0 )
{ {
m_plotsVector[0]->SetAxisY1( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "" ), mpALIGN_LEFT ) ); aPlotDiagram->SetAxisY1( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "" ), mpALIGN_LEFT ) );
m_plotsVector[0]->m_axis_y1->SetNameAlign( mpALIGN_LEFT ); aPlotDiagram->m_axis_y1->SetNameAlign( mpALIGN_LEFT );
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_y1 ); aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_y1 );
} }
else else
{ {
m_plotsVector[0]->SetAxisY2( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "" ), mpALIGN_RIGHT ) ); aPlotDiagram->SetAxisY2( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "" ), mpALIGN_RIGHT ) );
m_plotsVector[0]->m_axis_y2->SetNameAlign( mpALIGN_RIGHT ); aPlotDiagram->m_axis_y2->SetNameAlign( mpALIGN_RIGHT );
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_y2 ); aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_y2 );
} }
} }
m_plotsVector[0]->m_axis_x->SetName( _( "Frequency" ) ); aPlotDiagram->m_axis_x->SetName( _( "Frequency" ) );
if( m_plotsVector[0]->m_axis_y1 ) if( aPlotDiagram->m_axis_y1 )
m_plotsVector[0]->m_axis_y1->SetName( _( "Noise (V/√Hz)" ) ); aPlotDiagram->m_axis_y1->SetName( _( "Noise (V/√Hz)" ) );
if( m_plotsVector[0]->m_axis_y2 ) if( aPlotDiagram->m_axis_y2 )
m_plotsVector[0]->m_axis_y2->SetName( _( "Noise (A/√Hz)" ) ); aPlotDiagram->m_axis_y2->SetName( _( "Noise (A/√Hz)" ) );
break; break;
case ST_FFT: case ST_FFT:
if( !m_plotsVector[0]->m_axis_x ) if( !aPlotDiagram->m_axis_x )
{ {
m_plotsVector[0]->SetAxisX( new LOG_SCALE<mpScaleXLog>( wxEmptyString, wxT( "Hz" ), mpALIGN_BOTTOM ) ); aPlotDiagram->SetAxisX( new LOG_SCALE<mpScaleXLog>( wxEmptyString, wxT( "Hz" ), mpALIGN_BOTTOM ) );
m_plotsVector[0]->m_axis_x->SetNameAlign( mpALIGN_BOTTOM ); aPlotDiagram->m_axis_x->SetNameAlign( mpALIGN_BOTTOM );
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_x ); aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_x );
m_plotsVector[0]->SetAxisY1( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "dB" ), mpALIGN_LEFT ) ); aPlotDiagram->SetAxisY1( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "dB" ), mpALIGN_LEFT ) );
m_plotsVector[0]->m_axis_y1->SetNameAlign( mpALIGN_LEFT ); aPlotDiagram->m_axis_y1->SetNameAlign( mpALIGN_LEFT );
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_y1 ); aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_y1 );
} }
m_plotsVector[0]->m_axis_x->SetName( _( "Frequency" ) ); aPlotDiagram->m_axis_x->SetName( _( "Frequency" ) );
m_plotsVector[0]->m_axis_y1->SetName( _( "Intensity" ) ); aPlotDiagram->m_axis_y1->SetName( _( "Intensity" ) );
break; break;
case ST_TRAN: case ST_TRAN:
if( !m_plotsVector[0]->m_axis_x ) if( !aPlotDiagram->m_axis_x )
{ {
m_plotsVector[0]->SetAxisX( new TIME_SCALE( wxEmptyString, wxT( "s" ), mpALIGN_BOTTOM ) ); aPlotDiagram->SetAxisX( new TIME_SCALE( wxEmptyString, wxT( "s" ), mpALIGN_BOTTOM ) );
m_plotsVector[0]->m_axis_x->SetNameAlign( mpALIGN_BOTTOM ); aPlotDiagram->m_axis_x->SetNameAlign( mpALIGN_BOTTOM );
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_x ); aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_x );
m_plotsVector[0]->SetAxisY1( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "V" ), mpALIGN_LEFT ) ); aPlotDiagram->SetAxisY1( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "V" ), mpALIGN_LEFT ) );
m_plotsVector[0]->m_axis_y1->SetNameAlign( mpALIGN_LEFT ); aPlotDiagram->m_axis_y1->SetNameAlign( mpALIGN_LEFT );
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_y1 ); aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_y1 );
m_plotsVector[0]->SetAxisY2( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "A" ), mpALIGN_RIGHT ) ); aPlotDiagram->SetAxisY2( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "A" ), mpALIGN_RIGHT ) );
m_plotsVector[0]->m_axis_y2->SetNameAlign( mpALIGN_RIGHT ); aPlotDiagram->m_axis_y2->SetNameAlign( mpALIGN_RIGHT );
m_plotsVector[0]->m_axis_y2->SetMasterScale( m_plotsVector[0]->m_axis_y1 ); aPlotDiagram->m_axis_y2->SetMasterScale( aPlotDiagram->m_axis_y1 );
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_y2 ); aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_y2 );
} }
m_plotsVector[0]->m_axis_x->SetName( _( "Time" ) ); aPlotDiagram->m_axis_x->SetName( _( "Time" ) );
m_plotsVector[0]->m_axis_y1->SetName( _( "Voltage" ) ); aPlotDiagram->m_axis_y1->SetName( _( "Voltage" ) );
m_plotsVector[0]->m_axis_y2->SetName( _( "Current" ) ); aPlotDiagram->m_axis_y2->SetName( _( "Current" ) );
if( ( aNewTraceType & SPT_POWER ) && !m_plotsVector[0]->m_axis_y3 ) if( ( aNewTraceType & SPT_POWER ) && !aPlotDiagram->m_axis_y3 )
{ {
m_plotsVector[0]->m_plotWin->SetMargins( 30, 140, 45, 70 ); aPlotDiagram->m_plotWin->SetMargins( 30, 140, 45, 70 );
m_plotsVector[0]->SetAxisY3( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "W" ), mpALIGN_FAR_RIGHT ) ); aPlotDiagram->SetAxisY3( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "W" ), mpALIGN_FAR_RIGHT ) );
m_plotsVector[0]->m_axis_y3->SetNameAlign( mpALIGN_FAR_RIGHT ); aPlotDiagram->m_axis_y3->SetNameAlign( mpALIGN_FAR_RIGHT );
m_plotsVector[0]->m_axis_y3->SetMasterScale( m_plotsVector[0]->m_axis_y1 ); aPlotDiagram->m_axis_y3->SetMasterScale( aPlotDiagram->m_axis_y1 );
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_y3 ); aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_y3 );
} }
if( m_plotsVector[0]->m_axis_y3 ) if( aPlotDiagram->m_axis_y3 )
m_plotsVector[0]->m_axis_y3->SetName( _( "Power" ) ); aPlotDiagram->m_axis_y3->SetName( _( "Power" ) );
break; break;
@ -711,17 +719,17 @@ void SIM_PLOT_TAB::updateAxes( int aNewTraceType )
break; break;
} }
if( m_plotsVector[0]->m_axis_x ) if( aPlotDiagram->m_axis_x )
m_plotsVector[0]->m_axis_x->SetFont( KIUI::GetStatusFont( m_plotsVector[0]->m_plotWin ) ); aPlotDiagram->m_axis_x->SetFont( KIUI::GetStatusFont( aPlotDiagram->m_plotWin ) );
if( m_plotsVector[0]->m_axis_y1 ) if( aPlotDiagram->m_axis_y1 )
m_plotsVector[0]->m_axis_y1->SetFont( KIUI::GetStatusFont( m_plotsVector[0]->m_plotWin ) ); aPlotDiagram->m_axis_y1->SetFont( KIUI::GetStatusFont( aPlotDiagram->m_plotWin ) );
if( m_plotsVector[0]->m_axis_y2 ) if( aPlotDiagram->m_axis_y2 )
m_plotsVector[0]->m_axis_y2->SetFont( KIUI::GetStatusFont( m_plotsVector[0]->m_plotWin ) ); aPlotDiagram->m_axis_y2->SetFont( KIUI::GetStatusFont( aPlotDiagram->m_plotWin ) );
if( m_plotsVector[0]->m_axis_y3 ) if( aPlotDiagram->m_axis_y3 )
m_plotsVector[0]->m_axis_y3->SetFont( KIUI::GetStatusFont( m_plotsVector[0]->m_plotWin ) ); aPlotDiagram->m_axis_y3->SetFont( KIUI::GetStatusFont( aPlotDiagram->m_plotWin ) );
} }
@ -833,20 +841,20 @@ void SIM_PLOT_TAB::EnsureThirdYAxisExists()
} }
void SIM_PLOT_TAB::UpdatePlotColors() void SIM_PLOT_TAB::UpdatePlotColorsFor( mpWindow* aPlotWindow )
{ {
// Update bg and fg colors: // Update bg and fg colors:
m_plotsVector[0]->m_plotWin->SetColourTheme( m_colors.GetPlotColor( SIM_PLOT_COLORS::COLOR_SET::BACKGROUND ), aPlotWindow->SetColourTheme( m_colors.GetPlotColor( SIM_PLOT_COLORS::COLOR_SET::BACKGROUND ),
m_colors.GetPlotColor( SIM_PLOT_COLORS::COLOR_SET::FOREGROUND ), m_colors.GetPlotColor( SIM_PLOT_COLORS::COLOR_SET::FOREGROUND ),
m_colors.GetPlotColor( SIM_PLOT_COLORS::COLOR_SET::AXIS ) ); m_colors.GetPlotColor( SIM_PLOT_COLORS::COLOR_SET::AXIS ) );
m_plotsVector[0]->m_plotWin->UpdateAll(); aPlotWindow->UpdateAll();
} }
void SIM_PLOT_TAB::OnLanguageChanged() void SIM_PLOT_TAB::OnLanguageChanged()
{ {
updateAxes(); updateAxesFor( SIM_TRACE_TYPE::SPT_UNKNOWN, m_plotsVector[0] );
m_plotsVector[0]->m_plotWin->UpdateAll(); m_plotsVector[0]->m_plotWin->UpdateAll();
} }
@ -878,7 +886,7 @@ TRACE* SIM_PLOT_TAB::GetOrAddTrace( const wxString& aVectorName, int aType )
if( !trace ) if( !trace )
{ {
updateAxes( aType ); updateAxesFor( aType, m_plotsVector[0] );
if( GetSimType() == ST_TRAN || GetSimType() == ST_DC ) if( GetSimType() == ST_TRAN || GetSimType() == ST_DC )
{ {

View File

@ -389,7 +389,7 @@ public:
void ResetScales( bool aIncludeX ); void ResetScales( bool aIncludeX );
///< Update plot colors ///< Update plot colors
void UpdatePlotColors(); void UpdatePlotColorsFor( mpWindow* aPlotWindow );
void OnLanguageChanged() override; void OnLanguageChanged() override;
@ -408,7 +408,7 @@ public:
void EnsureThirdYAxisExists(); void EnsureThirdYAxisExists();
std::vector<SIM_PLOT_DIAGRAM*> getPlotsVector() const { return m_plotsVector; } SIM_PLOT_DIAGRAM* GetDefaultPlot() const { return m_plotsVector[0]; }
void SetSessionColors( const wxString& aString, const wxColour& aColor ) { m_sessionTraceColors[aString] = aColor; } void SetSessionColors( const wxString& aString, const wxColour& aColor ) { m_sessionTraceColors[aString] = aColor; }
@ -440,7 +440,9 @@ private:
void prepareDCAxes( int aNewTraceType ); void prepareDCAxes( int aNewTraceType );
///< Create/Ensure axes are available for plotting ///< Create/Ensure axes are available for plotting
void updateAxes( int aNewTraceType = SIM_TRACE_TYPE::SPT_UNKNOWN ); void updateAxesFor( int aNewTraceType = SIM_TRACE_TYPE::SPT_UNKNOWN, SIM_PLOT_DIAGRAM* aPlotDiagram = nullptr );
void makeNewPlotDiagram();
private: private:
SIM_PLOT_COLORS m_colors; SIM_PLOT_COLORS m_colors;

View File

@ -678,21 +678,21 @@ void SIMULATOR_FRAME::setupUIConditions()
[this]( const SELECTION& aSel ) [this]( const SELECTION& aSel )
{ {
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() ); SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() );
return plotTab && plotTab->getPlotsVector()[0]->IsGridShown(); return plotTab && plotTab->GetDefaultPlot()->IsGridShown();
}; };
auto showLegendCondition = auto showLegendCondition =
[this]( const SELECTION& aSel ) [this]( const SELECTION& aSel )
{ {
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() ); SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() );
return plotTab && plotTab->getPlotsVector()[0]->IsLegendShown(); return plotTab && plotTab->GetDefaultPlot()->IsLegendShown();
}; };
auto showDottedCondition = auto showDottedCondition =
[this]( const SELECTION& aSel ) [this]( const SELECTION& aSel )
{ {
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() ); SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() );
return plotTab && plotTab->getPlotsVector()[0]->GetDottedSecondary(); return plotTab && plotTab->GetDefaultPlot()->GetDottedSecondary();
}; };
auto darkModePlotCondition = auto darkModePlotCondition =

View File

@ -1283,9 +1283,11 @@ void SIMULATOR_FRAME_UI::onSignalsGridCellChanged( wxGridEvent& aEvent )
if( trace ) if( trace )
{ {
SIM_PLOT_DIAGRAM* plotDiagram = plotTab->GetDefaultPlot();
trace->SetTraceColour( color.ToColour() ); trace->SetTraceColour( color.ToColour() );
plotTab->getPlotsVector()[0]->UpdateTraceStyle( trace ); plotDiagram->UpdateTraceStyle( trace );
plotTab->UpdatePlotColors(); plotTab->UpdatePlotColorsFor( plotDiagram->m_plotWin );
OnModify(); OnModify();
} }
} }
@ -1472,9 +1474,11 @@ void SIMULATOR_FRAME_UI::OnUpdateUI( wxUpdateUIEvent& event )
{ {
if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() ) ) if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() ) )
{ {
if( plotTab->getPlotsVector()[0]->GetLegendPosition() != plotTab->getPlotsVector()[0]->m_LastLegendPosition ) SIM_PLOT_DIAGRAM* plotDiagram = plotTab->GetDefaultPlot();
if( plotDiagram->GetLegendPosition() != plotDiagram->m_LastLegendPosition )
{ {
plotTab->getPlotsVector()[0]->m_LastLegendPosition = plotTab->getPlotsVector()[0]->GetLegendPosition(); plotDiagram->m_LastLegendPosition = plotDiagram->GetLegendPosition();
OnModify(); OnModify();
} }
} }
@ -2265,6 +2269,8 @@ bool SIMULATOR_FRAME_UI::loadJsonWorkbook( const wxString& aPath )
if( plotTab ) if( plotTab )
{ {
SIM_PLOT_DIAGRAM* plotDiagram = plotTab->GetDefaultPlot();
if( tab_js.contains( "traces" ) ) if( tab_js.contains( "traces" ) )
traceInfo[plotTab] = tab_js[ "traces" ]; traceInfo[plotTab] = tab_js[ "traces" ];
@ -2274,20 +2280,20 @@ bool SIMULATOR_FRAME_UI::loadJsonWorkbook( const wxString& aPath )
plotTab->Measurements().emplace_back( m_js[ "expr" ], m_js[ "format" ] ); plotTab->Measurements().emplace_back( m_js[ "expr" ], m_js[ "format" ] );
} }
plotTab->getPlotsVector()[0]->SetDottedSecondary( tab_js["dottedSecondary"] ); plotDiagram->SetDottedSecondary( tab_js["dottedSecondary"] );
plotTab->getPlotsVector()[0]->ShowGrid( tab_js["showGrid"] ); plotDiagram->ShowGrid( tab_js["showGrid"] );
if( tab_js.contains( "fixedY1scale" ) ) if( tab_js.contains( "fixedY1scale" ) )
{ {
const nlohmann::json& scale_js = tab_js[ "fixedY1scale" ]; const nlohmann::json& scale_js = tab_js[ "fixedY1scale" ];
plotTab->getPlotsVector()[0]->SetY1Scale( true, scale_js["min"], scale_js["max"] ); plotDiagram->SetY1Scale( true, scale_js["min"], scale_js["max"] );
plotTab->GetPlotWin()->LockY( true ); plotTab->GetPlotWin()->LockY( true );
} }
if( tab_js.contains( "fixedY2scale" ) ) if( tab_js.contains( "fixedY2scale" ) )
{ {
const nlohmann::json& scale_js = tab_js[ "fixedY2scale" ]; const nlohmann::json& scale_js = tab_js[ "fixedY2scale" ];
plotTab->getPlotsVector()[0]->SetY2Scale( true, scale_js["min"], scale_js["max"] ); plotDiagram->SetY2Scale( true, scale_js["min"], scale_js["max"] );
plotTab->GetPlotWin()->LockY( true ); plotTab->GetPlotWin()->LockY( true );
} }
@ -2295,15 +2301,15 @@ bool SIMULATOR_FRAME_UI::loadJsonWorkbook( const wxString& aPath )
{ {
plotTab->EnsureThirdYAxisExists(); plotTab->EnsureThirdYAxisExists();
const nlohmann::json& scale_js = tab_js[ "fixedY3scale" ]; const nlohmann::json& scale_js = tab_js[ "fixedY3scale" ];
plotTab->getPlotsVector()[0]->SetY3Scale( true, scale_js["min"], scale_js["max"] ); plotDiagram->SetY3Scale( true, scale_js["min"], scale_js["max"] );
plotTab->GetPlotWin()->LockY( true ); plotTab->GetPlotWin()->LockY( true );
} }
if( tab_js.contains( "legend" ) ) if( tab_js.contains( "legend" ) )
{ {
const nlohmann::json& legend_js = tab_js[ "legend" ]; const nlohmann::json& legend_js = tab_js[ "legend" ];
plotTab->getPlotsVector()[0]->SetLegendPosition( wxPoint( legend_js["x"], legend_js["y"] ) ); plotDiagram->SetLegendPosition( wxPoint( legend_js["x"], legend_js["y"] ) );
plotTab->getPlotsVector()[0]->ShowLegend( true ); plotDiagram->ShowLegend( true );
} }
if( tab_js.contains( "margins" ) ) if( tab_js.contains( "margins" ) )
@ -2386,6 +2392,8 @@ bool SIMULATOR_FRAME_UI::loadJsonWorkbook( const wxString& aPath )
for( const auto& [ plotTab, traces_js ] : traceInfo ) for( const auto& [ plotTab, traces_js ] : traceInfo )
{ {
SIM_PLOT_DIAGRAM* plotDiagram = plotTab->GetDefaultPlot();
for( const nlohmann::json& trace_js : traces_js ) for( const nlohmann::json& trace_js : traces_js )
{ {
wxString signalName = trace_js[ "signal" ]; wxString signalName = trace_js[ "signal" ];
@ -2414,12 +2422,12 @@ bool SIMULATOR_FRAME_UI::loadJsonWorkbook( const wxString& aPath )
wxColour color; wxColour color;
color.Set( wxString( trace_js["color"].get<wxString>() ) ); color.Set( wxString( trace_js["color"].get<wxString>() ) );
trace->SetTraceColour( color ); trace->SetTraceColour( color );
plotTab->getPlotsVector()[0]->UpdateTraceStyle( trace ); plotDiagram->UpdateTraceStyle( trace );
} }
} }
} }
plotTab->UpdatePlotColors(); plotTab->UpdatePlotColorsFor( plotDiagram->m_plotWin );
} }
} }
catch( nlohmann::json::parse_error& error ) catch( nlohmann::json::parse_error& error )
@ -2584,29 +2592,30 @@ bool SIMULATOR_FRAME_UI::SaveWorkbook( const wxString& aPath )
{ "format", format } } ) ); { "format", format } } ) );
} }
SIM_PLOT_DIAGRAM* plotDiagram = plotTab->GetDefaultPlot();
// clang-format off // clang-format off
tab_js[ "traces" ] = traces_js; tab_js[ "traces" ] = traces_js;
tab_js[ "measurements" ] = measurements_js; tab_js[ "measurements" ] = measurements_js;
tab_js[ "dottedSecondary" ] = plotTab->getPlotsVector()[0]->GetDottedSecondary(); tab_js[ "dottedSecondary" ] = plotDiagram->GetDottedSecondary();
tab_js[ "showGrid" ] = plotTab->getPlotsVector()[0]->IsGridShown(); tab_js[ "showGrid" ] = plotDiagram->IsGridShown();
// clang-format on // clang-format on
double min, max; double min, max;
if( plotTab->getPlotsVector()[0]->GetY1Scale( &min, &max ) ) if( plotDiagram->GetY1Scale( &min, &max ) )
tab_js[ "fixedY1scale" ] = nlohmann::json( { { "min", min }, { "max", max } } ); tab_js[ "fixedY1scale" ] = nlohmann::json( { { "min", min }, { "max", max } } );
if( plotTab->getPlotsVector()[0]->GetY2Scale( &min, &max ) ) if( plotDiagram->GetY2Scale( &min, &max ) )
tab_js[ "fixedY2scale" ] = nlohmann::json( { { "min", min }, { "max", max } } ); tab_js[ "fixedY2scale" ] = nlohmann::json( { { "min", min }, { "max", max } } );
if( plotTab->getPlotsVector()[0]->GetY3Scale( &min, &max ) ) if( plotDiagram->GetY3Scale( &min, &max ) )
tab_js[ "fixedY3scale" ] = nlohmann::json( { { "min", min }, { "max", max } } ); tab_js[ "fixedY3scale" ] = nlohmann::json( { { "min", min }, { "max", max } } );
// clang-format off // clang-format off
if( plotTab->getPlotsVector()[0]->IsLegendShown() ) if( plotDiagram->IsLegendShown() )
{ {
tab_js[ "legend" ] = nlohmann::json( { { "x", plotTab->getPlotsVector()[0]->GetLegendPosition().x }, tab_js[ "legend" ] = nlohmann::json( { { "x", plotDiagram->GetLegendPosition().x },
{ "y", plotTab->getPlotsVector()[0]->GetLegendPosition().y } } ); { "y", plotDiagram->GetLegendPosition().y } } );
} }
// clang-format on // clang-format on
@ -2759,7 +2768,7 @@ void SIMULATOR_FRAME_UI::ToggleDarkModePlots()
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( curPage ); SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( curPage );
if( plotTab ) if( plotTab )
plotTab->UpdatePlotColors(); plotTab->UpdatePlotColorsFor( plotTab->GetDefaultPlot()->m_plotWin );
} }
} }
@ -2894,6 +2903,8 @@ void SIMULATOR_FRAME_UI::updatePlotCursors()
if( !plotTab ) if( !plotTab )
return; return;
SIM_PLOT_DIAGRAM* plotDiagram = plotTab->GetDefaultPlot();
// Update cursor values // Update cursor values
CURSOR* cursor1 = nullptr; CURSOR* cursor1 = nullptr;
wxString cursor1Name; wxString cursor1Name;
@ -2908,18 +2919,18 @@ void SIMULATOR_FRAME_UI::updatePlotCursors()
if( plotTab->GetSimType() == ST_AC ) if( plotTab->GetSimType() == ST_AC )
{ {
if( aTrace->GetType() & SPT_AC_PHASE ) if( aTrace->GetType() & SPT_AC_PHASE )
return plotTab->getPlotsVector()[0]->GetUnitsY2(); return plotDiagram->GetUnitsY2();
else else
return plotTab->getPlotsVector()[0]->GetUnitsY1(); return plotDiagram->GetUnitsY1();
} }
else else
{ {
if( aTrace->GetType() & SPT_POWER ) if( aTrace->GetType() & SPT_POWER )
return plotTab->getPlotsVector()[0]->GetUnitsY3(); return plotDiagram->GetUnitsY3();
else if( aTrace->GetType() & SPT_CURRENT ) else if( aTrace->GetType() & SPT_CURRENT )
return plotTab->getPlotsVector()[0]->GetUnitsY2(); return plotDiagram->GetUnitsY2();
else else
return plotTab->getPlotsVector()[0]->GetUnitsY1(); return plotDiagram->GetUnitsY1();
} }
}; };
@ -2929,18 +2940,18 @@ void SIMULATOR_FRAME_UI::updatePlotCursors()
if( plotTab->GetSimType() == ST_AC ) if( plotTab->GetSimType() == ST_AC )
{ {
if( aTrace->GetType() & SPT_AC_PHASE ) if( aTrace->GetType() & SPT_AC_PHASE )
return plotTab->getPlotsVector()[0]->GetLabelY2(); return plotDiagram->GetLabelY2();
else else
return plotTab->getPlotsVector()[0]->GetLabelY1(); return plotDiagram->GetLabelY1();
} }
else else
{ {
if( aTrace->GetType() & SPT_POWER ) if( aTrace->GetType() & SPT_POWER )
return plotTab->getPlotsVector()[0]->GetLabelY3(); return plotDiagram->GetLabelY3();
else if( aTrace->GetType() & SPT_CURRENT ) else if( aTrace->GetType() & SPT_CURRENT )
return plotTab->getPlotsVector()[0]->GetLabelY2(); return plotDiagram->GetLabelY2();
else else
return plotTab->getPlotsVector()[0]->GetLabelY1(); return plotDiagram->GetLabelY1();
} }
}; };
@ -2964,7 +2975,7 @@ void SIMULATOR_FRAME_UI::updatePlotCursors()
wxRealPoint coords = cursor->GetCoords(); wxRealPoint coords = cursor->GetCoords();
int row = m_cursorsGrid->GetNumberRows(); int row = m_cursorsGrid->GetNumberRows();
m_cursorFormatsDyn[0][0].UpdateUnits( plotTab->getPlotsVector()[0]->GetUnitsX() ); m_cursorFormatsDyn[0][0].UpdateUnits( plotDiagram->GetUnitsX() );
m_cursorFormatsDyn[0][1].UpdateUnits( cursor1Units ); m_cursorFormatsDyn[0][1].UpdateUnits( cursor1Units );
m_cursorsGrid->AppendRows( 1 ); m_cursorsGrid->AppendRows( 1 );
@ -2987,7 +2998,7 @@ void SIMULATOR_FRAME_UI::updatePlotCursors()
wxRealPoint coords = cursor->GetCoords(); wxRealPoint coords = cursor->GetCoords();
int row = m_cursorsGrid->GetNumberRows(); int row = m_cursorsGrid->GetNumberRows();
m_cursorFormatsDyn[1][0].UpdateUnits( plotTab->getPlotsVector()[0]->GetUnitsX() ); m_cursorFormatsDyn[1][0].UpdateUnits( plotDiagram->GetUnitsX() );
m_cursorFormatsDyn[1][1].UpdateUnits( cursor2Units ); m_cursorFormatsDyn[1][1].UpdateUnits( cursor2Units );
m_cursorsGrid->AppendRows( 1 ); m_cursorsGrid->AppendRows( 1 );
@ -3004,7 +3015,7 @@ void SIMULATOR_FRAME_UI::updatePlotCursors()
wxRealPoint coords = cursor2->GetCoords() - cursor1->GetCoords(); wxRealPoint coords = cursor2->GetCoords() - cursor1->GetCoords();
wxString signal; wxString signal;
m_cursorFormatsDyn[2][0].UpdateUnits( plotTab->getPlotsVector()[0]->GetUnitsX() ); m_cursorFormatsDyn[2][0].UpdateUnits( plotDiagram->GetUnitsX() );
m_cursorFormatsDyn[2][1].UpdateUnits( cursor1Units ); m_cursorFormatsDyn[2][1].UpdateUnits( cursor1Units );
if( cursor1->GetName() == cursor2->GetName() ) if( cursor1->GetName() == cursor2->GetName() )
@ -3019,7 +3030,7 @@ void SIMULATOR_FRAME_UI::updatePlotCursors()
m_cursorsGrid->SetCellValue( 2, COL_CURSOR_Y, formatValue( coords.y, 2, 1 ) ); m_cursorsGrid->SetCellValue( 2, COL_CURSOR_Y, formatValue( coords.y, 2, 1 ) );
} }
// Set up the labels // Set up the labels
m_cursorsGrid->SetColLabelValue( COL_CURSOR_X, plotTab->getPlotsVector()[0]->GetLabelX() ); m_cursorsGrid->SetColLabelValue( COL_CURSOR_X, plotDiagram->GetLabelX() );
wxString valColName = _( "Value" ); wxString valColName = _( "Value" );
@ -3050,7 +3061,7 @@ void SIMULATOR_FRAME_UI::updatePlotCursors()
wxRealPoint coords = cursor->GetCoords(); wxRealPoint coords = cursor->GetCoords();
int row = m_cursorsGrid->GetNumberRows(); int row = m_cursorsGrid->GetNumberRows();
m_cursorFormatsDyn[i][0].UpdateUnits( plotTab->getPlotsVector()[0]->GetUnitsX() ); m_cursorFormatsDyn[i][0].UpdateUnits( plotDiagram->GetUnitsX() );
m_cursorFormatsDyn[i][1].UpdateUnits( cursUnits ); m_cursorFormatsDyn[i][1].UpdateUnits( cursUnits );
m_cursorsGrid->AppendRows( 1 ); m_cursorsGrid->AppendRows( 1 );
@ -3060,7 +3071,7 @@ void SIMULATOR_FRAME_UI::updatePlotCursors()
m_cursorsGrid->SetCellValue( row, COL_CURSOR_Y, formatValue( coords.y, i, 1 ) ); m_cursorsGrid->SetCellValue( row, COL_CURSOR_Y, formatValue( coords.y, i, 1 ) );
// Set up the labels // Set up the labels
m_cursorsGrid->SetColLabelValue( COL_CURSOR_X, plotTab->getPlotsVector()[0]->GetLabelX() ); m_cursorsGrid->SetColLabelValue( COL_CURSOR_X, plotDiagram->GetLabelX() );
valColName = _( "Value" ); valColName = _( "Value" );

View File

@ -421,7 +421,7 @@ int SIMULATOR_CONTROL::ToggleGrid( const TOOL_EVENT& aEvent )
{ {
if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( getCurrentSimTab() ) ) if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( getCurrentSimTab() ) )
{ {
plotTab->getPlotsVector()[0]->ShowGrid( !plotTab->getPlotsVector()[0]->IsGridShown() ); plotTab->GetDefaultPlot()->ShowGrid( !plotTab->GetDefaultPlot()->IsGridShown() );
m_simulatorFrame->OnModify(); m_simulatorFrame->OnModify();
} }
@ -433,7 +433,7 @@ int SIMULATOR_CONTROL::ToggleLegend( const TOOL_EVENT& aEvent )
{ {
if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( getCurrentSimTab() ) ) if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( getCurrentSimTab() ) )
{ {
plotTab->getPlotsVector()[0]->ShowLegend( !plotTab->getPlotsVector()[0]->IsLegendShown() ); plotTab->GetDefaultPlot()->ShowLegend( !plotTab->GetDefaultPlot()->IsLegendShown() );
m_simulatorFrame->OnModify(); m_simulatorFrame->OnModify();
} }
@ -445,7 +445,7 @@ int SIMULATOR_CONTROL::ToggleDottedSecondary( const TOOL_EVENT& aEvent )
{ {
if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( getCurrentSimTab() ) ) if( SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( getCurrentSimTab() ) )
{ {
plotTab->getPlotsVector()[0]->SetDottedSecondary( !plotTab->getPlotsVector()[0]->GetDottedSecondary() ); plotTab->GetDefaultPlot()->SetDottedSecondary( !plotTab->GetDefaultPlot()->GetDottedSecondary() );
m_simulatorFrame->OnModify(); m_simulatorFrame->OnModify();
} }