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)
 Returns 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 59 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 62 of file connection_graph.h.

63  {
64  INVALID = -1,
65  NONE = 0,
66  PIN,
67  SHEET_PIN,
68  HIER_LABEL,
69  LOCAL_LABEL,
70  POWER_PIN,
71  GLOBAL
72  };

Constructor & Destructor Documentation

◆ CONNECTION_SUBGRAPH()

CONNECTION_SUBGRAPH::CONNECTION_SUBGRAPH ( CONNECTION_GRAPH aGraph)
inlineexplicit

Definition at line 74 of file connection_graph.h.

74  :
75  m_graph( aGraph ),
76  m_dirty( false ),
77  m_absorbed( false ),
78  m_absorbed_by( nullptr ),
79  m_code( -1 ),
80  m_multiple_drivers( false ),
81  m_strong_driver( false ),
82  m_local_driver( false ),
83  m_no_connect( nullptr ),
84  m_bus_entry( nullptr ),
85  m_driver( nullptr ),
86  m_driver_connection( nullptr ),
87  m_hier_parent( nullptr ),
88  m_first_driver( nullptr ),
89  m_second_driver( nullptr )
90  {}
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 321 of file connection_graph.cpp.

322 {
323  wxASSERT( m_sheet == aOther->m_sheet );
324 
325  for( SCH_ITEM* item : aOther->m_items )
326  {
328  AddItem( item );
329  }
330 
331  m_bus_neighbors.insert( aOther->m_bus_neighbors.begin(), aOther->m_bus_neighbors.end() );
332  m_bus_parents.insert( aOther->m_bus_parents.begin(), aOther->m_bus_parents.end() );
333 
335 
336  aOther->m_absorbed = true;
337  aOther->m_dirty = false;
338  aOther->m_driver = nullptr;
339  aOther->m_driver_connection = nullptr;
340  aOther->m_absorbed_by = this;
341 }
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:196

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

345 {
346  m_items.push_back( aItem );
347 
348  if( aItem->Connection( &m_sheet )->IsDriver() )
349  m_drivers.push_back( aItem );
350 
351  if( aItem->Type() == SCH_SHEET_PIN_T )
352  m_hier_pins.push_back( static_cast<SCH_SHEET_PIN*>( aItem ) );
353  else if( aItem->Type() == SCH_HIER_LABEL_T )
354  m_hier_ports.push_back( static_cast<SCH_HIERLABEL*>( aItem ) );
355 }
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:162

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

268 {
269  switch( aItem->Type() )
270  {
271  case SCH_PIN_T:
272  {
273  bool forceNoConnect = m_no_connect != nullptr;
274  SCH_PIN* pin = static_cast<SCH_PIN*>( aItem );
275  return pin->GetDefaultNetName( m_sheet, forceNoConnect );
276  break;
277  }
278 
279  case SCH_LABEL_T:
280  case SCH_GLOBAL_LABEL_T:
281  case SCH_HIER_LABEL_T:
282  case SCH_SHEET_PIN_T:
283  {
284  return EscapeString( static_cast<SCH_TEXT*>( aItem )->GetShownText(), CTX_NETNAME );
285  break;
286  }
287 
288  default:
289  wxFAIL_MSG( "Unhandled item type in GetNameForDriver" );
290  break;
291  }
292 
293  return wxEmptyString;
294 }
SCH_SHEET_PATH m_sheet
wxString GetDefaultNetName(const SCH_SHEET_PATH &aPath, bool aForceNoConnect=false)
Definition: sch_pin.cpp:235
wxString EscapeString(const wxString &aSource, ESCAPE_CONTEXT aContext)
These Escape/Unescape routines use HTML-entity-reference-style encoding to handle characters which ar...
Definition: string.cpp:77
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:162

References CTX_NETNAME, EscapeString(), SCH_PIN::GetDefaultNetName(), m_no_connect, m_sheet, 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 239 of file connection_graph.cpp.

240 {
241  std::vector<SCH_ITEM*> labels;
242 
243  for( SCH_ITEM* item : m_drivers )
244  {
245  switch( item->Type() )
246  {
247  case SCH_LABEL_T:
248  case SCH_GLOBAL_LABEL_T:
249  {
250  SCH_CONNECTION* label_conn = item->Connection( &m_sheet );
251 
252  // Only consider bus vectors
253  if( label_conn->Type() == CONNECTION_TYPE::BUS )
254  labels.push_back( item );
255 
256  break;
257  }
258 
259  default: break;
260  }
261  }
262 
263  return labels;
264 }
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:196
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

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

0: Invalid driver 1: Component 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 385 of file connection_graph.cpp.

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

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

298 {
299  auto it = m_driver_name_cache.find( aItem );
300 
301  if( it != m_driver_name_cache.end() )
302  return it->second;
303 
304  m_driver_name_cache[aItem] = driverName( aItem );
305 
306  return m_driver_name_cache.at( aItem );
307 }
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 310 of file connection_graph.cpp.

311 {
312  auto it = m_driver_name_cache.find( aItem );
313 
314  if( it != m_driver_name_cache.end() )
315  return it->second;
316 
317  return driverName( aItem );
318 }
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 221 of file connection_graph.cpp.

222 {
223  if( !m_driver || m_dirty )
224  return "";
225 
226  if( !m_driver->Connection( &m_sheet ) )
227  {
228 #ifdef CONNECTIVITY_DEBUG
229  wxASSERT_MSG( false, "Tried to get the net name of an item with no connection" );
230 #endif
231 
232  return "";
233  }
234 
235  return m_driver->Connection( &m_sheet )->Name();
236 }
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 63 of file connection_graph.cpp.

64 {
65  PRIORITY highest_priority = PRIORITY::INVALID;
66  std::vector<SCH_ITEM*> candidates;
67  std::vector<SCH_ITEM*> strong_drivers;
68 
69  m_driver = nullptr;
70 
71  // Hierarchical labels are lower priority than local labels here,
72  // because on the first pass we want local labels to drive subgraphs
73  // so that we can identify same-sheet neighbors and link them together.
74  // Hierarchical labels will end up overriding the final net name if
75  // a higher-level sheet has a different name during the hierarchical
76  // pass.
77 
78  for( SCH_ITEM* item : m_drivers )
79  {
80  PRIORITY item_priority = GetDriverPriority( item );
81 
82  if( item_priority == PRIORITY::PIN
83  && !static_cast<SCH_PIN*>( item )->GetParentSymbol()->IsInNetlist() )
84  continue;
85 
86  if( item_priority >= PRIORITY::HIER_LABEL )
87  strong_drivers.push_back( item );
88 
89  if( item_priority > highest_priority )
90  {
91  candidates.clear();
92  candidates.push_back( item );
93  highest_priority = item_priority;
94  }
95  else if( !candidates.empty() && ( item_priority == highest_priority ) )
96  {
97  candidates.push_back( item );
98  }
99  }
100 
101  if( highest_priority >= PRIORITY::HIER_LABEL )
102  m_strong_driver = true;
103 
104  // Power pins are 5, global labels are 6
105  m_local_driver = ( highest_priority < PRIORITY::POWER_PIN );
106 
107  if( !candidates.empty() )
108  {
109  if( candidates.size() > 1 )
110  {
111  if( highest_priority == PRIORITY::SHEET_PIN )
112  {
113  // We have multiple options, and they are all hierarchical
114  // sheet pins. Let's prefer outputs over inputs.
115 
116  for( SCH_ITEM* c : candidates )
117  {
118  SCH_SHEET_PIN* p = static_cast<SCH_SHEET_PIN*>( c );
119 
121  {
122  m_driver = c;
123  break;
124  }
125  }
126  }
127  else
128  {
129  // See if a previous driver is still a candidate
130  void* previousDriver = nullptr;
131 
132  for( SCH_ITEM* member : m_items )
133  {
134  if( SCH_CONNECTION* mc = member->Connection( &m_sheet ) )
135  {
136  if( mc->GetLastDriver() )
137  {
138  previousDriver = mc->GetLastDriver();
139  break;
140  }
141  }
142  }
143 
144  // For all other driver types, sort by name
145  std::sort( candidates.begin(), candidates.end(),
146  [&]( SCH_ITEM* a, SCH_ITEM* b ) -> bool
147  {
148  // meet irreflexive requirements of std::sort
149  if( a == b )
150  return false;
151 
152  SCH_CONNECTION* ac = a->Connection( &m_sheet );
153  SCH_CONNECTION* bc = b->Connection( &m_sheet );
154 
155  // Ensure we don't pick the subset over the superset
156  if( ac->IsBus() && bc->IsBus() )
157  return bc->IsSubsetOf( ac );
158 
159  if( a == previousDriver )
160  return true;
161  else if( b == previousDriver )
162  return false;
163  else
164  return GetNameForDriver( a ) < GetNameForDriver( b );
165  } );
166  }
167  }
168 
169  if( !m_driver )
170  m_driver = candidates[0];
171  }
172 
173  if( strong_drivers.size() > 1 )
174  m_multiple_drivers = true;
175 
176  // Drop weak drivers
177  if( m_strong_driver )
178  m_drivers = strong_drivers;
179 
180  // Cache driver connection
181  if( m_driver )
182  {
187  }
188  else
189  {
190  m_driver_connection = nullptr;
191  }
192 
193  if( aCheckMultipleDrivers && m_multiple_drivers )
194  {
195  // First check if all the candidates are actually the same
196  bool same = true;
197  wxString first = GetNameForDriver( candidates[0] );
198  SCH_ITEM* second_item = nullptr;
199 
200  for( unsigned i = 1; i < candidates.size(); i++ )
201  {
202  if( GetNameForDriver( candidates[i] ) != first )
203  {
204  second_item = candidates[i];
205  same = false;
206  break;
207  }
208  }
209 
210  if( !same )
211  {
213  m_second_driver = second_item;
214  }
215  }
216 
217  return ( m_driver != nullptr );
218 }
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.h:85
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:196
PRIORITY GetDriverPriority()
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:235

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

359 {
360  if( !m_driver_connection )
361  return;
362 
363  for( SCH_ITEM* item : m_items )
364  {
365  SCH_CONNECTION* item_conn = item->Connection( &m_sheet );
366 
367  if( !item_conn )
368  item_conn = item->InitializeConnection( m_sheet, m_graph );
369 
370  if( ( m_driver_connection->IsBus() && item_conn->IsNet() ) ||
371  ( m_driver_connection->IsNet() && item_conn->IsBus() ) )
372  {
373  continue;
374  }
375 
376  if( item != m_driver )
377  {
378  item_conn->Clone( *m_driver_connection );
379  item_conn->ClearDirty();
380  }
381  }
382 }
SCH_SHEET_PATH m_sheet
SCH_CONNECTION * m_driver_connection
Cache for driver connection.
CONNECTION_GRAPH * m_graph
std::vector< SCH_ITEM * > m_items
void Clone(SCH_CONNECTION &aOther)
Copies connectivity information (but not parent) from another connection.
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:196

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 156 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 159 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 180 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 202 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 210 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 222 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 228 of file connection_graph.h.

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

◆ m_graph

CONNECTION_GRAPH* CONNECTION_SUBGRAPH::m_graph

Definition at line 151 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 213 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 216 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 174 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 168 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 231 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 171 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: