From daf13adabb666ccb4d59ed818fdc41f7ed30da94 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 28 Jan 2026 21:32:34 +0000 Subject: [PATCH] Fill in some missing variant code. In particular: Resolving the DNP/InBOM/OnBoard/etc. flags needs to take into account the variant. Writing a SPICE netlist needs to take into account the variant. Updating a simulation tuned value needs to write to the current variant (this is only partly implemented, with a TODO for the hard part). Painting of fields needs to paint the current variant value. Still missing is reading/writing fields from the simulation model dialog to/from the current variant. --- eeschema/dialogs/dialog_sheet_properties.cpp | 2 +- eeschema/dialogs/dialog_symbol_properties.cpp | 12 +++++----- eeschema/erc/erc.cpp | 5 ++-- .../netlist_exporter_spice.cpp | 15 ++++++------ .../netlist_exporter_spice.h | 3 ++- eeschema/sch_edit_frame.cpp | 14 ++++++----- eeschema/sch_field.cpp | 12 ++++++---- eeschema/sch_painter.cpp | 24 +++++++++++++++---- eeschema/sch_sheet_path.cpp | 15 ++++++++++++ eeschema/sch_sheet_path.h | 1 + eeschema/sch_symbol.cpp | 8 +++---- eeschema/sch_symbol.h | 2 +- eeschema/sim/sim_lib_mgr.cpp | 6 ++--- eeschema/sim/sim_lib_mgr.h | 4 ++-- eeschema/sim/sim_model.cpp | 5 +++- eeschema/sim/sim_model.h | 3 ++- eeschema/sim/simulator_frame_ui.cpp | 6 +++-- eeschema/tools/sch_edit_tool.cpp | 14 ++++++----- eeschema/tools/sch_editor_control.cpp | 7 ++++-- 19 files changed, 104 insertions(+), 54 deletions(-) diff --git a/eeschema/dialogs/dialog_sheet_properties.cpp b/eeschema/dialogs/dialog_sheet_properties.cpp index e2615eaec1..f7329c2191 100644 --- a/eeschema/dialogs/dialog_sheet_properties.cpp +++ b/eeschema/dialogs/dialog_sheet_properties.cpp @@ -175,7 +175,7 @@ bool DIALOG_SHEET_PROPERTIES::TransferDataToWindow() m_cbExcludeFromSim->SetValue( m_sheet->GetExcludedFromSim( &instance, variantName ) ); m_cbExcludeFromBom->SetValue( m_sheet->GetExcludedFromBOM( &instance, variantName ) ); - m_cbExcludeFromBoard->SetValue( m_sheet->GetExcludedFromBoard() ); + m_cbExcludeFromBoard->SetValue( m_sheet->GetExcludedFromBoard( &instance, variantName ) ); m_cbDNP->SetValue( m_sheet->GetDNP( &instance, variantName ) ); instance.push_back( m_sheet ); diff --git a/eeschema/dialogs/dialog_symbol_properties.cpp b/eeschema/dialogs/dialog_symbol_properties.cpp index ece8319b44..5fe4d44a3b 100644 --- a/eeschema/dialogs/dialog_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_symbol_properties.cpp @@ -628,8 +628,8 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataToWindow() m_cbExcludeFromSim->SetValue( m_symbol->GetExcludedFromSim( &sheetPath, variantName ) ); m_cbExcludeFromBom->SetValue( m_symbol->GetExcludedFromBOM( &sheetPath, variantName ) ); - m_cbExcludeFromBoard->SetValue( m_symbol->GetExcludedFromBoard() ); - m_cbExcludeFromPosFiles->SetValue( m_symbol->GetExcludedFromPosFiles() ); + m_cbExcludeFromBoard->SetValue( m_symbol->GetExcludedFromBoard( &sheetPath, variantName ) ); + m_cbExcludeFromPosFiles->SetValue( m_symbol->GetExcludedFromPosFiles( &sheetPath, variantName ) ); m_cbDNP->SetValue( m_symbol->GetDNP( &sheetPath, variantName ) ); if( m_part ) @@ -786,11 +786,11 @@ bool DIALOG_SYMBOL_PROPERTIES::TransferDataFromWindow() if( !m_pinGrid->CommitPendingChanges() ) return false; - SCH_COMMIT commit( GetParent() ); - SCH_SCREEN* currentScreen = GetParent()->GetScreen(); + SCH_COMMIT commit( GetParent() ); + SCH_SCREEN* currentScreen = GetParent()->GetScreen(); SCH_SHEET_PATH currentSheet = GetParent()->Schematic().CurrentSheet(); - wxString currentVariant = GetParent()->Schematic().GetCurrentVariant(); - bool replaceOnCurrentScreen; + wxString currentVariant = GetParent()->Schematic().GetCurrentVariant(); + bool replaceOnCurrentScreen; wxCHECK( currentScreen, false ); diff --git a/eeschema/erc/erc.cpp b/eeschema/erc/erc.cpp index 8cb6aa8600..55ce3ec82b 100644 --- a/eeschema/erc/erc.cpp +++ b/eeschema/erc/erc.cpp @@ -1862,10 +1862,11 @@ int ERC_TESTER::TestSimModelIssues() WX_STRING_REPORTER reporter; int err_count = 0; SIM_LIB_MGR libMgr( &m_schematic->Project() ); + wxString variant = m_schematic->GetCurrentVariant(); for( SCH_SHEET_PATH& sheet : m_sheetList ) { - if( sheet.GetExcludedFromSim() ) + if( sheet.GetExcludedFromSim( variant ) ) continue; std::vector markers; @@ -1882,7 +1883,7 @@ int ERC_TESTER::TestSimModelIssues() // Reset for each symbol reporter.Clear(); - SIM_LIBRARY::MODEL model = libMgr.CreateModel( &sheet, *symbol, true, 0, reporter ); + SIM_LIBRARY::MODEL model = libMgr.CreateModel( &sheet, *symbol, true, 0, variant, reporter ); if( reporter.HasMessage() ) { diff --git a/eeschema/netlist_exporters/netlist_exporter_spice.cpp b/eeschema/netlist_exporters/netlist_exporter_spice.cpp index 5511c65b90..d8309277d2 100644 --- a/eeschema/netlist_exporters/netlist_exporter_spice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_spice.cpp @@ -125,6 +125,7 @@ bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions { std::set refNames; // Set of reference names to check for duplication. int ncCounter = 1; + wxString variant = m_schematic->GetCurrentVariant(); ReadDirectives( aNetlistOptions ); @@ -178,7 +179,7 @@ bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions { SCH_SYMBOL* symbol = findNextSymbol( item, sheet ); - if( !symbol || symbol->ResolveExcludedFromSim() ) + if( !symbol || symbol->ResolveExcludedFromSim( &sheet, variant ) ) continue; try @@ -193,11 +194,11 @@ bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions if( field.GetId() == FIELD_T::REFERENCE ) spiceItem.fields.back().SetText( symbol->GetRef( &sheet ) ); else - spiceItem.fields.back().SetText( field.GetShownText( &sheet, false ) ); + spiceItem.fields.back().SetText( field.GetShownText( &sheet, false, 0, variant ) ); } readRefName( sheet, *symbol, spiceItem, refNames ); - readModel( sheet, *symbol, spiceItem, aReporter ); + readModel( sheet, *symbol, spiceItem, variant, aReporter ); readPinNumbers( *symbol, spiceItem, pins ); readPinNetNames( *symbol, spiceItem, pins, ncCounter ); readNodePattern( spiceItem ); @@ -494,14 +495,14 @@ void NETLIST_EXPORTER_SPICE::readRefName( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aS } -void NETLIST_EXPORTER_SPICE::readModel( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aSymbol, - SPICE_ITEM& aItem, REPORTER& aReporter ) +void NETLIST_EXPORTER_SPICE::readModel( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem, + const wxString& aVariantName, REPORTER& aReporter ) { // For multi-unit symbols, collect merged Sim.Pins from all units wxString mergedSimPins = collectMergedSimPins( aSymbol, aSheet ); - const SIM_LIBRARY::MODEL& libModel = m_libMgr.CreateModel( &aSheet, aSymbol, true, 0, aReporter, - mergedSimPins ); + const SIM_LIBRARY::MODEL& libModel = m_libMgr.CreateModel( &aSheet, aSymbol, true, 0, aVariantName, + aReporter, mergedSimPins ); aItem.baseModelName = libModel.name; aItem.model = &libModel.model; diff --git a/eeschema/netlist_exporters/netlist_exporter_spice.h b/eeschema/netlist_exporters/netlist_exporter_spice.h index 2e8911f0cb..a07eed047a 100644 --- a/eeschema/netlist_exporters/netlist_exporter_spice.h +++ b/eeschema/netlist_exporters/netlist_exporter_spice.h @@ -162,7 +162,7 @@ private: wxString collectMergedSimPins( SCH_SYMBOL& aSymbol, const SCH_SHEET_PATH& aSheet ); void readModel( SCH_SHEET_PATH& aSheet, SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem, - REPORTER& aReporter ); + const wxString& aVariantName, REPORTER& aReporter ); void readPinNumbers( SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem, const std::vector& aPins ); void readPinNetNames( SCH_SYMBOL& aSymbol, SPICE_ITEM& aItem, @@ -177,6 +177,7 @@ private: void writeModels( OUTPUTFORMATTER& aFormatter ); void writeItems( OUTPUTFORMATTER& aFormatter ); +private: SIM_LIB_MGR m_libMgr; ///< Holds libraries and models NAME_GENERATOR m_modelNameGenerator; ///< Generates unique model names diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 4830cf97c0..3670fa3de1 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1579,6 +1579,8 @@ void SCH_EDIT_FRAME::RefreshOperatingPointDisplay() SCHEMATIC_SETTINGS& settings = m_schematic->Settings(); SIM_LIB_MGR simLibMgr( &Prj() ); NULL_REPORTER devnull; + SCH_SHEET_PATH& sheetPath = GetCurrentSheet(); + wxString variant = m_schematic->GetCurrentVariant(); // Patch for bug early in V7.99 dev if( settings.m_OPO_VRange.EndsWith( 'A' ) ) @@ -1623,7 +1625,7 @@ void SCH_EDIT_FRAME::RefreshOperatingPointDisplay() // for( SCH_ITEM* item : GetScreen()->Items() ) { - if( GetCurrentSheet().GetExcludedFromSim() ) + if( sheetPath.GetExcludedFromSim( variant ) ) continue; if( item->Type() == SCH_LINE_T ) @@ -1640,12 +1642,12 @@ void SCH_EDIT_FRAME::RefreshOperatingPointDisplay() else if( item->Type() == SCH_SYMBOL_T ) { SCH_SYMBOL* symbol = static_cast( item ); - wxString ref = symbol->GetRef( &GetCurrentSheet() ); - std::vector pins = symbol->GetPins( &GetCurrentSheet() ); + wxString ref = symbol->GetRef( &sheetPath ); + std::vector pins = symbol->GetPins( &sheetPath ); // Power symbols and other symbols which have the reference starting with "#" are // not included in simulation - if( ref.StartsWith( '#' ) || symbol->ResolveExcludedFromSim() ) + if( ref.StartsWith( '#' ) || symbol->ResolveExcludedFromSim( &sheetPath, variant ) ) continue; for( SCH_PIN* pin : pins ) @@ -1680,7 +1682,7 @@ void SCH_EDIT_FRAME::RefreshOperatingPointDisplay() simLibMgr.SetFilesStack( std::move( embeddedFilesStack ) ); - SIM_MODEL& model = simLibMgr.CreateModel( &GetCurrentSheet(), *symbol, true, 0, devnull ).model; + SIM_MODEL& model = simLibMgr.CreateModel( &sheetPath, *symbol, true, 0, variant, devnull ).model; SPICE_ITEM spiceItem; spiceItem.refName = ref; @@ -1716,7 +1718,7 @@ void SCH_EDIT_FRAME::RefreshOperatingPointDisplay() SCH_LINE* longestWire = nullptr; double length = 0.0; - if( subgraph->GetSheet().GetExcludedFromSim() ) + if( subgraph->GetSheet().GetExcludedFromSim( variant ) ) continue; for( SCH_ITEM* item : subgraph->GetItems() ) diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index b38e660671..897cfe6f79 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -693,10 +693,11 @@ void SCH_FIELD::OnScintillaCharAdded( SCINTILLA_TRICKS* aScintillaTricks, wxStyl return; } - auto textVarRef = [&]( int pt ) - { - return pt >= 2 && scintilla->GetCharAt( pt - 2 ) == '$' && scintilla->GetCharAt( pt - 1 ) == '{'; - }; + auto textVarRef = + [&]( int pt ) + { + return pt >= 2 && scintilla->GetCharAt( pt - 2 ) == '$' && scintilla->GetCharAt( pt - 1 ) == '{'; + }; // Check for cross-reference if( start > 1 && scintilla->GetCharAt( start - 1 ) == ':' ) @@ -716,6 +717,7 @@ void SCH_FIELD::OnScintillaCharAdded( SCINTILLA_TRICKS* aScintillaTricks, wxStyl { NULL_REPORTER devnull; SCH_SHEET_PATH& sheet = schematic->CurrentSheet(); + wxString variant = schematic->GetCurrentVariant(); SIM_LIB_MGR mgr( &schematic->Project() ); std::vector embeddedFilesStack; @@ -729,7 +731,7 @@ void SCH_FIELD::OnScintillaCharAdded( SCINTILLA_TRICKS* aScintillaTricks, wxStyl mgr.SetFilesStack( std::move( embeddedFilesStack ) ); - SIM_MODEL& model = mgr.CreateModel( &sheet, *symbol, true, 0, devnull ).model; + SIM_MODEL& model = mgr.CreateModel( &sheet, *symbol, true, 0, variant, devnull ).model; for( wxString pin : model.GetPinNames() ) { diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index bc9dfbc5f1..117118fa09 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -2909,7 +2909,16 @@ void SCH_PAINTER::draw( const SCH_FIELD* aField, int aLayer, bool aDimmed ) return; } - wxString shownText = aField->GetShownText( true ); + SCH_SHEET_PATH* sheetPath = nullptr; + wxString variant; + + if( m_schematic ) + { + sheetPath = &m_schematic->CurrentSheet(); + variant = m_schematic->GetCurrentVariant(); + } + + wxString shownText = aField->GetShownText( sheetPath, true, 0, variant ); if( shownText.IsEmpty() ) return; @@ -3282,13 +3291,20 @@ void SCH_PAINTER::draw( const SCH_DIRECTIVE_LABEL* aLabel, int aLayer, bool aDim void SCH_PAINTER::draw( const SCH_SHEET* aSheet, int aLayer ) { - bool DNP = false; + SCH_SHEET_PATH* sheetPath = nullptr; + wxString variant; + bool DNP = false; if( m_schematic ) - DNP = aSheet->GetDNP( &m_schematic->CurrentSheet(), m_schematic->GetCurrentVariant() ); + { + sheetPath = &m_schematic->CurrentSheet(); + variant = m_schematic->GetCurrentVariant(); + DNP = aSheet->GetDNP( sheetPath, variant ); + } bool drawingShadows = aLayer == LAYER_SELECTION_SHADOWS; - bool markExclusion = eeconfig()->m_Appearance.mark_sim_exclusions && aSheet->GetExcludedFromSim(); + bool markExclusion = eeconfig()->m_Appearance.mark_sim_exclusions + && aSheet->GetExcludedFromSim( sheetPath, variant ); if( m_schSettings.IsPrinting() && drawingShadows ) return; diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index d94c7805a0..91c9b2389f 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -358,6 +358,21 @@ bool SCH_SHEET_PATH::GetExcludedFromBoard() const } +bool SCH_SHEET_PATH::GetExcludedFromBoard( const wxString& aVariantName ) const +{ + if( aVariantName.IsEmpty() ) + return GetExcludedFromBoard(); + + for( SCH_SHEET* sheet : m_sheets ) + { + if( sheet->GetExcludedFromBoard( this, aVariantName ) ) + return true; + } + + return false; +} + + bool SCH_SHEET_PATH::GetDNP() const { for( SCH_SHEET* sheet : m_sheets ) diff --git a/eeschema/sch_sheet_path.h b/eeschema/sch_sheet_path.h index 523e256bbf..de663b1ad0 100644 --- a/eeschema/sch_sheet_path.h +++ b/eeschema/sch_sheet_path.h @@ -365,6 +365,7 @@ public: bool GetExcludedFromBOM() const; bool GetExcludedFromBOM( const wxString& aVariantName ) const; bool GetExcludedFromBoard() const; + bool GetExcludedFromBoard( const wxString& aVariantName ) const; bool GetDNP() const; bool GetDNP( const wxString& aVariantName ) const; diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 696c54c72c..763d24dbb6 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -1294,10 +1294,10 @@ void SCH_SYMBOL::SetValueFieldText( const wxString& aValue, const SCH_SHEET_PATH const wxString SCH_SYMBOL::GetFootprintFieldText( bool aResolve, const SCH_SHEET_PATH* aPath, - bool aAllowExtraText ) const + bool aAllowExtraText, const wxString& aVariantName ) const { if( aResolve ) - return GetField( FIELD_T::FOOTPRINT )->GetShownText( aPath, aAllowExtraText ); + return GetField( FIELD_T::FOOTPRINT )->GetShownText( aPath, aAllowExtraText, 0, aVariantName ); return GetField( FIELD_T::FOOTPRINT )->GetText(); } @@ -1826,8 +1826,8 @@ bool SCH_SYMBOL::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, simLibMgr.SetFilesStack( std::move( embeddedFilesStack ) ); NULL_REPORTER devnull; - SIM_MODEL& model = - simLibMgr.CreateModel( aPath, const_cast( *this ), true, aDepth + 1, devnull ).model; + SIM_MODEL& model = simLibMgr.CreateModel( aPath, const_cast( *this ), true, aDepth + 1, + aVariantName, devnull ).model; SPICE_ITEM spiceItem; spiceItem.refName = GetRef( aPath ); diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index 28da3da735..4496599662 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -495,7 +495,7 @@ public: const wxString& aVariantName = wxEmptyString ); const wxString GetFootprintFieldText( bool aResolve, const SCH_SHEET_PATH* aPath, - bool aAllowExtraText ) const; + bool aAllowExtraText, const wxString& aVariantName = wxEmptyString ) const; void SetFootprintFieldText( const wxString& aFootprint ); /* diff --git a/eeschema/sim/sim_lib_mgr.cpp b/eeschema/sim/sim_lib_mgr.cpp index f1bd4d8b0b..e41b1fce1d 100644 --- a/eeschema/sim/sim_lib_mgr.cpp +++ b/eeschema/sim/sim_lib_mgr.cpp @@ -200,8 +200,8 @@ SIM_MODEL& SIM_LIB_MGR::CreateModel( const SIM_MODEL* aBaseModel, const std::vec } SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, SCH_SYMBOL& aSymbol, - bool aResolve, int aDepth, REPORTER& aReporter, - const wxString& aMergedSimPins ) + bool aResolve, int aDepth, const wxString& aVariantName, + REPORTER& aReporter, const wxString& aMergedSimPins ) { // Note: currently this creates a resolved model (all Kicad variables references are resolved // before building the model). @@ -227,7 +227,7 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, S if( !aMergedSimPins.IsEmpty() && field.GetName() == SIM_PINS_FIELD ) fields.back().SetText( aMergedSimPins ); else - fields.back().SetText( field.GetShownText( aSheetPath, false, aDepth ) ); + fields.back().SetText( field.GetShownText( aSheetPath, false, aDepth, aVariantName ) ); } } diff --git a/eeschema/sim/sim_lib_mgr.h b/eeschema/sim/sim_lib_mgr.h index bde35e5509..a920e4526b 100644 --- a/eeschema/sim/sim_lib_mgr.h +++ b/eeschema/sim/sim_lib_mgr.h @@ -66,8 +66,8 @@ public: // aMergedSimPins is an optional merged Sim.Pins string from all units of a multi-unit symbol. // If provided (non-empty), it will be used instead of the symbol's Sim.Pins field. SIM_LIBRARY::MODEL CreateModel( const SCH_SHEET_PATH* aSheetPath, SCH_SYMBOL& aSymbol, - bool aResolve, int aDepth, REPORTER& aReporter, - const wxString& aMergedSimPins = wxEmptyString ); + bool aResolve, int aDepth, const wxString& aVariantName, + REPORTER& aReporter, const wxString& aMergedSimPins = wxEmptyString ); SIM_LIBRARY::MODEL CreateModel( const std::vector& aFields, bool aResolve, int aDepth, const std::vector& aPins, REPORTER& aReporter ); diff --git a/eeschema/sim/sim_model.cpp b/eeschema/sim/sim_model.cpp index 1d3a2a7cee..92976c7ba9 100644 --- a/eeschema/sim/sim_model.cpp +++ b/eeschema/sim/sim_model.cpp @@ -445,7 +445,8 @@ void SIM_MODEL::ReadDataFields( const std::vector* aFields, bool aRes } -void SIM_MODEL::WriteFields( std::vector& aFields ) const +void SIM_MODEL::WriteFields( std::vector& aFields, const SCH_SHEET_PATH* aSheetPath, + const wxString& aVariantName ) const { // Remove duplicate fields: they are at the end of list for( size_t ii = aFields.size() - 1; ii > 0; ii-- ) @@ -465,6 +466,8 @@ void SIM_MODEL::WriteFields( std::vector& aFields ) const aFields.erase( aFields.begin() + ii ); } + // TODO: handle writing to given instance & variant + SetFieldValue( aFields, SIM_DEVICE_FIELD, m_serializer->GenerateDevice(), false ); SetFieldValue( aFields, SIM_DEVICE_SUBTYPE_FIELD, m_serializer->GenerateDeviceSubtype(), false ); diff --git a/eeschema/sim/sim_model.h b/eeschema/sim/sim_model.h index ada4abf3bf..a070957b80 100644 --- a/eeschema/sim/sim_model.h +++ b/eeschema/sim/sim_model.h @@ -443,7 +443,8 @@ public: void ReadDataFields( const std::vector* aFields, bool aResolve, int aDepth, const std::vector& aPins ); - void WriteFields( std::vector& aFields ) const; + void WriteFields( std::vector& aFields, const SCH_SHEET_PATH* aSheetPath = nullptr, + const wxString& aVariantName = wxEmptyString ) const; SPICE_INFO GetSpiceInfo() const { return SpiceInfo( GetType() ); } diff --git a/eeschema/sim/simulator_frame_ui.cpp b/eeschema/sim/simulator_frame_ui.cpp index 3388d4bd01..a66cb5ab35 100644 --- a/eeschema/sim/simulator_frame_ui.cpp +++ b/eeschema/sim/simulator_frame_ui.cpp @@ -1694,6 +1694,8 @@ void SIMULATOR_FRAME_UI::AddTuner( const SCH_SHEET_PATH& aSheetPath, SCH_SYMBOL* void SIMULATOR_FRAME_UI::UpdateTunerValue( const SCH_SHEET_PATH& aSheetPath, const KIID& aSymbol, const wxString& aRef, const wxString& aValue ) { + SCHEMATIC& schematic = m_schematicFrame->Schematic(); + wxString variant = schematic.GetCurrentVariant(); SCH_ITEM* item = aSheetPath.ResolveItem( aSymbol ); SCH_SYMBOL* symbol = dynamic_cast( item ); @@ -1718,7 +1720,7 @@ void SIMULATOR_FRAME_UI::UpdateTunerValue( const SCH_SHEET_PATH& aSheetPath, con mgr.SetFilesStack( std::move( embeddedFilesStack ) ); - SIM_MODEL& model = mgr.CreateModel( &aSheetPath, *symbol, true, 0, devnull ).model; + SIM_MODEL& model = mgr.CreateModel( &aSheetPath, *symbol, true, 0, variant, devnull ).model; const SIM_MODEL::PARAM* tunerParam = model.GetTunerParam(); @@ -1730,7 +1732,7 @@ void SIMULATOR_FRAME_UI::UpdateTunerValue( const SCH_SHEET_PATH& aSheetPath, con } model.SetParamValue( tunerParam->info.name, std::string( aValue.ToUTF8() ) ); - model.WriteFields( symbol->GetFields() ); + model.WriteFields( symbol->GetFields(), &aSheetPath, variant ); m_schematicFrame->UpdateItem( symbol, false, true ); m_schematicFrame->OnModify(); diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index e3707f16a5..6f00824fda 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -3292,8 +3292,10 @@ void SCH_EDIT_TOOL::collectUnits( const SCH_SELECTION& int SCH_EDIT_TOOL::SetAttribute( const TOOL_EVENT& aEvent ) { - SCH_SELECTION& selection = m_selectionTool->RequestSelection( { SCH_SYMBOL_T } ); - SCH_COMMIT commit( m_toolMgr ); + SCH_SELECTION& selection = m_selectionTool->RequestSelection( { SCH_SYMBOL_T } ); + SCH_COMMIT commit( m_toolMgr ); + SCH_SHEET_PATH* sheet = &m_frame->GetCurrentSheet(); + wxString variant = m_frame->Schematic().GetCurrentVariant(); std::set> collectedUnits; @@ -3302,10 +3304,10 @@ int SCH_EDIT_TOOL::SetAttribute( const TOOL_EVENT& aEvent ) for( const auto& [symbol, _] : collectedUnits ) { - if( ( aEvent.IsAction( &SCH_ACTIONS::setDNP ) && !symbol->GetDNP() ) - || ( aEvent.IsAction( &SCH_ACTIONS::setExcludeFromSimulation ) && !symbol->GetExcludedFromSim() ) - || ( aEvent.IsAction( &SCH_ACTIONS::setExcludeFromBOM ) && !symbol->GetExcludedFromBOM() ) - || ( aEvent.IsAction( &SCH_ACTIONS::setExcludeFromBoard ) && !symbol->GetExcludedFromBoard() ) ) + if( ( aEvent.IsAction( &SCH_ACTIONS::setDNP ) && !symbol->GetDNP( sheet, variant ) ) + || ( aEvent.IsAction( &SCH_ACTIONS::setExcludeFromSimulation ) && !symbol->GetExcludedFromSim( sheet, variant ) ) + || ( aEvent.IsAction( &SCH_ACTIONS::setExcludeFromBOM ) && !symbol->GetExcludedFromBOM( sheet, variant ) ) + || ( aEvent.IsAction( &SCH_ACTIONS::setExcludeFromBoard ) && !symbol->GetExcludedFromBoard( sheet, variant ) ) ) { new_state = true; break; diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 2ca49a6f39..32477bd8a4 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -763,6 +763,7 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent ) EDA_ITEM* item = selTool->GetNode( aPosition ); SCH_SHEET_PATH& sheet = m_frame->GetCurrentSheet(); + wxString variant = m_frame->Schematic().GetCurrentVariant(); if( !item ) return false; @@ -789,7 +790,7 @@ int SCH_EDITOR_CONTROL::SimProbe( const TOOL_EVENT& aEvent ) mgr.SetFilesStack( std::move( embeddedFilesStack ) ); - SIM_MODEL& model = mgr.CreateModel( &sheet, *symbol, true, 0, reporter ).model; + SIM_MODEL& model = mgr.CreateModel( &sheet, *symbol, true, 0, variant, reporter ).model; if( reporter.HasMessage() ) THROW_IO_ERROR( reporter.GetMessages() ); @@ -3197,6 +3198,8 @@ int SCH_EDITOR_CONTROL::ToggleERCExclusions( const TOOL_EVENT& aEvent ) int SCH_EDITOR_CONTROL::MarkSimExclusions( const TOOL_EVENT& aEvent ) { + SCH_SHEET_PATH* sheetPath = &m_frame->GetCurrentSheet(); + wxString variant = m_frame->Schematic().GetCurrentVariant(); EESCHEMA_SETTINGS* cfg = m_frame->eeconfig(); cfg->m_Appearance.mark_sim_exclusions = !cfg->m_Appearance.mark_sim_exclusions; @@ -3226,7 +3229,7 @@ int SCH_EDITOR_CONTROL::MarkSimExclusions( const TOOL_EVENT& aEvent ) }, RECURSE_MODE::NO_RECURSE ); - if( item->GetExcludedFromSim() ) + if( item->GetExcludedFromSim( sheetPath, variant ) ) flags |= KIGFX::GEOMETRY | KIGFX::REPAINT; }