KiCad PCB EDA Suite
SCH_CONNECTION Class Reference

Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net). More...

#include <sch_connection.h>

Public Member Functions

 SCH_CONNECTION (SCH_ITEM *aParent=nullptr, SCH_SHEET_PATH aPath=SCH_SHEET_PATH())
 Buses can be defined in multiple ways. More...
 
 SCH_CONNECTION (CONNECTION_GRAPH *aGraph)
 
 ~SCH_CONNECTION ()
 
bool operator== (const SCH_CONNECTION &aOther) const
 Note: the equality operator for SCH_CONNECTION only tests the net properties, not the ownership / sheet location! More...
 
bool operator!= (const SCH_CONNECTION &aOther) const
 
void SetGraph (CONNECTION_GRAPH *aGraph)
 
void ConfigureFromLabel (const wxString &aLabel)
 Configures the connection given a label. More...
 
void Reset ()
 Clears connectivity information. More...
 
void Clone (const SCH_CONNECTION &aOther)
 Copies connectivity information (but not parent) from another connection. More...
 
SCH_ITEMParent () const
 
SCH_ITEMDriver () const
 
void SetDriver (SCH_ITEM *aItem)
 
SCH_SHEET_PATH Sheet () const
 
void SetSheet (SCH_SHEET_PATH aSheet)
 
SCH_SHEET_PATH LocalSheet () const
 
bool IsDriver () const
 Checks if the SCH_ITEM this connection is attached to can drive connections Drivers can be labels, sheet pins, or symbol pins. More...
 
bool IsBus () const
 
bool IsNet () const
 
bool IsUnconnected () const
 
bool IsDirty () const
 
void SetDirty ()
 
void ClearDirty ()
 
bool HasDriverChanged () const
 
void ClearDriverChanged ()
 
void * GetLastDriver () const
 
wxString Name (bool aIgnoreSheet=false) const
 
wxString LocalName () const
 
wxString FullLocalName () const
 
void SetName (const wxString &aName)
 
wxString Prefix () const
 
void SetPrefix (const wxString &aPrefix)
 
wxString BusPrefix () const
 
wxString Suffix () const
 
void SetSuffix (const wxString &aSuffix)
 
CONNECTION_TYPE Type () const
 
void SetType (CONNECTION_TYPE aType)
 
int NetCode () const
 
void SetNetCode (int aCode)
 
int BusCode () const
 
void SetBusCode (int aCode)
 
int SubgraphCode () const
 
void SetSubgraphCode (int aCode)
 
long VectorStart () const
 
long VectorEnd () const
 
long VectorIndex () const
 
wxString VectorPrefix () const
 
std::vector< std::shared_ptr< SCH_CONNECTION > > & Members ()
 
const std::vector< std::shared_ptr< SCH_CONNECTION > > & Members () const
 
const std::vector< std::shared_ptr< SCH_CONNECTION > > AllMembers () const
 
bool IsSubsetOf (SCH_CONNECTION *aOther) const
 Returns true if this connection is contained within aOther (but not the same as aOther) More...
 
bool IsMemberOfBus (SCH_CONNECTION *aOther) const
 Returns true if this connection is a member of bus connection aOther. More...
 
void AppendInfoToMsgPanel (std::vector< MSG_PANEL_ITEM > &aList) const
 Adds information about the connection object to aList. More...
 

Static Public Member Functions

static wxString PrintBusForUI (const wxString &aString)
 
static bool IsBusLabel (const wxString &aLabel)
 Test if aLabel has a bus notation. More...
 
static bool MightBeBusLabel (const wxString &aLabel)
 Test if aLabel looks like a bus notation. More...
 

Private Member Functions

void recacheName ()
 

Private Attributes

bool m_dirty
 
SCH_SHEET_PATH m_sheet
 The hierarchical sheet this connection is on. More...
 
SCH_SHEET_PATH m_local_sheet
 When a connection is overridden by one on a different hierarchical sheet, it will be cloned and m_sheet will point to the parent sheet. More...
 
SCH_ITEMm_parent
 The SCH_ITEM this connection is owned by. More...
 
void * m_lastDriver
 WEAK POINTER (there is no guarantee it is still allocated) Equality comparisons are OK, but that's pretty much it. More...
 
SCH_ITEMm_driver
 The SCH_ITEM that drives this connection's net. More...
 
CONNECTION_TYPE m_type
 
wxString m_name
 Name of the connection. More...
 
wxString m_cached_name
 Full name, including prefix and suffix. More...
 
wxString m_cached_name_with_path
 Full name including sheet path (if not global) More...
 
wxString m_local_name
 For bus members, we want to keep track of the "local" name of a member, that is, the name it takes on from its parent bus name. More...
 
wxString m_prefix
 Prefix if connection is member of a labeled bus group (or "" if not) More...
 
wxString m_local_prefix
 Local prefix for group bus members (used with m_local_name) More...
 
wxString m_bus_prefix
 Optional prefix of a bux group (always empty for nets and vector buses) More...
 
wxString m_suffix
 Name suffix (used only for disambiguation) More...
 
int m_net_code
 
int m_bus_code
 
int m_subgraph_code
 Groups directly-connected items. More...
 
long m_vector_index
 Index of bus vector member nets. More...
 
long m_vector_start
 Highest member of a vector bus. More...
 
long m_vector_end
 Lowest member of a vector bus. More...
 
wxString m_vector_prefix
 
std::vector< std::shared_ptr< SCH_CONNECTION > > m_members
 For bus connections, store a list of member connections. More...
 
CONNECTION_GRAPHm_graph
 Pointer to the connection graph for the schematic this connection exists on. More...
 

Detailed Description

Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).

These are generated when netlisting, or when editing operations that can change the netlist are performed.

