From b41d446f5859de53ad1965b673cd564ca4c8a666 Mon Sep 17 00:00:00 2001 From: Jeff Young <jeff@rokeby.ie> Date: Fri, 5 May 2023 14:21:56 +0100 Subject: [PATCH] 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). --- .../3d_canvas/create_3Dgraphic_brd_items.cpp | 4 +- common/drawing_sheet/ds_draw_item.cpp | 10 +++- common/drawing_sheet/ds_painter.cpp | 2 +- common/eda_text.cpp | 13 +++-- common/plotters/common_plot_functions.cpp | 8 +-- eeschema/annotate.cpp | 10 ++-- eeschema/connection_graph.cpp | 15 +++-- eeschema/dialogs/dialog_change_symbols.cpp | 8 ++- eeschema/dialogs/dialog_label_properties.cpp | 4 +- eeschema/dialogs/dialog_sheet_properties.cpp | 2 +- eeschema/erc.cpp | 20 +++---- eeschema/fields_grid_table.cpp | 4 +- eeschema/generate_alias_info.cpp | 6 +- eeschema/lib_field.cpp | 15 +++-- eeschema/lib_field.h | 2 +- eeschema/lib_symbol.cpp | 2 +- eeschema/lib_text.cpp | 9 +-- eeschema/lib_textbox.cpp | 8 +-- eeschema/lib_textbox.h | 2 +- .../netlist_exporter_cadstar.cpp | 6 +- .../netlist_exporter_orcadpcb2.cpp | 6 +- .../netlist_exporter_spice.cpp | 6 +- .../netlist_exporter_xml.cpp | 22 +++---- eeschema/sch_edit_frame.cpp | 18 +++--- eeschema/sch_field.cpp | 39 +++++++------ eeschema/sch_field.h | 8 +-- eeschema/sch_label.cpp | 30 +++++----- eeschema/sch_label.h | 8 +-- eeschema/sch_painter.cpp | 12 ++-- eeschema/sch_pin.cpp | 12 +++- eeschema/sch_plotter.cpp | 2 +- .../sch_plugins/kicad/sch_sexpr_plugin.cpp | 4 +- eeschema/sch_reference_list.cpp | 6 +- eeschema/sch_sheet.cpp | 16 +++-- eeschema/sch_sheet.h | 5 +- eeschema/sch_sheet_path.cpp | 2 +- eeschema/sch_sheet_pin.cpp | 2 +- eeschema/sch_symbol.cpp | 58 ++++++++++++------- eeschema/sch_symbol.h | 6 +- eeschema/sch_text.cpp | 9 +-- eeschema/sch_text.h | 8 +-- eeschema/sch_textbox.cpp | 16 +++-- eeschema/sch_textbox.h | 8 ++- eeschema/sim/sim_lib_mgr.cpp | 2 +- eeschema/sim/sim_model.cpp | 4 +- eeschema/tools/ee_inspection_tool.cpp | 10 +--- eeschema/widgets/hierarchy_pane.cpp | 2 +- include/eda_text.h | 6 +- pcbnew/build_BOM_from_board.cpp | 8 +-- .../dialogs/dialog_dimension_properties.cpp | 2 +- pcbnew/dialogs/dialog_pad_properties.cpp | 4 +- pcbnew/drc/drc_test_provider_misc.cpp | 4 +- pcbnew/drc/drc_test_provider_text_dims.cpp | 4 +- pcbnew/exporters/export_idf.cpp | 6 +- pcbnew/exporters/gerber_placefile_writer.cpp | 4 +- pcbnew/exporters/place_file_exporter.cpp | 11 ++-- pcbnew/footprint.cpp | 10 ++-- pcbnew/pcb_dimension.cpp | 10 +++- pcbnew/pcb_edit_frame.cpp | 4 +- pcbnew/pcb_painter.cpp | 6 +- pcbnew/pcb_text.cpp | 18 ++++-- pcbnew/pcb_text.h | 7 +-- pcbnew/pcb_textbox.cpp | 14 +++-- pcbnew/pcb_textbox.h | 7 +-- pcbnew/plot_board_layers.cpp | 4 +- pcbnew/plot_brditems_plotter.cpp | 8 ++- pcbnew/plugins/kicad/pcb_plugin.cpp | 2 +- pcbnew/widgets/search_handlers.cpp | 2 +- qa/schematic_utils/eeschema_test_utils.cpp | 2 +- .../eeschema/test_legacy_power_symbols.cpp | 3 +- 70 files changed, 347 insertions(+), 270 deletions(-) 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 <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 @@ -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<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; + } 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<VECTOR2I> 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<SHAPE_COMPOUND> 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<SHAPE_COMPOUND> 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<SCH_TEXT*>( aItem )->GetShownText( &m_sheet ), + return EscapeString( static_cast<SCH_TEXT*>( 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<SCH_TEXT*>( aItem )->GetShownText(), CTX_NETNAME ); + return EscapeString( static_cast<SCH_TEXT*>( 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<const CONNECTION_SUBGRAPH*> CONNECTION_GRAPH::GetBusesNeedingMigrati if( labels.size() > 1 ) { 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 ) { - if( static_cast<SCH_TEXT*>( labels.at( i ) )->GetShownText() != first ) + if( static_cast<SCH_TEXT*>( 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<SCH_TEXT*>( 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 <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 * 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<ERC_ITEM> 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<ERC_ITEM> 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<SCH_SHEET*>( item )->GetPins() ) { - if( pin->GetShownText().Matches( wxT( "*${*}*" ) ) ) + if( pin->GetShownText( true ).Matches( wxT( "*${*}*" ) ) ) { std::shared_ptr<ERC_ITEM> 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<SCH_TEXT*>( item ) ) { - if( text->GetShownText().Matches( wxT( "*${*}*" ) ) ) + if( text->GetShownText( true ).Matches( wxT( "*${*}*" ) ) ) { std::shared_ptr<ERC_ITEM> 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<SCH_TEXTBOX*>( item ) ) { - if( textBox->GetShownText().Matches( wxT( "*${*}*" ) ) ) + if( textBox->GetShownText( true ).Matches( wxT( "*${*}*" ) ) ) { std::shared_ptr<ERC_ITEM> 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<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 ); erc->SetErrorMessage( _( "Unresolved text variable in drawing sheet" ) ); @@ -819,14 +819,14 @@ int ERC_TESTER::TestSimilarLabels() { 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 ) ) { 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<ERC_ITEM> 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 <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 * 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::vector<MSG_PANEL_I 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 - aList.emplace_back( _( "Text" ), UnescapeString( GetText() ) ); + aList.emplace_back( _( "Text" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) ); aList.emplace_back( _( "Visible" ), IsVisible() ? _( "Yes" ) : _( "No" ) ); diff --git a/eeschema/lib_field.h b/eeschema/lib_field.h index f41d7c8506..1ee785a5d1 100644 --- a/eeschema/lib_field.h +++ b/eeschema/lib_field.h @@ -152,7 +152,7 @@ public: */ 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; diff --git a/eeschema/lib_symbol.cpp b/eeschema/lib_symbol.cpp index 3d37e2ee0f..5a590d44df 100644 --- a/eeschema/lib_symbol.cpp +++ b/eeschema/lib_symbol.cpp @@ -925,7 +925,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 e10b4500b3..04a00ebb53 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::vector<MSG_PANEL_IT LIB_ITEM::GetMsgPanelInfo( aFrame, aList ); // 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" ) ); @@ -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<VECTOR2I> 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 <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 * 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 <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 * 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<SCH_TEXT*>( item )->GetShownText(); + text = static_cast<SCH_TEXT*>( item )->GetShownText( &sheet, false ); else if( item->Type() == SCH_TEXTBOX_T ) - text = static_cast<SCH_TEXTBOX*>( item )->GetShownText(); + text = static_cast<SCH_TEXTBOX*>( 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 <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 * 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<SCH_SYMBOL*>( front )->GetValueFieldText( true ); + { + SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( front ); + findString = UnescapeString( symbol->GetField( VALUE_FIELD )->GetText() ); break; + } case SCH_FIELD_T: - findString = static_cast<SCH_FIELD*>( front )->GetShownText(); + findString = UnescapeString( static_cast<SCH_FIELD*>( 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<SCH_LABEL_BASE*>( front )->GetShownText(); + findString = UnescapeString( static_cast<SCH_LABEL_BASE*>( front )->GetText() ); break; case SCH_TEXT_T: - findString = static_cast<SCH_TEXT*>( front )->GetShownText(); + findString = UnescapeString( static_cast<SCH_TEXT*>( 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<SCH_SEARCH_DATA*>( m_findReplaceData.get() ), wxDefaultPosition, - wxDefaultSize, aReplace ? wxFR_REPLACEDIALOG : 0 ); + m_findReplaceDialog = new DIALOG_SCH_FIND( this, + static_cast<SCH_SEARCH_DATA*>( 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<bool( wxString* )> symbolResolver = [&]( 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 = @@ -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<MSG_PANEL_I { 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 - aList.emplace_back( _( "Text" ), UnescapeString( GetText() ) ); + aList.emplace_back( _( "Text" ), KIUI::EllipsizeStatusText( aFrame, GetText() ) ); aList.emplace_back( _( "Visible" ), IsVisible() ? _( "Yes" ) : _( "No" ) ); @@ -901,7 +902,7 @@ BITMAPS SCH_FIELD::GetMenuImage() const bool SCH_FIELD::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const { // Do not hit test hidden or empty fields. - if( !IsVisible() || GetShownText().IsEmpty() ) + if( !IsVisible() || GetShownText( true ).IsEmpty() ) return false; BOX2I rect = GetBoundingBox(); @@ -921,7 +922,7 @@ bool SCH_FIELD::HitTest( const VECTOR2I& aPosition, int aAccuracy ) const bool SCH_FIELD::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) const { // Do not hit test hidden fields. - if( !IsVisible() || GetShownText().IsEmpty() ) + if( !IsVisible() || GetShownText( true ).IsEmpty() ) return false; BOX2I rect = aRect; @@ -943,7 +944,7 @@ bool SCH_FIELD::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) co void SCH_FIELD::Plot( PLOTTER* aPlotter, bool aBackground ) const { - if( GetShownText().IsEmpty() || aBackground ) + if( GetShownText( true ).IsEmpty() || aBackground ) return; RENDER_SETTINGS* settings = aPlotter->RenderSettings(); @@ -1023,7 +1024,7 @@ void SCH_FIELD::Plot( PLOTTER* aPlotter, bool aBackground ) const attrs.m_Angle = orient; attrs.m_Multiline = false; - aPlotter->PlotText( textpos, color, GetShownText(), attrs, font ); + aPlotter->PlotText( textpos, color, GetShownText( true ), attrs, font ); if( IsHypertext() ) { diff --git a/eeschema/sch_field.h b/eeschema/sch_field.h index f787f6048a..a4e3106efa 100644 --- a/eeschema/sch_field.h +++ b/eeschema/sch_field.h @@ -126,12 +126,12 @@ public: void SetId( int aId ); - wxString GetShownText( const SCH_SHEET_PATH* aPath, int aDepth = 0, - bool aAllowExtraText = true ) const; + wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText, + 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; diff --git a/eeschema/sch_label.cpp b/eeschema/sch_label.cpp index 6f534f7ce3..aeaaaaf90f 100644 --- a/eeschema/sch_label.cpp +++ b/eeschema/sch_label.cpp @@ -587,7 +587,7 @@ bool SCH_LABEL_BASE::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* toke { if( token->IsSameAs( field.GetName() ) ) { - *token = field.GetShownText( aDepth + 1 ); + *token = field.GetShownText( false, aDepth + 1 ); return true; } } @@ -616,7 +616,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 = [&]( wxString* token ) -> bool @@ -624,7 +625,7 @@ wxString SCH_LABEL_BASE::GetShownText( const SCH_SHEET_PATH* aPath, int 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 { @@ -998,7 +999,7 @@ void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground ) const } else { - aPlotter->PlotText( textpos, color, GetShownText(), attrs, font ); + aPlotter->PlotText( textpos, color, GetShownText( true ), attrs, font ); if( s_poly.size() ) aPlotter->PlotPoly( s_poly, FILL_T::NO_FILL, penWidth ); @@ -1008,8 +1009,8 @@ void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground ) const if( connection ) { - properties.emplace_back( - wxString::Format( wxT( "!%s = %s" ), _( "Net" ), connection->Name() ) ); + properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), _( "Net" ), + connection->Name() ) ); properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), _( "Resolved netclass" ), GetEffectiveNetClass()->GetName() ) ); @@ -1017,8 +1018,8 @@ void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground ) const for( const SCH_FIELD& field : GetFields() ) { - properties.emplace_back( - wxString::Format( wxT( "!%s = %s" ), field.GetName(), field.GetShownText() ) ); + properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), field.GetName(), + field.GetShownText( false ) ) ); } if( !properties.empty() ) @@ -1026,7 +1027,8 @@ void SCH_LABEL_BASE::Plot( PLOTTER* aPlotter, bool aBackground ) const if( Type() == SCH_HIER_LABEL_T ) { - aPlotter->Bookmark( GetBodyBoundingBox(), GetShownText(), _( "Hierarchical Labels" ) ); + aPlotter->Bookmark( GetBodyBoundingBox(), GetShownText( false ), + _( "Hierarchical Labels" ) ); } } @@ -1111,7 +1113,7 @@ const BOX2I SCH_LABEL::GetBodyBoundingBox() 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() ) ); } @@ -1289,8 +1291,8 @@ wxString SCH_DIRECTIVE_LABEL::GetItemDescription( UNITS_PROVIDER* aUnitsProvider else { return wxString::Format( _( "Directive Label [%s %s]" ), - m_fields[0].GetName(), - m_fields[0].GetShownText() ); + UnescapeString( m_fields[0].GetName() ), + KIUI::EllipsizeMenuText( m_fields[0].GetText() ) ); } } @@ -1565,7 +1567,7 @@ void SCH_GLOBALLABEL::CreateGraphicShape( const RENDER_SETTINGS* aRenderSettings 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() ) ); } @@ -1699,7 +1701,7 @@ VECTOR2I SCH_HIERLABEL::GetSchematicTextOffset( const RENDER_SETTINGS* aSettings wxString SCH_HIERLABEL::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "Hierarchical Label '%s'" ), - KIUI::EllipsizeMenuText( GetShownText() ) ); + KIUI::EllipsizeMenuText( GetText() ) ); } diff --git a/eeschema/sch_label.h b/eeschema/sch_label.h index b04c0d9b88..a0d7e2eac7 100644 --- a/eeschema/sch_label.h +++ b/eeschema/sch_label.h @@ -143,12 +143,12 @@ public: */ virtual bool ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, int aDepth ) const; - wxString GetShownText( const SCH_SHEET_PATH* aPath, int aDepth = 0, - bool aAllowExtraText = true ) const override; + wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText, + 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; diff --git a/eeschema/sch_painter.cpp b/eeschema/sch_painter.cpp index ec336dd9ca..cdbbfd17ed 100644 --- a/eeschema/sch_painter.cpp +++ b/eeschema/sch_painter.cpp @@ -1057,7 +1057,7 @@ void SCH_PAINTER::draw( const LIB_FIELD *aField, int aLayer, bool aDimmed ) if( drawingShadows ) 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 @@ -1108,7 +1108,7 @@ void SCH_PAINTER::draw( const LIB_TEXT* aText, int aLayer, bool aDimmed ) } else { - wxString shownText( aText->GetShownText() ); + wxString shownText( aText->GetShownText( true ) ); VECTOR2D pos = bBox.Centre(); TEXT_ATTRIBUTES attrs = aText->GetAttributes(); @@ -1165,7 +1165,7 @@ void SCH_PAINTER::draw( const LIB_TEXTBOX* aTextBox, int aLayer, bool aDimmed ) auto drawText = [&]() { - wxString shownText = aTextBox->GetShownText(); + wxString shownText = aTextBox->GetShownText( true ); TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes(); attrs.m_Angle = aTextBox->GetDrawRotation(); @@ -2089,7 +2089,7 @@ void SCH_PAINTER::draw( const SCH_TEXT *aText, int aLayer ) m_gal->SetStrokeColor( color ); m_gal->SetFillColor( color ); - wxString shownText( aText->GetShownText() ); + wxString shownText( aText->GetShownText( true ) ); VECTOR2I text_offset = aText->GetSchematicTextOffset( &m_schSettings ); TEXT_ATTRIBUTES attrs = aText->GetAttributes(); KIFONT::FONT* font = getFont( aText ); @@ -2185,7 +2185,7 @@ void SCH_PAINTER::draw( const SCH_TEXTBOX* aTextBox, int aLayer ) auto drawText = [&]() { - wxString shownText = aTextBox->GetShownText(); + wxString shownText = aTextBox->GetShownText( true ); TEXT_ATTRIBUTES attrs = aTextBox->GetAttributes(); attrs.m_Angle = aTextBox->GetDrawRotation(); @@ -2488,7 +2488,7 @@ void SCH_PAINTER::draw( const SCH_FIELD* aField, int aLayer, bool aDimmed ) return; } - wxString shownText = aField->GetShownText(); + wxString shownText = aField->GetShownText( true ); if( shownText.IsEmpty() ) return; diff --git a/eeschema/sch_pin.cpp b/eeschema/sch_pin.cpp index 7c7a7ebdc8..488af3ece6 100644 --- a/eeschema/sch_pin.cpp +++ b/eeschema/sch_pin.cpp @@ -195,7 +195,7 @@ SCH_SYMBOL* SCH_PIN::GetParentSymbol() const wxString SCH_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( "Symbol %s %s", - GetParentSymbol()->GetField( REFERENCE_FIELD )->GetShownText(), + UnescapeString( GetParentSymbol()->GetField( REFERENCE_FIELD )->GetText() ), m_libPin->GetItemDescription( aUnitsProvider ) ); } @@ -231,7 +231,9 @@ void SCH_PIN::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITE SCH_SHEET_PATH* currentSheet = schframe ? &schframe->GetCurrentSheet() : nullptr; 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( !IsConnectivityDirty() && dynamic_cast<SCH_EDIT_FRAME*>( aFrame ) ) @@ -274,10 +276,14 @@ wxString SCH_PIN::GetDefaultNetName( const SCH_SHEET_PATH& aPath, bool aForceNoC if( IsGlobalPower() ) { if( GetLibPin()->GetParent()->IsPower() ) - return EscapeString( GetParentSymbol()->GetValueFieldText( true, &aPath ), + { + return EscapeString( GetParentSymbol()->GetValueFieldText( true, &aPath, false ), CTX_NETNAME ); + } else + { return EscapeString( m_libPin->GetName(), CTX_NETNAME ); + } } std::lock_guard<std::recursive_mutex> lock( m_netmap_mutex ); diff --git a/eeschema/sch_plotter.cpp b/eeschema/sch_plotter.cpp index 1cd5198761..632671e81e 100644 --- a/eeschema/sch_plotter.cpp +++ b/eeschema/sch_plotter.cpp @@ -195,7 +195,7 @@ void SCH_PLOTTER::createPDFFile( const SCH_PLOT_SETTINGS& aPlotSettings, plotter->ClosePage(); setupPlotPagePDF( plotter, screen, aPlotSettings ); plotter->StartPage( sheetList[i].GetPageNumber(), - sheetList[i].Last()->GetFields()[SHEETNAME].GetShownText() ); + sheetList[i].Last()->GetFields()[SHEETNAME].GetShownText( false ) ); } plotOneSheetPDF( plotter, screen, aPlotSettings ); diff --git a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp index 700980af8a..32e509aad8 100644 --- a/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp +++ b/eeschema/sch_plugins/kicad/sch_sexpr_plugin.cpp @@ -752,11 +752,11 @@ void SCH_SEXPR_PLUGIN::saveSymbol( SCH_SYMBOL* aSymbol, const SCHEMATIC& aSchema } else if( id == VALUE_FIELD ) { - field.SetText( aSymbol->GetValueFieldText( false ) ); + field.SetText( aSymbol->GetField( VALUE_FIELD )->GetText() ); } else if( id == FOOTPRINT_FIELD ) { - field.SetText( aSymbol->GetFootprintFieldText( false ) ); + field.SetText( aSymbol->GetField( FOOTPRINT_FIELD )->GetText() ); } } diff --git a/eeschema/sch_reference_list.cpp b/eeschema/sch_reference_list.cpp index 30a9ac2ee7..13496cd126 100644 --- a/eeschema/sch_reference_list.cpp +++ b/eeschema/sch_reference_list.cpp @@ -822,7 +822,7 @@ SCH_REFERENCE::SCH_REFERENCE( SCH_SYMBOL* aSymbol, LIB_SYMBOL* aLibSymbol, m_libPart = aLibSymbol; // Warning: can be nullptr for orphan symbols // (i.e. with a symbol library not found) m_unit = aSymbol->GetUnitSelection( &aSheetPath ); - m_footprint = aSymbol->GetFootprintFieldText( true ); + m_footprint = aSymbol->GetFootprintFieldText( true, &aSheetPath, false ); m_sheetPath = aSheetPath; m_isNew = false; m_flag = 0; @@ -838,10 +838,10 @@ SCH_REFERENCE::SCH_REFERENCE( SCH_SYMBOL* aSymbol, LIB_SYMBOL* aLibSymbol, m_numRef = -1; - if( aSymbol->GetValueFieldText( false ).IsEmpty() ) + if( aSymbol->GetValueFieldText( false, &aSheetPath, false ).IsEmpty() ) aSymbol->SetValueFieldText( wxT( "~" ) ); - m_value = aSymbol->GetValueFieldText( false ); + m_value = aSymbol->GetValueFieldText( false, &aSheetPath, false ); } diff --git a/eeschema/sch_sheet.cpp b/eeschema/sch_sheet.cpp index 5e85990cf5..80ef24634e 100644 --- a/eeschema/sch_sheet.cpp +++ b/eeschema/sch_sheet.cpp @@ -248,7 +248,7 @@ bool SCH_SHEET::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, in { 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; } } @@ -257,7 +257,7 @@ bool SCH_SHEET::ResolveTextVar( const SCH_SHEET_PATH* aPath, wxString* token, in { 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; } } @@ -795,7 +795,9 @@ int SCH_SHEET::CountSheets() const 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 ) ) { @@ -805,7 +807,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( _( "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() ) ); } @@ -1052,7 +1056,7 @@ void SCH_SHEET::RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction wxString SCH_SHEET::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "Hierarchical Sheet %s" ), - m_fields[ SHEETNAME ].GetText() ); + KIUI::EllipsizeMenuText( m_fields[ SHEETNAME ].GetText() ) ); } @@ -1123,7 +1127,7 @@ void SCH_SHEET::Plot( PLOTTER* aPlotter, bool aBackground ) const { properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), field.GetName(), - field.GetShownText() ) ); + field.GetShownText( false ) ) ); } aPlotter->HyperlinkMenu( GetBoundingBox(), properties ); diff --git a/eeschema/sch_sheet.h b/eeschema/sch_sheet.h index 56dffd7445..1db803ce0f 100644 --- a/eeschema/sch_sheet.h +++ b/eeschema/sch_sheet.h @@ -100,7 +100,10 @@ public: */ void SetFields( const std::vector<SCH_FIELD>& aFields ); - wxString GetShownName() const { return m_fields[SHEETNAME].GetShownText(); } + wxString GetShownName( bool aAllowExtraText ) const + { + return m_fields[SHEETNAME].GetShownText( aAllowExtraText ); + } wxString GetName() const { return m_fields[ SHEETNAME ].GetText(); } void SetName( const wxString& aName ) { m_fields[ SHEETNAME ].SetText( aName ); } diff --git a/eeschema/sch_sheet_path.cpp b/eeschema/sch_sheet_path.cpp index 365d3a7326..7ccaa239b4 100644 --- a/eeschema/sch_sheet_path.cpp +++ b/eeschema/sch_sheet_path.cpp @@ -311,7 +311,7 @@ wxString SCH_SHEET_PATH::PathHumanReadable( bool aUseShortRootName, // Start at 1 since we've already processed the root sheet. 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( "/" ) ) s = s.Left( s.length() - 1 ); diff --git a/eeschema/sch_sheet_pin.cpp b/eeschema/sch_sheet_pin.cpp index 3d0ff2f3b0..cf13dfb8f6 100644 --- a/eeschema/sch_sheet_pin.cpp +++ b/eeschema/sch_sheet_pin.cpp @@ -328,7 +328,7 @@ void SCH_SHEET_PIN::GetEndPoints( std::vector<DANGLING_END_ITEM>& aItemList ) wxString SCH_SHEET_PIN::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "Hierarchical Sheet Pin %s" ), - KIUI::EllipsizeMenuText( GetShownText() ) ); + KIUI::EllipsizeMenuText( GetText() ) ); } diff --git a/eeschema/sch_symbol.cpp b/eeschema/sch_symbol.cpp index 3a0df405d7..c90bacc155 100644 --- a/eeschema/sch_symbol.cpp +++ b/eeschema/sch_symbol.cpp @@ -856,10 +856,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 ) - return GetField( VALUE_FIELD )->GetShownText( aPath ); + return GetField( VALUE_FIELD )->GetShownText( aPath, aAllowExtraText ); return GetField( VALUE_FIELD )->GetText(); } @@ -871,10 +872,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 ) - return GetField( FOOTPRINT_FIELD )->GetShownText(); + return GetField( FOOTPRINT_FIELD )->GetShownText( aPath, aAllowExtraText ); return GetField( FOOTPRINT_FIELD )->GetText(); } @@ -928,7 +930,7 @@ void SCH_SYMBOL::GetFields( std::vector<SCH_FIELD*>& aVector, bool aVisibleOnly { if( aVisibleOnly ) { - if( !field.IsVisible() || field.GetShownText().IsEmpty() ) + if( !field.IsVisible() || field.GetShownText( nullptr, true ).IsEmpty() ) continue; } @@ -1239,11 +1241,11 @@ bool SCH_SYMBOL::ResolveTextVar( wxString* token, int aDepth, const SCH_SHEET_PA if( i == REFERENCE_FIELD ) *token = GetRef( &schematic->CurrentSheet(), true ); else if( i == VALUE_FIELD ) - *token = GetValueFieldText( true ); + *token = GetValueFieldText( true, aPath, false ); else if( i == FOOTPRINT_FIELD ) - *token = GetFootprintFieldText( true ); + *token = GetFootprintFieldText( true, aPath, false ); else - *token = m_fields[ i ].GetShownText( aDepth + 1 ); + *token = m_fields[ i ].GetShownText( aPath, false, aDepth + 1 ); return true; } @@ -1254,7 +1256,7 @@ bool SCH_SYMBOL::ResolveTextVar( wxString* token, int aDepth, const SCH_SHEET_PA if( token->IsSameAs( m_fields[ i ].GetName() ) || 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; } } @@ -1276,7 +1278,7 @@ bool SCH_SYMBOL::ResolveTextVar( wxString* token, int aDepth, const SCH_SHEET_PA { wxString footprint; - footprint = GetFootprintFieldText( true ); + footprint = GetFootprintFieldText( true, aPath, false ); wxArrayString parts = wxSplit( footprint, ':' ); @@ -1287,7 +1289,7 @@ bool SCH_SYMBOL::ResolveTextVar( wxString* token, int aDepth, const SCH_SHEET_PA { wxString footprint; - footprint = GetFootprintFieldText( true ); + footprint = GetFootprintFieldText( true, aPath, false ); wxArrayString parts = wxSplit( footprint, ':' ); @@ -1750,14 +1752,21 @@ void SCH_SYMBOL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ { 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 { - aList.emplace_back( _( "Reference" ), GetRef( currentSheet ) ); - aList.emplace_back( _( "Value" ), GetValueFieldText( true ) ); + aList.emplace_back( _( "Reference" ), + UnescapeString( GetRef( currentSheet ) ) ); + + // Don't use GetShownText(); we want to see the variable references here + aList.emplace_back( _( "Value" ), + KIUI::EllipsizeStatusText( aFrame, GetField( VALUE_FIELD )->GetText() ) ); addExcludes(); - aList.emplace_back( _( "Name" ), UnescapeString( GetLibId().GetLibItemName() ) ); + aList.emplace_back( _( "Name" ), + KIUI::EllipsizeStatusText( aFrame, GetLibId().GetLibItemName() ) ); } #if 0 // Display symbol flags, for debug only @@ -1785,7 +1794,8 @@ void SCH_SYMBOL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ } // 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() ) msg = _( "<Unknown>" ); @@ -1800,9 +1810,12 @@ void SCH_SYMBOL::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ else { aList.emplace_back( _( "Reference" ), GetRef( currentSheet ) ); - aList.emplace_back( _( "Value" ), GetValueFieldText( true ) ); + // Don't use GetShownText(); we want to see the variable references here + aList.emplace_back( _( "Value" ), + KIUI::EllipsizeStatusText( aFrame, GetField( VALUE_FIELD )->GetText() ) ); addExcludes(); - aList.emplace_back( _( "Name" ), UnescapeString( GetLibId().GetLibItemName() ) ); + aList.emplace_back( _( "Name" ), + KIUI::EllipsizeStatusText( aFrame, GetLibId().GetLibItemName() ) ); wxString libNickname = GetLibId().GetLibNickname(); @@ -1999,8 +2012,8 @@ LIB_ITEM* SCH_SYMBOL::GetDrawItem( const VECTOR2I& aPosition, KICAD_T aType ) wxString SCH_SYMBOL::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const { return wxString::Format( _( "Symbol %s [%s]" ), - GetField( REFERENCE_FIELD )->GetShownText(), - UnescapeString( GetLibId().GetLibItemName() ) ); + KIUI::EllipsizeMenuText( GetField( REFERENCE_FIELD )->GetText() ), + KIUI::EllipsizeMenuText( GetLibId().GetLibItemName() ) ); } @@ -2264,12 +2277,13 @@ void SCH_SYMBOL::Plot( PLOTTER* aPlotter, bool aBackground ) const // Plot attributes to a hypertext menu std::vector<wxString> properties; + SCH_SHEET_PATH* sheet = &Schematic()->CurrentSheet(); for( const SCH_FIELD& field : GetFields() ) { properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), field.GetName(), - field.GetShownText() ) ); + field.GetShownText( sheet, false) ) ); } properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), @@ -2287,7 +2301,7 @@ void SCH_SYMBOL::Plot( PLOTTER* aPlotter, bool aBackground ) const aPlotter->EndBlock( nullptr ); if( !m_part->IsPower() ) - aPlotter->Bookmark( GetBoundingBox(), GetField( REFERENCE_FIELD )->GetShownText(), _("Symbols") ); + aPlotter->Bookmark( GetBoundingBox(), GetRef( sheet ), _( "Symbols" ) ); } } diff --git a/eeschema/sch_symbol.h b/eeschema/sch_symbol.h index 2461487109..272b3e8777 100644 --- a/eeschema/sch_symbol.h +++ b/eeschema/sch_symbol.h @@ -465,10 +465,12 @@ public: 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 ); - const wxString GetFootprintFieldText( bool aResolve ) const; + const wxString GetFootprintFieldText( bool aResolve, const SCH_SHEET_PATH* aPath, + bool aAllowExtraText ) const; void SetFootprintFieldText( const wxString& aFootprint ); /** diff --git a/eeschema/sch_text.cpp b/eeschema/sch_text.cpp index 2f6ed6712a..196f12385d 100644 --- a/eeschema/sch_text.cpp +++ b/eeschema/sch_text.cpp @@ -346,7 +346,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; @@ -367,7 +368,7 @@ wxString SCH_TEXT::GetShownText( const SCH_SHEET_PATH* aPath, int aDepth, bool a return false; }; - wxString text = EDA_TEXT::GetShownText(); + wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth ); if( text == wxS( "~" ) ) // Legacy placeholder for empty string { @@ -395,7 +396,7 @@ void SCH_TEXT::DoHypertextAction( EDA_DRAW_FRAME* aFrame ) 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() ) ); } @@ -471,7 +472,7 @@ void SCH_TEXT::Plot( PLOTTER* aPlotter, bool aBackground ) const std::vector<VECTOR2I> positions; wxArrayString strings_list; - wxStringSplit( GetShownText(), strings_list, '\n' ); + wxStringSplit( GetShownText( true ), strings_list, '\n' ); positions.reserve( strings_list.Count() ); GetLinePositions( positions, (int) strings_list.Count() ); diff --git a/eeschema/sch_text.h b/eeschema/sch_text.h index dfe02a80f0..6b811f6b6a 100644 --- a/eeschema/sch_text.h +++ b/eeschema/sch_text.h @@ -128,12 +128,12 @@ public: return wxT( "SCH_TEXT" ); } - virtual wxString GetShownText( const SCH_SHEET_PATH* aPath, int aDepth = 0, - bool aAllowExtraText = true ) const; + virtual wxString GetShownText( const SCH_SHEET_PATH* aPath, bool aAllowExtraText, + 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 diff --git a/eeschema/sch_textbox.cpp b/eeschema/sch_textbox.cpp index 6878da9977..cbc87a79bc 100644 --- a/eeschema/sch_textbox.cpp +++ b/eeschema/sch_textbox.cpp @@ -285,12 +285,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 = [&]( wxString* token ) -> bool { - if( SCH_SHEET* sheet = Schematic()->CurrentSheet().Last() ) + if( sheet ) { if( sheet->ResolveTextVar( token, aDepth + 1 ) ) return true; @@ -299,7 +307,7 @@ wxString SCH_TEXTBOX::GetShownText( int aDepth, bool aAllowExtraText ) const return false; }; - wxString text = EDA_TEXT::GetShownText(); + wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth ); if( HasTextVars() ) { @@ -412,7 +420,7 @@ void SCH_TEXTBOX::Plot( PLOTTER* aPlotter, bool aBackground ) const std::vector<VECTOR2I> positions; wxArrayString strings_list; - wxStringSplit( GetShownText(), strings_list, '\n' ); + wxStringSplit( GetShownText( true ), strings_list, '\n' ); positions.reserve( strings_list.Count() ); GetLinePositions( positions, (int) strings_list.Count() ); diff --git a/eeschema/sch_textbox.h b/eeschema/sch_textbox.h index e10f852e43..ae8e4d74bf 100644 --- a/eeschema/sch_textbox.h +++ b/eeschema/sch_textbox.h @@ -55,7 +55,13 @@ public: 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 { diff --git a/eeschema/sim/sim_lib_mgr.cpp b/eeschema/sim/sim_lib_mgr.cpp index 3577b137a0..5d5ac8d42e 100644 --- a/eeschema/sim/sim_lib_mgr.cpp +++ b/eeschema/sim/sim_lib_mgr.cpp @@ -200,7 +200,7 @@ SIM_LIBRARY::MODEL SIM_LIB_MGR::CreateModel( const SCH_SHEET_PATH* aSheetPath, S if( field.GetId() == REFERENCE_FIELD ) fields.back().SetText( aSymbol.GetRef( aSheetPath ) ); else - fields.back().SetText( field.GetShownText( aSheetPath, 0, false ) ); + fields.back().SetText( field.GetShownText( aSheetPath, false ) ); } wxString deviceType; diff --git a/eeschema/sim/sim_model.cpp b/eeschema/sim/sim_model.cpp index 11d364a360..72a3ef3d18 100644 --- a/eeschema/sim/sim_model.cpp +++ b/eeschema/sim/sim_model.cpp @@ -627,7 +627,7 @@ std::string SIM_MODEL::GetFieldValue( const std::vector<T>* aFields, const wxStr { if( field.GetName() == aFieldName ) { - return aResolve ? field.GetShownText( 0, false ).ToStdString() + return aResolve ? field.GetShownText( false ).ToStdString() : field.GetText().ToStdString(); } } @@ -1420,7 +1420,7 @@ void SIM_MODEL::MigrateSimModel( T_symbol& aSymbol, const PROJECT* aProject ) // SPICE. Here we remap them to 'r0' and 'r1'. 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 ) ) { diff --git a/eeschema/tools/ee_inspection_tool.cpp b/eeschema/tools/ee_inspection_tool.cpp index 20232818de..00aa90e1ad 100644 --- a/eeschema/tools/ee_inspection_tool.cpp +++ b/eeschema/tools/ee_inspection_tool.cpp @@ -418,13 +418,9 @@ int EE_INSPECTION_TOOL::ShowDatasheet( const TOOL_EVENT& aEvent ) SCH_SYMBOL* symbol = (SCH_SYMBOL*) selection.Front(); - // Use GetShownText() to resolve any text variables, but uve only field value - // (do not allow adding field name ) - SCH_FIELD* tmp = symbol->GetField( DATASHEET_FIELD ); - bool name_shown = tmp->IsNameShown(); - tmp->SetNameShown( false ); - datasheet = tmp->GetShownText(); - tmp->SetNameShown( name_shown ); + // Use GetShownText() to resolve any text variables, but don't allow adding extra text + // (ie: the field name) + datasheet = symbol->GetField( DATASHEET_FIELD )->GetShownText( false ); } if( datasheet.IsEmpty() || datasheet == wxS( "~" ) ) diff --git a/eeschema/widgets/hierarchy_pane.cpp b/eeschema/widgets/hierarchy_pane.cpp index 39238d4e6d..cf70e045dd 100644 --- a/eeschema/widgets/hierarchy_pane.cpp +++ b/eeschema/widgets/hierarchy_pane.cpp @@ -124,7 +124,7 @@ void HIERARCHY_PANE::buildHierarchyTree( SCH_SHEET_PATH* aList, const wxTreeItem SCH_SHEET* sheet = static_cast<SCH_SHEET*>( aItem ); aList->push_back( sheet ); - wxString sheetName = formatPageString( sheet->GetFields()[SHEETNAME].GetShownText(), + wxString sheetName = formatPageString( sheet->GetFields()[SHEETNAME].GetShownText( false ), aList->GetPageNumber() ); wxTreeItemId child = m_tree->AppendItem( aParent, sheetName, 0, 1 ); m_tree->SetItemData( child, new TREE_ITEM_DATA( *aList ) ); diff --git a/include/eda_text.h b/include/eda_text.h index f48c11ea0a..9ff4a5ec87 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -89,13 +89,13 @@ public: /** * 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, * 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). + * @param aDepth is used to prevent infinite recursions and loops when expanding + * text variables. */ - virtual wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const + virtual wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const { return m_shown_text; } diff --git a/pcbnew/build_BOM_from_board.cpp b/pcbnew/build_BOM_from_board.cpp index b7861d9bc2..b9ec4c39da 100644 --- a/pcbnew/build_BOM_from_board.cpp +++ b/pcbnew/build_BOM_from_board.cpp @@ -2,7 +2,7 @@ * 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) 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 * 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_Ref.Append( wxT( ", " ), 1 ); - curEntry->m_Ref.Append( footprint->Reference().GetShownText() ); + curEntry->m_Ref.Append( footprint->Reference().GetShownText( false ) ); curEntry->m_Count++; valExist = true; @@ -146,8 +146,8 @@ void PCB_EDIT_FRAME::RecreateBOMFileFromBoard( wxCommandEvent& aEvent ) { BOM_ENTRY* newEntry = new BOM_ENTRY(); newEntry->m_Id = i++; - newEntry->m_Val = footprint->Value().GetShownText(); - newEntry->m_Ref = footprint->Reference().GetShownText(); + newEntry->m_Val = footprint->Value().GetShownText( false ); + newEntry->m_Ref = footprint->Reference().GetShownText( false ); newEntry->m_FPID = footprint->GetFPID(); newEntry->m_Count = 1; list.Append( newEntry ); diff --git a/pcbnew/dialogs/dialog_dimension_properties.cpp b/pcbnew/dialogs/dialog_dimension_properties.cpp index 71a992d839..81f192e1cf 100644 --- a/pcbnew/dialogs/dialog_dimension_properties.cpp +++ b/pcbnew/dialogs/dialog_dimension_properties.cpp @@ -442,5 +442,5 @@ void DIALOG_DIMENSION_PROPERTIES::updateDimensionFromDialog( PCB_DIMENSION_BASE* void DIALOG_DIMENSION_PROPERTIES::updatePreviewText() { updateDimensionFromDialog( m_previewDimension ); - m_staticTextPreview->SetLabel( m_previewDimension->GetShownText() ); + m_staticTextPreview->SetLabel( m_previewDimension->GetShownText( true ) ); } diff --git a/pcbnew/dialogs/dialog_pad_properties.cpp b/pcbnew/dialogs/dialog_pad_properties.cpp index 614087b409..7a06fed6e8 100644 --- a/pcbnew/dialogs/dialog_pad_properties.cpp +++ b/pcbnew/dialogs/dialog_pad_properties.cpp @@ -499,8 +499,8 @@ void DIALOG_PAD_PROPERTIES::initValues() // Display parent footprint info msg.Printf( _("Footprint %s (%s), %s, rotated %g deg"), - footprint->Reference().GetShownText(), - footprint->Value().GetShownText(), + footprint->Reference().GetShownText( false ), + footprint->Value().GetShownText( false ), footprint->IsFlipped() ? _( "back side (mirrored)" ) : _( "front side" ), footprint->GetOrientation().AsDegrees() ); diff --git a/pcbnew/drc/drc_test_provider_misc.cpp b/pcbnew/drc/drc_test_provider_misc.cpp index 33abca40e2..3093933037 100644 --- a/pcbnew/drc/drc_test_provider_misc.cpp +++ b/pcbnew/drc/drc_test_provider_misc.cpp @@ -287,7 +287,7 @@ void DRC_TEST_PROVIDER_MISC::testTextVars() 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 ); drcItem->SetItems( item ); @@ -323,7 +323,7 @@ void DRC_TEST_PROVIDER_MISC::testTextVars() 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 ); drcItem->SetItems( drawingSheet ); diff --git a/pcbnew/drc/drc_test_provider_text_dims.cpp b/pcbnew/drc/drc_test_provider_text_dims.cpp index 607788886f..aaff183d5c 100644 --- a/pcbnew/drc/drc_test_provider_text_dims.cpp +++ b/pcbnew/drc/drc_test_provider_text_dims.cpp @@ -1,7 +1,7 @@ /* * 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 * modify it under the terms of the GNU General Public License @@ -152,7 +152,7 @@ bool DRC_TEST_PROVIDER_TEXT_DIMS::Run() if( !constraint.Value().HasMin() ) return true; - auto* glyphs = text->GetRenderCache( font, text->GetShownText() ); + auto* glyphs = text->GetRenderCache( font, text->GetShownText( true ) ); bool collapsedStroke = false; bool collapsedArea = false; diff --git a/pcbnew/exporters/export_idf.cpp b/pcbnew/exporters/export_idf.cpp index 8b1619824b..fb2a640719 100644 --- a/pcbnew/exporters/export_idf.cpp +++ b/pcbnew/exporters/export_idf.cpp @@ -271,7 +271,7 @@ UseBoundingBox: static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD& aIDFBoard ) { // 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 footprintBasePath = wxEmptyString; @@ -295,7 +295,7 @@ static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD 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, // otherwise associated parts of the footprint must be marked NOREFDES. @@ -440,7 +440,7 @@ static void idf_export_footprint( BOARD* aPcb, FOOTPRINT* aFootprint, IDF3_BOARD 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 // when writing out the placement data due to conflicting diff --git a/pcbnew/exporters/gerber_placefile_writer.cpp b/pcbnew/exporters/gerber_placefile_writer.cpp index a328969a5b..6880e3c234 100644 --- a/pcbnew/exporters/gerber_placefile_writer.cpp +++ b/pcbnew/exporters/gerber_placefile_writer.cpp @@ -131,7 +131,7 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER // Add object attribute: component reference to flash (mainly useful for users) // using quoted UTF8 string - wxString ref = ConvertNotAllowedCharsInGerber( footprint->Reference().GetShownText(), + wxString ref = ConvertNotAllowedCharsInGerber( footprint->Reference().GetShownText( false ), allowUtf8, true ); gbr_metadata.SetCmpReference( ref ); @@ -152,7 +152,7 @@ int PLACEFILE_GERBER_WRITER::CreatePlaceFile( wxString& aFullFilename, PCB_LAYER pnpAttrib.m_MountType = GBR_CMP_PNP_METADATA::MOUNT_TYPE_SMD; // Add component value info: - pnpAttrib.m_Value = ConvertNotAllowedCharsInGerber( footprint->Value().GetShownText(), + pnpAttrib.m_Value = ConvertNotAllowedCharsInGerber( footprint->Value().GetShownText( false ), allowUtf8, true ); // Add component footprint info: diff --git a/pcbnew/exporters/place_file_exporter.cpp b/pcbnew/exporters/place_file_exporter.cpp index c0451bd0ab..b8ec4ec20c 100644 --- a/pcbnew/exporters/place_file_exporter.cpp +++ b/pcbnew/exporters/place_file_exporter.cpp @@ -145,9 +145,9 @@ std::string PLACE_FILE_EXPORTER::GenPositionData() m_fpCount++; LIST_MOD item; - item.m_Footprint = footprint; - item.m_Reference = footprint->Reference().GetShownText(); - item.m_Value = footprint->Value().GetShownText(); + item.m_Footprint = footprint; + item.m_Reference = footprint->Reference().GetShownText( false ); + item.m_Value = footprint->Value().GetShownText( false ); item.m_Layer = footprint->GetLayer(); list.push_back( item ); @@ -331,13 +331,14 @@ std::string PLACE_FILE_EXPORTER::GenReportData() 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 ) ); buffer += line; 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() ); buffer += line; diff --git a/pcbnew/footprint.cpp b/pcbnew/footprint.cpp index e56d0a8ca5..c6a2a5c215 100644 --- a/pcbnew/footprint.cpp +++ b/pcbnew/footprint.cpp @@ -498,12 +498,12 @@ bool FOOTPRINT::ResolveTextVar( wxString* token, int aDepth ) const if( token->IsSameAs( wxT( "REFERENCE" ) ) ) { - *token = m_reference->GetShownText( aDepth + 1 ); + *token = m_reference->GetShownText( false, aDepth + 1 ); return true; } else if( token->IsSameAs( wxT( "VALUE" ) ) ) { - *token = m_value->GetShownText( aDepth + 1 ); + *token = m_value->GetShownText( false, aDepth + 1 ); return true; } else if( token->IsSameAs( wxT( "LAYER" ) ) ) @@ -1024,7 +1024,9 @@ void FOOTPRINT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I { 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 ) || aFrame->IsType( FRAME_FOOTPRINT_VIEWER_MODAL ) @@ -1039,7 +1041,7 @@ void FOOTPRINT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_I aList.emplace_back( _( "Pads" ), wxString::Format( wxT( "%zu" ), padCount ) ); aList.emplace_back( wxString::Format( _( "Doc: %s" ), GetDescription() ), - wxString::Format( _( "Keywords: %s" ), GetKeywords() ) ); + wxString::Format( _( "Keywords: %s" ), GetKeywords() ) ); return; } diff --git a/pcbnew/pcb_dimension.cpp b/pcbnew/pcb_dimension.cpp index c4ab618920..8de77ee0df 100644 --- a/pcbnew/pcb_dimension.cpp +++ b/pcbnew/pcb_dimension.cpp @@ -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." ) ); - 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() ); @@ -449,7 +450,9 @@ const BOX2I PCB_DIMENSION_BASE::GetBoundingBox() 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 ) { - 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(); diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index bd2ceb8f61..dc7fc109c7 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -1696,11 +1696,11 @@ void PCB_EDIT_FRAME::ShowFindDialog() switch( front->Type() ) { case PCB_FOOTPRINT_T: - findString = static_cast<FOOTPRINT*>( front )->GetValue(); + findString = UnescapeString( static_cast<FOOTPRINT*>( front )->GetValue() ); break; case PCB_TEXT_T: - findString = static_cast<PCB_TEXT*>( front )->GetShownText(); + findString = UnescapeString( static_cast<PCB_TEXT*>( front )->GetText() ); if( findString.Contains( wxT( "\n" ) ) ) findString = findString.Before( '\n' ); diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 926f35622d..2a06e543ec 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -1915,7 +1915,7 @@ void PCB_PAINTER::draw( const PCB_BITMAP* aBitmap, 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 ) return; @@ -2030,7 +2030,7 @@ void PCB_PAINTER::draw( const PCB_TEXTBOX* aTextBox, int aLayer ) const COLOR4D& color = m_pcbSettings.GetColor( aTextBox, aLayer ); int thickness = getLineThickness( aTextBox->GetWidth() ); PLOT_DASH_TYPE lineStyle = aTextBox->GetStroke().GetPlotStyle(); - wxString resolvedText( aTextBox->GetShownText() ); + wxString resolvedText( aTextBox->GetShownText( true ) ); KIFONT::FONT* font = aTextBox->GetFont(); @@ -2407,7 +2407,7 @@ void PCB_PAINTER::draw( const PCB_DIMENSION_BASE* aDimension, int aLayer ) } // Draw text - wxString resolvedText = aDimension->GetShownText(); + wxString resolvedText = aDimension->GetShownText( true ); TEXT_ATTRIBUTES attrs = aDimension->GetAttributes(); if( m_gal->IsFlippedX() && !( aDimension->GetLayerSet() & LSET::SideSpecificMask() ).any() ) diff --git a/pcbnew/pcb_text.cpp b/pcbnew/pcb_text.cpp index b58acc8973..9d30efa320 100644 --- a/pcbnew/pcb_text.cpp +++ b/pcbnew/pcb_text.cpp @@ -77,7 +77,7 @@ PCB_TEXT::~PCB_TEXT() } -wxString PCB_TEXT::GetShownText( int aDepth, bool aAllowExtraText ) const +wxString PCB_TEXT::GetShownText( bool aAllowExtraText, int aDepth ) const { const FOOTPRINT* parentFootprint = GetParentFootprint(); const BOARD* board = GetBoard(); @@ -100,7 +100,7 @@ wxString PCB_TEXT::GetShownText( int aDepth, bool aAllowExtraText ) const return false; }; - wxString text = EDA_TEXT::GetShownText(); + wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth ); if( HasTextVars() ) { @@ -112,6 +112,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 ); +} + + EDA_ANGLE PCB_TEXT::GetDrawRotation() const { EDA_ANGLE rotation = GetTextAngle(); @@ -390,19 +396,19 @@ wxString PCB_TEXT::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const case TEXT_is_VALUE: return wxString::Format( _( "Value '%s' of %s" ), - GetShownText(), + KIUI::EllipsizeMenuText( GetText() ), parentFP->GetReference() ); case TEXT_is_DIVERS: return wxString::Format( _( "Footprint Text '%s' of %s" ), - KIUI::EllipsizeMenuText( GetShownText() ), + KIUI::EllipsizeMenuText( GetText() ), parentFP->GetReference() ); } } else { return wxString::Format( _( "PCB Text '%s' on %s"), - KIUI::EllipsizeMenuText( GetShownText() ), + KIUI::EllipsizeMenuText( GetText() ), GetLayerName() ); } @@ -487,7 +493,7 @@ void PCB_TEXT::TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLa buffer.Append( point.x, point.y ); } ); - font->Draw( &callback_gal, GetShownText(), GetTextPos(), attrs ); + font->Draw( &callback_gal, GetShownText( true ), GetTextPos(), attrs ); buffer.Simplify( SHAPE_POLY_SET::PM_FAST ); if( IsKnockout() ) diff --git a/pcbnew/pcb_text.h b/pcbnew/pcb_text.h index 663befff77..01066499d6 100644 --- a/pcbnew/pcb_text.h +++ b/pcbnew/pcb_text.h @@ -83,15 +83,12 @@ public: */ void KeepUpright( const EDA_ANGLE& aOldOrientation, const EDA_ANGLE& aNewOrientation ); - wxString GetShownText( int aDepth = 0, bool aAllowExtraText = true ) const override; + wxString GetShownText( bool aAllowExtraText, int aDepth = 0 ) const override; void SetType( TEXT_TYPE aType ) { m_type = aType; } TEXT_TYPE GetType() const { return m_type; } - bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override - { - return BOARD_ITEM::Matches( GetShownText(), aSearchData ); - } + bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override; virtual VECTOR2I GetPosition() const override { diff --git a/pcbnew/pcb_textbox.cpp b/pcbnew/pcb_textbox.cpp index dd89c56ae9..3e2113cd24 100644 --- a/pcbnew/pcb_textbox.cpp +++ b/pcbnew/pcb_textbox.cpp @@ -248,7 +248,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() ); @@ -269,7 +269,7 @@ wxString PCB_TEXTBOX::GetShownText( int aDepth, bool aAllowExtraText ) const return false; }; - wxString text = EDA_TEXT::GetShownText(); + wxString text = EDA_TEXT::GetShownText( aAllowExtraText, aDepth ); if( board && HasTextVars() && aDepth < 10 ) text = ExpandTextVars( text, &pcbTextResolver ); @@ -285,6 +285,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 ) { // Don't use GetShownText() here; we want to show the user the variable references @@ -406,7 +412,7 @@ bool PCB_TEXTBOX::HitTest( const BOX2I& aRect, bool aContained, int aAccuracy ) wxString PCB_TEXTBOX::GetItemDescription( UNITS_PROVIDER* aUnitsProvider ) const { - return wxString::Format( _( "PCB Text Box on %s"), GetLayerName() ); + return wxString::Format( _( "PCB Text Box on %s" ), GetLayerName() ); } @@ -471,7 +477,7 @@ void PCB_TEXTBOX::TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID 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 ); aBuffer.Append( buffer ); diff --git a/pcbnew/pcb_textbox.h b/pcbnew/pcb_textbox.h index ce46609640..52639c17c6 100644 --- a/pcbnew/pcb_textbox.h +++ b/pcbnew/pcb_textbox.h @@ -76,16 +76,13 @@ public: void SetTextAngle( const EDA_ANGLE& aAngle ) 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: void SetVisible( bool aVisible ) override { /* do nothing */} bool IsVisible() const override { return true; } - bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override - { - return BOARD_ITEM::Matches( GetShownText(), aSearchData ); - } + bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override; std::vector<VECTOR2I> GetAnchorAndOppositeCorner() const; diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index 9dff678d61..e4801fa2a1 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -89,11 +89,11 @@ void PlotInteractiveLayer( BOARD* aBoard, PLOTTER* aPlotter, const PCB_PLOT_PARA properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), _( "Reference designator" ), - fp->Reference().GetShownText() ) ); + fp->Reference().GetShownText( false ) ) ); properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), _( "Value" ), - fp->Value().GetShownText() ) ); + fp->Value().GetShownText( false ) ) ); for( const auto& [ name, value ] : fp->GetProperties() ) properties.emplace_back( wxString::Format( wxT( "!%s = %s" ), name, value ) ); diff --git a/pcbnew/plot_brditems_plotter.cpp b/pcbnew/plot_brditems_plotter.cpp index 9fe425dbde..d680e5b62c 100644 --- a/pcbnew/plot_brditems_plotter.cpp +++ b/pcbnew/plot_brditems_plotter.cpp @@ -447,7 +447,7 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItem( const PCB_TEXT* aText, const COLOR callback_gal.SetIsFill( font->IsOutline() ); 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; int margin = attrs.m_StrokeWidth * 1.5 @@ -461,7 +461,9 @@ void BRDITEMS_PLOTTER::PlotFootprintTextItem( const PCB_TEXT* aText, const COLOR m_plotter->PlotPoly( finalPoly.Outline( ii ), FILL_T::FILLED_SHAPE, 0, &gbr_metadata ); } else - m_plotter->PlotText( pos, aColor, aText->GetShownText(), attrs, font, &gbr_metadata ); + { + m_plotter->PlotText( pos, aColor, aText->GetShownText( true ), attrs, font, &gbr_metadata ); + } } @@ -644,7 +646,7 @@ void BRDITEMS_PLOTTER::PlotPcbText( const EDA_TEXT* aText, PCB_LAYER_ID aLayer, aText->IsBold(), aText->IsItalic() ); } - wxString shownText( aText->GetShownText() ); + wxString shownText( aText->GetShownText( true ) ); if( shownText.IsEmpty() ) return; diff --git a/pcbnew/plugins/kicad/pcb_plugin.cpp b/pcbnew/plugins/kicad/pcb_plugin.cpp index 0784784f34..1cbff0bad3 100644 --- a/pcbnew/plugins/kicad/pcb_plugin.cpp +++ b/pcbnew/plugins/kicad/pcb_plugin.cpp @@ -480,7 +480,7 @@ void PCB_PLUGIN::formatPolyPts( const SHAPE_LINE_CHAIN& outline, int aNestLevel, 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(), shownText ); diff --git a/pcbnew/widgets/search_handlers.cpp b/pcbnew/widgets/search_handlers.cpp index 4eac57c10f..caf67f63e2 100644 --- a/pcbnew/widgets/search_handlers.cpp +++ b/pcbnew/widgets/search_handlers.cpp @@ -255,7 +255,7 @@ wxString TEXT_SEARCH_HANDLER::GetResultCell( int aRow, int aCol ) if( PCB_TEXT::ClassOf( text ) ) return UnescapeString( static_cast<PCB_TEXT*>( text )->GetText() ); 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 ) return text->GetLayerName(); diff --git a/qa/schematic_utils/eeschema_test_utils.cpp b/qa/schematic_utils/eeschema_test_utils.cpp index 827b685eb5..2b0fa00ff1 100644 --- a/qa/schematic_utils/eeschema_test_utils.cpp +++ b/qa/schematic_utils/eeschema_test_utils.cpp @@ -1,7 +1,7 @@ /* * 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 * modify it under the terms of the GNU General Public License diff --git a/qa/tests/eeschema/test_legacy_power_symbols.cpp b/qa/tests/eeschema/test_legacy_power_symbols.cpp index 43f7a412bf..8620d4cfb7 100644 --- a/qa/tests/eeschema/test_legacy_power_symbols.cpp +++ b/qa/tests/eeschema/test_legacy_power_symbols.cpp @@ -47,7 +47,8 @@ struct LEGACY_POWER_SYMBOLS_TEST_FIXTURE && symbol->GetAllLibPins()[0]->IsGlobalPower() && !symbol->GetAllLibPins()[0]->IsVisible() ) { - BOOST_CHECK_EQUAL( symbol->GetValueFieldText(true), symbol->GetAllLibPins()[0]->GetName() ); + BOOST_CHECK_EQUAL( symbol->GetField( VALUE_FIELD )->GetText(), + symbol->GetAllLibPins()[0]->GetName() ); } } }