Implement cross-references for labels.

Fixes https://gitlab.com/kicad/code/kicad/issues/11564

(cherry picked from commit f9f0f6fe24)
This commit is contained in:
Jeff Young 2022-05-07 21:09:06 +01:00
parent 5b24003f6c
commit 8524042352
2 changed files with 24 additions and 19 deletions

View File

@ -176,17 +176,22 @@ bool DIALOG_TEXT_AND_LABEL_PROPERTIES::TransferDataToWindow()
if( !wxDialog::TransferDataToWindow() )
return false;
if( m_CurrentText->Type() == SCH_TEXT_T )
{
SCHEMATIC& schematic = m_Parent->Schematic();
if( m_CurrentText->Type() == SCH_TEXT_T )
{
// show text variable cross-references in a human-readable format
m_valueMultiLine->SetValue( schematic.ConvertKIIDsToRefs( m_CurrentText->GetText() ) );
}
else
{
// show control characters in a human-readable format
m_activeTextEntry->SetValue( UnescapeString( m_CurrentText->GetText() ) );
wxString text = UnescapeString( m_CurrentText->GetText() );
// show text variable cross-references in a human-readable format
text = schematic.ConvertKIIDsToRefs( text );
m_activeTextEntry->SetValue( text );
}
if( m_valueCombo->IsShown() )
@ -315,6 +320,7 @@ bool DIALOG_TEXT_AND_LABEL_PROPERTIES::TransferDataFromWindow()
if( !m_textSize.Validate( 0.01, 1000.0, EDA_UNITS::MILLIMETRES ) )
return false;
SCHEMATIC& schematic = m_Parent->Schematic();
wxString text;
/* save old text in undo list if not already in edit */
@ -325,8 +331,7 @@ bool DIALOG_TEXT_AND_LABEL_PROPERTIES::TransferDataFromWindow()
if( m_CurrentText->Type() == SCH_TEXT_T )
{
// convert any text variable cross-references to their UUIDs
text = m_Parent->Schematic().ConvertRefsToKIIDs( m_valueMultiLine->GetValue() );
text = m_valueMultiLine->GetValue();
}
else
{
@ -334,6 +339,9 @@ bool DIALOG_TEXT_AND_LABEL_PROPERTIES::TransferDataFromWindow()
text = EscapeString( m_activeTextEntry->GetValue(), CTX_NETNAME );
}
// convert any text variable cross-references to their UUIDs
text = schematic.ConvertRefsToKIIDs( text );
if( !text.IsEmpty() )
{
#ifdef __WXMAC__

View File

@ -619,8 +619,6 @@ wxString SCH_TEXT::GetShownText( int aDepth ) const
return true;
}
if( Type() == SCH_TEXT_T )
{
if( token->Contains( ':' ) )
{
if( Schematic()->ResolveCrossReference( token, aDepth ) )
@ -634,7 +632,6 @@ wxString SCH_TEXT::GetShownText( int aDepth ) const
if( sheet && sheet->ResolveTextVar( token, aDepth + 1 ) )
return true;
}
}
return false;
};