Improve eeschema selection disambiguation logic.

This commit is contained in:
Jeff Young 2019-06-26 19:43:37 +01:00
parent fa84babefe
commit 7292ce6a8b
1 changed files with 22 additions and 10 deletions

View File

@ -528,6 +528,28 @@ void EE_SELECTION_TOOL::guessSelectionCandidates( EE_COLLECTOR& collector, const
// There are certain parent/child and enclosure combinations that can be handled // There are certain parent/child and enclosure combinations that can be handled
// automatically. // automatically.
// Prefer exact hits to a sloppy ones
int exactHits = 0;
for( int i = collector.GetCount() - 1; i >= 0; --i )
{
EDA_ITEM* item = collector[ i ];
if( item->HitTest( (wxPoint) aPos, 0 ) )
exactHits++;
}
if( exactHits > 0 && exactHits < collector.GetCount() )
{
for( int i = collector.GetCount() - 1; i >= 0; --i )
{
EDA_ITEM* item = collector[ i ];
if( !item->HitTest( (wxPoint) aPos, 0 ) )
collector.Remove( item );
}
}
// Prefer a non-sheet to a sheet // Prefer a non-sheet to a sheet
for( int i = 0; collector.GetCount() == 2 && i < 2; ++i ) for( int i = 0; collector.GetCount() == 2 && i < 2; ++i )
{ {
@ -548,16 +570,6 @@ void EE_SELECTION_TOOL::guessSelectionCandidates( EE_COLLECTOR& collector, const
collector.Remove( other ); collector.Remove( other );
} }
// Prefer an exact hit to a sloppy one
for( int i = 0; collector.GetCount() == 2 && i < 2; ++i )
{
EDA_ITEM* item = collector[ i ];
EDA_ITEM* other = collector[ ( i + 1 ) % 2 ];
if( item->HitTest( (wxPoint) aPos, 0 ) && !other->HitTest( (wxPoint) aPos, 0 ) )
collector.Remove( other );
}
// Prefer a field to a symbol // Prefer a field to a symbol
for( int i = 0; collector.GetCount() == 2 && i < 2; ++i ) for( int i = 0; collector.GetCount() == 2 && i < 2; ++i )
{ {