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

Calculate the connectivity of a schematic and generate netlists. More...

#include <connection_graph.h>

Public Types

using CHAIN_TERMINAL_REF = SCH_CONNECTIVITY::NETCHAIN_MANAGER::CHAIN_TERMINAL_REF
 
using CHAIN_TERMINAL_REFS = SCH_CONNECTIVITY::NETCHAIN_MANAGER::CHAIN_TERMINAL_REFS
 

Public Member Functions

 CONNECTION_GRAPH (SCHEMATIC *aSchematic=nullptr, SCH_CONNECTIVITY::NETCHAIN_MANAGER *aNetChains=nullptr)
 
 ~CONNECTION_GRAPH ()
 
 CONNECTION_GRAPH (const CONNECTION_GRAPH &)=delete
 
CONNECTION_GRAPH & operator= (const CONNECTION_GRAPH &)=delete
 
void Reset ()
 
void SetSchematic (SCHEMATIC *aSchematic)
 
SCHEMATIC * GetSchematic () const
 
void SetLastCodes (const CONNECTION_GRAPH *aOther)
 
void Recalculate (const SCH_SHEET_LIST &aSheetList, bool aUnconditional=false, std::function< void(SCH_ITEM *)> *aChangedItemHandler=nullptr, PROGRESS_REPORTER *aProgressReporter=nullptr)
 Update the connection graph for the given list of sheets.
 
std::shared_ptr< BUS_ALIAS > GetBusAlias (const wxString &aName)
 Return a bus alias pointer for the given name if it exists (from cache)
 
std::vector< const CONNECTION_SUBGRAPH * > GetBusesNeedingMigration ()
 Determine which subgraphs have more than one conflicting bus label.
 
int RunERC ()
 Run electrical rule checks on the connectivity graph.
 
const NET_MAP & GetNetMap () const
 
SCH_NETCHAIN * GetNetChainForNet (const wxString &aNet)
 
SCH_NETCHAIN * GetNetChainByName (const wxString &aName)
 
void SetNetChainNetClassOverrides (const std::map< wxString, wxString > &aOverrides)
 Stash per-net-chain netclass overrides read from the schematic file.
 
const std::map< wxString, wxString > & GetNetChainNetClassOverrides () const
 
void SetNetChainTerminalRefOverrides (const std::map< wxString, CHAIN_TERMINAL_REFS > &aRefs)
 
const std::map< wxString, CHAIN_TERMINAL_REFS > & GetNetChainTerminalRefOverrides () const
 
void SetNetChainColorOverrides (const std::map< wxString, COLOR4D > &aOverrides)
 
const std::map< wxString, COLOR4D > & GetNetChainColorOverrides () const
 
void SetNetChainMemberNetOverrides (const std::map< wxString, std::set< wxString > > &aOverrides)
 Stash per-chain member-net lists read from the schematic file.
 
const std::map< wxString, std::set< wxString > > & GetNetChainMemberNetOverrides () const
 
CONNECTION_SUBGRAPH * FindFirstSubgraphByName (const wxString &aNetName)
 Retrieve a subgraph for the given net name, if one exists.
 
CONNECTION_SUBGRAPH * GetSubgraphForItem (SCH_ITEM *aItem) const
 
CONNECTION_SUBGRAPH * GetSubgraphForItemOnSheet (SCH_ITEM *aItem, const SCH_SHEET_PATH &aSheetPath) const
 Return the subgraph containing an item on a specific sheet path.
 
const std::vector< CONNECTION_SUBGRAPH * > & GetAllSubgraphs (const wxString &aNetName) const
 
std::vector< wxString > GetEquivalentBusNames (const wxString &aBusName) const
 Map a bus group name between its alias and expanded forms ({MIXED_BUS} <-> {FOO BAR HAM EGGS}).
 
wxString GetResolvedSubgraphName (const CONNECTION_SUBGRAPH *aSubGraph) const
 Return the fully-resolved netname for a given subgraph.
 
std::set< std::pair< SCH_SHEET_PATH, SCH_ITEM * > > ExtractAffectedItems (const std::set< SCH_ITEM * > &aItems)
 For a set of items, this will remove the connected items and their associated data including subgraphs and generated codes from the connection graph.
 
void Merge (CONNECTION_GRAPH &aGraph)
 Combine the input graph contents into the current graph.
 
void RemoveItem (SCH_ITEM *aItem)
 
void ExchangeItem (SCH_ITEM *aOldItem, SCH_ITEM *aNewItem)
 Replace all references to aOldItem with aNewItem in the graph.
 
bool IsMinor () const
 We modify how we handle the connectivity graph for small graphs vs large graphs.
 
const std::vector< std::unique_ptr< SCH_NETCHAIN > > & GetPotentialNetChains () const
 Potential net chains are inferred groupings produced by RebuildNetChains() but not yet user-committed.
 
SCH_NETCHAIN * CreateNetChainFromPotential (SCH_NETCHAIN *aPotential, const wxString &aName)
 Promote a potential net chain to an actual user net chain with the provided name.
 
SCH_NETCHAIN * CreateManualNetChain (const wxString &aName, const std::set< class SCH_SYMBOL * > &aSymbols, const std::set< wxString > &aNets, const KIID &aTerminalPinA, const KIID &aTerminalPinB, const wxString &aRefA, const wxString &aPinNumA, const wxString &aRefB, const wxString &aPinNumB)
 Commit a manually-defined net chain that the inferred-potential pass did not produce.
 
const std::vector< std::unique_ptr< SCH_NETCHAIN > > & GetCommittedNetChains () const
 Return user-created (committed) net chains (legacy accessor retained under net-chain API).
 
void ApplyNetChainNetclasses ()
 Mirror each committed net chain's netclass override into the project NET_SETTINGS as a chain-derived pattern assignment, so SCH_ITEM::GetEffectiveNetClass() resolves the chain's netclass for member nets the same way board_netlist_updater does on the PCB side.
 
bool NetChainsBuilt () const
 Returns true once RebuildNetChains() has completed at least once on this graph.
 
bool DeleteCommittedNetChain (const wxString &aName)
 Delete a committed net chain by name.
 
bool RenameCommittedNetChain (const wxString &aOld, const wxString &aNew)
 Rename a committed net chain.
 

Static Public Member Functions

static std::function< void(SCH_CONNECTIVITY::NETCHAIN_MANAGER &)> & RebuildNetChainsTestHook ()
 QA hook receives candidate state before publication and may throw to test rollback.
 

Private Member Functions

void updateSymbolConnectivity (const SCH_SHEET_PATH &aSheet, SCH_SYMBOL *aSymbol, std::map< VECTOR2I, std::vector< SCH_ITEM * > > &aConnectionMap)
 Update the connectivity of a symbol and its pins.
 
void updatePinConnectivity (const SCH_SHEET_PATH &aSheet, SCH_PIN *aPin, SCH_CONNECTION *aConnection)
 Update the connectivity of a pin and its connections.
 
void updateGenericItemConnectivity (const SCH_SHEET_PATH &aSheet, SCH_ITEM *aItem, std::map< VECTOR2I, std::vector< SCH_ITEM * > > &aConnectionMap)
 Update the connectivity of items that are not pins or symbols.
 
void updateItemConnectivity (const SCH_SHEET_PATH &aSheet, const std::vector< SCH_ITEM * > &aItemList)
 Update the graphical connectivity between items (i.e.
 
void buildConnectionGraph (std::function< void(SCH_ITEM *)> *aChangedItemHandler, bool aUnconditional)
 Generate the connection graph (after all item connectivity has been updated).
 
void buildItemSubGraphs ()
 Generate individual item subgraphs on a per-sheet basis.
 
void resolveAllDrivers ()
 Find all subgraphs in the connection graph and calls ResolveDrivers() in parallel.
 
void collectAllDriverValues ()
 Map the driver values for each subgraph.
 
void generateGlobalPowerPinSubGraphs ()
 Iterate through the global power pins to collect the global labels as drivers.
 
void generateBusAliasMembers ()
 Iterate through labels to create placeholders for bus elements.
 
void processSubGraphs ()
 Process all subgraphs to assign netcodes and merge subgraphs based on labels.
 
int assignNewNetCode (SCH_CONNECTION &aConnection)
 Helper to assign a new net code to a connection.
 
int getOrCreateNetCode (const wxString &aNetName)
 
void assignNetCodesToBus (SCH_CONNECTION *aConnection)
 Ensure all members of the bus connection have a valid net code assigned.
 
void propagateToNeighbors (CONNECTION_SUBGRAPH *aSubgraph, bool aForce)
 Update all neighbors of a subgraph with this one's connectivity info.
 
void removeSubgraphs (std::set< CONNECTION_SUBGRAPH * > &aSubgraphs)
 Remove references to the given subgraphs from all structures in the connection graph.
 
std::shared_ptr< SCH_CONNECTION > getDefaultConnection (SCH_ITEM *aItem, CONNECTION_SUBGRAPH *aSubgraph)
 Build a new default connection for the given item based on its properties.
 
void recacheSubgraphName (CONNECTION_SUBGRAPH *aSubgraph, const wxString &aOldName)
 
bool ercCheckMultipleDrivers (const CONNECTION_SUBGRAPH *aSubgraph)
 If the subgraph has multiple drivers of equal priority that are graphically connected, ResolveDrivers() will have stored the second driver for use by this function, which actually creates the markers.
 
bool ercCheckBusToNetConflicts (const CONNECTION_SUBGRAPH *aSubgraph)
 Check one subgraph for conflicting connections between net and bus labels.
 
bool ercCheckBusToBusConflicts (const CONNECTION_SUBGRAPH *aSubgraph)
 Check one subgraph for conflicting connections between two bus items.
 
bool ercCheckBusToBusEntryConflicts (const CONNECTION_SUBGRAPH *aSubgraph)
 Check one subgraph for conflicting bus entry to bus connections.
 
bool ercCheckNoConnects (const CONNECTION_SUBGRAPH *aSubgraph)
 Check one subgraph for proper presence or absence of no-connect symbols.
 
bool ercCheckFloatingWires (const CONNECTION_SUBGRAPH *aSubgraph)
 Check one subgraph for floating wires.
 
bool ercCheckDanglingWireEndpoints (const CONNECTION_SUBGRAPH *aSubgraph)
 Check one subgraph for dangling wire endpoints.
 
void collectBusMemberSiblings (const CONNECTION_SUBGRAPH *aBusParent, const wxString &aMemberName, std::unordered_set< const CONNECTION_SUBGRAPH * > &aOut) const
 Find bus members on other sheets that share aBusParent's bus and member name.
 
bool ercCheckLabels (const CONNECTION_SUBGRAPH *aSubgraph)
 Check one subgraph for proper connection of labels.
 
int ercCheckDirectiveLabels ()
 Check directive labels should be connected to something.
 
int ercCheckHierSheets ()
 Check that a hierarchical sheet has at least one matching label inside the sheet for each port on the parent sheet object.
 
int ercCheckSingleGlobalLabel ()
 Check that a global label is instantiated more that once across the schematic hierarchy.
 
size_t hasPins (const CONNECTION_SUBGRAPH *aLocSubgraph)
 Get the number of pins in a given subgraph.
 
void RebuildNetChains ()
 
std::unique_ptr< SCH_CONNECTIVITY::NETCHAIN_MANAGER > ReleaseNetChains () noexcept
 The graph keeps using the released manager.
 
void BorrowNetChains (SCH_CONNECTIVITY::NETCHAIN_MANAGER &aManager) noexcept
 

Static Private Member Functions

static SCH_CONNECTION * matchBusMember (SCH_CONNECTION *aBusConnection, SCH_CONNECTION *aSearch)
 Search for a matching bus member inside a bus connection.
 
static SCH_NETCHAIN * resolvePotentialChainByTerminals (const CHAIN_TERMINAL_REFS &aTermRefs, const std::map< std::pair< wxString, wxString >, wxString > &aRefPinToNet, const std::vector< std::unique_ptr< SCH_NETCHAIN > > &aPotentials, const wxString &aChainName)
 Disambiguate the saved (refA.pinA, refB.pinB) terminal pair against the current set of potential net chains.
 

Private Attributes

SCH_SHEET_LIST m_sheetList
 All the sheets in the schematic (as long as we don't have partial updates).
 
std::vector< SCH_ITEM * > m_items
 All connectable items in the schematic.
 
std::vector< CONNECTION_SUBGRAPH * > m_subgraphs
 The owner of all CONNECTION_SUBGRAPH objects.
 
std::vector< CONNECTION_SUBGRAPH * > m_driver_subgraphs
 Cache of a subset of m_subgraphs.
 
std::unordered_map< SCH_SHEET_PATH, std::vector< CONNECTION_SUBGRAPH * > > m_sheet_to_subgraphs_map
 Cache to lookup subgraphs in m_driver_subgraphs by sheet path.
 
std::vector< std::pair< SCH_SHEET_PATH, SCH_PIN * > > m_global_power_pins
 
std::unordered_map< wxString, std::shared_ptr< BUS_ALIAS > > m_bus_alias_cache
 
std::unordered_map< wxString, int > m_net_name_to_code_map
 
std::unordered_map< wxString, int > m_bus_name_to_code_map
 
std::unordered_map< wxString, std::vector< const CONNECTION_SUBGRAPH * > > m_global_label_cache
 
std::map< std::pair< SCH_SHEET_PATH, wxString >, std::vector< const CONNECTION_SUBGRAPH * > > m_local_label_cache
 
std::unordered_map< wxString, std::vector< CONNECTION_SUBGRAPH * > > m_net_name_to_subgraphs_map
 
std::unordered_map< SCH_ITEM *, std::vector< CONNECTION_SUBGRAPH * > > m_item_to_subgraph_map
 Every subgraph referencing the item, one per instantiating sheet path for items on shared screens.
 
NET_MAP m_net_code_to_subgraphs_map
 
std::unique_ptr< SCH_CONNECTIVITY::NETCHAIN_MANAGER > m_ownedNetChains
 
SCH_CONNECTIVITY::NETCHAIN_MANAGER * m_netChains
 
int m_last_net_code
 
int m_last_bus_code
 
int m_last_subgraph_code
 
SCHEMATIC * m_schematic
 The schematic this graph represents.
 
std::shared_ptr< CONNECTION_GRAPH_LIFETIME > m_lifetime
 Retired before graph teardown so late item destruction cannot enter this graph.
 

Friends

class SCHEMATIC
 
void boost_test_update_symbol_connectivity ()
 
void boost_test_update_generic_connectivity ()
 
void boost_test_inject_committed_net_chain (CONNECTION_GRAPH &aGraph, std::unique_ptr< SCH_NETCHAIN > aChain)
 
SCH_NETCHAIN * boost_test_resolve_potential_chain_by_terminals (const std::pair< std::pair< wxString, wxString >, std::pair< wxString, wxString > > &aTerms, const std::map< std::pair< wxString, wxString >, wxString > &aRefPinToNet, const std::vector< std::unique_ptr< SCH_NETCHAIN > > &aPotentials, const wxString &aChainName)
 

Detailed Description

Calculate the connectivity of a schematic and generate netlists.

Definition at line 380 of file connection_graph.h.

Member Typedef Documentation

◆ CHAIN_TERMINAL_REF

◆ CHAIN_TERMINAL_REFS

Constructor & Destructor Documentation

◆ CONNECTION_GRAPH() [1/2]

◆ ~CONNECTION_GRAPH()

CONNECTION_GRAPH::~CONNECTION_GRAPH ( )

Definition at line 92 of file connection_graph.cpp.

References m_lifetime, and Reset().

◆ CONNECTION_GRAPH() [2/2]

CONNECTION_GRAPH::CONNECTION_GRAPH ( const CONNECTION_GRAPH & )
delete

References CONNECTION_GRAPH().

Member Function Documentation

◆ ApplyNetChainNetclasses()

void CONNECTION_GRAPH::ApplyNetChainNetclasses ( )

Mirror each committed net chain's netclass override into the project NET_SETTINGS as a chain-derived pattern assignment, so SCH_ITEM::GetEffectiveNetClass() resolves the chain's netclass for member nets the same way board_netlist_updater does on the PCB side.

Existing chain-derived assignments are cleared first so removed or renamed chains leave no stale entries. Synthetic per-run member keys can't be matched against a resolved net name and are skipped, and a chain whose netclass no longer exists is ignored.

Definition at line 3135 of file connection_graph.cpp.

References m_netChains.

Referenced by BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), and buildConnectionGraph().

◆ assignNetCodesToBus()

void CONNECTION_GRAPH::assignNetCodesToBus ( SCH_CONNECTION * aConnection)
private

Ensure all members of the bus connection have a valid net code assigned.

Parameters
aConnectionis a bus connection.

Definition at line 3186 of file connection_graph.cpp.

References assignNewNetCode(), and SCH_CONNECTION::Members().

Referenced by processSubGraphs().

◆ assignNewNetCode()

int CONNECTION_GRAPH::assignNewNetCode ( SCH_CONNECTION & aConnection)
private

Helper to assign a new net code to a connection.

Returns
the assigned code

Definition at line 3176 of file connection_graph.cpp.

References getOrCreateNetCode(), SCH_CONNECTION::Name(), and SCH_CONNECTION::SetNetCode().

Referenced by assignNetCodesToBus(), generateBusAliasMembers(), generateGlobalPowerPinSubGraphs(), and processSubGraphs().

◆ BorrowNetChains()

void CONNECTION_GRAPH::BorrowNetChains ( SCH_CONNECTIVITY::NETCHAIN_MANAGER & aManager)
inlineprivatenoexcept

Definition at line 987 of file connection_graph.h.

References m_netChains, and m_ownedNetChains.

◆ buildConnectionGraph()

void CONNECTION_GRAPH::buildConnectionGraph ( std::function< void(SCH_ITEM *)> * aChangedItemHandler,
bool aUnconditional )
private

Generate the connection graph (after all item connectivity has been updated).

In the first phase, the algorithm iterates over all items, and then over all items that are connected (graphically) to each item, placing them into CONNECTION_SUBGRAPHs. Items that can potentially drive connectivity (i.e. labels, pins, etc.) are added to the m_drivers vector of the subgraph.

In the second phase, each subgraph is resolved. To resolve a subgraph, the driver is first selected by CONNECTION_SUBGRAPH::ResolveDrivers(), and then the connection for the chosen driver is propagated to all the other items in the subgraph.

If the unconitional flag is set, all existing net classes will be removed and re-created. Otherwise, we will preserve existing net classes that do not conflict with the new net classes.

TODO(JE): Net codes are non-deterministic. Fortunately, they are also not really used for anything. We should consider removing them entirely and just using net names everywhere.

Definition at line 2500 of file connection_graph.cpp.

References ApplyNetChainNetclasses(), buildItemSubGraphs(), BUS, SCH_CONNECTION::Clone(), collectAllDriverValues(), compareDrivers(), SCH_ITEM::Connection(), ConnTrace, DanglingProfileMask, FOR_NETNAME, generateBusAliasMembers(), generateGlobalPowerPinSubGraphs(), CONNECTION_SUBGRAPH::GetDriverPriority(), CONNECTION_SUBGRAPH::GetDriverPriority(), GetKiCadThreadPool(), CONNECTION_SUBGRAPH::GetNameForDriver(), SCH_SHEET::GetScreen(), SCH_LABEL_BASE::GetShownText(), CONNECTION_SUBGRAPH::GLOBAL_POWER_PIN, SCH_CONNECTION::IsBus(), SCH_CONNECTION::IsNet(), SCH_SCREEN::Items(), CONNECTION_SUBGRAPH::m_absorbed, CONNECTION_SUBGRAPH::m_absorbed_by, m_bus_alias_cache, CONNECTION_SUBGRAPH::m_code, CONNECTION_SUBGRAPH::m_dirty, CONNECTION_SUBGRAPH::m_driver, CONNECTION_SUBGRAPH::m_driver_connection, m_driver_subgraphs, CONNECTION_SUBGRAPH::m_drivers, m_net_code_to_subgraphs_map, m_net_name_to_subgraphs_map, m_schematic, CONNECTION_SUBGRAPH::m_sheet, m_sheet_to_subgraphs_map, matchBusMember(), SCH_CONNECTION::Name(), name, EE_RTREE::OfType(), path, pin, processSubGraphs(), propagateToNeighbors(), RebuildNetChains(), recacheSubgraphName(), resolveAllDrivers(), SCH_HIER_LABEL_T, SCH_PIN_T, SCH_SHEET_PIN_T, SCH_CONNECTION::SetType(), PROF_TIMER::Show(), and tp.

Referenced by Recalculate().

◆ buildItemSubGraphs()

◆ collectAllDriverValues()

void CONNECTION_GRAPH::collectAllDriverValues ( )
private

◆ collectBusMemberSiblings()

void CONNECTION_GRAPH::collectBusMemberSiblings ( const CONNECTION_SUBGRAPH * aBusParent,
const wxString & aMemberName,
std::unordered_set< const CONNECTION_SUBGRAPH * > & aOut ) const
private

◆ CreateManualNetChain()

SCH_NETCHAIN * CONNECTION_GRAPH::CreateManualNetChain ( const wxString & aName,
const std::set< class SCH_SYMBOL * > & aSymbols,
const std::set< wxString > & aNets,
const KIID & aTerminalPinA,
const KIID & aTerminalPinB,
const wxString & aRefA,
const wxString & aPinNumA,
const wxString & aRefB,
const wxString & aPinNumB )

Commit a manually-defined net chain that the inferred-potential pass did not produce.

Parameters
aNameName of the new chain. Must satisfy SCH_NETCHAIN::IsValidName().
aSymbolsSymbols that participate in the chain.
aNetsMember nets of the chain.
aTerminalPinAFirst terminal pin KIID.
aTerminalPinBSecond terminal pin KIID.
aRefAReference designator for the first terminal symbol.
aPinNumAPin number for the first terminal pin.
aRefBReference designator for the second terminal symbol.
aPinNumBPin number for the second terminal pin.
Returns
The new committed chain, or nullptr on name collision, name validation failure, or net-ownership collision with an existing committed chain.

Definition at line 3145 of file connection_graph.cpp.

References m_netChains.

Referenced by BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), and BOOST_FIXTURE_TEST_CASE().

