Allow PNS to select nearest pad when two overlap
Usually pads do not overlap. However custom pads are represented as their convex hull, so they may enclose other pads. This change allows the router to select the closest pad to the cursor position.
This commit is contained in:
parent
296ada95a3
commit
1ac905d3ee
|
@ -122,9 +122,13 @@ ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer, b
|
||||||
|
|
||||||
static const int candidateCount = 5;
|
static const int candidateCount = 5;
|
||||||
ITEM* prioritized[candidateCount];
|
ITEM* prioritized[candidateCount];
|
||||||
|
int dist[candidateCount];
|
||||||
|
|
||||||
for( int i = 0; i < candidateCount; i++ )
|
for( int i = 0; i < candidateCount; i++ )
|
||||||
|
{
|
||||||
prioritized[i] = 0;
|
prioritized[i] = 0;
|
||||||
|
dist[i] = std::numeric_limits<int>::max();
|
||||||
|
}
|
||||||
|
|
||||||
ITEM_SET candidates = m_router->QueryHoverItems( aWhere );
|
ITEM_SET candidates = m_router->QueryHoverItems( aWhere );
|
||||||
|
|
||||||
|
@ -147,10 +151,18 @@ ITEM* TOOL_BASE::pickSingleItem( const VECTOR2I& aWhere, int aNet, int aLayer, b
|
||||||
if( item->OfKind( ITEM::SOLID_T ) && aIgnorePads )
|
if( item->OfKind( ITEM::SOLID_T ) && aIgnorePads )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if( !prioritized[2] )
|
int itemDist = ( item->Shape()->Centre() - aWhere ).SquaredEuclideanNorm();
|
||||||
|
|
||||||
|
if( !prioritized[2] || itemDist < dist[2] )
|
||||||
|
{
|
||||||
prioritized[2] = item;
|
prioritized[2] = item;
|
||||||
if( item->Layers().Overlaps( tl ) )
|
dist[2] = itemDist;
|
||||||
|
}
|
||||||
|
if( item->Layers().Overlaps( tl ) && itemDist < dist[0] )
|
||||||
|
{
|
||||||
prioritized[0] = item;
|
prioritized[0] = item;
|
||||||
|
dist[0] = itemDist;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue