7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-21 09:01:42 +00:00

Ensure newly added Sim.* fields are not visible

Existing fields will retain their current visibility settings

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19466
This commit is contained in:
JamesJCode 2025-01-02 21:13:48 +00:00
parent 3a85a77289
commit bf17300949
3 changed files with 16 additions and 10 deletions

View File

@ -375,8 +375,8 @@ bool DIALOG_SIM_MODEL<T>::TransferDataFromWindow()
name = SIM_MODEL::GetFieldValue( &m_fields, SIM_LIBRARY::NAME_FIELD, false );
}
SIM_MODEL::SetFieldValue( m_fields, SIM_LIBRARY::LIBRARY_FIELD, path );
SIM_MODEL::SetFieldValue( m_fields, SIM_LIBRARY::NAME_FIELD, name );
SIM_MODEL::SetFieldValue( m_fields, SIM_LIBRARY::LIBRARY_FIELD, path, false );
SIM_MODEL::SetFieldValue( m_fields, SIM_LIBRARY::NAME_FIELD, name, false );
if( isIbisLoaded() )
{

View File

@ -462,16 +462,17 @@ void SIM_MODEL::WriteFields( std::vector<SCH_FIELD>& aFields ) const
aFields.erase( aFields.begin() + ii );
}
SetFieldValue( aFields, SIM_DEVICE_FIELD, m_serializer->GenerateDevice() );
SetFieldValue( aFields, SIM_DEVICE_SUBTYPE_FIELD, m_serializer->GenerateDeviceSubtype() );
SetFieldValue( aFields, SIM_DEVICE_FIELD, m_serializer->GenerateDevice(), false );
SetFieldValue( aFields, SIM_DEVICE_SUBTYPE_FIELD, m_serializer->GenerateDeviceSubtype(),
false );
SetFieldValue( aFields, SIM_LEGACY_ENABLE_FIELD_V7, m_serializer->GenerateEnable() );
SetFieldValue( aFields, SIM_PINS_FIELD, m_serializer->GeneratePins() );
SetFieldValue( aFields, SIM_LEGACY_ENABLE_FIELD_V7, m_serializer->GenerateEnable(), false );
SetFieldValue( aFields, SIM_PINS_FIELD, m_serializer->GeneratePins(), false );
SetFieldValue( aFields, SIM_PARAMS_FIELD, m_serializer->GenerateParams() );
SetFieldValue( aFields, SIM_PARAMS_FIELD, m_serializer->GenerateParams(), false );
if( IsStoredInValue() )
SetFieldValue( aFields, SIM_VALUE_FIELD, m_serializer->GenerateValue() );
SetFieldValue( aFields, SIM_VALUE_FIELD, m_serializer->GenerateValue(), false );
// New fields have a ID = -1 (undefined). so replace the undefined ID
// by a degined ID
@ -671,7 +672,7 @@ std::string SIM_MODEL::GetFieldValue( const std::vector<SCH_FIELD>* aFields,
void SIM_MODEL::SetFieldValue( std::vector<SCH_FIELD>& aFields, const wxString& aFieldName,
const std::string& aValue )
const std::string& aValue, bool aIsVisible )
{
auto fieldIt = std::find_if( aFields.begin(), aFields.end(),
[&]( const SCH_FIELD& f )
@ -682,9 +683,13 @@ void SIM_MODEL::SetFieldValue( std::vector<SCH_FIELD>& aFields, const wxString&
if( fieldIt != aFields.end() )
{
if( aValue == "" )
{
aFields.erase( fieldIt );
}
else
{
fieldIt->SetText( aValue );
}
return;
}
@ -696,6 +701,7 @@ void SIM_MODEL::SetFieldValue( std::vector<SCH_FIELD>& aFields, const wxString&
aFields.emplace_back( VECTOR2I(), aFields.size(), parent, aFieldName );
aFields.back().SetText( aValue );
aFields.back().SetVisible( aIsVisible );
}

View File

@ -430,7 +430,7 @@ public:
bool aResolve = true );
static void SetFieldValue( std::vector<SCH_FIELD>& aFields, const wxString& aFieldName,
const std::string& aValue );
const std::string& aValue, bool aIsVisible = true );
const SPICE_GENERATOR& SpiceGenerator() const { return *m_spiceGenerator; }
const SIM_MODEL_SERIALIZER& Serializer() const { return *m_serializer; }