KiCad PCB EDA Suite
Loading...
Searching...
No Matches
BOARD_NETLIST_UPDATER Class Reference

Update the BOARD with a new netlist. More...

#include <board_netlist_updater.h>

Public Member Functions

 BOARD_NETLIST_UPDATER (PCB_EDIT_FRAME *aFrame, BOARD *aBoard)
 Construct an updater for interactive use from the board editor.
 
 BOARD_NETLIST_UPDATER (TOOL_MANAGER *aToolManager, BOARD *aBoard)
 Construct an updater without a board editor frame (headless).
 
 ~BOARD_NETLIST_UPDATER ()
 
bool UpdateNetlist (NETLIST &aNetlist)
 Update the board's components according to the new netlist.
 
void SetReporter (REPORTER *aReporter)
 Enable dry run mode (just report, no changes to PCB).
 
void SetIsDryRun (bool aEnabled)
 
void SetReplaceFootprints (bool aEnabled)
 
void SetTransferGroups (bool aEnabled)
 
void SetApplyDesignBlockLayouts (bool aEnabled)
 
void SetOverrideLocks (bool aOverride)
 
void SetDeleteUnusedFootprints (bool aEnabled)
 
void SetLookupByTimestamp (bool aEnabled)
 
void SetUpdateFields (bool aEnabled)
 
void SetRemoveExtraFields (bool aEnabled)
 
std::vector< FOOTPRINT * > GetAddedFootprints () const
 
std::vector< PCB_GROUP * > GetAddedGroups () const
 
int GetErrorCount () const
 
int GetWarningCount () const
 
int GetNewFootprintCount () const
 

Static Public Member Functions

static bool fpidsEquivalent (const LIB_ID &aBoardFpid, const LIB_ID &aSchematicFpid)
 Compare a board footprint ID against a schematic-derived footprint ID, ignoring the library nickname when the schematic side uses a legacy bare footprint name.
 
static void ApplyChainAssignments (BOARD *aBoard, const NETLIST &aNetlist, REPORTER *aReporter, bool aDryRun)
 Apply the netlist's chain assignments to every NETINFO_ITEM on the board.
 

Private Member Functions

void cacheNetname (PAD *aPad, const wxString &aNetname)
 
wxString getNetname (PAD *aPad)
 
void cachePinFunction (PAD *aPad, const wxString &aPinFunction)
 
wxString getPinFunction (PAD *aPad)
 
VECTOR2I estimateFootprintInsertionPosition ()
 
FOOTPRINTaddNewFootprint (COMPONENT *aComponent)
 
FOOTPRINTaddNewFootprint (COMPONENT *aComponent, const LIB_ID &aFootprintId)
 
FOOTPRINTreplaceFootprint (NETLIST &aNetlist, FOOTPRINT *aFootprint, COMPONENT *aNewComponent)
 
bool updateFootprintParameters (FOOTPRINT *aFootprint, COMPONENT *aNetlistComponent)
 
bool updateFootprintGroup (FOOTPRINT *aPcbFootprint, COMPONENT *aNetlistComponent)
 
bool updateComponentPadConnections (FOOTPRINT *aFootprint, COMPONENT *aNewComponent)
 
bool updateComponentClass (FOOTPRINT *aFootprint, COMPONENT *aNewComponent)
 
bool updateComponentUnits (FOOTPRINT *aFootprint, COMPONENT *aNewComponent)
 
void applyComponentVariants (COMPONENT *aComponent, const std::vector< FOOTPRINT * > &aFootprints, const LIB_ID &aBaseFpid)
 
void cacheCopperZoneConnections ()
 
bool updateCopperZoneNets (NETLIST &aNetlist)
 
bool updateGroups (NETLIST &aNetlist)
 
bool testConnectivity (NETLIST &aNetlist, std::map< COMPONENT *, FOOTPRINT * > &aFootprintMap)
 

Private Attributes

PCB_EDIT_FRAMEm_frame
 
PCBNEW_SETTINGSm_settings
 
BOARD_COMMIT m_commit
 
BOARDm_board
 
REPORTERm_reporter
 
std::map< ZONE *, std::vector< PAD * > > m_zoneConnectionsCache
 
std::map< wxString, wxString > m_oldToNewNets
 
std::map< PAD *, wxString > m_padNets
 
std::map< PAD *, wxString > m_padPinFunctions
 
std::vector< FOOTPRINT * > m_addedFootprints
 
std::vector< PCB_GROUP * > m_addedGroups
 
std::map< wxString, NETINFO_ITEM * > m_addedNets
 
std::set< wxString > m_schematicNetNames
 
bool m_deleteUnusedFootprints = false
 
bool m_isDryRun = false
 
bool m_replaceFootprints = true
 
bool m_transferGroups = false
 
bool m_applyDesignBlockLayouts = false
 
bool m_lookupByTimestamp = false
 
bool m_overrideLocks = false
 
bool m_updateFields = false
 
bool m_removeExtraFields = false
 
int m_warningCount = 0
 
int m_errorCount = 0
 
int m_newFootprintsCount = 0
 

Detailed Description

Update the BOARD with a new netlist.

The changes are made to the board are as follows they are not disabled in the status settings in the NETLIST:

  • If a new component is found in the NETLIST and not in the BOARD, it is added to the BOARD.
  • If a the component in the NETLIST is already on the BOARD, then one or more of the following actions can occur:
    • If the footprint name in the NETLIST does not match the footprint name on the BOARD, the footprint on the BOARD is replaced with the footprint specified in the NETLIST and the proper parameters are copied from the existing footprint.
    • If the reference designator in the NETLIST does not match the reference designator on the BOARD, the reference designator is updated from the NETLIST.
    • If the value field in the NETLIST does not match the value field on the BOARD, the value field is updated from the NETLIST.
    • If the time stamp in the NETLIST does not match the time stamp on the BOARD, the time stamp is updated from the NETLIST.
  • After each footprint is added or update as described above, each footprint pad net name is compared and updated to the value defined in the NETLIST.
  • After all of the footprints have been added, updated, and net names and pin function properly set, any extra unlocked footprints are removed from the BOARD.

Definition at line 67 of file board_netlist_updater.h.

Constructor & Destructor Documentation

◆ BOARD_NETLIST_UPDATER() [1/2]

BOARD_NETLIST_UPDATER::BOARD_NETLIST_UPDATER ( PCB_EDIT_FRAME * aFrame,
BOARD * aBoard )

Construct an updater for interactive use from the board editor.

Definition at line 55 of file board_netlist_updater.cpp.

References GetAppSettings(), m_board, m_commit, m_frame, m_reporter, and m_settings.

◆ BOARD_NETLIST_UPDATER() [2/2]

BOARD_NETLIST_UPDATER::BOARD_NETLIST_UPDATER ( TOOL_MANAGER * aToolManager,
BOARD * aBoard )

Construct an updater without a board editor frame (headless).

Definition at line 65 of file board_netlist_updater.cpp.

References GetAppSettings(), m_board, m_commit, m_frame, m_reporter, and m_settings.

◆ ~BOARD_NETLIST_UPDATER()

BOARD_NETLIST_UPDATER::~BOARD_NETLIST_UPDATER ( )

Definition at line 75 of file board_netlist_updater.cpp.

Member Function Documentation

◆ addNewFootprint() [1/2]

FOOTPRINT * BOARD_NETLIST_UPDATER::addNewFootprint ( COMPONENT * aComponent)
private

Definition at line 173 of file board_netlist_updater.cpp.

References addNewFootprint(), and COMPONENT::GetFPID().

Referenced by addNewFootprint(), and UpdateNetlist().

◆ addNewFootprint() [2/2]

◆ ApplyChainAssignments()

void BOARD_NETLIST_UPDATER::ApplyChainAssignments ( BOARD * aBoard,
const NETLIST & aNetlist,
REPORTER * aReporter,
bool aDryRun )
static

Apply the netlist's chain assignments to every NETINFO_ITEM on the board.

Whenever a net's chain name is renamed or cleared, the prior terminal-pad pointer and its persisted UUID are dropped together so the pair stays in lockstep and stale terminals from a previous session do not bleed into the resaved board.

Definition at line 80 of file board_netlist_updater.cpp.

