From 604d7a72d6e9d392a2034e31bd686691c10ffa65 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 23 Dec 2022 17:26:16 +0000 Subject: [PATCH] Fix bug in tuning when value is stored in Value field. --- eeschema/dialogs/dialog_sim_model.cpp | 7 +++++++ eeschema/sim/sim_lib_mgr.cpp | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/eeschema/dialogs/dialog_sim_model.cpp b/eeschema/dialogs/dialog_sim_model.cpp index 0b61e482ea..4de3c9ceec 100644 --- a/eeschema/dialogs/dialog_sim_model.cpp +++ b/eeschema/dialogs/dialog_sim_model.cpp @@ -138,6 +138,7 @@ bool DIALOG_SIM_MODEL::TransferDataToWindow() wxString modelType; wxString modelParams; wxString pinMap; + bool storeInValue = false; // Infer RLC and VI models if they aren't specified if( SIM_MODEL::InferSimModel( m_symbol, &m_fields, false, SIM_VALUE_GRAMMAR::NOTATION::SI, @@ -158,6 +159,10 @@ bool DIALOG_SIM_MODEL::TransferDataToWindow() m_fields.emplace_back( &m_symbol, -1, SIM_MODEL::PINS_FIELD ); m_fields.back().SetText( pinMap ); + storeInValue = true; + + // In case the storeInValue checkbox is turned off (if it's left on then we'll overwrite + // this field with the actual value): m_fields[ VALUE_FIELD ].SetText( wxT( "${SIM.PARAMS}" ) ); } @@ -269,6 +274,8 @@ bool DIALOG_SIM_MODEL::TransferDataToWindow() m_curModelTypeOfDeviceType[deviceTypeT] = type; } + curModel().SetIsStoredInValue( storeInValue ); + m_saveInValueCheckbox->SetValue( curModel().IsStoredInValue() ); m_excludeCheckbox->SetValue( !curModel().IsEnabled() ); diff --git a/eeschema/sim/sim_lib_mgr.cpp b/eeschema/sim/sim_lib_mgr.cpp index c628461116..1950d2f18d 100644 --- a/eeschema/sim/sim_lib_mgr.cpp +++ b/eeschema/sim/sim_lib_mgr.cpp @@ -201,6 +201,7 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, S wxString modelType; wxString modelParams; wxString pinMap; + bool storeInValue = false; // Infer RLC and VI models if they aren't specified if( SIM_MODEL::InferSimModel( aSymbol, &fields, true, SIM_VALUE_GRAMMAR::NOTATION::SI, @@ -220,6 +221,8 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, S fields.emplace_back( &aSymbol, -1, SIM_MODEL::PINS_FIELD ); fields.back().SetText( pinMap ); + + storeInValue = true; } std::vector sourcePins = aSymbol.GetAllLibPins(); @@ -230,7 +233,11 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, S return StrNumCmp( lhs->GetNumber(), rhs->GetNumber(), true ) < 0; } ); - return CreateModel( fields, sourcePins ); + SIM_LIBRARY::MODEL model = CreateModel( fields, sourcePins ); + + model.model.SetIsStoredInValue( storeInValue ); + + return model; }