KiCad PCB EDA Suite
Loading...
Searching...
No Matches
schematic_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) 2004 Jean-Pierre Charras, [email protected]
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <sch_actions.h>
26#include <sch_edit_frame.h>
27#include <tool/tool_manager.h>
28#include <schematic.h>
29#include <sch_bus_entry.h>
30#include <sch_commit.h>
31#include <sch_group.h>
32#include <sch_junction.h>
33#include <sch_line.h>
34#include <sch_sheet_pin.h>
35#include <sch_table.h>
38#include <tool/actions.h>
39#include <wx/log.h>
40
41
42/* Functions to undo and redo edit commands.
43 *
44 * m_UndoList and m_RedoList handle a std::vector of PICKED_ITEMS_LIST. Each PICKED_ITEMS_LIST handles
45 * a std::vector of ITEM_PICKER that store the list of schematic items that are concerned by the command
46 * to undo or redo and is created for each command to undo/redo). Each picker has a pointer pointing to
47 * an item to undo or redo (in fact: deleted, added or modified), and has a pointer to a copy of this
48 * item, when this item has been modified (the old values of parameters are therefore saved).
49 *
50 * there are 3 cases:
51 * - delete item(s) command
52 * - change item(s) command
53 * - add item(s) command
54 *
55 * Undo command
56 * - delete item(s) command:
57 * => deleted items are moved in undo list
58 *
59 * - change item(s) command
60 * => A copy of item(s) is made (a DrawPickedStruct list of wrappers)
61 * the .m_Link member of each wrapper points the modified item.
62 * the .m_Item member of each wrapper points the old copy of this item.
63 *
64 * - add item(s) command
65 * =>A list of item(s) is made. The .m_Item member of each wrapper points
66 * the new item.
67 *
68 * Redo command
69 * - delete item(s) old command:
70 * => deleted items are moved into m_tree
71 *
72 * - change item(s) command
73 * => the copy of item(s) is moved in Undo list
74 *
75 * - add item(s) command
76 * => The list of item(s) is used to create a deleted list in undo
77 * list(same as a delete command)
78 *
79 * A problem is the hierarchical sheet handling. The data associated (sub-hierarchy, undo/redo list) is
80 * deleted only when the sheet is really deleted (i.e. when deleted from undo or redo list). This is
81 * handled by its destructor.
82 */
83
85 bool aAppend )
86{
87 PICKED_ITEMS_LIST* commandToUndo = nullptr;
88
89 wxCHECK( aItem, /* void */ );
90
92
93 // If the last stack was empty, use that one instead of creating a new stack
94 if( lastUndo )
95 {
96 if( aAppend || !lastUndo->GetCount() )
97 commandToUndo = lastUndo;
98 else
99 PushCommandToUndoList( lastUndo );
100 }
101
102 if( !commandToUndo )
103 {
104 commandToUndo = new PICKED_ITEMS_LIST();
105 }
106
107 ITEM_PICKER itemWrapper( aScreen, aItem, aCommandType );
108 itemWrapper.SetFlags( aItem->GetFlags() );
109
110 switch( aCommandType )
111 {
112 case UNDO_REDO::CHANGED: /* Create a copy of item */
113 itemWrapper.SetLink( aItem->Duplicate( IGNORE_PARENT_GROUP, nullptr, true ) );
114 commandToUndo->PushItem( itemWrapper );
115 break;
116
119 commandToUndo->PushItem( itemWrapper );
120 break;
121
122 default:
123 wxFAIL_MSG( wxString::Format( wxT( "SaveCopyInUndoList() error (unknown code %X)" ), aCommandType ) );
124 break;
125 }
126
127 if( commandToUndo->GetCount() )
128 {
129 /* Save the copy in undo list */
130 PushCommandToUndoList( commandToUndo );
131
132 /* Clear redo list, because after new save there is no redo to do */
134 }
135 else
136 {
137 delete commandToUndo;
138 }
139}
140
141
143 bool aAppend )
144{
145 PICKED_ITEMS_LIST* commandToUndo = nullptr;
146
147 if( !aItemsList.GetCount() )
148 return;
149
151
152 // If the last stack was empty, use that one instead of creating a new stack
153 if( lastUndo )
154 {
155 if( aAppend || !lastUndo->GetCount() )
156 commandToUndo = lastUndo;
157 else
158 PushCommandToUndoList( lastUndo );
159 }
160
161 if( !commandToUndo )
162 {
163 commandToUndo = new PICKED_ITEMS_LIST();
164 commandToUndo->SetDescription( aItemsList.GetDescription() );
165 }
166
167 // Copy picker list:
168 if( !commandToUndo->GetCount() )
169 {
170 commandToUndo->CopyList( aItemsList );
171
172 for( const std::unique_ptr<SCH_ITEM>& item : GetRepeatItems() )
173 {
174 EDA_ITEM* repeatItemClone = item->Clone();
175 repeatItemClone->SetFlags( UR_TRANSIENT );
176
177 ITEM_PICKER repeatItemPicker( nullptr, repeatItemClone, UNDO_REDO::REPEAT_ITEM );
178 commandToUndo->PushItem( repeatItemPicker );
179 }
180 }
181 else
182 {
183 // Unless we are appending, in which case, get the picker items
184 for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
185 commandToUndo->PushItem( aItemsList.GetItemWrapper( ii) );
186 }
187
188 // Verify list, and creates data if needed
189 for( unsigned ii = 0; ii < commandToUndo->GetCount(); ii++ )
190 {
191 SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( commandToUndo->GetPickedItem( ii ) );
192
193 // Common items implemented in EDA_DRAW_FRAME will not be SCH_ITEMs.
194 if( !sch_item )
195 continue;
196
197 UNDO_REDO command = commandToUndo->GetPickedItemStatus( ii );
198
199 if( command == UNDO_REDO::UNSPECIFIED )
200 {
201 command = aTypeCommand;
202 commandToUndo->SetPickedItemStatus( command, ii );
203 }
204
205 switch( command )
206 {
208
209 /* If needed, create a copy of item, and put in undo list
210 * in the picker, as link
211 * If this link is not null, the copy is already done
212 */
213 if( commandToUndo->GetPickedItemLink( ii ) == nullptr )
214 commandToUndo->SetPickedItemLink( sch_item->Duplicate( IGNORE_PARENT_GROUP, nullptr, true ), ii );
215
216 wxASSERT( commandToUndo->GetPickedItemLink( ii ) );
217 break;
218
223 break;
224
225 default:
226 wxFAIL_MSG( wxString::Format( wxT( "Unknown undo/redo command %d" ), command ) );
227 break;
228 }
229 }
230
231 if( commandToUndo->GetCount() )
232 {
233 /* Save the copy in undo list */
234 PushCommandToUndoList( commandToUndo );
235
236 /* Clear redo list, because after new save there is no redo to do */
238 }
239 else // Should not occur
240 {
241 delete commandToUndo;
242 }
243}
244
245
247{
248 std::vector<SCH_ITEM*> bulkAddedItems;
249 std::vector<SCH_ITEM*> bulkRemovedItems;
250 std::vector<SCH_ITEM*> bulkChangedItems;
251 std::set<SCH_TABLE*> changedTables;
252 bool updateVariantCtrl = false;
253 bool dirtyConnectivity = false;
254 bool rebuildHierarchyNavigator = false;
255 bool refreshHierarchy = false;
256 SCH_CLEANUP_FLAGS connectivityCleanUp = NO_CLEANUP;
257 SCH_SHEET_LIST sheets= m_schematic->Hierarchy();
258 bool clearedRepeatItems = false;
259
260 // Undo in the reverse order of list creation: (this can allow stacked changes like the
261 // same item can be changed and deleted in the same complex command).
262 // After hitting 0, subtracting 1 will roll the value over to its max representation
263 for( unsigned ii = aList->GetCount() - 1; ii < std::numeric_limits<unsigned>::max(); ii-- )
264 {
265 UNDO_REDO status = aList->GetPickedItemStatus( ii );
266 EDA_ITEM* eda_item = aList->GetPickedItem( ii );
267 SCH_SCREEN* screen = dynamic_cast<SCH_SCREEN*>( aList->GetScreenForItem( ii ) );
268 SCH_SHEET_PATH undoSheet = sheets.FindSheetForScreen( screen );
269
270 eda_item->SetFlags( aList->GetPickerFlags( ii ) );
271 eda_item->ClearEditFlags();
272 eda_item->ClearTempFlags();
273
274 // Set connectable object connectivity status.
275 auto propagateConnectivityDamage =
276 [&]( SCH_ITEM* schItem )
277 {
278 if( schItem->IsConnectable() )
279 {
280 schItem->SetConnectivityDirty();
281
282 if( schItem->Type() == SCH_SYMBOL_T )
283 {
284 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( schItem );
285
286 for( SCH_PIN* pin : symbol->GetPins( &undoSheet ) )
287 pin->SetConnectivityDirty();
288 }
289 else if( schItem->Type() == SCH_SHEET_T )
290 {
291 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( schItem );
292
293 for( SCH_SHEET_PIN* pin : sheet->GetPins() )
294 pin->SetConnectivityDirty();
295 }
296
298 dirtyConnectivity = true;
299
300 // Do a local clean up if there are any connectable objects in the commit
301 if( connectivityCleanUp == NO_CLEANUP )
302 connectivityCleanUp = LOCAL_CLEANUP;
303
304 // Do a full rebauild of the connectivity if there is a sheet in the commit
305 if( schItem->Type() == SCH_SHEET_T )
306 connectivityCleanUp = GLOBAL_CLEANUP;
307 }
308 else if( schItem->Type() == SCH_RULE_AREA_T )
309 {
310 dirtyConnectivity = true;
311 }
312 };
313
314 SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( eda_item );
315
316 if( status == UNDO_REDO::NEWITEM )
317 {
318 if( schItem )
319 propagateConnectivityDamage( schItem );
320
321 // If we are removing the current sheet, get out first
322 if( eda_item->Type() == SCH_SHEET_T )
323 {
324 rebuildHierarchyNavigator = true;
325 refreshHierarchy = true;
326
327 if( static_cast<SCH_SHEET*>( eda_item )->GetScreen() == GetScreen() )
329 }
330
331 RemoveFromScreen( eda_item, screen );
333
334 bulkRemovedItems.emplace_back( schItem );
335 }
336 else if( status == UNDO_REDO::DELETED )
337 {
338 if( eda_item->Type() == SCH_SHEET_T )
339 {
340 rebuildHierarchyNavigator = true;
341 refreshHierarchy = true;
342 }
343
344 if( schItem )
345 propagateConnectivityDamage( schItem );
346
347 // deleted items are re-inserted on undo
348 AddToScreen( eda_item, screen );
350
351 bulkAddedItems.emplace_back( schItem );
352 }
353 else if( status == UNDO_REDO::PAGESETTINGS )
354 {
355 if( GetCurrentSheet() != undoSheet )
356 {
357 SetCurrentSheet( undoSheet );
359 }
360
361 // swap current settings with stored settings
362 DS_PROXY_UNDO_ITEM alt_item( this );
363 DS_PROXY_UNDO_ITEM* item = static_cast<DS_PROXY_UNDO_ITEM*>( eda_item );
364 item->Restore( this );
365 *item = std::move( alt_item );
366 }
367 else if( status == UNDO_REDO::REPEAT_ITEM )
368 {
369 if( !clearedRepeatItems )
370 {
372 clearedRepeatItems = true;
373 }
374
375 if( schItem )
376 {
377 propagateConnectivityDamage( schItem );
378 AddCopyForRepeatItem( schItem );
379
380 if( schItem->Type() == SCH_SHEET_T )
381 {
382 rebuildHierarchyNavigator = true;
383 refreshHierarchy = true;
384 }
385 }
386 }
387 else if( schItem )
388 {
389 SCH_ITEM* itemCopy = dynamic_cast<SCH_ITEM*>( aList->GetPickedItemLink( ii ) );
390
391 wxCHECK2( itemCopy, continue );
392
393 if( schItem->HasConnectivityChanges( itemCopy, &GetCurrentSheet() ) )
394 propagateConnectivityDamage( schItem );
395
396 // The root sheet is a pseudo object that owns the root screen object but is not on
397 // the root screen so do not attempt to remove it from the screen it owns.
398 if( schItem != &Schematic().Root() )
399 RemoveFromScreen( schItem, screen );
400
401 switch( status )
402 {
404 if( schItem->Type() == SCH_SHEET_T )
405 {
406 const SCH_SHEET* origSheet = static_cast<const SCH_SHEET*>( schItem );
407 const SCH_SHEET* copySheet = static_cast<const SCH_SHEET*>( itemCopy );
408
409 wxCHECK2( origSheet && copySheet, continue );
410
411 if( origSheet->GetName() != copySheet->GetName()
412 || origSheet->GetFileName() != copySheet->GetFileName()
413 || origSheet->HasPageNumberChanges( *copySheet ) )
414 {
415 rebuildHierarchyNavigator = true;
416 }
417
418 // Sheet name changes do not require rebuilding the hiearchy.
419 if( origSheet->GetFileName() != copySheet->GetFileName()
420 || origSheet->HasPageNumberChanges( *copySheet ) )
421 {
422 refreshHierarchy = true;
423 }
424
425 updateVariantCtrl = true;
426 }
427
428 if( schItem->Type() == SCH_SYMBOL_T )
429 updateVariantCtrl = true;
430
431 schItem->SwapItemData( itemCopy );
432
433 bulkChangedItems.emplace_back( schItem );
434
435 // Special cases for items which have instance data
436 if( schItem->GetParent() && schItem->GetParent()->Type() == SCH_SYMBOL_T
437 && schItem->Type() == SCH_FIELD_T )
438 {
439 SCH_FIELD* field = static_cast<SCH_FIELD*>( schItem );
440 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( schItem->GetParent() );
441
442 if( field->GetId() == FIELD_T::REFERENCE )
443 {
444 // Lazy eval of sheet list; this is expensive even when unsorted
445 if( sheets.empty() )
446 sheets = m_schematic->Hierarchy();
447
448 SCH_SHEET_PATH sheet = sheets.FindSheetForScreen( screen );
449 symbol->SetRef( &sheet, field->GetText() );
450 }
451
452 bulkChangedItems.emplace_back( symbol );
453 }
454
455 break;
456
457 default:
458 wxFAIL_MSG( wxString::Format( wxT( "Unknown undo/redo command %d" ), status ) );
459 break;
460 }
461
462 if( schItem->Type() == SCH_SYMBOL_T )
463 {
464 SCH_SYMBOL* sym = static_cast<SCH_SYMBOL*>( schItem );
465 sym->UpdatePins();
466 }
467
468 if( schItem != &Schematic().Root() )
469 AddToScreen( schItem, screen );
470 }
471 }
472
473 // We have now swapped all the group parent and group member pointers. But it is a
474 // risky proposition to bet on the pointers being invariant, so validate them all.
475 for( int ii = 0; ii < (int) aList->GetCount(); ++ii )
476 {
477 ITEM_PICKER& wrapper = aList->GetItemWrapper( ii );
478
479 if( wrapper.GetStatus() == UNDO_REDO::DELETED )
480 continue;
481
482 SCH_ITEM* parentGroup = Schematic().ResolveItem( wrapper.GetGroupId(), nullptr, true );
483 wrapper.GetItem()->SetParentGroup( dynamic_cast<SCH_GROUP*>( parentGroup ) );
484
485 if( EDA_GROUP* group = dynamic_cast<SCH_GROUP*>( wrapper.GetItem() ) )
486 {
487 // Items list may contain dodgy pointers, so don't use RemoveAll()
488 group->GetItems().clear();
489
490 for( const KIID& member : wrapper.GetGroupMembers() )
491 {
492 if( SCH_ITEM* memberItem = Schematic().ResolveItem( member, nullptr, true ) )
493 group->AddItem( memberItem );
494 }
495 }
496
497 // And prepare for a redo by updating group info based on current image
498 if( EDA_ITEM* item = wrapper.GetLink() )
499 wrapper.SetLink( item );
500 }
501
503
504 // Notify our listeners
505 if( bulkAddedItems.size() > 0 )
506 Schematic().OnItemsAdded( bulkAddedItems );
507
508 if( bulkRemovedItems.size() > 0 )
509 Schematic().OnItemsRemoved( bulkRemovedItems );
510
511 if( bulkChangedItems.size() > 0 )
512 Schematic().OnItemsChanged( bulkChangedItems );
513
514 if( refreshHierarchy )
516
517 if( dirtyConnectivity )
518 {
519 wxLogTrace( wxS( "CONN_PROFILE" ), wxS( "Undo/redo %s clean up connectivity rebuild." ),
520 connectivityCleanUp == LOCAL_CLEANUP ? wxS( "local" ) : wxS( "global" ) );
521
522 SCH_COMMIT localCommit( m_toolManager );
523
524 RecalculateConnections( &localCommit, connectivityCleanUp );
525
526 if( connectivityCleanUp == GLOBAL_CLEANUP )
528
529 // Restore hop over shapes of wires, if any
530 if( m_schematic->Settings().m_HopOverScale > 0.0 )
531 {
532 for( SCH_ITEM* item : GetScreen()->Items() )
533 {
534 if( item->Type() != SCH_LINE_T )
535 continue;
536
537 SCH_LINE* line = static_cast<SCH_LINE*>( item );
538
539 if( line->IsWire() )
540 UpdateHopOveredWires( line );
541 }
542 }
543 }
544
545 // Update the hierarchy navigator when there are sheet changes.
546 if( rebuildHierarchyNavigator )
548
549 if( updateVariantCtrl && m_schematic )
550 {
551 m_schematic->LoadVariants();
552 UpdateVariantSelectionCtrl( m_schematic->GetVariantNamesForUI() );
553 }
554}
555
556
558{
560
561 // Skip empty frames
562 while( undo && !undo->GetCount() )
563 {
564 delete undo;
566 }
567
568 if( undo )
569 {
571 undo->ClearListAndDeleteItems( []( EDA_ITEM* aItem )
572 {
573 delete aItem;
574 } );
575
576 delete undo;
577
578 m_toolManager->GetTool<SCH_SELECTION_TOOL>()->RebuildSelection();
579 }
580
581 GetCanvas()->Refresh();
582}
583
584
586{
587 if( aItemCount == 0 )
588 return;
589
590 UNDO_REDO_CONTAINER& list = ( whichList == UNDO_LIST ) ? m_undoList : m_redoList;
591
592 if( aItemCount < 0 )
593 {
594 list.ClearCommandList();
595 }
596 else
597 {
598 for( int ii = 0; ii < aItemCount; ii++ )
599 {
600 if( list.m_CommandsList.size() == 0 )
601 break;
602
603 PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
604 list.m_CommandsList.erase( list.m_CommandsList.begin() );
605
606 curr_cmd->ClearListAndDeleteItems( []( EDA_ITEM* aItem )
607 {
608 delete aItem;
609 } );
610 delete curr_cmd; // Delete command
611 }
612 }
613}
614
615
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.
UNDO_REDO_CONTAINER m_undoList
UNDO_REDO_LIST
Specify whether we are interacting with the undo or redo stacks.
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 void Refresh(bool aEraseBackground=true, const wxRect *aRect=nullptr) override
A set of EDA_ITEMs (i.e., without duplicates).
Definition eda_group.h:46
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
virtual void ClearEditFlags()
Definition eda_item.h:162
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition eda_item.h:148
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:110
EDA_ITEM * GetParent() const
Definition eda_item.h:112
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition eda_item.cpp:118
EDA_ITEM_FLAGS GetFlags() const
Definition eda_item.h:151
virtual void ClearTempFlags()
Definition eda_item.h:175
void SetLink(EDA_ITEM *aItem)
void SetFlags(EDA_ITEM_FLAGS aFlags)
void ClearHiddenFlags()
Clear the hide flag of all items in the view.
Definition sch_view.cpp:194
Definition kiid.h:49
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.
EDA_ITEM_FLAGS GetPickerFlags(unsigned aIdx) const
Return the value of the picker flag.
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
EDA_ITEM * GetPickedItemLink(unsigned int aIdx) const
wxString GetDescription() const
const ITEM_PICKER & GetItemWrapper(unsigned int aIdx) const
unsigned GetCount() const
void CopyList(const PICKED_ITEMS_LIST &aSource)
Copy all data from aSource to the 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...
BASE_SCREEN * GetScreenForItem(unsigned int aIdx) const
EDA_ITEM * GetPickedItem(unsigned int aIdx) const
void OnItemsAdded(std::vector< SCH_ITEM * > &aNewItems)
Must be used if Add() is used using a BULK_x ADD_MODE to generate a change event for listeners.
void OnItemsRemoved(std::vector< SCH_ITEM * > &aRemovedItems)
Must be used if Remove() is used using a BULK_x REMOVE_MODE to generate a change event for listeners.
SCH_ITEM * ResolveItem(const KIID &aID, SCH_SHEET_PATH *aPathOut=nullptr, bool aAllowNullptrReturn=false) const
Definition schematic.h:126
void RefreshHierarchy()
void OnItemsChanged(std::vector< SCH_ITEM * > &aItems)
Notify the schematic and its listeners that an item on the schematic has been modified in some way.
static TOOL_ACTION leaveSheet
void RemoveFromScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen) override
Remove an item from the screen (and view) aScreen is the screen the item is located on,...
SCH_DRAW_PANEL * GetCanvas() const override
Return a pointer to GAL-based canvas of given EDA draw frame.
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr) override
Add an item to the screen (and view) aScreen is the screen the item is located on,...
KIGFX::SCH_VIEW * GetView() const override
Return a pointer to the #VIEW instance used in the panel.
void RollbackSchematicFromUndo()
Perform an undo of the last edit without logging a corresponding redo.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend)
Create a copy of the current schematic item, and put it in the undo list.
void UpdateVariantSelectionCtrl(const wxArrayString &aVariantNames)
Update the variant name control on the main toolbar.
void ClearUndoORRedoList(UNDO_REDO_LIST whichList, int aItemCount=-1) override
Free the undo or redo list from aList element.
SCHEMATIC * m_schematic
The currently loaded schematic.
SCH_SHEET_PATH & GetCurrentSheet() const
void RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, PROGRESS_REPORTER *aProgressReporter=nullptr)
Generate the connection data for the entire schematic hierarchy.
SCHEMATIC & Schematic() const
const std::vector< std::unique_ptr< SCH_ITEM > > & GetRepeatItems() const
Return the items which are to be repeated with the insert key.
void UpdateHierarchyNavigator(bool aRefreshNetNavigator=true, bool aClear=false)
Update the hierarchy navigation tree and history.
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void ClearRepeatItemsList()
Clear the list of items which are to be repeated with the insert key.
EDA_ITEM * ResolveItem(const KIID &aId, bool aAllowNullptrReturn=false) const override
Fetch an item by KIID.
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
void DisplayCurrentSheet()
Draw the current sheet on the display.
void PutDataInPreviousState(PICKED_ITEMS_LIST *aList)
Restore an undo or redo command to put data pointed by aList in the previous state.
void AddCopyForRepeatItem(const SCH_ITEM *aItem)
void UpdateHopOveredWires(SCH_ITEM *aItem)
virtual const wxString & GetText() const override
Return the string associated with the text object.
Definition sch_field.h:118
FIELD_T GetId() const
Definition sch_field.h:122
A set of SCH_ITEMs (i.e., without duplicates).
Definition sch_group.h:52
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:167
SCH_ITEM * Duplicate(bool addToParentGroup, SCH_COMMIT *aCommit=nullptr, bool doClone=false) const
Routine to create a new copy of given item.
Definition sch_item.cpp:140
virtual bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const
Check if aItem has connectivity changes against this object.
Definition sch_item.h:606
void SwapItemData(SCH_ITEM *aImage)
Swap data between aItem and aImage.
Definition sch_item.cpp:606
Segment description base class to describe items which have 2 end points (track, wire,...
Definition sch_line.h:42
bool IsWire() const
Return true if the line is a wire.
Definition sch_line.cpp:991
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
SCH_SHEET_PATH FindSheetForScreen(const SCH_SCREEN *aScreen)
Return the first SCH_SHEET_PATH object (not necessarily the only one) using a particular screen.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:48
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition sch_sheet.h:376
wxString GetName() const
Definition sch_sheet.h:142
bool HasPageNumberChanges(const SCH_SHEET &aOther) const
Check if the instance data of this sheet has any changes compared to aOther.
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition sch_sheet.h:233
Schematic symbol object.
Definition sch_symbol.h:76
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
TOOL_MANAGER * m_toolManager
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
bool PostAction(const std::string &aActionName, T aParam)
Run the specified action after the current action (coroutine) ends.
A holder to handle a list of undo (or redo) commands.
#define IGNORE_PARENT_GROUP
Definition eda_item.h:55
#define UR_TRANSIENT
indicates the item is owned by the undo/redo stack
Class to handle a set of SCH_ITEMs.
SCH_CLEANUP_FLAGS
Definition schematic.h:74
@ LOCAL_CLEANUP
Definition schematic.h:76
@ NO_CLEANUP
Definition schematic.h:75
@ GLOBAL_CLEANUP
Definition schematic.h:77
@ REFERENCE
Field Reference of part, i.e. "IC21".
KIBIS_PIN * pin
@ SCH_LINE_T
Definition typeinfo.h:167
@ SCH_SYMBOL_T
Definition typeinfo.h:176
@ SCH_FIELD_T
Definition typeinfo.h:154
@ SCH_SHEET_T
Definition typeinfo.h:179
@ SCH_RULE_AREA_T
Definition typeinfo.h:174
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...