From 5ff3bbb96e5b5a18c375735b80006a59ac3f7ed0 Mon Sep 17 00:00:00 2001 From: Chris Pavlina Date: Wed, 30 Mar 2016 14:19:32 -0400 Subject: [PATCH] eeschema: move part by a point on the grid (lp:1563587) --- eeschema/schedit.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/eeschema/schedit.cpp b/eeschema/schedit.cpp index 7457fdfc3f..9dd7031685 100644 --- a/eeschema/schedit.cpp +++ b/eeschema/schedit.cpp @@ -796,7 +796,15 @@ void SCH_EDIT_FRAME::PrepareMoveItem( SCH_ITEM* aItem, wxDC* aDC ) aItem->SetStoredPos( wxPoint( 0,0 ) ); } else - aItem->SetStoredPos( GetCrossHairPosition() - aItem->GetPosition() ); + { + // Round the point under the cursor to a multiple of the grid + wxPoint cursorpos = GetCrossHairPosition() - aItem->GetPosition(); + wxPoint gridsize = GetScreen()->GetGridSize(); + cursorpos.x = ( cursorpos.x / gridsize.x ) * gridsize.x; + cursorpos.y = ( cursorpos.y / gridsize.y ) * gridsize.y; + + aItem->SetStoredPos( cursorpos ); + } OnModify();