pcbnew: Move measure tool to common GRID_HELPER
This removes the last of the Magnetize legacy code from GAL, standardizing the key bindings and magnetic effects in the GAL canvas
This commit is contained in:
parent
4c6b84bfdb
commit
ee676b74d5
|
@ -129,8 +129,8 @@ bool FindBestGridPointOnTrack( wxPoint* aNearPos, wxPoint on_grid, const TRACK*
|
||||||
bool Magnetize( PCB_BASE_EDIT_FRAME* frame, int aCurrentTool, wxSize aGridSize,
|
bool Magnetize( PCB_BASE_EDIT_FRAME* frame, int aCurrentTool, wxSize aGridSize,
|
||||||
wxPoint on_grid, wxPoint* curpos )
|
wxPoint on_grid, wxPoint* curpos )
|
||||||
{
|
{
|
||||||
// Note: only used for routing in the Legacy Toolset and for the measurement tool in the
|
// Note: only used for routing in the Legacy Toolset
|
||||||
// Modern Toolset. Can be greatly simplified when the Legacy Toolset is retired.
|
// Can be greatly simplified when the Legacy Toolset is retired.
|
||||||
|
|
||||||
bool doCheckNet = frame->Settings().m_magneticPads != CAPTURE_ALWAYS && frame->Settings().m_legacyDrcOn;
|
bool doCheckNet = frame->Settings().m_magneticPads != CAPTURE_ALWAYS && frame->Settings().m_legacyDrcOn;
|
||||||
bool doCheckLayer = aCurrentTool == ID_TRACK_BUTT;
|
bool doCheckLayer = aCurrentTool == ID_TRACK_BUTT;
|
||||||
|
|
|
@ -72,10 +72,6 @@ using namespace std::placeholders;
|
||||||
#include <board_commit.h>
|
#include <board_commit.h>
|
||||||
|
|
||||||
|
|
||||||
extern bool Magnetize( PCB_BASE_EDIT_FRAME* frame, int aCurrentTool,
|
|
||||||
wxSize aGridSize, wxPoint on_grid, wxPoint* curpos );
|
|
||||||
|
|
||||||
|
|
||||||
// Edit tool actions
|
// Edit tool actions
|
||||||
TOOL_ACTION PCB_ACTIONS::editFootprintInFpEditor( "pcbnew.InteractiveEdit.editFootprintInFpEditor",
|
TOOL_ACTION PCB_ACTIONS::editFootprintInFpEditor( "pcbnew.InteractiveEdit.editFootprintInFpEditor",
|
||||||
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT_MODULE_WITH_MODEDIT ),
|
AS_GLOBAL, TOOL_ACTION::LegacyHotKey( HK_EDIT_MODULE_WITH_MODEDIT ),
|
||||||
|
@ -1201,35 +1197,24 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
|
||||||
frame()->SetToolID( toolID, wxCURSOR_PENCIL, _( "Measure distance" ) );
|
frame()->SetToolID( toolID, wxCURSOR_PENCIL, _( "Measure distance" ) );
|
||||||
|
|
||||||
KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPtMgr;
|
KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPtMgr;
|
||||||
|
|
||||||
KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, frame()->GetUserUnits() );
|
KIGFX::PREVIEW::RULER_ITEM ruler( twoPtMgr, frame()->GetUserUnits() );
|
||||||
|
|
||||||
view.Add( &ruler );
|
view.Add( &ruler );
|
||||||
view.SetVisible( &ruler, false );
|
view.SetVisible( &ruler, false );
|
||||||
|
|
||||||
|
GRID_HELPER grid( frame() );
|
||||||
|
|
||||||
bool originSet = false;
|
bool originSet = false;
|
||||||
|
|
||||||
controls.ShowCursor( true );
|
controls.ShowCursor( true );
|
||||||
controls.SetSnapping( true );
|
controls.SetSnapping( false );
|
||||||
controls.SetAutoPan( false );
|
controls.SetAutoPan( false );
|
||||||
|
|
||||||
while( auto evt = Wait() )
|
while( auto evt = Wait() )
|
||||||
{
|
{
|
||||||
// TODO: magnetic pad & track processing needs to move to VIEW_CONTROLS.
|
grid.SetSnap( !evt->Modifier( MD_SHIFT ) );
|
||||||
wxPoint pos( controls.GetMousePosition().x, controls.GetMousePosition().y );
|
grid.SetUseGrid( !evt->Modifier( MD_ALT ) );
|
||||||
frame()->SetMousePosition( pos );
|
const VECTOR2I cursorPos = grid.BestSnapAnchor( controls.GetCursorPosition(), nullptr );
|
||||||
|
|
||||||
wxRealPoint gridSize = frame()->GetScreen()->GetGridSize();
|
|
||||||
wxSize igridsize;
|
|
||||||
igridsize.x = KiROUND( gridSize.x );
|
|
||||||
igridsize.y = KiROUND( gridSize.y );
|
|
||||||
|
|
||||||
if( Magnetize( frame(), toolID, igridsize, pos, &pos ) )
|
|
||||||
controls.ForceCursorPosition( true, pos );
|
|
||||||
else
|
|
||||||
controls.ForceCursorPosition( false );
|
|
||||||
|
|
||||||
const VECTOR2I cursorPos = controls.GetCursorPosition();
|
|
||||||
|
|
||||||
if( evt->IsCancel() || TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
if( evt->IsCancel() || TOOL_EVT_UTILS::IsCancelInteractive( *evt ) || evt->IsActivate() )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue