KiCad PCB EDA Suite
footprint_tester.cpp File Reference

Go to the source code of this file.

Functions

void TestFootprints (NETLIST &aNetlist, BOARD *aBoard, std::vector< DRC_ITEM * > &aDRCList)
 

Function Documentation

◆ TestFootprints()

void TestFootprints ( NETLIST aNetlist,
BOARD aBoard,
std::vector< DRC_ITEM * > &  aDRCList 
)

Definition at line 28 of file footprint_tester.cpp.

29 {
30  wxString msg;
31 
32  auto comp = []( const MODULE* x, const MODULE* y )
33  {
34  return x->GetReference().CmpNoCase( y->GetReference() ) < 0;
35  };
36  auto mods = std::set<MODULE*, decltype( comp )>( comp );
37 
39  {
40  // Search for duplicate footprints on the board
41  for( MODULE* mod : aBoard->Modules() )
42  {
43  auto ins = mods.insert( mod );
44 
45  if( !ins.second )
46  {
48  item->SetItems( mod, *ins.first );
49  aDRCList.push_back( item );
50  }
51  }
52  }
53 
55  {
56  // Search for component footprints in the netlist but not on the board.
57  for( unsigned ii = 0; ii < aNetlist.GetCount(); ii++ )
58  {
59  COMPONENT* component = aNetlist.GetComponent( ii );
60  MODULE* module = aBoard->FindModuleByReference( component->GetReference() );
61 
62  if( module == NULL )
63  {
64  msg.Printf( _( "Missing footprint %s (%s)" ),
65  component->GetReference(),
66  component->GetValue() );
67 
69  item->SetErrorMessage( msg );
70  aDRCList.push_back( item );
71  }
72  }
73  }
74 
76  {
77  // Search for component footprints found on board but not in netlist.
78  for( auto module : mods )
79  {
80  COMPONENT* component = aNetlist.GetComponentByReference( module->GetReference() );
81 
82  if( component == NULL )
83  {
85  item->SetItems( module );
86  aDRCList.push_back( item );
87  }
88  }
89  }
90 }
footprint not found for netlist item
Definition: drc.h:69
void SetItems(EDA_ITEM *aItem, EDA_ITEM *bItem=nullptr, EDA_ITEM *cItem=nullptr, EDA_ITEM *dItem=nullptr)
Definition: rc_item.h:119
more than one footprints found for netlist item
Definition: drc.h:70
bool Ignore(int aDRCErrorCode)
returns true if the DRC error code's severity is SEVERITY_IGNORE
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Function GetDesignSettings.
Definition: class_board.h:551
unsigned GetCount() const
Function GetCount.
Definition: pcb_netlist.h:254
const wxString GetReference() const
Function GetReference.
Definition: class_module.h:433
netlist item not found for footprint
Definition: drc.h:71
#define NULL
MODULES & Modules()
Definition: class_board.h:266
const wxString & GetReference() const
Definition: pcb_netlist.h:149
static DRC_ITEM * Create(int aErrorCode)
Constructs a DRC_ITEM for the given error code.
Definition: drc_item.cpp:197
COMPONENT is used to store components and all of their related information found in a netlist.
Definition: pcb_netlist.h:80
COMPONENT * GetComponent(unsigned aIndex)
Function GetComponent returns the COMPONENT at aIndex.
Definition: pcb_netlist.h:263
#define _(s)
Definition: 3d_actions.cpp:33
MODULE * FindModuleByReference(const wxString &aReference) const
Function FindModuleByReference searches for a MODULE within this board with the given reference desig...
const wxString & GetValue() const
Definition: pcb_netlist.h:151
void SetErrorMessage(const wxString &aMessage)
Definition: rc_item.h:117
COMPONENT * GetComponentByReference(const wxString &aReference)
Function GetComponentByReference returns a COMPONENT by aReference.

References _, DRC_ITEM::Create(), DRCE_DUPLICATE_FOOTPRINT, DRCE_EXTRA_FOOTPRINT, DRCE_MISSING_FOOTPRINT, BOARD::FindModuleByReference(), NETLIST::GetComponent(), NETLIST::GetComponentByReference(), NETLIST::GetCount(), BOARD::GetDesignSettings(), COMPONENT::GetReference(), MODULE::GetReference(), COMPONENT::GetValue(), BOARD_DESIGN_SETTINGS::Ignore(), BOARD::Modules(), NULL, RC_ITEM::SetErrorMessage(), and RC_ITEM::SetItems().

Referenced by DIALOG_NETLIST::OnTestFootprintsClick(), and DRC::RunTests().