◆ CreateNetChainFromPotential()

SCH_NETCHAIN * CONNECTION_GRAPH::CreateNetChainFromPotential ( SCH_NETCHAIN * aPotential,
const wxString & aName )

◆ DeleteCommittedNetChain()

bool CONNECTION_GRAPH::DeleteCommittedNetChain ( const wxString & aName)

Delete a committed net chain by name.

Clears every net-chain override map entry (netclass, colour, terminal refs, terminal pin overrides) and resets the SetNetChainName marker on every member symbol so the chain is not reapplied on the next RebuildNetChains() pass.

Returns
true if a chain with that name was found and removed.

Definition at line 3123 of file connection_graph.cpp.

References m_netChains.

Referenced by BOOST_FIXTURE_TEST_CASE(), and BOOST_FIXTURE_TEST_CASE().

◆ ercCheckBusToBusConflicts()

bool CONNECTION_GRAPH::ercCheckBusToBusConflicts ( const CONNECTION_SUBGRAPH * aSubgraph)
private

Check one subgraph for conflicting connections between two bus items.

For example, a labeled bus wire connected to a hierarchical sheet pin where the labeled bus doesn't contain any of the same bus members as the sheet pin.

Parameters
aSubgraphis the subgraph to examine.
Returns
true for no errors, false for errors.

Definition at line 4194 of file connection_graph.cpp.

References SCH_SCREEN::Append(), SCH_ITEM::Connection(), ERC_ITEM::Create(), ERCE_BUS_TO_BUS_CONFLICT, EDA_ITEM::GetPosition(), SCH_CONNECTION::IsBus(), SCH_SHEET_PATH::LastScreen(), CONNECTION_SUBGRAPH::m_items, CONNECTION_SUBGRAPH::m_sheet, SCH_CONNECTION::Members(), SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_SHEET_PIN_T, SCH_TEXT_T, and EDA_ITEM::Type().

