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 <mohan.umesh@gmail.com> 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.
This commit is contained in:
Wayne Stambaugh 2014-03-07 17:34:54 -05:00
parent 04f8d12ae5
commit c89d52ee1a
1 changed files with 14 additions and 6 deletions

View File

@ -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 );