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.
This commit is contained in:
Wayne Stambaugh 2020-06-03 08:30:57 -04:00
parent 7db4a3f702
commit 77a59fb5d3
12 changed files with 144 additions and 22 deletions

View File

@ -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<SCH_COMPONENT*> 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 );
}
}

View File

@ -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 ) );

View File

@ -45,7 +45,7 @@
<property name="minimum_size"></property>
<property name="name">DIALOG_EDIT_COMPONENT_IN_SCHEMATIC_BASE</property>
<property name="pos"></property>
<property name="size">864,440</property>
<property name="size">-1,-1</property>
<property name="style">wxCAPTION|wxCLOSE_BOX|wxDEFAULT_DIALOG_STYLE|wxMAXIMIZE_BOX|wxMINIMIZE_BOX|wxRESIZE_BORDER|wxSYSTEM_MENU</property>
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Symbol Properties</property>
@ -215,7 +215,7 @@
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">30,30</property>
<property name="minimum_size">-1,-1</property>
<property name="moveable">1</property>
<property name="name">m_bpAdd</property>
<property name="pane_border">1</property>
@ -288,7 +288,7 @@
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">30,30</property>
<property name="minimum_size">-1,-1</property>
<property name="moveable">1</property>
<property name="name">m_bpMoveUp</property>
<property name="pane_border">1</property>
@ -361,7 +361,7 @@
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">30,30</property>
<property name="minimum_size">-1,-1</property>
<property name="moveable">1</property>
<property name="name">m_bpMoveDown</property>
<property name="pane_border">1</property>
@ -444,7 +444,7 @@
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">30,30</property>
<property name="minimum_size">-1,-1</property>
<property name="moveable">1</property>
<property name="name">m_bpDelete</property>
<property name="pane_border">1</property>
@ -594,7 +594,7 @@
<property name="name">fgSizer1</property>
<property name="non_flexible_grow_mode">wxFLEX_GROWMODE_SPECIFIED</property>
<property name="permission">none</property>
<property name="rows">3</property>
<property name="rows">4</property>
<property name="vgap">0</property>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
@ -775,7 +775,7 @@
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size">30,29</property>
<property name="minimum_size">-1,-1</property>
<property name="moveable">1</property>
<property name="name">m_buttonBrowseLibrary</property>
<property name="pane_border">1</property>
@ -1004,6 +1004,80 @@
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<object class="spacer" expanded="1">
<property name="height">0</property>
<property name="permission">protected</property>
<property name="width">0</property>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxBOTTOM</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Exclude from bill of materials</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_cbExcludeFromBom</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip">This is useful for adding symbols for board footprints such as fiducials&#x0A;and logos that you do not want to appear in the bill of materials export</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
</object>
</object>
</object>
</object>
</object>
@ -1281,7 +1355,7 @@
</object>
<object class="sizeritem" expanded="0">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxRIGHT</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxEXPAND|wxRIGHT|wxTOP</property>
<property name="proportion">1</property>
<object class="wxTextCtrl" expanded="0">
<property name="BottomDockable">1</property>

View File

@ -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();
};

View File

@ -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

View File

@ -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;
}

View File

@ -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<COMPONENT_INSTANCE_REFERENCE> 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;
};

View File

@ -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

View File

@ -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<KIID&>( symbol->m_Uuid ) = KIID( FromUTF8() );

View File

@ -180,6 +180,8 @@ class SCH_SEXPR_PARSER : public SCHEMATIC_LEXER
return xy;
}
bool parseBool();
/**
* Parse stroke definition \a aStroke.
*

View File

@ -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() );

View File

@ -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