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:
parent
d6322dcf0d
commit
f493e270ea
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* This program source code file is part of KICAD, a free EDA CAD application.
|
* 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
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* 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 },
|
{ 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
|
* Flag to enable GAL_DISPLAY_OPTIONS logging
|
||||||
|
@ -55,6 +62,7 @@ GAL_DISPLAY_OPTIONS::GAL_DISPLAY_OPTIONS()
|
||||||
cairo_antialiasing_mode( CAIRO_ANTIALIASING_MODE::NONE ),
|
cairo_antialiasing_mode( CAIRO_ANTIALIASING_MODE::NONE ),
|
||||||
m_dpi( nullptr, nullptr ),
|
m_dpi( nullptr, nullptr ),
|
||||||
m_gridStyle( GRID_STYLE::DOTS ),
|
m_gridStyle( GRID_STYLE::DOTS ),
|
||||||
|
m_gridSnapping( GRID_SNAPPING::ALWAYS ),
|
||||||
m_gridLineWidth( 1.0 ),
|
m_gridLineWidth( 1.0 ),
|
||||||
m_gridMinSpacing( 10.0 ),
|
m_gridMinSpacing( 10.0 ),
|
||||||
m_axesEnabled( false ),
|
m_axesEnabled( false ),
|
||||||
|
@ -69,6 +77,7 @@ void GAL_DISPLAY_OPTIONS::ReadWindowSettings( WINDOW_SETTINGS& aCfg )
|
||||||
wxLogTrace( traceGalDispOpts, "Reading app-specific options" );
|
wxLogTrace( traceGalDispOpts, "Reading app-specific options" );
|
||||||
|
|
||||||
m_gridStyle = UTIL::GetValFromConfig( gridStyleConfigVals, aCfg.grid.style );
|
m_gridStyle = UTIL::GetValFromConfig( gridStyleConfigVals, aCfg.grid.style );
|
||||||
|
m_gridSnapping = UTIL::GetValFromConfig( gridSnapConfigVals, aCfg.grid.snap );
|
||||||
m_gridLineWidth = aCfg.grid.line_width;
|
m_gridLineWidth = aCfg.grid.line_width;
|
||||||
m_gridMinSpacing = aCfg.grid.min_spacing;
|
m_gridMinSpacing = aCfg.grid.min_spacing;
|
||||||
m_axesEnabled = aCfg.grid.axes_enabled;
|
m_axesEnabled = aCfg.grid.axes_enabled;
|
||||||
|
@ -113,6 +122,7 @@ void GAL_DISPLAY_OPTIONS::WriteConfig( WINDOW_SETTINGS& aCfg )
|
||||||
wxLogTrace( traceGalDispOpts, "Writing window settings" );
|
wxLogTrace( traceGalDispOpts, "Writing window settings" );
|
||||||
|
|
||||||
aCfg.grid.style = UTIL::GetConfigForVal( gridStyleConfigVals, m_gridStyle );
|
aCfg.grid.style = UTIL::GetConfigForVal( gridStyleConfigVals, m_gridStyle );
|
||||||
|
aCfg.grid.snap = UTIL::GetConfigForVal( gridSnapConfigVals, m_gridSnapping );
|
||||||
aCfg.grid.line_width = m_gridLineWidth;
|
aCfg.grid.line_width = m_gridLineWidth;
|
||||||
aCfg.grid.min_spacing = m_gridMinSpacing;
|
aCfg.grid.min_spacing = m_gridMinSpacing;
|
||||||
aCfg.grid.axes_enabled = m_axesEnabled;
|
aCfg.grid.axes_enabled = m_axesEnabled;
|
||||||
|
@ -123,8 +133,11 @@ void GAL_DISPLAY_OPTIONS::WriteConfig( WINDOW_SETTINGS& aCfg )
|
||||||
|
|
||||||
void GAL_DISPLAY_OPTIONS::UpdateScaleFactor()
|
void GAL_DISPLAY_OPTIONS::UpdateScaleFactor()
|
||||||
{
|
{
|
||||||
|
if( m_scaleFactor != m_dpi.GetScaleFactor() )
|
||||||
|
{
|
||||||
m_scaleFactor = m_dpi.GetScaleFactor();
|
m_scaleFactor = m_dpi.GetScaleFactor();
|
||||||
NotifyChanged();
|
NotifyChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -312,6 +312,9 @@ void APP_SETTINGS_BASE::addParamsForWindow( WINDOW_SETTINGS* aWindow, const std:
|
||||||
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.style",
|
m_params.emplace_back( new PARAM<int>( aJsonPath + ".grid.style",
|
||||||
&aWindow->grid.style, 0 ) );
|
&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",
|
m_params.emplace_back( new PARAM<bool>( aJsonPath + ".cursor.always_show_cursor",
|
||||||
&aWindow->cursor.always_show_cursor, true ) );
|
&aWindow->cursor.always_show_cursor, true ) );
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,6 @@ void VIEW_CONTROLS::ApplySettings( const VC_SETTINGS& aSettings )
|
||||||
{
|
{
|
||||||
ShowCursor( aSettings.m_showCursor );
|
ShowCursor( aSettings.m_showCursor );
|
||||||
CaptureCursor( aSettings.m_cursorCaptured );
|
CaptureCursor( aSettings.m_cursorCaptured );
|
||||||
SetGridSnapping( aSettings.m_snappingEnabled );
|
|
||||||
SetGrabMouse( aSettings.m_grabMouse );
|
SetGrabMouse( aSettings.m_grabMouse );
|
||||||
SetAutoPan( aSettings.m_autoPanEnabled );
|
SetAutoPan( aSettings.m_autoPanEnabled );
|
||||||
SetAutoPanMargin( aSettings.m_autoPanMargin );
|
SetAutoPanMargin( aSettings.m_autoPanMargin );
|
||||||
|
|
|
@ -498,9 +498,11 @@ VECTOR2D WX_VIEW_CONTROLS::GetMousePosition( bool aWorldCoordinates ) const
|
||||||
|
|
||||||
VECTOR2D WX_VIEW_CONTROLS::GetRawCursorPosition( bool aEnableSnapping ) 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
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include <wx/sizer.h>
|
#include <wx/sizer.h>
|
||||||
#include <wx/checkbox.h>
|
#include <wx/checkbox.h>
|
||||||
|
#include <wx/choice.h>
|
||||||
#include <wx/radiobox.h>
|
#include <wx/radiobox.h>
|
||||||
#include <wx/spinctrl.h>
|
#include <wx/spinctrl.h>
|
||||||
#include <wx/stattext.h>
|
#include <wx/stattext.h>
|
||||||
|
@ -45,7 +46,7 @@ static const double gridMinSpacingMin = 5;
|
||||||
static const double gridMinSpacingMax = 200;
|
static const double gridMinSpacingMax = 200;
|
||||||
static const double gridMinSpacingStep = 5;
|
static const double gridMinSpacingStep = 5;
|
||||||
|
|
||||||
|
///TODO: These are duplicated in gal_display_options - Unify!
|
||||||
static const UTIL::CFG_MAP<KIGFX::GRID_STYLE> gridStyleSelectMap =
|
static const UTIL::CFG_MAP<KIGFX::GRID_STYLE> gridStyleSelectMap =
|
||||||
{
|
{
|
||||||
{ KIGFX::GRID_STYLE::DOTS, 0 }, // Default
|
{ 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 },
|
{ 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 ):
|
GAL_OPTIONS_PANEL::GAL_OPTIONS_PANEL( wxWindow* aParent, KIGFX::GAL_DISPLAY_OPTIONS& aGalOpts ):
|
||||||
wxPanel( aParent, wxID_ANY ),
|
wxPanel( aParent, wxID_ANY ),
|
||||||
|
@ -124,6 +131,25 @@ GAL_OPTIONS_PANEL::GAL_OPTIONS_PANEL( wxWindow* aParent, KIGFX::GAL_DISPLAY_OPTI
|
||||||
l_gridMinSpacingUnits->Wrap( -1 );
|
l_gridMinSpacingUnits->Wrap( -1 );
|
||||||
sGridSettingsGrid->Add( l_gridMinSpacingUnits, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5 );
|
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 );
|
sGridSettings->Add( sGridSettingsGrid, 1, wxALL | wxEXPAND, 5 );
|
||||||
|
|
||||||
sLeftSizer->Add( sGridSettings, 0, wxTOP | wxBOTTOM | wxRIGHT | 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()
|
bool GAL_OPTIONS_PANEL::TransferDataToWindow()
|
||||||
{
|
{
|
||||||
|
m_gridSnapOptions->SetSelection(
|
||||||
|
UTIL::GetConfigForVal( gridSnapConfigVals, m_galOptions.m_gridSnapping ) );
|
||||||
|
|
||||||
m_gridStyle->SetSelection( UTIL::GetConfigForVal(
|
m_gridStyle->SetSelection( UTIL::GetConfigForVal(
|
||||||
gridStyleSelectMap, m_galOptions.m_gridStyle ) );
|
gridStyleSelectMap, m_galOptions.m_gridStyle ) );
|
||||||
|
|
||||||
|
@ -178,6 +207,9 @@ bool GAL_OPTIONS_PANEL::TransferDataToWindow()
|
||||||
|
|
||||||
bool GAL_OPTIONS_PANEL::TransferDataFromWindow()
|
bool GAL_OPTIONS_PANEL::TransferDataFromWindow()
|
||||||
{
|
{
|
||||||
|
m_galOptions.m_gridSnapping = UTIL::GetValFromConfig( gridSnapConfigVals,
|
||||||
|
m_gridSnapOptions->GetSelection() );
|
||||||
|
|
||||||
m_galOptions.m_gridStyle = UTIL::GetValFromConfig(
|
m_galOptions.m_gridStyle = UTIL::GetValFromConfig(
|
||||||
gridStyleSelectMap, m_gridStyle->GetSelection() );
|
gridStyleSelectMap, m_gridStyle->GetSelection() );
|
||||||
|
|
||||||
|
|
|
@ -194,7 +194,6 @@ LIB_VIEW_FRAME::LIB_VIEW_FRAME( KIWAY* aKiway, wxWindow* aParent, FRAME_T aFrame
|
||||||
}
|
}
|
||||||
|
|
||||||
SyncView();
|
SyncView();
|
||||||
GetCanvas()->GetViewControls()->SetGridSnapping( IsGridVisible() );
|
|
||||||
GetCanvas()->SetCanFocus( false );
|
GetCanvas()->SetCanFocus( false );
|
||||||
|
|
||||||
// Set the working/draw area size to display a symbol to a reasonable value:
|
// Set the working/draw area size to display a symbol to a reasonable value:
|
||||||
|
|
|
@ -175,7 +175,6 @@ LIB_EDIT_FRAME::LIB_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
|
||||||
Show( true );
|
Show( true );
|
||||||
|
|
||||||
SyncView();
|
SyncView();
|
||||||
GetCanvas()->GetViewControls()->SetGridSnapping( IsGridVisible() );
|
|
||||||
GetCanvas()->GetView()->UseDrawPriority( true );
|
GetCanvas()->GetView()->UseDrawPriority( true );
|
||||||
GetCanvas()->GetGAL()->SetAxesEnabled( true );
|
GetCanvas()->GetGAL()->SetAxesEnabled( true );
|
||||||
|
|
||||||
|
|
|
@ -91,8 +91,6 @@ SCH_DRAW_PANEL::SCH_DRAW_PANEL( wxWindow* aParentWindow, wxWindowID aWindowId,
|
||||||
// on updated viewport data.
|
// on updated viewport data.
|
||||||
m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this );
|
m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this );
|
||||||
|
|
||||||
m_viewControls->SetGridSnapping( m_gal->GetGridVisibility() );
|
|
||||||
|
|
||||||
SetEvtHandlerEnabled( true );
|
SetEvtHandlerEnabled( true );
|
||||||
SetFocus();
|
SetFocus();
|
||||||
Show( true );
|
Show( true );
|
||||||
|
|
|
@ -70,8 +70,6 @@ SCH_PREVIEW_PANEL::SCH_PREVIEW_PANEL( wxWindow* aParentWindow, wxWindowID aWindo
|
||||||
m_gal->SetCursorEnabled( false );
|
m_gal->SetCursorEnabled( false );
|
||||||
m_gal->SetGridSize( VECTOR2D( Mils2iu( 100.0 ), Mils2iu( 100.0 ) ) );
|
m_gal->SetGridSize( VECTOR2D( Mils2iu( 100.0 ), Mils2iu( 100.0 ) ) );
|
||||||
|
|
||||||
m_viewControls->SetGridSnapping( m_gal->GetGridVisibility() );
|
|
||||||
|
|
||||||
SetEvtHandlerEnabled( true );
|
SetEvtHandlerEnabled( true );
|
||||||
SetFocus();
|
SetFocus();
|
||||||
Show( true );
|
Show( true );
|
||||||
|
|
|
@ -108,7 +108,7 @@ void EE_GRID_HELPER::SetAuxAxes( bool aEnable, const VECTOR2I& aOrigin )
|
||||||
|
|
||||||
VECTOR2I EE_GRID_HELPER::Align( const VECTOR2I& aPoint ) const
|
VECTOR2I EE_GRID_HELPER::Align( const VECTOR2I& aPoint ) const
|
||||||
{
|
{
|
||||||
if( !m_toolMgr->GetView()->GetGAL()->GetGridVisibility() )
|
if( !m_toolMgr->GetView()->GetGAL()->GetGridSnapping() )
|
||||||
return aPoint;
|
return aPoint;
|
||||||
|
|
||||||
const VECTOR2D gridOffset( GetOrigin() );
|
const VECTOR2D gridOffset( GetOrigin() );
|
||||||
|
|
|
@ -397,7 +397,6 @@ int LIB_DRAWING_TOOLS::DrawShape( const TOOL_EVENT& aEvent )
|
||||||
int LIB_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
|
int LIB_DRAWING_TOOLS::PlaceAnchor( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
getViewControls()->ShowCursor( true );
|
getViewControls()->ShowCursor( true );
|
||||||
getViewControls()->SetGridSnapping( m_frame->IsGridVisible() );
|
|
||||||
|
|
||||||
std::string tool = aEvent.GetCommandStr().get();
|
std::string tool = aEvent.GetCommandStr().get();
|
||||||
m_frame->PushTool( tool );
|
m_frame->PushTool( tool );
|
||||||
|
|
|
@ -70,7 +70,6 @@ void LIB_MOVE_TOOL::Reset( RESET_REASON aReason )
|
||||||
int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||||
controls->SetGridSnapping( m_frame->IsGridVisible() );
|
|
||||||
|
|
||||||
m_anchorPos = { 0, 0 };
|
m_anchorPos = { 0, 0 };
|
||||||
|
|
||||||
|
@ -103,7 +102,6 @@ int LIB_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
controls->SetGridSnapping( m_frame->IsGridVisible() );
|
|
||||||
|
|
||||||
if( evt->IsAction( &EE_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
|
if( evt->IsAction( &EE_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
|
||||||
|| evt->IsAction( &ACTIONS::refreshPreview )
|
|| evt->IsAction( &ACTIONS::refreshPreview )
|
||||||
|
|
|
@ -449,7 +449,6 @@ int SCH_DRAWING_TOOLS::SingleClickPlace( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
getViewControls()->ShowCursor( true );
|
getViewControls()->ShowCursor( true );
|
||||||
getViewControls()->SetGridSnapping( m_frame->IsGridVisible() );
|
|
||||||
|
|
||||||
SCH_ITEM* previewItem;
|
SCH_ITEM* previewItem;
|
||||||
switch( type )
|
switch( type )
|
||||||
|
|
|
@ -469,7 +469,6 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType
|
||||||
|
|
||||||
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
m_toolMgr->RunAction( EE_ACTIONS::clearSelection, true );
|
||||||
controls->ShowCursor( true );
|
controls->ShowCursor( true );
|
||||||
controls->SetGridSnapping( m_frame->IsGridVisible() );
|
|
||||||
|
|
||||||
|
|
||||||
Activate();
|
Activate();
|
||||||
|
@ -489,7 +488,6 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
||||||
|
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
controls->SetGridSnapping( m_frame->IsGridVisible() );
|
|
||||||
wxPoint cursorPos = wxPoint( grid.BestSnapAnchor(
|
wxPoint cursorPos = wxPoint( grid.BestSnapAnchor(
|
||||||
evt->IsPrime() ? evt->Position() : controls->GetMousePosition(), nullptr ) );
|
evt->IsPrime() ? evt->Position() : controls->GetMousePosition(), nullptr ) );
|
||||||
controls->ForceCursorPosition( true, cursorPos );
|
controls->ForceCursorPosition( true, cursorPos );
|
||||||
|
|
|
@ -110,7 +110,6 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
|
EESCHEMA_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<EESCHEMA_SETTINGS>();
|
||||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||||
controls->SetGridSnapping( m_frame->IsGridVisible() );
|
|
||||||
EE_GRID_HELPER grid( m_toolMgr );
|
EE_GRID_HELPER grid( m_toolMgr );
|
||||||
|
|
||||||
m_anchorPos.reset();
|
m_anchorPos.reset();
|
||||||
|
@ -173,7 +172,6 @@ int SCH_MOVE_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
controls->SetGridSnapping( m_frame->IsGridVisible() );
|
|
||||||
|
|
||||||
if( evt->IsAction( &EE_ACTIONS::moveActivate ) || evt->IsAction( &EE_ACTIONS::restartMove )
|
if( evt->IsAction( &EE_ACTIONS::moveActivate ) || evt->IsAction( &EE_ACTIONS::restartMove )
|
||||||
|| evt->IsAction( &EE_ACTIONS::move ) || evt->IsAction( &EE_ACTIONS::drag )
|
|| evt->IsAction( &EE_ACTIONS::move ) || evt->IsAction( &EE_ACTIONS::drag )
|
||||||
|
|
|
@ -49,7 +49,6 @@ EDA_DRAW_PANEL_GAL( aParentWindow, aWindowId, aPosition, aSize, aOptions, aGalTy
|
||||||
m_view->SetPainter( m_painter.get() );
|
m_view->SetPainter( m_painter.get() );
|
||||||
|
|
||||||
m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this );
|
m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this );
|
||||||
m_viewControls->SetGridSnapping( m_gal->GetGridVisibility() );
|
|
||||||
|
|
||||||
setDefaultLayerDeps();
|
setDefaultLayerDeps();
|
||||||
|
|
||||||
|
|
|
@ -571,7 +571,6 @@ int GERBVIEW_SELECTION_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
bool originSet = false;
|
bool originSet = false;
|
||||||
|
|
||||||
controls.ShowCursor( true );
|
controls.ShowCursor( true );
|
||||||
controls.SetGridSnapping( m_frame->IsGridVisible() );
|
|
||||||
|
|
||||||
while( TOOL_EVENT* evt = Wait() )
|
while( TOOL_EVENT* evt = Wait() )
|
||||||
{
|
{
|
||||||
|
|
|
@ -62,6 +62,13 @@ namespace KIGFX
|
||||||
BEST,
|
BEST,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class GRID_SNAPPING
|
||||||
|
{
|
||||||
|
ALWAYS,
|
||||||
|
WITH_GRID,
|
||||||
|
NEVER
|
||||||
|
};
|
||||||
|
|
||||||
class GAL_DISPLAY_OPTIONS;
|
class GAL_DISPLAY_OPTIONS;
|
||||||
|
|
||||||
class GAL_DISPLAY_OPTIONS_OBSERVER
|
class GAL_DISPLAY_OPTIONS_OBSERVER
|
||||||
|
@ -116,6 +123,9 @@ namespace KIGFX
|
||||||
///> The grid style to draw the grid in
|
///> The grid style to draw the grid in
|
||||||
KIGFX::GRID_STYLE m_gridStyle;
|
KIGFX::GRID_STYLE m_gridStyle;
|
||||||
|
|
||||||
|
///> Snapping options for the grid
|
||||||
|
GRID_SNAPPING m_gridSnapping;
|
||||||
|
|
||||||
///> Thickness to render grid lines/dots
|
///> Thickness to render grid lines/dots
|
||||||
double m_gridLineWidth;
|
double m_gridLineWidth;
|
||||||
|
|
||||||
|
|
|
@ -861,6 +861,11 @@ public:
|
||||||
|
|
||||||
bool GetGridVisibility() const { return gridVisibility; }
|
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.
|
* @brief Set the origin point for the grid.
|
||||||
*
|
*
|
||||||
|
|
|
@ -59,6 +59,7 @@ struct GRID_SETTINGS
|
||||||
double min_spacing;
|
double min_spacing;
|
||||||
bool show;
|
bool show;
|
||||||
int style;
|
int style;
|
||||||
|
int snap;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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
|
* Function SetGrabMouse
|
||||||
* Turns on/off mouse grabbing. When the mouse is grabbed, it cannot go outside the VIEW.
|
* Turns on/off mouse grabbing. When the mouse is grabbed, it cannot go outside the VIEW.
|
||||||
|
|
|
@ -63,6 +63,10 @@ private:
|
||||||
wxSpinCtrlDouble* m_gridMinSpacing;
|
wxSpinCtrlDouble* m_gridMinSpacing;
|
||||||
wxStaticText* l_gridMinSpacingUnits;
|
wxStaticText* l_gridMinSpacingUnits;
|
||||||
|
|
||||||
|
wxStaticText* l_gridSnapOptions;
|
||||||
|
wxChoice* m_gridSnapOptions;
|
||||||
|
wxStaticText* l_gridSnapSpace;
|
||||||
|
|
||||||
wxRadioBox* m_cursorShape;
|
wxRadioBox* m_cursorShape;
|
||||||
wxCheckBox* m_forceCursorDisplay;
|
wxCheckBox* m_forceCursorDisplay;
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,6 @@ PL_DRAW_PANEL_GAL::PL_DRAW_PANEL_GAL( wxWindow* aParentWindow, wxWindowID aWindo
|
||||||
m_view->SetLayerVisible( LAYER_WORKSHEET_PAGEn, false );
|
m_view->SetLayerVisible( LAYER_WORKSHEET_PAGEn, false );
|
||||||
|
|
||||||
m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this );
|
m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this );
|
||||||
m_viewControls->SetGridSnapping( m_gal->GetGridVisibility() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,6 @@ int PL_EDIT_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
KIGFX::VIEW_CONTROLS* controls = getViewControls();
|
||||||
|
|
||||||
controls->SetGridSnapping( m_frame->IsGridVisible() );
|
|
||||||
VECTOR2I originalCursorPos = controls->GetCursorPosition();
|
VECTOR2I originalCursorPos = controls->GetCursorPosition();
|
||||||
|
|
||||||
// Be sure that there is at least one item that we can move. If there's no selection try
|
// 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
|
do
|
||||||
{
|
{
|
||||||
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
controls->SetGridSnapping( m_frame->IsGridVisible() );
|
|
||||||
|
|
||||||
if( evt->IsAction( &PL_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
|
if( evt->IsAction( &PL_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
|
||||||
|| evt->IsAction( &ACTIONS::refreshPreview ) )
|
|| evt->IsAction( &ACTIONS::refreshPreview ) )
|
||||||
|
|
|
@ -130,7 +130,6 @@ int MICROWAVE_TOOL::drawMicrowaveInductor( const TOOL_EVENT& aEvent )
|
||||||
bool originSet = false;
|
bool originSet = false;
|
||||||
|
|
||||||
controls.ShowCursor( true );
|
controls.ShowCursor( true );
|
||||||
controls.SetGridSnapping( true );
|
|
||||||
controls.CaptureCursor( false );
|
controls.CaptureCursor( false );
|
||||||
controls.SetAutoPan( false );
|
controls.SetAutoPan( false );
|
||||||
|
|
||||||
|
|
|
@ -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
|
// View controls is the first in the event handler chain, so the Tool Framework operates
|
||||||
// on updated viewport data.
|
// on updated viewport data.
|
||||||
m_viewControls = new KIGFX::WX_VIEW_CONTROLS( m_view, this );
|
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).
|
// 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)
|
// Can be made only if the parent window is an EDA_DRAW_FRAME (or a derived class)
|
||||||
|
|
|
@ -270,7 +270,6 @@ int LENGTH_TUNER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_router->SetMode( aEvent.Parameter<PNS::ROUTER_MODE>() );
|
m_router->SetMode( aEvent.Parameter<PNS::ROUTER_MODE>() );
|
||||||
|
|
||||||
controls()->SetGridSnapping( true );
|
|
||||||
controls()->ShowCursor( true );
|
controls()->ShowCursor( true );
|
||||||
frame()->UndoRedoBlock( true );
|
frame()->UndoRedoBlock( true );
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* KiRouter - a push-and-(sometimes-)shove PCB router
|
* KiRouter - a push-and-(sometimes-)shove PCB router
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 CERN
|
* 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>
|
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it
|
* This program is free software: you can redistribute it and/or modify it
|
||||||
|
@ -24,13 +24,15 @@
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
|
|
||||||
#include <id.h>
|
#include <id.h>
|
||||||
|
#include <view/view.h>
|
||||||
#include <view/view_controls.h>
|
#include <view/view_controls.h>
|
||||||
#include <pcb_painter.h>
|
#include <pcb_painter.h>
|
||||||
#include <pcbnew_settings.h>
|
#include <pcbnew_settings.h>
|
||||||
#include <bitmaps.h>
|
#include <bitmaps.h>
|
||||||
|
|
||||||
#include <tools/pcb_actions.h>
|
|
||||||
#include <tools/grid_helper.h>
|
#include <tools/grid_helper.h>
|
||||||
|
#include <tools/pcb_actions.h>
|
||||||
|
#include <tool/tool_manager.h>
|
||||||
|
|
||||||
#include "pns_arc.h"
|
#include "pns_arc.h"
|
||||||
#include "pns_kicad_iface.h"
|
#include "pns_kicad_iface.h"
|
||||||
|
@ -265,7 +267,7 @@ void TOOL_BASE::updateStartItem( const TOOL_EVENT& aEvent, bool aIgnorePads )
|
||||||
VECTOR2I p;
|
VECTOR2I p;
|
||||||
|
|
||||||
controls()->ForceCursorPosition( false );
|
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 ) );
|
m_gridHelper->SetSnap( !aEvent.Modifier( MD_SHIFT ) );
|
||||||
|
|
||||||
bool snapEnabled = true;
|
bool snapEnabled = true;
|
||||||
|
@ -298,7 +300,7 @@ void TOOL_BASE::updateEndItem( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
int layer;
|
int layer;
|
||||||
bool snapEnabled = !aEvent.Modifier( MD_SHIFT );
|
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 );
|
m_gridHelper->SetSnap( snapEnabled );
|
||||||
|
|
||||||
controls()->ForceCursorPosition( false );
|
controls()->ForceCursorPosition( false );
|
||||||
|
|
|
@ -408,7 +408,6 @@ int DRAWING_TOOL::PlaceText( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
m_controls->ShowCursor( true );
|
m_controls->ShowCursor( true );
|
||||||
m_controls->SetGridSnapping( m_frame->IsGridVisible() );
|
|
||||||
// do not capture or auto-pan until we start placing some text
|
// do not capture or auto-pan until we start placing some text
|
||||||
|
|
||||||
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::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_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
m_controls->ShowCursor( true );
|
m_controls->ShowCursor( true );
|
||||||
m_controls->SetGridSnapping( m_frame->IsGridVisible() );
|
|
||||||
|
|
||||||
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DIMENSION );
|
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.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( m_frame->IsGridVisible() );
|
grid.SetUseGrid( m_frame->IsGridVisible() );
|
||||||
m_controls->SetGridSnapping( m_frame->IsGridVisible() );
|
|
||||||
VECTOR2I cursorPos = grid.BestSnapAnchor(
|
VECTOR2I cursorPos = grid.BestSnapAnchor(
|
||||||
evt->IsPrime() ? evt->Position() : m_controls->GetMousePosition(), nullptr );
|
evt->IsPrime() ? evt->Position() : m_controls->GetMousePosition(), nullptr );
|
||||||
m_controls->ForceCursorPosition( true, cursorPos );
|
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_toolMgr->RunAction( PCB_ACTIONS::selectItems, true, &newItems );
|
||||||
|
|
||||||
m_controls->ShowCursor( true );
|
m_controls->ShowCursor( true );
|
||||||
m_controls->SetGridSnapping( m_frame->IsGridVisible() );
|
|
||||||
m_controls->ForceCursorPosition( false );
|
m_controls->ForceCursorPosition( false );
|
||||||
|
|
||||||
SCOPED_DRAW_MODE scopedDrawMode( m_mode, MODE::DXF );
|
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.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( m_frame->IsGridVisible() );
|
grid.SetUseGrid( m_frame->IsGridVisible() );
|
||||||
m_controls->SetGridSnapping( m_frame->IsGridVisible() );
|
|
||||||
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), LSET::AllLayersMask() );
|
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), LSET::AllLayersMask() );
|
||||||
m_controls->ForceCursorPosition( true, cursorPos );
|
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.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( m_frame->IsGridVisible() );
|
grid.SetUseGrid( m_frame->IsGridVisible() );
|
||||||
m_controls->SetGridSnapping( m_frame->IsGridVisible() );
|
|
||||||
cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), m_frame->GetActiveLayer() );
|
cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), m_frame->GetActiveLayer() );
|
||||||
m_controls->ForceCursorPosition( true, cursorPos );
|
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 );
|
m_frame->GetCanvas()->SetCurrentCursor( wxCURSOR_PENCIL );
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( m_frame->IsGridVisible() );
|
grid.SetUseGrid( m_frame->IsGridVisible() );
|
||||||
m_controls->SetGridSnapping( m_frame->IsGridVisible() );
|
|
||||||
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), graphic );
|
VECTOR2I cursorPos = grid.BestSnapAnchor( m_controls->GetMousePosition(), graphic );
|
||||||
m_controls->ForceCursorPosition( true, cursorPos );
|
m_controls->ForceCursorPosition( true, cursorPos );
|
||||||
|
|
||||||
|
@ -1639,7 +1632,6 @@ int DRAWING_TOOL::DrawZone( const TOOL_EVENT& aEvent )
|
||||||
LSET layers( m_frame->GetActiveLayer() );
|
LSET layers( m_frame->GetActiveLayer() );
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( m_frame->IsGridVisible() );
|
grid.SetUseGrid( m_frame->IsGridVisible() );
|
||||||
m_controls->SetGridSnapping( m_frame->IsGridVisible() );
|
|
||||||
VECTOR2I cursorPos = grid.BestSnapAnchor( evt->IsPrime() ? evt->Position()
|
VECTOR2I cursorPos = grid.BestSnapAnchor( evt->IsPrime() ? evt->Position()
|
||||||
: m_controls->GetMousePosition(),
|
: m_controls->GetMousePosition(),
|
||||||
layers );
|
layers );
|
||||||
|
|
|
@ -407,7 +407,6 @@ int EDIT_TOOL::doMoveSelection( TOOL_EVENT aEvent, bool aPickReference )
|
||||||
editFrame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
editFrame->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
||||||
controls->SetGridSnapping( frame()->IsGridVisible() );
|
|
||||||
|
|
||||||
if( evt->IsAction( &PCB_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
|
if( evt->IsAction( &PCB_ACTIONS::move ) || evt->IsMotion() || evt->IsDrag( BUT_LEFT )
|
||||||
|| evt->IsAction( &ACTIONS::refreshPreview )
|
|| evt->IsAction( &ACTIONS::refreshPreview )
|
||||||
|
|
|
@ -318,7 +318,6 @@ VECTOR2I GRID_HELPER::BestSnapAnchor( const VECTOR2I& aOrigin, const LSET& aLaye
|
||||||
|
|
||||||
ANCHOR* nearest = nearestAnchor( aOrigin, SNAPPABLE, aLayers );
|
ANCHOR* nearest = nearestAnchor( aOrigin, SNAPPABLE, aLayers );
|
||||||
VECTOR2I nearestGrid = Align( aOrigin );
|
VECTOR2I nearestGrid = Align( aOrigin );
|
||||||
double gridDist = ( nearestGrid - aOrigin ).EuclideanNorm();
|
|
||||||
|
|
||||||
if( nearest && m_enableSnap )
|
if( nearest && m_enableSnap )
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,9 +31,8 @@
|
||||||
#include <core/optional.h>
|
#include <core/optional.h>
|
||||||
#include <origin_viewitem.h>
|
#include <origin_viewitem.h>
|
||||||
#include <layers_id_colors_and_visibility.h>
|
#include <layers_id_colors_and_visibility.h>
|
||||||
#include <geometry/seg.h>
|
|
||||||
#include <geometry/shape_arc.h>
|
|
||||||
|
|
||||||
|
class TOOL_MANAGER;
|
||||||
|
|
||||||
class GRID_HELPER {
|
class GRID_HELPER {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -798,7 +798,6 @@ int PCB_EDITOR_CONTROL::PlaceModule( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
controls->ShowCursor( true );
|
controls->ShowCursor( true );
|
||||||
controls->SetGridSnapping( m_frame->IsGridVisible() );
|
|
||||||
|
|
||||||
std::string tool = aEvent.GetCommandStr().get();
|
std::string tool = aEvent.GetCommandStr().get();
|
||||||
m_frame->PushTool( tool );
|
m_frame->PushTool( tool );
|
||||||
|
@ -1281,7 +1280,6 @@ int PCB_EDITOR_CONTROL::PlaceTarget( const TOOL_EVENT& aEvent )
|
||||||
view->Add( &preview );
|
view->Add( &preview );
|
||||||
|
|
||||||
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
m_toolMgr->RunAction( PCB_ACTIONS::selectionClear, true );
|
||||||
controls->SetGridSnapping( frame()->IsGridVisible() );
|
|
||||||
|
|
||||||
std::string tool = aEvent.GetCommandStr().get();
|
std::string tool = aEvent.GetCommandStr().get();
|
||||||
m_frame->PushTool( tool );
|
m_frame->PushTool( tool );
|
||||||
|
|
|
@ -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
|
// do not capture or auto-pan until we start placing an item
|
||||||
controls()->ShowCursor( true );
|
controls()->ShowCursor( true );
|
||||||
controls()->SetGridSnapping( frame()->IsGridVisible() );
|
|
||||||
|
|
||||||
// Add a VIEW_GROUP that serves as a preview for the new item
|
// Add a VIEW_GROUP that serves as a preview for the new item
|
||||||
PCBNEW_SELECTION preview;
|
PCBNEW_SELECTION preview;
|
||||||
|
|
|
@ -225,7 +225,6 @@ int PCB_VIEWER_TOOLS::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
frame()->GetCanvas()->SetCurrentCursor( wxCURSOR_ARROW );
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
||||||
controls.SetGridSnapping( frame()->IsGridVisible() );
|
|
||||||
const VECTOR2I cursorPos = grid.BestSnapAnchor( controls.GetMousePosition(), nullptr );
|
const VECTOR2I cursorPos = grid.BestSnapAnchor( controls.GetMousePosition(), nullptr );
|
||||||
controls.ForceCursorPosition(true, cursorPos );
|
controls.ForceCursorPosition(true, cursorPos );
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,6 @@ int PCBNEW_PICKER_TOOL::Main( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
||||||
controls->SetGridSnapping( frame->IsGridVisible() );
|
|
||||||
VECTOR2I cursorPos = grid.BestSnapAnchor( controls->GetMousePosition(), nullptr );
|
VECTOR2I cursorPos = grid.BestSnapAnchor( controls->GetMousePosition(), nullptr );
|
||||||
controls->ForceCursorPosition(true, cursorPos );
|
controls->ForceCursorPosition(true, cursorPos );
|
||||||
|
|
||||||
|
|
|
@ -383,7 +383,6 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
grid.SetUseGrid( editFrame->IsGridVisible() );
|
grid.SetUseGrid( editFrame->IsGridVisible() );
|
||||||
controls->SetGridSnapping( editFrame->IsGridVisible() );
|
|
||||||
|
|
||||||
if( !m_editPoints || evt->IsSelectionEvent() )
|
if( !m_editPoints || evt->IsSelectionEvent() )
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue