Fixed selected items drift on rotation/flip

This commit is contained in:
Maciej Suminski 2017-04-20 16:38:19 +02:00
parent 0e14cdf6da
commit 217593f6bc
1 changed files with 10 additions and 5 deletions

View File

@ -496,16 +496,18 @@ int EDIT_TOOL::Rotate( const TOOL_EVENT& aEvent )
if( m_selectionTool->CheckLock() == SELECTION_LOCKED )
return 0;
// Shall the selection be cleared at the end?
wxPoint rotatePoint = getModificationPoint( selection );
wxPoint modPoint = getModificationPoint( selection );
const int rotateAngle = TOOL_EVT_UTILS::GetEventRotationAngle( *editFrame, aEvent );
for( auto item : selection )
{
m_commit->Modify( item );
static_cast<BOARD_ITEM*>( item )->Rotate( rotatePoint, rotateAngle );
static_cast<BOARD_ITEM*>( item )->Rotate( modPoint, rotateAngle );
}
// Update the dragging point offset
m_offset = static_cast<BOARD_ITEM*>( selection.Front() )->GetPosition() - modPoint;
if( !m_dragging )
m_commit->Push( _( "Rotate" ) );
@ -634,14 +636,17 @@ int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent )
if( selection.Empty() )
return 0;
wxPoint flipPoint = getModificationPoint( selection );
wxPoint modPoint = getModificationPoint( selection );
for( auto item : selection )
{
m_commit->Modify( item );
static_cast<BOARD_ITEM*>( item )->Flip( flipPoint );
static_cast<BOARD_ITEM*>( item )->Flip( modPoint );
}
// Update the dragging point offset
m_offset = static_cast<BOARD_ITEM*>( selection.Front() )->GetPosition() - modPoint;
if( !m_dragging )
m_commit->Push( _( "Flip" ) );