Hit-test pads before computing their anchors.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19238
This commit is contained in:
Jeff Young 2024-12-04 17:41:27 +00:00
parent 6150586f01
commit a910eaf081
3 changed files with 7 additions and 13 deletions

View File

@ -417,7 +417,7 @@ int PAD_TOOL::EnumeratePads( const TOOL_EVENT& aEvent )
{ {
setCursor(); setCursor();
VECTOR2I cursorPos = grid.AlignToNearestPad( getViewControls()->GetMousePosition(), pads ); VECTOR2I cursorPos = grid.SnapToPad( getViewControls()->GetMousePosition(), pads );
getViewControls()->ForceCursorPosition( true, cursorPos ); getViewControls()->ForceCursorPosition( true, cursorPos );
if( evt->IsCancelInteractive() ) if( evt->IsCancelInteractive() )

View File

@ -391,12 +391,15 @@ VECTOR2I PCB_GRID_HELPER::AlignToArc( const VECTOR2I& aPoint, const SHAPE_ARC& a
} }
VECTOR2I PCB_GRID_HELPER::AlignToNearestPad( const VECTOR2I& aMousePos, std::deque<PAD*>& aPads ) VECTOR2I PCB_GRID_HELPER::SnapToPad( const VECTOR2I& aMousePos, std::deque<PAD*>& aPads )
{ {
clearAnchors(); clearAnchors();
for( BOARD_ITEM* item : aPads ) for( BOARD_ITEM* item : aPads )
{
if( item->HitTest( aMousePos ) )
computeAnchors( item, aMousePos, true, nullptr ); computeAnchors( item, aMousePos, true, nullptr );
}
double minDist = std::numeric_limits<double>::max(); double minDist = std::numeric_limits<double>::max();
ANCHOR* nearestOrigin = nullptr; ANCHOR* nearestOrigin = nullptr;
@ -406,15 +409,6 @@ VECTOR2I PCB_GRID_HELPER::AlignToNearestPad( const VECTOR2I& aMousePos, std::deq
if( ( ORIGIN & a.flags ) != ORIGIN ) if( ( ORIGIN & a.flags ) != ORIGIN )
continue; continue;
bool hitAny = true;
for( EDA_ITEM* item : m_snapItem->items )
{
hitAny = hitAny && item->HitTest( aMousePos );
}
if( !hitAny )
continue;
double dist = a.Distance( aMousePos ); double dist = a.Distance( aMousePos );
if( dist < minDist ) if( dist < minDist )

View File

@ -68,7 +68,7 @@ public:
VECTOR2I AlignToArc ( const VECTOR2I& aPoint, const SHAPE_ARC& aSeg ); VECTOR2I AlignToArc ( const VECTOR2I& aPoint, const SHAPE_ARC& aSeg );
VECTOR2I AlignToNearestPad( const VECTOR2I& aMousePos, std::deque<PAD*>& aPads ); VECTOR2I SnapToPad( const VECTOR2I& aMousePos, std::deque<PAD*>& aPads );
virtual void OnBoardItemRemoved( BOARD& aBoard, BOARD_ITEM* aBoardItem ) override virtual void OnBoardItemRemoved( BOARD& aBoard, BOARD_ITEM* aBoardItem ) override
{ {