pcbnew: snap final points to grid

When constraining moves, the cursor snaps to grid but does not
represent the position of the final edited point.  The point is rotated
to the nearest snap angle, while the vector length remains unchanged
resulting in a line longer than intended and off-grid.

This adds a grid-snap after the constraint is applied.

Fixes: lp:1792655
* https://bugs.launchpad.net/kicad/+bug/1792655

( cherry-picked from e7c51a6a6 )
This commit is contained in:
Seth Hillbrand 2018-09-15 07:49:23 -07:00
parent b60c368b3c
commit efdbc91e42
1 changed files with 4 additions and 0 deletions

View File

@ -34,6 +34,7 @@ using namespace std::placeholders;
#include "pcb_actions.h"
#include "selection_tool.h"
#include "point_editor.h"
#include "grid_helper.h"
#include <board_commit.h>
#include <bitmaps.h>
#include <status_popup.h>
@ -302,6 +303,8 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
KIGFX::VIEW_CONTROLS* controls = getViewControls();
KIGFX::VIEW* view = getView();
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
GRID_HELPER grid( editFrame );
auto item = selection.Front();
m_editPoints = EDIT_POINTS_FACTORY::Make( item, getView()->GetGAL() );
@ -358,6 +361,7 @@ int POINT_EDITOR::OnSelectionChange( const TOOL_EVENT& aEvent )
else
m_editedPoint->ApplyConstraint();
m_editedPoint->SetPosition( grid.Align( m_editedPoint->GetPosition() ) );
updateItem();
updatePoints();
}