Heirarchical sheet selection includes more.

Now the heirarchical sheet selection feature includes tracks that belong
to a net spanning multiple sheets, but only by doing a logical connection
from the pads of the modules. This is to be able to select connections
between components on the same sheet. For example if the sheet contains a
star power connection or something similar, then most of the sheet local
connections will now also be included.
This commit is contained in:
Kristoffer Ödmark 2017-07-17 14:55:31 +02:00 committed by Maciej Suminski
parent 2c23c4c3a9
commit aaa1e35b6a
4 changed files with 50 additions and 1 deletions

View File

@ -32,6 +32,7 @@
#include <limits.h>
#include <algorithm>
#include <iterator>
#include <fctsys.h>
#include <common.h>
@ -1560,6 +1561,21 @@ D_PAD* BOARD::GetPad( TRACK* aTrace, ENDPOINT_T aEndPoint )
}
return NULL;
}
std::list<TRACK*> BOARD::GetTracksByPosition( const wxPoint& aPosition, PCB_LAYER_ID aLayer ) const
{
std::list<TRACK*> tracks;
for( TRACK *track = GetFirstTrack( m_Track); track; track = GetFirstTrack( track->Next() ) )
{
if( ( ( track->GetStart() == aPosition) || track->GetEnd() == aPosition ) &&
( track->GetState( BUSY | IS_DELETED ) == 0 ) &&
( ( aLayer == UNDEFINED_LAYER ) || ( track->IsOnLayer( aLayer ) ) ) )
tracks.push_back( track );
}
return tracks;
}

View File

@ -1151,6 +1151,16 @@ public:
VIA* GetViaByPosition( const wxPoint& aPosition,
PCB_LAYER_ID aLayer = PCB_LAYER_ID( -1 ) ) const;
/**
* Function GetTracksByPosition
* finds the list of tracks that starts or ends at \a aPosition on \a aLayer.
*
* @param aPosition The wxPoint to check start agains against.
* @param aLayer The layer to search. Use -1 (<PCB_LAYER_ID>::UNDEFINED_LAYER) for a don't care.
* @return std::list<TRACK*> A list of TRACK* items that can be zero if no track is found.
*/
std::list<TRACK*> GetTracksByPosition( const wxPoint& aPosition, PCB_LAYER_ID aLayer = PCB_LAYER_ID( -1 ) ) const;
/**
* Function GetPad
* finds a pad \a aPosition on \a aLayer.

View File

@ -498,5 +498,16 @@ inline VIA* GetFirstVia( TRACK* aTrk, const TRACK* aStopPoint = NULL )
else
return NULL;
}
inline TRACK* GetFirstTrack( TRACK* aTrk, const TRACK* aStopPoint = NULL )
{
while( aTrk && ( aTrk != aStopPoint ) && ( aTrk->Type() != PCB_TRACE_T ) )
aTrk = aTrk->Next();
// It could stop because of the stop point, not on a via
if( aTrk && ( aTrk->Type() == PCB_TRACE_T ) )
return static_cast<TRACK*>( aTrk );
else
return NULL;
}
#endif // CLASS_TRACK_H

View File

@ -897,6 +897,7 @@ void SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetpath )
//Generate a list of all pads, and of all nets they belong to.
std::list<int> netcodeList;
std::list<BOARD_CONNECTED_ITEM*> padList;
for( MODULE* mmod : modList )
{
for( auto pad : mmod->Pads() )
@ -904,14 +905,25 @@ void SELECTION_TOOL::selectAllItemsOnSheet( wxString& aSheetpath )
if( pad->IsConnected() )
{
netcodeList.push_back( pad->GetNetCode() );
padList.push_back( pad );
}
}
}
// remove all duplicates
netcodeList.sort();
netcodeList.unique();
// auto select trivial connections segments which are launched from the pads
std::list<TRACK*> launchTracks;
for( auto pad : padList )
{
launchTracks = board()->GetTracksByPosition( pad->GetPosition() );
for ( auto track : launchTracks )
{
selectAllItemsConnectedToTrack( *track );
}
}
// now we need to find all modules that are connected to each of these nets
// then we need to determine if these modules are in the list of modules
// belonging to this sheet ( modList )