From 55394f343d479a111ea9ff85c887dd4195778733 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Mon, 28 Dec 2020 17:26:39 -0500 Subject: [PATCH] Don't use snapping for a selection interaction Fixes https://gitlab.com/kicad/code/kicad/-/issues/6856 --- pcbnew/tools/board_inspection_tool.cpp | 1 + pcbnew/tools/pcb_picker_tool.cpp | 14 ++++++++++---- pcbnew/tools/pcb_picker_tool.h | 2 ++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pcbnew/tools/board_inspection_tool.cpp b/pcbnew/tools/board_inspection_tool.cpp index 3fb19155ad..b74209a0bd 100644 --- a/pcbnew/tools/board_inspection_tool.cpp +++ b/pcbnew/tools/board_inspection_tool.cpp @@ -909,6 +909,7 @@ int BOARD_INSPECTION_TOOL::HighlightNetTool( const TOOL_EVENT& aEvent ) } ); picker->SetLayerSet( LSET::AllCuMask() ); + picker->SetSnapping( false ); m_toolMgr->RunAction( ACTIONS::pickerTool, true, &tool ); diff --git a/pcbnew/tools/pcb_picker_tool.cpp b/pcbnew/tools/pcb_picker_tool.cpp index 01b33fdbc2..86aa07489a 100644 --- a/pcbnew/tools/pcb_picker_tool.cpp +++ b/pcbnew/tools/pcb_picker_tool.cpp @@ -61,15 +61,20 @@ int PCB_PICKER_TOOL::Main( const TOOL_EVENT& aEvent ) // Set initial cursor setCursor(); + VECTOR2D cursorPos; while( TOOL_EVENT* evt = Wait() ) { setCursor(); + cursorPos = controls->GetMousePosition(); - grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); - grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->Modifier( MD_ALT ) ); - VECTOR2I cursorPos = grid.BestSnapAnchor( controls->GetMousePosition(), nullptr ); - controls->ForceCursorPosition(true, cursorPos ); + if( m_snap ) + { + grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); + grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->Modifier( MD_ALT ) ); + cursorPos = grid.BestSnapAnchor( cursorPos, nullptr ); + controls->ForceCursorPosition( true, cursorPos ); + } if( evt->IsCancelInteractive() || evt->IsActivate() ) { @@ -181,6 +186,7 @@ void PCB_PICKER_TOOL::reset() { m_layerMask = LSET::AllLayersMask(); m_cursor = KICURSOR::ARROW; + m_snap = true; m_picked = NULLOPT; m_clickHandler = NULLOPT; diff --git a/pcbnew/tools/pcb_picker_tool.h b/pcbnew/tools/pcb_picker_tool.h index e40235975f..ed6100b5f1 100644 --- a/pcbnew/tools/pcb_picker_tool.h +++ b/pcbnew/tools/pcb_picker_tool.h @@ -66,6 +66,7 @@ public: inline void SetCursor( KICURSOR aCursor ) { m_cursor = aCursor; } + inline void SetSnapping( bool aSnap ) { m_snap = aSnap; } /** * Function SetClickHandler() * 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 LSET m_layerMask; KICURSOR m_cursor; + bool m_snap; OPT m_clickHandler; OPT m_motionHandler;