diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index 63fd288f5c..6e1c286fa1 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -524,7 +524,8 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) { grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); - VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetCursorPosition(), nullptr ); + m_controls->SetSnapping( !evt->Modifier( MD_ALT ) ); + VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), nullptr ); if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) ) @@ -989,14 +990,13 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); m_controls->ShowCursor( true ); - m_controls->SetSnapping( false ); Activate(); bool direction45 = false; // 45 degrees only mode bool started = false; bool IsOCurseurSet = ( m_frame->GetScreen()->m_O_Curseur != wxPoint( 0, 0 ) ); - VECTOR2I cursorPos = m_controls->GetCursorPosition(); + VECTOR2I cursorPos = m_controls->GetMousePosition(); if( aStartingPoint ) { @@ -1027,7 +1027,8 @@ bool DRAWING_TOOL::drawSegment( int aShape, DRAWSEGMENT*& aGraphic, { grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); - cursorPos = grid.BestSnapAnchor( m_controls->GetCursorPosition(), getDrawingLayer() ); + m_controls->SetSnapping( !evt->Modifier( MD_ALT ) ); + cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), getDrawingLayer() ); // 45 degree angle constraint enabled with an option and toggled with Ctrl const bool limit45 = ( frame()->Settings().m_use45DegreeGraphicSegments != !!( evt->Modifier( MD_CTRL ) ) ); @@ -1211,7 +1212,7 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic ) GRID_HELPER grid( m_frame ); m_controls->ShowCursor( true ); - m_controls->SetSnapping( false ); + m_controls->SetSnapping( true ); Activate(); @@ -1225,7 +1226,8 @@ bool DRAWING_TOOL::drawArc( DRAWSEGMENT*& aGraphic ) grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); - VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetCursorPosition(), aGraphic ); + m_controls->SetSnapping( !evt->Modifier( MD_ALT ) ); + VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), aGraphic ); if( evt->IsClick( BUT_LEFT ) ) { @@ -1359,14 +1361,15 @@ void DRAWING_TOOL::runPolygonEventLoop( POLYGON_GEOM_MANAGER& polyGeomMgr ) STATUS_TEXT_POPUP status( m_frame ); status.SetTextColor( wxColour( 255, 0, 0 ) ); status.SetText( _( "Self-intersecting polygons are not allowed" ) ); - m_controls->SetSnapping( false ); + m_controls->SetSnapping( true ); while( OPT_TOOL_EVENT evt = Wait() ) { LSET layers( m_frame->GetActiveLayer() ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); - VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetCursorPosition(), layers ); + m_controls->SetSnapping( !evt->Modifier( MD_ALT ) ); + VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), layers ); if( TOOL_EVT_UTILS::IsCancelInteractive( *evt ) ) { diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index 6d03011bd8..a137b0014e 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -359,7 +359,6 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) Activate(); controls->ShowCursor( true ); - controls->SetSnapping( false ); controls->SetAutoPan( true ); auto curr_item = static_cast( selection.Front() ); @@ -374,6 +373,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) { grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); + controls->SetSnapping( !evt->Modifier( MD_ALT ) ); if( evt->IsAction( &PCB_ACTIONS::editActivate ) || evt->IsAction( &PCB_ACTIONS::move ) || @@ -381,7 +381,7 @@ int EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) { if( m_dragging && evt->Category() == TC_MOUSE ) { - m_cursor = grid.BestSnapAnchor( controls->GetCursorPosition(), item_layers ); + m_cursor = grid.BestSnapAnchor( controls->GetMousePosition(), item_layers ); VECTOR2I movement( m_cursor - prevPos ); selection.SetReferencePoint( m_cursor ); @@ -1207,14 +1207,14 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) bool originSet = false; controls.ShowCursor( true ); - controls.SetSnapping( false ); controls.SetAutoPan( false ); while( auto evt = Wait() ) { grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); - const VECTOR2I cursorPos = grid.BestSnapAnchor( controls.GetCursorPosition(), nullptr ); + controls.SetSnapping( !evt->Modifier( MD_ALT ) ); + const VECTOR2I cursorPos = grid.BestSnapAnchor( controls.GetMousePosition(), nullptr ); 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 f4e981f8e6..1d5938e34c 100644 --- a/pcbnew/tools/picker_tool.cpp +++ b/pcbnew/tools/picker_tool.cpp @@ -50,7 +50,7 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent ) { grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( m_cursorSnapping ); - VECTOR2I cursorPos = grid.BestSnapAnchor( controls->GetCursorPosition(), m_layerMask ); + VECTOR2I cursorPos = grid.BestSnapAnchor( controls->GetMousePosition(), m_layerMask ); if( evt->IsClick( BUT_LEFT ) ) { diff --git a/pcbnew/tools/point_editor.cpp b/pcbnew/tools/point_editor.cpp index 4e65537f27..0a0554da16 100644 --- a/pcbnew/tools/point_editor.cpp +++ b/pcbnew/tools/point_editor.cpp @@ -308,7 +308,6 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent ) PCB_BASE_EDIT_FRAME* editFrame = getEditFrame(); controls->ShowCursor( true ); - controls->SetSnapping( false ); GRID_HELPER grid( editFrame ); BOARD_ITEM* item = static_cast( selection.Front() ); @@ -338,6 +337,7 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent ) grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); + controls->SetSnapping( !evt->Modifier( MD_ALT ) ); if( !m_editPoints || evt->Matches( m_selectionTool->ClearedEvent ) ||