References _, NETLIST::GetNetChainFor(), BOARD::GetNetInfo(), next(), REPORTER::Report(), and RPT_SEVERITY_WARNING.

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and UpdateNetlist().

◆ applyComponentVariants()

◆ cacheCopperZoneConnections()

void BOARD_NETLIST_UPDATER::cacheCopperZoneConnections ( )
private

Definition at line 1662 of file board_netlist_updater.cpp.

References m_board, and m_zoneConnectionsCache.

Referenced by UpdateNetlist().

◆ cacheNetname()

void BOARD_NETLIST_UPDATER::cacheNetname ( PAD * aPad,
const wxString & aNetname )
private

Definition at line 115 of file board_netlist_updater.cpp.

References m_padNets.

Referenced by updateComponentPadConnections().

◆ cachePinFunction()

void BOARD_NETLIST_UPDATER::cachePinFunction ( PAD * aPad,
const wxString & aPinFunction )
private

Definition at line 130 of file board_netlist_updater.cpp.

References m_padPinFunctions.

Referenced by updateComponentPadConnections().

◆ estimateFootprintInsertionPosition()

VECTOR2I BOARD_NETLIST_UPDATER::estimateFootprintInsertionPosition ( )
private

◆ fpidsEquivalent()

bool BOARD_NETLIST_UPDATER::fpidsEquivalent ( const LIB_ID & aBoardFpid,
const LIB_ID & aSchematicFpid )
static

Compare a board footprint ID against a schematic-derived footprint ID, ignoring the library nickname when the schematic side uses a legacy bare footprint name.

A board footprint always carries a library nickname, so a strict equality test would never match a legacy schematic FPID and would wrongly treat the matching board footprint as a non-base variant (which gets flagged 'Do not place').

Definition at line 1357 of file board_netlist_updater.cpp.

References LIB_ID::GetLibItemName(), and LIB_ID::IsLegacy().

Referenced by applyComponentVariants(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and UpdateNetlist().

◆ GetAddedFootprints()

std::vector< FOOTPRINT * > BOARD_NETLIST_UPDATER::GetAddedFootprints ( ) const
inline

◆ GetAddedGroups()

std::vector< PCB_GROUP * > BOARD_NETLIST_UPDATER::GetAddedGroups ( ) const
inline

Definition at line 123 of file board_netlist_updater.h.

References m_addedGroups.

Referenced by DIALOG_UPDATE_PCB::PerformUpdate().

◆ GetErrorCount()

int BOARD_NETLIST_UPDATER::GetErrorCount ( ) const
inline

Definition at line 125 of file board_netlist_updater.h.

References m_errorCount.

◆ getNetname()

wxString BOARD_NETLIST_UPDATER::getNetname ( PAD * aPad)
private

◆ GetNewFootprintCount()

int BOARD_NETLIST_UPDATER::GetNewFootprintCount ( ) const
inline

Definition at line 129 of file board_netlist_updater.h.

References m_newFootprintsCount.

◆ getPinFunction()

wxString BOARD_NETLIST_UPDATER::getPinFunction ( PAD * aPad)
private

Definition at line 136 of file board_netlist_updater.cpp.

References PAD::GetPinFunction(), m_isDryRun, and m_padPinFunctions.

◆ GetWarningCount()

int BOARD_NETLIST_UPDATER::GetWarningCount ( ) const
inline

Definition at line 127 of file board_netlist_updater.h.

References m_warningCount.

◆ replaceFootprint()

◆ SetApplyDesignBlockLayouts()

void BOARD_NETLIST_UPDATER::SetApplyDesignBlockLayouts ( bool aEnabled)
inline

Definition at line 109 of file board_netlist_updater.h.

References m_applyDesignBlockLayouts.

Referenced by DIALOG_UPDATE_PCB::PerformUpdate().

◆ SetDeleteUnusedFootprints()

void BOARD_NETLIST_UPDATER::SetDeleteUnusedFootprints ( bool aEnabled)
inline

◆ SetIsDryRun()

void BOARD_NETLIST_UPDATER::SetIsDryRun ( bool aEnabled)
inline

◆ SetLookupByTimestamp()

void BOARD_NETLIST_UPDATER::SetLookupByTimestamp ( bool aEnabled)
inline

◆ SetOverrideLocks()

void BOARD_NETLIST_UPDATER::SetOverrideLocks ( bool aOverride)
inline

◆ SetRemoveExtraFields()

void BOARD_NETLIST_UPDATER::SetRemoveExtraFields ( bool aEnabled)
inline

Definition at line 119 of file board_netlist_updater.h.

References m_removeExtraFields.

Referenced by DIALOG_UPDATE_PCB::PerformUpdate().

◆ SetReplaceFootprints()

void BOARD_NETLIST_UPDATER::SetReplaceFootprints ( bool aEnabled)
inline

◆ SetReporter()

void BOARD_NETLIST_UPDATER::SetReporter ( REPORTER * aReporter)
inline

Enable dry run mode (just report, no changes to PCB).

Definition at line 100 of file board_netlist_updater.h.

References m_reporter.

Referenced by DIALOG_IMPORT_NETLIST::loadNetlist(), and DIALOG_UPDATE_PCB::PerformUpdate().

◆ SetTransferGroups()

void BOARD_NETLIST_UPDATER::SetTransferGroups ( bool aEnabled)
inline

◆ SetUpdateFields()

void BOARD_NETLIST_UPDATER::SetUpdateFields ( bool aEnabled)
inline

◆ testConnectivity()

◆ updateComponentClass()

◆ updateComponentPadConnections()

◆ updateComponentUnits()

bool BOARD_NETLIST_UPDATER::updateComponentUnits ( FOOTPRINT * aFootprint,
COMPONENT * aNewComponent )
private

◆ updateCopperZoneNets()

◆ updateFootprintGroup()

◆ updateFootprintParameters()

bool BOARD_NETLIST_UPDATER::updateFootprintParameters ( FOOTPRINT * aFootprint,
COMPONENT * aNetlistComponent )
private

Definition at line 430 of file board_netlist_updater.cpp.

References _, FOOTPRINT::Add(), KIID_PATH::AsString(), B_Fab, FOOTPRINT::Clone(), copy, EscapeHTML(), F_Cu, F_Fab, FOOTPRINT, FP_DNP, FP_EXCLUDE_FROM_BOM, FP_EXCLUDE_FROM_POS_FILES, FOOTPRINT::GetAttributes(), GetCanonicalFieldName(), COMPONENT::GetDuplicatePadNumbersAreJumpers(), FOOTPRINT::GetDuplicatePadNumbersAreJumpers(), FOOTPRINT::GetField(), COMPONENT::GetFields(), FOOTPRINT::GetFields(), FOOTPRINT::GetFilters(), COMPONENT::GetFPID(), FOOTPRINT::GetFPID(), FOOTPRINT::GetFPIDAsString(), COMPONENT::GetHumanReadablePath(), COMPONENT::GetKIIDs(), FOOTPRINT::GetLayer(), FOOTPRINT::GetOrientation(), COMPONENT::GetPath(), FOOTPRINT::GetPath(), FOOTPRINT::GetPosition(), COMPONENT::GetProperties(), COMPONENT::GetReference(), FOOTPRINT::GetReference(), FOOTPRINT::GetSheetfile(), FOOTPRINT::GetSheetname(), COMPONENT::GetValue(), FOOTPRINT::GetValue(), COMPONENT::GetVariants(), FOOTPRINT::HasField(), COMPONENT::JumperPadGroups(), FOOTPRINT::JumperPadGroups(), m_board, m_commit, COMPONENT_VARIANT::m_dnp, COMPONENT_VARIANT::m_excludedFromBOM, COMPONENT_VARIANT::m_excludedFromPosFiles, COMPONENT_VARIANT::m_fields, m_frame, COMPONENT_VARIANT::m_hasDnp, COMPONENT_VARIANT::m_hasExcludedFromBOM, COMPONENT_VARIANT::m_hasExcludedFromPosFiles, m_isDryRun, m_removeExtraFields, m_reporter, m_updateFields, name, REFERENCE, FOOTPRINT::Remove(), PCB_TEXT::Rotate(), RPT_SEVERITY_ACTION, FOOTPRINT::SetAttributes(), FOOTPRINT::SetDuplicatePadNumbersAreJumpers(), FOOTPRINT::SetFilters(), BOARD_ITEM::SetLayer(), PCB_FIELD::SetName(), FOOTPRINT::SetPath(), PCB_TEXT::SetPosition(), FOOTPRINT::SetReference(), FOOTPRINT::SetSheetfile(), FOOTPRINT::SetSheetname(), EDA_TEXT::SetText(), FOOTPRINT::SetValue(), EDA_TEXT::SetVisible(), PCB_TEXT::StyleFromSettings(), USER, and VALUE.

Referenced by UpdateNetlist().

◆ updateGroups()

◆ UpdateNetlist()

bool BOARD_NETLIST_UPDATER::UpdateNetlist ( NETLIST & aNetlist)

Update the board's components according to the new netlist.

See BOARD_NETLIST_UPDATER class description for the details of the process.

Parameters
aNetlistthe new netlist
Returns
true if process was completed successfully

Definition at line 2005 of file board_netlist_updater.cpp.

References _, addNewFootprint(), ApplyChainAssignments(), applyComponentVariants(), cacheCopperZoneConnections(), chain, comp, LIB_ID::empty(), EscapeHTML(), expected, FOOTPRINT::FindPadByNumber(), FOOTPRINT, LIB_ID::Format(), FP_BOARD_ONLY, fpidsEquivalent(), BOX2< Vec >::GetBottom(), FOOTPRINT::GetBoundingBox(), GetCanonicalFieldName(), NETLIST::GetComponent(), NETLIST::GetComponentByPath(), NETLIST::GetComponentByReference(), NETLIST::GetCount(), COMPONENT::GetFPID(), COMPONENT::GetKIIDs(), BOX2< Vec >::GetLeft(), BOARD_CONNECTED_ITEM::GetNet(), NETINFO_ITEM::GetNetChain(), NETLIST::GetNetChainColors(), NETLIST::GetNetChainNetClasses(), NETLIST::GetNetChainTerminalPins(), COMPONENT::GetPath(), PAD::GetPosition(), COMPONENT::GetProperties(), COMPONENT::GetReference(), BOX2< Vec >::GetRight(), NETLIST::GetSignalChainClasses(), BOX2< Vec >::GetTop(), NETLIST::GetVariantDescription(), NETLIST::GetVariantNames(), COMPONENT::GetVariants(), LIB_ID::IsLegacy(), m_addedNets, m_board, m_commit, m_deleteUnusedFootprints, m_errorCount, m_frame, m_isDryRun, m_lookupByTimestamp, m_newFootprintsCount, m_overrideLocks, m_replaceFootprints, m_reporter, m_schematicNetNames, EDA_ITEM::m_Uuid, m_warningCount, name, pad, LIB_ID::Parse(), pin, replaceFootprint(), RPT_SEVERITY_ACTION, RPT_SEVERITY_ERROR, RPT_SEVERITY_INFO, RPT_SEVERITY_WARNING, KIGFX::COLOR4D::SetFromHexString(), NETINFO_ITEM::SetTerminal(), testConnectivity(), updateComponentClass(), updateComponentPadConnections(), updateComponentUnits(), updateCopperZoneNets(), updateFootprintGroup(), updateFootprintParameters(), updateGroups(), UTF8::wx_str(), VECTOR2< T >::x, VECTOR2< T >::y, and ZONE_FILL_OP.

Referenced by PCB_EDIT_FRAME::KiwayMailIn(), DIALOG_IMPORT_NETLIST::loadNetlist(), and DIALOG_UPDATE_PCB::PerformUpdate().

Member Data Documentation

◆ m_addedFootprints

std::vector<FOOTPRINT*> BOARD_NETLIST_UPDATER::m_addedFootprints
private

Definition at line 188 of file board_netlist_updater.h.

Referenced by addNewFootprint(), and GetAddedFootprints().

◆ m_addedGroups

std::vector<PCB_GROUP*> BOARD_NETLIST_UPDATER::m_addedGroups
private

Definition at line 189 of file board_netlist_updater.h.

Referenced by GetAddedGroups(), and updateFootprintGroup().

◆ m_addedNets

std::map<wxString, NETINFO_ITEM*> BOARD_NETLIST_UPDATER::m_addedNets
private

◆ m_applyDesignBlockLayouts

bool BOARD_NETLIST_UPDATER::m_applyDesignBlockLayouts = false
private

Definition at line 197 of file board_netlist_updater.h.

Referenced by SetApplyDesignBlockLayouts().

◆ m_board

◆ m_commit

◆ m_deleteUnusedFootprints

bool BOARD_NETLIST_UPDATER::m_deleteUnusedFootprints = false
private

Definition at line 193 of file board_netlist_updater.h.

Referenced by SetDeleteUnusedFootprints(), and UpdateNetlist().

◆ m_errorCount

int BOARD_NETLIST_UPDATER::m_errorCount = 0
private

◆ m_frame

PCB_EDIT_FRAME* BOARD_NETLIST_UPDATER::m_frame
private

◆ m_isDryRun

◆ m_lookupByTimestamp

bool BOARD_NETLIST_UPDATER::m_lookupByTimestamp = false
private

Definition at line 198 of file board_netlist_updater.h.

Referenced by SetLookupByTimestamp(), and UpdateNetlist().

◆ m_newFootprintsCount

int BOARD_NETLIST_UPDATER::m_newFootprintsCount = 0
private

◆ m_oldToNewNets

std::map<wxString, wxString> BOARD_NETLIST_UPDATER::m_oldToNewNets
private

Definition at line 185 of file board_netlist_updater.h.

Referenced by updateComponentPadConnections(), and updateCopperZoneNets().

◆ m_overrideLocks

bool BOARD_NETLIST_UPDATER::m_overrideLocks = false
private

Definition at line 199 of file board_netlist_updater.h.

Referenced by replaceFootprint(), SetOverrideLocks(), and UpdateNetlist().

◆ m_padNets

std::map<PAD*, wxString> BOARD_NETLIST_UPDATER::m_padNets
private

Definition at line 186 of file board_netlist_updater.h.

Referenced by cacheNetname(), and getNetname().

◆ m_padPinFunctions

std::map<PAD*, wxString> BOARD_NETLIST_UPDATER::m_padPinFunctions
private

Definition at line 187 of file board_netlist_updater.h.

Referenced by cachePinFunction(), and getPinFunction().

◆ m_removeExtraFields

bool BOARD_NETLIST_UPDATER::m_removeExtraFields = false
private

Definition at line 201 of file board_netlist_updater.h.

Referenced by SetRemoveExtraFields(), and updateFootprintParameters().

◆ m_replaceFootprints

bool BOARD_NETLIST_UPDATER::m_replaceFootprints = true
private

Definition at line 195 of file board_netlist_updater.h.

Referenced by SetReplaceFootprints(), and UpdateNetlist().

◆ m_reporter

◆ m_schematicNetNames

std::set<wxString> BOARD_NETLIST_UPDATER::m_schematicNetNames
private

Definition at line 191 of file board_netlist_updater.h.

Referenced by updateComponentPadConnections(), and UpdateNetlist().

◆ m_settings

PCBNEW_SETTINGS* BOARD_NETLIST_UPDATER::m_settings
private

◆ m_transferGroups

bool BOARD_NETLIST_UPDATER::m_transferGroups = false
private

Definition at line 196 of file board_netlist_updater.h.

Referenced by SetTransferGroups(), updateFootprintGroup(), and updateGroups().

◆ m_updateFields

bool BOARD_NETLIST_UPDATER::m_updateFields = false
private

Definition at line 200 of file board_netlist_updater.h.

Referenced by SetUpdateFields(), and updateFootprintParameters().

◆ m_warningCount

int BOARD_NETLIST_UPDATER::m_warningCount = 0
private

◆ m_zoneConnectionsCache

std::map<ZONE*, std::vector<PAD*> > BOARD_NETLIST_UPDATER::m_zoneConnectionsCache
private

Definition at line 184 of file board_netlist_updater.h.

Referenced by cacheCopperZoneConnections(), and updateCopperZoneNets().


The documentation for this class was generated from the following files: