Eeschema: Fix selection of items inside filled shapes
The selection heuristic broke down when one item was a filled
shape. Because all hit tests would succeed with distance 0 for
these shapes, they would always be considered the closest item
to the exclusion of all else, which made it very hard to
click on a graphic inside a filled shape.
Now, recognise when an item would be "dominating" and
decline to promote it to the "closet" spot. It will still
be selectable if there are no other items nearby, or if
there are multiple shapes.
(cherry picked from commit fd4c15517f
)
This commit is contained in:
parent
c27ca33a2e
commit
e20a11cbb3
|
@ -1472,6 +1472,11 @@ void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const
|
||||||
BOX2I bbox = item->GetBoundingBox();
|
BOX2I bbox = item->GetBoundingBox();
|
||||||
int dist = INT_MAX / 4;
|
int dist = INT_MAX / 4;
|
||||||
|
|
||||||
|
// A dominating item is one that would unfairly win distance tests
|
||||||
|
// and mask out other items. For example, a filled rectangle "wins"
|
||||||
|
// with a zero distance over anything inside it.
|
||||||
|
bool dominating = false;
|
||||||
|
|
||||||
if( exactHits.count( item ) )
|
if( exactHits.count( item ) )
|
||||||
{
|
{
|
||||||
if( item->Type() == SCH_PIN_T || item->Type() == SCH_JUNCTION_T )
|
if( item->Type() == SCH_PIN_T || item->Type() == SCH_JUNCTION_T )
|
||||||
|
@ -1528,6 +1533,9 @@ void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const
|
||||||
|
|
||||||
delete s;
|
delete s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Filled shapes win hit tests anywhere inside them
|
||||||
|
dominating = shape->IsFilled();
|
||||||
}
|
}
|
||||||
else if( symbol )
|
else if( symbol )
|
||||||
{
|
{
|
||||||
|
@ -1551,6 +1559,11 @@ void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const
|
||||||
rect.Collide( poss, collector.m_Threshold, &dist );
|
rect.Collide( poss, collector.m_Threshold, &dist );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't promote dominating items to be the closest item
|
||||||
|
// (they'll always win) - they'll still be available for selection, but they
|
||||||
|
// won't boot out worthy competitors.
|
||||||
|
if ( !dominating )
|
||||||
|
{
|
||||||
if( dist == closestDist )
|
if( dist == closestDist )
|
||||||
{
|
{
|
||||||
if( item->GetParent() == closest )
|
if( item->GetParent() == closest )
|
||||||
|
@ -1562,6 +1575,7 @@ void EE_SELECTION_TOOL::GuessSelectionCandidates( EE_COLLECTOR& collector, const
|
||||||
closest = item;
|
closest = item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Construct a tight box (1/2 height and width) around the center of the closest item.
|
// Construct a tight box (1/2 height and width) around the center of the closest item.
|
||||||
// All items which exist at least partly outside this box have sufficient other areas
|
// All items which exist at least partly outside this box have sufficient other areas
|
||||||
|
|
Loading…
Reference in New Issue