From 86725db758d0bd4ad9d3805619841678270b9978 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Mon, 6 Sep 2021 06:35:36 -0700 Subject: [PATCH] Ensure doInteractivePlacement enforces snap option Fixes https://gitlab.com/kicad/code/kicad/issues/9105 --- pcbnew/tools/pcb_tool_base.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/pcbnew/tools/pcb_tool_base.cpp b/pcbnew/tools/pcb_tool_base.cpp index d54b3c5197..3bb85c4e08 100644 --- a/pcbnew/tools/pcb_tool_base.cpp +++ b/pcbnew/tools/pcb_tool_base.cpp @@ -28,9 +28,11 @@ #include #include #include -#include "pcb_selection_tool.h" -#include "pcb_actions.h" -#include "tool_event_utils.h" + +#include +#include +#include +#include void PCB_TOOL_BASE::doInteractiveItemPlacement( const std::string& aTool, INTERACTIVE_PLACER_BASE* aPlacer, @@ -49,6 +51,8 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( const std::string& aTool, // do not capture or auto-pan until we start placing an item controls()->ShowCursor( true ); + PCB_GRID_HELPER grid( m_toolMgr, frame()->GetMagneticItemsSettings() ); + // Add a VIEW_GROUP that serves as a preview for the new item PCB_SELECTION preview; view()->Add( &preview ); @@ -98,7 +102,10 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( const std::string& aTool, { setCursor(); - VECTOR2I cursorPos = controls()->GetCursorPosition(); + grid.SetSnap( false ); // Interactive placement tools need to set their own item snaps + grid.SetUseGrid( getView()->GetGAL()->GetGridSnapping() && !evt->DisableGridSnapping() ); + VECTOR2I cursorPos = grid.BestSnapAnchor( controls()->GetMousePosition(), nullptr ); + aPlacer->m_modifiers = evt->Modifier(); auto cleanup =