KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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, const SCH_SHEET_PATH &aPath=SCH_SHEET_PATH())
 Buses can be defined in multiple ways.
 
 SCH_CONNECTION (SCH_CONNECTION &aOther)
 
 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!
 
bool operator!= (const SCH_CONNECTION &aOther) const
 
void SetGraph (CONNECTION_GRAPH *aGraph)
 
void ConfigureFromLabel (const wxString &aLabel)
 Configures the connection given a label.
 
void Reset ()
 Clears connectivity information.
 
void Clone (const SCH_CONNECTION &aOther)
 Copies connectivity information (but not parent) from another connection.
 
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.
 
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 GetNetName () const
 
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
 
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)
 
bool IsMemberOfBus (SCH_CONNECTION *aOther) const
 Returns true if this connection is a member of bus connection aOther.
 
void AppendInfoToMsgPanel (std::vector< MSG_PANEL_ITEM > &aList) const
 Adds information about the connection object to aList.
 

Static Public Member Functions

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

Private Member Functions

void recacheName ()
 

Private Attributes

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

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/3]

SCH_CONNECTION::SCH_CONNECTION ( SCH_ITEM aParent = nullptr,
const 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.

References Reset().

◆ SCH_CONNECTION() [2/3]

SCH_CONNECTION::SCH_CONNECTION ( SCH_CONNECTION aOther)

Definition at line 87 of file sch_connection.cpp.

References Clone(), and Reset().

◆ SCH_CONNECTION() [3/3]

SCH_CONNECTION::SCH_CONNECTION ( CONNECTION_GRAPH aGraph)

Definition at line 76 of file sch_connection.cpp.

References Reset().

◆ ~SCH_CONNECTION()

SCH_CONNECTION::~SCH_CONNECTION ( )
inline

Definition at line 69 of file sch_connection.h.

Member Function Documentation

◆ AllMembers()

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

◆ AppendInfoToMsgPanel()

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

◆ BusCode()

int SCH_CONNECTION::BusCode ( ) const
inline

Definition at line 179 of file sch_connection.h.

References m_bus_code.

Referenced by Clone().

◆ BusPrefix()

wxString SCH_CONNECTION::BusPrefix ( ) const
inline

Definition at line 163 of file sch_connection.h.

References m_bus_prefix.

◆ ClearDirty()

void SCH_CONNECTION::ClearDirty ( )
inline

◆ ClearDriverChanged()

void SCH_CONNECTION::ClearDriverChanged ( )

Definition at line 351 of file sch_connection.cpp.

References m_driver, and m_lastDriver.

Referenced by SCH_EDIT_FRAME::RecalculateConnections().

◆ Clone()

◆ 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 139 of file sch_connection.cpp.

References CTX_NETNAME, EscapeString(), 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_SETTINGS::ParseBusGroup(), NET_SETTINGS::ParseBusVector(), recacheName(), and UnescapeString().

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

◆ Driver()

SCH_ITEM * SCH_CONNECTION::Driver ( ) const
inline

Definition at line 107 of file sch_connection.h.

References m_driver.

Referenced by AppendInfoToMsgPanel(), SCH_EDITOR_CONTROL::AssignNetclass(), and Clone().

◆ FullLocalName()

wxString SCH_CONNECTION::FullLocalName ( ) const
inline

◆ GetLastDriver()

void * SCH_CONNECTION::GetLastDriver ( ) const
inline

Definition at line 141 of file sch_connection.h.

References m_lastDriver.

◆ GetNetName()

wxString SCH_CONNECTION::GetNetName ( ) const

◆ HasDriverChanged()

bool SCH_CONNECTION::HasDriverChanged ( ) const

◆ 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 477 of file sch_connection.cpp.

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 135 of file sch_connection.h.

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 313 of file sch_connection.cpp.

References 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(), and CONNECTION_SUBGRAPH::ExchangeItem().

◆ 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 587 of file sch_connection.cpp.

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 572 of file sch_connection.cpp.

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

Referenced by CONNECTION_SUBGRAPH::ResolveDrivers().

◆ IsUnconnected()

bool SCH_CONNECTION::IsUnconnected ( ) const
inline

Definition at line 133 of file sch_connection.h.

References m_type.

◆ LocalName()

wxString SCH_CONNECTION::LocalName ( ) const
inline

◆ LocalSheet()

SCH_SHEET_PATH SCH_CONNECTION::LocalSheet ( ) const
inline

Definition at line 113 of file sch_connection.h.

References m_local_sheet.

◆ 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 486 of file sch_connection.cpp.

References UnescapeString().

◆ Name()

◆ NetCode()

int SCH_CONNECTION::NetCode ( ) const
inline

Definition at line 176 of file sch_connection.h.

References m_net_code.

Referenced by Clone().

◆ operator!=()

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

Definition at line 133 of file sch_connection.cpp.

◆ 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 95 of file sch_connection.cpp.

References m_driver, m_name, m_sheet, and m_type.

◆ Parent()

SCH_ITEM * SCH_CONNECTION::Parent ( ) const
inline

Definition at line 105 of file sch_connection.h.

References m_parent.

Referenced by IsDriver(), and recacheName().

◆ Prefix()

wxString SCH_CONNECTION::Prefix ( ) const
inline

Definition at line 160 of file sch_connection.h.

References m_prefix.

Referenced by Clone().

◆ PrintBusForUI()

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

Definition at line 515 of file sch_connection.cpp.

References isSuperSubOverbar().

Referenced by BUS_UNFOLD_MENU::update().

◆ recacheName()

◆ Reset()

◆ SetBusCode()

void SCH_CONNECTION::SetBusCode ( int  aCode)
inline

Definition at line 180 of file sch_connection.h.

References m_bus_code.

Referenced by CONNECTION_GRAPH::processSubGraphs().

◆ SetDirty()

void SCH_CONNECTION::SetDirty ( )
inline

Definition at line 136 of file sch_connection.h.

References m_dirty.

◆ SetDriver()

void SCH_CONNECTION::SetDriver ( SCH_ITEM aItem)

◆ SetGraph()

void SCH_CONNECTION::SetGraph ( CONNECTION_GRAPH aGraph)
inline

◆ SetName()

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

◆ SetNetCode()

void SCH_CONNECTION::SetNetCode ( int  aCode)
inline

◆ SetPrefix()

void SCH_CONNECTION::SetPrefix ( const wxString &  aPrefix)

Definition at line 412 of file sch_connection.cpp.

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

◆ SetSheet()

void SCH_CONNECTION::SetSheet ( SCH_SHEET_PATH  aSheet)

Definition at line 121 of file sch_connection.cpp.

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 423 of file sch_connection.cpp.

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

◆ SetType()

void SCH_CONNECTION::SetType ( CONNECTION_TYPE  aType)
inline

◆ Sheet()

SCH_SHEET_PATH SCH_CONNECTION::Sheet ( ) const
inline

Definition at line 110 of file sch_connection.h.

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 165 of file sch_connection.h.

References m_suffix.

Referenced by Clone().

◆ Type()

◆ VectorEnd()

long SCH_CONNECTION::VectorEnd ( ) const
inline

Definition at line 186 of file sch_connection.h.

References m_vector_end.

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

◆ VectorIndex()

long SCH_CONNECTION::VectorIndex ( ) const
inline

Definition at line 188 of file sch_connection.h.

References m_vector_index.

Referenced by CONNECTION_GRAPH::matchBusMember().

◆ VectorPrefix()

wxString SCH_CONNECTION::VectorPrefix ( ) const
inline

Definition at line 190 of file sch_connection.h.

References m_vector_prefix.

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

◆ VectorStart()

long SCH_CONNECTION::VectorStart ( ) const
inline

Definition at line 185 of file sch_connection.h.

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 288 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 282 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 262 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 264 of file sch_connection.h.

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

◆ m_dirty

bool SCH_CONNECTION::m_dirty
private

Definition at line 239 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 313 of file sch_connection.h.

Referenced by AppendInfoToMsgPanel(), Clone(), ConfigureFromLabel(), GetNetName(), 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 253 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 273 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 279 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 249 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 307 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 260 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 286 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 251 of file sch_connection.h.

Referenced by ConfigureFromLabel(), GetNetName(), 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 276 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 241 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 290 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 284 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 296 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 292 of file sch_connection.h.

Referenced by Reset(), and VectorIndex().

◆ m_vector_prefix

wxString SCH_CONNECTION::m_vector_prefix
private

Definition at line 299 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 294 of file sch_connection.h.

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


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