diff --git a/eeschema/cross-probing.cpp b/eeschema/cross-probing.cpp index b95c6cd86c..9f26ac3d1e 100644 --- a/eeschema/cross-probing.cpp +++ b/eeschema/cross-probing.cpp @@ -270,8 +270,24 @@ std::string FormatProbeItem( EDA_ITEM* aItem, SCH_COMPONENT* aComp ) case SCH_SHEET_T: { + // For cross probing, we need the full path of the sheet, because + // in complex hierarchies the sheet uuid of not unique SCH_SHEET* sheet = (SCH_SHEET*)aItem; - return StrPrintf( "$SHEET: \"%s\"", TO_UTF8( sheet->m_Uuid.AsString() ) ); + wxString full_path; + + SCH_SHEET* parent = sheet; + while( (parent = dynamic_cast( parent->GetParent() ) ) ) + { + if( parent->GetParent() ) // The root sheet has no parent and path is just "/" + { + full_path.Prepend( parent->m_Uuid.AsString() ); + full_path.Prepend( "/" ); + } + } + + full_path += "/" + sheet->m_Uuid.AsString(); + + return StrPrintf( "$SHEET: \"%s\"", TO_UTF8( full_path ) ); } case SCH_PIN_T: diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 9fe4ea0c0d..ff973688a9 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -971,25 +971,23 @@ int SELECTION_TOOL::selectNet( const TOOL_EVENT& aEvent ) } -void SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetID ) +void SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetPath ) { - KIID uuid( aSheetID ); std::list modList; - // store all modules that are on that sheet + // store all modules that are on that sheet path for( MODULE* module : board()->Modules() ) { if( module == nullptr ) continue; - for( const KIID& pathStep : module->GetPath() ) - { - if( pathStep == uuid ) - { - modList.push_back( module ); - break; - } - } + wxString footprint_path = module->GetPath().AsString().BeforeLast('/'); + + if( aSheetPath.IsEmpty() ) + aSheetPath += '/'; + + if( footprint_path == aSheetPath ) + modList.push_back( module ); } //Generate a list of all pads, and of all nets they belong to. @@ -1101,9 +1099,9 @@ void SELECTION_TOOL::zoomFitSelection() int SELECTION_TOOL::selectSheetContents( const TOOL_EVENT& aEvent ) { ClearSelection( true /*quiet mode*/ ); - wxString* sheetID = aEvent.Parameter(); + wxString sheetPath = *aEvent.Parameter(); - selectAllItemsOnSheet( *sheetID ); + selectAllItemsOnSheet( sheetPath ); zoomFitSelection(); @@ -1136,10 +1134,13 @@ int SELECTION_TOOL::selectSameSheet( const TOOL_EVENT& aEvent ) ClearSelection( true /*quiet mode*/ ); - // get the lowest subsheet name for this. - wxString sheetID = mod->GetPath().back().AsString(); + // get the sheet path only. + wxString sheetPath = mod->GetPath().AsString().BeforeLast( '/' ); - selectAllItemsOnSheet( sheetID ); + if( sheetPath.IsEmpty() ) + sheetPath += '/'; + + selectAllItemsOnSheet( sheetPath ); // Inform other potentially interested tools if( m_selection.Size() > 0 ) diff --git a/pcbnew/tools/selection_tool.h b/pcbnew/tools/selection_tool.h index a1e10400ab..03ef9c9a89 100644 --- a/pcbnew/tools/selection_tool.h +++ b/pcbnew/tools/selection_tool.h @@ -232,17 +232,18 @@ private: void selectAllItemsOnNet( int aNetCode ); /** - * Selects all items with the given sheet timestamp name + * Selects all items with the given sheet timestamp/UUID name * (the sheet path) + * The path of the root sheet is "/" */ - void selectAllItemsOnSheet( wxString& aSheetID ); + void selectAllItemsOnSheet( wxString& aSheetPath ); ///> Selects all modules belonging to same sheet, from Eeschema, ///> using crossprobing int selectSheetContents( const TOOL_EVENT& aEvent ); ///> Selects all modules belonging to same hierarchical sheet - ///> as the selected footprint. + ///> as the selected footprint (same sheet path). int selectSameSheet( const TOOL_EVENT& aEvent ); ///> Find dialog callback.