mirror of
https://gitlab.com/kicad/code/kicad.git
synced 2025-09-14 10:13:19 +02:00
Cleanup a bit
This commit is contained in:
parent
1d7053ea62
commit
5b84d63a9b
@ -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( !plotTab->getPlotsVector()[0]->GetLabelY1().IsEmpty() )
|
||||
SIM_PLOT_DIAGRAM* plotDiagram = plotTab->GetDefaultPlot();
|
||||
|
||||
if( !plotDiagram->GetLabelY1().IsEmpty() )
|
||||
{
|
||||
m_bSizerY1->Show( true );
|
||||
m_lockY1->SetLabel( wxString::Format( m_lockY1->GetLabel(), plotTab->getPlotsVector()[0]->GetLabelY1() ) );
|
||||
m_y1Units->SetLabel( plotTab->getPlotsVector()[0]->GetUnitsY1() );
|
||||
m_lockY1->SetLabel( wxString::Format( m_lockY1->GetLabel(), plotDiagram->GetLabelY1() ) );
|
||||
m_y1Units->SetLabel( plotDiagram->GetUnitsY1() );
|
||||
|
||||
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 );
|
||||
|
||||
if( !std::isnan( min ) )
|
||||
@ -210,14 +212,14 @@ void DIALOG_SIM_COMMAND::SetPlotSettings( const SIM_TAB* aSimTab )
|
||||
m_y1Max->SetValue( SIM_VALUE::Normalize( max ) );
|
||||
}
|
||||
|
||||
if( !plotTab->getPlotsVector()[0]->GetLabelY2().IsEmpty() )
|
||||
if( !plotDiagram->GetLabelY2().IsEmpty() )
|
||||
{
|
||||
m_bSizerY2->Show( true );
|
||||
m_lockY2->SetLabel( wxString::Format( m_lockY2->GetLabel(), plotTab->getPlotsVector()[0]->GetLabelY2() ) );
|
||||
m_y2Units->SetLabel( plotTab->getPlotsVector()[0]->GetUnitsY2() );
|
||||
m_lockY2->SetLabel( wxString::Format( m_lockY2->GetLabel(), plotDiagram->GetLabelY2() ) );
|
||||
m_y2Units->SetLabel( plotDiagram->GetUnitsY2() );
|
||||
|
||||
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 );
|
||||
|
||||
if( !std::isnan( min ) )
|
||||
@ -227,14 +229,14 @@ void DIALOG_SIM_COMMAND::SetPlotSettings( const SIM_TAB* aSimTab )
|
||||
m_y2Max->SetValue( SIM_VALUE::Normalize( max ) );
|
||||
}
|
||||
|
||||
if( !plotTab->getPlotsVector()[0]->GetLabelY3().IsEmpty() )
|
||||
if( !plotDiagram->GetLabelY3().IsEmpty() )
|
||||
{
|
||||
m_bSizerY3->Show( true );
|
||||
m_lockY3->SetLabel( wxString::Format( m_lockY3->GetLabel(), plotTab->getPlotsVector()[0]->GetLabelY3() ) );
|
||||
m_y3Units->SetLabel( plotTab->getPlotsVector()[0]->GetUnitsY3() );
|
||||
m_lockY3->SetLabel( wxString::Format( m_lockY3->GetLabel(), plotDiagram->GetLabelY3() ) );
|
||||
m_y3Units->SetLabel( plotDiagram->GetUnitsY3() );
|
||||
|
||||
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 );
|
||||
|
||||
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_grid->SetValue( plotTab->getPlotsVector()[0]->IsGridShown() );
|
||||
m_legend->SetValue( plotTab->getPlotsVector()[0]->IsLegendShown() );
|
||||
m_dottedSecondary->SetValue( plotTab->getPlotsVector()[0]->GetDottedSecondary() );
|
||||
m_grid->SetValue( plotDiagram->IsGridShown() );
|
||||
m_legend->SetValue( plotDiagram->IsLegendShown() );
|
||||
m_dottedSecondary->SetValue( plotDiagram->GetDottedSecondary() );
|
||||
|
||||
#define GET_STR( val ) EDA_UNIT_UTILS::UI::MessageTextFromValue( unityScale, EDA_UNITS::UNSCALED, \
|
||||
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( !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(),
|
||||
SIM_VALUE::ToDouble( m_y1Min->GetValue().ToStdString() ),
|
||||
SIM_VALUE::ToDouble( m_y1Max->GetValue().ToStdString() ) );
|
||||
plotDiagram->SetY1Scale( m_lockY1->GetValue(),
|
||||
SIM_VALUE::ToDouble( m_y1Min->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(),
|
||||
SIM_VALUE::ToDouble( m_y2Min->GetValue().ToStdString() ),
|
||||
SIM_VALUE::ToDouble( m_y2Max->GetValue().ToStdString() ) );
|
||||
plotDiagram->SetY2Scale( m_lockY2->GetValue(),
|
||||
SIM_VALUE::ToDouble( m_y2Min->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(),
|
||||
SIM_VALUE::ToDouble( m_y3Min->GetValue().ToStdString() ),
|
||||
SIM_VALUE::ToDouble( m_y3Max->GetValue().ToStdString() ) );
|
||||
plotDiagram->SetY3Scale( m_lockY3->GetValue(),
|
||||
SIM_VALUE::ToDouble( m_y3Min->GetValue().ToStdString() ),
|
||||
SIM_VALUE::ToDouble( m_y3Max->GetValue().ToStdString() ) );
|
||||
}
|
||||
|
||||
plotTab->GetPlotWin()->LockY( m_lockY1->GetValue()
|
||||
|| m_lockY2->GetValue()
|
||||
|| m_lockY3->GetValue() );
|
||||
// clang-format on
|
||||
|
||||
plotTab->getPlotsVector()[0]->ShowGrid( m_grid->GetValue() );
|
||||
plotTab->getPlotsVector()[0]->ShowLegend( m_legend->GetValue() );
|
||||
plotTab->getPlotsVector()[0]->SetDottedSecondary( m_dottedSecondary->GetValue() );
|
||||
plotDiagram->ShowGrid( m_grid->GetValue() );
|
||||
plotDiagram->ShowLegend( m_legend->GetValue() );
|
||||
plotDiagram->SetDottedSecondary( m_dottedSecondary->GetValue() );
|
||||
|
||||
plotTab->GetPlotWin()->SetMarginLeft( TO_INT( m_marginLeft ) );
|
||||
plotTab->GetPlotWin()->SetMarginRight( TO_INT( m_marginRight ) );
|
||||
|
@ -59,7 +59,7 @@ void SIMULATOR_FRAME_UI::parseTraceParams( SIM_PLOT_TAB* aPlotTab, TRACE* aTrace
|
||||
wxColour color;
|
||||
color.Set( item );
|
||||
aTrace->SetTraceColour( color );
|
||||
aPlotTab->getPlotsVector()[0]->UpdateTraceStyle( aTrace );
|
||||
aPlotTab->GetDefaultPlot()->UpdateTraceStyle( aTrace );
|
||||
}
|
||||
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" ) )
|
||||
{
|
||||
aPlotTab->getPlotsVector()[0]->SetDottedSecondary( true );
|
||||
aPlotTab->GetDefaultPlot()->SetDottedSecondary( true );
|
||||
}
|
||||
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[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
|
||||
{
|
||||
@ -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() )
|
||||
|
@ -448,6 +448,23 @@ SIM_PLOT_DIAGRAM::SIM_PLOT_DIAGRAM( wxWindow* aParent ) :
|
||||
m_sizerBox = new wxStaticBoxSizer( wxVERTICAL, m_parent , sizerLabel );
|
||||
*/
|
||||
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 )
|
||||
{
|
||||
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 = m_plotsVector[0]->m_sizerBox;
|
||||
m_plotsVector[0]->m_plotWin = new mpWindow( this, wxID_ANY );
|
||||
|
||||
m_plotsVector[0]->m_plotWin->LimitView( true );
|
||||
m_plotsVector[0]->m_plotWin->SetMargins( 30, 70, 45, 70 );
|
||||
UpdatePlotColors();
|
||||
makeNewPlotDiagram(); // Add the only main plot for now.
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
@ -496,10 +496,18 @@ SIM_PLOT_TAB::~SIM_PLOT_TAB()
|
||||
m_plotsVector.pop_back();
|
||||
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() )
|
||||
{
|
||||
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 ) );
|
||||
m_plotsVector[0]->m_axis_x->SetNameAlign( mpALIGN_BOTTOM );
|
||||
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_x );
|
||||
aPlotDiagram->SetAxisX( new LOG_SCALE<mpScaleXLog>( wxEmptyString, wxT( "Hz" ), mpALIGN_BOTTOM ) );
|
||||
aPlotDiagram->m_axis_x->SetNameAlign( mpALIGN_BOTTOM );
|
||||
aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_x );
|
||||
|
||||
m_plotsVector[0]->SetAxisY1( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "dB" ), mpALIGN_LEFT ) );
|
||||
m_plotsVector[0]->m_axis_y1->SetNameAlign( mpALIGN_LEFT );
|
||||
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_y1 );
|
||||
aPlotDiagram->SetAxisY1( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "dB" ), mpALIGN_LEFT ) );
|
||||
aPlotDiagram->m_axis_y1->SetNameAlign( mpALIGN_LEFT );
|
||||
aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_y1 );
|
||||
|
||||
m_plotsVector[0]->SetAxisY2( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "°" ), mpALIGN_RIGHT ) );
|
||||
m_plotsVector[0]->m_axis_y2->SetNameAlign( mpALIGN_RIGHT );
|
||||
m_plotsVector[0]->m_axis_y2->SetMasterScale( m_plotsVector[0]->m_axis_y1 );
|
||||
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_y2 );
|
||||
aPlotDiagram->SetAxisY2( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "°" ), mpALIGN_RIGHT ) );
|
||||
aPlotDiagram->m_axis_y2->SetNameAlign( mpALIGN_RIGHT );
|
||||
aPlotDiagram->m_axis_y2->SetMasterScale( aPlotDiagram->m_axis_y1 );
|
||||
aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_y2 );
|
||||
}
|
||||
|
||||
m_plotsVector[0]->m_axis_x->SetName( _( "Frequency" ) );
|
||||
m_plotsVector[0]->m_axis_y1->SetName( _( "Gain" ) );
|
||||
m_plotsVector[0]->m_axis_y2->SetName( _( "Phase" ) );
|
||||
aPlotDiagram->m_axis_x->SetName( _( "Frequency" ) );
|
||||
aPlotDiagram->m_axis_y1->SetName( _( "Gain" ) );
|
||||
aPlotDiagram->m_axis_y2->SetName( _( "Phase" ) );
|
||||
break;
|
||||
|
||||
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 ) );
|
||||
m_plotsVector[0]->m_axis_x->SetNameAlign( mpALIGN_BOTTOM );
|
||||
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_x );
|
||||
aPlotDiagram->SetAxisX( new LOG_SCALE<mpScaleXLog>( wxEmptyString, wxT( "Hz" ), mpALIGN_BOTTOM ) );
|
||||
aPlotDiagram->m_axis_x->SetNameAlign( mpALIGN_BOTTOM );
|
||||
aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_x );
|
||||
|
||||
m_plotsVector[0]->SetAxisY1( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "" ), mpALIGN_LEFT ) );
|
||||
m_plotsVector[0]->m_axis_y1->SetNameAlign( mpALIGN_LEFT );
|
||||
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_y1 );
|
||||
aPlotDiagram->SetAxisY1( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "" ), mpALIGN_LEFT ) );
|
||||
aPlotDiagram->m_axis_y1->SetNameAlign( mpALIGN_LEFT );
|
||||
aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_y1 );
|
||||
|
||||
m_plotsVector[0]->SetAxisY2( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "°" ), mpALIGN_RIGHT ) );
|
||||
m_plotsVector[0]->m_axis_y2->SetNameAlign( mpALIGN_RIGHT );
|
||||
m_plotsVector[0]->m_axis_y2->SetMasterScale( m_plotsVector[0]->m_axis_y1 );
|
||||
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_y2 );
|
||||
aPlotDiagram->SetAxisY2( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "°" ), mpALIGN_RIGHT ) );
|
||||
aPlotDiagram->m_axis_y2->SetNameAlign( mpALIGN_RIGHT );
|
||||
aPlotDiagram->m_axis_y2->SetMasterScale( aPlotDiagram->m_axis_y1 );
|
||||
aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_y2 );
|
||||
}
|
||||
|
||||
m_plotsVector[0]->m_axis_x->SetName( _( "Frequency" ) );
|
||||
m_plotsVector[0]->m_axis_y1->SetName( _( "Amplitude" ) );
|
||||
m_plotsVector[0]->m_axis_y2->SetName( _( "Phase" ) );
|
||||
aPlotDiagram->m_axis_x->SetName( _( "Frequency" ) );
|
||||
aPlotDiagram->m_axis_y1->SetName( _( "Amplitude" ) );
|
||||
aPlotDiagram->m_axis_y2->SetName( _( "Phase" ) );
|
||||
break;
|
||||
|
||||
case ST_DC:
|
||||
@ -624,85 +632,85 @@ void SIM_PLOT_TAB::updateAxes( int aNewTraceType )
|
||||
break;
|
||||
|
||||
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 ) );
|
||||
m_plotsVector[0]->m_axis_x->SetNameAlign( mpALIGN_BOTTOM );
|
||||
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_x );
|
||||
aPlotDiagram->SetAxisX( new LOG_SCALE<mpScaleXLog>( wxEmptyString, wxT( "Hz" ), mpALIGN_BOTTOM ) );
|
||||
aPlotDiagram->m_axis_x->SetNameAlign( mpALIGN_BOTTOM );
|
||||
aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_x );
|
||||
|
||||
if( ( aNewTraceType & SPT_CURRENT ) == 0 )
|
||||
{
|
||||
m_plotsVector[0]->SetAxisY1( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "" ), mpALIGN_LEFT ) );
|
||||
m_plotsVector[0]->m_axis_y1->SetNameAlign( mpALIGN_LEFT );
|
||||
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_y1 );
|
||||
aPlotDiagram->SetAxisY1( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "" ), mpALIGN_LEFT ) );
|
||||
aPlotDiagram->m_axis_y1->SetNameAlign( mpALIGN_LEFT );
|
||||
aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_y1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_plotsVector[0]->SetAxisY2( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "" ), mpALIGN_RIGHT ) );
|
||||
m_plotsVector[0]->m_axis_y2->SetNameAlign( mpALIGN_RIGHT );
|
||||
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_y2 );
|
||||
aPlotDiagram->SetAxisY2( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "" ), mpALIGN_RIGHT ) );
|
||||
aPlotDiagram->m_axis_y2->SetNameAlign( mpALIGN_RIGHT );
|
||||
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 )
|
||||
m_plotsVector[0]->m_axis_y1->SetName( _( "Noise (V/√Hz)" ) );
|
||||
if( aPlotDiagram->m_axis_y1 )
|
||||
aPlotDiagram->m_axis_y1->SetName( _( "Noise (V/√Hz)" ) );
|
||||
|
||||
if( m_plotsVector[0]->m_axis_y2 )
|
||||
m_plotsVector[0]->m_axis_y2->SetName( _( "Noise (A/√Hz)" ) );
|
||||
if( aPlotDiagram->m_axis_y2 )
|
||||
aPlotDiagram->m_axis_y2->SetName( _( "Noise (A/√Hz)" ) );
|
||||
|
||||
break;
|
||||
|
||||
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 ) );
|
||||
m_plotsVector[0]->m_axis_x->SetNameAlign( mpALIGN_BOTTOM );
|
||||
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_x );
|
||||
aPlotDiagram->SetAxisX( new LOG_SCALE<mpScaleXLog>( wxEmptyString, wxT( "Hz" ), mpALIGN_BOTTOM ) );
|
||||
aPlotDiagram->m_axis_x->SetNameAlign( mpALIGN_BOTTOM );
|
||||
aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_x );
|
||||
|
||||
m_plotsVector[0]->SetAxisY1( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "dB" ), mpALIGN_LEFT ) );
|
||||
m_plotsVector[0]->m_axis_y1->SetNameAlign( mpALIGN_LEFT );
|
||||
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_y1 );
|
||||
aPlotDiagram->SetAxisY1( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "dB" ), mpALIGN_LEFT ) );
|
||||
aPlotDiagram->m_axis_y1->SetNameAlign( mpALIGN_LEFT );
|
||||
aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_y1 );
|
||||
}
|
||||
|
||||
m_plotsVector[0]->m_axis_x->SetName( _( "Frequency" ) );
|
||||
m_plotsVector[0]->m_axis_y1->SetName( _( "Intensity" ) );
|
||||
aPlotDiagram->m_axis_x->SetName( _( "Frequency" ) );
|
||||
aPlotDiagram->m_axis_y1->SetName( _( "Intensity" ) );
|
||||
break;
|
||||
|
||||
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 ) );
|
||||
m_plotsVector[0]->m_axis_x->SetNameAlign( mpALIGN_BOTTOM );
|
||||
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_x );
|
||||
aPlotDiagram->SetAxisX( new TIME_SCALE( wxEmptyString, wxT( "s" ), mpALIGN_BOTTOM ) );
|
||||
aPlotDiagram->m_axis_x->SetNameAlign( mpALIGN_BOTTOM );
|
||||
aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_x );
|
||||
|
||||
m_plotsVector[0]->SetAxisY1( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "V" ), mpALIGN_LEFT ) );
|
||||
m_plotsVector[0]->m_axis_y1->SetNameAlign( mpALIGN_LEFT );
|
||||
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_y1 );
|
||||
aPlotDiagram->SetAxisY1( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "V" ), mpALIGN_LEFT ) );
|
||||
aPlotDiagram->m_axis_y1->SetNameAlign( mpALIGN_LEFT );
|
||||
aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_y1 );
|
||||
|
||||
m_plotsVector[0]->SetAxisY2( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "A" ), mpALIGN_RIGHT ) );
|
||||
m_plotsVector[0]->m_axis_y2->SetNameAlign( mpALIGN_RIGHT );
|
||||
m_plotsVector[0]->m_axis_y2->SetMasterScale( m_plotsVector[0]->m_axis_y1 );
|
||||
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_y2 );
|
||||
aPlotDiagram->SetAxisY2( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "A" ), mpALIGN_RIGHT ) );
|
||||
aPlotDiagram->m_axis_y2->SetNameAlign( mpALIGN_RIGHT );
|
||||
aPlotDiagram->m_axis_y2->SetMasterScale( aPlotDiagram->m_axis_y1 );
|
||||
aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_y2 );
|
||||
}
|
||||
|
||||
m_plotsVector[0]->m_axis_x->SetName( _( "Time" ) );
|
||||
m_plotsVector[0]->m_axis_y1->SetName( _( "Voltage" ) );
|
||||
m_plotsVector[0]->m_axis_y2->SetName( _( "Current" ) );
|
||||
aPlotDiagram->m_axis_x->SetName( _( "Time" ) );
|
||||
aPlotDiagram->m_axis_y1->SetName( _( "Voltage" ) );
|
||||
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 ) );
|
||||
m_plotsVector[0]->m_axis_y3->SetNameAlign( mpALIGN_FAR_RIGHT );
|
||||
m_plotsVector[0]->m_axis_y3->SetMasterScale( m_plotsVector[0]->m_axis_y1 );
|
||||
m_plotsVector[0]->m_plotWin->AddLayer( m_plotsVector[0]->m_axis_y3 );
|
||||
aPlotDiagram->SetAxisY3( new LIN_SCALE<mpScaleY>( wxEmptyString, wxT( "W" ), mpALIGN_FAR_RIGHT ) );
|
||||
aPlotDiagram->m_axis_y3->SetNameAlign( mpALIGN_FAR_RIGHT );
|
||||
aPlotDiagram->m_axis_y3->SetMasterScale( aPlotDiagram->m_axis_y1 );
|
||||
aPlotDiagram->m_plotWin->AddLayer( aPlotDiagram->m_axis_y3 );
|
||||
}
|
||||
|
||||
if( m_plotsVector[0]->m_axis_y3 )
|
||||
m_plotsVector[0]->m_axis_y3->SetName( _( "Power" ) );
|
||||
if( aPlotDiagram->m_axis_y3 )
|
||||
aPlotDiagram->m_axis_y3->SetName( _( "Power" ) );
|
||||
|
||||
break;
|
||||
|
||||
@ -711,17 +719,17 @@ void SIM_PLOT_TAB::updateAxes( int aNewTraceType )
|
||||
break;
|
||||
}
|
||||
|
||||
if( m_plotsVector[0]->m_axis_x )
|
||||
m_plotsVector[0]->m_axis_x->SetFont( KIUI::GetStatusFont( m_plotsVector[0]->m_plotWin ) );
|
||||
if( aPlotDiagram->m_axis_x )
|
||||
aPlotDiagram->m_axis_x->SetFont( KIUI::GetStatusFont( aPlotDiagram->m_plotWin ) );
|
||||
|
||||
if( m_plotsVector[0]->m_axis_y1 )
|
||||
m_plotsVector[0]->m_axis_y1->SetFont( KIUI::GetStatusFont( m_plotsVector[0]->m_plotWin ) );
|
||||
if( aPlotDiagram->m_axis_y1 )
|
||||
aPlotDiagram->m_axis_y1->SetFont( KIUI::GetStatusFont( aPlotDiagram->m_plotWin ) );
|
||||
|
||||
if( m_plotsVector[0]->m_axis_y2 )
|
||||
m_plotsVector[0]->m_axis_y2->SetFont( KIUI::GetStatusFont( m_plotsVector[0]->m_plotWin ) );
|
||||
if( aPlotDiagram->m_axis_y2 )
|
||||
aPlotDiagram->m_axis_y2->SetFont( KIUI::GetStatusFont( aPlotDiagram->m_plotWin ) );
|
||||
|
||||
if( m_plotsVector[0]->m_axis_y3 )
|
||||
m_plotsVector[0]->m_axis_y3->SetFont( KIUI::GetStatusFont( m_plotsVector[0]->m_plotWin ) );
|
||||
if( aPlotDiagram->m_axis_y3 )
|
||||
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:
|
||||
m_plotsVector[0]->m_plotWin->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::AXIS ) );
|
||||
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::AXIS ) );
|
||||
|
||||
m_plotsVector[0]->m_plotWin->UpdateAll();
|
||||
aPlotWindow->UpdateAll();
|
||||
}
|
||||
|
||||
|
||||
void SIM_PLOT_TAB::OnLanguageChanged()
|
||||
{
|
||||
updateAxes();
|
||||
updateAxesFor( SIM_TRACE_TYPE::SPT_UNKNOWN, m_plotsVector[0] );
|
||||
m_plotsVector[0]->m_plotWin->UpdateAll();
|
||||
}
|
||||
|
||||
@ -878,7 +886,7 @@ TRACE* SIM_PLOT_TAB::GetOrAddTrace( const wxString& aVectorName, int aType )
|
||||
|
||||
if( !trace )
|
||||
{
|
||||
updateAxes( aType );
|
||||
updateAxesFor( aType, m_plotsVector[0] );
|
||||
|
||||
if( GetSimType() == ST_TRAN || GetSimType() == ST_DC )
|
||||
{
|
||||
|
@ -389,7 +389,7 @@ public:
|
||||
void ResetScales( bool aIncludeX );
|
||||
|
||||
///< Update plot colors
|
||||
void UpdatePlotColors();
|
||||
void UpdatePlotColorsFor( mpWindow* aPlotWindow );
|
||||
|
||||
void OnLanguageChanged() override;
|
||||
|
||||
@ -408,7 +408,7 @@ public:
|
||||
|
||||
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; }
|
||||
|
||||
@ -440,7 +440,9 @@ private:
|
||||
void prepareDCAxes( int aNewTraceType );
|
||||
|
||||
///< 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:
|
||||
SIM_PLOT_COLORS m_colors;
|
||||
|
@ -678,21 +678,21 @@ void SIMULATOR_FRAME::setupUIConditions()
|
||||
[this]( const SELECTION& aSel )
|
||||
{
|
||||
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() );
|
||||
return plotTab && plotTab->getPlotsVector()[0]->IsGridShown();
|
||||
return plotTab && plotTab->GetDefaultPlot()->IsGridShown();
|
||||
};
|
||||
|
||||
auto showLegendCondition =
|
||||
[this]( const SELECTION& aSel )
|
||||
{
|
||||
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() );
|
||||
return plotTab && plotTab->getPlotsVector()[0]->IsLegendShown();
|
||||
return plotTab && plotTab->GetDefaultPlot()->IsLegendShown();
|
||||
};
|
||||
|
||||
auto showDottedCondition =
|
||||
[this]( const SELECTION& aSel )
|
||||
{
|
||||
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( GetCurrentSimTab() );
|
||||
return plotTab && plotTab->getPlotsVector()[0]->GetDottedSecondary();
|
||||
return plotTab && plotTab->GetDefaultPlot()->GetDottedSecondary();
|
||||
};
|
||||
|
||||
auto darkModePlotCondition =
|
||||
|
@ -1283,9 +1283,11 @@ void SIMULATOR_FRAME_UI::onSignalsGridCellChanged( wxGridEvent& aEvent )
|
||||
|
||||
if( trace )
|
||||
{
|
||||
SIM_PLOT_DIAGRAM* plotDiagram = plotTab->GetDefaultPlot();
|
||||
|
||||
trace->SetTraceColour( color.ToColour() );
|
||||
plotTab->getPlotsVector()[0]->UpdateTraceStyle( trace );
|
||||
plotTab->UpdatePlotColors();
|
||||
plotDiagram->UpdateTraceStyle( trace );
|
||||
plotTab->UpdatePlotColorsFor( plotDiagram->m_plotWin );
|
||||
OnModify();
|
||||
}
|
||||
}
|
||||
@ -1472,9 +1474,11 @@ void SIMULATOR_FRAME_UI::OnUpdateUI( wxUpdateUIEvent& event )
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
@ -2265,6 +2269,8 @@ bool SIMULATOR_FRAME_UI::loadJsonWorkbook( const wxString& aPath )
|
||||
|
||||
if( plotTab )
|
||||
{
|
||||
SIM_PLOT_DIAGRAM* plotDiagram = plotTab->GetDefaultPlot();
|
||||
|
||||
if( tab_js.contains( "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->getPlotsVector()[0]->SetDottedSecondary( tab_js["dottedSecondary"] );
|
||||
plotTab->getPlotsVector()[0]->ShowGrid( tab_js["showGrid"] );
|
||||
plotDiagram->SetDottedSecondary( tab_js["dottedSecondary"] );
|
||||
plotDiagram->ShowGrid( tab_js["showGrid"] );
|
||||
|
||||
if( tab_js.contains( "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 );
|
||||
}
|
||||
|
||||
if( tab_js.contains( "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 );
|
||||
}
|
||||
|
||||
@ -2295,15 +2301,15 @@ bool SIMULATOR_FRAME_UI::loadJsonWorkbook( const wxString& aPath )
|
||||
{
|
||||
plotTab->EnsureThirdYAxisExists();
|
||||
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 );
|
||||
}
|
||||
|
||||
if( tab_js.contains( "legend" ) )
|
||||
{
|
||||
const nlohmann::json& legend_js = tab_js[ "legend" ];
|
||||
plotTab->getPlotsVector()[0]->SetLegendPosition( wxPoint( legend_js["x"], legend_js["y"] ) );
|
||||
plotTab->getPlotsVector()[0]->ShowLegend( true );
|
||||
plotDiagram->SetLegendPosition( wxPoint( legend_js["x"], legend_js["y"] ) );
|
||||
plotDiagram->ShowLegend( true );
|
||||
}
|
||||
|
||||
if( tab_js.contains( "margins" ) )
|
||||
@ -2386,6 +2392,8 @@ bool SIMULATOR_FRAME_UI::loadJsonWorkbook( const wxString& aPath )
|
||||
|
||||
for( const auto& [ plotTab, traces_js ] : traceInfo )
|
||||
{
|
||||
SIM_PLOT_DIAGRAM* plotDiagram = plotTab->GetDefaultPlot();
|
||||
|
||||
for( const nlohmann::json& trace_js : traces_js )
|
||||
{
|
||||
wxString signalName = trace_js[ "signal" ];
|
||||
@ -2414,12 +2422,12 @@ bool SIMULATOR_FRAME_UI::loadJsonWorkbook( const wxString& aPath )
|
||||
wxColour color;
|
||||
color.Set( wxString( trace_js["color"].get<wxString>() ) );
|
||||
trace->SetTraceColour( color );
|
||||
plotTab->getPlotsVector()[0]->UpdateTraceStyle( trace );
|
||||
plotDiagram->UpdateTraceStyle( trace );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plotTab->UpdatePlotColors();
|
||||
plotTab->UpdatePlotColorsFor( plotDiagram->m_plotWin );
|
||||
}
|
||||
}
|
||||
catch( nlohmann::json::parse_error& error )
|
||||
@ -2584,29 +2592,30 @@ bool SIMULATOR_FRAME_UI::SaveWorkbook( const wxString& aPath )
|
||||
{ "format", format } } ) );
|
||||
}
|
||||
|
||||
SIM_PLOT_DIAGRAM* plotDiagram = plotTab->GetDefaultPlot();
|
||||
// clang-format off
|
||||
tab_js[ "traces" ] = traces_js;
|
||||
tab_js[ "measurements" ] = measurements_js;
|
||||
tab_js[ "dottedSecondary" ] = plotTab->getPlotsVector()[0]->GetDottedSecondary();
|
||||
tab_js[ "showGrid" ] = plotTab->getPlotsVector()[0]->IsGridShown();
|
||||
tab_js[ "dottedSecondary" ] = plotDiagram->GetDottedSecondary();
|
||||
tab_js[ "showGrid" ] = plotDiagram->IsGridShown();
|
||||
// clang-format on
|
||||
|
||||
double min, max;
|
||||
|
||||
if( plotTab->getPlotsVector()[0]->GetY1Scale( &min, &max ) )
|
||||
if( plotDiagram->GetY1Scale( &min, &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 } } );
|
||||
|
||||
if( plotTab->getPlotsVector()[0]->GetY3Scale( &min, &max ) )
|
||||
if( plotDiagram->GetY3Scale( &min, &max ) )
|
||||
tab_js[ "fixedY3scale" ] = nlohmann::json( { { "min", min }, { "max", max } } );
|
||||
|
||||
// clang-format off
|
||||
if( plotTab->getPlotsVector()[0]->IsLegendShown() )
|
||||
if( plotDiagram->IsLegendShown() )
|
||||
{
|
||||
tab_js[ "legend" ] = nlohmann::json( { { "x", plotTab->getPlotsVector()[0]->GetLegendPosition().x },
|
||||
{ "y", plotTab->getPlotsVector()[0]->GetLegendPosition().y } } );
|
||||
tab_js[ "legend" ] = nlohmann::json( { { "x", plotDiagram->GetLegendPosition().x },
|
||||
{ "y", plotDiagram->GetLegendPosition().y } } );
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
@ -2759,7 +2768,7 @@ void SIMULATOR_FRAME_UI::ToggleDarkModePlots()
|
||||
SIM_PLOT_TAB* plotTab = dynamic_cast<SIM_PLOT_TAB*>( curPage );
|
||||
|
||||
if( plotTab )
|
||||
plotTab->UpdatePlotColors();
|
||||
plotTab->UpdatePlotColorsFor( plotTab->GetDefaultPlot()->m_plotWin );
|
||||
}
|
||||
}
|
||||
|
||||
@ -2894,6 +2903,8 @@ void SIMULATOR_FRAME_UI::updatePlotCursors()
|
||||
if( !plotTab )
|
||||
return;
|
||||
|
||||
SIM_PLOT_DIAGRAM* plotDiagram = plotTab->GetDefaultPlot();
|
||||
|
||||
// Update cursor values
|
||||
CURSOR* cursor1 = nullptr;
|
||||
wxString cursor1Name;
|
||||
@ -2908,18 +2919,18 @@ void SIMULATOR_FRAME_UI::updatePlotCursors()
|
||||
if( plotTab->GetSimType() == ST_AC )
|
||||
{
|
||||
if( aTrace->GetType() & SPT_AC_PHASE )
|
||||
return plotTab->getPlotsVector()[0]->GetUnitsY2();
|
||||
return plotDiagram->GetUnitsY2();
|
||||
else
|
||||
return plotTab->getPlotsVector()[0]->GetUnitsY1();
|
||||
return plotDiagram->GetUnitsY1();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( aTrace->GetType() & SPT_POWER )
|
||||
return plotTab->getPlotsVector()[0]->GetUnitsY3();
|
||||
return plotDiagram->GetUnitsY3();
|
||||
else if( aTrace->GetType() & SPT_CURRENT )
|
||||
return plotTab->getPlotsVector()[0]->GetUnitsY2();
|
||||
return plotDiagram->GetUnitsY2();
|
||||
else
|
||||
return plotTab->getPlotsVector()[0]->GetUnitsY1();
|
||||
return plotDiagram->GetUnitsY1();
|
||||
}
|
||||
};
|
||||
|
||||
@ -2929,18 +2940,18 @@ void SIMULATOR_FRAME_UI::updatePlotCursors()
|
||||
if( plotTab->GetSimType() == ST_AC )
|
||||
{
|
||||
if( aTrace->GetType() & SPT_AC_PHASE )
|
||||
return plotTab->getPlotsVector()[0]->GetLabelY2();
|
||||
return plotDiagram->GetLabelY2();
|
||||
else
|
||||
return plotTab->getPlotsVector()[0]->GetLabelY1();
|
||||
return plotDiagram->GetLabelY1();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( aTrace->GetType() & SPT_POWER )
|
||||
return plotTab->getPlotsVector()[0]->GetLabelY3();
|
||||
return plotDiagram->GetLabelY3();
|
||||
else if( aTrace->GetType() & SPT_CURRENT )
|
||||
return plotTab->getPlotsVector()[0]->GetLabelY2();
|
||||
return plotDiagram->GetLabelY2();
|
||||
else
|
||||
return plotTab->getPlotsVector()[0]->GetLabelY1();
|
||||
return plotDiagram->GetLabelY1();
|
||||
}
|
||||
};
|
||||
|
||||
@ -2964,7 +2975,7 @@ void SIMULATOR_FRAME_UI::updatePlotCursors()
|
||||
wxRealPoint coords = cursor->GetCoords();
|
||||
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_cursorsGrid->AppendRows( 1 );
|
||||
@ -2987,7 +2998,7 @@ void SIMULATOR_FRAME_UI::updatePlotCursors()
|
||||
wxRealPoint coords = cursor->GetCoords();
|
||||
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_cursorsGrid->AppendRows( 1 );
|
||||
@ -3004,7 +3015,7 @@ void SIMULATOR_FRAME_UI::updatePlotCursors()
|
||||
wxRealPoint coords = cursor2->GetCoords() - cursor1->GetCoords();
|
||||
wxString signal;
|
||||
|
||||
m_cursorFormatsDyn[2][0].UpdateUnits( plotTab->getPlotsVector()[0]->GetUnitsX() );
|
||||
m_cursorFormatsDyn[2][0].UpdateUnits( plotDiagram->GetUnitsX() );
|
||||
m_cursorFormatsDyn[2][1].UpdateUnits( cursor1Units );
|
||||
|
||||
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 ) );
|
||||
}
|
||||
// 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" );
|
||||
|
||||
@ -3050,7 +3061,7 @@ void SIMULATOR_FRAME_UI::updatePlotCursors()
|
||||
wxRealPoint coords = cursor->GetCoords();
|
||||
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_cursorsGrid->AppendRows( 1 );
|
||||
@ -3060,7 +3071,7 @@ void SIMULATOR_FRAME_UI::updatePlotCursors()
|
||||
m_cursorsGrid->SetCellValue( row, COL_CURSOR_Y, formatValue( coords.y, i, 1 ) );
|
||||
|
||||
// Set up the labels
|
||||
m_cursorsGrid->SetColLabelValue( COL_CURSOR_X, plotTab->getPlotsVector()[0]->GetLabelX() );
|
||||
m_cursorsGrid->SetColLabelValue( COL_CURSOR_X, plotDiagram->GetLabelX() );
|
||||
|
||||
valColName = _( "Value" );
|
||||
|
||||
|
@ -421,7 +421,7 @@ int SIMULATOR_CONTROL::ToggleGrid( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
@ -433,7 +433,7 @@ int SIMULATOR_CONTROL::ToggleLegend( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
@ -445,7 +445,7 @@ int SIMULATOR_CONTROL::ToggleDottedSecondary( const TOOL_EVENT& aEvent )
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user