diff --git a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp index de8e00b741..c9620906bf 100644 --- a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp +++ b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp @@ -91,7 +91,7 @@ void BOARD_ADAPTER::addText( const EDA_TEXT* aText, CONTAINER_2D_BASE* aContaine callback_gal.SetIsFill( font->IsOutline() ); callback_gal.SetIsStroke( font->IsStroke() ); 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; 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(); - font->Draw( &callback_gal, aText->GetShownText(), aText->GetDrawPos(), attrs ); + font->Draw( &callback_gal, aText->GetShownText( true ), aText->GetDrawPos(), attrs ); } } diff --git a/common/drawing_sheet/ds_draw_item.cpp b/common/drawing_sheet/ds_draw_item.cpp index e7485f8ac6..5d5d8c005f 100644 --- a/common/drawing_sheet/ds_draw_item.cpp +++ b/common/drawing_sheet/ds_draw_item.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 1992-2013 Jean-Pierre Charras . - * 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 @@ -118,8 +118,12 @@ void DS_DRAW_ITEM_BASE::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, break; case DS_DATA_ITEM::DS_TEXT: - aList.emplace_back( _( "Text" ), static_cast( this )->GetShownText() ); + { + DS_DRAW_ITEM_TEXT* textItem = static_cast( this ); + // Don't use GetShownText(); we want to see the variable references here + aList.emplace_back( _( "Text" ), KIUI::EllipsizeStatusText( aFrame, textItem->GetText() ) ); break; + } case DS_DATA_ITEM::DS_POLYPOLYGON: 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 { - return wxString::Format( _( "Text '%s'" ), GetShownText() ); + return wxString::Format( _( "Text '%s'" ), KIUI::EllipsizeMenuText( GetText() ) ); } diff --git a/common/drawing_sheet/ds_painter.cpp b/common/drawing_sheet/ds_painter.cpp index 39f3056106..baea6e5a62 100644 --- a/common/drawing_sheet/ds_painter.cpp +++ b/common/drawing_sheet/ds_painter.cpp @@ -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(), m_renderSettings.GetDefaultPenWidth() ); - font->Draw( m_gal, aItem->GetShownText(), aItem->GetTextPos(), attrs ); + font->Draw( m_gal, aItem->GetShownText( true ), aItem->GetTextPos(), attrs ); } diff --git a/common/eda_text.cpp b/common/eda_text.cpp index 71d99f71f1..d3acf4f2c4 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -477,7 +477,8 @@ EDA_TEXT::GetRenderCache( const KIFONT::FONT* aFont, const wxString& forResolved 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_text = forResolvedText; m_render_cache_offset = aOffset; @@ -524,7 +525,7 @@ BOX2I EDA_TEXT::GetTextBox( int aLine, bool aInvertY ) const BOX2I bbox; wxArrayString strings; - wxString text = GetShownText(); + wxString text = GetShownText( true ); int thickness = GetEffectiveTextPenWidth(); if( IsMultilineAllowed() ) @@ -662,7 +663,7 @@ void EDA_TEXT::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, { std::vector positions; wxArrayString strings; - wxStringSplit( GetShownText(), strings, '\n' ); + wxStringSplit( GetShownText( true ), strings, '\n' ); positions.reserve( strings.Count() ); @@ -673,7 +674,8 @@ void EDA_TEXT::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, } else { - printOneLineOfText( aSettings, aOffset, aColor, aFillMode, GetShownText(), GetDrawPos() ); + printOneLineOfText( aSettings, aOffset, aColor, aFillMode, GetShownText( true ), + GetDrawPos() ); } } @@ -894,7 +896,7 @@ std::shared_ptr EDA_TEXT::GetEffectiveTextShape( bool aTriangula shape->AddShape( triShape ); } ); - font->Draw( &callback_gal, GetShownText(), GetDrawPos(), attrs ); + font->Draw( &callback_gal, GetShownText( true ), GetDrawPos(), attrs ); } else { @@ -911,7 +913,7 @@ std::shared_ptr EDA_TEXT::GetEffectiveTextShape( bool aTriangula shape->AddShape( aPoly.Clone() ); } ); - font->Draw( &callback_gal, GetShownText(), GetDrawPos(), attrs ); + font->Draw( &callback_gal, GetShownText( true ), GetDrawPos(), attrs ); } return shape; diff --git a/common/plotters/common_plot_functions.cpp b/common/plotters/common_plot_functions.cpp index 875123822e..9d9ad9224f 100644 --- a/common/plotters/common_plot_functions.cpp +++ b/common/plotters/common_plot_functions.cpp @@ -139,10 +139,10 @@ void PlotDrawingSheet( PLOTTER* plotter, const PROJECT* aProject, const TITLE_BL int penWidth = std::max( text->GetEffectiveTextPenWidth(), defaultPenWidth ); - plotter->Text( text->GetTextPos(), color, text->GetShownText(), text->GetTextAngle(), - text->GetTextSize(), text->GetHorizJustify(), text->GetVertJustify(), - penWidth, text->IsItalic(), text->IsBold(), text->IsMultilineAllowed(), - font ); + plotter->Text( text->GetTextPos(), color, text->GetShownText( true ), + text->GetTextAngle(), text->GetTextSize(), text->GetHorizJustify(), + text->GetVertJustify(), penWidth, text->IsItalic(), text->IsBold(), + text->IsMultilineAllowed(), font ); } break; diff --git a/eeschema/annotate.cpp b/eeschema/annotate.cpp index a9d8bb1491..0c26af75f6 100644 --- a/eeschema/annotate.cpp +++ b/eeschema/annotate.cpp @@ -1,7 +1,7 @@ /* * 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 * 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 ) { msg.Printf( _( "Updated %s (unit %s) from %s to %s." ), - symbol->GetValueFieldText( true ), + symbol->GetValueFieldText( true, sheet, false ), LIB_SYMBOL::SubReference( symbol->GetUnit(), false ), prevRef, newRef ); @@ -384,7 +384,7 @@ void SCH_EDIT_FRAME::AnnotateSymbols( ANNOTATE_SCOPE_T aAnnotateScope, else { msg.Printf( _( "Updated %s from %s to %s." ), - symbol->GetValueFieldText( true ), + symbol->GetValueFieldText( true, sheet, false ), prevRef, newRef ); } @@ -394,14 +394,14 @@ void SCH_EDIT_FRAME::AnnotateSymbols( ANNOTATE_SCOPE_T aAnnotateScope, if( symbol->GetUnitCount() > 1 ) { msg.Printf( _( "Annotated %s (unit %s) as %s." ), - symbol->GetValueFieldText( true ), + symbol->GetValueFieldText( true, sheet, false ), LIB_SYMBOL::SubReference( symbol->GetUnit(), false ), newRef ); } else { msg.Printf( _( "Annotated %s as %s." ), - symbol->GetValueFieldText( true ), + symbol->GetValueFieldText( true, sheet, false ), newRef ); } } diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 5b9112f8f5..7d60d7a0f8 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -336,18 +336,14 @@ wxString CONNECTION_SUBGRAPH::driverName( SCH_ITEM* aItem ) const case SCH_LABEL_T: case SCH_GLOBAL_LABEL_T: case SCH_HIER_LABEL_T: - { - SCH_LABEL_BASE* label = static_cast( aItem ); - return EscapeString( label->GetShownText( &m_sheet ), CTX_NETNAME ); - } + return EscapeString( static_cast( aItem )->GetShownText( &m_sheet, false ), + CTX_NETNAME ); case SCH_SHEET_PIN_T: - { // Sheet pins need to use their parent sheet as their starting sheet or they will // resolve variables on the current sheet first - SCH_SHEET_PIN* sheetPin = static_cast( aItem ); - return EscapeString( sheetPin->GetShownText(), CTX_NETNAME ); - } + return EscapeString( static_cast( aItem )->GetShownText( nullptr, false ), + CTX_NETNAME ); default: wxFAIL_MSG( wxS( "Unhandled item type in GetNameForDriver" ) ); @@ -2587,11 +2583,11 @@ std::vector CONNECTION_GRAPH::GetBusesNeedingMigrati if( labels.size() > 1 ) { bool different = false; - wxString first = static_cast( labels.at( 0 ) )->GetShownText(); + wxString first = static_cast( labels.at( 0 ) )->GetShownText( false ); for( unsigned i = 1; i < labels.size(); ++i ) { - if( static_cast( labels.at( i ) )->GetShownText() != first ) + if( static_cast( labels.at( i ) )->GetShownText( false ) != first ) { different = true; break; @@ -2931,7 +2927,7 @@ bool CONNECTION_GRAPH::ercCheckBusToNetConflicts( const CONNECTION_SUBGRAPH* aSu case SCH_HIER_LABEL_T: { SCH_TEXT* text = static_cast( item ); - conn.ConfigureFromLabel( EscapeString( text->GetShownText(), CTX_NETNAME ) ); + conn.ConfigureFromLabel( EscapeString( text->GetShownText( false ), CTX_NETNAME ) ); if( conn.IsBus() ) bus_item = ( !bus_item ) ? item : bus_item; diff --git a/eeschema/dialogs/dialog_change_symbols.cpp b/eeschema/dialogs/dialog_change_symbols.cpp index 5045575ae4..43eadd6eff 100644 --- a/eeschema/dialogs/dialog_change_symbols.cpp +++ b/eeschema/dialogs/dialog_change_symbols.cpp @@ -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_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() ) ); } else @@ -426,12 +426,14 @@ bool DIALOG_CHANGE_SYMBOLS::isMatch( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH* aInsta else if( m_matchByReference->GetValue() ) { return WildCompareString( m_specifiedReference->GetValue(), - aSymbol->GetRef( aInstance, false ), false ); + UnescapeString( aSymbol->GetRef( aInstance, false ) ), + false ); } else if( m_matchByValue->GetValue() ) { return WildCompareString( m_specifiedValue->GetValue(), - aSymbol->GetValueFieldText( false ), false ); + UnescapeString( aSymbol->GetField( VALUE_FIELD )->GetText() ), + false ); } else if( m_matchById ) { diff --git a/eeschema/dialogs/dialog_label_properties.cpp b/eeschema/dialogs/dialog_label_properties.cpp index e0fbb157a9..0bdc9c4076 100644 --- a/eeschema/dialogs/dialog_label_properties.cpp +++ b/eeschema/dialogs/dialog_label_properties.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2013 Wayne Stambaugh - * 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 * 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 // before adding its value in list if( power->IsSymbolLikePowerGlobalLabel() ) - existingLabels.insert( UnescapeString( power->GetValueFieldText( false ) ) ); + existingLabels.insert( UnescapeString( power->GetField( VALUE_FIELD )->GetText() ) ); } } diff --git a/eeschema/dialogs/dialog_sheet_properties.cpp b/eeschema/dialogs/dialog_sheet_properties.cpp index 1b2047e2b3..be9865a3ce 100644 --- a/eeschema/dialogs/dialog_sheet_properties.cpp +++ b/eeschema/dialogs/dialog_sheet_properties.cpp @@ -874,7 +874,7 @@ void DIALOG_SHEET_PROPERTIES::OnUpdateUI( wxUpdateUIEvent& event ) m_dummySheet.SetFields( *m_fields ); m_dummySheetNameField.SetText( sheetName ); - path += m_dummySheetNameField.GetShownText(); + path += m_dummySheetNameField.GetShownText( false ); editor->DecRef(); diff --git a/eeschema/erc.cpp b/eeschema/erc.cpp index ce402c5e43..760cf7c4e0 100644 --- a/eeschema/erc.cpp +++ b/eeschema/erc.cpp @@ -147,7 +147,7 @@ int ERC_TESTER::TestDuplicateSheetNames( bool aCreateMarker ) // We have found a second sheet: compare names // we are using case insensitive comparison to avoid mistakes between // 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 ) { @@ -206,7 +206,7 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet ) for( SCH_FIELD& field : symbol->GetFields() ) { - if( unresolved( field.GetShownText() ) ) + if( unresolved( field.GetShownText( true ) ) ) { VECTOR2I pos = field.GetPosition() - symbol->GetPosition(); pos = symbol->GetTransform().TransformCoordinate( pos ); @@ -227,7 +227,7 @@ void ERC_TESTER::TestTextVars( DS_PROXY_VIEW_ITEM* aDrawingSheet ) for( SCH_FIELD& field : subSheet->GetFields() ) { - if( unresolved( field.GetShownText() ) ) + if( unresolved( field.GetShownText( true ) ) ) { std::shared_ptr ercItem = 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( item )->GetPins() ) { - if( pin->GetShownText().Matches( wxT( "*${*}*" ) ) ) + if( pin->GetShownText( true ).Matches( wxT( "*${*}*" ) ) ) { std::shared_ptr ercItem = 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( item ) ) { - if( text->GetShownText().Matches( wxT( "*${*}*" ) ) ) + if( text->GetShownText( true ).Matches( wxT( "*${*}*" ) ) ) { std::shared_ptr ercItem = 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( item ) ) { - if( textBox->GetShownText().Matches( wxT( "*${*}*" ) ) ) + if( textBox->GetShownText( true ).Matches( wxT( "*${*}*" ) ) ) { std::shared_ptr ercItem = 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( item ) ) { - if( text->GetShownText().Matches( wxT( "*${*}*" ) ) ) + if( text->GetShownText( true ).Matches( wxT( "*${*}*" ) ) ) { std::shared_ptr erc = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE ); erc->SetErrorMessage( _( "Unresolved text variable in drawing sheet" ) ); @@ -824,13 +824,14 @@ int ERC_TESTER::TestSimilarLabels() { SCH_LABEL_BASE* label = static_cast( item ); - wxString normalized = label->GetShownText().Lower(); + wxString normalized = label->GetShownText( false ).Lower(); if( !labelMap.count( normalized ) ) { labelMap[normalized] = label; } - else if( labelMap.at( normalized )->GetShownText() != label->GetShownText() ) + else if( labelMap.at( normalized )->GetShownText( false ) + != label->GetShownText( false) ) { std::shared_ptr ercItem = ERC_ITEM::Create( ERCE_SIMILAR_LABELS ); ercItem->SetItems( label, labelMap.at( normalized ) ); diff --git a/eeschema/fields_grid_table.cpp b/eeschema/fields_grid_table.cpp index a9a7eeee92..4e54be3e7d 100644 --- a/eeschema/fields_grid_table.cpp +++ b/eeschema/fields_grid_table.cpp @@ -72,9 +72,9 @@ static wxString netList( SCH_SYMBOL* aSymbol, SCH_SHEET_PATH& aSheetPath ) */ 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->GetValueFieldText( true ), CTX_LINE ); + netlist << EscapeString( aSymbol->GetValueFieldText( true, &aSheetPath, false ), CTX_LINE ); for( SCH_PIN* pin : aSymbol->GetPins( &aSheetPath ) ) { diff --git a/eeschema/generate_alias_info.cpp b/eeschema/generate_alias_info.cpp index 10c3235f40..d9831c7fe6 100644 --- a/eeschema/generate_alias_info.cpp +++ b/eeschema/generate_alias_info.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2017 Chris Pavlina - * 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 * under the terms of the GNU General Public License as published by the @@ -166,7 +166,7 @@ protected: switch( aField.GetId() ) { case DATASHEET_FIELD: - text = m_symbol->GetDatasheetField().GetShownText( 0, false ); + text = m_symbol->GetDatasheetField().GetShownText( false ); if( text.IsEmpty() || text == wxT( "~" ) ) { @@ -197,7 +197,7 @@ protected: break; default: - text = aField.GetShownText( 0, false ); + text = aField.GetShownText( false ); fieldhtml.Replace( wxS( "__VALUE__" ), EscapeHTML( text ) ); } diff --git a/eeschema/lib_field.cpp b/eeschema/lib_field.cpp index 995a401d88..1377670b16 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -390,7 +390,7 @@ void LIB_FIELD::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOffs attrs.m_Angle = orient; 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() ) text = GetName() << wxT( ": " ) << text; @@ -516,7 +516,9 @@ void LIB_FIELD::SetName( const wxString& aName ) 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& aColumnMap ) LIB_FIELD* field = static_cast( &item ); 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 // to add '?' and the part id - wxString tmp = field.GetShownText(); + wxString tmp = field.GetShownText( true ); if( field.GetId() == REFERENCE_FIELD ) { diff --git a/eeschema/lib_text.cpp b/eeschema/lib_text.cpp index 421c33fe99..cb4dde71ce 100644 --- a/eeschema/lib_text.cpp +++ b/eeschema/lib_text.cpp @@ -406,8 +406,9 @@ void LIB_TEXT::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset, // Calculate pos according to mirror/rotation. txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset; - GRPrintText( DC, txtpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_H_ALIGN_CENTER, - GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold(), font ); + GRPrintText( DC, txtpos, color, GetShownText( true ), orient, GetTextSize(), + 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::vectorGetName() : _( "Default" ) ); @@ -473,7 +474,7 @@ const BOX2I LIB_TEXT::GetBoundingBox() 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() ) ); } diff --git a/eeschema/lib_textbox.cpp b/eeschema/lib_textbox.cpp index 3b981ce6dc..4feae4efa5 100644 --- a/eeschema/lib_textbox.cpp +++ b/eeschema/lib_textbox.cpp @@ -320,15 +320,15 @@ void LIB_TEXTBOX::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffs text.SetStart( VECTOR2I( pt1.x, -pt1.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.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(); VECTOR2D size = GetEnd() - GetStart(); @@ -460,7 +460,7 @@ void LIB_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground, const VECTOR2I& aOf std::vector positions; wxArrayString strings_list; - wxStringSplit( GetShownText(), strings_list, '\n' ); + wxStringSplit( GetShownText( true ), strings_list, '\n' ); positions.reserve( strings_list.Count() ); text.GetLinePositions( positions, (int) strings_list.Count() ); diff --git a/eeschema/lib_textbox.h b/eeschema/lib_textbox.h index 83913e17ab..be73336127 100644 --- a/eeschema/lib_textbox.h +++ b/eeschema/lib_textbox.h @@ -55,7 +55,7 @@ public: 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 MirrorVertically( const VECTOR2I& center ); diff --git a/eeschema/netlist_exporters/netlist_exporter_cadstar.cpp b/eeschema/netlist_exporters/netlist_exporter_cadstar.cpp index 8f43d49c7d..d096a69b4b 100644 --- a/eeschema/netlist_exporters/netlist_exporter_cadstar.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_cadstar.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 1992-2018 jp.charras at wanadoo.fr * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck - * 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 * 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() ) continue; - footprint = symbol->GetFootprintFieldText( true ); + footprint = symbol->GetFootprintFieldText( true, &sheetList[ i ], false ); if( footprint.IsEmpty() ) 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( msg ) ); - msg = symbol->GetValueFieldText( true ); + msg = symbol->GetValueFieldText( true, &sheetList[ i ], false ); msg.Replace( wxT( " " ), wxT( "_" ) ); ret |= fprintf( f, " \"%s\"", TO_UTF8( msg ) ); ret |= fprintf( f, " \"%s\"", TO_UTF8( footprint ) ); diff --git a/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp b/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp index 17376af6e8..0e5e53b38a 100644 --- a/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_orcadpcb2.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 1992-2018 jp.charras at wanadoo.fr * Copyright (C) 2013 SoftPLC Corporation, Dick Hollenbeck - * 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 * modify it under the terms of the GNU General Public License @@ -88,7 +88,7 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName, sheet ) ); } - footprint = symbol->GetFootprintFieldText( true ); + footprint = symbol->GetFootprintFieldText( true, &sheet, false ); footprint.Replace( wxT( " " ), wxT( "_" ) ); if( footprint.IsEmpty() ) @@ -102,7 +102,7 @@ bool NETLIST_EXPORTER_ORCADPCB2::WriteNetlist( const wxString& aOutFileName, ret |= fprintf( f, " %s", TO_UTF8( field ) ); - field = symbol->GetValueFieldText( true ); + field = symbol->GetValueFieldText( true, &sheet, false ); field.Replace( wxT( " " ), wxT( "_" ) ); ret |= fprintf( f, " %s", TO_UTF8( field ) ); diff --git a/eeschema/netlist_exporters/netlist_exporter_spice.cpp b/eeschema/netlist_exporters/netlist_exporter_spice.cpp index e4b29c69fe..a95746a39e 100644 --- a/eeschema/netlist_exporters/netlist_exporter_spice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_spice.cpp @@ -224,7 +224,7 @@ bool NETLIST_EXPORTER_SPICE::ReadSchematicAndLibraries( unsigned aNetlistOptions if( field.GetId() == REFERENCE_FIELD ) spiceItem.fields.back().SetText( symbol->GetRef( &sheet ) ); else - spiceItem.fields.back().SetText( field.GetShownText( &sheet, 0, false ) ); + spiceItem.fields.back().SetText( field.GetShownText( &sheet, false ) ); } readRefName( sheet, *symbol, spiceItem, refNames ); @@ -333,9 +333,9 @@ void NETLIST_EXPORTER_SPICE::ReadDirectives( unsigned aNetlistOptions ) for( SCH_ITEM* item : sheet.LastScreen()->Items() ) { if( item->Type() == SCH_TEXT_T ) - text = static_cast( item )->GetShownText(); + text = static_cast( item )->GetShownText( &sheet, false ); else if( item->Type() == SCH_TEXTBOX_T ) - text = static_cast( item )->GetShownText(); + text = static_cast( item )->GetShownText( &sheet, false ); else continue; diff --git a/eeschema/netlist_exporters/netlist_exporter_xml.cpp b/eeschema/netlist_exporters/netlist_exporter_xml.cpp index 7c3f766237..b76dd0c990 100644 --- a/eeschema/netlist_exporters/netlist_exporter_xml.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_xml.cpp @@ -127,18 +127,18 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol, int unit = symbol2->GetUnitSelection( aSheet ); // 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() ) ) value = candidate; - candidate = symbol2->GetFootprintFieldText( m_resolveTextVars ); + candidate = symbol2->GetFootprintFieldText( m_resolveTextVars, &sheetList[i], false ); if( !candidate.IsEmpty() && ( unit < minUnit || footprint.IsEmpty() ) ) footprint = candidate; candidate = m_resolveTextVars - ? symbol2->GetField( DATASHEET_FIELD )->GetShownText( aSheet, 0, false ) + ? symbol2->GetField( DATASHEET_FIELD )->GetShownText( &sheetList[i], false ) : symbol2->GetField( DATASHEET_FIELD )->GetText(); 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 ) ) { if( m_resolveTextVars ) - userFields[ f.GetName() ] = f.GetShownText( aSheet, 0, false ); + userFields[ f.GetName() ] = f.GetShownText( aSheet, false ); else userFields[ f.GetName() ] = f.GetText(); } @@ -164,11 +164,11 @@ void NETLIST_EXPORTER_XML::addSymbolFields( XNODE* aNode, SCH_SYMBOL* aSymbol, } else { - value = aSymbol->GetValueFieldText( m_resolveTextVars ); - footprint = aSymbol->GetFootprintFieldText( m_resolveTextVars ); + value = aSymbol->GetValueFieldText( m_resolveTextVars, aSheet, false ); + footprint = aSymbol->GetFootprintFieldText( m_resolveTextVars, aSheet, false ); if( m_resolveTextVars ) - datasheet = aSymbol->GetField( DATASHEET_FIELD )->GetShownText( aSheet, 0, false ); + datasheet = aSymbol->GetField( DATASHEET_FIELD )->GetShownText( aSheet, false ); else 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( m_resolveTextVars ) - userFields[ f.GetName() ] = f.GetShownText( aSheet, 0, false ); + userFields[ f.GetName() ] = f.GetShownText( aSheet, false ); else userFields[ f.GetName() ] = f.GetText(); } @@ -321,7 +321,7 @@ XNODE* NETLIST_EXPORTER_XML::makeSymbols( unsigned aCtl ) xproperty->AddAttribute( wxT( "name" ), fields[jj].GetCanonicalName() ); if( m_resolveTextVars ) - xproperty->AddAttribute( wxT( "value" ), fields[jj].GetShownText( &sheet, 0, false ) ); + xproperty->AddAttribute( wxT( "value" ), fields[jj].GetShownText( &sheet, false ) ); else xproperty->AddAttribute( wxT( "value" ), fields[jj].GetText() ); } @@ -334,7 +334,7 @@ XNODE* NETLIST_EXPORTER_XML::makeSymbols( unsigned aCtl ) if( m_resolveTextVars ) // do not allow GetShownText() to add any prefix useful only when displaying // the field on screen - xproperty->AddAttribute( wxT( "value" ), sheetField.GetShownText( &sheet, 0, false ) ); + xproperty->AddAttribute( wxT( "value" ), sheetField.GetShownText( &sheet, false ) ); else xproperty->AddAttribute( wxT( "value" ), sheetField.GetText() ); } diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index fa3278adff..5b44ad016c 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1016,22 +1016,25 @@ void SCH_EDIT_FRAME::ShowFindReplaceDialog( bool aReplace ) switch( front->Type() ) { case SCH_SYMBOL_T: - findString = static_cast( front )->GetValueFieldText( true ); + { + SCH_SYMBOL* symbol = static_cast( front ); + findString = UnescapeString( symbol->GetField( VALUE_FIELD )->GetText() ); break; + } case SCH_FIELD_T: - findString = static_cast( front )->GetShownText(); + findString = UnescapeString( static_cast( front )->GetText() ); break; case SCH_LABEL_T: case SCH_GLOBAL_LABEL_T: case SCH_HIER_LABEL_T: case SCH_SHEET_PIN_T: - findString = static_cast( front )->GetShownText(); + findString = UnescapeString( static_cast( front )->GetText() ); break; case SCH_TEXT_T: - findString = static_cast( front )->GetShownText(); + findString = UnescapeString( static_cast( front )->GetText() ); if( findString.Contains( wxT( "\n" ) ) ) findString = findString.Before( '\n' ); @@ -1046,9 +1049,10 @@ void SCH_EDIT_FRAME::ShowFindReplaceDialog( bool aReplace ) if( m_findReplaceDialog ) m_findReplaceDialog->Destroy(); - m_findReplaceDialog = new DIALOG_SCH_FIND( - this, static_cast( m_findReplaceData.get() ), wxDefaultPosition, - wxDefaultSize, aReplace ? wxFR_REPLACEDIALOG : 0 ); + m_findReplaceDialog = new DIALOG_SCH_FIND( this, + static_cast( m_findReplaceData.get() ), + wxDefaultPosition, wxDefaultSize, + aReplace ? wxFR_REPLACEDIALOG : 0 ); m_findReplaceDialog->SetFindEntries( m_findStringHistoryList, findString ); m_findReplaceDialog->SetReplaceEntries( m_replaceStringHistoryList ); diff --git a/eeschema/sch_field.cpp b/eeschema/sch_field.cpp index 0c43ee7c53..7111cfea8e 100644 --- a/eeschema/sch_field.cpp +++ b/eeschema/sch_field.cpp @@ -172,13 +172,14 @@ void SCH_FIELD::SetId( int aId ) } -wxString SCH_FIELD::GetShownText( const SCH_SHEET_PATH* aPath, int aDepth, - bool aAllowExtraText ) const +wxString SCH_FIELD::GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText, + int aDepth ) const { std::function symbolResolver = [&]( wxString* token ) -> bool { - return static_cast( m_parent )->ResolveTextVar( token, aDepth + 1, aPath ); + return static_cast( m_parent )->ResolveTextVar( token, aDepth + 1, + aPath ); }; std::function sheetResolver = @@ -194,7 +195,7 @@ wxString SCH_FIELD::GetShownText( const SCH_SHEET_PATH* aPath, int aDepth, aDepth + 1 ); }; - wxString text = EDA_TEXT::GetShownText(); + wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth ); if( IsNameShown() && aAllowExtraText ) text = GetName() << wxS( ": " ) << text; @@ -322,7 +323,7 @@ void SCH_FIELD::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset VECTOR2I textpos; int penWidth = GetEffectiveTextPenWidth( aSettings->GetDefaultPenWidth() ); - if( ( !IsVisible() && !IsForceVisible() ) || GetShownText().IsEmpty() ) + if( ( !IsVisible() && !IsForceVisible() ) || GetShownText( true ).IsEmpty() ) return; COLOR4D bg = aSettings->GetBackgroundColor(); @@ -375,8 +376,9 @@ void SCH_FIELD::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset */ textpos = GetBoundingBox().Centre() + aOffset; - GRPrintText( DC, textpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_H_ALIGN_CENTER, - GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold(), font ); + GRPrintText( DC, textpos, color, GetShownText( true ), orient, GetTextSize(), + 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 ) return false; @@ -597,7 +599,7 @@ bool SCH_FIELD::Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) co // symbols with multiple parts. if( aAuxData ) { - text = parentSymbol->GetRef((SCH_SHEET_PATH*) aAuxData ); + text = parentSymbol->GetRef( (SCH_SHEET_PATH*) aAuxData ); if( SCH_ITEM::Matches( text, aSearchData ) ) return true; @@ -653,7 +655,6 @@ bool SCH_FIELD::Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) } wxString text; - bool resolve = false; // Replace in source text, not shown text bool isReplaced = false; 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: 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 ); if( isReplaced ) @@ -690,7 +691,7 @@ bool SCH_FIELD::Replace( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) case 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 ); if( isReplaced ) @@ -732,7 +733,7 @@ void SCH_FIELD::Rotate( const VECTOR2I& aCenter ) 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