Referenced by RunERC().

◆ ercCheckBusToBusEntryConflicts()

bool CONNECTION_GRAPH::ercCheckBusToBusEntryConflicts ( const CONNECTION_SUBGRAPH * aSubgraph)
private

Check one subgraph for conflicting bus entry to bus connections.

For example, a wire with label "A0" is connected to a bus labeled "D[8..0]"

Will also check for mistakes related to bus group names, for example: A bus group named "USB{DP DM}" should have bus entry connections like "USB.DP" but someone might accidentally just enter "DP".

Parameters
aSubgraphis the subgraph to examine.
Returns
true for no errors, false for errors.

Definition at line 4259 of file connection_graph.cpp.

References _, SCH_SCREEN::Append(), BUS, SCH_ITEM::Connection(), ERC_ITEM::Create(), ERCE_BUS_ENTRY_CONFLICT, SCH_CONNECTION::FullLocalName(), CONNECTION_SUBGRAPH::GetDriverPriority(), CONNECTION_SUBGRAPH::GetNameForDriver(), SCH_BUS_ENTRY_BASE::GetPosition(), CONNECTION_SUBGRAPH::GLOBAL_POWER_PIN, SCH_SHEET_PATH::LastScreen(), SCH_BUS_WIRE_ENTRY::m_connected_bus_item, CONNECTION_SUBGRAPH::m_driver, CONNECTION_SUBGRAPH::m_driver_connection, CONNECTION_SUBGRAPH::m_drivers, CONNECTION_SUBGRAPH::m_items, CONNECTION_SUBGRAPH::m_sheet, SCH_CONNECTION::Members(), SCH_CONNECTION::Name(), SCH_SHEET_PATH::PathHumanReadable(), SCH_BUS_WIRE_ENTRY_T, SCH_LINE_T, EDA_ITEM::Type(), and UnescapeString().

Referenced by RunERC().

◆ ercCheckBusToNetConflicts()

bool CONNECTION_GRAPH::ercCheckBusToNetConflicts ( const CONNECTION_SUBGRAPH * aSubgraph)
private

Check one subgraph for conflicting connections between net and bus labels.

For example, a net wire connected to a bus port/pin, or vice versa

Parameters
aSubgraphis the subgraph to examine.
Returns
true for no errors, false for errors.

Definition at line 4127 of file connection_graph.cpp.

References SCH_SCREEN::Append(), SCH_CONNECTION::ConfigureFromLabel(), ERC_ITEM::Create(), CTX_NETNAME, ERCE_BUS_TO_NET_CONFLICT, EscapeString(), FOR_NETNAME, SCH_ITEM::GetLayer(), EDA_ITEM::GetPosition(), SCH_CONNECTION::IsBus(), SCH_SHEET_PATH::LastScreen(), LAYER_BUS, CONNECTION_SUBGRAPH::m_items, CONNECTION_SUBGRAPH::m_sheet, EDA_ITEM::m_Uuid, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_LINE_T, SCH_SHEET_PIN_T, text, and EDA_ITEM::Type().

Referenced by RunERC().

◆ ercCheckDanglingWireEndpoints()

bool CONNECTION_GRAPH::ercCheckDanglingWireEndpoints ( const CONNECTION_SUBGRAPH * aSubgraph)
private

◆ ercCheckDirectiveLabels()

int CONNECTION_GRAPH::ercCheckDirectiveLabels ( )
private

Check directive labels should be connected to something.

Returns
the number of errors found.

Definition at line 5073 of file connection_graph.cpp.

References ERC_ITEM::Create(), ERCE_LABEL_NOT_CONNECTED, SCH_LABEL_BASE::IsDangling(), m_sheetList, SCH_DIRECTIVE_LABEL_T, and text.

Referenced by RunERC().

◆ ercCheckFloatingWires()

bool CONNECTION_GRAPH::ercCheckFloatingWires ( const CONNECTION_SUBGRAPH * aSubgraph)
private

Check one subgraph for floating wires.

Will throw an error for any subgraph that consists of just wires with no driver.

Parameters
aSubgraphis the subgraph to examine.
Returns
true for no errors, false for errors.

Definition at line 4738 of file connection_graph.cpp.

References SCH_SCREEN::Append(), ERC_ITEM::Create(), ERCE_WIRE_DANGLING, SCH_ITEM::GetLayer(), SCH_SHEET_PATH::LastScreen(), LAYER_WIRE, CONNECTION_SUBGRAPH::m_driver, CONNECTION_SUBGRAPH::m_items, CONNECTION_SUBGRAPH::m_sheet, SCH_BUS_WIRE_ENTRY_T, SCH_LINE_T, and EDA_ITEM::Type().

Referenced by RunERC().

◆ ercCheckHierSheets()

int CONNECTION_GRAPH::ercCheckHierSheets ( )
private

Check that a hierarchical sheet has at least one matching label inside the sheet for each port on the parent sheet object.

Returns
the number of errors found.

Definition at line 5101 of file connection_graph.cpp.

References _, SCH_SCREEN::Append(), ERC_ITEM::Create(), ERCE_HIERACHICAL_LABEL, ERCE_PIN_NOT_CONNECTED, FOR_NETNAME, SCH_SHEET::GetPins(), SCH_SHEET::GetScreen(), SCH_LABEL_BASE::GetShownText(), ERC_SETTINGS::IsTestEnabled(), SCH_SCREEN::Items(), m_schematic, m_sheetList, name, pin, SCH_SHEET_PATH::push_back(), SCH_HIER_LABEL_T, SCH_SHEET_T, and UnescapeString().

Referenced by RunERC().

◆ ercCheckLabels()

◆ ercCheckMultipleDrivers()

bool CONNECTION_GRAPH::ercCheckMultipleDrivers ( const CONNECTION_SUBGRAPH * aSubgraph)
private

If the subgraph has multiple drivers of equal priority that are graphically connected, ResolveDrivers() will have stored the second driver for use by this function, which actually creates the markers.

Parameters
aSubgraphis the subgraph to examine
Returns
true for no errors, false for errors

Definition at line 4083 of file connection_graph.cpp.

References _, SCH_SCREEN::Append(), ERC_ITEM::Create(), ERCE_DRIVER_CONFLICT, CONNECTION_SUBGRAPH::GetNameForDriver(), EDA_ITEM::GetPosition(), CONNECTION_SUBGRAPH::GetSheet(), SCH_PIN::IsPower(), SCH_SHEET_PATH::LastScreen(), CONNECTION_SUBGRAPH::m_driver, CONNECTION_SUBGRAPH::m_drivers, CONNECTION_SUBGRAPH::m_multiple_drivers, CONNECTION_SUBGRAPH::m_sheet, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_PIN_T, and EDA_ITEM::Type().

Referenced by RunERC().

◆ ercCheckNoConnects()

bool CONNECTION_GRAPH::ercCheckNoConnects ( const CONNECTION_SUBGRAPH * aSubgraph)
private

◆ ercCheckSingleGlobalLabel()

int CONNECTION_GRAPH::ercCheckSingleGlobalLabel ( )
private

Check that a global label is instantiated more that once across the schematic hierarchy.

Definition at line 5024 of file connection_graph.cpp.

References SCH_SCREEN::Append(), ERC_ITEM::Create(), CTX_NETNAME, ERCE_SINGLE_GLOBAL_LABEL, EscapeString(), FOR_NETNAME, EDA_ITEM::GetPosition(), SCH_TEXT::GetShownText(), SCH_SHEET_PATH::LastScreen(), m_sheetList, and SCH_GLOBAL_LABEL_T.

Referenced by RunERC().

◆ ExchangeItem()

void CONNECTION_GRAPH::ExchangeItem ( SCH_ITEM * aOldItem,
SCH_ITEM * aNewItem )

Replace all references to aOldItem with aNewItem in the graph.

Definition at line 780 of file connection_graph.cpp.

