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

A subgraph is a set of items that are electrically connected on a single sheet. More...

#include <connection_graph.h>

Public Types

enum class  PRIORITY {
  INVALID = -1 , NONE = 0 , PIN , SHEET_PIN ,
  HIER_LABEL , LOCAL_LABEL , POWER_PIN , GLOBAL
}
 

Public Member Functions

 CONNECTION_SUBGRAPH (CONNECTION_GRAPH *aGraph)
 
 ~CONNECTION_SUBGRAPH ()=default
 
bool ResolveDrivers (bool aCheckMultipleDrivers=false)
 Determines which potential driver should drive the subgraph. More...
 
wxString GetNetName () const
 Returns the fully-qualified net name for this subgraph (if one exists) More...
 
std::vector< SCH_ITEM * > GetVectorBusLabels () const
 Returns all the vector-based bus labels attached to this subgraph (if any) More...
 
std::vector< SCH_ITEM * > GetAllBusLabels () const
 Returns all the all bus labels attached to this subgraph (if any) More...
 
const wxString & GetNameForDriver (SCH_ITEM *aItem) const
 Returns the candidate net name for a driver. More...
 
const wxString GetNetclassForDriver (SCH_ITEM *aItem) const
 
void Absorb (CONNECTION_SUBGRAPH *aOther)
 Combines another subgraph on the same sheet into this one. More...
 
void AddItem (SCH_ITEM *aItem)
 Adds a new item to the subgraph. More...
 
void UpdateItemConnections ()
 Updates all items to match the driver connection. More...
 
const std::set< SCH_ITEM * > & GetItems () const
 Provides a read-only reference to the items in the subgraph. More...
 
void getAllConnectedItems (std::set< std::pair< SCH_SHEET_PATH, SCH_ITEM * > > &aItems, std::set< CONNECTION_SUBGRAPH * > &aSubgraphs)
 Finds all items in the subgraph as well as child subgraphs recursively. More...
 
PRIORITY GetDriverPriority ()
 
const SCH_ITEMGetDriver () const
 
const SCH_CONNECTIONGetDriverConnection () const
 
const SCH_ITEMGetNoConnect () const
 
const SCH_SHEET_PATHGetSheet () const
 
void RemoveItem (SCH_ITEM *aItem)
 

Static Public Member Functions

static PRIORITY GetDriverPriority (SCH_ITEM *aDriver)
 Return the priority (higher is more important) of a candidate driver. More...
 

Private Member Functions

wxString driverName (SCH_ITEM *aItem) const
 

Private Attributes

CONNECTION_GRAPHm_graph
 
bool m_dirty
 
bool m_absorbed
 True if this subgraph has been absorbed into another. No pointers here are safe if so! More...
 
bool m_is_bus_member
 True if the subgraph is not actually part of a net. More...
 
CONNECTION_SUBGRAPHm_absorbed_by
 If this subgraph is absorbed, points to the absorbing (and valid) subgraph. More...
 
std::set< CONNECTION_SUBGRAPH * > m_absorbed_subgraphs
 Set of subgraphs that have been absorbed by this subgraph. More...
 
long m_code
 
bool m_multiple_drivers
 True if this subgraph contains more than one driver that should be shorted together in the netlist. More...
 
bool m_strong_driver
 True if the driver is "strong": a label or power object. More...
 
bool m_local_driver
 True if the driver is a local (i.e. non-global) type. More...
 
SCH_ITEMm_bus_entry
 Bus entry in graph, if any. More...
 
std::set< SCH_ITEM * > m_drivers
 
std::unordered_map< std::shared_ptr< SCH_CONNECTION >, std::unordered_set< CONNECTION_SUBGRAPH * > > m_bus_neighbors
 If a subgraph is a bus, this map contains links between the bus members and any local sheet neighbors with the same connection name. More...
 
std::unordered_map< std::shared_ptr< SCH_CONNECTION >, std::unordered_set< CONNECTION_SUBGRAPH * > > m_bus_parents
 If this is a net, this vector contains links to any same-sheet buses that contain it. More...
 
std::set< SCH_SHEET_PIN * > m_hier_pins
 
std::set< SCH_HIERLABEL * > m_hier_ports
 
CONNECTION_SUBGRAPHm_hier_parent
 
std::unordered_set< CONNECTION_SUBGRAPH * > m_hier_children
 
std::unordered_map< SCH_ITEM *, wxString > m_driver_name_cache
 A cache of escaped netnames from schematic items. More...
 
SCH_ITEMm_driver
 Fully-resolved driver for the subgraph (might not exist in this subgraph) More...
 
std::set< SCH_ITEM * > m_items
 Contents of the subgraph. More...
 
SCH_ITEMm_no_connect
 No-connect item in graph, if any. More...
 
