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
This commit is contained in:
Seth Hillbrand 2018-11-03 11:05:11 -07:00
parent f2ccad39b6
commit 4b931aeb57
3 changed files with 8 additions and 0 deletions

View File

@ -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 ) )
{

View File

@ -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() )
{

View File

@ -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 ) )
{