References exchange, SCH_SYMBOL::GetPins(), m_item_to_subgraph_map, m_items, m_lifetime, m_schematic, SCH_SYMBOL_T, and EDA_ITEM::Type().

◆ ExtractAffectedItems()

std::set< std::pair< SCH_SHEET_PATH, SCH_ITEM * > > CONNECTION_GRAPH::ExtractAffectedItems ( const std::set< SCH_ITEM * > & aItems)

For a set of items, this will remove the connected items and their associated data including subgraphs and generated codes from the connection graph.

Parameters
aItemsA vector of items whose presence should be removed from the graph.
Returns
The full set of all items associated with the input items that were removed.

Definition at line 1027 of file connection_graph.cpp.

References ALL_BODY_STYLES, ALL_UNITS, ConnTrace, GetAllSubgraphs(), SCH_SYMBOL::GetGraphicalPins(), CONNECTION_SUBGRAPH::GetNetName(), SCH_SHEET::GetPins(), GetSubgraphForItem(), CONNECTION_SUBGRAPH::m_code, m_items, path, pin, removeSubgraphs(), CONNECTION_SUBGRAPH::ResolveDrivers(), SCH_SHEET_T, and SCH_SYMBOL_T.

Referenced by BOOST_FIXTURE_TEST_CASE(), and SCHEMATIC::RecalculateConnections().

◆ FindFirstSubgraphByName()

CONNECTION_SUBGRAPH * CONNECTION_GRAPH::FindFirstSubgraphByName ( const wxString & aNetName)

Retrieve a subgraph for the given net name, if one exists.

Search every sheet.

Parameters
aNetNameis the full net name to search for.
Returns
the subgraph matching the query, or nullptr if none is found.

Definition at line 3812 of file connection_graph.cpp.

References m_net_name_to_subgraphs_map.

Referenced by SCH_EDIT_FRAME::RefreshConnectivity().

◆ generateBusAliasMembers()

◆ generateGlobalPowerPinSubGraphs()

◆ GetAllSubgraphs()

const std::vector< CONNECTION_SUBGRAPH * > & CONNECTION_GRAPH::GetAllSubgraphs ( const wxString & aNetName) const

◆ GetBusAlias()

std::shared_ptr< BUS_ALIAS > CONNECTION_GRAPH::GetBusAlias ( const wxString & aName)

Return a bus alias pointer for the given name if it exists (from cache)

CONNECTION_GRAPH caches these, they are owned by the SCH_SCREEN that the alias was defined on. The cache is only used to update the graph.

Definition at line 3729 of file connection_graph.cpp.

References m_bus_alias_cache.

◆ GetBusesNeedingMigration()

std::vector< const CONNECTION_SUBGRAPH * > CONNECTION_GRAPH::GetBusesNeedingMigration ( )

Determine which subgraphs have more than one conflicting bus label.

See also
DIALOG_MIGRATE_BUSES
Returns
a list of subgraphs that need migration

Definition at line 3737 of file connection_graph.cpp.

References SCH_ITEM::Connection(), ConnTrace, FOR_NETNAME, SCH_TEXT::GetShownText(), SCH_CONNECTION::IsBus(), SCH_CONNECTION::m_driver, m_subgraphs, and SCH_CONNECTION::Name().

Referenced by BOOST_FIXTURE_TEST_CASE().

◆ GetCommittedNetChains()

const std::vector< std::unique_ptr< SCH_NETCHAIN > > & CONNECTION_GRAPH::GetCommittedNetChains ( ) const
inline

Return user-created (committed) net chains (legacy accessor retained under net-chain API).

Definition at line 939 of file connection_graph.h.

References m_netChains.

Referenced by BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), and BOOST_FIXTURE_TEST_CASE().

◆ getDefaultConnection()

std::shared_ptr< SCH_CONNECTION > CONNECTION_GRAPH::getDefaultConnection ( SCH_ITEM * aItem,
CONNECTION_SUBGRAPH * aSubgraph )
private

Build a new default connection for the given item based on its properties.

Handles strong drivers (power pins and labels) only.

Parameters
aItemis an item that can generate a connection name.
aSubgraphis used to determine the sheet to use and retrieve the cached name.
Returns
a connection generated from the item, or nullptr if item is not valid.

Definition at line 3591 of file connection_graph.cpp.

References CONNECTION_SUBGRAPH::GetNameForDriver(), CONNECTION_SUBGRAPH::m_sheet, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_PIN_T, and EDA_ITEM::Type().

Referenced by processSubGraphs(), and propagateToNeighbors().

◆ GetEquivalentBusNames()

std::vector< wxString > CONNECTION_GRAPH::GetEquivalentBusNames ( const wxString & aBusName) const

Map a bus group name between its alias and expanded forms ({MIXED_BUS} <-> {FOO BAR HAM EGGS}).

Any sheet-path prefix on the input is preserved on the results so they resolve against the graph's net-name map.

Parameters
aBusNameis the bus group name, optionally sheet-path qualified.
Returns
the equivalent bus names, empty if none.

Definition at line 3880 of file connection_graph.cpp.

References CTX_NETNAME, EscapeString(), group, m_bus_alias_cache, NET_SETTINGS::ParseBusGroup(), path, and UnescapeString().

Referenced by BOOST_FIXTURE_TEST_CASE(), and BOOST_FIXTURE_TEST_CASE().

◆ GetNetChainByName()

◆ GetNetChainColorOverrides()

const std::map< wxString, COLOR4D > & CONNECTION_GRAPH::GetNetChainColorOverrides ( ) const
inline

Definition at line 508 of file connection_graph.h.

References m_netChains.

Referenced by BOOST_FIXTURE_TEST_CASE().

◆ GetNetChainForNet()

SCH_NETCHAIN * CONNECTION_GRAPH::GetNetChainForNet ( const wxString & aNet)

Definition at line 3113 of file connection_graph.cpp.

References m_netChains.

Referenced by BOOST_FIXTURE_TEST_CASE(), and BOOST_FIXTURE_TEST_CASE().

◆ GetNetChainMemberNetOverrides()

const std::map< wxString, std::set< wxString > > & CONNECTION_GRAPH::GetNetChainMemberNetOverrides ( ) const
inline

Definition at line 523 of file connection_graph.h.

References m_netChains.

Referenced by BOOST_FIXTURE_TEST_CASE(), and BOOST_FIXTURE_TEST_CASE().

◆ GetNetChainNetClassOverrides()

const std::map< wxString, wxString > & CONNECTION_GRAPH::GetNetChainNetClassOverrides ( ) const
inline

Definition at line 485 of file connection_graph.h.

References m_netChains.

Referenced by BOOST_FIXTURE_TEST_CASE().

◆ GetNetChainTerminalRefOverrides()

const std::map< wxString, CHAIN_TERMINAL_REFS > & CONNECTION_GRAPH::GetNetChainTerminalRefOverrides ( ) const
inline

Definition at line 498 of file connection_graph.h.

References m_netChains.

Referenced by BOOST_FIXTURE_TEST_CASE().

◆ GetNetMap()

◆ getOrCreateNetCode()

int CONNECTION_GRAPH::getOrCreateNetCode ( const wxString & aNetName)
private
Parameters
aNetNamestring with the netname for coding
Returns
existing netcode (if it exists) or newly created one

Definition at line 3156 of file connection_graph.cpp.

References m_last_net_code, and m_net_name_to_code_map.

Referenced by assignNewNetCode().

◆ GetPotentialNetChains()

const std::vector< std::unique_ptr< SCH_NETCHAIN > > & CONNECTION_GRAPH::GetPotentialNetChains ( ) const
inline

◆ GetResolvedSubgraphName()

wxString CONNECTION_GRAPH::GetResolvedSubgraphName ( const CONNECTION_SUBGRAPH * aSubGraph) const

Return the fully-resolved netname for a given subgraph.

Parameters
aSubGraphReference to the subgraph.
Returns
Netname string usable with m_net_name_to_subgraphs_map.

Definition at line 3786 of file connection_graph.cpp.

References CONNECTION_SUBGRAPH::GetNetName(), and m_net_name_to_subgraphs_map.

