From 2ebd47c331129a7fafcb654957134a145f392d69 Mon Sep 17 00:00:00 2001 From: Wayne Stambaugh Date: Fri, 7 Mar 2014 17:34:54 -0500 Subject: [PATCH] Pcbnew: make block rotate honor the rotation angle setting. (fixes lp:1281605) * Make block rotate command honor the rotation angle setting. Thank you Umesh Mohan for the patch. * Change block rotate undo command from UR_ROTATE to UR_CHANGED so consecutive rotations do not lead to round errors and for proper undo in case the user changes the rotation angle setting between block rotations. --- pcbnew/block.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/pcbnew/block.cpp b/pcbnew/block.cpp index bb86e61cfa..d9286c05dc 100644 --- a/pcbnew/block.cpp +++ b/pcbnew/block.cpp @@ -656,8 +656,8 @@ void PCB_EDIT_FRAME::Block_Delete() void PCB_EDIT_FRAME::Block_Rotate() { wxPoint oldpos; - wxPoint centre; // rotation cent-re for the rotation transform - int rotAngle = 900; // rotation angle in 0.1 deg. + wxPoint centre; // rotation cent-re for the rotation transform + int rotAngle = m_rotationAngle; // rotation angle in 0.1 deg. oldpos = GetCrossHairPosition(); centre = GetScreen()->m_BlockLocate.Centre(); @@ -665,14 +665,13 @@ void PCB_EDIT_FRAME::Block_Rotate() OnModify(); PICKED_ITEMS_LIST* itemsList = &GetScreen()->m_BlockLocate.GetItems(); - itemsList->m_Status = UR_ROTATED; + itemsList->m_Status = UR_CHANGED; for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ ) { BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii ); wxASSERT( item ); - itemsList->SetPickedItemStatus( UR_ROTATED, ii ); - item->Rotate( centre, rotAngle ); + itemsList->SetPickedItemStatus( UR_CHANGED, ii ); switch( item->Type() ) { @@ -706,7 +705,16 @@ void PCB_EDIT_FRAME::Block_Rotate() } } - SaveCopyInUndoList( *itemsList, UR_ROTATED, centre ); + // Save all the block items in there current state before applying the rotation. + SaveCopyInUndoList( *itemsList, UR_CHANGED, centre ); + + // Now perform the rotation. + for( unsigned ii = 0; ii < itemsList->GetCount(); ii++ ) + { + BOARD_ITEM* item = (BOARD_ITEM*) itemsList->GetPickedItem( ii ); + wxASSERT( item ); + item->Rotate( centre, rotAngle ); + } Compile_Ratsnest( NULL, true ); m_canvas->Refresh( true );