Fix off-grid block paste

Center point of a block may not always be located on a grid point,
therefore it needs to be rounded to the grid size to prevent off grid
component placement.
This commit is contained in:
Maciej Suminski 2018-09-22 17:25:37 +02:00 committed by Jeff Young
parent 6e2b7521d0
commit cbf74d6939
1 changed files with 2 additions and 1 deletions

View File

@ -540,7 +540,8 @@ bool SCH_BASE_FRAME::HandleBlockBegin( wxDC* aDC, EDA_KEY aKey, const wxPoint& a
InitBlockPasteInfos();
KIGFX::PREVIEW::SELECTION_AREA* sel = GetCanvas()->GetView()->GetSelectionArea();
VECTOR2I offsetToCenter = ( sel->GetOrigin() - sel->GetEnd() ) / 2;
VECTOR2I offsetToCenter = GetCanvas()->GetGAL()->GetGridPoint(
( sel->GetOrigin() - sel->GetEnd() ) / 2 );
block->SetLastCursorPosition( wxPoint( offsetToCenter.x, offsetToCenter.y ) );
if( block->GetCount() == 0 ) // No data to paste