29using namespace std::placeholders;
102 int preExisting = commandToUndo->
GetCount();
104 for(
unsigned ii = 0; ii < aItemsList.
GetCount(); ii++ )
107 for(
unsigned ii = preExisting; ii < commandToUndo->
GetCount(); ii++ )
112 if( command == UNDO_REDO::UNSPECIFIED )
114 command = aCommandType;
122 case UNDO_REDO::CHANGED:
123 case UNDO_REDO::DRILLORIGIN:
124 case UNDO_REDO::GRIDORIGIN:
134 brdclone->SetParentGroup(
nullptr );
141 case UNDO_REDO::NEWITEM:
142 case UNDO_REDO::DELETED:
143 case UNDO_REDO::PAGESETTINGS:
144 case UNDO_REDO::REGROUP:
145 case UNDO_REDO::UNGROUP:
149 wxFAIL_MSG( wxString::Format( wxT(
"Unrecognized undo command: %X" ), command ) );
166 delete commandToUndo;
268 bool not_found =
false;
269 bool reBuild_ratsnest =
false;
270 bool deep_reBuild_ratsnest =
false;
271 bool solder_mask_dirty =
false;
284 for(
int ii = aList->
GetCount() - 1; ii >= 0 ; ii-- )
297 if( status != UNDO_REDO::DELETED
298 && status != UNDO_REDO::UNGROUP
299 && status != UNDO_REDO::REGROUP
300 && status != UNDO_REDO::DRILLORIGIN
301 && status != UNDO_REDO::GRIDORIGIN
302 && status != UNDO_REDO::PAGESETTINGS )
307 wxASSERT_MSG(
false, wxT(
"Item in the undo buffer does not exist" ) );
321 switch( eda_item->
Type() )
324 deep_reBuild_ratsnest =
true;
332 reBuild_ratsnest =
true;
336 reBuild_ratsnest =
true;
337 deep_reBuild_ratsnest =
true;
344 switch( eda_item->
Type() )
347 solder_mask_dirty =
true;
351 solder_mask_dirty =
true;
360 LSET layers =
static_cast<BOARD_ITEM*
>( eda_item )->GetLayerSet();
363 solder_mask_dirty =
true;
374 case UNDO_REDO::CHANGED:
381 view->Remove( item );
382 connectivity->Remove( item );
395 view->Hide( item,
false );
396 connectivity->Add( item );
401 case UNDO_REDO::NEWITEM:
406 view->Remove( eda_item );
410 case UNDO_REDO::DELETED:
415 view->Add( eda_item );
422 case UNDO_REDO::REGROUP:
426 boardItem->SetParentGroup(
nullptr );
430 case UNDO_REDO::UNGROUP:
436 addedGroup->
AddItem( boardItem );
441 case UNDO_REDO::DRILLORIGIN:
442 case UNDO_REDO::GRIDORIGIN:
458 case UNDO_REDO::PAGESETTINGS:
469 wxFAIL_MSG( wxString::Format( wxT(
"PutDataInPreviousState() error (unknown code %X)" ),
476 wxMessageBox(
_(
"Incomplete undo/redo operation: some items not found" ) );
480 if( reBuild_ratsnest || deep_reBuild_ratsnest )
483 if( solder_mask_dirty )
496 if( aItemCount == 0 )
505 for(
unsigned ii = 0; ii < icnt; ii++ )
524 boardItem->SetParentGroup(
nullptr );
static void DoSetDrillOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, EDA_ITEM *aItem, const VECTOR2D &aPoint)
virtual void Remove(BOARD_ITEM *aItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL)=0
Removes an item from the container.
virtual void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false)=0
Adds an item to the container.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
void SetParentGroup(PCB_GROUP *aGroup)
void SwapItemData(BOARD_ITEM *aImage)
Swap data between aItem and aImage.
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
void OnItemChanged(BOARD_ITEM *aItem)
Notify the board and its listeners that an item on the board has been modified in some way.
void IncrementTimeStamp()
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
static DELETED_BOARD_ITEM * GetInstance()
void Restore(EDA_DRAW_FRAME *aFrame, KIGFX::VIEW *aView=nullptr)
virtual void PushCommandToUndoList(PICKED_ITEMS_LIST *aItem)
Add a command to undo in the undo list.
virtual int GetRedoCommandCount() const
UNDO_REDO_CONTAINER m_undoList
UNDO_REDO_LIST
Specifies whether we are interacting with the undo or redo stacks.
virtual PICKED_ITEMS_LIST * PopCommandFromRedoList()
Return the last command to undo and remove it from list, nothing is deleted.
UNDO_REDO_CONTAINER m_redoList
virtual PICKED_ITEMS_LIST * PopCommandFromUndoList()
Return the last command to undo and remove it from list, nothing is deleted.
virtual int GetUndoCommandCount() const
virtual void PushCommandToRedoList(PICKED_ITEMS_LIST *aItem)
Add a command to redo in the redo list.
bool IsType(FRAME_T aType) const
virtual void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
A base class for most all the KiCad significant classes used in schematics and boards.
virtual VECTOR2I GetPosition() const
KICAD_T Type() const
Returns the type of object.
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
static const TOOL_EVENT UndoRedoPreEvent
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
static const TOOL_EVENT UndoRedoPostEvent
LSET is a set of PCB_LAYER_IDs.
void ClearUndoORRedoList(UNDO_REDO_LIST whichList, int aItemCount=-1) override
Free the undo or redo list from List element.
void RestoreCopyFromUndoList(wxCommandEvent &aEvent)
Undo the last edit:
void saveCopyInUndoList(PICKED_ITEMS_LIST *commandToUndo, const PICKED_ITEMS_LIST &aItemsList, UNDO_REDO aCommandType)
void AppendCopyToUndoList(const PICKED_ITEMS_LIST &aItemsList, UNDO_REDO aCommandType) override
As SaveCopyInUndoList, but appends the changes to the last undo item on the stack.
void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand) override
Create a new entry in undo list of commands.
void ClearListAndDeleteItems(PICKED_ITEMS_LIST *aList)
void RollbackFromUndo()
Perform an undo of the last edit without logging a corresponding redo.
bool UndoRedoBlocked() const
Check if the undo and redo operations are currently blocked.
void PutDataInPreviousState(PICKED_ITEMS_LIST *aList)
Used in undo or redo command.
void RestoreCopyFromRedoList(wxCommandEvent &aEvent)
Redo the last edit:
EDA_ITEM * GetItem(const KIID &aId) const override
Fetch an item by KIID.
void OnModify() override
Must be called after a change in order to set the "modify" flag and update other data structures and ...
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
void Compile_Ratsnest(bool aDisplayStatus)
Create the entire board ratsnest.
static void DoSetGridOrigin(KIGFX::VIEW *aView, PCB_BASE_FRAME *aFrame, EDA_ITEM *originViewItem, const VECTOR2D &aPoint)
virtual KIGFX::PCB_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
A set of BOARD_ITEMs (i.e., without duplicates).
virtual bool AddItem(BOARD_ITEM *aItem)
Add item to group.
A holder to handle information on schematic or board items.
bool SetPickedItemStatus(UNDO_REDO aStatus, unsigned aIdx)
Set the type of undo/redo operation for a given picked item.
void PushItem(const ITEM_PICKER &aItem)
Push aItem to the top of the list.
void SetDescription(const wxString &aDescription)
UNDO_REDO GetPickedItemStatus(unsigned int aIdx) const
ITEM_PICKER GetItemWrapper(unsigned int aIdx) const
EDA_ITEM * GetPickedItemLink(unsigned int aIdx) const
wxString GetDescription() const
bool RemovePicker(unsigned aIdx)
Remove one entry (one picker) from the list of picked items.
unsigned GetCount() const
void ReversePickersListOrder()
Reverse the order of pickers stored in this list.
bool SetPickedItemLink(EDA_ITEM *aLink, unsigned aIdx)
Set the link associated to a given picked item.
void ClearListAndDeleteItems(std::function< void(EDA_ITEM *)> aItemDeleter)
Delete the list of pickers AND the data pointed by #m_PickedItem or #m_PickedItemLink according to th...
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
A holder to handle a list of undo (or redo) commands.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
This file contains miscellaneous commonly used macros and functions.
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Class to handle a set of BOARD_ITEMs.
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_PAD_T
class PAD, a pad in a footprint
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
@ PCB_NETINFO_T
class NETINFO_ITEM, a description of a net
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...