SCH_SHEET_PATH m_sheet
 On which logical sheet is the subgraph contained. More...
 
SCH_CONNECTIONm_driver_connection
 Cache for driver connection. More...
 

Friends

class CONNECTION_GRAPH
 

Detailed Description

A subgraph is a set of items that are electrically connected on a single sheet.

For example, a label connected to a wire and so on. A net is composed of one or more subgraphs.

A set of items that appears to be physically connected may actually be more than one subgraph, because some items don't connect electrically.

For example, multiple bus wires can come together at a junction but have different labels on each branch. Each label+wire branch is its own subgraph.

Definition at line 61 of file connection_graph.h.

Member Enumeration Documentation

◆ PRIORITY

enum class CONNECTION_SUBGRAPH::PRIORITY
strong
Enumerator
INVALID 
NONE 
PIN 
SHEET_PIN 
HIER_LABEL 
LOCAL_LABEL 
POWER_PIN 
GLOBAL 

Definition at line 64 of file connection_graph.h.

Constructor & Destructor Documentation

◆ CONNECTION_SUBGRAPH()

CONNECTION_SUBGRAPH::CONNECTION_SUBGRAPH ( CONNECTION_GRAPH aGraph)
inlineexplicit

Definition at line 76 of file connection_graph.h.

◆ ~CONNECTION_SUBGRAPH()

CONNECTION_SUBGRAPH::~CONNECTION_SUBGRAPH ( )
default

Member Function Documentation

◆ Absorb()

void CONNECTION_SUBGRAPH::Absorb ( CONNECTION_SUBGRAPH aOther)

◆ AddItem()

◆ driverName()

wxString CONNECTION_SUBGRAPH::driverName ( SCH_ITEM aItem) const
private

◆ GetAllBusLabels()

std::vector< SCH_ITEM * > CONNECTION_SUBGRAPH::GetAllBusLabels ( ) const

Returns all the all bus labels attached to this subgraph (if any)

Definition at line 272 of file connection_graph.cpp.

References m_drivers, m_sheet, SCH_GLOBAL_LABEL_T, and SCH_LABEL_T.

◆ getAllConnectedItems()

void CONNECTION_SUBGRAPH::getAllConnectedItems ( std::set< std::pair< SCH_SHEET_PATH, SCH_ITEM * > > &  aItems,
std::set< CONNECTION_SUBGRAPH * > &  aSubgraphs 
)

Finds all items in the subgraph as well as child subgraphs recursively.

Definition at line 233 of file connection_graph.cpp.

References getAllConnectedItems(), m_absorbed_by, m_absorbed_subgraphs, m_graph, m_hier_children, m_items, and m_sheet.

Referenced by getAllConnectedItems().

◆ GetDriver()

const SCH_ITEM * CONNECTION_SUBGRAPH::GetDriver ( ) const
inline
Returns
pointer to the SCH_ITEM whose name sets the subgraph netname. N.B. This item may not be in the subgraph

Definition at line 171 of file connection_graph.h.

References m_driver.

Referenced by DIALOG_MIGRATE_BUSES::onItemSelected().

◆ GetDriverConnection()

const SCH_CONNECTION * CONNECTION_SUBGRAPH::GetDriverConnection ( ) const
inline
Returns
SCH_CONNECTION object for m_driver on m_sheet

Definition at line 179 of file connection_graph.h.

References m_driver_connection.

Referenced by SCHEMATIC::GetNetClassAssignmentCandidates().

◆ GetDriverPriority() [1/2]

◆ GetDriverPriority() [2/2]

CONNECTION_SUBGRAPH::PRIORITY CONNECTION_SUBGRAPH::GetDriverPriority ( SCH_ITEM aDriver)
static

Return the priority (higher is more important) of a candidate driver.

0: Invalid driver 1: Symbol pin 2: Hierarchical sheet pin 3: Hierarchical label 4: Local label 5: Power pin 6: Global label

Parameters
aDriveris the item to inspect
Returns
a PRIORITY

Definition at line 481 of file connection_graph.cpp.

References SCH_SYMBOL::GetExcludedFromBoard(), SCH_SYMBOL::GetLibSymbolRef(), SCH_PIN::GetParentSymbol(), GLOBAL, HIER_LABEL, SCH_PIN::IsGlobalPower(), LOCAL_LABEL, NONE, PIN, POWER_PIN, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_PIN_T, SCH_SHEET_PIN_T, SHEET_PIN, and EDA_ITEM::Type().

Referenced by CONNECTION_GRAPH::ercCheckNoConnects(), and SCHEMATIC::GetNetClassAssignmentCandidates().

◆ GetItems()

const std::set< SCH_ITEM * > & CONNECTION_SUBGRAPH::GetItems ( ) const
inline

◆ GetNameForDriver()

◆ GetNetclassForDriver()

