ADDED support for NET_NAME, SHORT_NET_NAME and NET_CLASS system vars.

They can be used in fields of any of the label types.

Fixes https://gitlab.com/kicad/code/kicad/issues/12158
This commit is contained in:
Jeff Young 2022-08-04 18:05:55 +01:00
parent e3e24322bb
commit 2b1cfd6a74
1 changed files with 36 additions and 0 deletions

View File

@ -445,6 +445,42 @@ bool SCH_LABEL_BASE::ResolveTextVar( wxString* token, int aDepth ) const
*token = getElectricalTypeLabel( label->GetShape() );
return true;
}
else if( token->IsSameAs( wxT( "SHORT_NET_NAME" ) ) )
{
const SCH_CONNECTION* connection = Connection();
*token = wxEmptyString;
if( connection )
*token = connection->LocalName();
return true;
}
else if( token->IsSameAs( wxT( "NET_NAME" ) ) )
{
const SCH_CONNECTION* connection = Connection();
*token = wxEmptyString;
if( connection )
*token = connection->Name();
return true;
}
else if( token->IsSameAs( wxT( "NET_CLASS" ) ) )
{
const SCH_CONNECTION* connection = Connection();
*token = wxEmptyString;
if( connection )
{
NET_SETTINGS& netSettings = Schematic()->Prj().GetProjectFile().NetSettings();
*token = netSettings.m_NetClasses.GetDefaultPtr()->GetName();
if( netSettings.m_NetClassAssignments.count( connection->Name() ) )
*token = netSettings.m_NetClassAssignments[ connection->Name() ];
}
return true;
}
for( size_t i = 0; i < m_fields.size(); ++i )
{