Implement magnetic pads & tracks for measurement tool.

This really needs to get put into the VIEW_CONTROLS for all the
tools, but that's probably a bit too risky for 5.0 at this
point.

Fixes: lp:1766547
* https://bugs.launchpad.net/kicad/+bug/1766547
This commit is contained in:
Jeff Young 2018-04-25 23:32:05 +01:00
parent ac778bc5b4
commit 5342aacf97
1 changed files with 21 additions and 3 deletions

View File

@ -71,6 +71,11 @@ using namespace std::placeholders;
#include <board_commit.h> #include <board_commit.h>
extern bool Magnetize( PCB_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 ),
@ -1142,11 +1147,10 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
{ {
auto& view = *getView(); auto& view = *getView();
auto& controls = *getViewControls(); auto& controls = *getViewControls();
int toolID = EditingModules() ? ID_MODEDIT_MEASUREMENT_TOOL : ID_PCB_MEASUREMENT_TOOL;
Activate(); Activate();
frame()->SetToolID( EditingModules() ? ID_MODEDIT_MEASUREMENT_TOOL frame()->SetToolID( toolID, wxCURSOR_PENCIL, _( "Measure distance" ) );
: ID_PCB_MEASUREMENT_TOOL,
wxCURSOR_PENCIL, _( "Measure distance" ) );
KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPtMgr; KIGFX::PREVIEW::TWO_POINT_GEOMETRY_MANAGER twoPtMgr;
@ -1163,6 +1167,20 @@ int EDIT_TOOL::MeasureTool( const TOOL_EVENT& aEvent )
while( auto evt = Wait() ) while( auto evt = Wait() )
{ {
// TODO: magnetic pad & track processing needs to move to VIEW_CONTROLS.
wxPoint pos( controls.GetMousePosition().x, controls.GetMousePosition().y );
frame()->SetMousePosition( pos );
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(); const VECTOR2I cursorPos = controls.GetCursorPosition();
if( evt->IsCancel() || evt->IsActivate() ) if( evt->IsCancel() || evt->IsActivate() )