diff --git a/eeschema/sim/sim_plot_frame.cpp b/eeschema/sim/sim_plot_frame.cpp index 857ecce5be..70491a4206 100644 --- a/eeschema/sim/sim_plot_frame.cpp +++ b/eeschema/sim/sim_plot_frame.cpp @@ -572,13 +572,18 @@ void SIM_PLOT_FRAME::AddTuner( SCH_SYMBOL* aSymbol ) } } -void SIM_PLOT_FRAME::UpdateTunerValue( SCH_SYMBOL* aSymbol, const wxString& aValue ) +void SIM_PLOT_FRAME::UpdateTunerValue( SCH_SYMBOL* aSymbol, int aId, const wxString& aValue ) { for( auto& item : m_schematicFrame->GetScreen()->Items().OfType( SCH_SYMBOL_T ) ) { if( item == aSymbol ) { - aSymbol->SetValue( aValue ); + SCH_FIELD* field = aSymbol->GetFieldById( aId ); + + if( !field ) + break; + + field->SetText( aValue ); m_schematicFrame->UpdateItem( aSymbol, false, true ); m_schematicFrame->OnModify(); diff --git a/eeschema/sim/sim_plot_frame.h b/eeschema/sim/sim_plot_frame.h index 802195445f..de39b2bc1b 100644 --- a/eeschema/sim/sim_plot_frame.h +++ b/eeschema/sim/sim_plot_frame.h @@ -110,13 +110,14 @@ public: void RemoveTuner( TUNER_SLIDER* aTuner, bool aErase = true ); /** - * Safely update the value of the associated symbol without dereferencing + * Safely update a field of the associated symbol without dereferencing * the symbol. * * @param aSymbol pointer to the symbol needing updating - * @param aValue new value of the symbol + * @param aId id of the symbol field + * @param aValue new value of the symbol field */ - void UpdateTunerValue( SCH_SYMBOL* aSymbol, const wxString& aValue ); + void UpdateTunerValue( SCH_SYMBOL* aSymbol, int aId, const wxString& aValue ); /** * Return the currently opened plot panel (or NULL if there is none). diff --git a/eeschema/widgets/tuner_slider.cpp b/eeschema/widgets/tuner_slider.cpp index 0a8310d7e3..3c4d68320a 100644 --- a/eeschema/widgets/tuner_slider.cpp +++ b/eeschema/widgets/tuner_slider.cpp @@ -31,15 +31,23 @@ #include #include -TUNER_SLIDER::TUNER_SLIDER( SIM_PLOT_FRAME* aFrame, wxWindow* aParent, SCH_SYMBOL* aSymbol ) - : TUNER_SLIDER_BASE( aParent ), m_symbol( aSymbol ), - m_min( 0.0 ), m_max( 0.0 ), m_value( 0.0 ), m_frame ( aFrame ) +TUNER_SLIDER::TUNER_SLIDER( SIM_PLOT_FRAME* aFrame, wxWindow* aParent, SCH_SYMBOL* aSymbol ) : + TUNER_SLIDER_BASE( aParent ), + m_symbol( aSymbol ), + m_min( 0.0 ), + m_max( 0.0 ), + m_changed( false ), + m_frame ( aFrame ) { const wxString compName = aSymbol->GetField( REFERENCE_FIELD )->GetText(); m_name->SetLabel( compName ); - m_value = SPICE_VALUE( aSymbol->GetField( VALUE_FIELD )->GetText() ); - m_changed = false; + if( aSymbol->FindField( NETLIST_EXPORTER_PSPICE::GetSpiceFieldName( SF_MODEL ) ) ) + m_fieldId = aSymbol->FindField( NETLIST_EXPORTER_PSPICE::GetSpiceFieldName( SF_MODEL ) )->GetId(); + else + m_fieldId = aSymbol->GetField( VALUE_FIELD )->GetId(); + + m_value = SPICE_VALUE( aSymbol->GetFieldById( m_fieldId )->GetText() ); m_spiceName = aFrame->GetExporter()->GetSpiceDevice( compName ).Lower(); // Call Set*() methods to update fields and slider @@ -185,7 +193,7 @@ void TUNER_SLIDER::onClose( wxCommandEvent& event ) void TUNER_SLIDER::onSave( wxCommandEvent& event ) { - m_frame->UpdateTunerValue( m_symbol, m_value.ToOrigString() ); + m_frame->UpdateTunerValue( m_symbol, m_fieldId, m_value.ToOrigString() ); } diff --git a/eeschema/widgets/tuner_slider.h b/eeschema/widgets/tuner_slider.h index 13b300d72e..04023a7d0d 100644 --- a/eeschema/widgets/tuner_slider.h +++ b/eeschema/widgets/tuner_slider.h @@ -103,6 +103,7 @@ private: SCH_SYMBOL* m_symbol; + int m_fieldId; SPICE_VALUE m_min, m_max, m_value; bool m_changed;