From 4b931aeb57e5e17ac406a04f538848888b9465c0 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sat, 3 Nov 2018 11:05:11 -0700 Subject: [PATCH] pcbnew: Force cursor position when snapping This places the crosshairs (confusingly named here) at the snap position, either one of the snap points or the grid, depending on the status of the hotkeys SHIFT/ALT. Fixes: lp:1801373 * https://bugs.launchpad.net/kicad/+bug/1801373 Fixes: lp:1801369 * https://bugs.launchpad.net/kicad/+bug/1801369 --- pcbnew/tools/drawing_tool.cpp | 5 +++++ pcbnew/tools/edit_tool.cpp | 2 ++ pcbnew/tools/picker_tool.cpp | 1 + 3 files changed, 8 insertions(+) diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 4f72f224cd..98cd9c4c86 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -522,6 +522,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); m_controls->SetSnapping( !evt->Modifier( MD_ALT ) ); VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), nullptr ); + m_controls->ForceCursorPosition(true, cursorPos ); if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) ) { @@ -1003,6 +1004,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, aGraphic->SetStart( wxPoint( aStartingPoint->x, aStartingPoint->y ) ); cursorPos = grid.BestSnapAnchor( cursorPos, aGraphic ); + m_controls->ForceCursorPosition(true, cursorPos ); aGraphic->SetEnd( wxPoint( cursorPos.x, cursorPos.y ) ); if( aShape == S_SEGMENT ) @@ -1025,6 +1027,7 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); m_controls->SetSnapping( !evt->Modifier( MD_ALT ) ); cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), getDrawingLayer() ); + m_controls->ForceCursorPosition(true, cursorPos ); // 45 degree angle constraint enabled with an option and toggled with Ctrl const bool limit45 = ( frame()->Settings().m_use45DegreeGraphicSegments != !!( evt->Modifier( MD_CTRL ) ) ); @@ -1229,6 +1232,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic ) grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); m_controls->SetSnapping( !evt->Modifier( MD_ALT ) ); VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), aGraphic ); + m_controls->ForceCursorPosition(true, cursorPos ); if( evt->IsClick( BUT_LEFT ) ) { @@ -1412,6 +1416,7 @@ int DRAWING_TOOL::drawZone( bool aKeepout, ZONE_MODE aMode ) grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); m_controls->SetSnapping( !evt->Modifier( MD_ALT ) ); VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), layers ); + m_controls->ForceCursorPosition(true, cursorPos ); if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) ) { diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index fa1f95f987..1b33fdcda8 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -386,6 +386,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) if( m_dragging && evt->Category() == TC_MOUSE ) { m_cursor = grid.BestSnapAnchor( controls->GetMousePosition(), item_layers ); + controls->ForceCursorPosition(true, m_cursor ); VECTOR2I movement( m_cursor - prevPos ); selection.SetReferencePoint( m_cursor ); @@ -1220,6 +1221,7 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); controls.SetSnapping( !evt->Modifier( MD_ALT ) ); const VECTOR2I cursorPos = grid.BestSnapAnchor( controls.GetMousePosition(), nullptr ); + controls.ForceCursorPosition(true, cursorPos ); if( evt->IsCancel() || TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() ) { diff --git a/pcbnew/tools/picker_tool.cpp b/pcbnew/tools/picker_tool.cpp index 592ab5d9ff..7761d04425 100644 --- a/pcbnew/tools/picker_tool.cpp +++ b/pcbnew/tools/picker_tool.cpp @@ -52,6 +52,7 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent ) grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); controls->SetSnapping( !evt->Modifier( MD_ALT ) ); VECTOR2I cursorPos = grid.BestSnapAnchor( controls->GetMousePosition(), nullptr ); + controls->ForceCursorPosition(true, cursorPos ); if( evt->IsClick( BUT_LEFT ) ) {