24 #include <wx/tokenzr.h> 66 m_local_sheet( aPath ),
107 for(
const std::shared_ptr<SCH_CONNECTION>& member :
m_members )
108 member->SetDriver( aItem );
119 for(
const std::shared_ptr<SCH_CONNECTION>& member :
m_members )
120 member->SetSheet( aSheet );
126 return !( aOther == *this );
139 std::vector<wxString> members;
150 for(
const wxString& vector_member : members )
155 member->m_local_name = vector_member;
157 member->m_vector_index = i++;
158 member->SetName( vector_member );
169 if( !prefix.IsEmpty() )
170 prefix += wxT(
"." );
172 for(
const wxString& group_member : members )
177 for(
const wxString& alias_member : alias->Members() )
180 member->SetPrefix( prefix );
182 member->ConfigureFromLabel( alias_member );
189 member->SetPrefix( prefix );
191 member->ConfigureFromLabel( group_member );
258 const std::vector<std::shared_ptr<SCH_CONNECTION>>& otherMembers = aOther.
Members();
268 size_t cloneLimit = std::min(
m_members.size(), otherMembers.size() );
270 for(
size_t i = 0; i < cloneLimit; ++i )
283 for(
size_t i = 0; i <
m_members.size(); ++i )
285 auto it = std::find_if( otherMembers.begin(), otherMembers.end(),
286 [&](
const std::shared_ptr<SCH_CONNECTION>& aTest )
288 return aTest->LocalName() ==
m_members[i]->LocalName();
291 if( it != otherMembers.end() )
319 auto pin = static_cast<SCH_PIN*>(
Parent() );
322 return pin->IsPowerConnection() ||
pin->GetParentSymbol()->IsAnnotated( &
m_sheet );
355 bool prepend_path =
true;
358 prepend_path =
false;
368 prepend_path =
false;
387 for(
const auto& m :
Members() )
388 m->SetPrefix( aPrefix );
398 for(
const auto& m :
Members() )
399 m->SetSuffix( aSuffix );
405 wxString msg, group_name, members;
406 std::vector<wxString> group_members;
420 msg.Printf(
_(
"Bus Alias %s Members" ),
m_name );
422 for(
const wxString& member : alias->Members() )
423 members << member << wxT(
" " );
425 aList.emplace_back( msg, members );
429 for(
const wxString& group_member : group_members )
433 msg.Printf(
_(
"Bus Alias %s Members" ), group_alias->GetName() );
435 for(
const wxString& member : group_alias->Members() )
436 members << member << wxT(
" " );
438 aList.emplace_back( msg, members );
457 aList.emplace_back( wxT(
"Connection Source" ), msg );
477 return label.Contains( wxT(
"[" ) ) || label.Contains( wxT(
"{" ) );
483 std::vector< std::shared_ptr< SCH_CONNECTION > > ret(
m_members );
486 if( member->IsBus() )
487 ret.insert( ret.end(), member->Members().begin(), member->Members().end() );
495 return c ==
'_' || c ==
'^' || c ==
'~';
501 size_t groupLen = aGroup.length();
504 int braceNesting = 0;
508 for( ; i < groupLen; ++i )
516 else if( aGroup[i] ==
'}' )
524 if( aGroup[i] ==
'{' )
532 for( ; i < groupLen; ++i )
540 else if( aGroup[i] ==
'}' )
548 if( aGroup[i] ==
'}' )
558 if( !aOther->
IsBus() )
561 for(
const auto& member : aOther->
Members() )
573 if( !aOther->
IsBus() )
576 auto me =
Name(
true );
578 for(
const auto& m : aOther->
Members() )
579 if( m->Name(
true ) == me )
static wxString PrintBusForUI(const wxString &aString)
int m_subgraph_code
Groups directly-connected items.
static bool MightBeBusLabel(const wxString &aLabel)
Test if aLabel looks like a bus notation.
void Clone(const SCH_CONNECTION &aOther)
Copies connectivity information (but not parent) from another connection.
wxString m_cached_name
Full name, including prefix and suffix.
std::vector< std::shared_ptr< SCH_CONNECTION > > m_members
For bus connections, store a list of member connections.
std::shared_ptr< BUS_ALIAS > GetBusAlias(const wxString &aName)
Returns a bus alias pointer for the given name if it exists (from cache)
Calculates the connectivity of a schematic and generates netlists.
wxString m_name
Name of the connection.
SCH_ITEM * m_driver
The SCH_ITEM that drives this connection's net.
static bool IsBusLabel(const wxString &aLabel)
Test if aLabel has a bus notation.
This item represents a bus group.
wxString m_bus_prefix
Optional prefix of a bux group (always empty for nets and vector buses)
wxString PathHumanReadable(bool aUseShortRootName=true) const
Return the sheet path in a human readable form made from the sheet names.
SCH_CONNECTION(SCH_ITEM *aParent=nullptr, SCH_SHEET_PATH aPath=SCH_SHEET_PATH())
Buses can be defined in multiple ways.
bool IsMemberOfBus(SCH_CONNECTION *aOther) const
Returns true if this connection is a member of bus connection aOther.
void ConfigureFromLabel(const wxString &aLabel)
Configures the connection given a label.
void SetDriver(SCH_ITEM *aItem)
void SetSheet(SCH_SHEET_PATH aSheet)
wxString m_cached_name_with_path
Full name including sheet path (if not global)
wxString LocalName() const
bool HasDriverChanged() const
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.
No connection to this item.
wxString Name(bool aIgnoreSheet=false) const
const std::vector< std::shared_ptr< SCH_CONNECTION > > AllMembers() const
void AppendInfoToMsgPanel(std::vector< MSG_PANEL_ITEM > &aList) const
Adds information about the connection object to aList.
void Reset()
Clears connectivity information.
wxString m_local_prefix
Local prefix for group bus members (used with m_local_name)
SCH_ITEM * Driver() const
wxString m_prefix
Prefix if connection is member of a labeled bus group (or "" if not)
CONNECTION_GRAPH * m_graph
Pointer to the connection graph for the schematic this connection exists on.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
wxString FullLocalName() const
bool IsDriver() const
Checks if the SCH_ITEM this connection is attached to can drive connections Drivers can be labels,...
SCH_SHEET_PATH m_sheet
The hierarchical sheet this connection is on.
wxString UnescapeString(const wxString &aSource)
This item represents a net.
wxString m_suffix
Name suffix (used only for disambiguation)
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
static bool m_allowRealTime
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...
SCH_SHEET_PATH Sheet() const
void ClearDriverChanged()
long m_vector_start
Highest member of a vector bus.
wxString VectorPrefix() const
Each graphical item can have a SCH_CONNECTION describing its logical connection (to a bus or net).
void SetSuffix(const wxString &aSuffix)
void SetPrefix(const wxString &aPrefix)
static bool ParseBusVector(const wxString &aBus, wxString *aName, std::vector< wxString > *aMemberList)
Parse a bus vector (e.g.
bool operator!=(const SCH_CONNECTION &aOther) const
SCH_ITEM * Parent() const
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...
std::vector< std::shared_ptr< SCH_CONNECTION > > & Members()
static bool isSuperSubOverbar(wxChar c)
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
long m_vector_index
Index of bus vector member nets.
long m_vector_end
Lowest member of a vector bus.
bool IsSubsetOf(SCH_CONNECTION *aOther) const
Returns true if this connection is contained within aOther (but not the same as aOther)
void * m_lastDriver
WEAK POINTER (there is no guarantee it is still allocated) Equality comparisons are OK,...
CONNECTION_TYPE Type() const
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCH_ITEM * m_parent
The SCH_ITEM this connection is owned by.
bool operator==(const SCH_CONNECTION &aOther) const
Note: the equality operator for SCH_CONNECTION only tests the net properties, not the ownership / she...
This item represents a bus vector.
KICAD_T Type() const
Returns the type of object.