Referenced by ercCheckLabels(), and ercCheckNoConnects().

◆ GetSchematic()

SCHEMATIC * CONNECTION_GRAPH::GetSchematic ( ) const
inline

Definition at line 421 of file connection_graph.h.

References m_schematic, and SCHEMATIC.

◆ GetSubgraphForItem()

◆ GetSubgraphForItemOnSheet()

CONNECTION_SUBGRAPH * CONNECTION_GRAPH::GetSubgraphForItemOnSheet ( SCH_ITEM * aItem,
const SCH_SHEET_PATH & aSheetPath ) const

Return the subgraph containing an item on a specific sheet path.

Items on shared screens can belong to a different subgraph for each instantiating path.

Definition at line 3843 of file connection_graph.cpp.

References CONNECTION_SUBGRAPH::m_absorbed, CONNECTION_SUBGRAPH::m_absorbed_by, m_item_to_subgraph_map, and CONNECTION_SUBGRAPH::m_sheet.

◆ hasPins()

size_t CONNECTION_GRAPH::hasPins ( const CONNECTION_SUBGRAPH * aLocSubgraph)
private

Get the number of pins in a given subgraph.

Parameters
aLocSubgraphSubgraph to search
Returns
total number of pins in the subgraph

Referenced by ercCheckLabels().

◆ IsMinor()

bool CONNECTION_GRAPH::IsMinor ( ) const

We modify how we handle the connectivity graph for small graphs vs large graphs.

Partially this is to avoid unneeded complexity for small graphs, where the performance of the graph is not a concern. This is considered a temporary solution until the connectivity graph is refactored with an eye toward partial updates

Definition at line 71 of file connection_graph.cpp.

References ADVANCED_CFG::GetCfg(), m_items, and ADVANCED_CFG::m_MinorSchematicGraphSize.

◆ matchBusMember()

SCH_CONNECTION * CONNECTION_GRAPH::matchBusMember ( SCH_CONNECTION * aBusConnection,
SCH_CONNECTION * aSearch )
staticprivate

Search for a matching bus member inside a bus connection.

For bus groups, this returns a bus member that matches aSearch by name. For bus vectors, this returns a bus member that matches by vector index.

Parameters
aBusConnectionis the bus connection to search.
aSearchis the net connection to search for.
Returns
a member of aBusConnection that matches aSearch.

Definition at line 3624 of file connection_graph.cpp.

References BUS, SCH_CONNECTION::IsBus(), SCH_CONNECTION::LocalName(), SCH_CONNECTION::Members(), SCH_CONNECTION::Type(), and SCH_CONNECTION::VectorIndex().

Referenced by buildConnectionGraph(), and propagateToNeighbors().

◆ Merge()

◆ NetChainsBuilt()

bool CONNECTION_GRAPH::NetChainsBuilt ( ) const
inline

Returns true once RebuildNetChains() has completed at least once on this graph.

Definition at line 955 of file connection_graph.h.

References m_netChains.

Referenced by BOOST_FIXTURE_TEST_CASE(), and BOOST_FIXTURE_TEST_CASE().

◆ operator=()

CONNECTION_GRAPH & CONNECTION_GRAPH::operator= ( const CONNECTION_GRAPH & )
delete

References CONNECTION_GRAPH().

◆ processSubGraphs()

◆ propagateToNeighbors()

void CONNECTION_GRAPH::propagateToNeighbors ( CONNECTION_SUBGRAPH * aSubgraph,
bool aForce )
private

Update all neighbors of a subgraph with this one's connectivity info.

If this subgraph contains hierarchical links, this method will descent the hierarchy and propagate the connectivity across all linked sheets.

Parameters
aSubgraphis the subgraph being processed.
aForceprevents this routine from skipping subgraphs.

Definition at line 3207 of file connection_graph.cpp.

References SCH_CONNECTION::Clone(), ConnTrace, getDefaultConnection(), CONNECTION_SUBGRAPH::GetDriverPriority(), CONNECTION_SUBGRAPH::GetDriverPriority(), CONNECTION_SUBGRAPH::GetNameForDriver(), CONNECTION_SUBGRAPH::GLOBAL_POWER_PIN, CONNECTION_SUBGRAPH::HIER_LABEL, SCH_CONNECTION::IsBus(), SCH_CONNECTION::IsNet(), kv, SCH_CONNECTION::LocalName(), CONNECTION_SUBGRAPH::m_absorbed, CONNECTION_SUBGRAPH::m_absorbed_by, CONNECTION_SUBGRAPH::m_code, CONNECTION_SUBGRAPH::m_dirty, CONNECTION_SUBGRAPH::m_driver, CONNECTION_SUBGRAPH::m_driver_connection, CONNECTION_SUBGRAPH::m_drivers, CONNECTION_SUBGRAPH::m_graph, CONNECTION_SUBGRAPH::m_hier_children, CONNECTION_SUBGRAPH::m_hier_parent, CONNECTION_SUBGRAPH::m_hier_pins, CONNECTION_SUBGRAPH::m_hier_ports, CONNECTION_SUBGRAPH::m_multiple_drivers, CONNECTION_SUBGRAPH::m_sheet, m_sheet_to_subgraphs_map, CONNECTION_SUBGRAPH::m_strong_driver, matchBusMember(), SCH_CONNECTION::Members(), SCH_CONNECTION::Name(), path, SCH_SHEET_PATH::PathHumanReadable(), pin, propagateToNeighbors(), SCH_SHEET_PATH::push_back(), recacheSubgraphName(), SCH_CONNECTION::Sheet(), SCH_SHEET_PATH::size(), and SCH_CONNECTION::Type().

Referenced by buildConnectionGraph(), and propagateToNeighbors().

◆ RebuildNetChains()

◆ RebuildNetChainsTestHook()

std::function< void(SCH_CONNECTIVITY::NETCHAIN_MANAGER &)> & CONNECTION_GRAPH::RebuildNetChainsTestHook ( )
static

QA hook receives candidate state before publication and may throw to test rollback.

Definition at line 3049 of file connection_graph.cpp.

Referenced by BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), RebuildNetChains(), and NETCHAIN_ROLLBACK_FIXTURE::~NETCHAIN_ROLLBACK_FIXTURE().

◆ recacheSubgraphName()

void CONNECTION_GRAPH::recacheSubgraphName ( CONNECTION_SUBGRAPH * aSubgraph,
const wxString & aOldName )
private

◆ Recalculate()

void CONNECTION_GRAPH::Recalculate ( const SCH_SHEET_LIST & aSheetList,
bool aUnconditional = false,
std::function< void(SCH_ITEM *)> * aChangedItemHandler = nullptr,
PROGRESS_REPORTER * aProgressReporter = nullptr )

Update the connection graph for the given list of sheets.

Parameters
aSheetListis the list of possibly modified sheets
aUnconditionalis true if an unconditional full recalculation should be done
aChangedItemHandleran optional handler to receive any changed items
[in]aProgressReporteris the optional REPORTER object to sent output to.

Definition at line 858 of file connection_graph.cpp.

References buildConnectionGraph(), ConnTrace, DanglingProfileMask, APP_MONITOR::TRANSACTION::Finish(), APP_MONITOR::TRANSACTION::FinishSpan(), ADVANCED_CFG::GetCfg(), SCH_SHEET::GetPins(), SCH_SYMBOL::GetPins(), SCH_ITEM::GetUnit(), SCH_SYMBOL::GetUnitSelection(), PROGRESS_REPORTER::KeepRefreshing(), m_items, m_schematic, m_sheetList, pin, Reset(), SCH_SHEET_T, SCH_SYMBOL_T, PROGRESS_REPORTER::SetCurrentProgress(), SCH_ITEM::SetUnit(), PROF_TIMER::Show(), APP_MONITOR::TRANSACTION::Start(), APP_MONITOR::TRANSACTION::StartSpan(), PROF_TIMER::Stop(), SCH_SCREEN::TestDanglingEnds(), and updateItemConnectivity().

Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), checkConnectivity(), ORCAD_CONVERTER::minimizeNetLabels(), SCHEMATIC::RebuildConnectivity(), SCHEMATIC::RecalculateConnections(), and terminalNetName().

