KiCad PCB EDA Suite
undo_redo.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2012 Jean-Pierre Charras, [email protected]
5 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
6 * Copyright (C) 2016 CERN
7 * Copyright (C) 2012-2021 KiCad Developers, see AUTHORS.txt for contributors.
8 * @author Maciej Suminski <[email protected]>
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, you may find one here:
22 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
23 * or you may search the http://www.gnu.org website for the version 2 license,
24 * or you may write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
26 */
27
28#include <functional>
29using namespace std::placeholders;
30#include <macros.h>
31#include <pcb_edit_frame.h>
32#include <board.h>
33#include <pcb_track.h>
34#include <pcb_group.h>
35#include <pcb_target.h>
36#include <footprint.h>
37#include <pad.h>
38#include <pcb_dimension.h>
39#include <origin_viewitem.h>
41#include <pcbnew_settings.h>
42#include <tool/tool_manager.h>
43#include <tool/actions.h>
45#include <tools/pcb_control.h>
48#include <wx/msgdlg.h>
49
50/* Functions to undo and redo edit commands.
51 * commands to undo are stored in CurrentScreen->m_UndoList
52 * commands to redo are stored in CurrentScreen->m_RedoList
53 *
54 * m_UndoList and m_RedoList handle a std::vector of PICKED_ITEMS_LIST
55 * Each PICKED_ITEMS_LIST handle a std::vector of pickers (class ITEM_PICKER),
56 * that store the list of schematic items that are concerned by the command to undo or redo
57 * and is created for each command to undo (handle also a command to redo).
58 * each picker has a pointer pointing to an item to undo or redo (in fact: deleted, added or
59 * modified),
60 * and has a pointer to a copy of this item, when this item has been modified
61 * (the old values of parameters are therefore saved)
62 *
63 * there are 3 cases:
64 * - delete item(s) command
65 * - change item(s) command
66 * - add item(s) command
67 *
68 * Undo command
69 * - delete item(s) command:
70 * => deleted items are moved in undo list
71 *
72 * - change item(s) command
73 * => A copy of item(s) is made (a DrawPickedStruct list of wrappers)
74 * the .m_Link member of each wrapper points the modified item.
75 * the .m_Item member of each wrapper points the old copy of this item.
76 *
77 * - add item(s) command
78 * =>A list of item(s) is made. The .m_Item member of each wrapper points the new item.
79 *
80 * Redo command
81 * - delete item(s) old command:
82 * => deleted items are moved in EEDrawList list, and in
83 *
84 * - change item(s) command
85 * => the copy of item(s) is moved in Undo list
86 *
87 * - add item(s) command
88 * => The list of item(s) is used to create a deleted list in undo list(same as a delete
89 * command)
90 *
91 * Some block operations that change items can be undone without memorize items, just the
92 * coordinates of the transform:
93 * move list of items (undo/redo is made by moving with the opposite move vector)
94 * mirror (Y) and flip list of items (undo/redo is made by mirror or flip items)
95 * so they are handled specifically.
96 *
97 */
98
99
113static bool TestForExistingItem( BOARD* aPcb, BOARD_ITEM* aItem )
114{
115 for( PCB_TRACK* item : aPcb->Tracks() )
116 {
117 if( aItem == static_cast<BOARD_ITEM*>( item ) )
118 return true;
119 }
120
121 for( FOOTPRINT* item : aPcb->Footprints() )
122 {
123 if( aItem == static_cast<BOARD_ITEM*>( item ) )
124 return true;
125 }
126
127 for( BOARD_ITEM* item : aPcb->Drawings() )
128 {
129 if( aItem == static_cast<BOARD_ITEM*>( item ) )
130 return true;
131 }
132
133 for( ZONE* item : aPcb->Zones() )
134 {
135 if( aItem == static_cast<BOARD_ITEM*>( item ) )
136 return true;
137 }
138
139 NETINFO_LIST& netInfo = aPcb->GetNetInfo();
140
141 for( NETINFO_LIST::iterator i = netInfo.begin(); i != netInfo.end(); ++i )
142 {
143 if( aItem == static_cast<BOARD_ITEM*>( *i ) )
144 return true;
145 }
146
147 for( PCB_GROUP* item : aPcb->Groups() )
148 {
149 if( aItem == static_cast<BOARD_ITEM*>( item ) )
150 return true;
151 }
152
153 return false;
154}
155
156
157static void SwapItemData( BOARD_ITEM* aItem, BOARD_ITEM* aImage )
158{
159 if( aImage == nullptr )
160 return;
161
162 wxASSERT( aItem->Type() == aImage->Type() );
163
164 // Remark: to create images of edited items to undo, we are using Clone method
165 // which does not do a deep copy.
166 // So we have to use the current values of these parameters.
167
168 wxASSERT( aItem->m_Uuid == aImage->m_Uuid );
169
170 EDA_ITEM* parent = aItem->GetParent();
171
172 aItem->SwapData( aImage );
173
174 // Restore pointers to be sure they are not broken
175 aItem->SetParent( parent );
176}
177
178
180 const PICKED_ITEMS_LIST& aItemsList,
181 UNDO_REDO aCommandType )
182{
183 int preExisting = commandToUndo->GetCount();
184
185 // First, filter unnecessary stuff from the list (i.e. for multiple pads / labels modified),
186 // take the first occurrence of the footprint (we save copies of footprints when one of its
187 // subitems is changed).
188 for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
189 {
190 ITEM_PICKER curr_picker = aItemsList.GetItemWrapper(ii);
191 BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( aItemsList.GetPickedItem( ii ) );
192
193 // For items belonging to footprints, we need to save state of the parent footprint
194 if( item && item->GetParent() && item->GetParent()->Type() == PCB_FOOTPRINT_T )
195 {
196 item = item->GetParent();
197
198 // Check if the parent footprint has already been saved in another entry
199 bool found = false;
200
201 for( unsigned j = 0; j < commandToUndo->GetCount(); j++ )
202 {
203 if( commandToUndo->GetPickedItem( j ) == item
204 && commandToUndo->GetPickedItemStatus( j ) == UNDO_REDO::CHANGED )
205 {
206 found = true;
207 break;
208 }
209 }
210
211 if( !found )
212 {
213 // Create a clean copy of the parent footprint
214 FOOTPRINT* orig = static_cast<FOOTPRINT*>( item );
215 FOOTPRINT* clone = new FOOTPRINT( *orig );
216 clone->SetParent( GetBoard() );
217
218 // Clear current flags (which can be temporary set by a current edit command)
219 for( BOARD_ITEM* child : clone->GraphicalItems() )
220 child->ClearEditFlags();
221
222 for( PAD* pad : clone->Pads() )
223 pad->ClearEditFlags();
224
225 clone->Reference().ClearEditFlags();
226 clone->Value().ClearEditFlags();
227
228 ITEM_PICKER picker( nullptr, item, UNDO_REDO::CHANGED );
229 picker.SetLink( clone );
230 commandToUndo->PushItem( picker );
231 }
232 else
233 {
234 continue;
235 }
236 }
237 else
238 {
239 // Normal case: all other BOARD_ITEMs, are simply copied to the new list
240 commandToUndo->PushItem( curr_picker );
241 }
242 }
243
244 for( unsigned ii = preExisting; ii < commandToUndo->GetCount(); ii++ )
245 {
246 EDA_ITEM* item = commandToUndo->GetPickedItem( ii );
247 UNDO_REDO command = commandToUndo->GetPickedItemStatus( ii );
248
249 if( command == UNDO_REDO::UNSPECIFIED )
250 {
251 command = aCommandType;
252 commandToUndo->SetPickedItemStatus( command, ii );
253 }
254
255 wxASSERT( item );
256
257 switch( command )
258 {
262
263 // If we don't yet have a copy in the link, set one up
264 if( !commandToUndo->GetPickedItemLink( ii ) )
265 commandToUndo->SetPickedItemLink( item->Clone(), ii );
266
267 break;
268
274 break;
275
276 default:
277 wxFAIL_MSG( wxString::Format( wxT( "SaveCopyInUndoList() error (unknown code %X)" ),
278 command ) );
279 break;
280 }
281 }
282
283 if( commandToUndo->GetCount() )
284 {
285 /* Save the copy in undo list */
286 PushCommandToUndoList( commandToUndo );
287
288 /* Clear redo list, because after a new command one cannot redo a command */
290 }
291 else
292 {
293 // Should not occur
294 wxASSERT( false );
295 delete commandToUndo;
296 }
297}
298
299
301{
302 PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
303 PICKED_ITEMS_LIST itemsList;
304
305 itemsList.PushItem( ITEM_PICKER( nullptr, aItem, aCommandType ) );
306 saveCopyInUndoList( commandToUndo, itemsList, aCommandType );
307}
308
309
311 UNDO_REDO aCommandType )
312{
313 PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
314
315 saveCopyInUndoList( commandToUndo, aItemsList, aCommandType );
316}
317
318
320 UNDO_REDO aCommandType )
321{
322 PICKED_ITEMS_LIST* commandToUndo = PopCommandFromUndoList();
323
324 if( !commandToUndo )
325 commandToUndo = new PICKED_ITEMS_LIST();
326
327 saveCopyInUndoList( commandToUndo, aItemsList, aCommandType );
328}
329
330
332{
333 if( UndoRedoBlocked() )
334 return;
335
336 if( GetUndoCommandCount() <= 0 )
337 return;
338
339 // Inform tools that undo command was issued
341
342 // Get the old list
344
345 // Undo the command
347
348 // Put the old list in RedoList
350 PushCommandToRedoList( list );
351
352 OnModify();
353
356
357 GetCanvas()->Refresh();
358}
359
360
362{
363 if( UndoRedoBlocked() )
364 return;
365
366 if( GetRedoCommandCount() == 0 )
367 return;
368
369 // Inform tools that redo command was issued
371
372 // Get the old list
374
375 // Redo the command
377
378 // Put the old list in UndoList
380 PushCommandToUndoList( list );
381
382 OnModify();
383
386
387 GetCanvas()->Refresh();
388}
389
390
392{
393 bool not_found = false;
394 bool reBuild_ratsnest = false;
395 bool deep_reBuild_ratsnest = false; // true later if pointers must be rebuilt
396
397 auto view = GetCanvas()->GetView();
398 auto connectivity = GetBoard()->GetConnectivity();
399
400 PCB_GROUP* group = nullptr;
401
402 // Undo in the reverse order of list creation: (this can allow stacked changes
403 // like the same item can be changes and deleted in the same complex command
404
405 // Restore changes in reverse order
406 for( int ii = aList->GetCount() - 1; ii >= 0 ; ii-- )
407 {
408 EDA_ITEM* eda_item = aList->GetPickedItem( (unsigned) ii );
409
410 /* Test for existence of item on board.
411 * It could be deleted, and no more on board:
412 * - if a call to SaveCopyInUndoList was forgotten in Pcbnew
413 * - in zones outlines, when a change in one zone merges this zone with an other
414 * This test avoids a Pcbnew crash
415 * Obviously, this test is not made for deleted items
416 */
417 UNDO_REDO status = aList->GetPickedItemStatus( ii );
418
419 if( status != UNDO_REDO::DELETED
420 && status != UNDO_REDO::DRILLORIGIN // origin markers never on board
421 && status != UNDO_REDO::GRIDORIGIN // origin markers never on board
422 && status != UNDO_REDO::PAGESETTINGS ) // nor are page settings proxy items
423 {
424 if( !TestForExistingItem( GetBoard(), (BOARD_ITEM*) eda_item ) )
425 {
426 // Checking if it ever happens
427 wxASSERT_MSG( false, wxT( "Item in the undo buffer does not exist" ) );
428
429 // Remove this non existent item
430 aList->RemovePicker( ii );
431 not_found = true;
432
433 if( aList->GetCount() == 0 )
434 break;
435
436 continue;
437 }
438 }
439
440 // see if we must rebuild ratsnets and pointers lists
441 switch( eda_item->Type() )
442 {
443 case PCB_FOOTPRINT_T:
444 deep_reBuild_ratsnest = true; // Pointers on pads can be invalid
446
447 case PCB_ZONE_T:
448 case PCB_TRACE_T:
449 case PCB_ARC_T:
450 case PCB_VIA_T:
451 case PCB_PAD_T:
452 reBuild_ratsnest = true;
453 break;
454
455 case PCB_NETINFO_T:
456 reBuild_ratsnest = true;
457 deep_reBuild_ratsnest = true;
458 break;
459
460 default:
461 break;
462 }
463
464 switch( aList->GetPickedItemStatus( ii ) )
465 {
466 case UNDO_REDO::CHANGED: /* Exchange old and new data for each item */
467 {
468 BOARD_ITEM* item = (BOARD_ITEM*) eda_item;
469 BOARD_ITEM* image = (BOARD_ITEM*) aList->GetPickedItemLink( ii );
470
471 // Remove all pads/drawings/texts, as they become invalid
472 // for the VIEW after SwapData() called for footprints
473 view->Remove( item );
474 connectivity->Remove( item );
475
476 SwapItemData( item, image );
477
478 if( item->Type() == PCB_GROUP_T )
479 {
480 group = static_cast<PCB_GROUP*>( item );
481
482 group->RunOnChildren( [&]( BOARD_ITEM* child )
483 {
484 child->SetParentGroup( group );
485 } );
486 }
487
488 view->Add( item );
489 view->Hide( item, false );
490 connectivity->Add( item );
491 item->GetBoard()->OnItemChanged( item );
492 break;
493 }
494
495 case UNDO_REDO::NEWITEM: /* new items are deleted */
497 GetModel()->Remove( (BOARD_ITEM*) eda_item );
498
499 if( eda_item->Type() != PCB_NETINFO_T )
500 view->Remove( eda_item );
501
502 break;
503
504 case UNDO_REDO::DELETED: /* deleted items are put in List, as new items */
506 GetModel()->Add( (BOARD_ITEM*) eda_item );
507
508 if( eda_item->Type() != PCB_NETINFO_T )
509 view->Add( eda_item );
510
511 if( eda_item->Type() == PCB_GROUP_T )
512 group = static_cast<PCB_GROUP*>( eda_item );
513
514 break;
515
518 static_cast<BOARD_ITEM*>( eda_item )->SetParentGroup( nullptr );
519 break;
520
523
524 if( group )
525 group->AddItem( static_cast<BOARD_ITEM*>( eda_item ) );
526
527 break;
528
531 {
532 BOARD_ITEM* item = (BOARD_ITEM*) eda_item;
533 BOARD_ITEM* image = (BOARD_ITEM*) aList->GetPickedItemLink( ii );
534 VECTOR2D origin = image->GetPosition();
535 image->SetPosition( eda_item->GetPosition() );
536
537 if( aList->GetPickedItemStatus( ii ) == UNDO_REDO::DRILLORIGIN )
538 BOARD_EDITOR_CONTROL::DoSetDrillOrigin( view, this, item, origin );
539 else
540 PCB_CONTROL::DoSetGridOrigin( view, this, item, origin );
541
542 break;
543 }
544
546 {
547 // swap current settings with stored settings
548 DS_PROXY_UNDO_ITEM alt_item( this );
549 DS_PROXY_UNDO_ITEM* item = static_cast<DS_PROXY_UNDO_ITEM*>( eda_item );
550 item->Restore( this );
551 *item = alt_item;
552 break;
553 }
554
555 default:
556 wxFAIL_MSG( wxString::Format( wxT( "PutDataInPreviousState() error (unknown code %X)" ),
557 aList->GetPickedItemStatus( ii ) ) );
558 break;
559 }
560 }
561
562 if( not_found )
563 wxMessageBox( _( "Incomplete undo/redo operation: some items not found" ) );
564
565 // Rebuild pointers and connectivity that can be changed.
566 // connectivity can be rebuilt only in the board editor frame
567 if( IsType( FRAME_PCB_EDITOR ) && ( reBuild_ratsnest || deep_reBuild_ratsnest ) )
568 {
569 Compile_Ratsnest( false );
570 }
571
573 selTool->RebuildSelection();
574
576}
577
578
580{
581 if( aItemCount == 0 )
582 return;
583
584 UNDO_REDO_CONTAINER& list = whichList == UNDO_LIST ? m_undoList : m_redoList;
585 unsigned icnt = list.m_CommandsList.size();
586
587 if( aItemCount > 0 )
588 icnt = aItemCount;
589
590 for( unsigned ii = 0; ii < icnt; ii++ )
591 {
592 if( list.m_CommandsList.size() == 0 )
593 break;
594
595 PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
596 list.m_CommandsList.erase( list.m_CommandsList.begin() );
597
598 curr_cmd->ClearListAndDeleteItems();
599 delete curr_cmd; // Delete command
600 }
601}
602
603
605{
608
609 undo->ClearListAndDeleteItems();
610 delete undo;
611
612 GetCanvas()->Refresh();
613}
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...
Definition: board_item.h:50
void SetParentGroup(PCB_GROUP *aGroup)
Definition: board_item.h:61
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:37
virtual void SwapData(BOARD_ITEM *aImage)
Swap data between aItem and aImage.
Definition: board_item.cpp:155
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:150
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:265
void OnItemChanged(BOARD_ITEM *aItem)
Notify the board and its listeners that an item on the board has been modified in some way.
Definition: board.cpp:1991
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:763
ZONES & Zones()
Definition: board.h:313
void SanitizeNetcodes()
Definition: board.cpp:1956
FOOTPRINTS & Footprints()
Definition: board.h:307
GROUPS & Groups()
The groups must maintain the following invariants.
Definition: board.h:327
TRACKS & Tracks()
Definition: board.h:304
DRAWINGS & Drawings()
Definition: board.h:310
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:424
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
Update the board display after modifying it by a python script (note: it is automatically called by a...
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:249
const KIID m_Uuid
Definition: eda_item.h:492
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual void SetParent(EDA_ITEM *aParent)
Definition: eda_item.h:100
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:82
void ClearEditFlags()
Definition: eda_item.h:160
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:210
PADS & Pads()
Definition: footprint.h:174
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:555
DRAWINGS & GraphicalItems()
Definition: footprint.h:177
FP_TEXT & Reference()
Definition: footprint.h:556
void SetLink(EDA_ITEM *aItem)
Container for NETINFO_ITEM elements, which are the nets.
Definition: netinfo.h:324
iterator begin() const
Definition: netinfo.h:444
iterator end() const
Definition: netinfo.h:449
Definition: pad.h:58
void ClearUndoORRedoList(UNDO_REDO_LIST whichList, int aItemCount=-1) override
Free the undo or redo list from List element.
Definition: undo_redo.cpp:579
void RestoreCopyFromUndoList(wxCommandEvent &aEvent)
Undo the last edit:
Definition: undo_redo.cpp:331
void saveCopyInUndoList(PICKED_ITEMS_LIST *commandToUndo, const PICKED_ITEMS_LIST &aItemsList, UNDO_REDO aCommandType)
Definition: undo_redo.cpp:179
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.
Definition: undo_redo.cpp:319
void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand) override
Create a new entry in undo list of commands.
Definition: undo_redo.cpp:300
void RollbackFromUndo()
Perform an undo of the last edit without logging a corresponding redo.
Definition: undo_redo.cpp:604
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.
Definition: undo_redo.cpp:391
void RestoreCopyFromRedoList(wxCommandEvent &aEvent)
Redo the last edit:
Definition: undo_redo.cpp:361
virtual void OnModify()
Must be called after a change in order to set the "modify" flag of the current screen and update the ...
PCB_DRAW_PANEL_GAL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
BOARD * GetBoard() const
virtual BOARD_ITEM_CONTAINER * GetModel() const =0
void Compile_Ratsnest(bool aDisplayStatus)
Create the entire board ratsnest.
Definition: ratsnest.cpp:35
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).
Definition: pcb_group.h:51
The selection tool: currently supports:
void RebuildSelection()
Rebuild the selection from the EDA_ITEMs' selection flags.
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.
UNDO_REDO GetPickedItemStatus(unsigned int aIdx) const
ITEM_PICKER GetItemWrapper(unsigned int aIdx) const
EDA_ITEM * GetPickedItemLink(unsigned int aIdx) const
bool RemovePicker(unsigned aIdx)
Remove one entry (one picker) from the list of picked items.
unsigned GetCount() const
void ClearListAndDeleteItems()
Delete the list of pickers AND the data pointed by #m_PickedItem or #m_PickedItemLink according to th...
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.
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:170
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
void PostEvent(const TOOL_EVENT &aEvent)
Put an event to the event queue to be processed at the end of event processing cycle.
A holder to handle a list of undo (or redo) commands.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
#define _(s)
@ FRAME_PCB_EDITOR
Definition: frame_type.h:40
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 ...
Definition: macros.h:83
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
@ AS_GLOBAL
Global action (toolbar/main menu event, global shortcut)
Definition: tool_action.h:45
@ TA_UNDO_REDO_PRE
Definition: tool_event.h:101
@ TA_UNDO_REDO_POST
Definition: tool_event.h:104
@ TC_MESSAGE
Definition: tool_event.h:53
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:115
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:112
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:103
@ PCB_NETINFO_T
class NETINFO_ITEM, a description of a net
Definition: typeinfo.h:114
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:101
static void SwapItemData(BOARD_ITEM *aItem, BOARD_ITEM *aImage)
Definition: undo_redo.cpp:157
static bool TestForExistingItem(BOARD *aPcb, BOARD_ITEM *aItem)
Test if aItem exists somewhere in undo/redo lists of items.
Definition: undo_redo.cpp:113
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...