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 aCreateMarkers=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...
 
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...
 

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  {}
SCH_CONNECTION * m_driver_connection
Cache for driver connection.
SCH_ITEM * m_bus_entry
Bus entry in graph, if any.
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.
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 310 of file connection_graph.cpp.

311 {
312  wxASSERT( m_sheet == aOther->m_sheet );
313 
314  for( SCH_ITEM* item : aOther->m_items )
315  {
317  AddItem( item );
318  }
319 
320  m_bus_neighbors.insert( aOther->m_bus_neighbors.begin(), aOther->m_bus_neighbors.end() );
321  m_bus_parents.insert( aOther->m_bus_parents.begin(), aOther->m_bus_parents.end() );
322 
324 
325  aOther->m_absorbed = true;
326  aOther->m_dirty = false;
327  aOther->m_driver = nullptr;
328  aOther->m_driver_connection = nullptr;
329  aOther->m_absorbed_by = this;
330 }
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:194

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

334 {
335  m_items.push_back( aItem );
336 
337  if( aItem->Connection( &m_sheet )->IsDriver() )
338  m_drivers.push_back( aItem );
339 
340  if( aItem->Type() == SCH_SHEET_PIN_T )
341  m_hier_pins.push_back( static_cast<SCH_SHEET_PIN*>( aItem ) );
342  else if( aItem->Type() == SCH_HIER_LABEL_T )
343  m_hier_ports.push_back( static_cast<SCH_HIERLABEL*>( aItem ) );
344 }
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
Function Type()
Definition: eda_item.h:181

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().

◆ GetBusLabels()

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

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

Definition at line 247 of file connection_graph.cpp.

248 {
249  std::vector<SCH_ITEM*> labels;
250 
251  for( SCH_ITEM* item : m_drivers )
252  {
253  switch( item->Type() )
254  {
255  case SCH_LABEL_T:
256  case SCH_GLOBAL_LABEL_T:
257  {
258  SCH_CONNECTION* label_conn = item->Connection( &m_sheet );
259 
260  // Only consider bus vectors
261  if( label_conn->Type() == CONNECTION_TYPE::BUS )
262  labels.push_back( item );
263 
264  break;
265  }
266 
267  default: break;
268  }
269  }
270 
271  return labels;
272 }
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:194
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 374 of file connection_graph.cpp.

375 {
376  if( !aDriver )
377  return PRIORITY::NONE;
378 
379  switch( aDriver->Type() )
380  {
383  case SCH_LABEL_T: return PRIORITY::LOCAL_LABEL;
385  case SCH_PIN_T:
386  {
387  auto sch_pin = static_cast<SCH_PIN*>( aDriver );
388 
389  if( sch_pin->IsPowerConnection() )
390  return PRIORITY::POWER_PIN;
391  else
392  return PRIORITY::PIN;
393  }
394 
395  default: return PRIORITY::NONE;
396  }
397 }
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

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()

const wxString & CONNECTION_SUBGRAPH::GetNameForDriver ( SCH_ITEM aItem)

Returns the candidate net name for a driver.

Definition at line 275 of file connection_graph.cpp.

276 {
277  auto it = m_driver_name_cache.find( aItem );
278 
279  if( it != m_driver_name_cache.end() )
280  return it->second;
281 
282  switch( aItem->Type() )
283  {
284  case SCH_PIN_T:
285  {
286  SCH_PIN* pin = static_cast<SCH_PIN*>( aItem );
288  break;
289  }
290 
291  case SCH_LABEL_T:
292  case SCH_GLOBAL_LABEL_T:
293  case SCH_HIER_LABEL_T:
294  case SCH_SHEET_PIN_T:
295  {
296  m_driver_name_cache[aItem] = EscapeString( static_cast<SCH_TEXT*>( aItem )->GetShownText(),
297  CTX_NETNAME );
298  break;
299  }
300 
301  default:
302  wxFAIL_MSG( "Unhandled item type in GetNameForDriver" );
303  break;
304  }
305 
306  return m_driver_name_cache.at( aItem );
307 }
SCH_SHEET_PATH m_sheet
wxString GetDefaultNetName(const SCH_SHEET_PATH &aPath)
Definition: sch_pin.cpp:234
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
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181
std::unordered_map< SCH_ITEM *, wxString > m_driver_name_cache
A cache of escaped netnames from schematic items.

References CTX_NETNAME, EscapeString(), SCH_PIN::GetDefaultNetName(), m_driver_name_cache, 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 CONNECTION_GRAPH::getDefaultConnection(), inheritNetclass(), CONNECTION_GRAPH::propagateToNeighbors(), and ResolveDrivers().

◆ GetNetName()

wxString CONNECTION_SUBGRAPH::GetNetName ( ) const

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

