Fix a bunch more issues with sheetpaths and allowExtraText.

A sheetpath is required to correctly resolve text variables.
Depending on currentSheet is rife with bugs.

There are many places where we do *not* want to be prepending
field names to the field values, such as netlisting,
building PDF hypertext menus, etc.

Also, Find/Replace needs to work on unresolved text, as
that's what we're going to display (and if replace nuked
your variable references you wouldn't be happy).

(cherry picked from commit b41d446f58)
This commit is contained in:
Jeff Young 2023-05-05 14:21:56 +01:00
parent 9c78d86f58
commit e28b50e8d6
73 changed files with 357 additions and 287 deletions

View File

@ -91,7 +91,7 @@ void BOARD_ADAPTER::addText( const EDA_TEXT* aText, CONTAINER_2D_BASE* aContaine
callback_gal.SetIsFill( font->IsOutline() ); callback_gal.SetIsFill( font->IsOutline() );
callback_gal.SetIsStroke( font->IsStroke() ); callback_gal.SetIsStroke( font->IsStroke() );
callback_gal.SetLineWidth( attrs.m_StrokeWidth ); callback_gal.SetLineWidth( attrs.m_StrokeWidth );
font->Draw( &callback_gal, aText->GetShownText(), aText->GetDrawPos(), attrs ); font->Draw( &callback_gal, aText->GetShownText( true ), aText->GetDrawPos(), attrs );
SHAPE_POLY_SET finalPoly; SHAPE_POLY_SET finalPoly;
int margin = attrs.m_StrokeWidth * 1.5 + int margin = attrs.m_StrokeWidth * 1.5 +
@ -137,7 +137,7 @@ void BOARD_ADAPTER::addText( const EDA_TEXT* aText, CONTAINER_2D_BASE* aContaine
attrs.m_Angle = aText->GetDrawRotation(); attrs.m_Angle = aText->GetDrawRotation();
font->Draw( &callback_gal, aText->GetShownText(), aText->GetDrawPos(), attrs ); font->Draw( &callback_gal, aText->GetShownText( true ), aText->GetDrawPos(), attrs );
} }
} }

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 1992-2013 Jean-Pierre Charras <jp.charras at wanadoo.fr>. * Copyright (C) 1992-2013 Jean-Pierre Charras <jp.charras at wanadoo.fr>.
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
* *
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
@ -118,8 +118,12 @@ void DS_DRAW_ITEM_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame,
break; break;
case DS_DATA_ITEM::DS_TEXT: case DS_DATA_ITEM::DS_TEXT:
aList.emplace_back( _( "Text" ), static_cast<DS_DRAW_ITEM_TEXT*>( this )->GetShownText() ); {
DS_DRAW_ITEM_TEXT* textItem = static_cast<DS_DRAW_ITEM_TEXT*>( this );
// Don't use GetShownText(); we want to see the variable references here
aList.emplace_back( _( "Text" ), KIUI::EllipsizeStatusText( aFrame, textItem->GetText() ) );
break; break;
}
case DS_DATA_ITEM::DS_POLYPOLYGON: case DS_DATA_ITEM::DS_POLYPOLYGON:
aList.emplace_back( _( "Imported Shape" ), wxEmptyString ); aList.emplace_back( _( "Imported Shape" ), wxEmptyString );
@ -190,7 +194,7 @@ bool DS_DRAW_ITEM_TEXT::HitTest( const BOX2I& aRect, bool aContains, int aAccura
wxString DS_DRAW_ITEM_TEXT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const wxString DS_DRAW_ITEM_TEXT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
{ {
return wxString::Format( _( "Text '%s'" ), GetShownText() ); return wxString::Format( _( "Text '%s'" ), KIUI::EllipsizeMenuText( GetText() ) );
} }

View File

@ -270,7 +270,7 @@ void KIGFX::DS_PAINTER::draw( const DS_DRAW_ITEM_TEXT* aItem, int aLayer ) const
attrs.m_StrokeWidth = std::max( aItem->GetEffectiveTextPenWidth(), attrs.m_StrokeWidth = std::max( aItem->GetEffectiveTextPenWidth(),
m_renderSettings.GetDefaultPenWidth() ); m_renderSettings.GetDefaultPenWidth() );
font->Draw( m_gal, aItem->GetShownText(), aItem->GetTextPos(), attrs ); font->Draw( m_gal, aItem->GetShownText( true ), aItem->GetTextPos(), attrs );
} }

View File

@ -477,7 +477,8 @@ EDA_TEXT::GetRenderCache( const KIFONT::FONT* aFont, const wxString& forResolved
attrs.m_Angle = resolvedAngle; attrs.m_Angle = resolvedAngle;
font->GetLinesAsGlyphs( &m_render_cache, GetShownText(), GetDrawPos() + aOffset, attrs ); font->GetLinesAsGlyphs( &m_render_cache, forResolvedText, GetDrawPos() + aOffset,
attrs );
m_render_cache_angle = resolvedAngle; m_render_cache_angle = resolvedAngle;
m_render_cache_text = forResolvedText; m_render_cache_text = forResolvedText;
m_render_cache_offset = aOffset; m_render_cache_offset = aOffset;
@ -524,7 +525,7 @@ BOX2I EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const
BOX2I bbox; BOX2I bbox;
wxArrayString strings; wxArrayString strings;
wxString text = GetShownText(); wxString text = GetShownText( true );
int thickness = GetEffectiveTextPenWidth(); int thickness = GetEffectiveTextPenWidth();
if( IsMultilineAllowed() ) if( IsMultilineAllowed() )
@ -662,7 +663,7 @@ void EDA_TEXT::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
{ {
std::vector<VECTOR2I> positions; std::vector<VECTOR2I> positions;
wxArrayString strings; wxArrayString strings;
wxStringSplit( GetShownText(), strings, '\n' ); wxStringSplit( GetShownText( true ), strings, '\n' );
positions.reserve( strings.Count() ); positions.reserve( strings.Count() );
@ -673,7 +674,8 @@ void EDA_TEXT::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
} }
else else
{ {
printOneLineOfText( aSettings, aOffset, aColor, aFillMode, GetShownText(), GetDrawPos() ); printOneLineOfText( aSettings, aOffset, aColor, aFillMode, GetShownText( true ),
GetDrawPos() );
} }
} }
@ -894,7 +896,7 @@ std::shared_ptr<SHAPE_COMPOUND> EDA_TEXT::GetEffectiveTextShape( bool aTriangula
shape->AddShape( triShape ); shape->AddShape( triShape );
} ); } );
font->Draw( &callback_gal, GetShownText(), GetDrawPos(), attrs ); font->Draw( &callback_gal, GetShownText( true ), GetDrawPos(), attrs );
} }
else else
{ {
@ -911,7 +913,7 @@ std::shared_ptr<SHAPE_COMPOUND> EDA_TEXT::GetEffectiveTextShape( bool aTriangula
shape->AddShape( aPoly.Clone() ); shape->AddShape( aPoly.Clone() );
} ); } );
font->Draw( &callback_gal, GetShownText(), GetDrawPos(), attrs ); font->Draw( &callback_gal, GetShownText( true ), GetDrawPos(), attrs );
} }
return shape; return shape;

View File

@ -139,10 +139,10 @@ void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BL
int penWidth = std::max( text->GetEffectiveTextPenWidth(), defaultPenWidth ); int penWidth = std::max( text->GetEffectiveTextPenWidth(), defaultPenWidth );
plotter->Text( text->GetTextPos(), color, text->GetShownText(), text->GetTextAngle(), plotter->Text( text->GetTextPos(), color, text->GetShownText( true ),
text->GetTextSize(), text->GetHorizJustify(), text->GetVertJustify(), text->GetTextAngle(), text->GetTextSize(), text->GetHorizJustify(),
penWidth, text->IsItalic(), text->IsBold(), text->IsMultilineAllowed(), text->GetVertJustify(), penWidth, text->IsItalic(), text->IsBold(),
font ); text->IsMultilineAllowed(), font );
} }
break; break;

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2004-2023 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -376,7 +376,7 @@ void SCH_EDIT_FRAME::AnnotateSymbols( ANNOTATE_SCOPE_T aAnnotateScope,
if( symbol->GetUnitCount() > 1 ) if( symbol->GetUnitCount() > 1 )
{ {
msg.Printf( _( "Updated %s (unit %s) from %s to %s." ), msg.Printf( _( "Updated %s (unit %s) from %s to %s." ),
symbol->GetValueFieldText( true ), symbol->GetValueFieldText( true, sheet, false ),
LIB_SYMBOL::SubReference( symbol->GetUnit(), false ), LIB_SYMBOL::SubReference( symbol->GetUnit(), false ),
prevRef, prevRef,
newRef ); newRef );
@ -384,7 +384,7 @@ void SCH_EDIT_FRAME::AnnotateSymbols( ANNOTATE_SCOPE_T aAnnotateScope,
else else
{ {
msg.Printf( _( "Updated %s from %s to %s." ), msg.Printf( _( "Updated %s from %s to %s." ),
symbol->GetValueFieldText( true ), symbol->GetValueFieldText( true, sheet, false ),
prevRef, prevRef,
newRef ); newRef );
} }
@ -394,14 +394,14 @@ void SCH_EDIT_FRAME::AnnotateSymbols( ANNOTATE_SCOPE_T aAnnotateScope,
if( symbol->GetUnitCount() > 1 ) if( symbol->GetUnitCount() > 1 )
{ {
msg.Printf( _( "Annotated %s (unit %s) as %s." ), msg.Printf( _( "Annotated %s (unit %s) as %s." ),
symbol->GetValueFieldText( true ), symbol->GetValueFieldText( true, sheet, false ),
LIB_SYMBOL::SubReference( symbol->GetUnit(), false ), LIB_SYMBOL::SubReference( symbol->GetUnit(), false ),
newRef ); newRef );
} }
else else
{ {
msg.Printf( _( "Annotated %s as %s." ), msg.Printf( _( "Annotated %s as %s." ),
symbol->GetValueFieldText( true ), symbol->GetValueFieldText( true, sheet, false ),
newRef ); newRef );
} }
} }

View File

@ -336,18 +336,14 @@ wxString CONNECTION_SUBGRAPH::driverName( SCH_ITEM* aItem ) const
case SCH_LABEL_T: case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T: case SCH_GLOBAL_LABEL_T:
case SCH_HIER_LABEL_T: case SCH_HIER_LABEL_T:
{ return EscapeString( static_cast<SCH_TEXT*>( aItem )->GetShownText( &m_sheet, false ),
SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( aItem ); CTX_NETNAME );
return EscapeString( label->GetShownText( &m_sheet ), CTX_NETNAME );
}
case SCH_SHEET_PIN_T: case SCH_SHEET_PIN_T:
{
// Sheet pins need to use their parent sheet as their starting sheet or they will // Sheet pins need to use their parent sheet as their starting sheet or they will
// resolve variables on the current sheet first // resolve variables on the current sheet first
SCH_SHEET_PIN* sheetPin = static_cast<SCH_SHEET_PIN*>( aItem ); return EscapeString( static_cast<SCH_TEXT*>( aItem )->GetShownText( nullptr, false ),
return EscapeString( sheetPin->GetShownText(), CTX_NETNAME ); CTX_NETNAME );
}
default: default:
wxFAIL_MSG( wxS( "Unhandled item type in GetNameForDriver" ) ); wxFAIL_MSG( wxS( "Unhandled item type in GetNameForDriver" ) );
@ -2587,11 +2583,11 @@ std::vector<const CONNECTION_SUBGRAPH*> CONNECTION_GRAPH::GetBusesNeedingMigrati
if( labels.size() > 1 ) if( labels.size() > 1 )
{ {
bool different = false; bool different = false;
wxString first = static_cast<SCH_TEXT*>( labels.at( 0 ) )->GetShownText(); wxString first = static_cast<SCH_TEXT*>( labels.at( 0 ) )->GetShownText( false );
for( unsigned i = 1; i < labels.size(); ++i ) for( unsigned i = 1; i < labels.size(); ++i )
{ {
if( static_cast<SCH_TEXT*>( labels.at( i ) )->GetShownText() != first ) if( static_cast<SCH_TEXT*>( labels.at( i ) )->GetShownText( false ) != first )
{ {
different = true; different = true;
break; break;
@ -2931,7 +2927,7 @@ bool CONNECTION_GRAPH::ercCheckBusToNetConflicts( const CONNECTION_SUBGRAPH* aSu
case SCH_HIER_LABEL_T: case SCH_HIER_LABEL_T:
{ {
SCH_TEXT* text = static_cast<SCH_TEXT*>( item ); SCH_TEXT* text = static_cast<SCH_TEXT*>( item );
conn.ConfigureFromLabel( EscapeString( text->GetShownText(), CTX_NETNAME ) ); conn.ConfigureFromLabel( EscapeString( text->GetShownText( false ), CTX_NETNAME ) );
if( conn.IsBus() ) if( conn.IsBus() )
bus_item = ( !bus_item ) ? item : bus_item; bus_item = ( !bus_item ) ? item : bus_item;

View File

@ -75,7 +75,7 @@ DIALOG_CHANGE_SYMBOLS::DIALOG_CHANGE_SYMBOLS( SCH_EDIT_FRAME* aParent, SCH_SYMBO
m_newId->ChangeValue( UnescapeString( m_symbol->GetLibId().Format() ) ); m_newId->ChangeValue( UnescapeString( m_symbol->GetLibId().Format() ) );
m_specifiedReference->ChangeValue( m_symbol->GetRef( currentSheet ) ); m_specifiedReference->ChangeValue( m_symbol->GetRef( currentSheet ) );
m_specifiedValue->ChangeValue( m_symbol->GetValueFieldText( false ) ); m_specifiedValue->ChangeValue( UnescapeString( m_symbol->GetField( VALUE_FIELD )->GetText() ) );
m_specifiedId->ChangeValue( UnescapeString( m_symbol->GetLibId().Format() ) ); m_specifiedId->ChangeValue( UnescapeString( m_symbol->GetLibId().Format() ) );
} }
else else
@ -426,12 +426,14 @@ bool DIALOG_CHANGE_SYMBOLS::isMatch( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aInsta
else if( m_matchByReference->GetValue() ) else if( m_matchByReference->GetValue() )
{ {
return WildCompareString( m_specifiedReference->GetValue(), return WildCompareString( m_specifiedReference->GetValue(),
aSymbol->GetRef( aInstance, false ), false ); UnescapeString( aSymbol->GetRef( aInstance, false ) ),
false );
} }
else if( m_matchByValue->GetValue() ) else if( m_matchByValue->GetValue() )
{ {
return WildCompareString( m_specifiedValue->GetValue(), return WildCompareString( m_specifiedValue->GetValue(),
aSymbol->GetValueFieldText( false ), false ); UnescapeString( aSymbol->GetField( VALUE_FIELD )->GetText() ),
false );
} }
else if( m_matchById ) else if( m_matchById )
{ {

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com> * Copyright (C) 2013 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -287,7 +287,7 @@ bool DIALOG_LABEL_PROPERTIES::TransferDataToWindow()
// Ensure the symbol has the Power (i.e. equivalent to a global label // Ensure the symbol has the Power (i.e. equivalent to a global label
// before adding its value in list // before adding its value in list
if( power->IsSymbolLikePowerGlobalLabel() ) if( power->IsSymbolLikePowerGlobalLabel() )
existingLabels.insert( UnescapeString( power->GetValueFieldText( false ) ) ); existingLabels.insert( UnescapeString( power->GetField( VALUE_FIELD )->GetText() ) );
} }
} }

View File

@ -874,7 +874,7 @@ void DIALOG_SHEET_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event )
m_dummySheet.SetFields( *m_fields ); m_dummySheet.SetFields( *m_fields );
m_dummySheetNameField.SetText( sheetName ); m_dummySheetNameField.SetText( sheetName );
path += m_dummySheetNameField.GetShownText(); path += m_dummySheetNameField.GetShownText( false );
editor->DecRef(); editor->DecRef();

View File

@ -147,7 +147,7 @@ int ERC_TESTER::TestDuplicateSheetNames( bool aCreateMarker )
// We have found a second sheet: compare names // We have found a second sheet: compare names
// we are using case insensitive comparison to avoid mistakes between // we are using case insensitive comparison to avoid mistakes between
// similar names like Mysheet and mysheet // similar names like Mysheet and mysheet
if( sheet->GetName().CmpNoCase( test_item->GetName() ) == 0 ) if( sheet->GetShownName( false ).CmpNoCase( test_item->GetShownName( false ) ) == 0 )
{ {
if( aCreateMarker ) if( aCreateMarker )
{ {
@ -206,7 +206,7 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
for( SCH_FIELD& field : symbol->GetFields() ) for( SCH_FIELD& field : symbol->GetFields() )
{ {
if( unresolved( field.GetShownText() ) ) if( unresolved( field.GetShownText( true ) ) )
{ {
VECTOR2I pos = field.GetPosition() - symbol->GetPosition(); VECTOR2I pos = field.GetPosition() - symbol->GetPosition();
pos = symbol->GetTransform().TransformCoordinate( pos ); pos = symbol->GetTransform().TransformCoordinate( pos );
@ -227,7 +227,7 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
for( SCH_FIELD& field : subSheet->GetFields() ) for( SCH_FIELD& field : subSheet->GetFields() )
{ {
if( unresolved( field.GetShownText() ) ) if( unresolved( field.GetShownText( true ) ) )
{ {
std::shared_ptr<ERC_ITEM> ercItem = std::shared_ptr<ERC_ITEM> ercItem =
ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE ); ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
@ -240,7 +240,7 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() ) for( SCH_SHEET_PIN* pin : static_cast<SCH_SHEET*>( item )->GetPins() )
{ {
if( pin->GetShownText().Matches( wxT( "*${*}*" ) ) ) if( pin->GetShownText( true ).Matches( wxT( "*${*}*" ) ) )
{ {
std::shared_ptr<ERC_ITEM> ercItem = std::shared_ptr<ERC_ITEM> ercItem =
ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE ); ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
@ -253,7 +253,7 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
} }
else if( SCH_TEXT* text = dynamic_cast<SCH_TEXT*>( item ) ) else if( SCH_TEXT* text = dynamic_cast<SCH_TEXT*>( item ) )
{ {
if( text->GetShownText().Matches( wxT( "*${*}*" ) ) ) if( text->GetShownText( true ).Matches( wxT( "*${*}*" ) ) )
{ {
std::shared_ptr<ERC_ITEM> ercItem = std::shared_ptr<ERC_ITEM> ercItem =
ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE ); ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
@ -265,7 +265,7 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
} }
else if( SCH_TEXTBOX* textBox = dynamic_cast<SCH_TEXTBOX*>( item ) ) else if( SCH_TEXTBOX* textBox = dynamic_cast<SCH_TEXTBOX*>( item ) )
{ {
if( textBox->GetShownText().Matches( wxT( "*${*}*" ) ) ) if( textBox->GetShownText( true ).Matches( wxT( "*${*}*" ) ) )
{ {
std::shared_ptr<ERC_ITEM> ercItem = std::shared_ptr<ERC_ITEM> ercItem =
ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE ); ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
@ -281,7 +281,7 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet )
{ {
if( DS_DRAW_ITEM_TEXT* text = dynamic_cast<DS_DRAW_ITEM_TEXT*>( item ) ) if( DS_DRAW_ITEM_TEXT* text = dynamic_cast<DS_DRAW_ITEM_TEXT*>( item ) )
{ {
if( text->GetShownText().Matches( wxT( "*${*}*" ) ) ) if( text->GetShownText( true ).Matches( wxT( "*${*}*" ) ) )
{ {
std::shared_ptr<ERC_ITEM> erc = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE ); std::shared_ptr<ERC_ITEM> erc = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE );
erc->SetErrorMessage( _( "Unresolved text variable in drawing sheet" ) ); erc->SetErrorMessage( _( "Unresolved text variable in drawing sheet" ) );
@ -824,13 +824,14 @@ int ERC_TESTER::TestSimilarLabels()
{ {
SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( item ); SCH_LABEL_BASE* label = static_cast<SCH_LABEL_BASE*>( item );
wxString normalized = label->GetShownText().Lower(); wxString normalized = label->GetShownText( false ).Lower();
if( !labelMap.count( normalized ) ) if( !labelMap.count( normalized ) )
{ {
labelMap[normalized] = label; labelMap[normalized] = label;
} }
else if( labelMap.at( normalized )->GetShownText() != label->GetShownText() ) else if( labelMap.at( normalized )->GetShownText( false )
!= label->GetShownText( false) )
{ {
std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_SIMILAR_LABELS ); std::shared_ptr<ERC_ITEM> ercItem = ERC_ITEM::Create( ERCE_SIMILAR_LABELS );
ercItem->SetItems( label, labelMap.at( normalized ) ); ercItem->SetItems( label, labelMap.at( normalized ) );

View File

@ -72,9 +72,9 @@ static wxString netList( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH& aSheetPath )
*/ */
wxString netlist; wxString netlist;
netlist << EscapeString( aSymbol->GetFootprintFieldText( true ), CTX_LINE ) << wxS( "\r" ); netlist << EscapeString( aSymbol->GetFootprintFieldText( true, &aSheetPath, false ), CTX_LINE ) << wxS( "\r" );
netlist << EscapeString( aSymbol->GetRef( &aSheetPath ), CTX_LINE ) << wxS( "\r" ); netlist << EscapeString( aSymbol->GetRef( &aSheetPath ), CTX_LINE ) << wxS( "\r" );
netlist << EscapeString( aSymbol->GetValueFieldText( true ), CTX_LINE ); netlist << EscapeString( aSymbol->GetValueFieldText( true, &aSheetPath, false ), CTX_LINE );
for( SCH_PIN* pin : aSymbol->GetPins( &aSheetPath ) ) for( SCH_PIN* pin : aSymbol->GetPins( &aSheetPath ) )
{ {

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2017 Chris Pavlina <pavlina.chris@gmail.com> * Copyright (C) 2017 Chris Pavlina <pavlina.chris@gmail.com>
* Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 2017-2023 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software: you can redistribute it and/or modify it * This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the * under the terms of the GNU General Public License as published by the
@ -166,7 +166,7 @@ protected:
switch( aField.GetId() ) switch( aField.GetId() )
{ {
case DATASHEET_FIELD: case DATASHEET_FIELD:
text = m_symbol->GetDatasheetField().GetShownText( 0, false ); text = m_symbol->GetDatasheetField().GetShownText( false );
if( text.IsEmpty() || text == wxT( "~" ) ) if( text.IsEmpty() || text == wxT( "~" ) )
{ {
@ -197,7 +197,7 @@ protected:
break; break;
default: default:
text = aField.GetShownText( 0, false ); text = aField.GetShownText( false );
fieldhtml.Replace( wxS( "__VALUE__" ), EscapeHTML( text ) ); fieldhtml.Replace( wxS( "__VALUE__" ), EscapeHTML( text ) );
} }

View File

@ -390,7 +390,7 @@ void LIB_FIELD::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffs
attrs.m_Angle = orient; attrs.m_Angle = orient;
attrs.m_Multiline = false; attrs.m_Multiline = false;
aPlotter->PlotText( textpos, color, GetShownText(), attrs, font ); aPlotter->PlotText( textpos, color, GetShownText( true ), attrs, font );
} }
@ -411,9 +411,9 @@ wxString LIB_FIELD::GetFullText( int unit ) const
} }
wxString LIB_FIELD::GetShownText( int aDepth, bool aAllowExtraText ) const wxString LIB_FIELD::GetShownText( bool aAllowExtraText, int aDepth ) const
{ {
wxString text = EDA_TEXT::GetShownText( aDepth ); wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
if( IsNameShown() ) if( IsNameShown() )
text = GetName() << wxT( ": " ) << text; text = GetName() << wxT( ": " ) << text;
@ -516,7 +516,9 @@ void LIB_FIELD::SetName( const wxString& aName )
wxString LIB_FIELD::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const wxString LIB_FIELD::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
{ {
return wxString::Format( "%s '%s'", GetName(), KIUI::EllipsizeMenuText( GetShownText() ) ); return wxString::Format( "%s '%s'",
UnescapeString( GetName() ),
KIUI::EllipsizeMenuText( GetText() ) );
} }
@ -538,10 +540,11 @@ void LIB_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
LIB_ITEM::GetMsgPanelInfo( aFrame, aList ); LIB_ITEM::GetMsgPanelInfo( aFrame, aList );
aList.emplace_back( _( "Field" ), GetName() ); // Don't use GetShownText(); we want to see the variable references here
aList.emplace_back( _( "Field" ), UnescapeString( GetName() ) );
// Don't use GetShownText() here; we want to show the user the variable references // Don't use GetShownText() here; we want to show the user the variable references
aList.emplace_back( _( "Text" ), UnescapeString( GetText() ) ); aList.emplace_back( _( "Text" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
aList.emplace_back( _( "Visible" ), IsVisible() ? _( "Yes" ) : _( "No" ) ); aList.emplace_back( _( "Visible" ), IsVisible() ? _( "Yes" ) : _( "No" ) );

View File

@ -147,7 +147,7 @@ public:
*/ */
wxString GetFullText( int unit = 1 ) const; wxString GetFullText( int unit = 1 ) const;
wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override; wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override;
SCH_LAYER_ID GetDefaultLayer() const; SCH_LAYER_ID GetDefaultLayer() const;

View File

@ -78,7 +78,7 @@ void LIB_SYMBOL::GetChooserFields( std::map<wxString , wxString>& aColumnMap )
LIB_FIELD* field = static_cast<LIB_FIELD*>( &item ); LIB_FIELD* field = static_cast<LIB_FIELD*>( &item );
if( field->ShowInChooser() ) if( field->ShowInChooser() )
aColumnMap[field->GetName()] = field->EDA_TEXT::GetShownText(); aColumnMap[field->GetName()] = field->EDA_TEXT::GetShownText( false );
} }
} }
@ -784,7 +784,7 @@ void LIB_SYMBOL::PlotLibFields( PLOTTER* aPlotter, int aUnit, int aConvert, bool
// The reference is a special case: we should change the basic text // The reference is a special case: we should change the basic text
// to add '?' and the part id // to add '?' and the part id
wxString tmp = field.GetShownText(); wxString tmp = field.GetShownText( true );
if( field.GetId() == REFERENCE_FIELD ) if( field.GetId() == REFERENCE_FIELD )
{ {

View File

@ -406,8 +406,9 @@ void LIB_TEXT::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
// Calculate pos according to mirror/rotation. // Calculate pos according to mirror/rotation.
txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset; txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset;
GRPrintText( DC, txtpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_H_ALIGN_CENTER, GRPrintText( DC, txtpos, color, GetShownText( true ), orient, GetTextSize(),
GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold(), font ); GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold(),
font );
} }
@ -418,7 +419,7 @@ void LIB_TEXT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_IT
LIB_ITEM::GetMsgPanelInfo( aFrame, aList ); LIB_ITEM::GetMsgPanelInfo( aFrame, aList );
// Don't use GetShownText() here; we want to show the user the variable references // Don't use GetShownText() here; we want to show the user the variable references
aList.emplace_back( _( "Text" ), UnescapeString( GetText() ) ); aList.emplace_back( _( "Text" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) ); aList.emplace_back( _( "Font" ), GetFont() ? GetFont()->GetName() : _( "Default" ) );
@ -473,7 +474,7 @@ const BOX2I LIB_TEXT::GetBoundingBox() const
wxString LIB_TEXT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const wxString LIB_TEXT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
{ {
return wxString::Format( _( "Graphic Text '%s'" ), KIUI::EllipsizeMenuText( GetShownText() ) ); return wxString::Format( _( "Graphic Text '%s'" ), KIUI::EllipsizeMenuText( GetText() ) );
} }

View File

@ -320,15 +320,15 @@ void LIB_TEXTBOX::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffs
text.SetStart( VECTOR2I( pt1.x, -pt1.y ) ); text.SetStart( VECTOR2I( pt1.x, -pt1.y ) );
text.SetEnd( VECTOR2I( pt2.x, -pt2.y ) ); text.SetEnd( VECTOR2I( pt2.x, -pt2.y ) );
GRPrintText( DC, text.GetDrawPos(), color, text.GetShownText(), text.GetTextAngle(), GRPrintText( DC, text.GetDrawPos(), color, text.GetShownText( true ), text.GetTextAngle(),
text.GetTextSize(), text.GetHorizJustify(), text.GetVertJustify(), penWidth, text.GetTextSize(), text.GetHorizJustify(), text.GetVertJustify(), penWidth,
text.IsItalic(), text.IsBold(), font ); text.IsItalic(), text.IsBold(), font );
} }
wxString LIB_TEXTBOX::GetShownText( int aDepth, bool aAllowExtraText ) const wxString LIB_TEXTBOX::GetShownText( bool aAllowExtraText, int aDepth ) const
{ {
wxString text = EDA_TEXT::GetShownText(); wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
KIFONT::FONT* font = GetFont(); KIFONT::FONT* font = GetFont();
VECTOR2D size = GetEnd() - GetStart(); VECTOR2D size = GetEnd() - GetStart();
@ -460,7 +460,7 @@ void LIB_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOf
std::vector<VECTOR2I> positions; std::vector<VECTOR2I> positions;
wxArrayString strings_list; wxArrayString strings_list;
wxStringSplit( GetShownText(), strings_list, '\n' ); wxStringSplit( GetShownText( true ), strings_list, '\n' );
positions.reserve( strings_list.Count() ); positions.reserve( strings_list.Count() );
text.GetLinePositions( positions, (int) strings_list.Count() ); text.GetLinePositions( positions, (int) strings_list.Count() );

View File

@ -55,7 +55,7 @@ public:
VECTOR2I GetDrawPos() const override; VECTOR2I GetDrawPos() const override;
wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override; wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override;
void MirrorHorizontally( const VECTOR2I& center ); void MirrorHorizontally( const VECTOR2I& center );
void MirrorVertically( const VECTOR2I& center ); void MirrorVertically( const VECTOR2I& center );

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 1992-2018 jp.charras at wanadoo.fr * Copyright (C) 1992-2018 jp.charras at wanadoo.fr
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -79,7 +79,7 @@ bool NETLIST_EXPORTER_CADSTAR::WriteNetlist( const wxString& aOutFileName,
if( !symbol->GetIncludeOnBoard() ) if( !symbol->GetIncludeOnBoard() )
continue; continue;
footprint = symbol->GetFootprintFieldText( true ); footprint = symbol->GetFootprintFieldText( true, &sheetList[ i ], false );
if( footprint.IsEmpty() ) if( footprint.IsEmpty() )
footprint = "$noname"; footprint = "$noname";
@ -88,7 +88,7 @@ bool NETLIST_EXPORTER_CADSTAR::WriteNetlist( const wxString& aOutFileName,
ret |= fprintf( f, "%s ", TO_UTF8( StartCmpDesc ) ); ret |= fprintf( f, "%s ", TO_UTF8( StartCmpDesc ) );
ret |= fprintf( f, "%s", TO_UTF8( msg ) ); ret |= fprintf( f, "%s", TO_UTF8( msg ) );
msg = symbol->GetValueFieldText( true ); msg = symbol->GetValueFieldText( true, &sheetList[ i ], false );
msg.Replace( wxT( " " ), wxT( "_" ) ); msg.Replace( wxT( " " ), wxT( "_" ) );
ret |= fprintf( f, " \"%s\"", TO_UTF8( msg ) ); ret |= fprintf( f, " \"%s\"", TO_UTF8( msg ) );
ret |= fprintf( f, " \"%s\"", TO_UTF8( footprint ) ); ret |= fprintf( f, " \"%s\"", TO_UTF8( footprint ) );

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 1992-2018 jp.charras at wanadoo.fr * Copyright (C) 1992-2018 jp.charras at wanadoo.fr
* Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com> * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2022 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -88,7 +88,7 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName,
sheet ) ); sheet ) );
} }
footprint = symbol->GetFootprintFieldText( true ); footprint = symbol->GetFootprintFieldText( true, &sheet, false );
footprint.Replace( wxT( " " ), wxT( "_" ) ); footprint.Replace( wxT( " " ), wxT( "_" ) );
if( footprint.IsEmpty() ) if( footprint.IsEmpty() )
@ -102,7 +102,7 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName,
ret |= fprintf( f, " %s", TO_UTF8( field ) ); ret |= fprintf( f, " %s", TO_UTF8( field ) );
field = symbol->GetValueFieldText( true ); field = symbol->GetValueFieldText( true, &sheet, false );
field.Replace( wxT( " " ), wxT( "_" ) ); field.Replace( wxT( " " ), wxT( "_" ) );
ret |= fprintf( f, " %s", TO_UTF8( field ) ); ret |= fprintf( f, " %s", TO_UTF8( field ) );

View File

@ -224,7 +224,7 @@ bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions
if( field.GetId() == REFERENCE_FIELD ) if( field.GetId() == REFERENCE_FIELD )
spiceItem.fields.back().SetText( symbol->GetRef( &sheet ) ); spiceItem.fields.back().SetText( symbol->GetRef( &sheet ) );
else else
spiceItem.fields.back().SetText( field.GetShownText( &sheet, 0, false ) ); spiceItem.fields.back().SetText( field.GetShownText( &sheet, false ) );
} }
readRefName( sheet, *symbol, spiceItem, refNames ); readRefName( sheet, *symbol, spiceItem, refNames );
@ -333,9 +333,9 @@ void NETLIST_EXPORTER_SPICE::ReadDirectives( unsigned aNetlistOptions )
for( SCH_ITEM* item : sheet.LastScreen()->Items() ) for( SCH_ITEM* item : sheet.LastScreen()->Items() )
{ {
if( item->Type() == SCH_TEXT_T ) if( item->Type() == SCH_TEXT_T )
text = static_cast<SCH_TEXT*>( item )->GetShownText(); text = static_cast<SCH_TEXT*>( item )->GetShownText( &sheet, false );
else if( item->Type() == SCH_TEXTBOX_T ) else if( item->Type() == SCH_TEXTBOX_T )
text = static_cast<SCH_TEXTBOX*>( item )->GetShownText(); text = static_cast<SCH_TEXTBOX*>( item )->GetShownText( &sheet, false );
else else
continue; continue;

View File

@ -127,18 +127,18 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol,
int unit = symbol2->GetUnitSelection( aSheet ); int unit = symbol2->GetUnitSelection( aSheet );
// The lowest unit number wins. User should only set fields in any one unit. // The lowest unit number wins. User should only set fields in any one unit.
candidate = symbol2->GetValueFieldText( m_resolveTextVars ); candidate = symbol2->GetValueFieldText( m_resolveTextVars, &sheetList[i], false );
if( !candidate.IsEmpty() && ( unit < minUnit || value.IsEmpty() ) ) if( !candidate.IsEmpty() && ( unit < minUnit || value.IsEmpty() ) )
value = candidate; value = candidate;
candidate = symbol2->GetFootprintFieldText( m_resolveTextVars ); candidate = symbol2->GetFootprintFieldText( m_resolveTextVars, &sheetList[i], false );
if( !candidate.IsEmpty() && ( unit < minUnit || footprint.IsEmpty() ) ) if( !candidate.IsEmpty() && ( unit < minUnit || footprint.IsEmpty() ) )
footprint = candidate; footprint = candidate;
candidate = m_resolveTextVars candidate = m_resolveTextVars
? symbol2->GetField( DATASHEET_FIELD )->GetShownText( aSheet, 0, false ) ? symbol2->GetField( DATASHEET_FIELD )->GetShownText( &sheetList[i], false )
: symbol2->GetField( DATASHEET_FIELD )->GetText(); : symbol2->GetField( DATASHEET_FIELD )->GetText();
if( !candidate.IsEmpty() && ( unit < minUnit || datasheet.IsEmpty() ) ) if( !candidate.IsEmpty() && ( unit < minUnit || datasheet.IsEmpty() ) )
@ -152,7 +152,7 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol,
&& ( unit < minUnit || userFields.count( f.GetName() ) == 0 ) ) && ( unit < minUnit || userFields.count( f.GetName() ) == 0 ) )
{ {
if( m_resolveTextVars ) if( m_resolveTextVars )
userFields[ f.GetName() ] = f.GetShownText( aSheet, 0, false ); userFields[ f.GetName() ] = f.GetShownText( aSheet, false );
else else
userFields[ f.GetName() ] = f.GetText(); userFields[ f.GetName() ] = f.GetText();
} }
@ -164,11 +164,11 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol,
} }
else else
{ {
value = aSymbol->GetValueFieldText( m_resolveTextVars ); value = aSymbol->GetValueFieldText( m_resolveTextVars, aSheet, false );
footprint = aSymbol->GetFootprintFieldText( m_resolveTextVars ); footprint = aSymbol->GetFootprintFieldText( m_resolveTextVars, aSheet, false );
if( m_resolveTextVars ) if( m_resolveTextVars )
datasheet = aSymbol->GetField( DATASHEET_FIELD )->GetShownText( aSheet, 0, false ); datasheet = aSymbol->GetField( DATASHEET_FIELD )->GetShownText( aSheet, false );
else else
datasheet = aSymbol->GetField( DATASHEET_FIELD )->GetText(); datasheet = aSymbol->GetField( DATASHEET_FIELD )->GetText();
@ -179,7 +179,7 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol,
if( f.GetText().size() ) if( f.GetText().size() )
{ {
if( m_resolveTextVars ) if( m_resolveTextVars )
userFields[ f.GetName() ] = f.GetShownText( aSheet, 0, false ); userFields[ f.GetName() ] = f.GetShownText( aSheet, false );
else else
userFields[ f.GetName() ] = f.GetText(); userFields[ f.GetName() ] = f.GetText();
} }
@ -321,7 +321,7 @@ XNODE* NETLIST_EXPORTER_XML::makeSymbols( unsigned aCtl )
xproperty->AddAttribute( wxT( "name" ), fields[jj].GetCanonicalName() ); xproperty->AddAttribute( wxT( "name" ), fields[jj].GetCanonicalName() );
if( m_resolveTextVars ) if( m_resolveTextVars )
xproperty->AddAttribute( wxT( "value" ), fields[jj].GetShownText( &sheet, 0, false ) ); xproperty->AddAttribute( wxT( "value" ), fields[jj].GetShownText( &sheet, false ) );
else else
xproperty->AddAttribute( wxT( "value" ), fields[jj].GetText() ); xproperty->AddAttribute( wxT( "value" ), fields[jj].GetText() );
} }
@ -334,7 +334,7 @@ XNODE* NETLIST_EXPORTER_XML::makeSymbols( unsigned aCtl )
if( m_resolveTextVars ) if( m_resolveTextVars )
// do not allow GetShownText() to add any prefix useful only when displaying // do not allow GetShownText() to add any prefix useful only when displaying
// the field on screen // the field on screen
xproperty->AddAttribute( wxT( "value" ), sheetField.GetShownText( &sheet, 0, false ) ); xproperty->AddAttribute( wxT( "value" ), sheetField.GetShownText( &sheet, false ) );
else else
xproperty->AddAttribute( wxT( "value" ), sheetField.GetText() ); xproperty->AddAttribute( wxT( "value" ), sheetField.GetText() );
} }

View File

@ -1016,22 +1016,25 @@ void SCH_EDIT_FRAME::ShowFindReplaceDialog( bool aReplace )
switch( front->Type() ) switch( front->Type() )
{ {
case SCH_SYMBOL_T: case SCH_SYMBOL_T:
findString = static_cast<SCH_SYMBOL*>( front )->GetValueFieldText( true ); {
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( front );
findString = UnescapeString( symbol->GetField( VALUE_FIELD )->GetText() );
break; break;
}
case SCH_FIELD_T: case SCH_FIELD_T:
findString = static_cast<SCH_FIELD*>( front )->GetShownText(); findString = UnescapeString( static_cast<SCH_FIELD*>( front )->GetText() );
break; break;
case SCH_LABEL_T: case SCH_LABEL_T:
case SCH_GLOBAL_LABEL_T: case SCH_GLOBAL_LABEL_T:
case SCH_HIER_LABEL_T: case SCH_HIER_LABEL_T:
case SCH_SHEET_PIN_T: case SCH_SHEET_PIN_T:
findString = static_cast<SCH_LABEL_BASE*>( front )->GetShownText(); findString = UnescapeString( static_cast<SCH_LABEL_BASE*>( front )->GetText() );
break; break;
case SCH_TEXT_T: case SCH_TEXT_T:
findString = static_cast<SCH_TEXT*>( front )->GetShownText(); findString = UnescapeString( static_cast<SCH_TEXT*>( front )->GetText() );
if( findString.Contains( wxT( "\n" ) ) ) if( findString.Contains( wxT( "\n" ) ) )
findString = findString.Before( '\n' ); findString = findString.Before( '\n' );
@ -1046,9 +1049,10 @@ void SCH_EDIT_FRAME::ShowFindReplaceDialog( bool aReplace )
if( m_findReplaceDialog ) if( m_findReplaceDialog )
m_findReplaceDialog->Destroy(); m_findReplaceDialog->Destroy();
m_findReplaceDialog = new DIALOG_SCH_FIND( m_findReplaceDialog = new DIALOG_SCH_FIND( this,
this, static_cast<SCH_SEARCH_DATA*>( m_findReplaceData.get() ), wxDefaultPosition, static_cast<SCH_SEARCH_DATA*>( m_findReplaceData.get() ),
wxDefaultSize, aReplace ? wxFR_REPLACEDIALOG : 0 ); wxDefaultPosition, wxDefaultSize,
aReplace ? wxFR_REPLACEDIALOG : 0 );
m_findReplaceDialog->SetFindEntries( m_findStringHistoryList, findString ); m_findReplaceDialog->SetFindEntries( m_findStringHistoryList, findString );
m_findReplaceDialog->SetReplaceEntries( m_replaceStringHistoryList ); m_findReplaceDialog->SetReplaceEntries( m_replaceStringHistoryList );

View File

@ -172,13 +172,14 @@ void SCH_FIELD::SetId( int aId )
} }
wxString SCH_FIELD::GetShownText( const SCH_SHEET_PATH* aPath, int aDepth, wxString SCH_FIELD::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
bool aAllowExtraText ) const int aDepth ) const
{ {
std::function<bool( wxString* )> symbolResolver = std::function<bool( wxString* )> symbolResolver =
[&]( wxString* token ) -> bool [&]( wxString* token ) -> bool
{ {
return static_cast<SCH_SYMBOL*>( m_parent )->ResolveTextVar( token, aDepth + 1, aPath ); return static_cast<SCH_SYMBOL*>( m_parent )->ResolveTextVar( token, aDepth + 1,
aPath );
}; };
std::function<bool( wxString* )> sheetResolver = std::function<bool( wxString* )> sheetResolver =
@ -194,7 +195,7 @@ wxString SCH_FIELD::GetShownText( const SCH_SHEET_PATH* aPath, int aDepth,
aDepth + 1 ); aDepth + 1 );
}; };
wxString text = EDA_TEXT::GetShownText(); wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
if( IsNameShown() && aAllowExtraText ) if( IsNameShown() && aAllowExtraText )
text = GetName() << wxS( ": " ) << text; text = GetName() << wxS( ": " ) << text;
@ -322,7 +323,7 @@ void SCH_FIELD::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
VECTOR2I textpos; VECTOR2I textpos;
int penWidth = GetEffectiveTextPenWidth( aSettings->GetDefaultPenWidth() ); int penWidth = GetEffectiveTextPenWidth( aSettings->GetDefaultPenWidth() );
if( ( !IsVisible() && !IsForceVisible() ) || GetShownText().IsEmpty() ) if( ( !IsVisible() && !IsForceVisible() ) || GetShownText( true ).IsEmpty() )
return; return;
COLOR4D bg = aSettings->GetBackgroundColor(); COLOR4D bg = aSettings->GetBackgroundColor();
@ -375,8 +376,9 @@ void SCH_FIELD::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
*/ */
textpos = GetBoundingBox().Centre() + aOffset; textpos = GetBoundingBox().Centre() + aOffset;
GRPrintText( DC, textpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_H_ALIGN_CENTER, GRPrintText( DC, textpos, color, GetShownText( true ), orient, GetTextSize(),
GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold(), font ); GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold(),
font );
} }
@ -580,7 +582,7 @@ bool SCH_FIELD::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) co
{ {
} }
wxString text = GetShownText(); wxString text = UnescapeString( GetText() );
if( !IsVisible() && !searchHiddenFields ) if( !IsVisible() && !searchHiddenFields )
return false; return false;
@ -653,7 +655,6 @@ bool SCH_FIELD::Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData )
} }
wxString text; wxString text;
bool resolve = false; // Replace in source text, not shown text
bool isReplaced = false; bool isReplaced = false;
if( m_parent && m_parent->Type() == SCH_SYMBOL_T ) if( m_parent && m_parent->Type() == SCH_SYMBOL_T )
@ -679,7 +680,7 @@ bool SCH_FIELD::Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData )
case VALUE_FIELD: case VALUE_FIELD:
wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in value field." ) ); wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in value field." ) );
text = parentSymbol->GetValueFieldText( resolve ); text = parentSymbol->GetField( VALUE_FIELD )->GetText();
isReplaced = EDA_ITEM::Replace( aSearchData, text ); isReplaced = EDA_ITEM::Replace( aSearchData, text );
if( isReplaced ) if( isReplaced )
@ -690,7 +691,7 @@ bool SCH_FIELD::Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData )
case FOOTPRINT_FIELD: case FOOTPRINT_FIELD:
wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in footprint field." ) ); wxCHECK_MSG( aAuxData, false, wxT( "Need sheetpath to replace in footprint field." ) );
text = parentSymbol->GetFootprintFieldText( resolve ); text = parentSymbol->GetField( FOOTPRINT_FIELD )->GetText();
isReplaced = EDA_ITEM::Replace( aSearchData, text ); isReplaced = EDA_ITEM::Replace( aSearchData, text );
if( isReplaced ) if( isReplaced )
@ -732,7 +733,7 @@ void SCH_FIELD::Rotate( const VECTOR2I& aCenter )
wxString SCH_FIELD::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const wxString SCH_FIELD::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
{ {
return wxString::Format( "%s '%s'", GetName(), KIUI::EllipsizeMenuText( GetShownText() ) ); return wxString::Format( "%s '%s'", GetName(), KIUI::EllipsizeMenuText( GetText() ) );
} }
@ -740,10 +741,10 @@ void SCH_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
{ {
wxString msg; wxString msg;
aList.emplace_back( _( "Symbol Field" ), GetName() ); aList.emplace_back( _( "Symbol Field" ), UnescapeString( GetName() ) );
// Don't use GetShownText() here; we want to show the user the variable references // Don't use GetShownText() here; we want to show the user the variable references
aList.emplace_back( _( "Text" ), UnescapeString( GetText() ) ); aList.emplace_back( _( "Text" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
aList.emplace_back( _( "Visible" ), IsVisible() ? _( "Yes" ) : _( "No" ) ); aList.emplace_back( _( "Visible" ), IsVisible() ? _( "Yes" ) : _( "No" ) );
@ -911,7 +912,7 @@ BITMAPS SCH_FIELD::GetMenuImage() const
bool SCH_FIELD::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const bool SCH_FIELD::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
{ {
// Do not hit test hidden or empty fields. // Do not hit test hidden or empty fields.
if( !IsVisible() || GetShownText().IsEmpty() ) if( !IsVisible() || GetShownText( true ).IsEmpty() )
return false; return false;
BOX2I rect = GetBoundingBox(); BOX2I rect = GetBoundingBox();
@ -931,7 +932,7 @@ bool SCH_FIELD::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const
bool SCH_FIELD::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const bool SCH_FIELD::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const
{ {
// Do not hit test hidden fields. // Do not hit test hidden fields.
if( !IsVisible() || GetShownText().IsEmpty() ) if( !IsVisible() || GetShownText( true ).IsEmpty() )
return false; return false;
BOX2I rect = aRect; BOX2I rect = aRect;
@ -953,7 +954,7 @@ bool SCH_FIELD::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) co
void SCH_FIELD::Plot( PLOTTER* aPlotter, bool aBackground ) const void SCH_FIELD::Plot( PLOTTER* aPlotter, bool aBackground ) const
{ {
if( GetShownText().IsEmpty() || aBackground ) if( GetShownText( true ).IsEmpty() || aBackground )
return; return;
RENDER_SETTINGS* settings = aPlotter->RenderSettings(); RENDER_SETTINGS* settings = aPlotter->RenderSettings();
@ -1033,7 +1034,7 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter, bool aBackground ) const
attrs.m_Angle = orient; attrs.m_Angle = orient;
attrs.m_Multiline = false; attrs.m_Multiline = false;
aPlotter->PlotText( textpos, color, GetShownText(), attrs, font ); aPlotter->PlotText( textpos, color, GetShownText( true ), attrs, font );
if( IsHypertext() ) if( IsHypertext() )
{ {

View File

@ -126,12 +126,12 @@ public:
void SetId( int aId ); void SetId( int aId );
wxString GetShownText( const SCH_SHEET_PATH* aPath, int aDepth = 0, wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
bool aAllowExtraText = true ) const; int aDepth = 0 ) const;
wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override
{ {
return GetShownText( nullptr, aDepth, aAllowExtraText ); return GetShownText( nullptr, aAllowExtraText, aDepth );
} }
COLOR4D GetFieldColor() const; COLOR4D GetFieldColor() const;

View File

@ -548,7 +548,7 @@ bool SCH_LABEL_BASE::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* toke
{ {
if( token->IsSameAs( field.GetName() ) ) if( token->IsSameAs( field.GetName() ) )
{ {
*token = field.GetShownText( aDepth + 1 ); *token = field.GetShownText( false, aDepth + 1 );
return true; return true;
} }
} }
@ -577,7 +577,8 @@ bool SCH_LABEL_BASE::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* toke
} }
wxString SCH_LABEL_BASE::GetShownText( const SCH_SHEET_PATH* aPath, int aDepth, bool aAllowExtraText ) const wxString SCH_LABEL_BASE::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
int aDepth ) const
{ {
std::function<bool( wxString* )> textResolver = std::function<bool( wxString* )> textResolver =
[&]( wxString* token ) -> bool [&]( wxString* token ) -> bool
@ -585,7 +586,7 @@ wxString SCH_LABEL_BASE::GetShownText( const SCH_SHEET_PATH* aPath, int aDepth,
return ResolveTextVar( aPath, token, aDepth ); return ResolveTextVar( aPath, token, aDepth );
}; };
wxString text = EDA_TEXT::GetShownText(); wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
if( text == wxS( "~" ) ) // Legacy placeholder for empty string if( text == wxS( "~" ) ) // Legacy placeholder for empty string
{ {
@ -959,7 +960,7 @@ void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground ) const
} }
else else
{ {
aPlotter->PlotText( textpos, color, GetShownText(), attrs, font ); aPlotter->PlotText( textpos, color, GetShownText( true ), attrs, font );
if( s_poly.size() ) if( s_poly.size() )
aPlotter->PlotPoly( s_poly, FILL_T::NO_FILL, penWidth ); aPlotter->PlotPoly( s_poly, FILL_T::NO_FILL, penWidth );
@ -969,8 +970,8 @@ void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground ) const
if( connection ) if( connection )
{ {
properties.emplace_back( properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), _( "Net" ),
wxString::Format( wxT( "!%s = %s" ), _( "Net" ), connection->Name() ) ); connection->Name() ) );
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), _( "Resolved netclass" ), properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), _( "Resolved netclass" ),
GetEffectiveNetClass()->GetName() ) ); GetEffectiveNetClass()->GetName() ) );
@ -978,8 +979,8 @@ void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground ) const
for( const SCH_FIELD& field : GetFields() ) for( const SCH_FIELD& field : GetFields() )
{ {
properties.emplace_back( properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), field.GetName(),
wxString::Format( wxT( "!%s = %s" ), field.GetName(), field.GetShownText() ) ); field.GetShownText( false ) ) );
} }
if( !properties.empty() ) if( !properties.empty() )
@ -987,7 +988,8 @@ void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground ) const
if( Type() == SCH_HIER_LABEL_T ) if( Type() == SCH_HIER_LABEL_T )
{ {
aPlotter->Bookmark( GetBodyBoundingBox(), GetShownText(), _( "Hierarchical Labels" ) ); aPlotter->Bookmark( GetBodyBoundingBox(), GetShownText( false ),
_( "Hierarchical Labels" ) );
} }
} }
@ -1072,7 +1074,7 @@ const BOX2I SCH_LABEL::GetBodyBoundingBox() const
wxString SCH_LABEL::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const wxString SCH_LABEL::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
{ {
return wxString::Format( _( "Label '%s'" ), KIUI::EllipsizeMenuText( GetShownText() ) ); return wxString::Format( _( "Label '%s'" ), KIUI::EllipsizeMenuText( GetText() ) );
} }
@ -1250,8 +1252,8 @@ wxString SCH_DIRECTIVE_LABEL::GetItemDescription( UNITS_PROVIDER* aUnitsProvider
else else
{ {
return wxString::Format( _( "Directive Label [%s %s]" ), return wxString::Format( _( "Directive Label [%s %s]" ),
m_fields[0].GetName(), UnescapeString( m_fields[0].GetName() ),
m_fields[0].GetShownText() ); KIUI::EllipsizeMenuText( m_fields[0].GetText() ) );
} }
} }
@ -1526,7 +1528,7 @@ void SCH_GLOBALLABEL::CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings
wxString SCH_GLOBALLABEL::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const wxString SCH_GLOBALLABEL::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
{ {
return wxString::Format( _( "Global Label '%s'" ), KIUI::EllipsizeMenuText( GetShownText() ) ); return wxString::Format( _( "Global Label '%s'" ), KIUI::EllipsizeMenuText( GetText() ) );
} }
@ -1660,7 +1662,7 @@ VECTOR2I SCH_HIERLABEL::GetSchematicTextOffset( const RENDER_SETTINGS* aSettings
wxString SCH_HIERLABEL::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const wxString SCH_HIERLABEL::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
{ {
return wxString::Format( _( "Hierarchical Label '%s'" ), return wxString::Format( _( "Hierarchical Label '%s'" ),
KIUI::EllipsizeMenuText( GetShownText() ) ); KIUI::EllipsizeMenuText( GetText() ) );
} }

View File

@ -133,12 +133,12 @@ public:
*/ */
virtual bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth ) const; virtual bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth ) const;
wxString GetShownText( const SCH_SHEET_PATH* aPath, int aDepth = 0, wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
bool aAllowExtraText = true ) const override; int aDepth = 0 ) const override;
wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override
{ {
return GetShownText( nullptr, aDepth, aAllowExtraText ); return GetShownText( nullptr, aAllowExtraText, aDepth );
} }
void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override; void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction ) override;