const wxString CONNECTION_SUBGRAPH::GetNetclassForDriver ( SCH_ITEM aItem) const

Definition at line 378 of file connection_graph.cpp.

References SCH_ITEM::RunOnChildren(), SCH_FIELD_T, and EDA_ITEM::Type().

◆ GetNetName()

wxString CONNECTION_SUBGRAPH::GetNetName ( ) const

◆ GetNoConnect()

const SCH_ITEM * CONNECTION_SUBGRAPH::GetNoConnect ( ) const
inline
Returns
pointer to the item causing a no-connect or nullptr if none

Definition at line 187 of file connection_graph.h.

References m_no_connect.

Referenced by NETLIST_EXPORTER_BASE::CreatePinList(), NETLIST_EXPORTER_BASE::findAllUnitsOfSymbol(), and ERC_TESTER::TestPinToPin().

◆ GetSheet()

const SCH_SHEET_PATH & CONNECTION_SUBGRAPH::GetSheet ( ) const
inline

◆ GetVectorBusLabels()

std::vector< SCH_ITEM * > CONNECTION_SUBGRAPH::GetVectorBusLabels ( ) const

Returns all the vector-based bus labels attached to this subgraph (if any)

Definition at line 301 of file connection_graph.cpp.

References m_drivers, m_sheet, SCH_GLOBAL_LABEL_T, SCH_LABEL_T, and SCH_CONNECTION::Type().

◆ RemoveItem()

void CONNECTION_SUBGRAPH::RemoveItem ( SCH_ITEM aItem)

◆ ResolveDrivers()

bool CONNECTION_SUBGRAPH::ResolveDrivers ( bool  aCheckMultipleDrivers = false)

Determines which potential driver should drive the subgraph.

If multiple possible drivers exist, picks one according to the priority. If multiple "winners" exist, returns false and sets m_driver to nullptr.

Parameters
aCheckMultipleDriverscontrols whether the second driver should be captured for ERC
Returns
true if m_driver was set, or false if a conflict occurred

Definition at line 87 of file connection_graph.cpp.

References SCH_CONNECTION::ClearDirty(), SCH_CONNECTION::ConfigureFromLabel(), SCH_ITEM::Connection(), GetDriverPriority(), SCH_PIN::GetLibPin(), GetNameForDriver(), LIB_ITEM::GetParent(), SCH_LABEL_BASE::GetShape(), HIER_LABEL, INVALID, SCH_CONNECTION::IsBus(), LIB_SYMBOL::IsPower(), SCH_CONNECTION::IsSubsetOf(), m_driver, m_driver_connection, m_drivers, m_is_bus_member, m_local_driver, m_multiple_drivers, m_sheet, m_strong_driver, PIN, POWER_PIN, SCH_PIN_T, SCH_CONNECTION::SetDriver(), SHEET_PIN, and EDA_ITEM::Type().

Referenced by CONNECTION_GRAPH::generateGlobalPowerPinSubGraphs().

◆ UpdateItemConnections()

void CONNECTION_SUBGRAPH::UpdateItemConnections ( )

Updates all items to match the driver connection.

Definition at line 454 of file connection_graph.cpp.

References SCH_CONNECTION::ClearDirty(), SCH_CONNECTION::Clone(), SCH_CONNECTION::IsBus(), SCH_CONNECTION::IsNet(), m_driver, m_driver_connection, m_graph, m_items, and m_sheet.

Friends And Related Function Documentation

◆ CONNECTION_GRAPH

friend class CONNECTION_GRAPH
friend

Definition at line 95 of file connection_graph.h.

Member Data Documentation

◆ m_absorbed

bool CONNECTION_SUBGRAPH::m_absorbed
private

True if this subgraph has been absorbed into another. No pointers here are safe if so!

Definition at line 207 of file connection_graph.h.

Referenced by Absorb(), CONNECTION_GRAPH::buildConnectionGraph(), CONNECTION_GRAPH::FindSubgraphByName(), CONNECTION_GRAPH::GetSubgraphForItem(), CONNECTION_GRAPH::processSubGraphs(), and CONNECTION_GRAPH::propagateToNeighbors().

◆ m_absorbed_by

CONNECTION_SUBGRAPH* CONNECTION_SUBGRAPH::m_absorbed_by
private

If this subgraph is absorbed, points to the absorbing (and valid) subgraph.

Definition at line 216 of file connection_graph.h.

Referenced by CONNECTION_GRAPH::buildConnectionGraph(), getAllConnectedItems(), CONNECTION_GRAPH::GetSubgraphForItem(), and CONNECTION_GRAPH::propagateToNeighbors().

◆ m_absorbed_subgraphs

std::set<CONNECTION_SUBGRAPH*> CONNECTION_SUBGRAPH::m_absorbed_subgraphs
private

