ADDED: Menu option to enable/disable snap to grid

You can now enable and disable snap to grid when drawing/editing across
all apps.  You can also tie snap to grid to the visibility of the grid
to allow rapid enable/disable via grid display.
This commit is contained in:
Seth Hillbrand 2020-09-10 20:07:56 -07:00
parent d6322dcf0d
commit f493e270ea
37 changed files with 84 additions and 71 deletions

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 2016-2017 Kicad Developers, see change_log.txt for contributors.
* Copyright (C) 2016-2020 Kicad Developers, see change_log.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -39,6 +39,13 @@ static const UTIL::CFG_MAP<KIGFX::GRID_STYLE> gridStyleConfigVals =
{ KIGFX::GRID_STYLE::SMALL_CROSS,2 },
};
static const UTIL::CFG_MAP<KIGFX::GRID_SNAPPING> gridSnapConfigVals =
{
{ KIGFX::GRID_SNAPPING::ALWAYS, 0 },
{ KIGFX::GRID_SNAPPING::WITH_GRID, 1 },
{ KIGFX::GRID_SNAPPING::NEVER, 2 }
};
/**
* Flag to enable GAL_DISPLAY_OPTIONS logging
@ -55,6 +62,7 @@ GAL_DISPLAY_OPTIONS::GAL_DISPLAY_OPTIONS()
cairo_antialiasing_mode( CAIRO_ANTIALIASING_MODE::NONE ),
m_dpi( nullptr, nullptr ),
m_gridStyle( GRID_STYLE::DOTS ),
m_gridSnapping( GRID_SNAPPING::ALWAYS ),
m_gridLineWidth( 1.0 ),
m_gridMinSpacing( 10.0 ),
m_axesEnabled( false ),
@ -69,6 +77,7 @@ void GAL_DISPLAY_OPTIONS::ReadWindowSettings( WINDOW_SETTINGS& aCfg )
wxLogTrace( traceGalDispOpts, "Reading app-specific options" );
m_gridStyle = UTIL::GetValFromConfig( gridStyleConfigVals, aCfg.grid.style );
m_gridSnapping = UTIL::GetValFromConfig( gridSnapConfigVals, aCfg.grid.snap );
m_gridLineWidth = aCfg.grid.line_width;
m_gridMinSpacing = aCfg.grid.min_spacing;
m_axesEnabled = aCfg.grid.axes_enabled;
@ -113,6 +122,7 @@ void GAL_DISPLAY_OPTIONS::WriteConfig( WINDOW_SETTINGS& aCfg )
wxLogTrace( traceGalDispOpts, "Writing window settings" );
aCfg.grid.style = UTIL::GetConfigForVal( gridStyleConfigVals, m_gridStyle );
aCfg.grid.snap = UTIL::GetConfigForVal( gridSnapConfigVals, m_gridSnapping );
aCfg.grid.line_width = m_gridLineWidth;
aCfg.grid.min_spacing = m_gridMinSpacing;
aCfg.grid.axes_enabled = m_axesEnabled;
@ -123,8 +133,11 @@ void GAL_DISPLAY_OPTIONS::WriteConfig( WINDOW_SETTINGS& aCfg )
void GAL_DISPLAY_OPTIONS::UpdateScaleFactor()
{
m_scaleFactor = m_dpi.GetScaleFactor();
NotifyChanged();
if( m_scaleFactor != m_dpi.GetScaleFactor() )
{
m_scaleFactor = m_dpi.GetScaleFactor();
NotifyChanged();
}
}

View File

@ -312,6 +312,9 @@ void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std:
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.style",
&aWindow->grid.style, 0 ) );
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.snap",
&aWindow->grid.snap, 0 ) );
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".cursor.always_show_cursor",
&aWindow->cursor.always_show_cursor, true ) );

View File

@ -87,7 +87,6 @@ void VIEW_CONTROLS::ApplySettings( const VC_SETTINGS& aSettings )
{
ShowCursor( aSettings.m_showCursor );
CaptureCursor( aSettings.m_cursorCaptured );
SetGridSnapping( aSettings.m_snappingEnabled );
SetGrabMouse( aSettings.m_grabMouse );
SetAutoPan( aSettings.m_autoPanEnabled );
SetAutoPanMargin( aSettings.m_autoPanMargin );

View File

@ -498,9 +498,11 @@ VECTOR2D WX_VIEW_CONTROLS::GetMousePosition( bool aWorldCoordinates ) const
VECTOR2D WX_VIEW_CONTROLS::GetRawCursorPosition( bool aEnableSnapping ) const
{
if( aEnableSnapping )
GAL* gal = m_view->GetGAL();
if( aEnableSnapping && gal->GetGridSnapping() )
{
return m_view->GetGAL()->GetGridPoint( m_cursorPos );
return gal->GetGridPoint( m_cursorPos );
}
else
{

View File

@ -24,6 +24,7 @@
#include <wx/sizer.h>
#include <wx/checkbox.h>
#include <wx/choice.h>
#include <wx/radiobox.h>
#include <wx/spinctrl.h>
#include <wx/stattext.h>
@ -45,7 +46,7 @@ static const double gridMinSpacingMin = 5;
static const double gridMinSpacingMax = 200;
static const double gridMinSpacingStep = 5;
///TODO: These are duplicated in gal_display_options - Unify!
static const UTIL::CFG_MAP<KIGFX::GRID_STYLE> gridStyleSelectMap =
{
{ KIGFX::GRID_STYLE::DOTS, 0 }, // Default
@ -53,6 +54,12 @@ static const UTIL::CFG_MAP<KIGFX::GRID_STYLE> gridStyleSelectMap =
{ KIGFX::GRID_STYLE::SMALL_CROSS, 2 },
};
static const UTIL::CFG_MAP<KIGFX::GRID_SNAPPING> gridSnapConfigVals =
{
{ KIGFX::GRID_SNAPPING::ALWAYS, 0 },
{ KIGFX::GRID_SNAPPING::WITH_GRID, 1 },
{ KIGFX::GRID_SNAPPING::NEVER, 2 }
};
GAL_OPTIONS_PANEL::GAL_OPTIONS_PANEL( wxWindow* aParent, KIGFX::GAL_DISPLAY_OPTIONS& aGalOpts ):
wxPanel( aParent, wxID_ANY ),
@ -124,6 +131,25 @@ GAL_OPTIONS_PANEL::GAL_OPTIONS_PANEL( wxWindow* aParent, KIGFX::GAL_DISPLAY_OPTI
l_gridMinSpacingUnits->Wrap( -1 );
sGridSettingsGrid->Add( l_gridMinSpacingUnits, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
l_gridSnapOptions = new wxStaticText( sGridSettings->GetStaticBox(), wxID_ANY, _( "Snap to Grid:" ) );
l_gridSnapOptions->Wrap( -1 );
sGridSettingsGrid->Add( l_gridSnapOptions, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
wxString gridSnapChoices[] = { _( "Always"), _("When grid shown"), _("Never") };
int gridSnapNChoices = sizeof( gridSnapChoices ) / sizeof( wxString );
m_gridSnapOptions = new wxChoice( sGridSettings->GetStaticBox(), wxID_ANY,
wxDefaultPosition, wxDefaultSize, gridSnapNChoices, gridSnapChoices );
m_gridSnapOptions->Select( 0 );
sGridSettingsGrid->Add( m_gridSnapOptions, 0, wxALIGN_CENTER_VERTICAL | wxEXPAND | wxALL, 5 );
l_gridSnapSpace = new wxStaticText( sGridSettings->GetStaticBox(),
wxID_ANY, _( "px" ) );
l_gridSnapSpace->Wrap( -1 );
l_gridSnapSpace->Hide();
sGridSettingsGrid->Add( l_gridSnapSpace, 0,
wxALIGN_CENTER_VERTICAL | wxALL | wxRESERVE_SPACE_EVEN_IF_HIDDEN, 5 );
sGridSettings->Add( sGridSettingsGrid, 1, wxALL | wxEXPAND, 5 );
sLeftSizer->Add( sGridSettings, 0, wxTOP | wxBOTTOM | wxRIGHT | wxEXPAND, 5 );
@ -161,6 +187,9 @@ GAL_OPTIONS_PANEL::GAL_OPTIONS_PANEL( wxWindow* aParent, KIGFX::GAL_DISPLAY_OPTI
bool GAL_OPTIONS_PANEL::TransferDataToWindow()
{
m_gridSnapOptions->SetSelection(
UTIL::GetConfigForVal( gridSnapConfigVals, m_galOptions.m_gridSnapping ) );
m_gridStyle->SetSelection( UTIL::GetConfigForVal(
gridStyleSelectMap, m_galOptions.m_gridStyle ) );
@ -178,6 +207,9 @@ bool GAL_OPTIONS_PANEL::TransferDataToWindow()
bool GAL_OPTIONS_PANEL::TransferDataFromWindow()
{
m_galOptions.m_gridSnapping = UTIL::GetValFromConfig( gridSnapConfigVals,
m_gridSnapOptions->GetSelection() );
m_galOptions.m_gridStyle = UTIL::GetValFromConfig(
gridStyleSelectMap, m_gridStyle->GetSelection() );

View File

@ -194,7 +194,6 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
}
SyncView();
GetCanvas()->GetViewControls()->SetGridSnapping( IsGridVisible() );
GetCanvas()->SetCanFocus( false );
// Set the working/draw area size to display a symbol to a reasonable value:

View File

@ -175,7 +175,6 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
Show( true );
SyncView();
GetCanvas()->GetViewControls()->SetGridSnapping( IsGridVisible() );
GetCanvas()->GetView()->UseDrawPriority( true );
GetCanvas()->GetGAL()->SetAxesEnabled( true );

View File

@ -91,8 +91,6 @@ 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( m_gal->GetGridVisibility() );
SetEvtHandlerEnabled( true );
SetFocus();
Show( true );

View File

@ -70,8 +70,6 @@ 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( m_gal->GetGridVisibility() );
SetEvtHandlerEnabled( true );
SetFocus();
Show( true );

View File

@ -108,7 +108,7 @@ void EE_GRID_HELPER::SetAuxAxes( bool aEnable, const VECTOR2I& aOrigin )
VECTOR2I EE_GRID_HELPER::Align( const VECTOR2I& aPoint ) const
{
if( !m_toolMgr->GetView()->GetGAL()->GetGridVisibility() )
if( !m_toolMgr->GetView()->GetGAL()->GetGridSnapping() )
return aPoint;
const VECTOR2D gridOffset( GetOrigin() );

View File

@ -397,7 +397,6 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
int LIB_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
{
getViewControls()->ShowCursor( true );
getViewControls()->SetGridSnapping( m_frame->IsGridVisible() );
std::string tool = aEvent.GetCommandStr().get();
m_frame->PushTool( tool );

View File

@ -70,7 +70,6 @@ void LIB_MOVE_TOOL::Reset( RESET_REASON aReason )
int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
{
KIGFX::VIEW_CONTROLS* controls = getViewControls();
controls->SetGridSnapping( m_frame->IsGridVisible() );
m_anchorPos = { 0, 0 };
@ -103,7 +102,6 @@ int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
do
{
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
controls->SetGridSnapping( m_frame->IsGridVisible() );
if( evt->IsAction( &EE_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
|| evt->IsAction( &ACTIONS::refreshPreview )

View File

@ -449,7 +449,6 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
getViewControls()->ShowCursor( true );
getViewControls()->SetGridSnapping( m_frame->IsGridVisible() );
SCH_ITEM* previewItem;
switch( type )

View File

@ -469,7 +469,6 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
controls->ShowCursor( true );
controls->SetGridSnapping( m_frame->IsGridVisible() );
Activate();
@ -489,7 +488,6 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
controls->SetGridSnapping( m_frame->IsGridVisible() );
wxPoint cursorPos = wxPoint( grid.BestSnapAnchor(
evt->IsPrime() ? evt->Position() : controls->GetMousePosition(), nullptr ) );
controls->ForceCursorPosition( true, cursorPos );

View File

@ -110,7 +110,6 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
KIGFX::VIEW_CONTROLS* controls = getViewControls();
controls->SetGridSnapping( m_frame->IsGridVisible() );
EE_GRID_HELPER grid( m_toolMgr );
m_anchorPos.reset();
@ -173,7 +172,6 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
do
{
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
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 )

View File

@ -49,7 +49,6 @@ 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();

View File

@ -571,7 +571,6 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
bool originSet = false;
controls.ShowCursor( true );
controls.SetGridSnapping( m_frame->IsGridVisible() );
while( TOOL_EVENT* evt = Wait() )
{

View File

@ -62,6 +62,13 @@ namespace KIGFX
BEST,
};
enum class GRID_SNAPPING
{
ALWAYS,
WITH_GRID,
NEVER
};
class GAL_DISPLAY_OPTIONS;
class GAL_DISPLAY_OPTIONS_OBSERVER
@ -116,6 +123,9 @@ namespace KIGFX
///> The grid style to draw the grid in
KIGFX::GRID_STYLE m_gridStyle;
///> Snapping options for the grid
GRID_SNAPPING m_gridSnapping;
///> Thickness to render grid lines/dots
double m_gridLineWidth;

View File

@ -861,6 +861,11 @@ public:
bool GetGridVisibility() const { return gridVisibility; }
bool GetGridSnapping() const
{
return ( options.m_gridSnapping == KIGFX::GRID_SNAPPING::ALWAYS ||
( gridVisibility && options.m_gridSnapping == KIGFX::GRID_SNAPPING::WITH_GRID ) );
}
/**
* @brief Set the origin point for the grid.
*

View File

@ -59,6 +59,7 @@ struct GRID_SETTINGS
double min_spacing;
bool show;
int style;
int snap;
};
/**

View File

@ -153,25 +153,6 @@ public:
{
}
/**
* Function SetGridSnapping()
* Enables/disables snapping cursor to grid.
*
* @param aEnabled says whether the opion should be enabled or disabled.
*/
virtual void SetGridSnapping( bool aEnabled )
{
m_settings.m_snappingEnabled = aEnabled;
}
/**
* @return the current state of the snapping cursor to grid.
*/
virtual bool GetGridSnapping()
{
return m_settings.m_snappingEnabled;
}
/**
* Function SetGrabMouse
* Turns on/off mouse grabbing. When the mouse is grabbed, it cannot go outside the VIEW.

View File

@ -63,6 +63,10 @@ private:
wxSpinCtrlDouble* m_gridMinSpacing;
wxStaticText* l_gridMinSpacingUnits;
wxStaticText* l_gridSnapOptions;
wxChoice* m_gridSnapOptions;
wxStaticText* l_gridSnapSpace;
wxRadioBox* m_cursorShape;
wxCheckBox* m_forceCursorDisplay;

View File

@ -65,7 +65,6 @@ 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() );
}

View File

@ -93,7 +93,6 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
{
KIGFX::VIEW_CONTROLS* controls = getViewControls();
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 +122,6 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
do
{
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
controls->SetGridSnapping( m_frame->IsGridVisible() );
if( evt->IsAction( &PL_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
|| evt->IsAction( &ACTIONS::refreshPreview ) )

View File

@ -130,7 +130,6 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
bool originSet = false;
controls.ShowCursor( true );
controls.SetGridSnapping( true );
controls.CaptureCursor( false );
controls.SetAutoPan( false );

View File

@ -126,7 +126,6 @@ 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)

View File

@ -270,7 +270,6 @@ int LENGTH_TUNER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
m_router->SetMode( aEvent.Parameter<PNS::ROUTER_MODE>() );
controls()->SetGridSnapping( true );
controls()->ShowCursor( true );
frame()->UndoRedoBlock( true );

View File

@ -2,7 +2,7 @@
* KiRouter - a push-and-(sometimes-)shove PCB router
*
* Copyright (C) 2013 CERN
* Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2016-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
*
* This program is free software: you can redistribute it and/or modify it
@ -24,13 +24,15 @@
using namespace std::placeholders;
#include <id.h>
#include <view/view.h>
#include <view/view_controls.h>
#include <pcb_painter.h>
#include <pcbnew_settings.h>
#include <bitmaps.h>
#include <tools/pcb_actions.h>
#include <tools/grid_helper.h>
#include <tools/pcb_actions.h>
#include <tool/tool_manager.h>
#include "pns_arc.h"
#include "pns_kicad_iface.h"
@ -265,7 +267,7 @@ void TOOL_BASE::updateStartItem( const TOOL_EVENT& aEvent, bool aIgnorePads )
VECTOR2I p;
controls()->ForceCursorPosition( false );
m_gridHelper->SetUseGrid( !aEvent.Modifier( MD_ALT ) );
m_gridHelper->SetUseGrid( m_toolMgr->GetView()->GetGAL()->GetGridSnapping() );
m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
bool snapEnabled = true;
@ -298,7 +300,7 @@ void TOOL_BASE::updateEndItem( const TOOL_EVENT& aEvent )
{
int layer;
bool snapEnabled = !aEvent.Modifier( MD_SHIFT );
m_gridHelper->SetUseGrid( !aEvent.Modifier( MD_ALT ) );
m_gridHelper->SetUseGrid( m_toolMgr->GetView()->GetGAL()->GetGridSnapping() );
m_gridHelper->SetSnap( snapEnabled );
controls()->ForceCursorPosition( false );

View File

@ -408,7 +408,6 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
m_controls->ShowCursor( 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 +619,6 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
m_controls->ShowCursor( true );
m_controls->SetGridSnapping( m_frame->IsGridVisible() );
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DIMENSION );
@ -651,7 +649,6 @@ int DRAWING_TOOL::DrawDimension( const TOOL_EVENT& aEvent )
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
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 +913,6 @@ int DRAWING_TOOL::PlaceImportedGraphics( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &newItems );
m_controls->ShowCursor( true );
m_controls->SetGridSnapping( m_frame->IsGridVisible() );
m_controls->ForceCursorPosition( false );
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DXF );
@ -1020,7 +1016,6 @@ int DRAWING_TOOL::SetAnchor( const TOOL_EVENT& aEvent )
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
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,7 +1119,6 @@ bool DRAWING_TOOL::drawSegment( const std::string& aTool, int aShape, DRAWSEGMEN
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
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 );
@ -1401,7 +1395,6 @@ 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( m_frame->IsGridVisible() );
m_controls->SetGridSnapping( m_frame->IsGridVisible() );
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), graphic );
m_controls->ForceCursorPosition( true, cursorPos );
@ -1639,7 +1632,6 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
LSET layers( m_frame->GetActiveLayer() );
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( m_frame->IsGridVisible() );
m_controls->SetGridSnapping( m_frame->IsGridVisible() );
VECTOR2I cursorPos = grid.BestSnapAnchor( evt->IsPrime() ? evt->Position()
: m_controls->GetMousePosition(),
layers );

View File

@ -407,7 +407,6 @@ 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( frame()->IsGridVisible() );
if( evt->IsAction( &PCB_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
|| evt->IsAction( &ACTIONS::refreshPreview )

View File

@ -318,7 +318,6 @@ VECTOR2I GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, const LSET& aLaye
ANCHOR* nearest = nearestAnchor( aOrigin, SNAPPABLE, aLayers );
VECTOR2I nearestGrid = Align( aOrigin );
double gridDist = ( nearestGrid - aOrigin ).EuclideanNorm();
if( nearest && m_enableSnap )
{

View File

@ -31,9 +31,8 @@
#include <core/optional.h>
#include <origin_viewitem.h>
#include <layers_id_colors_and_visibility.h>
#include <geometry/seg.h>
#include <geometry/shape_arc.h>
class TOOL_MANAGER;
class GRID_HELPER {
public:

View File

@ -798,7 +798,6 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
controls->ShowCursor( true );
controls->SetGridSnapping( m_frame->IsGridVisible() );
std::string tool = aEvent.GetCommandStr().get();
m_frame->PushTool( tool );
@ -1281,7 +1280,6 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent )
view->Add( &preview );
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
controls->SetGridSnapping( frame()->IsGridVisible() );
std::string tool = aEvent.GetCommandStr().get();
m_frame->PushTool( tool );

View File

@ -50,7 +50,6 @@ 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( frame()->IsGridVisible() );
// Add a VIEW_GROUP that serves as a preview for the new item
PCBNEW_SELECTION preview;

View File

@ -225,7 +225,6 @@ 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( frame()->IsGridVisible() );
const VECTOR2I cursorPos = grid.BestSnapAnchor( controls.GetMousePosition(), nullptr );
controls.ForceCursorPosition(true, cursorPos );

View File

@ -59,7 +59,6 @@ int PCBNEW_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
controls->SetGridSnapping( frame->IsGridVisible() );
VECTOR2I cursorPos = grid.BestSnapAnchor( controls->GetMousePosition(), nullptr );
controls->ForceCursorPosition(true, cursorPos );

View File

@ -383,7 +383,6 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
{
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
grid.SetUseGrid( editFrame->IsGridVisible() );
controls->SetGridSnapping( editFrame->IsGridVisible() );
if( !m_editPoints || evt->IsSelectionEvent() )
break;