diff --git a/common/tool/picker_tool.cpp b/common/tool/picker_tool.cpp index 9a39ab86a5..c62ea2da40 100644 --- a/common/tool/picker_tool.cpp +++ b/common/tool/picker_tool.cpp @@ -62,15 +62,12 @@ int PICKER_TOOL::Main( const TOOL_EVENT& aEvent ) m_frame->PushTool( tool ); Activate(); - // To many things are off-grid in LibEdit; turn snapping off. - bool snap = !m_frame->IsType( FRAME_SCH_LIB_EDITOR ); - setControls(); while( TOOL_EVENT* evt = Wait() ) { m_frame->GetCanvas()->SetCurrentCursor( m_cursor ); - VECTOR2D cursorPos = controls->GetCursorPosition( snap && !evt->Modifier( MD_ALT ) ); + VECTOR2D cursorPos = controls->GetCursorPosition( m_frame->IsGridVisible() ); if( evt->IsCancelInteractive() || evt->IsActivate() ) { diff --git a/eeschema/lib_view_frame.cpp b/eeschema/lib_view_frame.cpp index 7d907a494f..ba7401e203 100644 --- a/eeschema/lib_view_frame.cpp +++ b/eeschema/lib_view_frame.cpp @@ -194,7 +194,7 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame } SyncView(); - GetCanvas()->GetViewControls()->SetGridSnapping( true ); + GetCanvas()->GetViewControls()->SetGridSnapping( IsGridVisible() ); GetCanvas()->SetCanFocus( false ); // Set the working/draw area size to display a symbol to a reasonable value: diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index ed47fe347f..88835abc69 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -175,7 +175,7 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) : Show( true ); SyncView(); - GetCanvas()->GetViewControls()->SetGridSnapping( true ); + GetCanvas()->GetViewControls()->SetGridSnapping( IsGridVisible() ); GetCanvas()->GetView()->UseDrawPriority( true ); GetCanvas()->GetGAL()->SetAxesEnabled( true ); diff --git a/eeschema/sch_draw_panel.cpp b/eeschema/sch_draw_panel.cpp index 9e762fa301..6ba82ffe5a 100644 --- a/eeschema/sch_draw_panel.cpp +++ b/eeschema/sch_draw_panel.cpp @@ -91,7 +91,7 @@ SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId, // on updated viewport data. m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this ); - m_viewControls->SetGridSnapping( true ); + m_viewControls->SetGridSnapping( m_gal->GetGridVisibility() ); SetEvtHandlerEnabled( true ); SetFocus(); diff --git a/eeschema/sch_preview_panel.cpp b/eeschema/sch_preview_panel.cpp index e9a91fd459..1322e3d2ff 100644 --- a/eeschema/sch_preview_panel.cpp +++ b/eeschema/sch_preview_panel.cpp @@ -70,7 +70,7 @@ SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL( wxWindow* aParentWindow, wxWindowID aWindo m_gal->SetCursorEnabled( false ); m_gal->SetGridSize( VECTOR2D( Mils2iu( 100.0 ), Mils2iu( 100.0 ) ) ); - m_viewControls->SetGridSnapping( true ); + m_viewControls->SetGridSnapping( m_gal->GetGridVisibility() ); SetEvtHandlerEnabled( true ); SetFocus(); diff --git a/eeschema/tools/lib_drawing_tools.cpp b/eeschema/tools/lib_drawing_tools.cpp index 553058d2d1..3b152adfd3 100644 --- a/eeschema/tools/lib_drawing_tools.cpp +++ b/eeschema/tools/lib_drawing_tools.cpp @@ -397,7 +397,7 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent ) int LIB_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent ) { getViewControls()->ShowCursor( true ); - getViewControls()->SetGridSnapping( true ); + getViewControls()->SetGridSnapping( m_frame->IsGridVisible() ); std::string tool = aEvent.GetCommandStr().get(); m_frame->PushTool( tool ); diff --git a/eeschema/tools/lib_move_tool.cpp b/eeschema/tools/lib_move_tool.cpp index 7bc856add1..e59c9c0b6f 100644 --- a/eeschema/tools/lib_move_tool.cpp +++ b/eeschema/tools/lib_move_tool.cpp @@ -70,7 +70,7 @@ void LIB_MOVE_TOOL::Reset( RESET_REASON aReason ) int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) { KIGFX::VIEW_CONTROLS* controls = getViewControls(); - controls->SetGridSnapping( true ); + controls->SetGridSnapping( m_frame->IsGridVisible() ); m_anchorPos = { 0, 0 }; @@ -103,7 +103,7 @@ int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) do { m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); - controls->SetGridSnapping( !evt->Modifier( MD_ALT ) ); + controls->SetGridSnapping( m_frame->IsGridVisible() ); if( evt->IsAction( &EE_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT ) || evt->IsAction( &ACTIONS::refreshPreview ) @@ -271,7 +271,6 @@ int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) controls->ForceCursorPosition( false ); controls->ShowCursor( false ); - controls->SetGridSnapping( false ); controls->SetAutoPan( false ); if( !chain_commands ) diff --git a/eeschema/tools/sch_drawing_tools.cpp b/eeschema/tools/sch_drawing_tools.cpp index 58fa4c600c..c928046c28 100644 --- a/eeschema/tools/sch_drawing_tools.cpp +++ b/eeschema/tools/sch_drawing_tools.cpp @@ -449,7 +449,7 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true ); getViewControls()->ShowCursor( true ); - getViewControls()->SetGridSnapping( true ); + getViewControls()->SetGridSnapping( m_frame->IsGridVisible() ); SCH_ITEM* previewItem; switch( type ) diff --git a/eeschema/tools/sch_move_tool.cpp b/eeschema/tools/sch_move_tool.cpp index 9c14e11ac6..bbed0fd2f1 100644 --- a/eeschema/tools/sch_move_tool.cpp +++ b/eeschema/tools/sch_move_tool.cpp @@ -109,7 +109,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings(); KIGFX::VIEW_CONTROLS* controls = getViewControls(); - controls->SetGridSnapping( true ); + controls->SetGridSnapping( m_frame->IsGridVisible() ); m_anchorPos.reset(); @@ -171,7 +171,7 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) do { m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); - controls->SetGridSnapping( !evt->Modifier( MD_ALT ) ); + controls->SetGridSnapping( m_frame->IsGridVisible() ); if( evt->IsAction( &EE_ACTIONS::moveActivate ) || evt->IsAction( &EE_ACTIONS::restartMove ) || evt->IsAction( &EE_ACTIONS::move ) || evt->IsAction( &EE_ACTIONS::drag ) @@ -428,7 +428,6 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent ) controls->ForceCursorPosition( false ); controls->ShowCursor( false ); - controls->SetGridSnapping( false ); controls->SetAutoPan( false ); if( !chain_commands ) diff --git a/gerbview/gerbview_draw_panel_gal.cpp b/gerbview/gerbview_draw_panel_gal.cpp index 28b541c806..29d19e20d7 100644 --- a/gerbview/gerbview_draw_panel_gal.cpp +++ b/gerbview/gerbview_draw_panel_gal.cpp @@ -49,6 +49,7 @@ EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalTy m_view->SetPainter( m_painter.get() ); m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this ); + m_viewControls->SetGridSnapping( m_gal->GetGridVisibility() ); setDefaultLayerDeps(); diff --git a/gerbview/tools/gerbview_selection_tool.cpp b/gerbview/tools/gerbview_selection_tool.cpp index f59e3a38e7..cc830c7eda 100644 --- a/gerbview/tools/gerbview_selection_tool.cpp +++ b/gerbview/tools/gerbview_selection_tool.cpp @@ -571,7 +571,7 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent ) bool originSet = false; controls.ShowCursor( true ); - controls.SetGridSnapping( true ); + controls.SetGridSnapping( m_frame->IsGridVisible() ); while( TOOL_EVENT* evt = Wait() ) { diff --git a/pagelayout_editor/pl_draw_panel_gal.cpp b/pagelayout_editor/pl_draw_panel_gal.cpp index a8f370a952..d78d1f3007 100644 --- a/pagelayout_editor/pl_draw_panel_gal.cpp +++ b/pagelayout_editor/pl_draw_panel_gal.cpp @@ -65,6 +65,7 @@ PL_DRAW_PANEL_GAL::PL_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindo m_view->SetLayerVisible( LAYER_WORKSHEET_PAGEn, false ); m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this ); + m_viewControls->SetGridSnapping( m_gal->GetGridVisibility() ); } diff --git a/pagelayout_editor/tools/pl_edit_tool.cpp b/pagelayout_editor/tools/pl_edit_tool.cpp index 8a9ee0559b..82d08fb21e 100644 --- a/pagelayout_editor/tools/pl_edit_tool.cpp +++ b/pagelayout_editor/tools/pl_edit_tool.cpp @@ -93,7 +93,7 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) { KIGFX::VIEW_CONTROLS* controls = getViewControls(); - controls->SetGridSnapping( true ); + controls->SetGridSnapping( m_frame->IsGridVisible() ); VECTOR2I originalCursorPos = controls->GetCursorPosition(); // Be sure that there is at least one item that we can move. If there's no selection try @@ -123,7 +123,7 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) do { m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); - controls->SetGridSnapping( !evt->Modifier( MD_ALT ) ); + controls->SetGridSnapping( m_frame->IsGridVisible() ); if( evt->IsAction( &PL_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT ) || evt->IsAction( &ACTIONS::refreshPreview ) ) @@ -236,7 +236,6 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent ) controls->ForceCursorPosition( false ); controls->ShowCursor( false ); - controls->SetGridSnapping( false ); controls->SetAutoPan( false ); if( !chain_commands ) diff --git a/pcbnew/pcb_draw_panel_gal.cpp b/pcbnew/pcb_draw_panel_gal.cpp index 39e76e6cd8..c9ab845a22 100644 --- a/pcbnew/pcb_draw_panel_gal.cpp +++ b/pcbnew/pcb_draw_panel_gal.cpp @@ -126,6 +126,7 @@ PCB_DRAW_PANEL_GAL::PCB_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWin // View controls is the first in the event handler chain, so the Tool Framework operates // on updated viewport data. m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this ); + m_viewControls->SetGridSnapping( m_gal->GetGridVisibility() ); // Load display options (such as filled/outline display of items). // Can be made only if the parent window is an EDA_DRAW_FRAME (or a derived class) diff --git a/pcbnew/tools/drawing_tool.cpp b/pcbnew/tools/drawing_tool.cpp index fb48f55c0f..207d2d94e6 100644 --- a/pcbnew/tools/drawing_tool.cpp +++ b/pcbnew/tools/drawing_tool.cpp @@ -408,7 +408,7 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); m_controls->ShowCursor( true ); - m_controls->SetGridSnapping( true ); + m_controls->SetGridSnapping( m_frame->IsGridVisible() ); // do not capture or auto-pan until we start placing some text SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::TEXT ); @@ -620,7 +620,7 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); m_controls->ShowCursor( true ); - m_controls->SetGridSnapping( true ); + m_controls->SetGridSnapping( m_frame->IsGridVisible() ); SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DIMENSION ); @@ -650,8 +650,8 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent ) m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); - grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); - m_controls->SetGridSnapping( !evt->Modifier( MD_ALT ) ); + grid.SetUseGrid( m_frame->IsGridVisible() ); + m_controls->SetGridSnapping( m_frame->IsGridVisible() ); VECTOR2I cursorPos = grid.BestSnapAnchor( evt->IsPrime() ? evt->Position() : m_controls->GetMousePosition(), nullptr ); m_controls->ForceCursorPosition( true, cursorPos ); @@ -916,7 +916,7 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &newItems ); m_controls->ShowCursor( true ); - m_controls->SetGridSnapping( true ); + m_controls->SetGridSnapping( m_frame->IsGridVisible() ); m_controls->ForceCursorPosition( false ); SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DXF ); @@ -1011,7 +1011,6 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); m_controls->ShowCursor( true ); - m_controls->SetGridSnapping( true ); m_controls->SetAutoPan( true ); m_controls->CaptureCursor( false ); @@ -1020,8 +1019,8 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent ) m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_BULLSEYE ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); - grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); - m_controls->SetGridSnapping( !evt->Modifier( MD_ALT ) ); + grid.SetUseGrid( m_frame->IsGridVisible() ); + m_controls->SetGridSnapping( m_frame->IsGridVisible() ); VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), LSET::AllLayersMask() ); m_controls->ForceCursorPosition( true, cursorPos ); @@ -1124,8 +1123,8 @@ bool DRAWING_TOOL::drawSegment( const std::string& aTool, int aShape, DRAWSEGMEN m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); - grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); - m_controls->SetGridSnapping( !evt->Modifier( MD_ALT ) ); + grid.SetUseGrid( m_frame->IsGridVisible() ); + m_controls->SetGridSnapping( m_frame->IsGridVisible() ); cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), m_frame->GetActiveLayer() ); m_controls->ForceCursorPosition( true, cursorPos ); @@ -1383,7 +1382,6 @@ bool DRAWING_TOOL::drawArc( const std::string& aTool, DRAWSEGMENT** aGraphic, bo GRID_HELPER grid( m_toolMgr, m_frame->GetMagneticItemsSettings() ); m_controls->ShowCursor( true ); - m_controls->SetGridSnapping( true ); bool firstPoint = false; bool cancelled = false; @@ -1402,8 +1400,8 @@ bool DRAWING_TOOL::drawArc( const std::string& aTool, DRAWSEGMENT** aGraphic, bo m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); - grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); - m_controls->SetGridSnapping( !evt->Modifier( MD_ALT ) ); + grid.SetUseGrid( m_frame->IsGridVisible() ); + m_controls->SetGridSnapping( m_frame->IsGridVisible() ); VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), graphic ); m_controls->ForceCursorPosition( true, cursorPos ); @@ -1623,7 +1621,6 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent ) Activate(); // register for events m_controls->ShowCursor( true ); - m_controls->SetGridSnapping( true ); bool started = false; GRID_HELPER grid( m_toolMgr, m_frame->GetMagneticItemsSettings() ); @@ -1641,8 +1638,8 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent ) m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL ); LSET layers( m_frame->GetActiveLayer() ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); - grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); - m_controls->SetGridSnapping( !evt->Modifier( MD_ALT ) ); + grid.SetUseGrid( m_frame->IsGridVisible() ); + m_controls->SetGridSnapping( m_frame->IsGridVisible() ); VECTOR2I cursorPos = grid.BestSnapAnchor( evt->IsPrime() ? evt->Position() : m_controls->GetMousePosition(), layers ); diff --git a/pcbnew/tools/edit_tool.cpp b/pcbnew/tools/edit_tool.cpp index b107e44e36..abbf08d130 100644 --- a/pcbnew/tools/edit_tool.cpp +++ b/pcbnew/tools/edit_tool.cpp @@ -409,7 +409,7 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference ) editFrame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); - controls->SetGridSnapping( !evt->Modifier( MD_ALT ) ); + controls->SetGridSnapping( frame()->IsGridVisible() ); if( evt->IsAction( &PCB_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT ) || evt->IsAction( &ACTIONS::refreshPreview ) @@ -616,7 +616,6 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference ) m_lockedSelected = false; controls->ForceCursorPosition( false ); controls->ShowCursor( false ); - controls->SetGridSnapping( false ); controls->SetAutoPan( false ); m_dragging = false; diff --git a/pcbnew/tools/grid_helper.cpp b/pcbnew/tools/grid_helper.cpp index b60aec376d..ce491e583e 100644 --- a/pcbnew/tools/grid_helper.cpp +++ b/pcbnew/tools/grid_helper.cpp @@ -322,9 +322,7 @@ VECTOR2I GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, const LSET& aLaye if( nearest && m_enableSnap ) { - double snapDist = nearest->Distance( aOrigin ); - - if( !m_enableGrid || snapDist <= gridDist ) + if( nearest->Distance( aOrigin ) <= snapRange ) { m_viewSnapPoint.SetPosition( wxPoint( nearest->pos ) ); m_viewSnapLine.SetPosition( wxPoint( nearest->pos ) ); diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index d35c808e98..0a3139bfe1 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -797,7 +797,7 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent ) m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); controls->ShowCursor( true ); - controls->SetGridSnapping( true ); + controls->SetGridSnapping( m_frame->IsGridVisible() ); std::string tool = aEvent.GetCommandStr().get(); m_frame->PushTool( tool ); @@ -1280,7 +1280,7 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent ) view->Add( &preview ); m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true ); - controls->SetGridSnapping( true ); + controls->SetGridSnapping( frame()->IsGridVisible() ); std::string tool = aEvent.GetCommandStr().get(); m_frame->PushTool( tool ); @@ -1363,7 +1363,6 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent ) preview.Clear(); delete target; view->Remove( &preview ); - controls->SetGridSnapping( false ); return 0; } diff --git a/pcbnew/tools/pcb_tool_base.cpp b/pcbnew/tools/pcb_tool_base.cpp index d594de16cf..49451fc804 100644 --- a/pcbnew/tools/pcb_tool_base.cpp +++ b/pcbnew/tools/pcb_tool_base.cpp @@ -50,7 +50,7 @@ void PCB_TOOL_BASE::doInteractiveItemPlacement( const std::string& aTool, // do not capture or auto-pan until we start placing an item controls()->ShowCursor( true ); - controls()->SetGridSnapping( true ); + controls()->SetGridSnapping( frame()->IsGridVisible() ); // Add a VIEW_GROUP that serves as a preview for the new item PCBNEW_SELECTION preview; diff --git a/pcbnew/tools/pcb_viewer_tools.cpp b/pcbnew/tools/pcb_viewer_tools.cpp index ee22700cfc..182f845f48 100644 --- a/pcbnew/tools/pcb_viewer_tools.cpp +++ b/pcbnew/tools/pcb_viewer_tools.cpp @@ -225,7 +225,7 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent ) frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW ); grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); - controls.SetGridSnapping( !evt->Modifier( MD_ALT ) ); + controls.SetGridSnapping( frame()->IsGridVisible() ); const VECTOR2I cursorPos = grid.BestSnapAnchor( controls.GetMousePosition(), nullptr ); controls.ForceCursorPosition(true, cursorPos ); diff --git a/pcbnew/tools/pcbnew_picker_tool.cpp b/pcbnew/tools/pcbnew_picker_tool.cpp index 0c2e0ac6d6..928a002cd1 100644 --- a/pcbnew/tools/pcbnew_picker_tool.cpp +++ b/pcbnew/tools/pcbnew_picker_tool.cpp @@ -59,7 +59,7 @@ int PCBNEW_PICKER_TOOL::Main( const TOOL_EVENT& aEvent ) grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); - controls->SetGridSnapping( !evt->Modifier( MD_ALT ) ); + controls->SetGridSnapping( frame->IsGridVisible() ); VECTOR2I cursorPos = grid.BestSnapAnchor( controls->GetMousePosition(), nullptr ); controls->ForceCursorPosition(true, cursorPos ); @@ -186,9 +186,6 @@ void PCBNEW_PICKER_TOOL::setControls() { KIGFX::VIEW_CONTROLS* controls = getViewControls(); - // Ensure that the view controls do not handle our snapping as we use the GRID_HELPER - controls->SetGridSnapping( false ); - controls->CaptureCursor( false ); controls->SetAutoPan( false ); } diff --git a/pcbnew/tools/point_editor.cpp b/pcbnew/tools/point_editor.cpp index 10aa674d8a..112b130805 100644 --- a/pcbnew/tools/point_editor.cpp +++ b/pcbnew/tools/point_editor.cpp @@ -382,8 +382,8 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent ) while( TOOL_EVENT* evt = Wait() ) { grid.SetSnap( !evt->Modifier( MD_SHIFT ) ); - grid.SetUseGrid( !evt->Modifier( MD_ALT ) ); - controls->SetGridSnapping( !evt->Modifier( MD_ALT ) ); + grid.SetUseGrid( editFrame->IsGridVisible() ); + controls->SetGridSnapping( editFrame->IsGridVisible() ); if( !m_editPoints || evt->IsSelectionEvent() ) break;