From 77a59fb5d3f90ef7a594d5ff5034cc024da24e02 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Wed, 3 Jun 2020 08:30:57 -0400 Subject: [PATCH] Eeschema: add support for excluding symbols from bill of materials. This provides a method to add symbols that represent footprints on the board that do not have an associate component such as mounting holes, fiducials, logos, etc that should be excluded from the bill of materials. It also prevents those footprints from being removed from the board accidentally when updating the board from the schematic. ADDED: Support to exclude schematic symbols from bill of materials export. --- .../dialog_edit_component_in_schematic.cpp | 9 +- ...ialog_edit_component_in_schematic_base.cpp | 20 +++-- ...ialog_edit_component_in_schematic_base.fbp | 90 +++++++++++++++++-- .../dialog_edit_component_in_schematic_base.h | 5 +- .../netlist_exporter_generic.cpp | 2 +- eeschema/sch_component.cpp | 2 + eeschema/sch_component.h | 5 ++ eeschema/sch_file_versions.h | 4 +- eeschema/sch_sexpr_parser.cpp | 20 +++++ eeschema/sch_sexpr_parser.h | 2 + eeschema/sch_sexpr_plugin.cpp | 4 + eeschema/schematic.keywords | 3 + 12 files changed, 144 insertions(+), 22 deletions(-) diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp index e53e58a9d2..9982aa6340 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic.cpp @@ -223,6 +223,8 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataToWindow() // Set the component's library name. m_libraryNameTextCtrl->SetValue( m_cmp->GetLibId().Format() ); + m_cbExcludeFromBom->SetValue( !m_cmp->GetIncludeInBom() ); + Layout(); return true; @@ -515,8 +517,10 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow() // reference. m_cmp->SetRef( &GetParent()->GetCurrentSheet(), m_fields->at( REFERENCE ).GetText() ); - // The value, footprint and datasheet fields should be kept in sync in multi-unit - // parts. + m_cmp->SetIncludeInBom( !m_cbExcludeFromBom->IsChecked() ); + + // The value, footprint and datasheet fields and exclude from bill of materials setting + // should be kept in sync in multi-unit parts. if( m_cmp->GetUnitCount() > 1 ) { std::vector otherUnits; @@ -529,6 +533,7 @@ bool DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::TransferDataFromWindow() otherUnit->GetField( VALUE )->SetText( m_fields->at( VALUE ).GetText() ); otherUnit->GetField( FOOTPRINT )->SetText( m_fields->at( FOOTPRINT ).GetText() ); otherUnit->GetField( DATASHEET )->SetText( m_fields->at( DATASHEET ).GetText() ); + otherUnit->SetIncludeInBom( !m_cbExcludeFromBom->IsChecked() ); GetParent()->RefreshItem( otherUnit ); } } diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_base.cpp b/eeschema/dialogs/dialog_edit_component_in_schematic_base.cpp index 38b9671424..d02279422d 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_base.cpp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version Nov 6 2019) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -76,19 +76,16 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE m_bpAdd = new wxBitmapButton( sbFields->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); m_bpAdd->SetToolTip( _("Add field") ); - m_bpAdd->SetMinSize( wxSize( 30,30 ) ); bButtonSize->Add( m_bpAdd, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); m_bpMoveUp = new wxBitmapButton( sbFields->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); m_bpMoveUp->SetToolTip( _("Move up") ); - m_bpMoveUp->SetMinSize( wxSize( 30,30 ) ); bButtonSize->Add( m_bpMoveUp, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); m_bpMoveDown = new wxBitmapButton( sbFields->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); m_bpMoveDown->SetToolTip( _("Move down") ); - m_bpMoveDown->SetMinSize( wxSize( 30,30 ) ); bButtonSize->Add( m_bpMoveDown, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); @@ -97,7 +94,6 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE m_bpDelete = new wxBitmapButton( sbFields->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); m_bpDelete->SetToolTip( _("Delete field") ); - m_bpDelete->SetMinSize( wxSize( 30,30 ) ); bButtonSize->Add( m_bpDelete, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 ); @@ -122,7 +118,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE sbSizerLibraryReference = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Symbol") ), wxVERTICAL ); wxFlexGridSizer* fgSizer1; - fgSizer1 = new wxFlexGridSizer( 3, 2, 0, 0 ); + fgSizer1 = new wxFlexGridSizer( 4, 2, 0, 0 ); fgSizer1->AddGrowableCol( 1 ); fgSizer1->SetFlexibleDirection( wxBOTH ); fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); @@ -141,7 +137,6 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE m_buttonBrowseLibrary = new wxBitmapButton( sbSizerLibraryReference->GetStaticBox(), wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 ); m_buttonBrowseLibrary->SetToolTip( _("Browse library") ); - m_buttonBrowseLibrary->SetMinSize( wxSize( 30,29 ) ); bLibraryReferenceSizer->Add( m_buttonBrowseLibrary, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); @@ -168,6 +163,14 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE fgSizer1->Add( m_cbAlternateSymbol, 0, wxRIGHT|wxTOP, 5 ); + fgSizer1->Add( 0, 0, 1, wxEXPAND, 5 ); + + m_cbExcludeFromBom = new wxCheckBox( sbSizerLibraryReference->GetStaticBox(), 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") ); + + fgSizer1->Add( m_cbExcludeFromBom, 0, wxBOTTOM, 5 ); + + sbSizerLibraryReference->Add( fgSizer1, 0, wxEXPAND, 5 ); @@ -209,7 +212,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE m_textCtrlTimeStamp->SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) ); m_textCtrlTimeStamp->SetToolTip( _("Unique ID that identifies the symbol") ); - bSizerUUID->Add( m_textCtrlTimeStamp, 1, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT, 5 ); + bSizerUUID->Add( m_textCtrlTimeStamp, 1, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxRIGHT|wxTOP, 5 ); bSizerBottom->Add( bSizerUUID, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); @@ -238,6 +241,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE this->SetSizer( mainSizer ); this->Layout(); + mainSizer->Fit( this ); // Connect Events this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE::OnInitDlg ) ); diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp b/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp index 5a1bb692a1..82282d671b 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_base.fbp @@ -45,7 +45,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE - 864,440 + -1,-1 wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU DIALOG_SHIM; dialog_shim.h Symbol Properties @@ -215,7 +215,7 @@ 0 - 30,30 + -1,-1 1 m_bpAdd 1 @@ -288,7 +288,7 @@ 0 - 30,30 + -1,-1 1 m_bpMoveUp 1 @@ -361,7 +361,7 @@ 0 - 30,30 + -1,-1 1 m_bpMoveDown 1 @@ -444,7 +444,7 @@ 0 - 30,30 + -1,-1 1 m_bpDelete 1 @@ -594,7 +594,7 @@ fgSizer1 wxFLEX_GROWMODE_SPECIFIED none - 3 + 4 0 5 @@ -775,7 +775,7 @@ 0 - 30,29 + -1,-1 1 m_buttonBrowseLibrary 1 @@ -1004,6 +1004,80 @@ + + 5 + wxEXPAND + 1 + + 0 + protected + 0 + + + + 5 + wxBOTTOM + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 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 + + + + + + @@ -1281,7 +1355,7 @@ 5 - wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxRIGHT|wxTOP 1 1 diff --git a/eeschema/dialogs/dialog_edit_component_in_schematic_base.h b/eeschema/dialogs/dialog_edit_component_in_schematic_base.h index 0d9272235d..33abfc6ab4 100644 --- a/eeschema/dialogs/dialog_edit_component_in_schematic_base.h +++ b/eeschema/dialogs/dialog_edit_component_in_schematic_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Oct 26 2018) +// C++ code generated with wxFormBuilder (version Nov 6 2019) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -57,6 +57,7 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE : public DIALOG_SHIM wxStaticText* m_unitLabel; wxChoice* m_unitChoice; wxCheckBox* m_cbAlternateSymbol; + wxCheckBox* m_cbExcludeFromBom; wxRadioBox* m_rbOrientation; wxRadioBox* m_rbMirror; wxStaticLine* m_staticline1; @@ -83,7 +84,7 @@ class DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE : public DIALOG_SHIM public: - DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Symbol Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 864,440 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU ); + DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Symbol Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU ); ~DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE(); }; diff --git a/eeschema/netlist_exporters/netlist_exporter_generic.cpp b/eeschema/netlist_exporters/netlist_exporter_generic.cpp index 5a79e59854..90b31f894f 100644 --- a/eeschema/netlist_exporters/netlist_exporter_generic.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_generic.cpp @@ -234,7 +234,7 @@ XNODE* NETLIST_EXPORTER_GENERIC::makeComponents() { SCH_COMPONENT* comp = findNextComponent( item, &sheet ); - if( !comp ) + if( !comp || !comp->GetIncludeInBom() ) continue; XNODE* xcomp; // current component being constructed diff --git a/eeschema/sch_component.cpp b/eeschema/sch_component.cpp index 650b952c31..0254f03d68 100644 --- a/eeschema/sch_component.cpp +++ b/eeschema/sch_component.cpp @@ -166,6 +166,7 @@ SCH_COMPONENT::SCH_COMPONENT( const SCH_COMPONENT& aComponent ) : m_convert = aComponent.m_convert; m_lib_id = aComponent.m_lib_id; m_isInNetlist = aComponent.m_isInNetlist; + m_inBom = aComponent.m_inBom; if( aComponent.m_part ) SetLibSymbol( new LIB_PART( *aComponent.m_part.get() ) ); @@ -209,6 +210,7 @@ void SCH_COMPONENT::Init( const wxPoint& pos ) m_prefix = wxString( wxT( "U" ) ); m_isInNetlist = true; + m_inBom = true; } diff --git a/eeschema/sch_component.h b/eeschema/sch_component.h index a91df448f5..51eaeb0e41 100644 --- a/eeschema/sch_component.h +++ b/eeschema/sch_component.h @@ -126,6 +126,8 @@ private: bool m_isInNetlist; ///< True if the component should appear in the netlist + bool m_inBom; ///< True to include in bill of materials export. + // Defines the hierarchical path and reference of the component. This allows support // for multiple references to a single sub-sheet. std::vector m_instanceReferences; @@ -678,6 +680,9 @@ public: void HighlightPin( LIB_PIN* aPin ); + bool GetIncludeInBom() const { return m_inBom; } + void SetIncludeInBom( bool aIncludeInBom ) { m_inBom = aIncludeInBom; } + private: bool doIsConnected( const wxPoint& aPosition ) const override; }; diff --git a/eeschema/sch_file_versions.h b/eeschema/sch_file_versions.h index b1dbab01cf..0c8aba569d 100644 --- a/eeschema/sch_file_versions.h +++ b/eeschema/sch_file_versions.h @@ -43,4 +43,6 @@ //#define SEXPR_SCHEMATIC_FILE_VERSION 20200506 // Used "page" instead of "paper" for paper // sizes. -#define SEXPR_SCHEMATIC_FILE_VERSION 20200512 +//#define SEXPR_SCHEMATIC_FILE_VERSION 20200512 // Add support for exclude from BOM. + +#define SEXPR_SCHEMATIC_FILE_VERSION 20200602 diff --git a/eeschema/sch_sexpr_parser.cpp b/eeschema/sch_sexpr_parser.cpp index 1a36d212ea..4d26c0806b 100644 --- a/eeschema/sch_sexpr_parser.cpp +++ b/eeschema/sch_sexpr_parser.cpp @@ -69,6 +69,21 @@ SCH_SEXPR_PARSER::SCH_SEXPR_PARSER( LINE_READER* aLineReader ) : } +bool SCH_SEXPR_PARSER::parseBool() +{ + T token = NextTok(); + + if( token == T_yes ) + return true; + else if( token == T_no ) + return false; + else + Expecting( "yes or no" ); + + return false; +} + + bool SCH_SEXPR_PARSER::IsTooRecent() const { return m_requiredVersion && m_requiredVersion > SEXPR_SYMBOL_LIB_FILE_VERSION; @@ -2130,6 +2145,11 @@ SCH_COMPONENT* SCH_SEXPR_PARSER::parseSchematicSymbol() NeedRIGHT(); break; + case T_in_bom: + symbol->SetIncludeInBom( parseBool() ); + NeedRIGHT(); + break; + case T_uuid: NeedSYMBOL(); const_cast( symbol->m_Uuid ) = KIID( FromUTF8() ); diff --git a/eeschema/sch_sexpr_parser.h b/eeschema/sch_sexpr_parser.h index a1f89280e5..6c0ed55900 100644 --- a/eeschema/sch_sexpr_parser.h +++ b/eeschema/sch_sexpr_parser.h @@ -180,6 +180,8 @@ class SCH_SEXPR_PARSER : public SCHEMATIC_LEXER return xy; } + bool parseBool(); + /** * Parse stroke definition \a aStroke. * diff --git a/eeschema/sch_sexpr_plugin.cpp b/eeschema/sch_sexpr_plugin.cpp index 64cd18f357..beeb07ffc4 100644 --- a/eeschema/sch_sexpr_plugin.cpp +++ b/eeschema/sch_sexpr_plugin.cpp @@ -940,6 +940,10 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_COMPONENT* aSymbol, int aNestLevel ) m_out->Print( 0, "\n" ); + m_out->Print( aNestLevel + 1, "(in_bom %s)", ( aSymbol->GetIncludeInBom() ) ? "yes" : "no" ); + + m_out->Print( 0, "\n" ); + // @todo Convert to full UUID if current UUID is a legacy time stamp. m_out->Print( aNestLevel + 1, "(uuid %s)\n", m_out->Quotew( aSymbol->m_Uuid.AsString() ).c_str() ); diff --git a/eeschema/schematic.keywords b/eeschema/schematic.keywords index f0e26882cc..fa6aa0a67a 100644 --- a/eeschema/schematic.keywords +++ b/eeschema/schematic.keywords @@ -43,6 +43,7 @@ input input_low inverted inverted_clock +in_bom italic junction justify @@ -59,6 +60,7 @@ members mid mirror name +no no_connect non_logic none @@ -119,3 +121,4 @@ wire xy x y +yes