If present, tune Spice_Model instead of Value
Fixes https://gitlab.com/kicad/code/kicad/issues/9880
This commit is contained in:
parent
78ff9a857a
commit
2dbc6ef6ca
|
@ -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();
|
||||
|
|
|
@ -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).
|
||||
|
|
|
@ -31,15 +31,23 @@
|
|||
#include <template_fieldnames.h>
|
||||
#include <sim/netlist_exporter_pspice_sim.h>
|
||||
|
||||
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() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -103,6 +103,7 @@ private:
|
|||
|
||||
SCH_SYMBOL* m_symbol;
|
||||
|
||||
int m_fieldId;
|
||||
SPICE_VALUE m_min, m_max, m_value;
|
||||
bool m_changed;
|
||||
|
||||
|
|
Loading…
Reference in New Issue