From d64cb7f81b661c4e27d07e3fea42147aaa9269b9 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 14 Apr 2023 19:40:41 +0100 Subject: [PATCH] More uniform handling of power symbols and exclude-from-simulation. --- eeschema/dialogs/dialog_lib_symbol_properties.cpp | 5 +++++ eeschema/dialogs/dialog_lib_symbol_properties_base.cpp | 2 +- eeschema/dialogs/dialog_lib_symbol_properties_base.fbp | 2 +- eeschema/dialogs/dialog_symbol_properties.cpp | 3 +++ eeschema/erc.cpp | 7 +++---- eeschema/sch_edit_frame.cpp | 5 +++++ 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/eeschema/dialogs/dialog_lib_symbol_properties.cpp b/eeschema/dialogs/dialog_lib_symbol_properties.cpp index ef8e16bbb5..3890223a4d 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_lib_symbol_properties.cpp @@ -180,6 +180,9 @@ bool DIALOG_LIB_SYMBOL_PROPERTIES::TransferDataToWindow() m_OptionPower->SetValue( m_libEntry->IsPower() ); + if( m_libEntry->IsPower() ) + m_spiceFieldsButton->Hide(); + LIB_FIELD* simEnableField = m_libEntry->FindField( SIM_ENABLE_FIELD ); m_excludeFromSim->SetValue( simEnableField && simEnableField->GetText() == wxT( "0" ) ); @@ -942,11 +945,13 @@ void DIALOG_LIB_SYMBOL_PROPERTIES::onPowerCheckBox( wxCommandEvent& aEvent ) m_excludeFromBoardCheckBox->SetValue( true ); m_excludeFromBomCheckBox->Enable( false ); m_excludeFromBoardCheckBox->Enable( false ); + m_spiceFieldsButton->Show( false ); } else { m_excludeFromBomCheckBox->Enable( true ); m_excludeFromBoardCheckBox->Enable( true ); + m_spiceFieldsButton->Show( true ); } OnModify(); diff --git a/eeschema/dialogs/dialog_lib_symbol_properties_base.cpp b/eeschema/dialogs/dialog_lib_symbol_properties_base.cpp index 739a16ebed..872727ab7d 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties_base.cpp +++ b/eeschema/dialogs/dialog_lib_symbol_properties_base.cpp @@ -353,7 +353,7 @@ DIALOG_LIB_SYMBOL_PROPERTIES_BASE::DIALOG_LIB_SYMBOL_PROPERTIES_BASE( wxWindow* bUpperSizer->Add( m_NoteBook, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 10 ); - bMainSizer->Add( bUpperSizer, 1, wxEXPAND, 5 ); + bMainSizer->Add( bUpperSizer, 1, wxEXPAND|wxBOTTOM, 5 ); wxBoxSizer* bSizer101; bSizer101 = new wxBoxSizer( wxHORIZONTAL ); diff --git a/eeschema/dialogs/dialog_lib_symbol_properties_base.fbp b/eeschema/dialogs/dialog_lib_symbol_properties_base.fbp index df80da696d..dca63aa06f 100644 --- a/eeschema/dialogs/dialog_lib_symbol_properties_base.fbp +++ b/eeschema/dialogs/dialog_lib_symbol_properties_base.fbp @@ -64,7 +64,7 @@ none 5 - wxEXPAND + wxEXPAND|wxBOTTOM 1 diff --git a/eeschema/dialogs/dialog_symbol_properties.cpp b/eeschema/dialogs/dialog_symbol_properties.cpp index 10ceb88649..517ba55214 100644 --- a/eeschema/dialogs/dialog_symbol_properties.cpp +++ b/eeschema/dialogs/dialog_symbol_properties.cpp @@ -355,6 +355,9 @@ DIALOG_SYMBOL_PROPERTIES::DIALOG_SYMBOL_PROPERTIES( SCH_EDIT_FRAME* aParent, m_pinGrid->SetTable( m_dataModel ); } + if( m_part && m_part->IsPower() ) + m_spiceFieldsButton->Hide(); + m_pinGrid->PushEventHandler( new GRID_TRICKS( m_pinGrid ) ); m_pinGrid->SetSelectionMode( wxGrid::wxGridSelectRows ); diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index 20596b3c0c..436fe40f52 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -1031,10 +1031,9 @@ int ERC_TESTER::TestSimModelIssues() { SCH_SYMBOL* symbol = static_cast( item ); - // Power symbols are skipped: obviously they do not have a simulator model - const std::unique_ptr< LIB_SYMBOL >& libpart = symbol->GetLibSymbolRef(); - - if( libpart && libpart->IsPower() ) + // Power symbols and other symbols which have the reference starting with "#" are + // not included in simulation + if( symbol->GetRef( &sheet ).StartsWith( '#' ) || symbol->GetExcludeFromSim() ) continue; // Reset for each symbol diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 4371ef72c1..453415f297 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1366,6 +1366,11 @@ void SCH_EDIT_FRAME::RefreshOperatingPointDisplay() wxString ref = symbol->GetRef( &GetCurrentSheet() ); std::vector pins = symbol->GetPins( &GetCurrentSheet() ); + // Power symbols and other symbols which have the reference starting with "#" are + // not included in simulation + if( ref.StartsWith( '#' ) || symbol->GetExcludeFromSim() ) + continue; + for( SCH_PIN* pin : pins ) { if( !pin->GetOperatingPoint().IsEmpty() )