More Undo/Redo Cleanup.

Don't need the reference point or container action type.  Clearing this
command signatures to prevent future confusion/use
This commit is contained in:
Seth Hillbrand 2021-02-12 11:26:48 -08:00
parent 3c6a6bac57
commit 8c2fe42ef0
14 changed files with 2974 additions and 72 deletions

View File

@ -106,9 +106,6 @@ COMMIT& COMMIT::Stage( const PICKED_ITEMS_LIST& aItems, UNDO_REDO aModFlag )
EDA_ITEM* item = aItems.GetPickedItem( i );
EDA_ITEM* copy = NULL;
if( change_type == UNDO_REDO::UNSPECIFIED )
change_type = aItems.m_Status;
if( change_type == UNDO_REDO::UNSPECIFIED )
change_type = aModFlag;

File diff suppressed because it is too large Load Diff

View File

@ -60,7 +60,6 @@ ITEM_PICKER::ITEM_PICKER( BASE_SCREEN* aScreen, EDA_ITEM* aItem, UNDO_REDO aUndo
PICKED_ITEMS_LIST::PICKED_ITEMS_LIST()
{
m_Status = UNDO_REDO::UNSPECIFIED;
}
PICKED_ITEMS_LIST::~PICKED_ITEMS_LIST()

View File

@ -89,8 +89,7 @@ public:
/**
* Does nothing in CvPcb but defined because it is a pure virtual in #PCB_BASE_FRAME.
*/
void SaveCopyInUndoList( EDA_ITEM* aItemToCopy, UNDO_REDO aTypeCommand = UNDO_REDO::UNSPECIFIED,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) override
void SaveCopyInUndoList( EDA_ITEM* aItemToCopy, UNDO_REDO aTypeCommand = UNDO_REDO::UNSPECIFIED ) override
{
}
@ -102,11 +101,8 @@ public:
*
* @param aItemsList is the list of items modified by the command to undo
* @param aTypeCommand is command type (see enum UNDO_REDO)
* @param aTransformPoint is the reference point of the transformation,
* for commands like move
*/
void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO aTypeCommand,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) override
void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO aTypeCommand ) override
{
// currently: do nothing in CvPcb.
}

View File

