Eeschema: Add 'append' option to undo
Allows eeschema to add elements to previous undo commits, permitting stacking of changes through multiple calls
This commit is contained in:
parent
a0c922e493
commit
f8e0099ecc
|
@ -127,7 +127,7 @@ void SCH_EDIT_FRAME::HandleBlockPlace( wxDC* DC )
|
||||||
if( m_canvas->IsMouseCaptured() )
|
if( m_canvas->IsMouseCaptured() )
|
||||||
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
m_canvas->CallMouseCapture( DC, wxDefaultPosition, false );
|
||||||
|
|
||||||
SaveCopyInUndoList( block->GetItems(), UR_MOVED, block->GetMoveVector() );
|
SaveCopyInUndoList( block->GetItems(), UR_MOVED, false, block->GetMoveVector() );
|
||||||
MoveItemsInList( block->GetItems(), block->GetMoveVector() );
|
MoveItemsInList( block->GetItems(), block->GetMoveVector() );
|
||||||
block->ClearItemsList();
|
block->ClearItemsList();
|
||||||
break;
|
break;
|
||||||
|
@ -216,7 +216,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
||||||
wxPoint rotationPoint = block->Centre();
|
wxPoint rotationPoint = block->Centre();
|
||||||
rotationPoint = GetNearestGridPosition( rotationPoint );
|
rotationPoint = GetNearestGridPosition( rotationPoint );
|
||||||
SetCrossHairPosition( rotationPoint );
|
SetCrossHairPosition( rotationPoint );
|
||||||
SaveCopyInUndoList( block->GetItems(), UR_ROTATED, rotationPoint );
|
SaveCopyInUndoList( block->GetItems(), UR_ROTATED, false, rotationPoint );
|
||||||
RotateListOfItems( block->GetItems(), rotationPoint );
|
RotateListOfItems( block->GetItems(), rotationPoint );
|
||||||
OnModify();
|
OnModify();
|
||||||
}
|
}
|
||||||
|
@ -330,7 +330,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
||||||
wxPoint mirrorPoint = block->Centre();
|
wxPoint mirrorPoint = block->Centre();
|
||||||
mirrorPoint = GetNearestGridPosition( mirrorPoint );
|
mirrorPoint = GetNearestGridPosition( mirrorPoint );
|
||||||
SetCrossHairPosition( mirrorPoint );
|
SetCrossHairPosition( mirrorPoint );
|
||||||
SaveCopyInUndoList( block->GetItems(), UR_MIRRORED_X, mirrorPoint );
|
SaveCopyInUndoList( block->GetItems(), UR_MIRRORED_X, false, mirrorPoint );
|
||||||
MirrorX( block->GetItems(), mirrorPoint );
|
MirrorX( block->GetItems(), mirrorPoint );
|
||||||
OnModify();
|
OnModify();
|
||||||
}
|
}
|
||||||
|
@ -349,7 +349,7 @@ bool SCH_EDIT_FRAME::HandleBlockEnd( wxDC* aDC )
|
||||||
wxPoint mirrorPoint = block->Centre();
|
wxPoint mirrorPoint = block->Centre();
|
||||||
mirrorPoint = GetNearestGridPosition( mirrorPoint );
|
mirrorPoint = GetNearestGridPosition( mirrorPoint );
|
||||||
SetCrossHairPosition( mirrorPoint );
|
SetCrossHairPosition( mirrorPoint );
|
||||||
SaveCopyInUndoList( block->GetItems(), UR_MIRRORED_Y, mirrorPoint );
|
SaveCopyInUndoList( block->GetItems(), UR_MIRRORED_Y, false, mirrorPoint );
|
||||||
MirrorY( block->GetItems(), mirrorPoint );
|
MirrorY( block->GetItems(), mirrorPoint );
|
||||||
OnModify();
|
OnModify();
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,7 @@ void SCH_EDIT_FRAME::MoveImage( SCH_BITMAP* aImageItem, wxDC* aDC )
|
||||||
void SCH_EDIT_FRAME::RotateImage( SCH_BITMAP* aItem )
|
void SCH_EDIT_FRAME::RotateImage( SCH_BITMAP* aItem )
|
||||||
{
|
{
|
||||||
if( aItem->GetFlags( ) == 0 )
|
if( aItem->GetFlags( ) == 0 )
|
||||||
SaveCopyInUndoList( aItem, UR_ROTATED, aItem->GetPosition() );
|
SaveCopyInUndoList( aItem, UR_ROTATED, false, aItem->GetPosition() );
|
||||||
|
|
||||||
aItem->Rotate( aItem->GetPosition() );
|
aItem->Rotate( aItem->GetPosition() );
|
||||||
OnModify();
|
OnModify();
|
||||||
|
|
|
@ -108,8 +108,11 @@
|
||||||
|
|
||||||
void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
|
void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
|
||||||
UNDO_REDO_T aCommandType,
|
UNDO_REDO_T aCommandType,
|
||||||
|
bool aAppend,
|
||||||
const wxPoint& aTransformPoint )
|
const wxPoint& aTransformPoint )
|
||||||
{
|
{
|
||||||
|
PICKED_ITEMS_LIST* commandToUndo = NULL;
|
||||||
|
|
||||||
/* Does not save a null item or a UR_WIRE_IMAGE command type. UR_WIRE_IMAGE commands
|
/* Does not save a null item or a UR_WIRE_IMAGE command type. UR_WIRE_IMAGE commands
|
||||||
* are handled by the overloaded version of SaveCopyInUndoList that takes a reference
|
* are handled by the overloaded version of SaveCopyInUndoList that takes a reference
|
||||||
* to a PICKED_ITEMS_LIST.
|
* to a PICKED_ITEMS_LIST.
|
||||||
|
@ -117,8 +120,14 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
|
||||||
if( aItem == NULL || aCommandType == UR_WIRE_IMAGE )
|
if( aItem == NULL || aCommandType == UR_WIRE_IMAGE )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
|
if( aAppend )
|
||||||
commandToUndo->m_TransformPoint = aTransformPoint;
|
commandToUndo = GetScreen()->PopCommandFromUndoList();
|
||||||
|
|
||||||
|
if( !commandToUndo )
|
||||||
|
{
|
||||||
|
commandToUndo = new PICKED_ITEMS_LIST();
|
||||||
|
commandToUndo->m_TransformPoint = aTransformPoint;
|
||||||
|
}
|
||||||
|
|
||||||
ITEM_PICKER itemWrapper( aItem, aCommandType );
|
ITEM_PICKER itemWrapper( aItem, aCommandType );
|
||||||
itemWrapper.SetFlags( aItem->GetFlags() );
|
itemWrapper.SetFlags( aItem->GetFlags() );
|
||||||
|
@ -160,15 +169,41 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_ITEM* aItem,
|
||||||
|
|
||||||
void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
|
void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
|
||||||
UNDO_REDO_T aTypeCommand,
|
UNDO_REDO_T aTypeCommand,
|
||||||
|
bool aAppend,
|
||||||
const wxPoint& aTransformPoint )
|
const wxPoint& aTransformPoint )
|
||||||
{
|
{
|
||||||
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
|
PICKED_ITEMS_LIST* commandToUndo = NULL;
|
||||||
|
|
||||||
commandToUndo->m_TransformPoint = aTransformPoint;
|
if( !aItemsList.GetCount() )
|
||||||
commandToUndo->m_Status = aTypeCommand;
|
return;
|
||||||
|
|
||||||
|
// Can't append a WIRE IMAGE, so fail to a new undo point
|
||||||
|
if( aAppend && ( aTypeCommand != UR_WIRE_IMAGE ) )
|
||||||
|
{
|
||||||
|
commandToUndo = GetScreen()->PopCommandFromUndoList();
|
||||||
|
if( commandToUndo && commandToUndo->m_Status == UR_WIRE_IMAGE )
|
||||||
|
{
|
||||||
|
GetScreen()->PushCommandToUndoList( commandToUndo );
|
||||||
|
commandToUndo = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !commandToUndo )
|
||||||
|
{
|
||||||
|
commandToUndo = new PICKED_ITEMS_LIST();
|
||||||
|
commandToUndo->m_TransformPoint = aTransformPoint;
|
||||||
|
commandToUndo->m_Status = aTypeCommand;
|
||||||
|
}
|
||||||
|
|
||||||
// Copy picker list:
|
// Copy picker list:
|
||||||
commandToUndo->CopyList( aItemsList );
|
if( !commandToUndo->GetCount() )
|
||||||
|
commandToUndo->CopyList( aItemsList );
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Unless we are appending, in which case, get the picker items
|
||||||
|
for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
|
||||||
|
commandToUndo->PushItem( aItemsList.GetItemWrapper( ii) );
|
||||||
|
}
|
||||||
|
|
||||||
// Verify list, and creates data if needed
|
// Verify list, and creates data if needed
|
||||||
for( unsigned ii = 0; ii < commandToUndo->GetCount(); ii++ )
|
for( unsigned ii = 0; ii < commandToUndo->GetCount(); ii++ )
|
||||||
|
|
|
@ -1161,11 +1161,13 @@ public:
|
||||||
*
|
*
|
||||||
* @param aItemToCopy = the schematic item modified by the command to undo
|
* @param aItemToCopy = the schematic item modified by the command to undo
|
||||||
* @param aTypeCommand = command type (see enum UNDO_REDO_T)
|
* @param aTypeCommand = command type (see enum UNDO_REDO_T)
|
||||||
|
* @param aAppend = add the item to the previous undo list
|
||||||
* @param aTransformPoint = the reference point of the transformation,
|
* @param aTransformPoint = the reference point of the transformation,
|
||||||
* for commands like move
|
* for commands like move
|
||||||
*/
|
*/
|
||||||
void SaveCopyInUndoList( SCH_ITEM* aItemToCopy,
|
void SaveCopyInUndoList( SCH_ITEM* aItemToCopy,
|
||||||
UNDO_REDO_T aTypeCommand,
|
UNDO_REDO_T aTypeCommand,
|
||||||
|
bool aAppend = false,
|
||||||
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) );
|
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1173,11 +1175,13 @@ public:
|
||||||
*
|
*
|
||||||
* @param aItemsList = the list of items modified by the command to undo
|
* @param aItemsList = the list of items modified by the command to undo
|
||||||
* @param aTypeCommand = command type (see enum UNDO_REDO_T)
|
* @param aTypeCommand = command type (see enum UNDO_REDO_T)
|
||||||
|
* @param aAppend = add the item to the previous undo list
|
||||||
* @param aTransformPoint = the reference point of the transformation,
|
* @param aTransformPoint = the reference point of the transformation,
|
||||||
* for commands like move
|
* for commands like move
|
||||||
*/
|
*/
|
||||||
void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
|
void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
|
||||||
UNDO_REDO_T aTypeCommand,
|
UNDO_REDO_T aTypeCommand,
|
||||||
|
bool aAppend = false,
|
||||||
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) );
|
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue