More changes to clean up redraw after an undo.
Fixes: lp:1803038 * https://bugs.launchpad.net/kicad/+bug/1803038
This commit is contained in:
parent
dde933ba08
commit
10887868dc
|
@ -306,78 +306,79 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
|
|||
}
|
||||
|
||||
// Undo in the reverse order of list creation: (this can allow stacked changes like the
|
||||
// same item can be changes and deleted in the same complex command.
|
||||
// same item can be changed and deleted in the same complex command).
|
||||
for( int ii = aList->GetCount() - 1; ii >= 0; ii-- )
|
||||
{
|
||||
UNDO_REDO_T status = aList->GetPickedItemStatus((unsigned) ii );
|
||||
item = (SCH_ITEM*) aList->GetPickedItem( (unsigned) ii );
|
||||
wxASSERT( item );
|
||||
alt_item = (SCH_ITEM*) aList->GetPickedItemLink( (unsigned) ii );
|
||||
|
||||
item->ClearFlags();
|
||||
|
||||
SCH_ITEM* image = (SCH_ITEM*) aList->GetPickedItemLink( (unsigned) ii );
|
||||
|
||||
switch( aList->GetPickedItemStatus( (unsigned) ii ) )
|
||||
if( status == UR_NEW )
|
||||
{
|
||||
case UR_CHANGED: /* Exchange old and new data for each item */
|
||||
item->SwapData( image );
|
||||
break;
|
||||
|
||||
case UR_NEW: /* new items are deleted */
|
||||
// new items are deleted on undo
|
||||
RemoveFromScreen( item );
|
||||
aList->SetPickedItemStatus( UR_DELETED, (unsigned) ii );
|
||||
RemoveFromScreen( item );
|
||||
|
||||
//schprintf("UndoRemFroMscreen %p %s\n", item, (const char *)item->GetClass().c_str() );
|
||||
break;
|
||||
|
||||
case UR_DELETED: /* deleted items are put in the draw item list, as new items */
|
||||
aList->SetPickedItemStatus( UR_NEW, (unsigned) ii );
|
||||
}
|
||||
else if (status == UR_DELETED )
|
||||
{
|
||||
// deleted items are re-inserted on undo
|
||||
AddToScreen( item );
|
||||
break;
|
||||
|
||||
case UR_MOVED:
|
||||
item->ClearFlags();
|
||||
item->SetFlags( aList->GetPickerFlags( (unsigned) ii ) );
|
||||
item->Move( aRedoCommand ? aList->m_TransformPoint : -aList->m_TransformPoint );
|
||||
item->ClearFlags();
|
||||
break;
|
||||
|
||||
case UR_MIRRORED_Y:
|
||||
item->MirrorY( aList->m_TransformPoint.x );
|
||||
break;
|
||||
|
||||
case UR_MIRRORED_X:
|
||||
item->MirrorX( aList->m_TransformPoint.y );
|
||||
break;
|
||||
|
||||
case UR_ROTATED:
|
||||
// To undo a rotate 90 deg transform we must rotate 270 deg to undo
|
||||
// and 90 deg to redo:
|
||||
item->Rotate( aList->m_TransformPoint );
|
||||
|
||||
if( aRedoCommand )
|
||||
break; // A only one rotate transform is OK
|
||||
|
||||
// Make 3 rotate 90 deg transforms is this is actually an undo command
|
||||
item->Rotate( aList->m_TransformPoint );
|
||||
item->Rotate( aList->m_TransformPoint );
|
||||
break;
|
||||
|
||||
case UR_EXCHANGE_T:
|
||||
alt_item = (SCH_ITEM*) aList->GetPickedItemLink( (unsigned) ii );
|
||||
alt_item->SetNext( NULL );
|
||||
alt_item->SetBack( NULL );
|
||||
|
||||
aList->SetPickedItemStatus( UR_NEW, (unsigned) ii );
|
||||
}
|
||||
else
|
||||
{
|
||||
// everthing else is modified in place
|
||||
RemoveFromScreen( item );
|
||||
AddToScreen( alt_item );
|
||||
|
||||
aList->SetPickedItem( alt_item, (unsigned) ii );
|
||||
aList->SetPickedItemLink( item, (unsigned) ii );
|
||||
break;
|
||||
switch( status )
|
||||
{
|
||||
case UR_CHANGED:
|
||||
item->SwapData( alt_item );
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( wxString::Format( wxT( "Unknown undo/redo command %d" ),
|
||||
aList->GetPickedItemStatus( (unsigned) ii ) ) );
|
||||
break;
|
||||
case UR_MOVED:
|
||||
item->SetFlags( aList->GetPickerFlags( (unsigned) ii ) );
|
||||
item->Move( aRedoCommand ? aList->m_TransformPoint : -aList->m_TransformPoint );
|
||||
item->ClearFlags();
|
||||
break;
|
||||
|
||||
case UR_MIRRORED_Y:
|
||||
item->MirrorY( aList->m_TransformPoint.x );
|
||||
break;
|
||||
|
||||
case UR_MIRRORED_X:
|
||||
item->MirrorX( aList->m_TransformPoint.y );
|
||||
break;
|
||||
|
||||
case UR_ROTATED:
|
||||
if( aRedoCommand )
|
||||
item->Rotate( aList->m_TransformPoint );
|
||||
else
|
||||
{
|
||||
// Rotate 270 deg to undo 90-deg rotate
|
||||
item->Rotate( aList->m_TransformPoint );
|
||||
item->Rotate( aList->m_TransformPoint );
|
||||
item->Rotate( aList->m_TransformPoint );
|
||||
}
|
||||
break;
|
||||
|
||||
case UR_EXCHANGE_T:
|
||||
alt_item->SetNext( NULL );
|
||||
alt_item->SetBack( NULL );
|
||||
aList->SetPickedItem( alt_item, (unsigned) ii );
|
||||
aList->SetPickedItemLink( item, (unsigned) ii );
|
||||
item = alt_item;
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( wxString::Format( wxT( "Unknown undo/redo command %d" ),
|
||||
aList->GetPickedItemStatus( (unsigned) ii ) ) );
|
||||
break;
|
||||
}
|
||||
|
||||
AddToScreen( item );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -386,7 +387,6 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
|
|||
GetCanvas()->GetGAL()->ClearCache();
|
||||
|
||||
GetCanvas()->GetView()->ClearHiddenFlags();
|
||||
GetCanvas()->GetView()->UpdateAllItems( KIGFX::ALL );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue