diff --git a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp index 8d5bc84870..d939b26571 100644 --- a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp +++ b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp @@ -89,7 +89,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 + @@ -135,7 +135,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 0bdfc3519c..cb065d3ef0 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -479,7 +479,7 @@ EDA_TEXT::GetRenderCache( const KIFONT::FONT* aFont, const wxString& forResolved attrs.m_Angle = resolvedAngle; - font->GetLinesAsGlyphs( &m_render_cache, GetShownText(), GetDrawPos() + aOffset, + font->GetLinesAsGlyphs( &m_render_cache, forResolvedText, GetDrawPos() + aOffset, attrs ); m_render_cache_angle = resolvedAngle; m_render_cache_text = forResolvedText; @@ -527,7 +527,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() ) @@ -665,7 +665,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() ); @@ -676,7 +676,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() ); } } @@ -897,7 +898,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 { @@ -914,7 +915,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 d497cf4738..8d75e77000 100644 --- a/common/plotters/common_plot_functions.cpp +++ b/common/plotters/common_plot_functions.cpp @@ -131,10 +131,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 4e3f10148a..d9c0becf83 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 @@ -377,7 +377,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 ); @@ -385,7 +385,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 ); } @@ -395,14 +395,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 267825140b..38bee9f83b 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -337,12 +337,15 @@ wxString CONNECTION_SUBGRAPH::driverName( SCH_ITEM* aItem ) const case SCH_LABEL_T: case SCH_GLOBAL_LABEL_T: case SCH_HIER_LABEL_T: - return EscapeString( static_cast( aItem )->GetShownText( &m_sheet ), + 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 - return EscapeString( static_cast( aItem )->GetShownText(), CTX_NETNAME ); + return EscapeString( static_cast( aItem )->GetShownText( nullptr, false ), + CTX_NETNAME ); + default: wxFAIL_MSG( wxS( "Unhandled item type in GetNameForDriver" ) ); break; @@ -1379,7 +1382,7 @@ void CONNECTION_GRAPH::generateGlobalPowerPinSubGraphs() // in the symbol, but we support legacy non-power symbols with global // power connections based on invisible, power-in, pin's names. if( pin->GetLibPin()->GetParent()->IsPower() ) - connection->SetName( pin->GetParentSymbol()->GetValueFieldText( true, &sheet ) ); + connection->SetName( pin->GetParentSymbol()->GetValueFieldText( true, &sheet, false ) ); else connection->SetName( pin->GetShownName() ); @@ -2593,11 +2596,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; @@ -2937,7 +2940,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 39737a23da..ad9243e761 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 bf1341af22..417687e302 100644 --- a/eeschema/dialogs/dialog_sheet_properties.cpp +++ b/eeschema/dialogs/dialog_sheet_properties.cpp @@ -855,7 +855,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 436fe40f52..df0a030271 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->GetShownName().CmpNoCase( test_item->GetShownName() ) == 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 ) ) ) { std::shared_ptr ercItem = ERC_ITEM::Create( ERCE_UNRESOLVED_VARIABLE ); @@ -223,7 +223,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 ); @@ -236,7 +236,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 ); @@ -249,7 +249,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 ); @@ -261,7 +261,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 ); @@ -277,7 +277,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" ) ); @@ -819,14 +819,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] = std::make_pair( label, subgraph->GetSheet() ); } - else if( labelMap.at( normalized ).first->GetShownText() - != label->GetShownText() ) + else if( labelMap.at( normalized ).first->GetShownText( false ) + != label->GetShownText( false ) ) { std::shared_ptr ercItem = ERC_ITEM::Create( ERCE_SIMILAR_LABELS ); ercItem->SetItems( label, labelMap.at( normalized ).first ); diff --git a/eeschema/fields_grid_table.cpp b/eeschema/fields_grid_table.cpp index 5376f2a3dc..e7d7ea64e8 100644 --- a/eeschema/fields_grid_table.cpp +++ b/eeschema/fields_grid_table.cpp @@ -71,9 +71,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 b94ef3f5c2..dfc141a8c8 100644 --- a/eeschema/lib_field.cpp +++ b/eeschema/lib_field.cpp @@ -391,7 +391,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 ); } @@ -412,9 +412,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; @@ -517,7 +517,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() ) ); } @@ -539,10 +541,11 @@ void LIB_FIELD::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 386a50c30d..deb6143be7 100644 --- a/eeschema/lib_textbox.cpp +++ b/eeschema/lib_textbox.cpp @@ -321,15 +321,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(); @@ -461,7 +461,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 1d126e3641..3c04b1689a 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 67e260ca2c..4ef89f0662 100644 --- a/eeschema/netlist_exporters/netlist_exporter_spice.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_spice.cpp @@ -223,7 +223,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 ); @@ -335,9 +335,9 @@ void NETLIST_EXPORTER_SPICE::ReadDirectives( unsigned aNetlistOptions ) continue; 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 ff035aecd9..6194a95848 100644 --- a/eeschema/netlist_exporters/netlist_exporter_xml.cpp +++ b/eeschema/netlist_exporters/netlist_exporter_xml.cpp @@ -3,7 +3,7 @@ * * Copyright (C) 1992-2013 jp.charras at wanadoo.fr * Copyright (C) 2013-2017 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 @@ -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 685e63cca2..5c400fa751 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1066,22 +1066,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' ); @@ -1096,9 +1099,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 6951c61501..c4d19dcd90 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; @@ -643,7 +645,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 ) @@ -669,7 +670,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 ) @@ -680,7 +681,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 ) @@ -722,7 +723,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() ) ); } @@ -730,10 +731,10 @@ void SCH_FIELD::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector