diff --git a/eeschema/dialogs/dialog_shape_properties.cpp b/eeschema/dialogs/dialog_shape_properties.cpp index 41b4e439bd..7657c2fcbe 100644 --- a/eeschema/dialogs/dialog_shape_properties.cpp +++ b/eeschema/dialogs/dialog_shape_properties.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -34,10 +35,10 @@ DIALOG_SHAPE_PROPERTIES::DIALOG_SHAPE_PROPERTIES( SCH_BASE_FRAME* aParent, SCH_SHAPE* aShape ) : - DIALOG_SHAPE_PROPERTIES_BASE( aParent ), - m_frame( aParent ), - m_shape( aShape ), - m_borderWidth( aParent, m_borderWidthLabel, m_borderWidthCtrl, m_borderWidthUnits, true ) + DIALOG_SHAPE_PROPERTIES_BASE( aParent ), + m_frame( aParent ), + m_shape( aShape ), + m_borderWidth( aParent, m_borderWidthLabel, m_borderWidthCtrl, m_borderWidthUnits, true ) { SetTitle( wxString::Format( GetTitle(), aShape->GetFriendlyName() ) ); @@ -68,6 +69,8 @@ DIALOG_SHAPE_PROPERTIES::DIALOG_SHAPE_PROPERTIES( SCH_BASE_FRAME* aParent, SCH_S if( m_frame->GetColorSettings()->GetOverrideSchItemColors() ) m_infoBar->ShowMessage( _( "Note: individual item colors overridden in Preferences." ) ); + m_ruleAreaSizer->Show( dynamic_cast( aShape ) != nullptr ); + SetInitialFocus( m_borderWidthCtrl ); // Required under wxGTK if we want to dismiss the dialog with the ESC key @@ -92,10 +95,8 @@ DIALOG_SHAPE_PROPERTIES::DIALOG_SHAPE_PROPERTIES( SCH_BASE_FRAME* aParent, SCH_S m_symbolEditorSizer->Show( false ); } - m_borderColorSwatch->Bind( COLOR_SWATCH_CHANGED, &DIALOG_SHAPE_PROPERTIES::onBorderSwatch, - this ); - m_customColorSwatch->Bind( COLOR_SWATCH_CHANGED, &DIALOG_SHAPE_PROPERTIES::onCustomColorSwatch, - this ); + m_borderColorSwatch->Bind( COLOR_SWATCH_CHANGED, &DIALOG_SHAPE_PROPERTIES::onBorderSwatch, this ); + m_customColorSwatch->Bind( COLOR_SWATCH_CHANGED, &DIALOG_SHAPE_PROPERTIES::onCustomColorSwatch, this ); // Now all widgets have the size fixed, call FinishDialogSettings finishDialogSettings(); @@ -104,11 +105,8 @@ DIALOG_SHAPE_PROPERTIES::DIALOG_SHAPE_PROPERTIES( SCH_BASE_FRAME* aParent, SCH_S DIALOG_SHAPE_PROPERTIES::~DIALOG_SHAPE_PROPERTIES() { - m_borderColorSwatch->Unbind( COLOR_SWATCH_CHANGED, &DIALOG_SHAPE_PROPERTIES::onBorderSwatch, - this ); - m_customColorSwatch->Unbind( COLOR_SWATCH_CHANGED, - &DIALOG_SHAPE_PROPERTIES::onCustomColorSwatch, - this ); + m_borderColorSwatch->Unbind( COLOR_SWATCH_CHANGED, &DIALOG_SHAPE_PROPERTIES::onBorderSwatch, this ); + m_customColorSwatch->Unbind( COLOR_SWATCH_CHANGED, &DIALOG_SHAPE_PROPERTIES::onCustomColorSwatch, this ); } @@ -117,6 +115,14 @@ bool DIALOG_SHAPE_PROPERTIES::TransferDataToWindow() if( !wxDialog::TransferDataToWindow() ) return false; + if( SCH_RULE_AREA* ruleArea = dynamic_cast( m_shape ) ) + { + m_cbExcludeFromSim->SetValue( ruleArea->GetExcludedFromSim() ); + m_cbExcludeFromBom->SetValue( ruleArea->GetExcludedFromBOM() ); + m_cbExcludeFromBoard->SetValue( ruleArea->GetExcludedFromBoard() ); + m_cbDNP->SetValue( ruleArea->GetDNP() ); + } + if( m_shape->GetWidth() >= 0 ) { m_borderCheckbox->SetValue( true ); @@ -309,6 +315,14 @@ bool DIALOG_SHAPE_PROPERTIES::TransferDataFromWindow() if( !m_shape->IsNew() ) commit.Modify( m_shape, m_frame->GetScreen() ); + if( SCH_RULE_AREA* ruleArea = dynamic_cast( m_shape ) ) + { + ruleArea->SetExcludedFromSim( m_cbExcludeFromSim->GetValue() ); + ruleArea->SetExcludedFromBOM( m_cbExcludeFromBom->GetValue() ); + ruleArea->SetExcludedFromBoard( m_cbExcludeFromBoard->GetValue() ); + ruleArea->SetDNP( m_cbDNP->GetValue() ); + } + STROKE_PARAMS stroke = m_shape->GetStroke(); if( m_borderCheckbox->GetValue() ) diff --git a/eeschema/dialogs/dialog_shape_properties_base.cpp b/eeschema/dialogs/dialog_shape_properties_base.cpp index 1d2ac09622..4b35e43d84 100644 --- a/eeschema/dialogs/dialog_shape_properties_base.cpp +++ b/eeschema/dialogs/dialog_shape_properties_base.cpp @@ -13,6 +13,9 @@ /////////////////////////////////////////////////////////////////////////// BEGIN_EVENT_TABLE( DIALOG_SHAPE_PROPERTIES_BASE, DIALOG_SHIM ) + EVT_CHECKBOX( wxID_ANY, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_OnCheckBox ) + EVT_CHECKBOX( wxID_ANY, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_OnCheckBox ) + EVT_CHECKBOX( wxID_ANY, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_OnCheckBox ) EVT_CHECKBOX( wxID_ANY, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onBorderChecked ) EVT_CHOICE( wxID_ANY, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onFillChoice ) EVT_RADIOBUTTON( NO_FILL, DIALOG_SHAPE_PROPERTIES_BASE::_wxFB_onFillRadioButton ) @@ -35,6 +38,33 @@ DIALOG_SHAPE_PROPERTIES_BASE::DIALOG_SHAPE_PROPERTIES_BASE( wxWindow* parent, wx mainSizer->Add( m_infoBar, 0, wxBOTTOM|wxEXPAND, 5 ); + m_ruleAreaSizer = new wxBoxSizer( wxVERTICAL ); + + m_cbExcludeFromSim = new wxCheckBox( this, wxID_ANY, _("Exclude from simulation"), wxDefaultPosition, wxDefaultSize, 0 ); + m_ruleAreaSizer->Add( m_cbExcludeFromSim, 0, wxTOP|wxRIGHT|wxLEFT, 5 ); + + + m_ruleAreaSizer->Add( 0, 10, 0, wxEXPAND, 5 ); + + m_cbExcludeFromBom = new wxCheckBox( this, wxID_ANY, _("Exclude from bill of materials"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbExcludeFromBom->SetToolTip( _("This is useful for adding symbols for board footprints such as fiducials\nand logos that you do not want to appear in the bill of materials export") ); + + m_ruleAreaSizer->Add( m_cbExcludeFromBom, 0, wxALL, 5 ); + + m_cbExcludeFromBoard = new wxCheckBox( this, wxID_ANY, _("Exclude from board"), wxDefaultPosition, wxDefaultSize, 0 ); + m_cbExcludeFromBoard->SetToolTip( _("This is useful for adding symbols that only get exported to the bill of materials but\nnot required to layout the board such as mechanical fasteners and enclosures") ); + + m_ruleAreaSizer->Add( m_cbExcludeFromBoard, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + + m_cbDNP = new wxCheckBox( this, wxID_ANY, _("Do not populate"), wxDefaultPosition, wxDefaultSize, 0 ); + m_ruleAreaSizer->Add( m_cbDNP, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 ); + + + m_ruleAreaSizer->Add( 0, 5, 1, wxEXPAND, 5 ); + + + mainSizer->Add( m_ruleAreaSizer, 1, wxEXPAND|wxALL, 5 ); + wxBoxSizer* bColumns; bColumns = new wxBoxSizer( wxHORIZONTAL ); diff --git a/eeschema/dialogs/dialog_shape_properties_base.fbp b/eeschema/dialogs/dialog_shape_properties_base.fbp index f9a0738a58..19c57bddf3 100644 --- a/eeschema/dialogs/dialog_shape_properties_base.fbp +++ b/eeschema/dialogs/dialog_shape_properties_base.fbp @@ -14,7 +14,7 @@ res UTF-8 dialog_shape_properties_base - 1000 + 11300 1 1 UI @@ -125,6 +125,300 @@ + + 5 + wxEXPAND|wxALL + 1 + + + m_ruleAreaSizer + wxVERTICAL + protected + + 5 + wxTOP|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Exclude from simulation + + 0 + + + 0 + + 1 + m_cbExcludeFromSim + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnCheckBox + + + + 5 + wxEXPAND + 0 + + 10 + protected + 0 + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Exclude from bill of materials + + 0 + + + 0 + + 1 + m_cbExcludeFromBom + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + This is useful for adding symbols for board footprints such as fiducials and logos that you do not want to appear in the bill of materials export + + wxFILTER_NONE + wxDefaultValidator + + + + + OnCheckBox + + + + 5 + wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Exclude from board + + 0 + + + 0 + + 1 + m_cbExcludeFromBoard + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + This is useful for adding symbols that only get exported to the bill of materials but not required to layout the board such as mechanical fasteners and enclosures + + wxFILTER_NONE + wxDefaultValidator + + + + + OnCheckBox + + + + 5 + wxBOTTOM|wxLEFT|wxRIGHT + 0 + + 1 + 1 + 1 + 1 + 0 + + 0 + 0 + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 0 + 1 + + 1 + + 0 + 0 + wxID_ANY + Do not populate + + 0 + + + 0 + + 1 + m_cbDNP + 1 + + + protected + 1 + + Resizable + 1 + + + ; ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + 5 + wxEXPAND + 1 + + 5 + protected + 0 + + + + 5 wxEXPAND diff --git a/eeschema/dialogs/dialog_shape_properties_base.h b/eeschema/dialogs/dialog_shape_properties_base.h index bfb8c9d7c9..6183ee8765 100644 --- a/eeschema/dialogs/dialog_shape_properties_base.h +++ b/eeschema/dialogs/dialog_shape_properties_base.h @@ -21,9 +21,9 @@ class WX_INFOBAR; #include #include #include +#include #include #include -#include #include #include #include @@ -45,6 +45,7 @@ class DIALOG_SHAPE_PROPERTIES_BASE : public DIALOG_SHIM private: // Private event handlers + void _wxFB_OnCheckBox( wxCommandEvent& event ){ OnCheckBox( event ); } void _wxFB_onBorderChecked( wxCommandEvent& event ){ onBorderChecked( event ); } void _wxFB_onFillChoice( wxCommandEvent& event ){ onFillChoice( event ); } void _wxFB_onFillRadioButton( wxCommandEvent& event ){ onFillRadioButton( event ); } @@ -53,13 +54,18 @@ class DIALOG_SHAPE_PROPERTIES_BASE : public DIALOG_SHIM protected: enum { - NO_FILL = 1000, + NO_FILL = 11300, FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR, FILLED_WITH_COLOR, }; WX_INFOBAR* m_infoBar; + wxBoxSizer* m_ruleAreaSizer; + wxCheckBox* m_cbExcludeFromSim; + wxCheckBox* m_cbExcludeFromBom; + wxCheckBox* m_cbExcludeFromBoard; + wxCheckBox* m_cbDNP; wxGridBagSizer* m_borderSizer; wxCheckBox* m_borderCheckbox; wxStaticText* m_borderWidthLabel; @@ -95,6 +101,7 @@ class DIALOG_SHAPE_PROPERTIES_BASE : public DIALOG_SHIM wxButton* m_sdbSizerCancel; // Virtual event handlers, override them in your derived class + virtual void OnCheckBox( wxCommandEvent& event ) { event.Skip(); } virtual void onBorderChecked( wxCommandEvent& event ) { event.Skip(); } virtual void onFillChoice( wxCommandEvent& event ) { event.Skip(); } virtual void onFillRadioButton( wxCommandEvent& event ) { event.Skip(); } diff --git a/eeschema/erc/erc.cpp b/eeschema/erc/erc.cpp index 9ed49c5b90..5e0850cca2 100644 --- a/eeschema/erc/erc.cpp +++ b/eeschema/erc/erc.cpp @@ -1780,7 +1780,7 @@ int ERC_TESTER::TestSimModelIssues() // Power symbols and other symbols which have the reference starting with "#" are // not included in simulation - if( symbol->GetRef( &sheet ).StartsWith( '#' ) || symbol->GetExcludedFromSim() ) + if( symbol->GetRef( &sheet ).StartsWith( '#' ) || symbol->ResolveExcludedFromSim() ) continue; // Reset for each symbol diff --git a/eeschema/netlist_exporters/netlist_exporter_spice.cpp b/eeschema/netlist_exporters/netlist_exporter_spice.cpp index 79e92e5746..7b47759006 100644 --- a/eeschema/netlist_exporters/netlist_exporter_spice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_spice.cpp @@ -177,7 +177,7 @@ bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions { SCH_SYMBOL* symbol = findNextSymbol( item, sheet ); - if( !symbol || symbol->GetExcludedFromSim() ) + if( !symbol || symbol->ResolveExcludedFromSim() ) continue; try @@ -306,7 +306,7 @@ void NETLIST_EXPORTER_SPICE::ReadDirectives( unsigned aNetlistOptions ) { for( SCH_ITEM* item : sheet.LastScreen()->Items() ) { - if( item->GetExcludedFromSim() ) + if( item->ResolveExcludedFromSim() ) continue; if( item->Type() == SCH_TEXT_T ) diff --git a/eeschema/netlist_exporters/netlist_exporter_xml.cpp b/eeschema/netlist_exporters/netlist_exporter_xml.cpp index 93316dfd04..4cd7141134 100644 --- a/eeschema/netlist_exporters/netlist_exporter_xml.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_xml.cpp @@ -305,10 +305,10 @@ XNODE* NETLIST_EXPORTER_XML::makeSymbols( unsigned aCtl ) if( !symbol ) continue; - if( forBOM && ( sheet.GetExcludedFromBOM() || symbol->GetExcludedFromBOM() ) ) + if( forBOM && ( sheet.GetExcludedFromBOM() || symbol->ResolveExcludedFromBOM() ) ) continue; - if( forBoard && ( sheet.GetExcludedFromBoard() || symbol->GetExcludedFromBoard() ) ) + if( forBoard && ( sheet.GetExcludedFromBoard() || symbol->ResolveExcludedFromBoard() ) ) continue; // Output the symbol's elements in order of expected access frequency. This may @@ -379,19 +379,19 @@ XNODE* NETLIST_EXPORTER_XML::makeSymbols( unsigned aCtl ) xproperty->AddAttribute( wxT( "value" ), sheetField.GetText() ); } - if( symbol->GetExcludedFromBOM() || sheet.GetExcludedFromBOM() ) + if( symbol->ResolveExcludedFromBOM() || sheet.GetExcludedFromBOM() ) { xcomp->AddChild( xproperty = node( wxT( "property" ) ) ); xproperty->AddAttribute( wxT( "name" ), wxT( "exclude_from_bom" ) ); } - if( symbol->GetExcludedFromBoard() || sheet.GetExcludedFromBoard() ) + if( symbol->ResolveExcludedFromBoard() || sheet.GetExcludedFromBoard() ) { xcomp->AddChild( xproperty = node( wxT( "property" ) ) ); xproperty->AddAttribute( wxT( "name" ), wxT( "exclude_from_board" ) ); } - if( symbol->GetDNP() || sheet.GetDNP() ) + if( symbol->ResolveDNP() || sheet.GetDNP() ) { xcomp->AddChild( xproperty = node( wxT( "property" ) ) ); xproperty->AddAttribute( wxT( "name" ), wxT( "dnp" ) ); @@ -889,10 +889,10 @@ XNODE* NETLIST_EXPORTER_XML::makeListOfNets( unsigned aCtl ) if( !symbol ) continue; - if( forBOM && ( sheet.GetExcludedFromBOM() || symbol->GetExcludedFromBOM() ) ) + if( forBOM && ( sheet.GetExcludedFromBOM() || symbol->ResolveExcludedFromBOM() ) ) continue; - if( forBoard && ( sheet.GetExcludedFromBoard() || symbol->GetExcludedFromBoard() ) ) + if( forBoard && ( sheet.GetExcludedFromBoard() || symbol->ResolveExcludedFromBoard() ) ) continue; net_record->m_Nodes.emplace_back( pin, sheet ); diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 2d3684005b..4ed0d53632 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1602,7 +1602,7 @@ void SCH_EDIT_FRAME::RefreshOperatingPointDisplay() // Power symbols and other symbols which have the reference starting with "#" are // not included in simulation - if( ref.StartsWith( '#' ) || symbol->GetExcludedFromSim() ) + if( ref.StartsWith( '#' ) || symbol->ResolveExcludedFromSim() ) continue; for( SCH_PIN* pin : pins ) diff --git a/eeschema/sch_file_versions.h b/eeschema/sch_file_versions.h index 8ee42fb6c6..96a0fd8ffa 100644 --- a/eeschema/sch_file_versions.h +++ b/eeschema/sch_file_versions.h @@ -122,4 +122,5 @@ //#define SEXPR_SCHEMATIC_FILE_VERSION 20250227 // Support for local power symbols //#define SEXPR_SCHEMATIC_FILE_VERSION 20250318 // ~ no longer means empty text //#define SEXPR_SCHEMATIC_FILE_VERSION 20250425 // uuids for tables -#define SEXPR_SCHEMATIC_FILE_VERSION 20250513 // Groups can have design block lib_id +//#define SEXPR_SCHEMATIC_FILE_VERSION 20250513 // Groups can have design block lib_id +#define SEXPR_SCHEMATIC_FILE_VERSION 20250610 // DNP, etc. flags for rule areas diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp index 35fb86f5a2..7df8af6e8d 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr.cpp @@ -1215,7 +1215,14 @@ void SCH_IO_KICAD_SEXPR::saveRuleArea( SCH_RULE_AREA* aRuleArea ) wxCHECK_RET( aRuleArea != nullptr && m_out != nullptr, "" ); m_out->Print( "(rule_area " ); + + KICAD_FORMAT::FormatBool( m_out, "exclude_from_sim", aRuleArea->GetExcludedFromSim() ); + KICAD_FORMAT::FormatBool( m_out, "in_bom", !aRuleArea->GetExcludedFromBOM() ); + KICAD_FORMAT::FormatBool( m_out, "on_board", !aRuleArea->GetExcludedFromBoard() ); + KICAD_FORMAT::FormatBool( m_out, "dnp", aRuleArea->GetDNP() ); + saveShape( aRuleArea ); + m_out->Print( ")" ); } diff --git a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp index a1e39afbb5..10c34aac92 100644 --- a/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp +++ b/eeschema/sch_io/kicad_sexpr/sch_io_kicad_sexpr_parser.cpp @@ -3413,7 +3413,7 @@ SCH_SYMBOL* SCH_IO_KICAD_SEXPR_PARSER::parseSchematicSymbol() } default: - Expecting( "lib_id, lib_name, at, mirror, uuid, on_board, in_bom, dnp, " + Expecting( "lib_id, lib_name, at, mirror, uuid, exclude_from_sim, on_board, in_bom, dnp, " "default_instance, property, pin, or instances" ); } } @@ -4224,8 +4224,29 @@ SCH_RULE_AREA* SCH_IO_KICAD_SEXPR_PARSER::parseSchRuleArea() const_cast( ruleArea->m_Uuid ) = poly->m_Uuid; break; } + + case T_exclude_from_sim: + ruleArea->SetExcludedFromSim( parseBool() ); + NeedRIGHT(); + break; + + case T_in_bom: + ruleArea->SetExcludedFromBOM( !parseBool() ); + NeedRIGHT(); + break; + + case T_on_board: + ruleArea->SetExcludedFromBoard( !parseBool() ); + NeedRIGHT(); + break; + + case T_dnp: + ruleArea->SetDNP( parseBool() ); + NeedRIGHT(); + break; + default: - Expecting( "polyline" ); + Expecting( "exclude_from_sim, on_board, in_bom, dnp, or polyline" ); } } diff --git a/eeschema/sch_item.cpp b/eeschema/sch_item.cpp index 80ec69eaf0..f29991bd06 100644 --- a/eeschema/sch_item.cpp +++ b/eeschema/sch_item.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -244,6 +245,66 @@ SYMBOL* SCH_ITEM::GetParentSymbol() } +bool SCH_ITEM::ResolveExcludedFromSim() const +{ + if( GetExcludedFromSim() ) + return true; + + for( SCH_RULE_AREA* area : m_rule_areas_cache ) + { + if( area->GetExcludedFromSim() ) + return true; + } + + return false; +} + + +bool SCH_ITEM::ResolveExcludedFromBOM() const +{ + if( GetExcludedFromBOM() ) + return true; + + for( SCH_RULE_AREA* area : m_rule_areas_cache ) + { + if( area->GetExcludedFromBOM() ) + return true; + } + + return false; +} + + +bool SCH_ITEM::ResolveExcludedFromBoard() const +{ + if( GetExcludedFromBoard() ) + return true; + + for( SCH_RULE_AREA* area : m_rule_areas_cache ) + { + if( area->GetExcludedFromBoard() ) + return true; + } + + return false; +} + + +bool SCH_ITEM::ResolveDNP() const +{ + if( GetDNP() ) + return true; + + for( SCH_RULE_AREA* area : m_rule_areas_cache ) + { + if( area->GetDNP() ) + return true; + } + + return false; +} + + std::vector SCH_ITEM::ViewGetLayers() const { // Basic fallback diff --git a/eeschema/sch_item.h b/eeschema/sch_item.h index 43375dde3f..1354f85e49 100644 --- a/eeschema/sch_item.h +++ b/eeschema/sch_item.h @@ -251,6 +251,19 @@ public: virtual void SetExcludedFromSim( bool aExclude ) { } virtual bool GetExcludedFromSim() const { return false; } + bool ResolveExcludedFromSim() const; + + virtual void SetExcludedFromBOM( bool aExcludeFromBOM ) { } + virtual bool GetExcludedFromBOM() const { return false; } + bool ResolveExcludedFromBOM() const; + + virtual void SetExcludedFromBoard( bool aExcludeFromBoard ) { } + virtual bool GetExcludedFromBoard() const { return false; } + bool ResolveExcludedFromBoard() const; + + virtual void SetDNP( bool aDNP ) { } + virtual bool GetDNP() const { return false; } + bool ResolveDNP() const; /** * Check if object is movable from the anchor point. @@ -739,7 +752,7 @@ protected: bool m_connectivity_dirty; /// Store pointers to rule areas which this item is contained within - std::unordered_set m_rule_areas_cache; + std::unordered_set m_rule_areas_cache; private: friend class LIB_SYMBOL; diff --git a/eeschema/sch_label.cpp b/eeschema/sch_label.cpp index d940f1efba..c2223a992e 100644 --- a/eeschema/sch_label.cpp +++ b/eeschema/sch_label.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -769,6 +770,58 @@ bool SCH_LABEL_BASE::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* toke return true; } + else if( Type() == SCH_DIRECTIVE_LABEL_T && token->IsSameAs( wxT( "EXCLUDE_FROM_BOM" ) ) ) + { + const SCH_DIRECTIVE_LABEL* directive = static_cast( this ); + *token = wxEmptyString; + + for( SCH_RULE_AREA* ruleArea : directive->GetConnectedRuleAreas() ) + { + if( ruleArea->GetExcludedFromBOM() ) + *token = _( "Excluded from BOM" ); + } + + return true; + } + else if( Type() == SCH_DIRECTIVE_LABEL_T && token->IsSameAs( wxT( "EXCLUDE_FROM_BOARD" ) ) ) + { + const SCH_DIRECTIVE_LABEL* directive = static_cast( this ); + *token = wxEmptyString; + + for( SCH_RULE_AREA* ruleArea : directive->GetConnectedRuleAreas() ) + { + if( ruleArea->GetExcludedFromBoard() ) + *token = _( "Excluded from board" ); + } + + return true; + } + else if( Type() == SCH_DIRECTIVE_LABEL_T && token->IsSameAs( wxT( "EXCLUDE_FROM_SIM" ) ) ) + { + const SCH_DIRECTIVE_LABEL* directive = static_cast( this ); + *token = wxEmptyString; + + for( SCH_RULE_AREA* ruleArea : directive->GetConnectedRuleAreas() ) + { + if( ruleArea->GetExcludedFromSim() ) + *token = _( "Excluded from simulation" ); + } + + return true; + } + else if( Type() == SCH_DIRECTIVE_LABEL_T && token->IsSameAs( wxT( "DNP" ) ) ) + { + const SCH_DIRECTIVE_LABEL* directive = static_cast( this ); + *token = wxEmptyString; + + for( SCH_RULE_AREA* ruleArea : directive->GetConnectedRuleAreas() ) + { + if( ruleArea->GetDNP() ) + *token = _( "DNP" ); + } + + return true; + } for( const SCH_FIELD& field : m_fields) { @@ -1792,6 +1845,12 @@ void SCH_DIRECTIVE_LABEL::RemoveConnectedRuleArea( SCH_RULE_AREA* aRuleArea ) } +const std::unordered_set SCH_DIRECTIVE_LABEL::GetConnectedRuleAreas() const +{ + return m_connected_rule_areas; +} + + bool SCH_DIRECTIVE_LABEL::IsDangling() const { return m_isDangling && m_connected_rule_areas.empty(); diff --git a/eeschema/sch_label.h b/eeschema/sch_label.h index 4b8b6bd626..276b61be66 100644 --- a/eeschema/sch_label.h +++ b/eeschema/sch_label.h @@ -493,6 +493,8 @@ public: /// @brief Removes a specific rule area from the cache void RemoveConnectedRuleArea( SCH_RULE_AREA* aRuleArea ); + const std::unordered_set GetConnectedRuleAreas() const; + /// @brief Determines dangling state from connectivity and cached connected rule areas virtual bool IsDangling() const override; diff --git a/eeschema/sch_rule_area.h b/eeschema/sch_rule_area.h index 427d8e4f27..f383d765ea 100644 --- a/eeschema/sch_rule_area.h +++ b/eeschema/sch_rule_area.h @@ -55,6 +55,30 @@ public: EDA_ITEM* Clone() const override; + /** + * Set or clear the exclude from simulation flag. + */ + void SetExcludedFromSim( bool aExcludeFromSim ) override { m_excludedFromSim = aExcludeFromSim; } + bool GetExcludedFromSim() const override { return m_excludedFromSim; } + + /** + * Set or clear the exclude from schematic bill of materials flag. + */ + void SetExcludedFromBOM( bool aExcludeFromBOM ) override { m_excludedFromBOM = aExcludeFromBOM; } + bool GetExcludedFromBOM() const override { return m_excludedFromBOM; } + + /** + * Set or clear exclude from board netlist flag. + */ + void SetExcludedFromBoard( bool aExcludeFromBoard ) override { m_excludedFromBoard = aExcludeFromBoard; } + bool GetExcludedFromBoard() const override { return m_excludedFromBoard; } + + /** + * Set or clear the 'Do Not Populate' flag. + */ + bool GetDNP() const override { return m_DNP; } + void SetDNP( bool aDNP ) override { m_DNP = aDNP; } + std::vector ViewGetLayers() const override; bool IsFilledForHitTesting() const override @@ -116,6 +140,12 @@ protected: /// Clear the list of items which this rule area affects. void clearContainedItems(); +protected: + bool m_excludedFromSim; + bool m_excludedFromBOM; + bool m_excludedFromBoard; + bool m_DNP; ///< True if symbol is set to 'Do Not Populate'. + /// All #SCH_ITEM objects currently contained or intersecting the rule area. std::unordered_set m_items; @@ -123,7 +153,7 @@ protected: std::unordered_set m_directives; /// All #SCH_ITEM objectss contained or intersecting the rule area in the previous update. - std::unordered_set m_prev_items; + std::unordered_set m_prev_items; /// All SCH_DIRECTIVE_LABEL objects attached to the rule area border in the previous update. std::unordered_set m_prev_directives; diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index ecaa0b1c29..b84ee032cf 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -272,7 +272,7 @@ bool SCH_SHEET::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, in { *token = wxEmptyString; - if( aPath->GetExcludedFromBOM() || this->GetExcludedFromBOM() ) + if( aPath->GetExcludedFromBOM() || this->ResolveExcludedFromBOM() ) *token = _( "Excluded from BOM" ); return true; @@ -281,7 +281,7 @@ bool SCH_SHEET::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, in { *token = wxEmptyString; - if( aPath->GetExcludedFromBoard() || this->GetExcludedFromBoard() ) + if( aPath->GetExcludedFromBoard() || this->ResolveExcludedFromBoard() ) *token = _( "Excluded from board" ); return true; @@ -290,7 +290,7 @@ bool SCH_SHEET::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, in { *token = wxEmptyString; - if( aPath->GetExcludedFromSim() || this->GetExcludedFromSim() ) + if( aPath->GetExcludedFromSim() || this->ResolveExcludedFromSim() ) *token = _( "Excluded from simulation" ); return true; @@ -299,7 +299,7 @@ bool SCH_SHEET::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, in { *token = wxEmptyString; - if( aPath->GetDNP() || this->GetDNP() ) + if( aPath->GetDNP() || this->ResolveDNP() ) *token = _( "DNP" ); return true; diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 52460da56a..5bc824d6a1 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -387,20 +387,20 @@ public: /** * Set or clear the exclude from schematic bill of materials flag. */ - void SetExcludedFromBOM( bool aExcludeFromBOM ) { m_excludedFromBOM = aExcludeFromBOM; } - bool GetExcludedFromBOM() const { return m_excludedFromBOM; } + void SetExcludedFromBOM( bool aExcludeFromBOM ) override { m_excludedFromBOM = aExcludeFromBOM; } + bool GetExcludedFromBOM() const override { return m_excludedFromBOM; } /** * Set or clear exclude from board netlist flag. */ - void SetExcludedFromBoard( bool aExcludeFromBoard ) { m_excludedFromBoard = aExcludeFromBoard; } - bool GetExcludedFromBoard() const { return m_excludedFromBoard; } + void SetExcludedFromBoard( bool aExcludeFromBoard ) override { m_excludedFromBoard = aExcludeFromBoard; } + bool GetExcludedFromBoard() const override { return m_excludedFromBoard; } /** * Set or clear the 'Do Not Populate' flags */ - bool GetDNP() const { return m_DNP; } - void SetDNP( bool aDNP ) { m_DNP = aDNP; } + bool GetDNP() const override { return m_DNP; } + void SetDNP( bool aDNP ) override { m_DNP = aDNP; } wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override; diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 7039be36ab..65df2be7a4 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -1424,7 +1424,7 @@ bool SCH_SYMBOL::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, i { *token = wxEmptyString; - if( aPath->GetExcludedFromBOM() || this->GetExcludedFromBOM() ) + if( aPath->GetExcludedFromBOM() || this->ResolveExcludedFromBOM() ) *token = _( "Excluded from BOM" ); return true; @@ -1433,7 +1433,7 @@ bool SCH_SYMBOL::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, i { *token = wxEmptyString; - if( aPath->GetExcludedFromBoard() || this->GetExcludedFromBoard() ) + if( aPath->GetExcludedFromBoard() || this->ResolveExcludedFromBoard() ) *token = _( "Excluded from board" ); return true; @@ -1442,7 +1442,7 @@ bool SCH_SYMBOL::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, i { *token = wxEmptyString; - if( aPath->GetExcludedFromSim() || this->GetExcludedFromSim() ) + if( aPath->GetExcludedFromSim() || this->ResolveExcludedFromSim() ) *token = _( "Excluded from simulation" ); return true; @@ -1451,7 +1451,7 @@ bool SCH_SYMBOL::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, i { *token = wxEmptyString; - if( aPath->GetDNP() || this->GetDNP() ) + if( aPath->GetDNP() || this->ResolveDNP() ) *token = _( "DNP" ); return true; diff --git a/eeschema/symbol.h b/eeschema/symbol.h index 43fcd399d3..2f6de0988f 100644 --- a/eeschema/symbol.h +++ b/eeschema/symbol.h @@ -177,20 +177,20 @@ public: /** * Set or clear the exclude from schematic bill of materials flag. */ - void SetExcludedFromBOM( bool aExcludeFromBOM ) { m_excludedFromBOM = aExcludeFromBOM; } - bool GetExcludedFromBOM() const { return m_excludedFromBOM; } + void SetExcludedFromBOM( bool aExcludeFromBOM ) override { m_excludedFromBOM = aExcludeFromBOM; } + bool GetExcludedFromBOM() const override { return m_excludedFromBOM; } /** * Set or clear exclude from board netlist flag. */ - void SetExcludedFromBoard( bool aExcludeFromBoard ) { m_excludedFromBoard = aExcludeFromBoard; } - bool GetExcludedFromBoard() const { return m_excludedFromBoard; } + void SetExcludedFromBoard( bool aExcludeFromBoard ) override { m_excludedFromBoard = aExcludeFromBoard; } + bool GetExcludedFromBoard() const override { return m_excludedFromBoard; } /** * Set or clear the 'Do Not Populate' flag. */ - bool GetDNP() const { return m_DNP; } - void SetDNP( bool aDNP ) { m_DNP = aDNP; } + bool GetDNP() const override { return m_DNP; } + void SetDNP( bool aDNP ) override { m_DNP = aDNP; } virtual int GetOrientation() const { return SYM_NORMAL; } diff --git a/eeschema/widgets/search_handlers.cpp b/eeschema/widgets/search_handlers.cpp index 8757900931..57236d4c52 100644 --- a/eeschema/widgets/search_handlers.cpp +++ b/eeschema/widgets/search_handlers.cpp @@ -234,13 +234,13 @@ wxString SYMBOL_SEARCH_HANDLER::getResultCell( const SCH_SEARCH_HIT& aHit, int a else if( aCol == 5 ) return m_frame->MessageTextFromValue( sym->GetPosition().y ); else if( aCol == 6 ) - return sym->GetExcludedFromSim() ? wxS( "X" ) : wxS( " " ); + return sym->ResolveExcludedFromSim() ? wxS( "X" ) : wxS( " " ); else if( aCol == 7 ) - return sym->GetExcludedFromBOM() ? wxS( "X" ) : wxS( " " ); + return sym->ResolveExcludedFromBOM() ? wxS( "X" ) : wxS( " " ); else if( aCol == 8 ) - return sym->GetExcludedFromBoard() ? wxS( "X" ) : wxS( " " ); + return sym->ResolveExcludedFromBoard() ? wxS( "X" ) : wxS( " " ); else if( aCol == 9 ) - return sym->GetDNP() ? wxS( "X" ) : wxS( " " ); + return sym->ResolveDNP() ? wxS( "X" ) : wxS( " " ); else if( aCol == 10 ) return sym->GetLibId().Format(); else if( aCol == 11 )