KiCad PCB EDA Suite
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  PRIORITY {
  PRIORITY::INVALID = -1, PRIORITY::NONE = 0, PRIORITY::PIN, PRIORITY::SHEET_PIN,
  PRIORITY::HIER_LABEL, PRIORITY::LOCAL_LABEL, PRIORITY::POWER_PIN, PRIORITY::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 * > GetBusLabels () const
 Returns all the bus labels attached to this subgraph (if any) More...
 
const wxString & GetNameForDriver (SCH_ITEM *aItem)
 Returns the candidate net name for a driver. More...
 
const wxString GetNameForDriver (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...
 
PRIORITY GetDriverPriority ()
 

Static Public Member Functions

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

Public 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...
 
CONNECTION_SUBGRAPHm_absorbed_by
 If this subgraph is absorbed, points to the absorbing (and valid) 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_no_connect
 No-connect item in graph, if any. More...
 
SCH_ITEMm_bus_entry
 Bus entry in graph, if any. More...
 
std::vector< SCH_ITEM * > m_items
 
std::vector< SCH_ITEM * > m_drivers
 
SCH_ITEMm_driver
 
SCH_SHEET_PATH m_sheet
 
SCH_CONNECTIONm_driver_connection
 Cache for driver connection. More...
 
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::vector< SCH_SHEET_PIN * > m_hier_pins
 
std::vector< SCH_HIERLABEL * > m_hier_ports
 
CONNECTION_SUBGRAPHm_hier_parent
 
std::unordered_map< SCH_ITEM *, wxString > m_driver_name_cache
 A cache of escaped netnames from schematic items. More...
 
SCH_ITEMm_first_driver
 Stores the primary driver for the multiple drivers ERC check. More...
 
SCH_ITEMm_second_driver
 Used for multiple drivers ERC message; stores the second possible driver (or nullptr) More...
 

Private Member Functions

wxString driverName (SCH_ITEM *aItem) const
 

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 60 of file connection_graph.h.

Member Enumeration Documentation

◆ PRIORITY

Enumerator
INVALID 
NONE 
PIN 
SHEET_PIN 
HIER_LABEL 
LOCAL_LABEL 
POWER_PIN 
GLOBAL 

Definition at line 63 of file connection_graph.h.

64  {
65  INVALID = -1,
66  NONE = 0,
67  PIN,
68  SHEET_PIN,
69  HIER_LABEL,
70  LOCAL_LABEL,
71  POWER_PIN,
72  GLOBAL
73  };
No updates are required.
Definition: view_item.h:51

Constructor & Destructor Documentation

◆ CONNECTION_SUBGRAPH()

CONNECTION_SUBGRAPH::CONNECTION_SUBGRAPH ( CONNECTION_GRAPH aGraph)
inlineexplicit

Definition at line 75 of file connection_graph.h.

75  :
76  m_graph( aGraph ),
77  m_dirty( false ),
78  m_absorbed( false ),
79  m_absorbed_by( nullptr ),
80  m_code( -1 ),
81  m_multiple_drivers( false ),
82  m_strong_driver( false ),
83  m_local_driver( false ),
84  m_no_connect( nullptr ),
85  m_bus_entry( nullptr ),
86  m_driver( nullptr ),
87  m_driver_connection( nullptr ),
88  m_hier_parent( nullptr ),
89  m_first_driver( nullptr ),
90  m_second_driver( nullptr )
91  {}
SCH_CONNECTION * m_driver_connection
Cache for driver connection.
SCH_ITEM * m_bus_entry
Bus entry in graph, if any.
SCH_ITEM * m_second_driver
Used for multiple drivers ERC message; stores the second possible driver (or nullptr)
bool m_absorbed
True if this subgraph has been absorbed into another. No pointers here are safe if so!
bool m_local_driver
True if the driver is a local (i.e. non-global) type.
bool m_multiple_drivers
True if this subgraph contains more than one driver that should be shorted together in the netlist.
CONNECTION_GRAPH * m_graph
bool m_strong_driver
True if the driver is "strong": a label or power object.
SCH_ITEM * m_first_driver
Stores the primary driver for the multiple drivers ERC check.
CONNECTION_SUBGRAPH * m_absorbed_by
If this subgraph is absorbed, points to the absorbing (and valid) subgraph.
CONNECTION_SUBGRAPH * m_hier_parent
SCH_ITEM * m_no_connect
No-connect item in graph, if any.

◆ ~CONNECTION_SUBGRAPH()

CONNECTION_SUBGRAPH::~CONNECTION_SUBGRAPH ( )
default

Member Function Documentation

◆ Absorb()

void CONNECTION_SUBGRAPH::Absorb ( CONNECTION_SUBGRAPH aOther)

Combines another subgraph on the same sheet into this one.

Definition at line 323 of file connection_graph.cpp.

324 {
325  wxASSERT( m_sheet == aOther->m_sheet );
326 
327  for( SCH_ITEM* item : aOther->m_items )
328  {
330  AddItem( item );
331  }
332 
333  m_bus_neighbors.insert( aOther->m_bus_neighbors.begin(), aOther->m_bus_neighbors.end() );
334  m_bus_parents.insert( aOther->m_bus_parents.begin(), aOther->m_bus_parents.end() );
335 
337 
338  aOther->m_absorbed = true;
339  aOther->m_dirty = false;
340  aOther->m_driver = nullptr;
341  aOther->m_driver_connection = nullptr;
342  aOther->m_absorbed_by = this;
343 }
SCH_SHEET_PATH m_sheet
SCH_CONNECTION * m_driver_connection
Cache for driver connection.
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...
bool m_absorbed
True if this subgraph has been absorbed into another. No pointers here are safe if so!
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.
bool m_multiple_drivers
True if this subgraph contains more than one driver that should be shorted together in the netlist.
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:131
void SetSubgraphCode(int aCode)
std::vector< SCH_ITEM * > m_items
void AddItem(SCH_ITEM *aItem)
Adds a new item to the subgraph.
CONNECTION_SUBGRAPH * m_absorbed_by
If this subgraph is absorbed, points to the absorbing (and valid) subgraph.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:193

References AddItem(), SCH_ITEM::Connection(), m_absorbed, m_absorbed_by, m_bus_neighbors, m_bus_parents, m_code, m_dirty, m_driver, m_driver_connection, m_items, m_multiple_drivers, m_sheet, and SCH_CONNECTION::SetSubgraphCode().

◆ AddItem()

void CONNECTION_SUBGRAPH::AddItem ( SCH_ITEM aItem)

Adds a new item to the subgraph.

Definition at line 346 of file connection_graph.cpp.

347 {
348  m_items.push_back( aItem );
349 
350  if( aItem->Connection( &m_sheet )->IsDriver() )
351  m_drivers.push_back( aItem );
352 
353  if( aItem->Type() == SCH_SHEET_PIN_T )
354  m_hier_pins.push_back( static_cast<SCH_SHEET_PIN*>( aItem ) );
355  else if( aItem->Type() == SCH_HIER_LABEL_T )
356  m_hier_ports.push_back( static_cast<SCH_HIERLABEL*>( aItem ) );
357 }
SCH_SHEET_PATH m_sheet
std::vector< SCH_SHEET_PIN * > m_hier_pins
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:131
std::vector< SCH_ITEM * > m_items
std::vector< SCH_ITEM * > m_drivers
bool IsDriver() const
Checks if the SCH_ITEM this connection is attached to can drive connections Drivers can be labels,...
std::vector< SCH_HIERLABEL * > m_hier_ports
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References SCH_ITEM::Connection(), SCH_CONNECTION::IsDriver(), m_drivers, m_hier_pins, m_hier_ports, m_items, m_sheet, SCH_HIER_LABEL_T, SCH_SHEET_PIN_T, and EDA_ITEM::Type().

Referenced by Absorb(), and CONNECTION_GRAPH::buildConnectionGraph().

◆ driverName()

wxString CONNECTION_SUBGRAPH::driverName ( SCH_ITEM aItem) const
private

Definition at line 269 of file connection_graph.cpp.

270 {
271  switch( aItem->Type() )
272  {
273  case SCH_PIN_T:
274  {
275  bool forceNoConnect = m_no_connect != nullptr;
276  SCH_PIN* pin = static_cast<SCH_PIN*>( aItem );
277  return pin->GetDefaultNetName( m_sheet, forceNoConnect );
278  break;
279  }
280 
281  case SCH_LABEL_T:
282  case SCH_GLOBAL_LABEL_T:
283  case SCH_HIER_LABEL_T:
284  case SCH_SHEET_PIN_T:
285  {
286  return EscapeString( static_cast<SCH_TEXT*>( aItem )->GetShownText(), CTX_NETNAME );
287  break;
288  }
289 
290  default:
291  wxFAIL_MSG( "Unhandled item type in GetNameForDriver" );
292  break;
293  }
294 
295  return wxEmptyString;
296 }
SCH_SHEET_PATH m_sheet
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
The Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which are:...
SCH_ITEM * m_no_connect
No-connect item in graph, if any.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References CTX_NETNAME, EscapeString(), m_no_connect, m_sheet, pin, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_PIN_T, SCH_SHEET_PIN_T, and EDA_ITEM::Type().

Referenced by GetNameForDriver().

◆ GetBusLabels()

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

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

Definition at line 241 of file connection_graph.cpp.

242 {
243  std::vector<SCH_ITEM*> labels;
244 
245  for( SCH_ITEM* item : m_drivers )
246  {
247  switch( item->Type() )
248  {
249  case SCH_LABEL_T:
250  case SCH_GLOBAL_LABEL_T:
251  {
252  SCH_CONNECTION* label_conn = item->Connection( &m_sheet );
253 
254  // Only consider bus vectors
255  if( label_conn->Type() == CONNECTION_TYPE::BUS )
256  labels.push_back( item );
257 
258  break;
259  }
260 
261  default: break;
262  }
263  }
264 
265  return labels;
266 }
SCH_SHEET_PATH m_sheet
std::vector< SCH_ITEM * > m_drivers
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
CONNECTION_TYPE Type() const
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:193
This item represents a bus vector.

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

◆ GetDriverPriority() [1/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 387 of file connection_graph.cpp.

388 {
389  if( !aDriver )
390  return PRIORITY::NONE;
391 
392  switch( aDriver->Type() )
393  {
396  case SCH_LABEL_T: return PRIORITY::LOCAL_LABEL;
398  case SCH_PIN_T:
399  {
400  auto sch_pin = static_cast<SCH_PIN*>( aDriver );
401 
402  if( sch_pin->IsPowerConnection() )
403  return PRIORITY::POWER_PIN;
404  else
405  return PRIORITY::PIN;
406  }
407 
408  default: return PRIORITY::NONE;
409  }
410 }
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References GLOBAL, HIER_LABEL, 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().

◆ GetDriverPriority() [2/2]

◆ GetNameForDriver() [1/2]

const wxString & CONNECTION_SUBGRAPH::GetNameForDriver ( SCH_ITEM aItem)

Returns the candidate net name for a driver.

Definition at line 299 of file connection_graph.cpp.

300 {
301  auto it = m_driver_name_cache.find( aItem );
302 
303  if( it != m_driver_name_cache.end() )
304  return it->second;
305 
306  m_driver_name_cache[aItem] = driverName( aItem );
307 
308  return m_driver_name_cache.at( aItem );
309 }
wxString driverName(SCH_ITEM *aItem) const
std::unordered_map< SCH_ITEM *, wxString > m_driver_name_cache
A cache of escaped netnames from schematic items.

References driverName(), and m_driver_name_cache.

Referenced by CONNECTION_GRAPH::ercCheckMultipleDrivers(), CONNECTION_GRAPH::getDefaultConnection(), inheritNetclass(), CONNECTION_GRAPH::propagateToNeighbors(), and ResolveDrivers().

◆ GetNameForDriver() [2/2]

const wxString CONNECTION_SUBGRAPH::GetNameForDriver ( SCH_ITEM aItem) const

Definition at line 312 of file connection_graph.cpp.

313 {
314  auto it = m_driver_name_cache.find( aItem );
315 
316  if( it != m_driver_name_cache.end() )
317  return it->second;
318 
319  return driverName( aItem );
320 }
wxString driverName(SCH_ITEM *aItem) const
std::unordered_map< SCH_ITEM *, wxString > m_driver_name_cache
A cache of escaped netnames from schematic items.

References driverName(), and m_driver_name_cache.

◆ GetNetName()

wxString CONNECTION_SUBGRAPH::GetNetName ( ) const

Returns the fully-qualified net name for this subgraph (if one exists)

Definition at line 223 of file connection_graph.cpp.

224 {
225  if( !m_driver || m_dirty )
226  return "";
227 
228  if( !m_driver->Connection( &m_sheet ) )
229  {
230 #ifdef CONNECTIVITY_DEBUG
231  wxASSERT_MSG( false, "Tried to get the net name of an item with no connection" );
232 #endif
233 
234  return "";
235  }
236 
237  return m_driver->Connection( &m_sheet )->Name();
238 }
SCH_SHEET_PATH m_sheet
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:131
wxString Name(bool aIgnoreSheet=false) const

References SCH_ITEM::Connection(), m_dirty, m_driver, m_sheet, and SCH_CONNECTION::Name().

Referenced by CONNECTION_GRAPH::buildConnectionGraph().

◆ 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 65 of file connection_graph.cpp.

66 {
67  PRIORITY highest_priority = PRIORITY::INVALID;
68  std::vector<SCH_ITEM*> candidates;
69  std::vector<SCH_ITEM*> strong_drivers;
70 
71  m_driver = nullptr;
72 
73  // Hierarchical labels are lower priority than local labels here,
74  // because on the first pass we want local labels to drive subgraphs
75  // so that we can identify same-sheet neighbors and link them together.
76  // Hierarchical labels will end up overriding the final net name if
77  // a higher-level sheet has a different name during the hierarchical
78  // pass.
79 
80  for( SCH_ITEM* item : m_drivers )
81  {
82  PRIORITY item_priority = GetDriverPriority( item );
83 
84  if( item_priority == PRIORITY::PIN
85  && !static_cast<SCH_PIN*>( item )->GetParentSymbol()->IsInNetlist() )
86  continue;
87 
88  if( item_priority >= PRIORITY::HIER_LABEL )
89  strong_drivers.push_back( item );
90 
91  if( item_priority > highest_priority )
92  {
93  candidates.clear();
94  candidates.push_back( item );
95  highest_priority = item_priority;
96  }
97  else if( !candidates.empty() && ( item_priority == highest_priority ) )
98  {
99  candidates.push_back( item );
100  }
101  }
102 
103  if( highest_priority >= PRIORITY::HIER_LABEL )
104  m_strong_driver = true;
105 
106  // Power pins are 5, global labels are 6
107  m_local_driver = ( highest_priority < PRIORITY::POWER_PIN );
108 
109  if( !candidates.empty() )
110  {
111  if( candidates.size() > 1 )
112  {
113  if( highest_priority == PRIORITY::SHEET_PIN )
114  {
115  // We have multiple options, and they are all hierarchical
116  // sheet pins. Let's prefer outputs over inputs.
117 
118  for( SCH_ITEM* c : candidates )
119  {
120  SCH_SHEET_PIN* p = static_cast<SCH_SHEET_PIN*>( c );
121 
123  {
124  m_driver = c;
125  break;
126  }
127  }
128  }
129  else
130  {
131  // See if a previous driver is still a candidate
132  void* previousDriver = nullptr;
133 
134  for( SCH_ITEM* member : m_items )
135  {
136  if( SCH_CONNECTION* mc = member->Connection( &m_sheet ) )
137  {
138  if( mc->GetLastDriver() )
139  {
140  previousDriver = mc->GetLastDriver();
141  break;
142  }
143  }
144  }
145 
146  // For all other driver types, sort by name
147  std::sort( candidates.begin(), candidates.end(),
148  [&]( SCH_ITEM* a, SCH_ITEM* b ) -> bool
149  {
150  // meet irreflexive requirements of std::sort
151  if( a == b )
152  return false;
153 
154  SCH_CONNECTION* ac = a->Connection( &m_sheet );
155  SCH_CONNECTION* bc = b->Connection( &m_sheet );
156 
157  // Ensure we don't pick the subset over the superset
158  if( ac->IsBus() && bc->IsBus() )
159  return bc->IsSubsetOf( ac );
160 
161  if( a == previousDriver )
162  return true;
163  else if( b == previousDriver )
164  return false;
165  else
166  return GetNameForDriver( a ) < GetNameForDriver( b );
167  } );
168  }
169  }
170 
171  if( !m_driver )
172  m_driver = candidates[0];
173  }
174 
175  if( strong_drivers.size() > 1 )
176  m_multiple_drivers = true;
177 
178  // Drop weak drivers
179  if( m_strong_driver )
180  m_drivers = strong_drivers;
181 
182  // Cache driver connection
183  if( m_driver )
184  {
189  }
190  else
191  {
192  m_driver_connection = nullptr;
193  }
194 
195  if( aCheckMultipleDrivers && m_multiple_drivers )
196  {
197  // First check if all the candidates are actually the same
198  bool same = true;
199  wxString first = GetNameForDriver( candidates[0] );
200  SCH_ITEM* second_item = nullptr;
201 
202  for( unsigned i = 1; i < candidates.size(); i++ )
203  {
204  if( GetNameForDriver( candidates[i] ) != first )
205  {
206  second_item = candidates[i];
207  same = false;
208  break;
209  }
210  }
211 
212  if( !same )
213  {
215  m_second_driver = second_item;
216  }
217  }
218 
219  return ( m_driver != nullptr );
220 }
SCH_SHEET_PATH m_sheet
SCH_CONNECTION * m_driver_connection
Cache for driver connection.
SCH_ITEM * m_second_driver
Used for multiple drivers ERC message; stores the second possible driver (or nullptr)
bool m_local_driver
True if the driver is a local (i.e. non-global) type.
void ConfigureFromLabel(const wxString &aLabel)
Configures the connection given a label.
void SetDriver(SCH_ITEM *aItem)
bool m_multiple_drivers
True if this subgraph contains more than one driver that should be shorted together in the netlist.
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:131
const wxString & GetNameForDriver(SCH_ITEM *aItem)
Returns the candidate net name for a driver.
std::vector< SCH_ITEM * > m_items
bool m_strong_driver
True if the driver is "strong": a label or power object.
std::vector< SCH_ITEM * > m_drivers
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:65
SCH_ITEM * m_first_driver
Stores the primary driver for the multiple drivers ERC check.
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
bool IsBus() const
bool IsSubsetOf(SCH_CONNECTION *aOther) const
Returns true if this connection is contained within aOther (but not the same as aOther)
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:193
PRIORITY GetDriverPriority()
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:161

References SCH_CONNECTION::ClearDirty(), SCH_CONNECTION::ConfigureFromLabel(), SCH_ITEM::Connection(), GetDriverPriority(), GetNameForDriver(), SCH_TEXT::GetShape(), HIER_LABEL, INVALID, SCH_CONNECTION::IsBus(), SCH_CONNECTION::IsSubsetOf(), m_driver, m_driver_connection, m_drivers, m_first_driver, m_items, m_local_driver, m_multiple_drivers, m_second_driver, m_sheet, m_strong_driver, PIN, POWER_PIN, PS_OUTPUT, SCH_CONNECTION::SetDriver(), and SHEET_PIN.

Referenced by CONNECTION_GRAPH::buildConnectionGraph().

◆ UpdateItemConnections()

void CONNECTION_SUBGRAPH::UpdateItemConnections ( )

Updates all items to match the driver connection.

Definition at line 360 of file connection_graph.cpp.

361 {
362  if( !m_driver_connection )
363  return;
364 
365  for( SCH_ITEM* item : m_items )
366  {
367  SCH_CONNECTION* item_conn = item->Connection( &m_sheet );
368 
369  if( !item_conn )
370  item_conn = item->InitializeConnection( m_sheet, m_graph );
371 
372  if( ( m_driver_connection->IsBus() && item_conn->IsNet() ) ||
373  ( m_driver_connection->IsNet() && item_conn->IsBus() ) )
374  {
375  continue;
376  }
377 
378  if( item != m_driver )
379  {
380  item_conn->Clone( *m_driver_connection );
381  item_conn->ClearDirty();
382  }
383  }
384 }
SCH_SHEET_PATH m_sheet
SCH_CONNECTION * m_driver_connection
Cache for driver connection.
void Clone(const SCH_CONNECTION &aOther)
Copies connectivity information (but not parent) from another connection.
CONNECTION_GRAPH * m_graph
std::vector< SCH_ITEM * > m_items
bool IsNet() const
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
bool IsBus() const
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:193

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.

Referenced by CONNECTION_GRAPH::buildConnectionGraph().

Member Data Documentation

◆ m_absorbed

bool CONNECTION_SUBGRAPH::m_absorbed

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

Definition at line 161 of file connection_graph.h.

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

◆ m_absorbed_by

CONNECTION_SUBGRAPH* CONNECTION_SUBGRAPH::m_absorbed_by

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

Definition at line 164 of file connection_graph.h.

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

◆ m_bus_entry

SCH_ITEM* CONNECTION_SUBGRAPH::m_bus_entry

Bus entry in graph, if any.

Definition at line 185 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

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 vector will contain a pointer to the D7 net subgraph.

Definition at line 207 of file connection_graph.h.

Referenced by Absorb().

◆ m_bus_parents

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

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 215 of file connection_graph.h.

Referenced by Absorb().

◆ m_code

long CONNECTION_SUBGRAPH::m_code

◆ m_dirty

bool CONNECTION_SUBGRAPH::m_dirty

◆ m_driver

◆ m_driver_connection

◆ m_driver_name_cache

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

A cache of escaped netnames from schematic items.

Definition at line 227 of file connection_graph.h.

Referenced by GetNameForDriver().

◆ m_drivers

◆ m_first_driver

SCH_ITEM* CONNECTION_SUBGRAPH::m_first_driver

Stores the primary driver for the multiple drivers ERC check.

This is the chosen driver before subgraphs are absorbed (so m_driver may be different)

Definition at line 233 of file connection_graph.h.

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

◆ m_graph

CONNECTION_GRAPH* CONNECTION_SUBGRAPH::m_graph

Definition at line 156 of file connection_graph.h.

Referenced by UpdateItemConnections().

◆ m_hier_parent

CONNECTION_SUBGRAPH* CONNECTION_SUBGRAPH::m_hier_parent

◆ m_hier_pins

std::vector<SCH_SHEET_PIN*> CONNECTION_SUBGRAPH::m_hier_pins

Definition at line 218 of file connection_graph.h.

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

◆ m_hier_ports

std::vector<SCH_HIERLABEL*> CONNECTION_SUBGRAPH::m_hier_ports

Definition at line 221 of file connection_graph.h.

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

◆ m_items

◆ m_local_driver

bool CONNECTION_SUBGRAPH::m_local_driver

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

Definition at line 179 of file connection_graph.h.

Referenced by ResolveDrivers().

◆ m_multiple_drivers

bool CONNECTION_SUBGRAPH::m_multiple_drivers

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 173 of file connection_graph.h.

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

◆ m_no_connect

◆ m_second_driver

SCH_ITEM* CONNECTION_SUBGRAPH::m_second_driver

Used for multiple drivers ERC message; stores the second possible driver (or nullptr)

Definition at line 236 of file connection_graph.h.

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

◆ m_sheet

◆ m_strong_driver

bool CONNECTION_SUBGRAPH::m_strong_driver

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

Definition at line 176 of file connection_graph.h.

Referenced by CONNECTION_GRAPH::buildConnectionGraph(), CONNECTION_GRAPH::ercCheckLabels(), CONNECTION_GRAPH::propagateToNeighbors(), and ResolveDrivers().


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