@ -763,27 +763,18 @@ public:
* CHANGED
* NEWITEM
* DELETED
* UR_WIRE_IMAGE
*
* If it is a delete command, items are put on list with the .Flags member
* set to DELETED.
*
* @note
* Edit wires and buses is a bit complex.
* When a new wire is added, a lot of modifications are made in the wire list (merging,
* junctions, etc.). We therefore set the aTypeCommand to UR_WIRE_IMAGE and save the whole
* schebang.
*
* @param aItemToCopy = the schematic item modified by the command to undo
* @param aTypeCommand = command type (see enum UNDO_REDO)
* @param aAppend = add the item to the previous undo list
* @param aTransformPoint = the reference point of the transformation for commands like move
*/
void SaveCopyInUndoList( SCH_SCREEN* aScreen,
SCH_ITEM* aItemToCopy,
UNDO_REDO aTypeCommand,
bool aAppend,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) );
bool aAppend );
/**
* Create a new entry in undo list of commands.
@ -791,12 +782,10 @@ public:
* @param aItemsList = the list of items modified by the command to undo
* @param aTypeCommand = command type (see enum UNDO_REDO)
* @param aAppend = add the item to the previous undo list
* @param aTransformPoint = the reference point of the transformation for commands like move
*/
void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO aTypeCommand,
bool aAppend,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) );
bool aAppend );
/**
* Restore an undo or redo command to put data pointed by \a aList in the previous state.

View File

@ -98,8 +98,7 @@
void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_SCREEN* aScreen,
SCH_ITEM* aItem,
UNDO_REDO aCommandType,
bool aAppend,
const wxPoint& aTransformPoint )
bool aAppend )
{
PICKED_ITEMS_LIST* commandToUndo = nullptr;
@ -114,7 +113,6 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_SCREEN* aScreen,
if( !commandToUndo )
{
commandToUndo = new PICKED_ITEMS_LIST();
commandToUndo->m_TransformPoint = aTransformPoint;
}
ITEM_PICKER itemWrapper( aScreen, aItem, aCommandType );
@ -155,24 +153,18 @@ void SCH_EDIT_FRAME::SaveCopyInUndoList( SCH_SCREEN* aScreen,
void SCH_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO aTypeCommand,
bool aAppend,
const wxPoint& aTransformPoint )
bool aAppend )
{
PICKED_ITEMS_LIST* commandToUndo = nullptr;
if( !aItemsList.GetCount() )
return;
// Can't append a WIRE IMAGE, so fail to a new undo point
if( aAppend )
commandToUndo = PopCommandFromUndoList();
if( !commandToUndo )
{
commandToUndo = new PICKED_ITEMS_LIST();
commandToUndo->m_TransformPoint = aTransformPoint;
commandToUndo->m_Status = aTypeCommand;
}
// Copy picker list:
if( !commandToUndo->GetCount() )
@ -258,6 +250,10 @@ void SCH_EDIT_FRAME::PutDataInPreviousState( PICKED_ITEMS_LIST* aList, bool aRed
eda_item->ClearEditFlags();
eda_item->ClearTempFlags();
if( status == UNDO_REDO::NOP )
{
continue;
}
if( status == UNDO_REDO::NEWITEM )
{
// new items are deleted on undo
@ -331,6 +327,10 @@ void SCH_EDIT_FRAME::RollbackSchematicFromUndo()
{
PICKED_ITEMS_LIST* undo = PopCommandFromUndoList();
// Skip empty frames
while( undo && undo->GetCount() == 1 && undo->GetPickedItemStatus( 0 ) == UNDO_REDO::NOP )
undo = PopCommandFromUndoList();
if( undo )
{
PutDataInPreviousState( undo, false );

View File

@ -356,8 +356,7 @@ public:
* Do nothing in GerbView.
*/
void SaveCopyInUndoList( GERBER_DRAW_ITEM* aItemToCopy,
UNDO_REDO aTypeCommand = UNDO_REDO::UNSPECIFIED,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) { }
UNDO_REDO aTypeCommand = UNDO_REDO::UNSPECIFIED ) { }
/**
* Create a new entry in undo list of commands and add a list of pickers to handle a list
@ -369,8 +368,7 @@ public:
* for commands like move
*/
void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO aTypeCommand,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) )
UNDO_REDO aTypeCommand )
{
// currently: do nothing in GerbView.
}

View File

@ -315,22 +315,16 @@ public:
*
* @param aItemToCopy is the board item modified by the command to undo.
* @param aTypeCommand is the command type (see enum #UNDO_REDO).
* @param aTransformPoint is the reference point of the transformation, for
* commands like move
*/
virtual void SaveCopyInUndoList( EDA_ITEM* aItemToCopy, UNDO_REDO aTypeCommand,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) = 0;
virtual void SaveCopyInUndoList( EDA_ITEM* aItemToCopy, UNDO_REDO aTypeCommand ) = 0;
/**
* Creates a new entry in undo list of commands.
*
* @param aItemsList is the list of items modified by the command to undo.
* @param aTypeCommand is the command type (see enum #UNDO_REDO)
* @param aTransformPoint is the reference point of the transformation,
* for commands like move.
*/
virtual void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO aTypeCommand,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) = 0;
virtual void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO aTypeCommand ) = 0;
/**

View File

@ -54,6 +54,7 @@ class BASE_SCREEN;
*/
enum class UNDO_REDO {
UNSPECIFIED = 0, // illegal
NOP, // Undo/redo will ignore this entry. Only forces the start of a new stack
CHANGED, // params of items have a value changed: undo is made by exchange
// values with a copy of these values
NEWITEM, // new item, undo by changing in deleted
@ -132,12 +133,6 @@ private:
*/
class PICKED_ITEMS_LIST
{
public:
UNDO_REDO m_Status; /* info about operation to undo/redo for this item. can be
* UNSPECIFIED */
wxPoint m_TransformPoint; /* used to undo redo command by the same command: usually
* need to know the rotate point or the move vector */
private:
std::vector <ITEM_PICKER> m_ItemsList;

View File

@ -163,8 +163,8 @@ private:
*/
void Update3DView( bool aForceReload, const wxString* aTitle = nullptr ) override;
void SaveCopyInUndoList( EDA_ITEM*, UNDO_REDO, const wxPoint& ) override {}
void SaveCopyInUndoList( const PICKED_ITEMS_LIST&, UNDO_REDO, const wxPoint &) override {}
void SaveCopyInUndoList( EDA_ITEM*, UNDO_REDO ) override {}
void SaveCopyInUndoList( const PICKED_ITEMS_LIST&, UNDO_REDO ) override {}
void updateView();

View File

@ -207,8 +207,8 @@ private:
/*
* Not used here but needed by PCB_BASE_EDIT_FRAME.
*/
void SaveCopyInUndoList( EDA_ITEM*, UNDO_REDO, const wxPoint& ) override {}
void SaveCopyInUndoList( const PICKED_ITEMS_LIST&, UNDO_REDO, const wxPoint& ) override {}
void SaveCopyInUndoList( EDA_ITEM*, UNDO_REDO ) override {}
void SaveCopyInUndoList( const PICKED_ITEMS_LIST&, UNDO_REDO ) override {}
void OnEditItemRequest( BOARD_ITEM* aItem ) override {}
DECLARE_EVENT_TABLE()

View File

@ -86,10 +86,8 @@ public:
*
* @param aItemToCopy the board item modified by the command to undo.
* @param aTypeCommand command type (see enum UNDO_REDO).
* @param aTransformPoint the reference point of the transformation, for commands like move
*/
void SaveCopyInUndoList( EDA_ITEM* aItemToCopy, UNDO_REDO aTypeCommand,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) override;
void SaveCopyInUndoList( EDA_ITEM* aItemToCopy, UNDO_REDO aTypeCommand ) override;
/**
* Create a new entry in undo list of commands.
@ -98,10 +96,8 @@ public:
*
* @param aItemsList the list of items modified by the command to undo.
* @param aTypeCommand command type (see enum UNDO_REDO).
* @param aTransformPoint the reference point of the transformation for commands like move.
*/
void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO aTypeCommand,
const wxPoint& aTransformPoint = wxPoint( 0, 0 ) ) override;
void SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList, UNDO_REDO aTypeCommand ) override;
/**
* Redo the last edit:

View File

@ -207,8 +207,6 @@ void PCB_EDIT_FRAME::RunActionPlugin( ACTION_PLUGIN* aActionPlugin )
BOARD* currentPcb = GetBoard();
bool fromEmpty = false;
itemsList.m_Status = UNDO_REDO::CHANGED;
// Append tracks:
for( TRACK* item : currentPcb->Tracks() )
{
@ -238,7 +236,7 @@ void PCB_EDIT_FRAME::RunActionPlugin( ACTION_PLUGIN* aActionPlugin )
}
if( itemsList.GetCount() > 0 )
SaveCopyInUndoList( itemsList, UNDO_REDO::CHANGED, wxPoint( 0.0, 0.0 ) );
SaveCopyInUndoList( itemsList, UNDO_REDO::CHANGED );
else
fromEmpty = true;
@ -255,7 +253,6 @@ void PCB_EDIT_FRAME::RunActionPlugin( ACTION_PLUGIN* aActionPlugin )
if( fromEmpty )
{
oldBuffer = new PICKED_ITEMS_LIST();
oldBuffer->m_Status = UNDO_REDO::NEWITEM;
}
else
{

View File

@ -176,23 +176,19 @@ static void SwapItemData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
}
void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( EDA_ITEM* aItem, UNDO_REDO aCommandType,
const wxPoint& aTransformPoint )
void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( EDA_ITEM* aItem, UNDO_REDO aCommandType )
{
PICKED_ITEMS_LIST commandToUndo;
commandToUndo.PushItem( ITEM_PICKER( nullptr, aItem, aCommandType ) );
SaveCopyInUndoList( commandToUndo, aCommandType, aTransformPoint );
SaveCopyInUndoList( commandToUndo, aCommandType );
}
void PCB_BASE_EDIT_FRAME::SaveCopyInUndoList( const PICKED_ITEMS_LIST& aItemsList,
UNDO_REDO aTypeCommand,
const wxPoint& aTransformPoint )
UNDO_REDO aTypeCommand )
{
PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
commandToUndo->m_TransformPoint = aTransformPoint;
// First, filter unnecessary stuff from the list (i.e. for multiple pads / labels modified),
// take the first occurence of the footprint (we save copies of footprints when one of its
// subitems is changed).