◆ ReleaseNetChains()

std::unique_ptr< SCH_CONNECTIVITY::NETCHAIN_MANAGER > CONNECTION_GRAPH::ReleaseNetChains ( )
inlineprivatenoexcept

The graph keeps using the released manager.

Definition at line 982 of file connection_graph.h.

References m_ownedNetChains.

◆ RemoveItem()

◆ removeSubgraphs()

void CONNECTION_GRAPH::removeSubgraphs ( std::set< CONNECTION_SUBGRAPH * > & aSubgraphs)
private

Remove references to the given subgraphs from all structures in the connection graph.

Parameters
aSubgraphsset of unique subgraphs to find/remove.

Definition at line 1181 of file connection_graph.cpp.

References ConnTrace, m_bus_name_to_code_map, CONNECTION_SUBGRAPH::m_bus_neighbors, CONNECTION_SUBGRAPH::m_bus_parents, m_driver_subgraphs, m_global_label_cache, m_item_to_subgraph_map, m_local_label_cache, m_net_code_to_subgraphs_map, m_net_name_to_code_map, m_net_name_to_subgraphs_map, m_sheet_to_subgraphs_map, and m_subgraphs.

Referenced by ExtractAffectedItems().

◆ RenameCommittedNetChain()

bool CONNECTION_GRAPH::RenameCommittedNetChain ( const wxString & aOld,
const wxString & aNew )

Rename a committed net chain.

Re-keys override map entries from the old name to the new one, and updates every member symbol's net-chain name marker. Returns false when the new name is empty, the old chain does not exist, or another chain already uses the new name.

Definition at line 3128 of file connection_graph.cpp.

References m_netChains.

Referenced by BOOST_FIXTURE_TEST_CASE(), and BOOST_FIXTURE_TEST_CASE().

◆ Reset()

◆ resolveAllDrivers()

void CONNECTION_GRAPH::resolveAllDrivers ( )
private

Find all subgraphs in the connection graph and calls ResolveDrivers() in parallel.

Definition at line 1786 of file connection_graph.cpp.

References ConnTrace, GetKiCadThreadPool(), m_driver_subgraphs, m_subgraphs, pin, PT_NC, SCH_BUS_WIRE_ENTRY_T, SCH_NO_CONNECT_T, SCH_PIN_T, tp, and EDA_ITEM::Type().

Referenced by buildConnectionGraph().

◆ resolvePotentialChainByTerminals()

SCH_NETCHAIN * CONNECTION_GRAPH::resolvePotentialChainByTerminals ( const CHAIN_TERMINAL_REFS & aTermRefs,
const std::map< std::pair< wxString, wxString >, wxString > & aRefPinToNet,
const std::vector< std::unique_ptr< SCH_NETCHAIN > > & aPotentials,
const wxString & aChainName )
staticprivate

Disambiguate the saved (refA.pinA, refB.pinB) terminal pair against the current set of potential net chains.

Returns the potential chain whose net set contains BOTH endpoint nets. Returning the first match that contains only one net would silently pick the wrong chain when two potentials share an endpoint but differ at the other terminal. Tested via the boost_test_resolve_potential_chain_by_terminals friend shim.

Definition at line 3103 of file connection_graph.cpp.

References SCH_CONNECTIVITY::NETCHAIN_MANAGER::resolvePotentialChainByTerminals().

Referenced by boost_test_resolve_potential_chain_by_terminals.

◆ RunERC()

int CONNECTION_GRAPH::RunERC ( )

Run electrical rule checks on the connectivity graph.

Precondition: graph is up-to-date

Returns
the number of errors found

NOTE:

We could check that labels attached to bus subgraphs follow the proper format (i.e. actually define a bus).

This check doesn't need to be here right now because labels won't actually be connected to bus wires if they aren't in the right format due to their TestDanglingEnds() implementation.

Definition at line 3965 of file connection_graph.cpp.

References ercCheckBusToBusConflicts(), ercCheckBusToBusEntryConflicts(), ercCheckBusToNetConflicts(), ercCheckDanglingWireEndpoints(), ercCheckDirectiveLabels(), ercCheckFloatingWires(), ercCheckHierSheets(), ercCheckLabels(), ercCheckMultipleDrivers(), ercCheckNoConnects(), ercCheckSingleGlobalLabel(), ERCE_BUS_ENTRY_CONFLICT, ERCE_BUS_TO_BUS_CONFLICT, ERCE_BUS_TO_NET_CONFLICT, ERCE_DRIVER_CONFLICT, ERCE_HIERACHICAL_LABEL, ERCE_LABEL_NOT_CONNECTED, ERCE_LABEL_SINGLE_PIN, ERCE_NOCONNECT_CONNECTED, ERCE_NOCONNECT_NOT_CONNECTED, ERCE_PIN_NOT_CONNECTED, ERCE_SINGLE_GLOBAL_LABEL, ERCE_UNCONNECTED_WIRE_ENDPOINT, ERCE_WIRE_DANGLING, ADVANCED_CFG::GetCfg(), ERC_SETTINGS::IsTestEnabled(), m_schematic, m_subgraphs, and ERC_TESTER::TestConnectivity().

◆ SetLastCodes()

void CONNECTION_GRAPH::SetLastCodes ( const CONNECTION_GRAPH * aOther)
inline

◆ SetNetChainColorOverrides()

void CONNECTION_GRAPH::SetNetChainColorOverrides ( const std::map< wxString, COLOR4D > & aOverrides)
inline

◆ SetNetChainMemberNetOverrides()

void CONNECTION_GRAPH::SetNetChainMemberNetOverrides ( const std::map< wxString, std::set< wxString > > & aOverrides)
inline

Stash per-chain member-net lists read from the schematic file.

Used by RebuildNetChains to reconstruct manual force-created chains, which have no underlying inferred potential to match against.

Definition at line 518 of file connection_graph.h.

References m_netChains.

Referenced by BOOST_FIXTURE_TEST_CASE().

◆ SetNetChainNetClassOverrides()

void CONNECTION_GRAPH::SetNetChainNetClassOverrides ( const std::map< wxString, wxString > & aOverrides)
inline

Stash per-net-chain netclass overrides read from the schematic file.

These are consumed by RebuildNetChains when committed chains are named: if a chain matches one of the keys, its netclass override is set from the value.

Definition at line 480 of file connection_graph.h.

References m_netChains.

Referenced by BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), BOOST_FIXTURE_TEST_CASE(), and BOOST_FIXTURE_TEST_CASE().

◆ SetNetChainTerminalRefOverrides()

void CONNECTION_GRAPH::SetNetChainTerminalRefOverrides ( const std::map< wxString, CHAIN_TERMINAL_REFS > & aRefs)
inline

Definition at line 493 of file connection_graph.h.

References m_netChains.

Referenced by BOOST_FIXTURE_TEST_CASE().

◆ SetSchematic()

void CONNECTION_GRAPH::SetSchematic ( SCHEMATIC * aSchematic)
inline

◆ updateGenericItemConnectivity()

void CONNECTION_GRAPH::updateGenericItemConnectivity ( const SCH_SHEET_PATH & aSheet,
SCH_ITEM * aItem,
std::map< VECTOR2I, std::vector< SCH_ITEM * > > & aConnectionMap )
private

◆ updateItemConnectivity()

void CONNECTION_GRAPH::updateItemConnectivity ( const SCH_SHEET_PATH & aSheet,
const std::vector< SCH_ITEM * > & aItemList )
private

Update the graphical connectivity between items (i.e.

where they touch) The items passed in must be on the same sheet.

In the first phase, all items in aItemList have their connections initialized for the given sheet (since they may have connections on more than one sheet, and each needs to be calculated individually). The graphical connection points for the item are added to a map that stores (x, y) -> [list of items].

Any item that is stored in the list of items that have a connection point at a given (x, y) location will eventually be electrically connected. This means that we can't store SCH_SYMBOLs in this map – we must store a structure that links a specific pin on a symbol back to that symbol: a SCH_PIN_CONNECTION. This wrapper class is a convenience for linking a pin and symbol to a specific (x, y) point.

