From cb482eb8ebe750dcb4b60ff0d0ffdc179078bf9d Mon Sep 17 00:00:00 2001 From: dsa-t Date: Fri, 3 Dec 2021 20:35:54 +0000 Subject: [PATCH] Symbol Fields Table: Highlight proper symbols even if they aren't annotated --- common/view/view.cpp | 4 ++ eeschema/cross-probing.cpp | 44 +++++++++++++------ .../dialogs/dialog_symbol_fields_table.cpp | 6 ++- eeschema/tools/sch_editor_control.h | 9 ++-- 4 files changed, 45 insertions(+), 18 deletions(-) diff --git a/common/view/view.cpp b/common/view/view.cpp index 6d6ae3603c..c83ed63b6f 100644 --- a/common/view/view.cpp +++ b/common/view/view.cpp @@ -42,6 +42,10 @@ #include +#ifdef KICAD_GAL_PROFILE +#include +#endif + namespace KIGFX { class VIEW; diff --git a/eeschema/cross-probing.cpp b/eeschema/cross-probing.cpp index 7b315e20aa..df5a9dc3ce 100644 --- a/eeschema/cross-probing.cpp +++ b/eeschema/cross-probing.cpp @@ -40,9 +40,8 @@ #include #include -SCH_ITEM* SCH_EDITOR_CONTROL::FindSymbolAndItem( const wxString& aReference, - bool aSearchHierarchy, - SCH_SEARCH_T aSearchType, +SCH_ITEM* SCH_EDITOR_CONTROL::FindSymbolAndItem( const wxString* aPath, const wxString* aReference, + bool aSearchHierarchy, SCH_SEARCH_T aSearchType, const wxString& aSearchText ) { SCH_SHEET_PATH* sheetWithSymbolFound = nullptr; @@ -65,7 +64,20 @@ SCH_ITEM* SCH_EDITOR_CONTROL::FindSymbolAndItem( const wxString& aReference, { SCH_SYMBOL* candidate = static_cast( item ); - if( aReference.CmpNoCase( candidate->GetRef( &sheet ) ) == 0 ) + // Search by path if specified, otherwise search by reference + bool found = false; + + if( aPath ) + { + wxString path = sheet.PathAsString() + candidate->m_Uuid.AsString(); + found = ( *aPath == path ); + } + else + { + found = ( aReference && aReference->CmpNoCase( candidate->GetRef( &sheet ) ) == 0 ); + } + + if( found ) { symbol = candidate; sheetWithSymbolFound = &sheet; @@ -233,24 +245,30 @@ SCH_ITEM* SCH_EDITOR_CONTROL::FindSymbolAndItem( const wxString& aReference, /* Print diag */ wxString msg; + wxString displayRef; + + if( aReference ) + displayRef = *aReference; + else if( aPath ) + displayRef = *aPath; if( symbol ) { if( aSearchType == HIGHLIGHT_PIN ) { if( foundItem ) - msg.Printf( _( "%s pin %s found" ), aReference, aSearchText ); + msg.Printf( _( "%s pin %s found" ), displayRef, aSearchText ); else - msg.Printf( _( "%s found but pin %s not found" ), aReference, aSearchText ); + msg.Printf( _( "%s found but pin %s not found" ), displayRef, aSearchText ); } else { - msg.Printf( _( "%s found" ), aReference ); + msg.Printf( _( "%s found" ), displayRef ); } } else { - msg.Printf( _( "%s not found" ), aReference ); + msg.Printf( _( "%s not found" ), displayRef ); } m_frame->SetStatusText( msg ); @@ -327,7 +345,7 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline ) if( idcmd == nullptr ) // Highlight symbol only (from CvPcb or Pcbnew) { // Highlight symbol part_ref, or clear Highlight, if part_ref is not existing - editor->FindSymbolAndItem( part_ref, true, HIGHLIGHT_SYMBOL, wxEmptyString ); + editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, wxEmptyString ); return; } @@ -342,21 +360,21 @@ void SCH_EDIT_FRAME::ExecuteRemoteCommand( const char* cmdline ) { // Highlighting the reference itself isn't actually that useful, and it's harder to // see. Highlight the parent and display the message. - editor->FindSymbolAndItem( part_ref, true, HIGHLIGHT_SYMBOL, msg ); + editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, msg ); } else if( strcmp( idcmd, "$VAL:" ) == 0 ) { // Highlighting the value itself isn't actually that useful, and it's harder to see. // Highlight the parent and display the message. - editor->FindSymbolAndItem( part_ref, true, HIGHLIGHT_SYMBOL, msg ); + editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, msg ); } else if( strcmp( idcmd, "$PAD:" ) == 0 ) { - editor->FindSymbolAndItem( part_ref, true, HIGHLIGHT_PIN, msg ); + editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_PIN, msg ); } else { - editor->FindSymbolAndItem( part_ref, true, HIGHLIGHT_SYMBOL, wxEmptyString ); + editor->FindSymbolAndItem( nullptr, &part_ref, true, HIGHLIGHT_SYMBOL, wxEmptyString ); } } diff --git a/eeschema/dialogs/dialog_symbol_fields_table.cpp b/eeschema/dialogs/dialog_symbol_fields_table.cpp index a195622b38..c989e9c20b 100644 --- a/eeschema/dialogs/dialog_symbol_fields_table.cpp +++ b/eeschema/dialogs/dialog_symbol_fields_table.cpp @@ -1147,8 +1147,10 @@ void DIALOG_SYMBOL_FIELDS_TABLE::OnTableCellClick( wxGridEvent& event ) { SCH_EDITOR_CONTROL* editor = m_parent->GetToolManager()->GetTool(); - editor->FindSymbolAndItem( refs[ 0 ].GetRef() + refs[ 0 ].GetRefNumber(), true, - HIGHLIGHT_SYMBOL, wxEmptyString ); + wxString path = refs[0].GetPath(); + wxString reference = refs[0].GetRef() + refs[0].GetRefNumber(); + + editor->FindSymbolAndItem( &path, &reference, true, HIGHLIGHT_SYMBOL, wxEmptyString ); } } else diff --git a/eeschema/tools/sch_editor_control.h b/eeschema/tools/sch_editor_control.h index 1314f9fc82..98b8febce2 100644 --- a/eeschema/tools/sch_editor_control.h +++ b/eeschema/tools/sch_editor_control.h @@ -147,14 +147,17 @@ public: /** * Find a symbol in the schematic and an item in this symbol. * - * @param aReference The symbol reference designator to find. + * @param aPath The symbol path to find. Pass nullptr to search by aReference. + * @param aReference The symbol reference designator to find, or to display in + * status bar if aPath is specified * @param aSearchHierarchy If false, search the current sheet only. Otherwise, * the entire hierarchy * @param aSearchType A #SCH_SEARCH_T value used to determine what to search for. * @param aSearchText The text to search for, either in value, reference or elsewhere. */ - SCH_ITEM* FindSymbolAndItem( const wxString& aReference, bool aSearchHierarchy, - SCH_SEARCH_T aSearchType, const wxString& aSearchText ); + SCH_ITEM* FindSymbolAndItem( const wxString* aPath, const wxString* aReference, + bool aSearchHierarchy, SCH_SEARCH_T aSearchType, + const wxString& aSearchText ); private: ///< copy selection to clipboard or to m_localClipboard if aUseLocalClipboard is true