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-2022 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 <origin_viewitem.h>
40#include <tool/tool_manager.h>
41#include <tool/actions.h>
43#include <tools/pcb_control.h>
46#include <wx/msgdlg.h>
47
48/* Functions to undo and redo edit commands.
49 * commands to undo are stored in CurrentScreen->m_UndoList
50 * commands to redo are stored in CurrentScreen->m_RedoList
51 *
52 * m_UndoList and m_RedoList handle a std::vector of PICKED_ITEMS_LIST
53 * Each PICKED_ITEMS_LIST handle a std::vector of pickers (class ITEM_PICKER),
54 * that store the list of schematic items that are concerned by the command to undo or redo
55 * and is created for each command to undo (handle also a command to redo).
56 * each picker has a pointer pointing to an item to undo or redo (in fact: deleted, added or
57 * modified),
58 * and has a pointer to a copy of this item, when this item has been modified
59 * (the old values of parameters are therefore saved)
60 *
61 * there are 3 cases:
62 * - delete item(s) command
63 * - change item(s) command
64 * - add item(s) command
65 *
66 * Undo command
67 * - delete item(s) command:
68 * => deleted items are moved in undo list
69 *
70 * - change item(s) command
71 * => A copy of item(s) is made (a DrawPickedStruct list of wrappers)
72 * the .m_Link member of each wrapper points the modified item.
73 * the .m_Item member of each wrapper points the old copy of this item.
74 *
75 * - add item(s) command
76 * =>A list of item(s) is made. The .m_Item member of each wrapper points the new item.
77 *
78 * Redo command
79 * - delete item(s) old command:
80 * => deleted items are moved in EEDrawList list, and in
81 *
82 * - change item(s) command
83 * => the copy of item(s) is moved in Undo list
84 *
85 * - add item(s) command
86 * => The list of item(s) is used to create a deleted list in undo list(same as a delete
87 * command)
88 *
89 * Some block operations that change items can be undone without memorize items, just the
90 * coordinates of the transform:
91 * move list of items (undo/redo is made by moving with the opposite move vector)
92 * mirror (Y) and flip list of items (undo/redo is made by mirror or flip items)
93 * so they are handled specifically.
94 *
95 */
96
97
111static bool TestForExistingItem( BOARD* aPcb, BOARD_ITEM* aItem )
112{
113 for( PCB_TRACK* item : aPcb->Tracks() )
114 {
115 if( aItem == static_cast<BOARD_ITEM*>( item ) )
116 return true;
117 }
118
119 for( FOOTPRINT* item : aPcb->Footprints() )
120 {
121 if( aItem == static_cast<BOARD_ITEM*>( item ) )
122 return true;
123 }
124
125 for( BOARD_ITEM* item : aPcb->Drawings() )
126 {
127 if( aItem == static_cast<BOARD_ITEM*>( item ) )
128 return true;
129 }
130
131 for( ZONE* item : aPcb->Zones() )
132 {
133 if( aItem == static_cast<BOARD_ITEM*>( item ) )
134 return true;
135 }
136
137 NETINFO_LIST& netInfo = aPcb->GetNetInfo();
138
139 for( NETINFO_LIST::iterator i = netInfo.begin(); i != netInfo.end(); ++i )
140 {
141 if( aItem == static_cast<BOARD_ITEM*>( *i ) )
142 return true;
143 }
144
145 for( PCB_GROUP* item : aPcb->Groups() )
146 {
147 if( aItem == static_cast<BOARD_ITEM*>( item ) )
148 return true;
149 }
150
151 return false;
152}
153
154
156 const PICKED_ITEMS_LIST& aItemsList,
157 UNDO_REDO aCommandType )
158{
159 int preExisting = commandToUndo->GetCount();
160
161 // First, filter unnecessary stuff from the list (i.e. for multiple pads / labels modified),
162 // take the first occurrence of the footprint (we save copies of footprints when one of its
163 // subitems is changed).
164 for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
165 {
166 ITEM_PICKER curr_picker = aItemsList.GetItemWrapper(ii);
167 BOARD_ITEM* item = dynamic_cast<BOARD_ITEM*>( aItemsList.GetPickedItem( ii ) );
168
169 // For items belonging to footprints, we need to save state of the parent footprint
170 if( item && item->GetParent() && item->GetParent()->Type() == PCB_FOOTPRINT_T )
171 {
172 item = item->GetParent();
173
174 // Check if the parent footprint has already been saved in another entry
175 bool found = false;
176
177 for( unsigned j = 0; j < commandToUndo->GetCount(); j++ )
178 {
179 if( commandToUndo->GetPickedItem( j ) == item
180 && commandToUndo->GetPickedItemStatus( j ) == UNDO_REDO::CHANGED )
181 {
182 found = true;
183 break;
184 }
185 }
186
187 if( !found )
188 {
189 // Create a clean copy of the parent footprint
190 FOOTPRINT* orig = static_cast<FOOTPRINT*>( item );
191 FOOTPRINT* clone = new FOOTPRINT( *orig );
192 clone->SetParent( GetBoard() );
193 clone->SetParentGroup( nullptr );
194
195 // Clear current flags (which can be temporary set by a current edit command)
196 for( BOARD_ITEM* child : clone->GraphicalItems() )
197 child->ClearEditFlags();
198
199 for( PAD* pad : clone->Pads() )
200 pad->ClearEditFlags();
201
202 clone->Reference().ClearEditFlags();
203 clone->Value().ClearEditFlags();
204
205 ITEM_PICKER picker( nullptr, item, UNDO_REDO::CHANGED );
206 picker.SetLink( clone );
207 commandToUndo->PushItem( picker );
208 }
209 else
210 {
211 continue;
212 }
213 }
214 else
215 {
216 // Normal case: all other BOARD_ITEMs, are simply copied to the new list
217 commandToUndo->PushItem( curr_picker );
218 }
219 }
220
221 for( unsigned ii = preExisting; ii < commandToUndo->GetCount(); ii++ )
222 {
223 EDA_ITEM* item = commandToUndo->GetPickedItem( ii );
224 UNDO_REDO command = commandToUndo->GetPickedItemStatus( ii );
225
226 if( command == UNDO_REDO::UNSPECIFIED )
227 {
228 command = aCommandType;
229 commandToUndo->SetPickedItemStatus( command, ii );
230 }
231
232 wxASSERT( item );
233
234 switch( command )
235 {
239
240 // If we don't yet have a copy in the link, set one up
241 if( !commandToUndo->GetPickedItemLink( ii ) )
242 {
243 BOARD_ITEM* clone = static_cast<BOARD_ITEM*>( item->Clone() );
244 clone->SetParentGroup( nullptr );
245
246 commandToUndo->SetPickedItemLink( clone, ii );
247 }
248
249 break;
250
256 break;
257
258 default:
259 wxFAIL_MSG( wxString::Format( wxT( "SaveCopyInUndoList() error (unknown code %X)" ),
260 command ) );
261 break;
262 }
263 }
264
265 if( commandToUndo->GetCount() )
266 {
267 /* Save the copy in undo list */
268 PushCommandToUndoList( commandToUndo );
269
270 /* Clear redo list, because after a new command one cannot redo a command */
272 }
273 else
274 {
275 // Should not occur
276 wxASSERT( false );
277 delete commandToUndo;
278 }
279}
280
281
283{
284 PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
285 PICKED_ITEMS_LIST itemsList;
286
287 itemsList.PushItem( ITEM_PICKER( nullptr, aItem, aCommandType ) );
288 saveCopyInUndoList( commandToUndo, itemsList, aCommandType );
289}
290
291
293 UNDO_REDO aCommandType )
294{
295 PICKED_ITEMS_LIST* commandToUndo = new PICKED_ITEMS_LIST();
296
297 saveCopyInUndoList( commandToUndo, aItemsList, aCommandType );
298}
299
300
302 UNDO_REDO aCommandType )
303{
304 PICKED_ITEMS_LIST* commandToUndo = PopCommandFromUndoList();
305
306 if( !commandToUndo )
307 commandToUndo = new PICKED_ITEMS_LIST();
308
309 saveCopyInUndoList( commandToUndo, aItemsList, aCommandType );
310}
311
312
314{
315 if( UndoRedoBlocked() )
316 return;
317
318 if( GetUndoCommandCount() <= 0 )
319 return;
320
321 // Inform tools that undo command was issued
323
324 // Get the old list
326
327 // Undo the command
329
330 // Put the old list in RedoList
332 PushCommandToRedoList( list );
333
334 OnModify();
335
338
339 GetCanvas()->Refresh();
340}
341
342
344{
345 if( UndoRedoBlocked() )
346 return;
347
348 if( GetRedoCommandCount() == 0 )
349 return;
350
351 // Inform tools that redo command was issued
353
354 // Get the old list
356
357 // Redo the command
359
360 // Put the old list in UndoList
362 PushCommandToUndoList( list );
363
364 OnModify();
365
368
369 GetCanvas()->Refresh();
370}
371
372
374{
375 bool not_found = false;
376 bool reBuild_ratsnest = false;
377 bool deep_reBuild_ratsnest = false; // true later if pointers must be rebuilt
378
379 auto view = GetCanvas()->GetView();
380 auto connectivity = GetBoard()->GetConnectivity();
381
382 PCB_GROUP* group = nullptr;
383
384 GetBoard()->IncrementTimeStamp(); // clear caches
385
386 // Undo in the reverse order of list creation: (this can allow stacked changes
387 // like the same item can be changes and deleted in the same complex command
388
389 // Restore changes in reverse order
390 for( int ii = aList->GetCount() - 1; ii >= 0 ; ii-- )
391 {
392 EDA_ITEM* eda_item = aList->GetPickedItem( (unsigned) ii );
393
394 /* Test for existence of item on board.
395 * It could be deleted, and no more on board:
396 * - if a call to SaveCopyInUndoList was forgotten in Pcbnew
397 * - in zones outlines, when a change in one zone merges this zone with an other
398 * This test avoids a Pcbnew crash
399 * Obviously, this test is not made for deleted items
400 */
401 UNDO_REDO status = aList->GetPickedItemStatus( ii );
402
403 if( status != UNDO_REDO::DELETED
404 && status != UNDO_REDO::DRILLORIGIN // origin markers never on board
405 && status != UNDO_REDO::GRIDORIGIN // origin markers never on board
406 && status != UNDO_REDO::PAGESETTINGS ) // nor are page settings proxy items
407 {
408 if( !TestForExistingItem( GetBoard(), (BOARD_ITEM*) eda_item ) )
409 {
410 // Checking if it ever happens
411 wxASSERT_MSG( false, wxT( "Item in the undo buffer does not exist" ) );
412
413 // Remove this non existent item
414 aList->RemovePicker( ii );
415 not_found = true;
416
417 if( aList->GetCount() == 0 )
418 break;
419
420 continue;
421 }
422 }
423
424 // see if we must rebuild ratsnets and pointers lists
425 switch( eda_item->Type() )
426 {
427 case PCB_FOOTPRINT_T:
428 deep_reBuild_ratsnest = true; // Pointers on pads can be invalid
430
431 case PCB_ZONE_T:
432 case PCB_TRACE_T:
433 case PCB_ARC_T:
434 case PCB_VIA_T:
435 case PCB_PAD_T:
436 reBuild_ratsnest = true;
437 break;
438
439 case PCB_NETINFO_T:
440 reBuild_ratsnest = true;
441 deep_reBuild_ratsnest = true;
442 break;
443
444 default:
445 break;
446 }
447
448 switch( aList->GetPickedItemStatus( ii ) )
449 {
450 case UNDO_REDO::CHANGED: /* Exchange old and new data for each item */
451 {
452 BOARD_ITEM* item = (BOARD_ITEM*) eda_item;
453 BOARD_ITEM* image = (BOARD_ITEM*) aList->GetPickedItemLink( ii );
454
455 // Remove all pads/drawings/texts, as they become invalid
456 // for the VIEW after SwapItemData() called for footprints
457 view->Remove( item );
458 connectivity->Remove( item );
459
460 item->SwapItemData( image );
461
462 if( item->Type() == PCB_GROUP_T )
463 {
464 group = static_cast<PCB_GROUP*>( item );
465
466 group->RunOnChildren( [&]( BOARD_ITEM* child )
467 {
468 child->SetParentGroup( group );
469 } );
470 }
471
472 view->Add( item );
473 view->Hide( item, false );
474 connectivity->Add( item );
475 item->GetBoard()->OnItemChanged( item );
476 break;
477 }
478
479 case UNDO_REDO::NEWITEM: /* new items are deleted */
481 GetModel()->Remove( (BOARD_ITEM*) eda_item );
482
483 if( eda_item->Type() != PCB_NETINFO_T )
484 view->Remove( eda_item );
485
486 break;
487
488 case UNDO_REDO::DELETED: /* deleted items are put in List, as new items */
490 GetModel()->Add( (BOARD_ITEM*) eda_item );
491
492 if( eda_item->Type() != PCB_NETINFO_T )
493 view->Add( eda_item );
494
495 if( eda_item->Type() == PCB_GROUP_T )
496 group = static_cast<PCB_GROUP*>( eda_item );
497
498 break;
499
502 static_cast<BOARD_ITEM*>( eda_item )->SetParentGroup( nullptr );
503 break;
504
507
508 if( group )
509 group->AddItem( static_cast<BOARD_ITEM*>( eda_item ) );
510
511 break;
512
515 {
516 BOARD_ITEM* item = (BOARD_ITEM*) eda_item;
517 BOARD_ITEM* image = (BOARD_ITEM*) aList->GetPickedItemLink( ii );
518 VECTOR2D origin = image->GetPosition();
519 image->SetPosition( eda_item->GetPosition() );
520
521 if( aList->GetPickedItemStatus( ii ) == UNDO_REDO::DRILLORIGIN )
522 BOARD_EDITOR_CONTROL::DoSetDrillOrigin( view, this, item, origin );
523 else
524 PCB_CONTROL::DoSetGridOrigin( view, this, item, origin );
525
526 break;
527 }
528
530 {
531 // swap current settings with stored settings
532 DS_PROXY_UNDO_ITEM alt_item( this );
533 DS_PROXY_UNDO_ITEM* item = static_cast<DS_PROXY_UNDO_ITEM*>( eda_item );
534 item->Restore( this );
535 *item = alt_item;
536 break;
537 }
538
539 default:
540 wxFAIL_MSG( wxString::Format( wxT( "PutDataInPreviousState() error (unknown code %X)" ),
541 aList->GetPickedItemStatus( ii ) ) );
542 break;
543 }
544 }
545
546 if( not_found )
547 wxMessageBox( _( "Incomplete undo/redo operation: some items not found" ) );
548
549 // Rebuild pointers and connectivity that can be changed.
550 // connectivity can be rebuilt only in the board editor frame
551 if( IsType( FRAME_PCB_EDITOR ) && ( reBuild_ratsnest || deep_reBuild_ratsnest ) )
552 {
553 Compile_Ratsnest( false );
554 }
555
557 selTool->RebuildSelection();
558
560}
561
562
564{
565 if( aItemCount == 0 )
566 return;
567
568 UNDO_REDO_CONTAINER& list = whichList == UNDO_LIST ? m_undoList : m_redoList;
569 unsigned icnt = list.m_CommandsList.size();
570
571 if( aItemCount > 0 )
572 icnt = aItemCount;
573
574 for( unsigned ii = 0; ii < icnt; ii++ )
575 {
576 if( list.m_CommandsList.size() == 0 )
577 break;
578
579 PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
580 list.m_CommandsList.erase( list.m_CommandsList.begin() );
581 ClearListAndDeleteItems( curr_cmd );
582 delete curr_cmd; // Delete command
583 }
584}
585
586
588{
589 aList->ClearListAndDeleteItems( []( EDA_ITEM* item )
590 {
591 static_cast<BOARD_ITEM*>( item )->SetParentGroup( nullptr );
592 delete item;
593 } );
594}
595
596
598{
602 delete undo;
603
604 GetCanvas()->Refresh();
605}
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:58
void SetParentGroup(PCB_GROUP *aGroup)
Definition: board_item.h:71
void SwapItemData(BOARD_ITEM *aImage)
Swap data between aItem and aImage.
Definition: board_item.cpp:166
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:43
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:163
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:2048
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:765
ZONES & Zones()
Definition: board.h:313
void SanitizeNetcodes()
Definition: board.cpp:2013
FOOTPRINTS & Footprints()
Definition: board.h:307
void IncrementTimeStamp()
Definition: board.cpp:226
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
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:158
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:213
PADS & Pads()
Definition: footprint.h:170
FP_TEXT & Value()
read/write accessors:
Definition: footprint.h:567
DRAWINGS & GraphicalItems()
Definition: footprint.h:173
FP_TEXT & Reference()
Definition: footprint.h:568
void SetLink(EDA_ITEM *aItem)
Container for NETINFO_ITEM elements, which are the nets.
Definition: netinfo.h:333
iterator begin() const
Definition: netinfo.h:453
iterator end() const
Definition: netinfo.h:458
Definition: pad.h:59
void ClearUndoORRedoList(UNDO_REDO_LIST whichList, int aItemCount=-1) override
Free the undo or redo list from List element.
Definition: undo_redo.cpp:563
void RestoreCopyFromUndoList(wxCommandEvent &aEvent)
Undo the last edit:
Definition: undo_redo.cpp:313
void saveCopyInUndoList(PICKED_ITEMS_LIST *commandToUndo, const PICKED_ITEMS_LIST &aItemsList, UNDO_REDO aCommandType)
Definition: undo_redo.cpp:155
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:301
void SaveCopyInUndoList(EDA_ITEM *aItemToCopy, UNDO_REDO aTypeCommand) override
Create a new entry in undo list of commands.
Definition: undo_redo.cpp:282
void ClearListAndDeleteItems(PICKED_ITEMS_LIST *aList)
Definition: undo_redo.cpp:587
void RollbackFromUndo()
Perform an undo of the last edit without logging a corresponding redo.
Definition: undo_redo.cpp:597
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:373
void RestoreCopyFromRedoList(wxCommandEvent &aEvent)
Redo the last edit:
Definition: undo_redo.cpp:343
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.
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 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
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 bool TestForExistingItem(BOARD *aPcb, BOARD_ITEM *aItem)
Test if aItem exists somewhere in undo/redo lists of items.
Definition: undo_redo.cpp:111
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...