View File

@ -990,7 +990,7 @@ void SCH_PAINTER::draw( const LIB_FIELD *aField, int aLayer, bool aDimmed )
if( drawingShadows ) if( drawingShadows )
attrs.m_StrokeWidth += getShadowWidth( !aField->IsSelected() ); attrs.m_StrokeWidth += getShadowWidth( !aField->IsSelected() );
strokeText( UnescapeString( aField->GetShownText() ), textpos, attrs ); strokeText( UnescapeString( aField->GetShownText( true ) ), textpos, attrs );
} }
// Draw the umbilical line when in the schematic editor // Draw the umbilical line when in the schematic editor
@ -1041,7 +1041,7 @@ void SCH_PAINTER::draw( const LIB_TEXT* aText, int aLayer, bool aDimmed )
} }
else else
{ {
wxString shownText( aText->GetShownText() ); wxString shownText( aText->GetShownText( true ) );
VECTOR2D pos = bBox.Centre(); VECTOR2D pos = bBox.Centre();
TEXT_ATTRIBUTES attrs = aText->GetAttributes(); TEXT_ATTRIBUTES attrs = aText->GetAttributes();
@ -1098,7 +1098,7 @@ void SCH_PAINTER::draw( const LIB_TEXTBOX* aTextBox, int aLayer, bool aDimmed )
auto drawText = auto drawText =
[&]() [&]()
{ {
wxString shownText = aTextBox->GetShownText(); wxString shownText = aTextBox->GetShownText( true );
TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes(); TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes();
attrs.m_Angle = aTextBox->GetDrawRotation(); attrs.m_Angle = aTextBox->GetDrawRotation();
@ -1962,7 +1962,7 @@ void SCH_PAINTER::draw( const SCH_TEXT *aText, int aLayer )
m_gal->SetStrokeColor( color ); m_gal->SetStrokeColor( color );
m_gal->SetFillColor( color ); m_gal->SetFillColor( color );
wxString shownText( aText->GetShownText() ); wxString shownText( aText->GetShownText( true ) );
VECTOR2I text_offset = aText->GetSchematicTextOffset( &m_schSettings ); VECTOR2I text_offset = aText->GetSchematicTextOffset( &m_schSettings );
TEXT_ATTRIBUTES attrs = aText->GetAttributes(); TEXT_ATTRIBUTES attrs = aText->GetAttributes();
KIFONT::FONT* font = getFont( aText ); KIFONT::FONT* font = getFont( aText );
@ -2058,7 +2058,7 @@ void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer )
auto drawText = auto drawText =
[&]() [&]()
{ {
wxString shownText = aTextBox->GetShownText(); wxString shownText = aTextBox->GetShownText( true );
TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes(); TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes();
attrs.m_Angle = aTextBox->GetDrawRotation(); attrs.m_Angle = aTextBox->GetDrawRotation();
@ -2356,7 +2356,7 @@ void SCH_PAINTER::draw( const SCH_FIELD* aField, int aLayer, bool aDimmed )
return; return;
} }
wxString shownText = aField->GetShownText(); wxString shownText = aField->GetShownText( true );
if( shownText.IsEmpty() ) if( shownText.IsEmpty() )
return; return;

View File

@ -194,7 +194,7 @@ SCH_SYMBOL* SCH_PIN::GetParentSymbol() const
wxString SCH_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const wxString SCH_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
{ {
return wxString::Format( "Symbol %s %s", return wxString::Format( "Symbol %s %s",
GetParentSymbol()->GetField( REFERENCE_FIELD )->GetShownText(), UnescapeString( GetParentSymbol()->GetField( REFERENCE_FIELD )->GetText() ),
m_libPin->GetItemDescription( aUnitsProvider ) ); m_libPin->GetItemDescription( aUnitsProvider ) );
} }
@ -230,7 +230,9 @@ void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITE
SCH_SHEET_PATH* currentSheet = schframe ? &schframe->GetCurrentSheet() : nullptr; SCH_SHEET_PATH* currentSheet = schframe ? &schframe->GetCurrentSheet() : nullptr;
SCH_SYMBOL* symbol = GetParentSymbol(); SCH_SYMBOL* symbol = GetParentSymbol();
aList.emplace_back( symbol->GetRef( currentSheet ), symbol->GetValueFieldText( true ) ); // Don't use GetShownText(); we want to see the variable references here
aList.emplace_back( symbol->GetRef( currentSheet ),
UnescapeString( symbol->GetField( VALUE_FIELD )->GetText() ) );
#if defined(DEBUG) #if defined(DEBUG)
if( !IsConnectivityDirty() && dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) ) if( !IsConnectivityDirty() && dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) )

View File

@ -194,7 +194,7 @@ void SCH_PLOTTER::createPDFFile( const SCH_PLOT_SETTINGS& aPlotSettings,
plotter->ClosePage(); plotter->ClosePage();
setupPlotPagePDF( plotter, screen, aPlotSettings ); setupPlotPagePDF( plotter, screen, aPlotSettings );
plotter->StartPage( sheetList[i].GetPageNumber(), plotter->StartPage( sheetList[i].GetPageNumber(),
sheetList[i].Last()->GetFields()[SHEETNAME].GetShownText() ); sheetList[i].Last()->GetFields()[SHEETNAME].GetShownText( false ) );
} }
plotOneSheetPDF( plotter, screen, aPlotSettings ); plotOneSheetPDF( plotter, screen, aPlotSettings );

View File

@ -748,11 +748,11 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, const SCHEMATIC& aSchema
} }
else if( id == VALUE_FIELD ) else if( id == VALUE_FIELD )
{ {
field.SetText( aSymbol->GetValueFieldText( false ) ); field.SetText( aSymbol->GetField( VALUE_FIELD )->GetText() );
} }
else if( id == FOOTPRINT_FIELD ) else if( id == FOOTPRINT_FIELD )
{ {
field.SetText( aSymbol->GetFootprintFieldText( false ) ); field.SetText( aSymbol->GetField( FOOTPRINT_FIELD )->GetText() );
} }
} }

View File

@ -820,7 +820,7 @@ SCH_REFERENCE::SCH_REFERENCE( SCH_SYMBOL* aSymbol, LIB_SYMBOL* aLibSymbol,
m_libPart = aLibSymbol; // Warning: can be nullptr for orphan symbols m_libPart = aLibSymbol; // Warning: can be nullptr for orphan symbols
// (i.e. with a symbol library not found) // (i.e. with a symbol library not found)
m_unit = aSymbol->GetUnitSelection( &aSheetPath ); m_unit = aSymbol->GetUnitSelection( &aSheetPath );
m_footprint = aSymbol->GetFootprintFieldText( true ); m_footprint = aSymbol->GetFootprintFieldText( true, &aSheetPath, false );
m_sheetPath = aSheetPath; m_sheetPath = aSheetPath;
m_isNew = false; m_isNew = false;
m_flag = 0; m_flag = 0;
@ -836,10 +836,10 @@ SCH_REFERENCE::SCH_REFERENCE( SCH_SYMBOL* aSymbol, LIB_SYMBOL* aLibSymbol,
m_numRef = -1; m_numRef = -1;
if( aSymbol->GetValueFieldText( false ).IsEmpty() ) if( aSymbol->GetValueFieldText( false, &aSheetPath, false ).IsEmpty() )
aSymbol->SetValueFieldText( wxT( "~" ) ); aSymbol->SetValueFieldText( wxT( "~" ) );
m_value = aSymbol->GetValueFieldText( false ); m_value = aSymbol->GetValueFieldText( false, &aSheetPath, false );
} }

View File

@ -249,7 +249,7 @@ bool SCH_SHEET::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, in
{ {
if( token->IsSameAs( m_fields[i].GetCanonicalName().Upper() ) ) if( token->IsSameAs( m_fields[i].GetCanonicalName().Upper() ) )
{ {
*token = m_fields[i].GetShownText( aDepth + 1 ); *token = m_fields[i].GetShownText( nullptr, false, aDepth + 1 );
return true; return true;
} }
} }
@ -258,7 +258,7 @@ bool SCH_SHEET::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, in
{ {
if( token->IsSameAs( m_fields[i].GetName() ) ) if( token->IsSameAs( m_fields[i].GetName() ) )
{ {
*token = m_fields[i].GetShownText( aDepth + 1 ); *token = m_fields[i].GetShownText( nullptr, false, aDepth + 1 );
return true; return true;
} }
} }
@ -796,7 +796,9 @@ int SCH_SHEET::CountSheets() const
void SCH_SHEET::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) void SCH_SHEET::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
{ {
aList.emplace_back( _( "Sheet Name" ), m_fields[ SHEETNAME ].GetText() ); // Don't use GetShownText(); we want to see the variable references here
aList.emplace_back( _( "Sheet Name" ),
KIUI::EllipsizeStatusText( aFrame, m_fields[ SHEETNAME ].GetText() ) );
if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) ) if( SCH_EDIT_FRAME* schframe = dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) )
{ {
@ -806,7 +808,9 @@ void SCH_SHEET::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
aList.emplace_back( _( "Hierarchical Path" ), path.PathHumanReadable( false, true ) ); aList.emplace_back( _( "Hierarchical Path" ), path.PathHumanReadable( false, true ) );
} }
aList.emplace_back( _( "File Name" ), m_fields[ SHEETFILENAME ].GetText() ); // Don't use GetShownText(); we want to see the variable references here
aList.emplace_back( _( "File Name" ),
KIUI::EllipsizeStatusText( aFrame, m_fields[ SHEETFILENAME ].GetText() ) );
} }
@ -1053,7 +1057,7 @@ void SCH_SHEET::RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction
wxString SCH_SHEET::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const wxString SCH_SHEET::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
{ {
return wxString::Format( _( "Hierarchical Sheet %s" ), return wxString::Format( _( "Hierarchical Sheet %s" ),
m_fields[ SHEETNAME ].GetText() ); KIUI::EllipsizeMenuText( m_fields[ SHEETNAME ].GetText() ) );
} }
@ -1124,7 +1128,7 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter, bool aBackground ) const
{ {
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
field.GetName(), field.GetName(),
field.GetShownText() ) ); field.GetShownText( false ) ) );
} }
aPlotter->HyperlinkMenu( GetBoundingBox(), properties ); aPlotter->HyperlinkMenu( GetBoundingBox(), properties );

View File

@ -100,6 +100,10 @@ public:
*/ */
void SetFields( const std::vector<SCH_FIELD>& aFields ); void SetFields( const std::vector<SCH_FIELD>& aFields );
wxString GetShownName( bool aAllowExtraText ) const
{
return m_fields[SHEETNAME].GetShownText( aAllowExtraText );
}
wxString GetName() const { return m_fields[ SHEETNAME ].GetText(); } wxString GetName() const { return m_fields[ SHEETNAME ].GetText(); }
void SetName( const wxString& aName ) { m_fields[ SHEETNAME ].SetText( aName ); } void SetName( const wxString& aName ) { m_fields[ SHEETNAME ].SetText( aName ); }

View File

@ -311,7 +311,7 @@ wxString SCH_SHEET_PATH::PathHumanReadable( bool aUseShortRootName,
// Start at 1 since we've already processed the root sheet. // Start at 1 since we've already processed the root sheet.
for( unsigned i = 1; i < size(); i++ ) for( unsigned i = 1; i < size(); i++ )
s << at( i )->GetFields()[SHEETNAME].GetShownText() << wxS( "/" ); s << at( i )->GetFields()[SHEETNAME].GetShownText( false ) << wxS( "/" );
if( aStripTrailingSeparator && s.EndsWith( "/" ) ) if( aStripTrailingSeparator && s.EndsWith( "/" ) )
s = s.Left( s.length() - 1 ); s = s.Left( s.length() - 1 );

View File

@ -328,7 +328,7 @@ void SCH_SHEET_PIN::GetEndPoints( std::vector<DANGLING_END_ITEM>& aItemList )
wxString SCH_SHEET_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const wxString SCH_SHEET_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
{ {
return wxString::Format( _( "Hierarchical Sheet Pin %s" ), return wxString::Format( _( "Hierarchical Sheet Pin %s" ),
KIUI::EllipsizeMenuText( GetShownText() ) ); KIUI::EllipsizeMenuText( GetText() ) );
} }

View File

@ -827,10 +827,11 @@ void SCH_SYMBOL::SetUnitSelection( int aUnitSelection )
} }
const wxString SCH_SYMBOL::GetValueFieldText( bool aResolve, const SCH_SHEET_PATH* aPath ) const const wxString SCH_SYMBOL::GetValueFieldText( bool aResolve, const SCH_SHEET_PATH* aPath,
bool aAllowExtraText ) const
{ {
if( aResolve ) if( aResolve )
return GetField( VALUE_FIELD )->GetShownText( aPath ); return GetField( VALUE_FIELD )->GetShownText( aPath, aAllowExtraText );
return GetField( VALUE_FIELD )->GetText(); return GetField( VALUE_FIELD )->GetText();
} }
@ -842,10 +843,11 @@ void SCH_SYMBOL::SetValueFieldText( const wxString& aValue )
} }
const wxString SCH_SYMBOL::GetFootprintFieldText( bool aResolve ) const const wxString SCH_SYMBOL::GetFootprintFieldText( bool aResolve, const SCH_SHEET_PATH* aPath,
bool aAllowExtraText ) const
{ {
if( aResolve ) if( aResolve )
return GetField( FOOTPRINT_FIELD )->GetShownText(); return GetField( FOOTPRINT_FIELD )->GetShownText( aPath, aAllowExtraText );
return GetField( FOOTPRINT_FIELD )->GetText(); return GetField( FOOTPRINT_FIELD )->GetText();
} }
@ -899,7 +901,7 @@ void SCH_SYMBOL::GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly
{ {
if( aVisibleOnly ) if( aVisibleOnly )
{ {
if( !field.IsVisible() || field.GetShownText().IsEmpty() ) if( !field.IsVisible() || field.GetShownText( nullptr, true ).IsEmpty() )
continue; continue;
} }
@ -1178,11 +1180,11 @@ bool SCH_SYMBOL::ResolveTextVar( wxString* token, int aDepth, const SCH_SHEET_PA
if( i == REFERENCE_FIELD ) if( i == REFERENCE_FIELD )
*token = GetRef( &schematic->CurrentSheet(), true ); *token = GetRef( &schematic->CurrentSheet(), true );
else if( i == VALUE_FIELD ) else if( i == VALUE_FIELD )
*token = GetValueFieldText( true ); *token = GetValueFieldText( true, aPath, false );
else if( i == FOOTPRINT_FIELD ) else if( i == FOOTPRINT_FIELD )
*token = GetFootprintFieldText( true ); *token = GetFootprintFieldText( true, aPath, false );
else else
*token = m_fields[ i ].GetShownText( aDepth + 1 ); *token = m_fields[ i ].GetShownText( aPath, false, aDepth + 1 );
return true; return true;
} }
@ -1193,7 +1195,7 @@ bool SCH_SYMBOL::ResolveTextVar( wxString* token, int aDepth, const SCH_SHEET_PA
if( token->IsSameAs( m_fields[ i ].GetName() ) if( token->IsSameAs( m_fields[ i ].GetName() )
|| token->IsSameAs( m_fields[ i ].GetName().Upper() ) ) || token->IsSameAs( m_fields[ i ].GetName().Upper() ) )
{ {
*token = m_fields[ i ].GetShownText( aDepth + 1 ); *token = m_fields[ i ].GetShownText( aPath, false, aDepth + 1 );
return true; return true;
} }
} }
@ -1215,7 +1217,7 @@ bool SCH_SYMBOL::ResolveTextVar( wxString* token, int aDepth, const SCH_SHEET_PA
{ {
wxString footprint; wxString footprint;
footprint = GetFootprintFieldText( true ); footprint = GetFootprintFieldText( true, aPath, false );
wxArrayString parts = wxSplit( footprint, ':' ); wxArrayString parts = wxSplit( footprint, ':' );
@ -1226,7 +1228,7 @@ bool SCH_SYMBOL::ResolveTextVar( wxString* token, int aDepth, const SCH_SHEET_PA
{ {
wxString footprint; wxString footprint;
footprint = GetFootprintFieldText( true ); footprint = GetFootprintFieldText( true, aPath, false );
wxArrayString parts = wxSplit( footprint, ':' ); wxArrayString parts = wxSplit( footprint, ':' );
@ -1653,13 +1655,20 @@ void SCH_SYMBOL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_
{ {
if( m_part->IsPower() ) if( m_part->IsPower() )
{ {
aList.emplace_back( _( "Power symbol" ), GetValueFieldText( true ) ); // Don't use GetShownText(); we want to see the variable references here
aList.emplace_back( _( "Power symbol" ),
KIUI::EllipsizeStatusText( aFrame, GetField( VALUE_FIELD )->GetText() ) );
} }
else else
{ {
aList.emplace_back( _( "Reference" ), GetRef( currentSheet ) ); aList.emplace_back( _( "Reference" ),
aList.emplace_back( _( "Value" ), GetValueFieldText( true ) ); UnescapeString( GetRef( currentSheet ) ) );
aList.emplace_back( _( "Name" ), UnescapeString( GetLibId().GetLibItemName() ) );
// Don't use GetShownText(); we want to see the variable references here
aList.emplace_back( _( "Value" ),
KIUI::EllipsizeStatusText( aFrame, GetField( VALUE_FIELD )->GetText() ) );
aList.emplace_back( _( "Name" ),
KIUI::EllipsizeStatusText( aFrame, GetLibId().GetLibItemName() ) );
} }
#if 0 // Display symbol flags, for debug only #if 0 // Display symbol flags, for debug only
@ -1687,7 +1696,8 @@ void SCH_SYMBOL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_
} }
// Display the current associated footprint, if exists. // Display the current associated footprint, if exists.
msg = GetFootprintFieldText( true ); // Don't use GetShownText(); we want to see the variable references here
msg = KIUI::EllipsizeStatusText( aFrame, GetField( FOOTPRINT_FIELD )->GetText() );
if( msg.IsEmpty() ) if( msg.IsEmpty() )
msg = _( "<Unknown>" ); msg = _( "<Unknown>" );
@ -1702,9 +1712,11 @@ void SCH_SYMBOL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_
else else
{ {
aList.emplace_back( _( "Reference" ), GetRef( currentSheet ) ); aList.emplace_back( _( "Reference" ), GetRef( currentSheet ) );
// Don't use GetShownText(); we want to see the variable references here
aList.emplace_back( _( "Value" ), GetValueFieldText( true ) ); aList.emplace_back( _( "Value" ),
aList.emplace_back( _( "Name" ), GetLibId().GetLibItemName() ); KIUI::EllipsizeStatusText( aFrame, GetField( VALUE_FIELD )->GetText() ) );
aList.emplace_back( _( "Name" ),
KIUI::EllipsizeStatusText( aFrame, GetLibId().GetLibItemName() ) );
wxString libNickname = GetLibId().GetLibNickname(); wxString libNickname = GetLibId().GetLibNickname();
@ -1901,8 +1913,8 @@ LIB_ITEM* SCH_SYMBOL::GetDrawItem( const VECTOR2I& aPosition, KICAD_T aType )
wxString SCH_SYMBOL::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const wxString SCH_SYMBOL::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
{ {
return wxString::Format( _( "Symbol %s [%s]" ), return wxString::Format( _( "Symbol %s [%s]" ),
GetField( REFERENCE_FIELD )->GetShownText(), KIUI::EllipsizeMenuText( GetField( REFERENCE_FIELD )->GetText() ),
UnescapeString( GetLibId().GetLibItemName() ) ); KIUI::EllipsizeMenuText( GetLibId().GetLibItemName() ) );
} }
@ -2166,12 +2178,13 @@ void SCH_SYMBOL::Plot( PLOTTER* aPlotter, bool aBackground ) const
// Plot attributes to a hypertext menu // Plot attributes to a hypertext menu
std::vector<wxString> properties; std::vector<wxString> properties;
SCH_SHEET_PATH* sheet = &Schematic()->CurrentSheet();
for( const SCH_FIELD& field : GetFields() ) for( const SCH_FIELD& field : GetFields() )
{ {
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
field.GetName(), field.GetName(),
field.GetShownText() ) ); field.GetShownText( sheet, false) ) );
} }
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
@ -2189,7 +2202,7 @@ void SCH_SYMBOL::Plot( PLOTTER* aPlotter, bool aBackground ) const
aPlotter->EndBlock( nullptr ); aPlotter->EndBlock( nullptr );
if( !m_part->IsPower() ) if( !m_part->IsPower() )
aPlotter->Bookmark( GetBoundingBox(), GetField( REFERENCE_FIELD )->GetShownText(), _("Symbols") ); aPlotter->Bookmark( GetBoundingBox(), GetRef( sheet ), _( "Symbols" ) );
} }
} }

View File

@ -462,10 +462,12 @@ public:
m_fields = aFields; // vector copying, length is changed possibly m_fields = aFields; // vector copying, length is changed possibly
} }
const wxString GetValueFieldText( bool aResolve, const SCH_SHEET_PATH* aPath = nullptr ) const; const wxString GetValueFieldText( bool aResolve, const SCH_SHEET_PATH* aPath,
bool aAllowExtraText ) const;
void SetValueFieldText( const wxString& aValue ); void SetValueFieldText( const wxString& aValue );
const wxString GetFootprintFieldText( bool aResolve ) const; const wxString GetFootprintFieldText( bool aResolve, const SCH_SHEET_PATH* aPath,
bool aAllowExtraText ) const;
void SetFootprintFieldText( const wxString& aFootprint ); void SetFootprintFieldText( const wxString& aFootprint );
/** /**

View File

@ -339,7 +339,8 @@ const BOX2I SCH_TEXT::GetBoundingBox() const
} }
wxString SCH_TEXT::GetShownText( const SCH_SHEET_PATH* aPath, int aDepth, bool aAllowExtraText ) const wxString SCH_TEXT::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
int aDepth ) const
{ {
SCH_SHEET* sheet = nullptr; SCH_SHEET* sheet = nullptr;
@ -360,7 +361,7 @@ wxString SCH_TEXT::GetShownText( const SCH_SHEET_PATH* aPath, int aDepth, bool a
return false; return false;
}; };
wxString text = EDA_TEXT::GetShownText(); wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
if( text == wxS( "~" ) ) // Legacy placeholder for empty string if( text == wxS( "~" ) ) // Legacy placeholder for empty string
{ {
@ -388,7 +389,7 @@ void SCH_TEXT::DoHypertextAction( EDA_DRAW_FRAME* aFrame ) const
wxString SCH_TEXT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const wxString SCH_TEXT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
{ {
return wxString::Format( _( "Graphic Text '%s'" ), KIUI::EllipsizeMenuText( GetShownText() ) ); return wxString::Format( _( "Graphic Text '%s'" ), KIUI::EllipsizeMenuText( GetText() ) );
} }
@ -464,7 +465,7 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter, bool aBackground ) const
std::vector<VECTOR2I> positions; std::vector<VECTOR2I> positions;
wxArrayString strings_list; wxArrayString strings_list;
wxStringSplit( GetShownText(), strings_list, '\n' ); wxStringSplit( GetShownText( true ), strings_list, '\n' );
positions.reserve( strings_list.Count() ); positions.reserve( strings_list.Count() );
GetLinePositions( positions, (int) strings_list.Count() ); GetLinePositions( positions, (int) strings_list.Count() );

View File

@ -128,12 +128,12 @@ public:
return wxT( "SCH_TEXT" ); return wxT( "SCH_TEXT" );
} }
virtual wxString GetShownText( const SCH_SHEET_PATH* aPath, int aDepth = 0, virtual wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
bool aAllowExtraText = true ) const; int aDepth = 0 ) const;
wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override
{ {
return GetShownText( nullptr, aDepth, aAllowExtraText ); return GetShownText( nullptr, aAllowExtraText, aDepth );
} }
bool IsHypertext() const override bool IsHypertext() const override

View File

@ -278,12 +278,20 @@ void SCH_TEXTBOX::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffs
} }
wxString SCH_TEXTBOX::GetShownText( int aDepth, bool aAllowExtraText ) const wxString SCH_TEXTBOX::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
int aDepth ) const
{ {
SCH_SHEET* sheet = nullptr;
if( aPath )
sheet = aPath->Last();
else if( Schematic() )
sheet = Schematic()->CurrentSheet().Last();
std::function<bool( wxString* )> textResolver = std::function<bool( wxString* )> textResolver =
[&]( wxString* token ) -> bool [&]( wxString* token ) -> bool
{ {
if( SCH_SHEET* sheet = Schematic()->CurrentSheet().Last() ) if( sheet )
{ {
if( sheet->ResolveTextVar( token, aDepth + 1 ) ) if( sheet->ResolveTextVar( token, aDepth + 1 ) )
return true; return true;
@ -292,7 +300,7 @@ wxString SCH_TEXTBOX::GetShownText( int aDepth, bool aAllowExtraText ) const
return false; return false;
}; };
wxString text = EDA_TEXT::GetShownText(); wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
if( HasTextVars() ) if( HasTextVars() )
{ {
@ -405,7 +413,7 @@ void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground ) const
std::vector<VECTOR2I> positions; std::vector<VECTOR2I> positions;
wxArrayString strings_list; wxArrayString strings_list;
wxStringSplit( GetShownText(), strings_list, '\n' ); wxStringSplit( GetShownText( true ), strings_list, '\n' );
positions.reserve( strings_list.Count() ); positions.reserve( strings_list.Count() );
GetLinePositions( positions, (int) strings_list.Count() ); GetLinePositions( positions, (int) strings_list.Count() );

View File

@ -55,7 +55,13 @@ public:
VECTOR2I GetDrawPos() const override; VECTOR2I GetDrawPos() const override;
wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override; virtual wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText,
int aDepth = 0 ) const;
wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override
{
return GetShownText( nullptr, aAllowExtraText, aDepth );
}
bool IsHypertext() const override bool IsHypertext() const override
{ {

View File

@ -190,7 +190,7 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, S
if( field.GetId() == REFERENCE_FIELD ) if( field.GetId() == REFERENCE_FIELD )
fields.back().SetText( aSymbol.GetRef( aSheetPath ) ); fields.back().SetText( aSymbol.GetRef( aSheetPath ) );
else else
fields.back().SetText( field.GetShownText( aSheetPath, 0, false ) ); fields.back().SetText( field.GetShownText( aSheetPath, false ) );
} }
wxString deviceType; wxString deviceType;

View File

@ -648,7 +648,7 @@ std::string SIM_MODEL::GetFieldValue( const std::vector<T>* aFields, const wxStr
{ {
if( field.GetName() == aFieldName ) if( field.GetName() == aFieldName )
{ {
return aResolve ? field.GetShownText( 0, false ).ToStdString() return aResolve ? field.GetShownText( false ).ToStdString()
: field.GetText().ToStdString(); : field.GetText().ToStdString();
} }
} }
@ -1449,7 +1449,7 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol, const PROJECT* aProject )
// SPICE. Here we remap them to 'r0' and 'r1'. // SPICE. Here we remap them to 'r0' and 'r1'.
if( T_field* deviceType = aSymbol.FindField( SIM_TYPE_FIELD ) ) if( T_field* deviceType = aSymbol.FindField( SIM_TYPE_FIELD ) )
{ {
if( deviceType->GetShownText( 0, false ).Lower() == wxS( "pot" ) ) if( deviceType->GetShownText( false ).Lower() == wxS( "pot" ) )
{ {
if( T_field* pins = aSymbol.FindField( SIM_PINS_FIELD ) ) if( T_field* pins = aSymbol.FindField( SIM_PINS_FIELD ) )
{ {

View File

@ -289,13 +289,9 @@ int EE_INSPECTION_TOOL::ShowDatasheet( const TOOL_EVENT& aEvent )
SCH_SYMBOL* symbol = (SCH_SYMBOL*) selection.Front(); SCH_SYMBOL* symbol = (SCH_SYMBOL*) selection.Front();
// Use GetShownText() to resolve any text variables, but uve only field value // Use GetShownText() to resolve any text variables, but don't allow adding extra text
// (do not allow adding field name ) // (ie: the field name)
SCH_FIELD* tmp = symbol->GetField( DATASHEET_FIELD ); datasheet = symbol->GetField( DATASHEET_FIELD )->GetShownText( false );
bool name_shown = tmp->IsNameShown();
tmp->SetNameShown( false );
datasheet = tmp->GetShownText();
tmp->SetNameShown( name_shown );
} }
if( datasheet.IsEmpty() || datasheet == wxT( "~" ) ) if( datasheet.IsEmpty() || datasheet == wxT( "~" ) )

View File

@ -124,7 +124,7 @@ void HIERARCHY_PANE::buildHierarchyTree( SCH_SHEET_PATH* aList, const wxTreeItem
SCH_SHEET* sheet = static_cast<SCH_SHEET*>( aItem ); SCH_SHEET* sheet = static_cast<SCH_SHEET*>( aItem );
aList->push_back( sheet ); aList->push_back( sheet );
wxString sheetName = formatPageString( sheet->GetFields()[SHEETNAME].GetShownText(), wxString sheetName = formatPageString( sheet->GetFields()[SHEETNAME].GetShownText( false ),
aList->GetPageNumber() ); aList->GetPageNumber() );
wxTreeItemId child = m_tree->AppendItem( aParent, sheetName, 0, 1 ); wxTreeItemId child = m_tree->AppendItem( aParent, sheetName, 0, 1 );
m_tree->SetItemData( child, new TREE_ITEM_DATA( *aList ) ); m_tree->SetItemData( child, new TREE_ITEM_DATA( *aList ) );

View File

@ -89,13 +89,16 @@ public:
/** /**
* Return the string actually shown after processing of the base text. * Return the string actually shown after processing of the base text.
* *
* @param aDepth is used to prevent infinite recursions and loops when expanding
* text variables.
* @param aAllowExtraText is true to allow adding more text than the initial expanded text, * @param aAllowExtraText is true to allow adding more text than the initial expanded text,
* for intance a title, a prefix for texts in display functions. * for intance a title, a prefix for texts in display functions.
* False to disable any added text (for instance when writing the shown text in netlists). * False to disable any added text (for instance when writing the shown text in netlists).
* @param aDepth is used to prevent infinite recursions and loops when expanding
* text variables.
*/ */
virtual wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const { return m_shown_text; } virtual wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const
{
return m_shown_text;
}
/** /**
* Indicates the ShownText has text var references which need to be processed. * Indicates the ShownText has text var references which need to be processed.

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2009-2014 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr * Copyright (C) 2009-2014 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors. * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -133,7 +133,7 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
&& curEntry->m_FPID == footprint->GetFPID() ) && curEntry->m_FPID == footprint->GetFPID() )
{ {
curEntry->m_Ref.Append( wxT( ", " ), 1 ); curEntry->m_Ref.Append( wxT( ", " ), 1 );
curEntry->m_Ref.Append( footprint->Reference().GetShownText() ); curEntry->m_Ref.Append( footprint->Reference().GetShownText( false ) );
curEntry->m_Count++; curEntry->m_Count++;
valExist = true; valExist = true;
@ -146,8 +146,8 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent )
{ {
BOM_ENTRY* newEntry = new BOM_ENTRY(); BOM_ENTRY* newEntry = new BOM_ENTRY();
newEntry->m_Id = i++; newEntry->m_Id = i++;
newEntry->m_Val = footprint->Value().GetShownText(); newEntry->m_Val = footprint->Value().GetShownText( false );
newEntry->m_Ref = footprint->Reference().GetShownText(); newEntry->m_Ref = footprint->Reference().GetShownText( false );
newEntry->m_FPID = footprint->GetFPID(); newEntry->m_FPID = footprint->GetFPID();
newEntry->m_Count = 1; newEntry->m_Count = 1;
list.Append( newEntry ); list.Append( newEntry );

View File

@ -441,5 +441,5 @@ void DIALOG_DIMENSION_PROPERTIES::updateDimensionFromDialog( PCB_DIMENSION_BASE*
void DIALOG_DIMENSION_PROPERTIES::updatePreviewText() void DIALOG_DIMENSION_PROPERTIES::updatePreviewText()
{ {
updateDimensionFromDialog( m_previewDimension ); updateDimensionFromDialog( m_previewDimension );
m_staticTextPreview->SetLabel( m_previewDimension->GetShownText() ); m_staticTextPreview->SetLabel( m_previewDimension->GetShownText( true ) );
} }

View File

@ -492,8 +492,8 @@ void DIALOG_PAD_PROPERTIES::initValues()
// Display parent footprint info // Display parent footprint info
msg.Printf( _("Footprint %s (%s), %s, rotated %g deg"), msg.Printf( _("Footprint %s (%s), %s, rotated %g deg"),
footprint->Reference().GetShownText(), footprint->Reference().GetShownText( false ),
footprint->Value().GetShownText(), footprint->Value().GetShownText( false ),
footprint->IsFlipped() ? _( "back side (mirrored)" ) : _( "front side" ), footprint->IsFlipped() ? _( "back side (mirrored)" ) : _( "front side" ),
footprint->GetOrientation().AsDegrees() ); footprint->GetOrientation().AsDegrees() );
} }

View File

@ -286,7 +286,7 @@ void DRC_TEST_PROVIDER_MISC::testTextVars()
wxCHECK( boardItem, false ); wxCHECK( boardItem, false );
if( text && text->GetShownText().Matches( wxT( "*${*}*" ) ) ) if( text && text->GetShownText( true ).Matches( wxT( "*${*}*" ) ) )
{ {
std::shared_ptr<DRC_ITEM>drcItem = DRC_ITEM::Create( DRCE_UNRESOLVED_VARIABLE ); std::shared_ptr<DRC_ITEM>drcItem = DRC_ITEM::Create( DRCE_UNRESOLVED_VARIABLE );
drcItem->SetItems( item ); drcItem->SetItems( item );
@ -322,7 +322,7 @@ void DRC_TEST_PROVIDER_MISC::testTextVars()
DS_DRAW_ITEM_TEXT* text = dynamic_cast<DS_DRAW_ITEM_TEXT*>( item ); DS_DRAW_ITEM_TEXT* text = dynamic_cast<DS_DRAW_ITEM_TEXT*>( item );
if( text && text->GetShownText().Matches( wxT( "*${*}*" ) ) ) if( text && text->GetShownText( true ).Matches( wxT( "*${*}*" ) ) )
{ {
std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_UNRESOLVED_VARIABLE ); std::shared_ptr<DRC_ITEM> drcItem = DRC_ITEM::Create( DRCE_UNRESOLVED_VARIABLE );
drcItem->SetItems( drawingSheet ); drcItem->SetItems( drawingSheet );

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2021-2022 KiCad Developers. * Copyright (C) 2021-2023 KiCad Developers.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -154,7 +154,7 @@ bool DRC_TEST_PROVIDER_TEXT_DIMS::Run()
if( !constraint.Value().HasMin() ) if( !constraint.Value().HasMin() )
return true; return true;
auto* glyphs = text->GetRenderCache( font, text->GetShownText() ); auto* glyphs = text->GetRenderCache( font, text->GetShownText( true ) );
bool collapsedStroke = false; bool collapsedStroke = false;
bool collapsedArea = false; bool collapsedArea = false;

View File

@ -274,7 +274,7 @@ UseBoundingBox:
static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD& aIDFBoard ) static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD& aIDFBoard )
{ {
// Reference Designator // Reference Designator
std::string crefdes = TO_UTF8( aFootprint->Reference().GetShownText() ); std::string crefdes = TO_UTF8( aFootprint->Reference().GetShownText( false ) );
wxString libraryName = aFootprint->GetFPID().GetLibNickname(); wxString libraryName = aFootprint->GetFPID().GetLibNickname();
wxString footprintBasePath = wxEmptyString; wxString footprintBasePath = wxEmptyString;
@ -298,7 +298,7 @@ static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD
if( crefdes.empty() || !crefdes.compare( "~" ) ) if( crefdes.empty() || !crefdes.compare( "~" ) )
{ {
std::string cvalue = TO_UTF8( aFootprint->Value().GetShownText() ); std::string cvalue = TO_UTF8( aFootprint->Value().GetShownText( false ) );
// if both the RefDes and Value are empty or set to '~' the board owns the part, // if both the RefDes and Value are empty or set to '~' the board owns the part,
// otherwise associated parts of the footprint must be marked NOREFDES. // otherwise associated parts of the footprint must be marked NOREFDES.
@ -443,7 +443,7 @@ static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD
if( refdes.empty() ) if( refdes.empty() )
{ {
refdes = TO_UTF8( aFootprint->Reference().GetShownText() ); refdes = TO_UTF8( aFootprint->Reference().GetShownText( false ) );
// NOREFDES cannot be used or else the software gets confused // NOREFDES cannot be used or else the software gets confused
// when writing out the placement data due to conflicting // when writing out the placement data due to conflicting

View File

@ -132,7 +132,7 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
// Add object attribute: component reference to flash (mainly useful for users) // Add object attribute: component reference to flash (mainly useful for users)
// using quoted UTF8 string // using quoted UTF8 string
wxString ref = ConvertNotAllowedCharsInGerber( footprint->Reference().GetShownText(), wxString ref = ConvertNotAllowedCharsInGerber( footprint->Reference().GetShownText( false ),
allowUtf8, true ); allowUtf8, true );
gbr_metadata.SetCmpReference( ref ); gbr_metadata.SetCmpReference( ref );
@ -153,7 +153,7 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER
pnpAttrib.m_MountType = GBR_CMP_PNP_METADATA::MOUNT_TYPE_SMD; pnpAttrib.m_MountType = GBR_CMP_PNP_METADATA::MOUNT_TYPE_SMD;
// Add component value info: // Add component value info:
pnpAttrib.m_Value = ConvertNotAllowedCharsInGerber( footprint->Value().GetShownText(), pnpAttrib.m_Value = ConvertNotAllowedCharsInGerber( footprint->Value().GetShownText( false ),
allowUtf8, true ); allowUtf8, true );
// Add component footprint info: // Add component footprint info:

View File

@ -146,8 +146,8 @@ std::string PLACE_FILE_EXPORTER::GenPositionData()
LIST_MOD item; LIST_MOD item;
item.m_Footprint = footprint; item.m_Footprint = footprint;
item.m_Reference = footprint->Reference().GetShownText(); item.m_Reference = footprint->Reference().GetShownText( false );
item.m_Value = footprint->Value().GetShownText(); item.m_Value = footprint->Value().GetShownText( false );
item.m_Layer = footprint->GetLayer(); item.m_Layer = footprint->GetLayer();
list.push_back( item ); list.push_back( item );
@ -331,13 +331,14 @@ std::string PLACE_FILE_EXPORTER::GenReportData()
for( FOOTPRINT* footprint : sortedFootprints ) for( FOOTPRINT* footprint : sortedFootprints )
{ {
wxString ref = footprint->Reference().GetShownText(); wxString ref = footprint->Reference().GetShownText( false );
wxString value = footprint->Value().GetShownText( false );
snprintf( line, sizeof(line), "$MODULE %s\n", TO_UTF8( ref ) ); snprintf( line, sizeof(line), "$MODULE %s\n", TO_UTF8( ref ) );
buffer += line; buffer += line;
snprintf( line, sizeof(line), "reference %s\n", TO_UTF8( ref ) ); snprintf( line, sizeof(line), "reference %s\n", TO_UTF8( ref ) );
snprintf( line, sizeof(line), "value %s\n", EscapedUTF8( footprint->Value().GetShownText() ).c_str() ); snprintf( line, sizeof(line), "value %s\n", TO_UTF8( value ) );
snprintf( line, sizeof(line), "footprint %s\n", footprint->GetFPID().Format().c_str() ); snprintf( line, sizeof(line), "footprint %s\n", footprint->GetFPID().Format().c_str() );
buffer += line; buffer += line;

View File

@ -498,12 +498,12 @@ bool FOOTPRINT::ResolveTextVar( wxString* token, int aDepth ) const
if( token->IsSameAs( wxT( "REFERENCE" ) ) ) if( token->IsSameAs( wxT( "REFERENCE" ) ) )
{ {
*token = m_reference->GetShownText( aDepth + 1 ); *token = m_reference->GetShownText( false, aDepth + 1 );
return true; return true;
} }
else if( token->IsSameAs( wxT( "VALUE" ) ) ) else if( token->IsSameAs( wxT( "VALUE" ) ) )
{ {
*token = m_value->GetShownText( aDepth + 1 ); *token = m_value->GetShownText( false, aDepth + 1 );
return true; return true;
} }
else if( token->IsSameAs( wxT( "LAYER" ) ) ) else if( token->IsSameAs( wxT( "LAYER" ) ) )
@ -1027,7 +1027,9 @@ void FOOTPRINT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I
{ {
wxString msg, msg2; wxString msg, msg2;
aList.emplace_back( m_reference->GetShownText(), m_value->GetShownText() ); // Don't use GetShownText(); we want to see the variable references here
aList.emplace_back( UnescapeString( m_reference->GetText() ),
UnescapeString( m_value->GetText() ) );
if( aFrame->IsType( FRAME_FOOTPRINT_VIEWER ) if( aFrame->IsType( FRAME_FOOTPRINT_VIEWER )
|| aFrame->IsType( FRAME_FOOTPRINT_VIEWER_MODAL ) || aFrame->IsType( FRAME_FOOTPRINT_VIEWER_MODAL )

View File

@ -323,12 +323,12 @@ wxString FP_TEXT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
case TEXT_is_VALUE: case TEXT_is_VALUE:
return wxString::Format( _( "Value '%s' of %s" ), return wxString::Format( _( "Value '%s' of %s" ),
GetShownText(), GetShownText( false ),
static_cast<FOOTPRINT*>( GetParent() )->GetReference() ); static_cast<FOOTPRINT*>( GetParent() )->GetReference() );
default: default:
return wxString::Format( _( "Footprint Text '%s' of %s" ), return wxString::Format( _( "Footprint Text '%s' of %s" ),
KIUI::EllipsizeMenuText( GetShownText() ), KIUI::EllipsizeMenuText( GetShownText( false ) ),
static_cast<FOOTPRINT*>( GetParent() )->GetReference() ); static_cast<FOOTPRINT*>( GetParent() )->GetReference() );
} }
} }
@ -412,17 +412,17 @@ double FP_TEXT::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
} }
wxString FP_TEXT::GetShownText( int aDepth, bool aAllowExtraText ) const wxString FP_TEXT::GetShownText( bool aAllowExtraText, int aDepth ) const
{ {
const FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( GetParent() ); const FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( GetParent() );
std::function<bool( wxString* )> footprintResolver = std::function<bool( wxString* )> footprintResolver =
[&]( wxString* token ) -> bool [&]( wxString* token ) -> bool
{ {
return parentFootprint && parentFootprint->ResolveTextVar( token, aDepth ); return parentFootprint && parentFootprint->ResolveTextVar( token, aDepth + 1 );
}; };
wxString text = EDA_TEXT::GetShownText(); wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
if( HasTextVars() ) if( HasTextVars() )
{ {
@ -490,7 +490,7 @@ void FP_TEXT::TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLay
TEXT_ATTRIBUTES attrs = GetAttributes(); TEXT_ATTRIBUTES attrs = GetAttributes();
attrs.m_Angle = GetDrawRotation(); attrs.m_Angle = GetDrawRotation();
font->Draw( &callback_gal, GetShownText(), GetTextPos(), attrs ); font->Draw( &callback_gal, GetShownText( true ), GetTextPos(), attrs );
buffer.Simplify( SHAPE_POLY_SET::PM_FAST ); buffer.Simplify( SHAPE_POLY_SET::PM_FAST );

View File

@ -81,7 +81,7 @@ public:
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
{ {
return BOARD_ITEM::Matches( GetShownText(), aSearchData ); return BOARD_ITEM::Matches( GetShownText( false ), aSearchData );
} }
virtual VECTOR2I GetPosition() const override virtual VECTOR2I GetPosition() const override
@ -177,7 +177,7 @@ public:
EDA_ITEM* Clone() const override; EDA_ITEM* Clone() const override;
virtual wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override; virtual wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override;
virtual const BOX2I ViewBBox() const override; virtual const BOX2I ViewBBox() const override;

View File

@ -411,17 +411,17 @@ double FP_TEXTBOX::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
} }
wxString FP_TEXTBOX::GetShownText( int aDepth, bool aAllowExtraText ) const wxString FP_TEXTBOX::GetShownText( bool aAllowExtraText, int aDepth ) const
{ {
const FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( GetParent() ); const FOOTPRINT* parentFootprint = static_cast<FOOTPRINT*>( GetParent() );
std::function<bool( wxString* )> footprintResolver = std::function<bool( wxString* )> footprintResolver =
[&]( wxString* token ) -> bool [&]( wxString* token ) -> bool
{ {
return parentFootprint && parentFootprint->ResolveTextVar( token, aDepth ); return parentFootprint && parentFootprint->ResolveTextVar( token, aDepth + 1 );
}; };
wxString text = EDA_TEXT::GetShownText(); wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
if( HasTextVars() ) if( HasTextVars() )
{ {
@ -484,7 +484,7 @@ void FP_TEXTBOX::TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID a
TEXT_ATTRIBUTES attrs = GetAttributes(); TEXT_ATTRIBUTES attrs = GetAttributes();
attrs.m_Angle = GetDrawRotation(); attrs.m_Angle = GetDrawRotation();
font->Draw( &callback_gal, GetShownText(), GetDrawPos(), attrs ); font->Draw( &callback_gal, GetShownText( true ), GetDrawPos(), attrs );
buffer.Simplify( SHAPE_POLY_SET::PM_FAST ); buffer.Simplify( SHAPE_POLY_SET::PM_FAST );
aBuffer.Append( buffer ); aBuffer.Append( buffer );

View File

@ -75,7 +75,7 @@ public:
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override
{ {
return BOARD_ITEM::Matches( GetShownText(), aSearchData ); return BOARD_ITEM::Matches( GetShownText( false ), aSearchData );
} }
int GetTextMargin() const; int GetTextMargin() const;
@ -125,7 +125,7 @@ public:
EDA_ITEM* Clone() const override; EDA_ITEM* Clone() const override;
virtual wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override; virtual wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override;
virtual void ViewGetLayers( int aLayers[], int& aCount ) const override; virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;

View File

@ -295,7 +295,8 @@ void PCB_DIMENSION_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame,
wxCHECK_RET( m_parent != nullptr, wxT( "PCB_TEXT::GetMsgPanelInfo() m_Parent is NULL." ) ); wxCHECK_RET( m_parent != nullptr, wxT( "PCB_TEXT::GetMsgPanelInfo() m_Parent is NULL." ) );
aList.emplace_back( _( "Dimension" ), GetShownText() ); // Don't use GetShownText(); we want to see the variable references here
aList.emplace_back( _( "Dimension" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
aList.emplace_back( _( "Prefix" ), GetPrefix() ); aList.emplace_back( _( "Prefix" ), GetPrefix() );
@ -449,7 +450,9 @@ const BOX2I PCB_DIMENSION_BASE::GetBoundingBox() const
wxString PCB_DIMENSION_BASE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const wxString PCB_DIMENSION_BASE::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
{ {
return wxString::Format( _( "Dimension '%s' on %s" ), GetText(), GetLayerName() ); return wxString::Format( _( "Dimension '%s' on %s" ),
KIUI::EllipsizeMenuText( GetText() ),
GetLayerName() );
} }
@ -1082,7 +1085,8 @@ void PCB_DIM_LEADER::updateGeometry()
void PCB_DIM_LEADER::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) void PCB_DIM_LEADER::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
{ {
aList.emplace_back( _( "Leader" ), GetShownText() ); // Don't use GetShownText(); we want to see the variable references here
aList.emplace_back( _( "Leader" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) );
ORIGIN_TRANSFORMS originTransforms = aFrame->GetOriginTransforms(); ORIGIN_TRANSFORMS originTransforms = aFrame->GetOriginTransforms();

View File

@ -1642,15 +1642,15 @@ void PCB_EDIT_FRAME::ShowFindDialog()
switch( front->Type() ) switch( front->Type() )
{ {
case PCB_FOOTPRINT_T: case PCB_FOOTPRINT_T:
findString = static_cast<FOOTPRINT*>( front )->GetValue(); findString = UnescapeString( static_cast<FOOTPRINT*>( front )->GetValue() );
break; break;
case PCB_FP_TEXT_T: case PCB_FP_TEXT_T:
findString = static_cast<FP_TEXT*>( front )->GetShownText(); findString = UnescapeString( static_cast<FP_TEXT*>( front )->GetText() );
break; break;
case PCB_TEXT_T: case PCB_TEXT_T:
findString = static_cast<PCB_TEXT*>( front )->GetShownText(); findString = UnescapeString( static_cast<PCB_TEXT*>( front )->GetText() );
if( findString.Contains( wxT( "\n" ) ) ) if( findString.Contains( wxT( "\n" ) ) )
findString = findString.Before( '\n' ); findString = findString.Before( '\n' );

View File

@ -1937,7 +1937,7 @@ void PCB_PAINTER::draw( const PCB_BITMAP* aBitmap, int aLayer )
void PCB_PAINTER::draw( const PCB_TEXT* aText, int aLayer ) void PCB_PAINTER::draw( const PCB_TEXT* aText, int aLayer )
{ {
wxString resolvedText( aText->GetShownText() ); wxString resolvedText( aText->GetShownText( true ) );
if( resolvedText.Length() == 0 ) if( resolvedText.Length() == 0 )
return; return;
@ -2041,7 +2041,7 @@ void PCB_PAINTER::draw( const PCB_TEXTBOX* aTextBox, int aLayer )
const COLOR4D& color = m_pcbSettings.GetColor( aTextBox, aLayer ); const COLOR4D& color = m_pcbSettings.GetColor( aTextBox, aLayer );
int thickness = getLineThickness( aTextBox->GetWidth() ); int thickness = getLineThickness( aTextBox->GetWidth() );
PLOT_DASH_TYPE lineStyle = aTextBox->GetStroke().GetPlotStyle(); PLOT_DASH_TYPE lineStyle = aTextBox->GetStroke().GetPlotStyle();
wxString resolvedText( aTextBox->GetShownText() ); wxString resolvedText( aTextBox->GetShownText( true ) );
KIFONT::FONT* font = aTextBox->GetFont(); KIFONT::FONT* font = aTextBox->GetFont();
@ -2140,7 +2140,7 @@ void PCB_PAINTER::draw( const PCB_TEXTBOX* aTextBox, int aLayer )
void PCB_PAINTER::draw( const FP_TEXT* aText, int aLayer ) void PCB_PAINTER::draw( const FP_TEXT* aText, int aLayer )
{ {
wxString resolvedText( aText->GetShownText() ); wxString resolvedText( aText->GetShownText( true ) );
if( resolvedText.Length() == 0 ) if( resolvedText.Length() == 0 )
return; return;
@ -2269,7 +2269,7 @@ void PCB_PAINTER::draw( const FP_TEXTBOX* aTextBox, int aLayer )
} }
} }
wxString resolvedText( aTextBox->GetShownText() ); wxString resolvedText( aTextBox->GetShownText( true ) );
if( resolvedText.Length() == 0 ) if( resolvedText.Length() == 0 )
return; return;
@ -2581,7 +2581,7 @@ void PCB_PAINTER::draw( const PCB_DIMENSION_BASE* aDimension, int aLayer )
} }
// Draw text // Draw text
wxString resolvedText = aDimension->GetShownText(); wxString resolvedText = aDimension->GetShownText( true );
TEXT_ATTRIBUTES attrs = aDimension->GetAttributes(); TEXT_ATTRIBUTES attrs = aDimension->GetAttributes();
if( m_gal->IsFlippedX() && !( aDimension->GetLayerSet() & LSET::SideSpecificMask() ).any() ) if( m_gal->IsFlippedX() && !( aDimension->GetLayerSet() & LSET::SideSpecificMask() ).any() )

View File

@ -52,7 +52,7 @@ PCB_TEXT::~PCB_TEXT()
} }
wxString PCB_TEXT::GetShownText( int aDepth, bool aAllowExtraText ) const wxString PCB_TEXT::GetShownText( bool aAllowExtraText, int aDepth ) const
{ {
BOARD* board = dynamic_cast<BOARD*>( GetParent() ); BOARD* board = dynamic_cast<BOARD*>( GetParent() );
@ -73,7 +73,7 @@ wxString PCB_TEXT::GetShownText( int aDepth, bool aAllowExtraText ) const
return false; return false;
}; };
wxString text = EDA_TEXT::GetShownText(); wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
if( board && HasTextVars() && aDepth < 10 ) if( board && HasTextVars() && aDepth < 10 )
text = ExpandTextVars( text, &pcbTextResolver ); text = ExpandTextVars( text, &pcbTextResolver );
@ -82,6 +82,12 @@ wxString PCB_TEXT::GetShownText( int aDepth, bool aAllowExtraText ) const
} }
bool PCB_TEXT::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
{
return BOARD_ITEM::Matches( UnescapeString( GetText() ), aSearchData );
}
double PCB_TEXT::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const double PCB_TEXT::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
{ {
constexpr double HIDE = std::numeric_limits<double>::max(); constexpr double HIDE = std::numeric_limits<double>::max();
@ -237,7 +243,7 @@ void PCB_TEXT::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
wxString PCB_TEXT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const wxString PCB_TEXT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const
{ {
return wxString::Format( _( "PCB Text '%s' on %s"), return wxString::Format( _( "PCB Text '%s' on %s"),
KIUI::EllipsizeMenuText( GetShownText() ), KIUI::EllipsizeMenuText( GetShownText( false ) ),
GetLayerName() ); GetLayerName() );
} }
@ -315,7 +321,7 @@ void PCB_TEXT::TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLa
buffer.Append( point.x, point.y ); buffer.Append( point.x, point.y );
} ); } );
font->Draw( &callback_gal, GetShownText(), GetTextPos(), GetAttributes() ); font->Draw( &callback_gal, GetShownText( true ), GetTextPos(), GetAttributes() );
buffer.Simplify( SHAPE_POLY_SET::PM_FAST ); buffer.Simplify( SHAPE_POLY_SET::PM_FAST );

View File

@ -62,16 +62,13 @@ public:
return false; return false;
} }
wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override; wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override;
/// PCB_TEXTs are always visible: /// PCB_TEXTs are always visible:
void SetVisible( bool aVisible ) override { /* do nothing */} void SetVisible( bool aVisible ) override { /* do nothing */}
bool IsVisible() const override { return true; } bool IsVisible() const override { return true; }
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
{
return BOARD_ITEM::Matches( GetShownText(), aSearchData );
}
virtual VECTOR2I GetPosition() const override virtual VECTOR2I GetPosition() const override
{ {

View File

@ -239,7 +239,7 @@ double PCB_TEXTBOX::ViewGetLOD( int aLayer, KIGFX::VIEW* aView ) const
} }
wxString PCB_TEXTBOX::GetShownText( int aDepth, bool aAllowExtraText ) const wxString PCB_TEXTBOX::GetShownText( bool aAllowExtraText, int aDepth ) const
{ {
BOARD* board = dynamic_cast<BOARD*>( GetParent() ); BOARD* board = dynamic_cast<BOARD*>( GetParent() );
@ -260,7 +260,7 @@ wxString PCB_TEXTBOX::GetShownText( int aDepth, bool aAllowExtraText ) const
return false; return false;
}; };
wxString text = EDA_TEXT::GetShownText(); wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth );
if( board && HasTextVars() && aDepth < 10 ) if( board && HasTextVars() && aDepth < 10 )
text = ExpandTextVars( text, &pcbTextResolver ); text = ExpandTextVars( text, &pcbTextResolver );
@ -276,6 +276,12 @@ wxString PCB_TEXTBOX::GetShownText( int aDepth, bool aAllowExtraText ) const
} }
bool PCB_TEXTBOX::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const
{
return BOARD_ITEM::Matches( UnescapeString( GetText() ), aSearchData );
}
void PCB_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) void PCB_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList )
{ {
// Don't use GetShownText() here; we want to show the user the variable references // Don't use GetShownText() here; we want to show the user the variable references
@ -462,7 +468,7 @@ void PCB_TEXTBOX::TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID
buffer.Append( point.x, point.y ); buffer.Append( point.x, point.y );
} ); } );
font->Draw( &callback_gal, GetShownText(), GetDrawPos(), GetAttributes() ); font->Draw( &callback_gal, GetShownText( true ), GetDrawPos(), GetAttributes() );
buffer.Simplify( SHAPE_POLY_SET::PM_FAST ); buffer.Simplify( SHAPE_POLY_SET::PM_FAST );
aBuffer.Append( buffer ); aBuffer.Append( buffer );

View File

@ -74,16 +74,13 @@ public:
VECTOR2I GetDrawPos() const override; VECTOR2I GetDrawPos() const override;
wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override; wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override;
/// PCB_TEXTBOXes are always visible: /// PCB_TEXTBOXes are always visible:
void SetVisible( bool aVisible ) override { /* do nothing */} void SetVisible( bool aVisible ) override { /* do nothing */}
bool IsVisible() const override { return true; } bool IsVisible() const override { return true; }
bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
{
return BOARD_ITEM::Matches( GetShownText(), aSearchData );
}
std::vector<VECTOR2I> GetAnchorAndOppositeCorner() const; std::vector<VECTOR2I> GetAnchorAndOppositeCorner() const;

View File

@ -83,11 +83,11 @@ void PlotInteractiveLayer( BOARD* aBoard, PLOTTER* aPlotter )
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
_( "Reference designator" ), _( "Reference designator" ),
fp->Reference().GetShownText() ) ); fp->Reference().GetShownText( false ) ) );
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), properties.emplace_back( wxString::Format( wxT( "!%s = %s" ),
_( "Value" ), _( "Value" ),
fp->Value().GetShownText() ) ); fp->Value().GetShownText( false ) ) );
for( const auto& [ name, value ] : fp->GetProperties() ) for( const auto& [ name, value ] : fp->GetProperties() )
properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), name, value ) ); properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), name, value ) );