In the second phase, we iterate over each value in the map, which is a vector of items that have overlapping connection points. After some checks to ensure that the items should actually connect, the items are linked together using ConnectedItems().

As a side effect, items are loaded into m_items for BuildConnectionGraph().

Parameters
aSheetis the path to the sheet of all items in the list.
aItemListis a list of items to consider.

Special case for labels that overlap wires While this is an ERC error as there is not an explicit junction, we want to enforce connectivity for all items under the label position.

Definition at line 1481 of file connection_graph.cpp.

References SCH_ITEM::AddConnectionTo(), SCH_SCREEN::GetBus(), SCH_SCREEN::GetBusesAndWires(), SCH_SHEET::GetFileName(), SCH_ITEM::GetLayer(), SCH_SCREEN::Items(), SCH_SHEET_PATH::Last(), SCH_SHEET_PATH::LastScreen(), LAYER_BUS, LAYER_BUS_JUNCTION, LAYER_JUNCTION, SCH_BUS_WIRE_ENTRY::m_connected_bus_item, SCH_BUS_BUS_ENTRY::m_connected_bus_items, m_items, EE_RTREE::Overlapping(), pin, alg::remove_duplicates(), SCH_BUS_BUS_ENTRY_T, SCH_BUS_WIRE_ENTRY_T, SCH_JUNCTION_T, SCH_SHEET_T, SCH_SYMBOL_T, updateGenericItemConnectivity(), and updateSymbolConnectivity().

Referenced by Recalculate().

◆ updatePinConnectivity()

void CONNECTION_GRAPH::updatePinConnectivity ( const SCH_SHEET_PATH & aSheet,
SCH_PIN * aPin,
SCH_CONNECTION * aConnection )
private

Update the connectivity of a pin and its connections.

This is called by updateItemConnectivity() for each pin in the schematic.

Definition at line 1424 of file connection_graph.cpp.

References SCH_ITEM::ClearConnectedItems(), SCH_PIN::GetDefaultNetName(), SCH_PIN::IsGlobalPower(), m_global_power_pins, name, NET, SCH_CONNECTION::SetName(), and SCH_CONNECTION::SetType().

Referenced by updateGenericItemConnectivity().

◆ updateSymbolConnectivity()

void CONNECTION_GRAPH::updateSymbolConnectivity ( const SCH_SHEET_PATH & aSheet,
SCH_SYMBOL * aSymbol,
std::map< VECTOR2I, std::vector< SCH_ITEM * > > & aConnectionMap )
private

Friends And Related Symbol Documentation

◆ boost_test_inject_committed_net_chain

void boost_test_inject_committed_net_chain ( CONNECTION_GRAPH & aGraph,
std::unique_ptr< SCH_NETCHAIN > aChain )
friend

◆ boost_test_resolve_potential_chain_by_terminals

SCH_NETCHAIN * boost_test_resolve_potential_chain_by_terminals ( const std::pair< std::pair< wxString, wxString >, std::pair< wxString, wxString > > & aTerms,
const std::map< std::pair< wxString, wxString >, wxString > & aRefPinToNet,
const std::vector< std::unique_ptr< SCH_NETCHAIN > > & aPotentials,
const wxString & aChainName )
friend

◆ boost_test_update_generic_connectivity

◆ boost_test_update_symbol_connectivity

◆ SCHEMATIC

Member Data Documentation

◆ m_bus_alias_cache

std::unordered_map<wxString, std::shared_ptr<BUS_ALIAS> > CONNECTION_GRAPH::m_bus_alias_cache
private

◆ m_bus_name_to_code_map

std::unordered_map<wxString, int> CONNECTION_GRAPH::m_bus_name_to_code_map
private

Definition at line 1027 of file connection_graph.h.

Referenced by Merge(), processSubGraphs(), removeSubgraphs(), and Reset().

◆ m_driver_subgraphs

std::vector<CONNECTION_SUBGRAPH*> CONNECTION_GRAPH::m_driver_subgraphs
private

◆ m_global_label_cache

std::unordered_map<wxString, std::vector<const CONNECTION_SUBGRAPH*> > CONNECTION_GRAPH::m_global_label_cache
private

◆ m_global_power_pins

◆ m_item_to_subgraph_map

std::unordered_map<SCH_ITEM*, std::vector<CONNECTION_SUBGRAPH*> > CONNECTION_GRAPH::m_item_to_subgraph_map
private

Every subgraph referencing the item, one per instantiating sheet path for items on shared screens.

Removal must purge all of them or a freed item leaves a dangling driver behind.

Definition at line 1038 of file connection_graph.h.

Referenced by buildItemSubGraphs(), ExchangeItem(), GetSubgraphForItem(), GetSubgraphForItemOnSheet(), Merge(), RebuildNetChains(), RemoveItem(), removeSubgraphs(), and Reset().

◆ m_items

◆ m_last_bus_code

int CONNECTION_GRAPH::m_last_bus_code
private

Definition at line 1047 of file connection_graph.h.

Referenced by CONNECTION_GRAPH(), Merge(), processSubGraphs(), Reset(), and SetLastCodes().

◆ m_last_net_code

int CONNECTION_GRAPH::m_last_net_code
private

Definition at line 1045 of file connection_graph.h.

Referenced by CONNECTION_GRAPH(), getOrCreateNetCode(), Merge(), Reset(), and SetLastCodes().

◆ m_last_subgraph_code

int CONNECTION_GRAPH::m_last_subgraph_code
private

◆ m_lifetime

std::shared_ptr<CONNECTION_GRAPH_LIFETIME> CONNECTION_GRAPH::m_lifetime
private
Initial value:
=
std::make_shared<CONNECTION_GRAPH_LIFETIME>( CONNECTION_GRAPH_LIFETIME{ this } )
Lets indexed items detect graph destruction without traversing their schematic parents.

Retired before graph teardown so late item destruction cannot enter this graph.

Definition at line 1054 of file connection_graph.h.

Referenced by buildItemSubGraphs(), ExchangeItem(), Merge(), and ~CONNECTION_GRAPH().

◆ m_local_label_cache

std::map< std::pair<SCH_SHEET_PATH, wxString>, std::vector<const CONNECTION_SUBGRAPH*> > CONNECTION_GRAPH::m_local_label_cache
private

◆ m_net_code_to_subgraphs_map

NET_MAP CONNECTION_GRAPH::m_net_code_to_subgraphs_map
private

◆ m_net_name_to_code_map

std::unordered_map<wxString, int> CONNECTION_GRAPH::m_net_name_to_code_map
private

Definition at line 1025 of file connection_graph.h.

Referenced by getOrCreateNetCode(), Merge(), removeSubgraphs(), and Reset().

◆ m_net_name_to_subgraphs_map

◆ m_netChains

◆ m_ownedNetChains

std::unique_ptr<SCH_CONNECTIVITY::NETCHAIN_MANAGER> CONNECTION_GRAPH::m_ownedNetChains
private

Definition at line 1042 of file connection_graph.h.

Referenced by BorrowNetChains(), CONNECTION_GRAPH(), and ReleaseNetChains().

◆ m_schematic

◆ m_sheet_to_subgraphs_map

std::unordered_map<SCH_SHEET_PATH, std::vector<CONNECTION_SUBGRAPH*> > CONNECTION_GRAPH::m_sheet_to_subgraphs_map
private

Cache to lookup subgraphs in m_driver_subgraphs by sheet path.

Definition at line 1019 of file connection_graph.h.

Referenced by buildConnectionGraph(), Merge(), processSubGraphs(), propagateToNeighbors(), removeSubgraphs(), and Reset().

◆ m_sheetList

SCH_SHEET_LIST CONNECTION_GRAPH::m_sheetList
private

All the sheets in the schematic (as long as we don't have partial updates).

Definition at line 1007 of file connection_graph.h.

Referenced by buildItemSubGraphs(), ercCheckDirectiveLabels(), ercCheckHierSheets(), ercCheckSingleGlobalLabel(), RebuildNetChains(), and Recalculate().

◆ m_subgraphs


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