Don't use snapping for a selection interaction

Fixes https://gitlab.com/kicad/code/kicad/-/issues/6856
This commit is contained in:
Jon Evans 2020-12-28 17:26:39 -05:00
parent be294dabce
commit 55394f343d
3 changed files with 13 additions and 4 deletions

View File

@ -909,6 +909,7 @@ int BOARD_INSPECTION_TOOL::HighlightNetTool( const TOOL_EVENT& aEvent )
} ); } );
picker->SetLayerSet( LSET::AllCuMask() ); picker->SetLayerSet( LSET::AllCuMask() );
picker->SetSnapping( false );
m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool ); m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool );

View File

@ -61,15 +61,20 @@ int PCB_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
// Set initial cursor // Set initial cursor
setCursor(); setCursor();
VECTOR2D cursorPos;
while( TOOL_EVENT* evt = Wait() ) while( TOOL_EVENT* evt = Wait() )
{ {
setCursor(); setCursor();
cursorPos = controls->GetMousePosition();
grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); if( m_snap )
grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->Modifier( MD_ALT ) ); {
VECTOR2I cursorPos = grid.BestSnapAnchor( controls->GetMousePosition(), nullptr ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
controls->ForceCursorPosition(true, cursorPos ); grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->Modifier( MD_ALT ) );
cursorPos = grid.BestSnapAnchor( cursorPos, nullptr );
controls->ForceCursorPosition( true, cursorPos );
}
if( evt->IsCancelInteractive() || evt->IsActivate() ) if( evt->IsCancelInteractive() || evt->IsActivate() )
{ {
@ -181,6 +186,7 @@ void PCB_PICKER_TOOL::reset()
{ {
m_layerMask = LSET::AllLayersMask(); m_layerMask = LSET::AllLayersMask();
m_cursor = KICURSOR::ARROW; m_cursor = KICURSOR::ARROW;
m_snap = true;
m_picked = NULLOPT; m_picked = NULLOPT;
m_clickHandler = NULLOPT; m_clickHandler = NULLOPT;

View File

@ -66,6 +66,7 @@ public:
inline void SetCursor( KICURSOR aCursor ) { m_cursor = aCursor; } inline void SetCursor( KICURSOR aCursor ) { m_cursor = aCursor; }
inline void SetSnapping( bool aSnap ) { m_snap = aSnap; }
/** /**
* Function SetClickHandler() * Function SetClickHandler()
* Sets a handler for mouse click event. Handler may decide to receive further click by * Sets a handler for mouse click event. Handler may decide to receive further click by
@ -121,6 +122,7 @@ private:
///> The layer set to use for optional snapping ///> The layer set to use for optional snapping
LSET m_layerMask; LSET m_layerMask;
KICURSOR m_cursor; KICURSOR m_cursor;
bool m_snap;
OPT<CLICK_HANDLER> m_clickHandler; OPT<CLICK_HANDLER> m_clickHandler;
OPT<MOTION_HANDLER> m_motionHandler; OPT<MOTION_HANDLER> m_motionHandler;