View File

@ -450,7 +450,7 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItem( const FP_TEXT* aText, const COLOR4
callback_gal.SetIsFill( font->IsOutline() ); callback_gal.SetIsFill( font->IsOutline() );
callback_gal.SetIsStroke( font->IsStroke() ); callback_gal.SetIsStroke( font->IsStroke() );
font->Draw( &callback_gal, aText->GetShownText(), aText->GetDrawPos(), attrs ); font->Draw( &callback_gal, aText->GetShownText( true ), aText->GetDrawPos(), attrs );
SHAPE_POLY_SET finalPoly; SHAPE_POLY_SET finalPoly;
int margin = attrs.m_StrokeWidth * 1.5 int margin = attrs.m_StrokeWidth * 1.5
@ -464,7 +464,9 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItem( const FP_TEXT* aText, const COLOR4
m_plotter->PlotPoly( finalPoly.Outline( ii ), FILL_T::FILLED_SHAPE, 0, &gbr_metadata ); m_plotter->PlotPoly( finalPoly.Outline( ii ), FILL_T::FILLED_SHAPE, 0, &gbr_metadata );
} }
else else
m_plotter->PlotText( pos, aColor, aText->GetShownText(), attrs, font, &gbr_metadata ); {
m_plotter->PlotText( pos, aColor, aText->GetShownText( true ), attrs, font, &gbr_metadata );
}
} }
@ -836,7 +838,7 @@ void BRDITEMS_PLOTTER::PlotPcbText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer,
aText->IsBold(), aText->IsItalic() ); aText->IsBold(), aText->IsItalic() );
} }
wxString shownText( aText->GetShownText() ); wxString shownText( aText->GetShownText( true ) );
if( shownText.IsEmpty() ) if( shownText.IsEmpty() )
return; return;

View File

@ -476,7 +476,7 @@ void PCB_PLUGIN::formatPolyPts( const SHAPE_LINE_CHAIN& outline, int aNestLevel,
void PCB_PLUGIN::formatRenderCache( const EDA_TEXT* aText, int aNestLevel ) const void PCB_PLUGIN::formatRenderCache( const EDA_TEXT* aText, int aNestLevel ) const
{ {
const wxString& shownText = aText->GetShownText(); const wxString& shownText = aText->GetShownText( true );
std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = aText->GetRenderCache( aText->GetFont(), std::vector<std::unique_ptr<KIFONT::GLYPH>>* cache = aText->GetRenderCache( aText->GetFont(),
shownText ); shownText );

View File

@ -255,7 +255,7 @@ wxString TEXT_SEARCH_HANDLER::GetResultCell( int aRow, int aCol )
if( PCB_TEXT::ClassOf( text ) ) if( PCB_TEXT::ClassOf( text ) )
return UnescapeString( static_cast<PCB_TEXT*>( text )->GetText() ); return UnescapeString( static_cast<PCB_TEXT*>( text )->GetText() );
else if( PCB_TEXTBOX::ClassOf( text ) ) else if( PCB_TEXTBOX::ClassOf( text ) )
return UnescapeString( static_cast<PCB_TEXTBOX*>( text )->GetShownText() ); return UnescapeString( static_cast<PCB_TEXTBOX*>( text )->GetText() );
} }
if( aCol == 2 ) if( aCol == 2 )
return text->GetLayerName(); return text->GetLayerName();

View File

@ -1,7 +1,7 @@
/* /*
* This program source code file is part of KiCad, a free EDA CAD application. * This program source code file is part of KiCad, a free EDA CAD application.
* *
* Copyright (C) 2019-2022 KiCad Developers, see AUTHORS.TXT for contributors. * Copyright (C) 2019-2023 KiCad Developers, see AUTHORS.TXT for contributors.
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License