Definition at line 229 of file connection_graph.cpp.

230 {
231  if( !m_driver || m_dirty )
232  return "";
233 
234  if( !m_driver->Connection( &m_sheet ) )
235  {
236 #ifdef CONNECTIVITY_DEBUG
237  wxASSERT_MSG( false, "Tried to get the net name of an item with no connection" );
238 #endif
239 
240  return "";
241  }
242 
243  return m_driver->Connection( &m_sheet )->Name();
244 }
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  aCreateMarkers = 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
aCreateMarkerscontrols whether ERC markers should be added for conflicts
Returns
true if m_driver was set, or false if a conflict occurred

Definition at line 60 of file connection_graph.cpp.

61 {
62  PRIORITY highest_priority = PRIORITY::INVALID;
63  std::vector<SCH_ITEM*> candidates;
64  std::vector<SCH_ITEM*> strong_drivers;
65 
66  m_driver = nullptr;
67 
68  // Hierarchical labels are lower priority than local labels here,
69  // because on the first pass we want local labels to drive subgraphs
70  // so that we can identify same-sheet neighbors and link them together.
71  // Hierarchical labels will end up overriding the final net name if
72  // a higher-level sheet has a different name during the hierarchical
73  // pass.
74 
75  for( SCH_ITEM* item : m_drivers )
76  {
77  PRIORITY item_priority = GetDriverPriority( item );
78 
79  if( item_priority == PRIORITY::PIN
80  && !static_cast<SCH_PIN*>( item )->GetParentSymbol()->IsInNetlist() )
81  continue;
82 
83  if( item_priority >= PRIORITY::HIER_LABEL )
84  strong_drivers.push_back( item );
85 
86  if( item_priority > highest_priority )
87  {
88  candidates.clear();
89  candidates.push_back( item );
90  highest_priority = item_priority;
91  }
92  else if( !candidates.empty() && ( item_priority == highest_priority ) )
93  {
94  candidates.push_back( item );
95  }
96  }
97 
98  if( highest_priority >= PRIORITY::HIER_LABEL )
99  m_strong_driver = true;
100 
101  // Power pins are 5, global labels are 6
102  m_local_driver = ( highest_priority < PRIORITY::POWER_PIN );
103 
104  if( !candidates.empty() )
105  {
106  if( candidates.size() > 1 )
107  {
108  if( highest_priority == PRIORITY::SHEET_PIN )
109  {
110  // We have multiple options, and they are all hierarchical
111  // sheet pins. Let's prefer outputs over inputs.
112 
113  for( SCH_ITEM* c : candidates )
114  {
115  SCH_SHEET_PIN* p = static_cast<SCH_SHEET_PIN*>( c );
116 
118  {
119  m_driver = c;
120  break;
121  }
122  }
123  }
124  else
125  {
126  // See if a previous driver is still a candidate
127  void* previousDriver = nullptr;
128 
129  for( SCH_ITEM* member : m_items )
130  {
131  if( SCH_CONNECTION* mc = member->Connection( &m_sheet ) )
132  {
133  if( mc->GetLastDriver() )
134  {
135  previousDriver = mc->GetLastDriver();
136  break;
137  }
138  }
139  }
140 
141  // For all other driver types, sort by name
142  std::sort( candidates.begin(), candidates.end(),
143  [&]( SCH_ITEM* a, SCH_ITEM* b ) -> bool
144  {
145  // meet irreflexive requirements of std::sort
146  if( a == b )
147  return false;
148 
149  SCH_CONNECTION* ac = a->Connection( &m_sheet );
150  SCH_CONNECTION* bc = b->Connection( &m_sheet );
151 
152  // Ensure we don't pick the subset over the superset
153  if( ac->IsBus() && bc->IsBus() )
154  return bc->IsSubsetOf( ac );
155 
156  if( a == previousDriver )
157  return true;
158  else if( b == previousDriver )
159  return false;
160  else
161  return GetNameForDriver( a ) < GetNameForDriver( b );
162  } );
163  }
164  }
165 
166  if( !m_driver )
167  m_driver = candidates[0];
168  }
169 
170  if( strong_drivers.size() > 1 )
171  m_multiple_drivers = true;
172 
173  // Drop weak drivers
174  if( m_strong_driver )
175  m_drivers = strong_drivers;
176 
177  // Cache driver connection
178  if( m_driver )
180  else
181  m_driver_connection = nullptr;
182 
183  if( aCreateMarkers && m_multiple_drivers )
184  {
185  // First check if all the candidates are actually the same
186  bool same = true;
187  wxString first = GetNameForDriver( candidates[0] );
188  SCH_ITEM* second_item = nullptr;
189 
190  for( unsigned i = 1; i < candidates.size(); i++ )
191  {
192  if( GetNameForDriver( candidates[i] ) != first )
193  {
194  second_item = candidates[i];
195  same = false;
196  break;
197  }
198  }
199 
200  if( !same )
201  {
202  wxPoint pos = candidates[0]->Type() == SCH_PIN_T ?
203  static_cast<SCH_PIN*>( candidates[0] )->GetTransformedPosition() :
204  candidates[0]->GetPosition();
205 
206  wxString msg = wxString::Format( _( "Both %s and %s are attached to the same "
207  "items; %s will be used in the netlist" ),
208  first,
209  GetNameForDriver( second_item ),
210  first );
211 
212  std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_DRIVER_CONFLICT );
213  ercItem->SetItems( candidates[0], second_item );
214  ercItem->SetErrorMessage( msg );
215 
216  SCH_MARKER* marker = new SCH_MARKER( ercItem, pos );
217  m_sheet.LastScreen()->Append( marker );
218 
219  // If aCreateMarkers is true, then this is part of ERC check, so we
220  // should return false even if the driver was assigned
221  return false;
222  }
223  }
224 
225  return aCreateMarkers || ( m_driver != nullptr );
226 }
SCH_SHEET_PATH m_sheet
SCH_CONNECTION * m_driver_connection
Cache for driver connection.
static std::shared_ptr< ERC_ITEM > Create(int aErrorCode)
Constructs an ERC_ITEM for the given error code.
Definition: erc_item.cpp:160
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.
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
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
SCH_SCREEN * LastScreen()
void Append(SCH_ITEM *aItem)
Definition: sch_screen.cpp:129
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
#define _(s)
Definition: 3d_actions.cpp:33
bool IsBus() const
bool IsSubsetOf(SCH_CONNECTION *aOther) const
Returns true if this connection is contained within aOther (but not the same as aOther)
Conflicting drivers (labels, etc) on a subgraph.
Definition: erc_settings.h:55
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:194
PRIORITY GetDriverPriority()
PINSHEETLABEL_SHAPE GetShape() const
Definition: sch_text.h:235
KICAD_T Type() const
Function Type()
Definition: eda_item.h:181

