Cache connection names
This commit is contained in:
parent
1204b9cbef
commit
f4f43f51c8
|
@ -89,6 +89,8 @@ void SCH_CONNECTION::SetDriver( SCH_ITEM* aItem )
|
||||||
{
|
{
|
||||||
m_driver = aItem;
|
m_driver = aItem;
|
||||||
|
|
||||||
|
recacheName();
|
||||||
|
|
||||||
for( const auto& member : m_members )
|
for( const auto& member : m_members )
|
||||||
member->SetDriver( aItem );
|
member->SetDriver( aItem );
|
||||||
}
|
}
|
||||||
|
@ -98,6 +100,8 @@ void SCH_CONNECTION::SetSheet( SCH_SHEET_PATH aSheet )
|
||||||
{
|
{
|
||||||
m_sheet = aSheet;
|
m_sheet = aSheet;
|
||||||
|
|
||||||
|
recacheName();
|
||||||
|
|
||||||
for( const auto& member : m_members )
|
for( const auto& member : m_members )
|
||||||
member->SetSheet( aSheet );
|
member->SetSheet( aSheet );
|
||||||
}
|
}
|
||||||
|
@ -132,9 +136,9 @@ void SCH_CONNECTION::ConfigureFromLabel( wxString aLabel )
|
||||||
auto member = std::make_shared<SCH_CONNECTION>( m_parent, m_sheet );
|
auto member = std::make_shared<SCH_CONNECTION>( m_parent, m_sheet );
|
||||||
member->m_type = CONNECTION_TYPE::NET;
|
member->m_type = CONNECTION_TYPE::NET;
|
||||||
member->m_prefix = m_prefix;
|
member->m_prefix = m_prefix;
|
||||||
member->m_name = vector_member;
|
|
||||||
member->m_local_name = vector_member;
|
member->m_local_name = vector_member;
|
||||||
member->m_vector_index = i++;
|
member->m_vector_index = i++;
|
||||||
|
member->SetName( vector_member );
|
||||||
m_members.push_back( member );
|
m_members.push_back( member );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -177,6 +181,8 @@ void SCH_CONNECTION::ConfigureFromLabel( wxString aLabel )
|
||||||
{
|
{
|
||||||
m_type = CONNECTION_TYPE::NET;
|
m_type = CONNECTION_TYPE::NET;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
recacheName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -185,6 +191,8 @@ void SCH_CONNECTION::Reset()
|
||||||
m_type = CONNECTION_TYPE::NONE;
|
m_type = CONNECTION_TYPE::NONE;
|
||||||
m_name.Empty();
|
m_name.Empty();
|
||||||
m_local_name.Empty();
|
m_local_name.Empty();
|
||||||
|
m_cached_name.Empty();
|
||||||
|
m_cached_name_with_path.Empty();
|
||||||
m_prefix.Empty();
|
m_prefix.Empty();
|
||||||
m_suffix .Empty();
|
m_suffix .Empty();
|
||||||
m_driver = nullptr;
|
m_driver = nullptr;
|
||||||
|
@ -218,6 +226,8 @@ void SCH_CONNECTION::Clone( SCH_CONNECTION& aOther )
|
||||||
m_vector_prefix = aOther.VectorPrefix();
|
m_vector_prefix = aOther.VectorPrefix();
|
||||||
|
|
||||||
// Note: subgraph code isn't cloned, it should remain with the original object
|
// Note: subgraph code isn't cloned, it should remain with the original object
|
||||||
|
|
||||||
|
recacheName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -250,44 +260,40 @@ bool SCH_CONNECTION::IsDriver() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString SCH_CONNECTION::Name( bool aIgnoreSheet ) const
|
const wxString& SCH_CONNECTION::Name( bool aIgnoreSheet ) const
|
||||||
{
|
{
|
||||||
wxString ret = m_prefix + m_name + m_suffix;
|
wxASSERT( !m_cached_name.IsEmpty() );
|
||||||
|
return aIgnoreSheet ? m_cached_name : m_cached_name_with_path;
|
||||||
|
}
|
||||||
|
|
||||||
if( m_name.IsEmpty() )
|
|
||||||
ret = "<NO NET>";
|
void SCH_CONNECTION::recacheName()
|
||||||
|
{
|
||||||
|
m_cached_name = m_name.IsEmpty() ? "<NO NET>" : m_prefix + m_name + m_suffix;
|
||||||
|
|
||||||
|
bool prepend_path = true;
|
||||||
|
|
||||||
if( !Parent() || m_type == CONNECTION_TYPE::NONE )
|
if( !Parent() || m_type == CONNECTION_TYPE::NONE )
|
||||||
return ret;
|
prepend_path = false;
|
||||||
|
|
||||||
if( !aIgnoreSheet )
|
if( m_driver )
|
||||||
{
|
{
|
||||||
bool prepend_path = true;
|
switch( m_driver->Type() )
|
||||||
|
|
||||||
if( m_driver )
|
|
||||||
{
|
{
|
||||||
switch( m_driver->Type() )
|
case SCH_GLOBAL_LABEL_T:
|
||||||
{
|
case SCH_PIN_T:
|
||||||
case SCH_PIN_T:
|
// Pins are either power connections or belong to a uniquely-annotated
|
||||||
// Pins are either power connections or belong to a uniquely-annotated
|
// component, so they don't need a path if they are driving the subgraph
|
||||||
// component, so they don't need a path if they are driving the subgraph
|
prepend_path = false;
|
||||||
prepend_path = false;
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case SCH_GLOBAL_LABEL_T:
|
default:
|
||||||
prepend_path = false;
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( prepend_path )
|
|
||||||
ret = m_sheet.PathHumanReadable() + ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
m_cached_name_with_path =
|
||||||
|
prepend_path ? m_sheet.PathHumanReadable() + m_cached_name : m_cached_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -295,6 +301,8 @@ void SCH_CONNECTION::SetPrefix( const wxString& aPrefix )
|
||||||
{
|
{
|
||||||
m_prefix = aPrefix;
|
m_prefix = aPrefix;
|
||||||
|
|
||||||
|
recacheName();
|
||||||
|
|
||||||
for( const auto& m : Members() )
|
for( const auto& m : Members() )
|
||||||
m->SetPrefix( aPrefix );
|
m->SetPrefix( aPrefix );
|
||||||
}
|
}
|
||||||
|
@ -304,6 +312,8 @@ void SCH_CONNECTION::SetSuffix( const wxString& aSuffix )
|
||||||
{
|
{
|
||||||
m_suffix = aSuffix;
|
m_suffix = aSuffix;
|
||||||
|
|
||||||
|
recacheName();
|
||||||
|
|
||||||
for( const auto& m : Members() )
|
for( const auto& m : Members() )
|
||||||
m->SetSuffix( aSuffix );
|
m->SetSuffix( aSuffix );
|
||||||
}
|
}
|
||||||
|
|
|
@ -145,9 +145,9 @@ public:
|
||||||
m_dirty = false;
|
m_dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString Name( bool aIgnoreSheet = false ) const;
|
const wxString& Name( bool aIgnoreSheet = false ) const;
|
||||||
|
|
||||||
wxString RawName() const
|
const wxString& RawName() const
|
||||||
{
|
{
|
||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
@ -157,6 +157,7 @@ public:
|
||||||
void SetName( const wxString& aName )
|
void SetName( const wxString& aName )
|
||||||
{
|
{
|
||||||
m_name = aName;
|
m_name = aName;
|
||||||
|
recacheName();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString Prefix() const
|
wxString Prefix() const
|
||||||
|
@ -181,6 +182,7 @@ public:
|
||||||
void SetType( CONNECTION_TYPE aType )
|
void SetType( CONNECTION_TYPE aType )
|
||||||
{
|
{
|
||||||
m_type = aType;
|
m_type = aType;
|
||||||
|
recacheName();
|
||||||
}
|
}
|
||||||
|
|
||||||
int NetCode() const
|
int NetCode() const
|
||||||
|
@ -318,6 +320,7 @@ public:
|
||||||
static bool IsBusGroupLabel( const wxString& aLabel );
|
static bool IsBusGroupLabel( const wxString& aLabel );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void recacheName();
|
||||||
|
|
||||||
bool m_dirty;
|
bool m_dirty;
|
||||||
|
|
||||||
|
@ -331,6 +334,10 @@ private:
|
||||||
|
|
||||||
wxString m_name; ///< Name of the connection.
|
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)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For bus members, we want to keep track of the "local" name of a member, that is,
|
* 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 name it takes on from its parent bus name. This is because we always want to use
|
||||||
|
|
Loading…
Reference in New Issue