Set of subgraphs that have been absorbed by this subgraph.

Definition at line 219 of file connection_graph.h.

Referenced by Absorb(), and getAllConnectedItems().

◆ m_bus_entry

SCH_ITEM* CONNECTION_SUBGRAPH::m_bus_entry
private

Bus entry in graph, if any.

Definition at line 237 of file connection_graph.h.

◆ m_bus_neighbors

std::unordered_map< std::shared_ptr<SCH_CONNECTION>, std::unordered_set<CONNECTION_SUBGRAPH*> > CONNECTION_SUBGRAPH::m_bus_neighbors
private

If a subgraph is a bus, this map contains links between the bus members and any local sheet neighbors with the same connection name.

For example, if this subgraph is a bus D[7..0], and on the same sheet there is a net with label D7, this map will contain an entry for the D7 bus member, and the set will contain a pointer to the D7 net subgraph.

Definition at line 250 of file connection_graph.h.

Referenced by Absorb(), CONNECTION_GRAPH::ExtractAffectedItems(), and CONNECTION_GRAPH::removeSubgraphs().

◆ m_bus_parents

std::unordered_map< std::shared_ptr<SCH_CONNECTION>, std::unordered_set<CONNECTION_SUBGRAPH*> > CONNECTION_SUBGRAPH::m_bus_parents
private

If this is a net, this vector contains links to any same-sheet buses that contain it.

The string key is the name of the connection that forms the link (which isn't necessarily the same as the name of the connection driving this subgraph)

Definition at line 258 of file connection_graph.h.

Referenced by Absorb(), CONNECTION_GRAPH::ExtractAffectedItems(), CONNECTION_GRAPH::processSubGraphs(), and CONNECTION_GRAPH::removeSubgraphs().

◆ m_code

◆ m_dirty

◆ m_driver

◆ m_driver_connection

◆ m_driver_name_cache

std::unordered_map<SCH_ITEM*, wxString> CONNECTION_SUBGRAPH::m_driver_name_cache
mutableprivate

A cache of escaped netnames from schematic items.

Definition at line 273 of file connection_graph.h.

Referenced by GetNameForDriver().

◆ m_drivers

◆ m_graph

◆ m_hier_children

std::unordered_set<CONNECTION_SUBGRAPH*> CONNECTION_SUBGRAPH::m_hier_children
private

◆ m_hier_parent

CONNECTION_SUBGRAPH* CONNECTION_SUBGRAPH::m_hier_parent
private

Definition at line 267 of file connection_graph.h.

Referenced by CONNECTION_GRAPH::propagateToNeighbors().

◆ m_hier_pins

std::set<SCH_SHEET_PIN*> CONNECTION_SUBGRAPH::m_hier_pins
private

Definition at line 261 of file connection_graph.h.

Referenced by AddItem(), CONNECTION_GRAPH::propagateToNeighbors(), and RemoveItem().

◆ m_hier_ports

std::set<SCH_HIERLABEL*> CONNECTION_SUBGRAPH::m_hier_ports
private

Definition at line 264 of file connection_graph.h.

Referenced by AddItem(), CONNECTION_GRAPH::propagateToNeighbors(), and RemoveItem().

◆ m_is_bus_member

bool CONNECTION_SUBGRAPH::m_is_bus_member
private

True if the subgraph is not actually part of a net.

These are created for bus members to ensure that bus-to-bus connection happens but they don't have any valid data

Definition at line 213 of file connection_graph.h.

Referenced by CONNECTION_GRAPH::generateBusAliasMembers(), and ResolveDrivers().

◆ m_items

◆ m_local_driver

bool CONNECTION_SUBGRAPH::m_local_driver
private

True if the driver is a local (i.e. non-global) type.

Definition at line 234 of file connection_graph.h.

Referenced by ResolveDrivers().

◆ m_multiple_drivers

bool CONNECTION_SUBGRAPH::m_multiple_drivers
private

True if this subgraph contains more than one driver that should be shorted together in the netlist.

For example, two labels or two power ports.

Definition at line 228 of file connection_graph.h.

Referenced by Absorb(), CONNECTION_GRAPH::ercCheckMultipleDrivers(), CONNECTION_GRAPH::processSubGraphs(), CONNECTION_GRAPH::propagateToNeighbors(), and ResolveDrivers().

◆ m_no_connect

SCH_ITEM* CONNECTION_SUBGRAPH::m_no_connect
private

◆ m_sheet

◆ m_strong_driver

bool CONNECTION_SUBGRAPH::m_strong_driver
private

True if the driver is "strong": a label or power object.

Definition at line 231 of file connection_graph.h.

Referenced by CONNECTION_GRAPH::generateBusAliasMembers(), CONNECTION_GRAPH::propagateToNeighbors(), and ResolveDrivers().


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