References _, SCH_SCREEN::Append(), SCH_ITEM::Connection(), ERC_ITEM::Create(), ERCE_DRIVER_CONFLICT, Format(), GetDriverPriority(), GetNameForDriver(), SCH_TEXT::GetShape(), HIER_LABEL, INVALID, SCH_CONNECTION::IsBus(), SCH_CONNECTION::IsSubsetOf(), SCH_SHEET_PATH::LastScreen(), m_driver, m_driver_connection, m_drivers, m_items, m_local_driver, m_multiple_drivers, m_sheet, m_strong_driver, PIN, POWER_PIN, PS_OUTPUT, SCH_PIN_T, SHEET_PIN, and EDA_ITEM::Type().

Referenced by CONNECTION_GRAPH::buildConnectionGraph().

◆ UpdateItemConnections()

void CONNECTION_SUBGRAPH::UpdateItemConnections ( )

Updates all items to match the driver connection.

Definition at line 347 of file connection_graph.cpp.

348 {
349  if( !m_driver_connection )
350  return;
351 
352  for( SCH_ITEM* item : m_items )
353  {
354  SCH_CONNECTION* item_conn = item->Connection( &m_sheet );
355 
356  if( !item_conn )
357  item_conn = item->InitializeConnection( m_sheet, m_graph );
358 
359  if( ( m_driver_connection->IsBus() && item_conn->IsNet() ) ||
360  ( m_driver_connection->IsNet() && item_conn->IsBus() ) )
361  {
362  continue;
363  }
364 
365  if( item != m_driver )
366  {
367  item_conn->Clone( *m_driver_connection );
368  item_conn->ClearDirty();
369  }
370  }
371 }
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:194

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(), and CONNECTION_GRAPH::propagateToNeighbors().

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 152 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 155 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 176 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 198 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 206 of file connection_graph.h.

Referenced by Absorb().

◆ m_code

long CONNECTION_SUBGRAPH::m_code

◆ m_dirty

bool CONNECTION_SUBGRAPH::m_dirty

Definition at line 149 of file connection_graph.h.

Referenced by Absorb(), GetNetName(), and CONNECTION_GRAPH::propagateToNeighbors().

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

Referenced by GetNameForDriver().

◆ m_drivers

std::vector<SCH_ITEM*> CONNECTION_SUBGRAPH::m_drivers

◆ m_graph

CONNECTION_GRAPH* CONNECTION_SUBGRAPH::m_graph

Definition at line 147 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 209 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 212 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 170 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 164 of file connection_graph.h.

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

◆ m_no_connect

SCH_ITEM* CONNECTION_SUBGRAPH::m_no_connect

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

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


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