KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 {
236 case UNDO_REDO::CHANGED:
237 case UNDO_REDO::DRILLORIGIN:
238 case UNDO_REDO::GRIDORIGIN:
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
251 case UNDO_REDO::NEWITEM:
252 case UNDO_REDO::DELETED:
253 case UNDO_REDO::PAGESETTINGS:
254 case UNDO_REDO::REGROUP:
255 case UNDO_REDO::UNGROUP:
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 bool solder_mask_dirty = false;
379
380 auto view = GetCanvas()->GetView();
381 auto connectivity = GetBoard()->GetConnectivity();
382
383 PCB_GROUP* group = nullptr;
384
385 GetBoard()->IncrementTimeStamp(); // clear caches
386
387 // Undo in the reverse order of list creation: (this can allow stacked changes
388 // like the same item can be changes and deleted in the same complex command
389
390 // Restore changes in reverse order
391 for( int ii = aList->GetCount() - 1; ii >= 0 ; ii-- )
392 {
393 EDA_ITEM* eda_item = aList->GetPickedItem( (unsigned) ii );
394
395 /* Test for existence of item on board.
396 * It could be deleted, and no more on board:
397 * - if a call to SaveCopyInUndoList was forgotten in Pcbnew
398 * - in zones outlines, when a change in one zone merges this zone with an other
399 * This test avoids a Pcbnew crash
400 * Obviously, this test is not made for deleted items
401 */
402 UNDO_REDO status = aList->GetPickedItemStatus( ii );
403
404 if( status != UNDO_REDO::DELETED
405 && status != UNDO_REDO::DRILLORIGIN // origin markers never on board
406 && status != UNDO_REDO::GRIDORIGIN // origin markers never on board
407 && status != UNDO_REDO::PAGESETTINGS ) // nor are page settings proxy items
408 {
409 if( !TestForExistingItem( GetBoard(), (BOARD_ITEM*) eda_item ) )
410 {
411 // Checking if it ever happens
412 wxASSERT_MSG( false, wxT( "Item in the undo buffer does not exist" ) );
413
414 // Remove this non existent item
415 aList->RemovePicker( ii );
416 not_found = true;
417
418 if( aList->GetCount() == 0 )
419 break;
420
421 continue;
422 }
423 }
424
425 // see if we must rebuild ratsnets and pointers lists
426 switch( eda_item->Type() )
427 {
428 case PCB_FOOTPRINT_T:
429 deep_reBuild_ratsnest = true; // Pointers on pads can be invalid
431
432 case PCB_ZONE_T:
433 case PCB_TRACE_T:
434 case PCB_ARC_T:
435 case PCB_VIA_T:
436 case PCB_PAD_T:
437 reBuild_ratsnest = true;
438 break;
439
440 case PCB_NETINFO_T:
441 reBuild_ratsnest = true;
442 deep_reBuild_ratsnest = true;
443 break;
444
445 default:
446 break;
447 }
448
449 switch( eda_item->Type() )
450 {
451 case PCB_FOOTPRINT_T:
452 solder_mask_dirty = true;
453 break;
454
455 case PCB_VIA_T:
456 solder_mask_dirty = true;
457 break;
458
459 case PCB_ZONE_T:
460 case PCB_TRACE_T:
461 case PCB_ARC_T:
462 case PCB_PAD_T:
463 case PCB_SHAPE_T:
464 {
465 LSET layers = static_cast<BOARD_ITEM*>( eda_item )->GetLayerSet();
466
467 if( layers.test( F_Mask ) || layers.test( B_Mask ) )
468 solder_mask_dirty = true;
469
470 break;
471 }
472
473 default:
474 break;
475 }
476
477 switch( aList->GetPickedItemStatus( ii ) )
478 {
479 case UNDO_REDO::CHANGED: /* Exchange old and new data for each item */
480 {
481 BOARD_ITEM* item = (BOARD_ITEM*) eda_item;
482 BOARD_ITEM* image = (BOARD_ITEM*) aList->GetPickedItemLink( ii );
483
484 // Remove all pads/drawings/texts, as they become invalid
485 // for the VIEW after SwapItemData() called for footprints
486 view->Remove( item );
487 connectivity->Remove( item );
488
489 item->SwapItemData( image );
490
491 if( item->Type() == PCB_GROUP_T )
492 {
493 group = static_cast<PCB_GROUP*>( item );
494
495 group->RunOnChildren( [&]( BOARD_ITEM* child )
496 {
497 child->SetParentGroup( group );
498 } );
499 }
500
501 view->Add( item );
502 view->Hide( item, false );
503 connectivity->Add( item );
504 item->GetBoard()->OnItemChanged( item );
505 break;
506 }
507
508 case UNDO_REDO::NEWITEM: /* new items are deleted */
509 aList->SetPickedItemStatus( UNDO_REDO::DELETED, ii );
510 GetModel()->Remove( (BOARD_ITEM*) eda_item );
511
512 if( eda_item->Type() != PCB_NETINFO_T )
513 view->Remove( eda_item );
514
515 break;
516
517 case UNDO_REDO::DELETED: /* deleted items are put in List, as new items */
518 aList->SetPickedItemStatus( UNDO_REDO::NEWITEM, ii );
519 GetModel()->Add( (BOARD_ITEM*) eda_item );
520
521 if( eda_item->Type() != PCB_NETINFO_T )
522 view->Add( eda_item );
523
524 if( eda_item->Type() == PCB_GROUP_T )
525 group = static_cast<PCB_GROUP*>( eda_item );
526
527 break;
528
529 case UNDO_REDO::REGROUP:
530 aList->SetPickedItemStatus( UNDO_REDO::UNGROUP, ii );
531 static_cast<BOARD_ITEM*>( eda_item )->SetParentGroup( nullptr );
532 break;
533
534 case UNDO_REDO::UNGROUP:
535 aList->SetPickedItemStatus( UNDO_REDO::REGROUP, ii );
536
537 if( group )
538 group->AddItem( static_cast<BOARD_ITEM*>( eda_item ) );
539
540 break;
541
542 case UNDO_REDO::DRILLORIGIN:
543 case UNDO_REDO::GRIDORIGIN:
544 {
545 BOARD_ITEM* item = (BOARD_ITEM*) eda_item;
546 BOARD_ITEM* image = (BOARD_ITEM*) aList->GetPickedItemLink( ii );
547 VECTOR2D origin = image->GetPosition();
548 image->SetPosition( eda_item->GetPosition() );
549
550 if( aList->GetPickedItemStatus( ii ) == UNDO_REDO::DRILLORIGIN )
551 BOARD_EDITOR_CONTROL::DoSetDrillOrigin( view, this, item, origin );
552 else
553 PCB_CONTROL::DoSetGridOrigin( view, this, item, origin );
554
555 break;
556 }
557
558 case UNDO_REDO::PAGESETTINGS:
559 {
560 // swap current settings with stored settings
561 DS_PROXY_UNDO_ITEM alt_item( this );
562 DS_PROXY_UNDO_ITEM* item = static_cast<DS_PROXY_UNDO_ITEM*>( eda_item );
563 item->Restore( this );
564 *item = alt_item;
565 break;
566 }
567
568 default:
569 wxFAIL_MSG( wxString::Format( wxT( "PutDataInPreviousState() error (unknown code %X)" ),
570 aList->GetPickedItemStatus( ii ) ) );
571 break;
572 }
573 }
574
575 if( not_found )
576 wxMessageBox( _( "Incomplete undo/redo operation: some items not found" ) );
577
578 if( IsType( FRAME_PCB_EDITOR ) )
579 {
580 if( reBuild_ratsnest || deep_reBuild_ratsnest )
581 Compile_Ratsnest( false );
582
583 if( solder_mask_dirty )
585 }
586
588 selTool->RebuildSelection();
589
591}
592
593
595{
596 if( aItemCount == 0 )
597 return;
598
599 UNDO_REDO_CONTAINER& list = whichList == UNDO_LIST ? m_undoList : m_redoList;
600 unsigned icnt = list.m_CommandsList.size();
601
602 if( aItemCount > 0 )
603 icnt = aItemCount;
604
605 for( unsigned ii = 0; ii < icnt; ii++ )
606 {
607 if( list.m_CommandsList.size() == 0 )
608 break;
609
610 PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
611 list.m_CommandsList.erase( list.m_CommandsList.begin() );
612 ClearListAndDeleteItems( curr_cmd );
613 delete curr_cmd; // Delete command
614 }
615}
616
617
619{
620 aList->ClearListAndDeleteItems( []( EDA_ITEM* item )
621 {
622 static_cast<BOARD_ITEM*>( item )->SetParentGroup( nullptr );
623 delete item;
624 } );
625}
626
627
629{
633 delete undo;
634
635 GetCanvas()->Refresh();
636}
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:71
void SetParentGroup(PCB_GROUP *aGroup)
Definition: board_item.h:84
void SwapItemData(BOARD_ITEM *aImage)
Swap data between aItem and aImage.
Definition: board_item.cpp:167
virtual const BOARD * GetBoard() const
Return the BOARD in which this BOARD_ITEM resides, or NULL if none.
Definition: board_item.cpp:44
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:176
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:270
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:2127
const NETINFO_LIST & GetNetInfo() const
Definition: board.h:800
ZONES & Zones()
Definition: board.h:318
void SanitizeNetcodes()
Definition: board.cpp:2092
FOOTPRINTS & Footprints()
Definition: board.h:312
void IncrementTimeStamp()
Definition: board.cpp:237
GROUPS & Groups()
The groups must maintain the following invariants.
Definition: board.h:334
TRACKS & Tracks()
Definition: board.h:309
DRAWINGS & Drawings()
Definition: board.h:315
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
Definition: board.h:432
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.
Definition: eda_item.h:85
virtual VECTOR2I GetPosition() const
Definition: eda_item.h:232
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:81
void ClearEditFlags()
Definition: eda_item.h:142
static const TOOL_EVENT SelectedItemsModified
Selected items were moved, this can be very high frequency on the canvas, use with care.
Definition: actions.h:214
PCB_TEXT & Value()
read/write accessors:
Definition: footprint.h:569
PADS & Pads()
Definition: footprint.h:172
PCB_TEXT & Reference()
Definition: footprint.h:570
DRAWINGS & GraphicalItems()
Definition: footprint.h:175
void SetLink(EDA_ITEM *aItem)
LSET is a set of PCB_LAYER_IDs.
Definition: layer_ids.h:536
Wrapper class, so you can iterate through NETINFO_ITEM*s, not std::pair<int/wxString,...
Definition: netinfo.h:413
Container for NETINFO_ITEM elements, which are the nets.
Definition: netinfo.h:338
iterator begin() const
Definition: netinfo.h:458
iterator end() const
Definition: netinfo.h:463
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:594
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:618
void RollbackFromUndo()
Perform an undo of the last edit without logging a corresponding redo.
Definition: undo_redo.cpp:628
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:72
#define _(s)
@ FRAME_PCB_EDITOR
Definition: frame_type.h:40
@ B_Mask
Definition: layer_ids.h:106
@ F_Mask
Definition: layer_ids.h:107
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
Class to handle a set of BOARD_ITEMs.
@ 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_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:93
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:106
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:103
@ 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:94
@ PCB_NETINFO_T
class NETINFO_ITEM, a description of a net
Definition: typeinfo.h:105
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:92
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...