Fix fully broken selection of items of the same sheet, in pcbnew and from eeschema.

Previously, the full UUID path used to select footprints was full broken.
This commit is contained in:
jean-pierre charras 2020-04-02 14:20:28 +02:00
parent ffe0b4aba1
commit 25fb2595c8
3 changed files with 38 additions and 20 deletions

View File

@ -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<SCH_SHEET*>( 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:

View File

@ -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<MODULE*> 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*>();
wxString sheetPath = *aEvent.Parameter<wxString*>();
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 )

View File

@ -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.