Implement cross-references for labels.

Fixes https://gitlab.com/kicad/code/kicad/issues/11564
This commit is contained in:
Jeff Young 2022-05-07 21:09:06 +01:00
parent ecf6773f74
commit f9f0f6fe24
2 changed files with 15 additions and 1 deletions

View File

@ -228,7 +228,12 @@ bool DIALOG_LABEL_PROPERTIES::TransferDataToWindow()
if( m_activeTextEntry )
{
// show control characters in a human-readable format
m_activeTextEntry->SetValue( UnescapeString( m_currentLabel->GetText() ) );
wxString text = UnescapeString( m_currentLabel->GetText() );
// show text variable cross-references in a human-readable format
text = m_currentLabel->Schematic()->ConvertKIIDsToRefs( text );
m_activeTextEntry->SetValue( text );
}
if( m_currentLabel->Type() == SCH_GLOBAL_LABEL_T || m_currentLabel->Type() == SCH_LABEL_T )
@ -403,6 +408,9 @@ bool DIALOG_LABEL_PROPERTIES::TransferDataFromWindow()
// labels need escaping
text = EscapeString( m_activeTextEntry->GetValue(), CTX_NETNAME );
// convert any text variable cross-references to their UUIDs
text = m_currentLabel->Schematic()->ConvertRefsToKIIDs( text );
#ifdef __WXMAC__
// On macOS CTRL+Enter produces '\r' instead of '\n' regardless of EOL setting
text.Replace( "\r", "\n" );

View File

@ -447,6 +447,12 @@ void SCH_LABEL_BASE::AutoplaceFields( SCH_SCREEN* aScreen, bool aManual )
bool SCH_LABEL_BASE::ResolveTextVar( wxString* token, int aDepth ) const
{
if( token->Contains( ':' ) )
{
if( Schematic()->ResolveCrossReference( token, aDepth ) )
return true;
}
if( ( Type() == SCH_GLOBAL_LABEL_T || Type() == SCH_HIER_LABEL_T || Type() == SCH_SHEET_PIN_T )
&& token->IsSameAs( wxT( "CONNECTION_TYPE" ) ) )
{