From 2b1cfd6a74e6a364059955f373293973ad8c51f7 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 4 Aug 2022 18:05:55 +0100 Subject: [PATCH] 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 --- eeschema/sch_label.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/eeschema/sch_label.cpp b/eeschema/sch_label.cpp index 4294f04596..691ad99b25 100644 --- a/eeschema/sch_label.cpp +++ b/eeschema/sch_label.cpp @@ -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 ) {