In hierarchical schematics, a single SCH_ITEM object can refer to multiple distinct parts of a design (in the case of a sub-sheet that is instanced more than once in a higher level sheet). Because of this, a single item may contain more than one SCH_CONNECTION – each is specific to a sheet.

Symbols contain connections for each of their pins (and for each sheet they exist on) but don't use their own connection object.

Definition at line 60 of file sch_connection.h.

Constructor & Destructor Documentation

◆ SCH_CONNECTION() [1/2]

SCH_CONNECTION::SCH_CONNECTION ( SCH_ITEM aParent = nullptr,
SCH_SHEET_PATH  aPath = SCH_SHEET_PATH() 
)

Buses can be defined in multiple ways.

A bus vector consists of a prefix and a numeric range of suffixes:

BUS_NAME[M..N]

For example, the bus A[3..0] will contain nets A3, A2, A1, and A0. The BUS_NAME is required. M and N must be integers but do not need to be in any particular order – A[0..3] produces the same result.

Like net names, bus names cannot contain whitespace.

A bus group is just a grouping of signals, separated by spaces, some of which may be bus vectors. Bus groups can have names, but do not need to.

MEMORY{A[15..0] D[7..0] RW CE OE}

In named bus groups, the net names are expanded as <BUS_NAME>.<NET_NAME> In the above example, the nets would be named like MEMORY.A15, MEMORY.D0, etc.

{USB_DP USB_DN}

In the above example, the bus is unnamed and so the underlying net names are just USB_DP and USB_DN.

Definition at line 65 of file sch_connection.cpp.

65 :
66 m_sheet( aPath ),
67 m_local_sheet( aPath ),
68 m_parent( aParent ),
69 m_driver( nullptr ),
70 m_graph( nullptr )
71{
72 Reset();
73}
SCH_ITEM * m_parent
The SCH_ITEM this connection is owned by.
SCH_SHEET_PATH m_sheet
The hierarchical sheet this connection is on.
void Reset()
Clears connectivity information.
SCH_ITEM * m_driver
The SCH_ITEM that drives this connection's net.
SCH_SHEET_PATH m_local_sheet
When a connection is overridden by one on a different hierarchical sheet, it will be cloned and m_she...
CONNECTION_GRAPH * m_graph
Pointer to the connection graph for the schematic this connection exists on.

References Reset().

◆ SCH_CONNECTION() [2/2]

SCH_CONNECTION::SCH_CONNECTION ( CONNECTION_GRAPH aGraph)

Definition at line 76 of file sch_connection.cpp.

76 :
79 m_parent( nullptr ),
80 m_driver( nullptr ),
81 m_graph( aGraph )
82{
83 Reset();
84}
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...

References Reset().

◆ ~SCH_CONNECTION()

SCH_CONNECTION::~SCH_CONNECTION ( )
inline

Definition at line 67 of file sch_connection.h.

68 {}

Member Function Documentation

◆ AllMembers()

const std::vector< std::shared_ptr< SCH_CONNECTION > > SCH_CONNECTION::AllMembers ( ) const

Definition at line 469 of file sch_connection.cpp.

470{
471 std::vector< std::shared_ptr< SCH_CONNECTION > > ret( m_members );
472
473 for( const auto& member : m_members )
474 if( member->IsBus() )
475 ret.insert( ret.end(), member->Members().begin(), member->Members().end() );
476
477 return ret;
478}
std::vector< std::shared_ptr< SCH_CONNECTION > > m_members
For bus connections, store a list of member connections.

References m_members.

Referenced by SCH_EDIT_FRAME::SetCrossProbeConnection().

◆ AppendInfoToMsgPanel()

void SCH_CONNECTION::AppendInfoToMsgPanel ( std::vector< MSG_PANEL_ITEM > &  aList) const

Adds information about the connection object to aList.

Definition at line 405 of file sch_connection.cpp.

406{
407 wxString msg, group_name, members;
408 std::vector<wxString> group_members;
409
410 aList.emplace_back( _( "Connection Name" ), UnescapeString( Name() ) );
411
412 if( std::shared_ptr<BUS_ALIAS> alias = m_graph->GetBusAlias( m_name ) )
413 {
414 msg.Printf( _( "Bus Alias %s Members" ), m_name );
415 aList.emplace_back( msg, boost::algorithm::join( alias->Members(), " " ) );
416 }
417 else if( NET_SETTINGS::ParseBusGroup( m_name, &group_name, &group_members ) )
418 {
419 for( const wxString& group_member : group_members )
420 {
421 if( std::shared_ptr<BUS_ALIAS> group_alias = m_graph->GetBusAlias( group_member ) )
422 {
423 msg.Printf( _( "Bus Alias %s Members" ), group_alias->GetName() );
424 aList.emplace_back( msg, boost::algorithm::join( group_alias->Members(), " " ) );
425 }
426 }
427 }
428
429#if defined(DEBUG)
430 // These messages are not flagged as translatable, because they are only debug messages
431
432 if( !ADVANCED_CFG::GetCfg().m_RealTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime )
433 return;
434
435 if( IsBus() )
436 aList.emplace_back( wxT( "Bus Code" ), wxString::Format( "%d", m_bus_code ) );
437
438 aList.emplace_back( wxT( "Subgraph Code" ), wxString::Format( "%d", m_subgraph_code ) );
439
440 if( SCH_ITEM* driver = Driver() )
441 {
443
444 msg.Printf( "%s at %p", driver->GetSelectMenuText( &unitsProvider ), driver );
445 aList.emplace_back( wxT( "Connection Source" ), msg );
446 }
447#endif
448}
constexpr EDA_IU_SCALE schIUScale
Definition: base_units.h:111
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
static bool m_allowRealTime
std::shared_ptr< BUS_ALIAS > GetBusAlias(const wxString &aName)
Returns a bus alias pointer for the given name if it exists (from cache)
static bool ParseBusGroup(const wxString &aGroup, wxString *name, std::vector< wxString > *aMemberList)
Parse a bus group label into the name and a list of components.
wxString m_name
Name of the connection.
wxString Name(bool aIgnoreSheet=false) const
bool IsBus() const
SCH_ITEM * Driver() const
int m_subgraph_code
Groups directly-connected items.
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:147
#define _(s)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
wxString UnescapeString(const wxString &aSource)

References _, Driver(), Format(), CONNECTION_GRAPH::GetBusAlias(), ADVANCED_CFG::GetCfg(), IsBus(), CONNECTION_GRAPH::m_allowRealTime, m_bus_code, m_graph, m_name, m_subgraph_code, MILLIMETRES, Name(), NET_SETTINGS::ParseBusGroup(), schIUScale, and UnescapeString().

Referenced by SCH_BUS_ENTRY_BASE::GetMsgPanelInfo(), SCH_LABEL_BASE::GetMsgPanelInfo(), SCH_LINE::GetMsgPanelInfo(), and SCH_PIN::GetMsgPanelInfo().

◆ BusCode()

int SCH_CONNECTION::BusCode ( ) const
inline

Definition at line 175 of file sch_connection.h.

175{ return m_bus_code; }

References m_bus_code.

Referenced by Clone().

◆ BusPrefix()

wxString SCH_CONNECTION::BusPrefix ( ) const
inline

Definition at line 159 of file sch_connection.h.

159{ return m_bus_prefix; }
wxString m_bus_prefix
Optional prefix of a bux group (always empty for nets and vector buses)

References m_bus_prefix.

◆ ClearDirty()

void SCH_CONNECTION::ClearDirty ( )
inline

Definition at line 135 of file sch_connection.h.

135{ m_dirty = false; }

References m_dirty.

Referenced by CONNECTION_SUBGRAPH::ResolveDrivers(), and CONNECTION_SUBGRAPH::UpdateItemConnections().

◆ ClearDriverChanged()

void SCH_CONNECTION::ClearDriverChanged ( )

Definition at line 338 of file sch_connection.cpp.

339{
341}
void * m_lastDriver
WEAK POINTER (there is no guarantee it is still allocated) Equality comparisons are OK,...

References m_driver, and m_lastDriver.

Referenced by SCH_EDIT_FRAME::RecalculateConnections().

◆ Clone()

void SCH_CONNECTION::Clone ( const SCH_CONNECTION aOther)

Copies connectivity information (but not parent) from another connection.

Parameters
aOtheris the connection to clone

Definition at line 231 of file sch_connection.cpp.

232{
233 m_graph = aOther.m_graph;
234 // Note: m_lastDriver is not cloned as it needs to be the last driver of *this* connection
235 m_driver = aOther.Driver();
236 m_sheet = aOther.Sheet();
237 // Note: m_local_sheet is not cloned
238 m_name = aOther.m_name;
239 // Note: m_local_name is not cloned if not set yet
240 if( m_local_name.IsEmpty() )
241 {
242 m_local_name = aOther.LocalName();
243 m_local_prefix = aOther.Prefix();
244 }
245
246 m_prefix = aOther.Prefix();
247 // m_bus_prefix is not cloned; only used for local names
248 m_suffix = aOther.Suffix();
249 m_net_code = aOther.NetCode();
250 m_bus_code = aOther.BusCode();
251 m_vector_start = aOther.VectorStart();
252 m_vector_end = aOther.VectorEnd();
253 // Note: m_vector_index is not cloned
254 m_vector_prefix = aOther.VectorPrefix();
255
256 // Note: subgraph code isn't cloned, it should remain with the original object
257
258 // Handle vector bus members: make sure local names are preserved where possible
259 const std::vector<std::shared_ptr<SCH_CONNECTION>>& otherMembers = aOther.Members();
260
262 {
263 if( m_members.empty() )
264 {
265 m_members = otherMembers;
266 }
267 else
268 {
269 size_t cloneLimit = std::min( m_members.size(), otherMembers.size() );
270
271 for( size_t i = 0; i < cloneLimit; ++i )
272 m_members[i]->Clone( *otherMembers[i] );
273 }
274 }
276 {
277 if( m_members.empty() )
278 {
279 m_members = otherMembers;
280 }
281 else
282 {
283 // TODO: refactor this once we support deep nesting
284 for( size_t i = 0; i < m_members.size(); ++i )
285 {
286 auto it = std::find_if( otherMembers.begin(), otherMembers.end(),
287 [&]( const std::shared_ptr<SCH_CONNECTION>& aTest )
288 {
289 return aTest->LocalName() == m_members[i]->LocalName();
290 } );
291
292 if( it != otherMembers.end() )
293 m_members[i]->Clone( **it );
294 }
295 }
296 }
297
298 m_type = aOther.Type();
299
300 recacheName();
301}
long VectorEnd() const
long m_vector_start
Highest member of a vector bus.
long VectorStart() const
long m_vector_end
Lowest member of a vector bus.
SCH_SHEET_PATH Sheet() const
CONNECTION_TYPE Type() const
int BusCode() const
wxString m_local_prefix
Local prefix for group bus members (used with m_local_name)
CONNECTION_TYPE m_type
wxString LocalName() const
wxString Suffix() const
wxString m_prefix
Prefix if connection is member of a labeled bus group (or "" if not)
void Clone(const SCH_CONNECTION &aOther)
Copies connectivity information (but not parent) from another connection.
wxString VectorPrefix() const
wxString m_suffix
Name suffix (used only for disambiguation)
wxString Prefix() const
wxString m_local_name
For bus members, we want to keep track of the "local" name of a member, that is, the name it takes on...
std::vector< std::shared_ptr< SCH_CONNECTION > > & Members()
wxString m_vector_prefix
int NetCode() const
@ BUS
This item represents a bus vector.
@ BUS_GROUP
This item represents a bus group.

References BUS, BUS_GROUP, BusCode(), Clone(), Driver(), LocalName(), m_bus_code, m_driver, m_graph, m_local_name, m_local_prefix, m_members, m_name, m_net_code, m_prefix, m_sheet, m_suffix, m_type, m_vector_end, m_vector_prefix, m_vector_start, Members(), NetCode(), Prefix(), recacheName(), Sheet(), Suffix(), Type(), VectorEnd(), VectorPrefix(), and VectorStart().

Referenced by CONNECTION_GRAPH::buildConnectionGraph(), Clone(), CONNECTION_GRAPH::propagateToNeighbors(), and CONNECTION_SUBGRAPH::UpdateItemConnections().

◆ ConfigureFromLabel()

void SCH_CONNECTION::ConfigureFromLabel ( const wxString &  aLabel)

Configures the connection given a label.

For CONNECTION_NET, this just sets the name. For CONNECTION_BUS, this will deduce the correct BUS_TYPE and also generate a correct list of members.

Definition at line 131 of file sch_connection.cpp.

132{
133 m_members.clear();
134
135 m_name = aLabel;
136 m_local_name = aLabel;
138
139 wxString prefix;
140 std::vector<wxString> members;
141
142 wxString unescaped = UnescapeString( aLabel );
143
144 if( NET_SETTINGS::ParseBusVector( unescaped, &prefix, &members ) )
145 {
147 m_vector_prefix = prefix;
148
149 long i = 0;
150
151 for( const wxString& vector_member : members )
152 {
153 auto member = std::make_shared<SCH_CONNECTION>( m_parent, m_sheet );
154 member->m_type = CONNECTION_TYPE::NET;
155 member->m_prefix = m_prefix;
156 member->m_local_name = vector_member;
157 member->m_local_prefix = m_prefix;
158 member->m_vector_index = i++;
159 member->SetName( vector_member );
160 member->SetGraph( m_graph );
161 m_members.push_back( member );
162 }
163 }
164 else if( NET_SETTINGS::ParseBusGroup( unescaped, &prefix, &members ) )
165 {
167 m_bus_prefix = prefix;
168
169 // Named bus groups generate a net prefix, unnamed ones don't
170 if( !prefix.IsEmpty() )
171 prefix += wxT( "." );
172
173 for( const wxString& group_member : members )
174 {
175 // Handle alias inside bus group member list
176 if( auto alias = m_graph->GetBusAlias( group_member ) )
177 {
178 for( const wxString& alias_member : alias->Members() )
179 {
180 auto member = std::make_shared< SCH_CONNECTION >( m_parent, m_sheet );
181 member->SetPrefix( prefix );
182 member->SetGraph( m_graph );
183 member->ConfigureFromLabel( alias_member );
184 m_members.push_back( member );
185 }
186 }
187 else
188 {
189 auto member = std::make_shared< SCH_CONNECTION >( m_parent, m_sheet );
190 member->SetPrefix( prefix );
191 member->SetGraph( m_graph );
192 member->ConfigureFromLabel( group_member );
193 m_members.push_back( member );
194 }
195 }
196 }
197 else
198 {
200 }
201
202 recacheName();
203}
static bool ParseBusVector(const wxString &aBus, wxString *aName, std::vector< wxString > *aMemberList)
Parse a bus vector (e.g.
@ NET
This item represents a net.

References BUS, BUS_GROUP, CONNECTION_GRAPH::GetBusAlias(), m_bus_prefix, m_graph, m_local_name, m_local_prefix, m_members, m_name, m_parent, m_prefix, m_sheet, m_type, m_vector_prefix, NET, NET_SETTINGS::ParseBusGroup(), NET_SETTINGS::ParseBusVector(), recacheName(), and UnescapeString().

Referenced by CONNECTION_GRAPH::ercCheckBusToNetConflicts(), DIALOG_MIGRATE_BUSES::getProposedLabels(), and CONNECTION_SUBGRAPH::ResolveDrivers().

◆ Driver()

SCH_ITEM * SCH_CONNECTION::Driver ( ) const
inline

◆ FullLocalName()

wxString SCH_CONNECTION::FullLocalName ( ) const
inline

Definition at line 145 of file sch_connection.h.

146 {
148 }

References m_local_name, m_local_prefix, and m_suffix.

Referenced by IsSubsetOf().

◆ GetLastDriver()

void * SCH_CONNECTION::GetLastDriver ( ) const
inline

Definition at line 139 of file sch_connection.h.

139{ return m_lastDriver; }

References m_lastDriver.

◆ HasDriverChanged()

bool SCH_CONNECTION::HasDriverChanged ( ) const

Definition at line 332 of file sch_connection.cpp.

333{
334 return m_driver != m_lastDriver;
335}

References m_driver, and m_lastDriver.

Referenced by SCH_EDIT_FRAME::RecalculateConnections().

◆ IsBus()

◆ IsBusLabel()

bool SCH_CONNECTION::IsBusLabel ( const wxString &  aLabel)
static

Test if aLabel has a bus notation.

Parameters
aLabelA wxString object containing the label to test.
Returns
true if text is a bus notation format otherwise false is returned.

Definition at line 451 of file sch_connection.cpp.

452{
453 const wxString& unescaped = UnescapeString( aLabel );
454
455 return NET_SETTINGS::ParseBusVector( unescaped, nullptr, nullptr )
456 || NET_SETTINGS::ParseBusGroup( unescaped, nullptr, nullptr );
457}

References NET_SETTINGS::ParseBusGroup(), NET_SETTINGS::ParseBusVector(), and UnescapeString().

Referenced by SCH_BUS_WIRE_ENTRY::ConnectionPropagatesTo().

◆ IsDirty()

bool SCH_CONNECTION::IsDirty ( ) const
inline

Definition at line 133 of file sch_connection.h.

133{ return m_dirty; }

References m_dirty.

◆ IsDriver()

bool SCH_CONNECTION::IsDriver ( ) const

Checks if the SCH_ITEM this connection is attached to can drive connections Drivers can be labels, sheet pins, or symbol pins.

Returns
true if the attached items is a driver

Definition at line 304 of file sch_connection.cpp.

305{
306 wxASSERT( Parent() );
307
308 switch( Parent()->Type() )
309 {
310 case SCH_LABEL_T:
312 case SCH_HIER_LABEL_T:
313 case SCH_SHEET_PIN_T:
314 case SCH_SHEET_T:
315 case LIB_PIN_T:
316 return true;
317
318 case SCH_PIN_T:
319 {
320 auto pin = static_cast<SCH_PIN*>( Parent() );
321
322 // Only annotated symbols should drive nets.
323 return pin->IsPowerConnection() || pin->GetParentSymbol()->IsAnnotated( &m_sheet );
324 }
325
326 default:
327 return false;
328 }
329}
SCH_ITEM * Parent() const
@ SCH_LABEL_T
Definition: typeinfo.h:150
@ SCH_SHEET_T
Definition: typeinfo.h:157
@ SCH_HIER_LABEL_T
Definition: typeinfo.h:152
@ LIB_PIN_T
Definition: typeinfo.h:202
@ SCH_SHEET_PIN_T
Definition: typeinfo.h:156
@ SCH_GLOBAL_LABEL_T
Definition: typeinfo.h:151
@ SCH_PIN_T
Definition: typeinfo.h:158

References LIB_PIN_T, m_sheet, Parent(), pin, SCH_GLOBAL_LABEL_T, SCH_HIER_LABEL_T, SCH_LABEL_T, SCH_PIN_T, SCH_SHEET_PIN_T, SCH_SHEET_T, and Type().

Referenced by CONNECTION_SUBGRAPH::AddItem().

◆ IsMemberOfBus()

bool SCH_CONNECTION::IsMemberOfBus ( SCH_CONNECTION aOther) const

Returns true if this connection is a member of bus connection aOther.

Will always return false if aOther is not a bus connection

Definition at line 559 of file sch_connection.cpp.

560{
561 if( !aOther->IsBus() )
562 return false;
563
564 auto me = Name( true );
565
566 for( const auto& m : aOther->Members() )
567 if( m->Name( true ) == me )
568 return true;
569
570 return false;
571}

References IsBus(), Members(), and Name().

◆ IsNet()

◆ IsSubsetOf()

bool SCH_CONNECTION::IsSubsetOf ( SCH_CONNECTION aOther) const

Returns true if this connection is contained within aOther (but not the same as aOther)

Returns
true if this connection is a member of aOther

Definition at line 544 of file sch_connection.cpp.

545{
546 if( !aOther->IsBus() )
547 return false;
548
549 for( const auto& member : aOther->Members() )
550 {
551 if( member->FullLocalName() == FullLocalName() )
552 return true;
553 }
554
555 return false;
556}
wxString FullLocalName() const

References FullLocalName(), IsBus(), and Members().

◆ IsUnconnected()

bool SCH_CONNECTION::IsUnconnected ( ) const
inline

Definition at line 131 of file sch_connection.h.

131{ return ( m_type == CONNECTION_TYPE::NONE ); }
@ NONE
No connection to this item.

References m_type, and NONE.

◆ LocalName()

wxString SCH_CONNECTION::LocalName ( ) const
inline

◆ LocalSheet()

SCH_SHEET_PATH SCH_CONNECTION::LocalSheet ( ) const
inline

Definition at line 111 of file sch_connection.h.

111{ return m_local_sheet; }

References m_local_sheet.

Referenced by SCH_EDIT_FRAME::RecalculateConnections().

◆ Members() [1/2]

◆ Members() [2/2]

const std::vector< std::shared_ptr< SCH_CONNECTION > > & SCH_CONNECTION::Members ( ) const
inline

Definition at line 193 of file sch_connection.h.

194 {
195 return m_members;
196 }

References m_members.

◆ MightBeBusLabel()

bool SCH_CONNECTION::MightBeBusLabel ( const wxString &  aLabel)
static

Test if aLabel looks like a bus notation.

This check is much less expensive than IsBusLabel.

Parameters
aLabelA wxString object containing the label to test.
Returns
true if text might be a bus label

Definition at line 460 of file sch_connection.cpp.

461{
462 // Weak heuristic for performance reasons. Stronger test will be used for connectivity
463 wxString label = UnescapeString( aLabel );
464
465 return label.Contains( wxT( "[" ) ) || label.Contains( wxT( "{" ) );
466}

References UnescapeString().

◆ Name()

◆ NetCode()

int SCH_CONNECTION::NetCode ( ) const
inline

Definition at line 172 of file sch_connection.h.

172{ return m_net_code; }

References m_net_code.

Referenced by Clone().

◆ operator!=()

bool SCH_CONNECTION::operator!= ( const SCH_CONNECTION aOther) const

Definition at line 125 of file sch_connection.cpp.

126{
127 return !( aOther == *this );
128}

◆ operator==()

bool SCH_CONNECTION::operator== ( const SCH_CONNECTION aOther) const

Note: the equality operator for SCH_CONNECTION only tests the net properties, not the ownership / sheet location!

Definition at line 87 of file sch_connection.cpp.

88{
89 // NOTE: Not comparing m_dirty or net/bus/subgraph codes
90 if( ( aOther.m_driver == m_driver ) &&
91 ( aOther.m_type == m_type ) &&
92 ( aOther.m_name == m_name ) &&
93 ( aOther.m_sheet == m_sheet ) )
94 {
95 return true;
96 }
97
98 return false;
99}

References m_driver, m_name, m_sheet, and m_type.

◆ Parent()

SCH_ITEM * SCH_CONNECTION::Parent ( ) const
inline

◆ Prefix()

wxString SCH_CONNECTION::Prefix ( ) const
inline

Definition at line 156 of file sch_connection.h.

156{ return m_prefix; }

References m_prefix.

Referenced by Clone().

◆ PrintBusForUI()

wxString SCH_CONNECTION::PrintBusForUI ( const wxString &  aString)
static

Definition at line 487 of file sch_connection.cpp.

488{
489 size_t groupLen = aGroup.length();
490 size_t i = 0;
491 wxString ret;
492 int braceNesting = 0;
493
494 // Parse prefix
495 //
496 for( ; i < groupLen; ++i )
497 {
498 if( isSuperSubOverbar( aGroup[i] ) && i + 1 < groupLen && aGroup[i+1] == '{' )
499 {
500 braceNesting++;
501 i++;
502 continue;
503 }
504 else if( aGroup[i] == '}' )
505 {
506 braceNesting--;
507 continue;
508 }
509
510 ret += aGroup[i];
511
512 if( aGroup[i] == '{' )
513 break;
514 }
515
516 // Parse members
517 //
518 i++; // '{' character
519
520 for( ; i < groupLen; ++i )
521 {
522 if( isSuperSubOverbar( aGroup[i] ) && i + 1 < groupLen && aGroup[i+1] == '{' )
523 {
524 braceNesting++;
525 i++;
526 continue;
527 }
528 else if( aGroup[i] == '}' )
529 {
530 braceNesting--;
531 continue;
532 }
533
534 ret += aGroup[i];
535
536 if( aGroup[i] == '}' )
537 break;
538 }
539
540 return ret;
541}
static bool isSuperSubOverbar(wxChar c)

References isSuperSubOverbar().

Referenced by BUS_UNFOLD_MENU::update().

◆ recacheName()

void SCH_CONNECTION::recacheName ( )
private

Definition at line 352 of file sch_connection.cpp.

353{
355 m_name.IsEmpty() ? wxT( "<NO NET>" ) : wxString( m_prefix ) << m_name << m_suffix;
356
357 bool prepend_path = true;
358
359 if( !Parent() || m_type == CONNECTION_TYPE::NONE )
360 prepend_path = false;
361
362 if( m_driver )
363 {
364 switch( m_driver->Type() )
365 {
367 case SCH_PIN_T:
368 // Pins are either power connections or belong to a uniquely-annotated
369 // symbol, so they don't need a path if they are driving the subgraph.
370 prepend_path = false;
371 break;
372
373 default:
374 break;
375 }
376 }
377
380}
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
wxString PathHumanReadable(bool aUseShortRootName=true) const
Return the sheet path in a human readable form made from the sheet names.

References m_cached_name, m_cached_name_with_path, m_driver, m_name, m_prefix, m_sheet, m_suffix, m_type, NONE, Parent(), SCH_SHEET_PATH::PathHumanReadable(), SCH_GLOBAL_LABEL_T, SCH_PIN_T, and EDA_ITEM::Type().

Referenced by Clone(), ConfigureFromLabel(), SetDriver(), SetName(), SetPrefix(), SetSheet(), SetSuffix(), and SetType().

◆ Reset()

void SCH_CONNECTION::Reset ( )

Clears connectivity information.

Definition at line 206 of file sch_connection.cpp.

207{
209 m_name.Empty();
210 m_local_name.Empty();
211 m_local_prefix.Empty();
212 m_cached_name.Empty();
214 m_prefix.Empty();
215 m_bus_prefix.Empty();
216 m_suffix .Empty();
218 m_driver = nullptr;
219 m_members.clear();
220 m_dirty = true;
221 m_net_code = 0;
222 m_bus_code = 0;
223 m_subgraph_code = 0;
224 m_vector_start = 0;
225 m_vector_end = 0;
226 m_vector_index = 0;
227 m_vector_prefix.Empty();
228}
long m_vector_index
Index of bus vector member nets.

References m_bus_code, m_bus_prefix, m_cached_name, m_cached_name_with_path, m_dirty, m_driver, m_lastDriver, m_local_name, m_local_prefix, m_members, m_name, m_net_code, m_prefix, m_subgraph_code, m_suffix, m_type, m_vector_end, m_vector_index, m_vector_prefix, m_vector_start, and NONE.

Referenced by SCH_ITEM::InitializeConnection(), and SCH_CONNECTION().

◆ SetBusCode()

void SCH_CONNECTION::SetBusCode ( int  aCode)
inline

Definition at line 176 of file sch_connection.h.

176{ m_bus_code = aCode; }

References m_bus_code.

Referenced by CONNECTION_GRAPH::processSubGraphs().

◆ SetDirty()

void SCH_CONNECTION::SetDirty ( )
inline

Definition at line 134 of file sch_connection.h.

134{ m_dirty = true; }

References m_dirty.

◆ SetDriver()

void SCH_CONNECTION::SetDriver ( SCH_ITEM aItem)

Definition at line 102 of file sch_connection.cpp.

103{
104 m_driver = aItem;
105
106 recacheName();
107
108 for( const std::shared_ptr<SCH_CONNECTION>& member : m_members )
109 member->SetDriver( aItem );
110}

References m_driver, m_members, and recacheName().

Referenced by CONNECTION_SUBGRAPH::ResolveDrivers().

◆ SetGraph()

void SCH_CONNECTION::SetGraph ( CONNECTION_GRAPH aGraph)
inline

Definition at line 78 of file sch_connection.h.

79 {
80 m_graph = aGraph;
81 }

References m_graph.

Referenced by SCH_ITEM::InitializeConnection().

◆ SetName()

void SCH_CONNECTION::SetName ( const wxString &  aName)
inline

Definition at line 150 of file sch_connection.h.

151 {
152 m_name = aName;
153 recacheName();
154 }

References m_name, and recacheName().

Referenced by CONNECTION_GRAPH::generateInvisiblePinSubGraphs().

◆ SetNetCode()

void SCH_CONNECTION::SetNetCode ( int  aCode)
inline

Definition at line 173 of file sch_connection.h.

173{ m_net_code = aCode; }

References m_net_code.

Referenced by CONNECTION_GRAPH::assignNewNetCode(), and CONNECTION_GRAPH::generateInvisiblePinSubGraphs().

◆ SetPrefix()

void SCH_CONNECTION::SetPrefix ( const wxString &  aPrefix)

Definition at line 383 of file sch_connection.cpp.

384{
385 m_prefix = aPrefix;
386
387 recacheName();
388
389 for( const auto& m : Members() )
390 m->SetPrefix( aPrefix );
391}

References m_prefix, Members(), and recacheName().

◆ SetSheet()

void SCH_CONNECTION::SetSheet ( SCH_SHEET_PATH  aSheet)

Definition at line 113 of file sch_connection.cpp.

114{
115 m_sheet = aSheet;
116 m_local_sheet = aSheet;
117
118 recacheName();
119
120 for( const std::shared_ptr<SCH_CONNECTION>& member : m_members )
121 member->SetSheet( aSheet );
122}

References m_local_sheet, m_members, m_sheet, and recacheName().

Referenced by SCH_ITEM::InitializeConnection().

◆ SetSubgraphCode()

void SCH_CONNECTION::SetSubgraphCode ( int  aCode)
inline

◆ SetSuffix()

void SCH_CONNECTION::SetSuffix ( const wxString &  aSuffix)

Definition at line 394 of file sch_connection.cpp.

395{
396 m_suffix = aSuffix;
397
398 recacheName();
399
400 for( const auto& m : Members() )
401 m->SetSuffix( aSuffix );
402}

References m_suffix, Members(), and recacheName().

◆ SetType()

void SCH_CONNECTION::SetType ( CONNECTION_TYPE  aType)
inline

Definition at line 166 of file sch_connection.h.

167 {
168 m_type = aType;
169 recacheName();
170 }

References m_type, and recacheName().

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

◆ Sheet()

SCH_SHEET_PATH SCH_CONNECTION::Sheet ( ) const
inline

Definition at line 108 of file sch_connection.h.

108{ return m_sheet; }

References m_sheet.

Referenced by Clone(), and BACK_ANNOTATE::processNetNameChange().

◆ SubgraphCode()

int SCH_CONNECTION::SubgraphCode ( ) const
inline

◆ Suffix()

wxString SCH_CONNECTION::Suffix ( ) const
inline

Definition at line 161 of file sch_connection.h.

161{ return m_suffix; }

References m_suffix.

Referenced by Clone().

◆ Type()

CONNECTION_TYPE SCH_CONNECTION::Type ( ) const
inline

◆ VectorEnd()

long SCH_CONNECTION::VectorEnd ( ) const
inline

Definition at line 182 of file sch_connection.h.

182{ return m_vector_end; }

References m_vector_end.

Referenced by Clone(), and DIALOG_MIGRATE_BUSES::getProposedLabels().

◆ VectorIndex()

long SCH_CONNECTION::VectorIndex ( ) const
inline

Definition at line 184 of file sch_connection.h.

184{ return m_vector_index; }

References m_vector_index.

Referenced by CONNECTION_GRAPH::matchBusMember().

◆ VectorPrefix()

wxString SCH_CONNECTION::VectorPrefix ( ) const
inline

Definition at line 186 of file sch_connection.h.

186{ return m_vector_prefix; }

References m_vector_prefix.

Referenced by Clone(), and DIALOG_MIGRATE_BUSES::getProposedLabels().

◆ VectorStart()

long SCH_CONNECTION::VectorStart ( ) const
inline

Definition at line 181 of file sch_connection.h.

181{ return m_vector_start; }

References m_vector_start.

Referenced by Clone(), and DIALOG_MIGRATE_BUSES::getProposedLabels().

Member Data Documentation

◆ m_bus_code

int SCH_CONNECTION::m_bus_code
private

Definition at line 289 of file sch_connection.h.

Referenced by AppendInfoToMsgPanel(), BusCode(), Clone(), Reset(), and SetBusCode().

◆ m_bus_prefix

wxString SCH_CONNECTION::m_bus_prefix
private

Optional prefix of a bux group (always empty for nets and vector buses)

Definition at line 283 of file sch_connection.h.

Referenced by BusPrefix(), ConfigureFromLabel(), and Reset().

◆ m_cached_name

wxString SCH_CONNECTION::m_cached_name
private

Full name, including prefix and suffix.

Definition at line 263 of file sch_connection.h.

Referenced by Name(), recacheName(), and Reset().

◆ m_cached_name_with_path

wxString SCH_CONNECTION::m_cached_name_with_path
private

Full name including sheet path (if not global)

Definition at line 265 of file sch_connection.h.

Referenced by Name(), recacheName(), and Reset().

◆ m_dirty

bool SCH_CONNECTION::m_dirty
private

Definition at line 240 of file sch_connection.h.

Referenced by ClearDirty(), IsDirty(), Reset(), and SetDirty().

◆ m_driver

SCH_ITEM* SCH_CONNECTION::m_driver
private

◆ m_graph

CONNECTION_GRAPH* SCH_CONNECTION::m_graph
private

Pointer to the connection graph for the schematic this connection exists on.

Needed for bus alias lookups.

Definition at line 314 of file sch_connection.h.

Referenced by AppendInfoToMsgPanel(), Clone(), ConfigureFromLabel(), and SetGraph().

◆ m_lastDriver

void* SCH_CONNECTION::m_lastDriver
private

WEAK POINTER (there is no guarantee it is still allocated) Equality comparisons are OK, but that's pretty much it.

Definition at line 254 of file sch_connection.h.

Referenced by ClearDriverChanged(), GetLastDriver(), HasDriverChanged(), and Reset().

◆ m_local_name

wxString SCH_CONNECTION::m_local_name
private

For bus members, we want to keep track of the "local" name of a member, that is, the name it takes on from its parent bus name.

This is because we always want to use the local name for bus unfolding, matching within buses, etc. The actual resolved name of this bus member might change, for example if it's connected elsewhere to some other item with higher priority.

Definition at line 274 of file sch_connection.h.

Referenced by Clone(), ConfigureFromLabel(), FullLocalName(), LocalName(), and Reset().

◆ m_local_prefix

wxString SCH_CONNECTION::m_local_prefix
private

Local prefix for group bus members (used with m_local_name)

Definition at line 280 of file sch_connection.h.

Referenced by Clone(), ConfigureFromLabel(), FullLocalName(), and Reset().

◆ m_local_sheet

SCH_SHEET_PATH SCH_CONNECTION::m_local_sheet
private

When a connection is overridden by one on a different hierarchical sheet, it will be cloned and m_sheet will point to the parent sheet.

This member stores the original sheet so that it can be used for applications such as net highlighting to retrieve the sheet of the parent item from the highlighted connection.

Definition at line 250 of file sch_connection.h.

Referenced by LocalSheet(), and SetSheet().

◆ m_members

std::vector< std::shared_ptr< SCH_CONNECTION > > SCH_CONNECTION::m_members
private

For bus connections, store a list of member connections.

NOTE: All connections that Clone() others share the list of member pointers. This seems fine at the moment.

Definition at line 308 of file sch_connection.h.

Referenced by AllMembers(), Clone(), ConfigureFromLabel(), Members(), Reset(), SetDriver(), and SetSheet().

◆ m_name

wxString SCH_CONNECTION::m_name
private

Name of the connection.

Definition at line 261 of file sch_connection.h.

Referenced by AppendInfoToMsgPanel(), Clone(), ConfigureFromLabel(), operator==(), recacheName(), Reset(), and SetName().

◆ m_net_code

int SCH_CONNECTION::m_net_code
private

Definition at line 287 of file sch_connection.h.

Referenced by Clone(), NetCode(), Reset(), and SetNetCode().

◆ m_parent

SCH_ITEM* SCH_CONNECTION::m_parent
private

The SCH_ITEM this connection is owned by.

Definition at line 252 of file sch_connection.h.

Referenced by ConfigureFromLabel(), and Parent().

◆ m_prefix

wxString SCH_CONNECTION::m_prefix
private

Prefix if connection is member of a labeled bus group (or "" if not)

Definition at line 277 of file sch_connection.h.

Referenced by Clone(), ConfigureFromLabel(), Prefix(), recacheName(), Reset(), and SetPrefix().

◆ m_sheet

SCH_SHEET_PATH SCH_CONNECTION::m_sheet
private

The hierarchical sheet this connection is on.

Definition at line 242 of file sch_connection.h.

Referenced by Clone(), ConfigureFromLabel(), IsDriver(), operator==(), recacheName(), SetSheet(), and Sheet().

◆ m_subgraph_code

int SCH_CONNECTION::m_subgraph_code
private

Groups directly-connected items.

Definition at line 291 of file sch_connection.h.

Referenced by AppendInfoToMsgPanel(), Reset(), SetSubgraphCode(), and SubgraphCode().

◆ m_suffix

wxString SCH_CONNECTION::m_suffix
private

Name suffix (used only for disambiguation)

Definition at line 285 of file sch_connection.h.

Referenced by Clone(), FullLocalName(), recacheName(), Reset(), SetSuffix(), and Suffix().

◆ m_type

CONNECTION_TYPE SCH_CONNECTION::m_type
private

◆ m_vector_end

long SCH_CONNECTION::m_vector_end
private

Lowest member of a vector bus.

Prefix name of the vector, if m_type == CONNECTION_BUS (or "" if not)

Definition at line 297 of file sch_connection.h.

Referenced by Clone(), Reset(), and VectorEnd().

◆ m_vector_index

long SCH_CONNECTION::m_vector_index
private

Index of bus vector member nets.

Definition at line 293 of file sch_connection.h.

Referenced by Reset(), and VectorIndex().

◆ m_vector_prefix

wxString SCH_CONNECTION::m_vector_prefix
private

Definition at line 300 of file sch_connection.h.

Referenced by Clone(), ConfigureFromLabel(), Reset(), and VectorPrefix().

◆ m_vector_start

long SCH_CONNECTION::m_vector_start
private

Highest member of a vector bus.

Definition at line 295 of file sch_connection.h.

Referenced by Clone(), Reset(), and VectorStart().


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