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 (C) 2004-2024 KiCad Developers, see change_log.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 <ee_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_junction.h>
32#include <sch_line.h>
33#include <sch_bitmap.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
45 * Each PICKED_ITEMS_LIST handle a std::vector of pickers (class ITEM_PICKER),
46 * that store the list of schematic items that are concerned by the command to
47 * undo or redo and is created for each command to undo (handle also a command
48 * to redo). each picker has a pointer pointing to an item to undo or redo (in
49 * fact: deleted, added or modified), and has a pointer to a copy of this item,
50 * when this item has been modified (the old values of parameters are
51 * therefore saved)
52 *
53 * there are 3 cases:
54 * - delete item(s) command
55 * - change item(s) command
56 * - add item(s) command
57 * and 2 cases for block:
58 * - move list of items
59 * - mirror (Y) list of items
60 *
61 * Undo command
62 * - delete item(s) command:
63 * => deleted items are moved in undo list
64 *
65 * - change item(s) command
66 * => A copy of item(s) is made (a DrawPickedStruct list of wrappers)
67 * the .m_Link member of each wrapper points the modified item.
68 * the .m_Item member of each wrapper points the old copy of this item.
69 *
70 * - add item(s) command
71 * =>A list of item(s) is made. The .m_Item member of each wrapper points
72 * the new item.
73 *
74 * Redo command
75 * - delete item(s) old command:
76 * => deleted items are moved into m_tree
77 *
78 * - change item(s) command
79 * => the copy of item(s) is moved in Undo list
80 *
81 * - add item(s) command
82 * => The list of item(s) is used to create a deleted list in undo
83 * list(same as a delete command)
84 *
85 * Some block operations that change items can be undone without memorized
86 * items, just the coordinates of the transform: move list of items (undo/
87 * redo is made by moving with the opposite move vector) mirror (Y) and flip
88 * list of items (undo/redo is made by mirror or flip items) so they are
89 * handled specifically.
90 *
91 * A problem is the hierarchical sheet handling.
92 * the data associated (sub-hierarchy, undo/redo list) is deleted only
93 * when the sheet is really deleted (i.e. when deleted from undo or redo list)
94 * This is handled by its destructor.
95 */
96
97
98/* Used if undo / redo command:
99 * swap data between Item and its copy, pointed by its picked item link member
100 * swapped data is data modified by editing, so not all values are swapped
101 */
102
104 UNDO_REDO aCommandType, bool aAppend,
105 bool aDirtyConnectivity )
106{
107 PICKED_ITEMS_LIST* commandToUndo = nullptr;
108
109 wxCHECK( aItem, /* void */ );
110
111 if( aDirtyConnectivity )
112 {
113 if( !aItem->IsConnectivityDirty() && aItem->Connection()
114 && ( aItem->Connection()->Name() == m_highlightedConn
115 || aItem->Connection()->HasDriverChanged() ) )
116 {
118 }
119
120 aItem->SetConnectivityDirty();
121 }
122
124
125 // If the last stack was empty, use that one instead of creating a new stack
126 if( lastUndo )
127 {
128 if( aAppend || !lastUndo->GetCount() )
129 commandToUndo = lastUndo;
130 else
131 PushCommandToUndoList( lastUndo );
132 }
133
134 if( !commandToUndo )
135 {
136 commandToUndo = new PICKED_ITEMS_LIST();
137 }
138
139 ITEM_PICKER itemWrapper( aScreen, aItem, aCommandType );
140 itemWrapper.SetFlags( aItem->GetFlags() );
141
142 switch( aCommandType )
143 {
144 case UNDO_REDO::CHANGED: /* Create a copy of item */
145 itemWrapper.SetLink( aItem->Duplicate( true ) );
146 commandToUndo->PushItem( itemWrapper );
147 break;
148
149 case UNDO_REDO::NEWITEM:
150 case UNDO_REDO::DELETED:
151 commandToUndo->PushItem( itemWrapper );
152 break;
153
154 default:
155 wxFAIL_MSG( wxString::Format( wxT( "SaveCopyInUndoList() error (unknown code %X)" ),
156 aCommandType ) );
157 break;
158 }
159
160 if( commandToUndo->GetCount() )
161 {
162 /* Save the copy in undo list */
163 PushCommandToUndoList( commandToUndo );
164
165 /* Clear redo list, because after new save there is no redo to do */
167 }
168 else
169 {
170 delete commandToUndo;
171 }
172}
173
174
176 UNDO_REDO aTypeCommand, bool aAppend,
177 bool aDirtyConnectivity )
178{
179 PICKED_ITEMS_LIST* commandToUndo = nullptr;
180
181 if( !aItemsList.GetCount() )
182 return;
183
185
186 // If the last stack was empty, use that one instead of creating a new stack
187 if( lastUndo )
188 {
189 if( aAppend || !lastUndo->GetCount() )
190 commandToUndo = lastUndo;
191 else
192 PushCommandToUndoList( lastUndo );
193 }
194
195 if( !commandToUndo )
196 {
197 commandToUndo = new PICKED_ITEMS_LIST();
198 commandToUndo->SetDescription( aItemsList.GetDescription() );
199 }
200
201 // Copy picker list:
202 if( !commandToUndo->GetCount() )
203 {
204 commandToUndo->CopyList( aItemsList );
205
206 for( const std::unique_ptr<SCH_ITEM>& item : GetRepeatItems() )
207 {
208 EDA_ITEM* repeatItemClone = item->Clone();
209 repeatItemClone->SetFlags( UR_TRANSIENT );
210
211 ITEM_PICKER repeatItemPicker( nullptr, repeatItemClone, UNDO_REDO::REPEAT_ITEM );
212 commandToUndo->PushItem( repeatItemPicker );
213 }
214 }
215 else
216 {
217 // Unless we are appending, in which case, get the picker items
218 for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
219 commandToUndo->PushItem( aItemsList.GetItemWrapper( ii) );
220 }
221
222 // Verify list, and creates data if needed
223 for( unsigned ii = 0; ii < commandToUndo->GetCount(); ii++ )
224 {
225 SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( commandToUndo->GetPickedItem( ii ) );
226
227 // Common items implemented in EDA_DRAW_FRAME will not be SCH_ITEMs.
228 if( !sch_item )
229 continue;
230
231 UNDO_REDO command = commandToUndo->GetPickedItemStatus( ii );
232
233 if( command == UNDO_REDO::UNSPECIFIED )
234 {
235 command = aTypeCommand;
236 commandToUndo->SetPickedItemStatus( command, ii );
237 }
238
239 switch( command )
240 {
241 case UNDO_REDO::CHANGED:
242
243 /* If needed, create a copy of item, and put in undo list
244 * in the picker, as link
245 * If this link is not null, the copy is already done
246 */
247 if( commandToUndo->GetPickedItemLink( ii ) == nullptr )
248 commandToUndo->SetPickedItemLink( sch_item->Duplicate( true ), ii );
249
250 wxASSERT( commandToUndo->GetPickedItemLink( ii ) );
251 break;
252
253 case UNDO_REDO::NEWITEM:
254 case UNDO_REDO::DELETED:
255 case UNDO_REDO::PAGESETTINGS:
256 case UNDO_REDO::REPEAT_ITEM:
257 break;
258
259 default:
260 wxFAIL_MSG( wxString::Format( wxT( "Unknown undo/redo command %d" ), 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 new save there is no redo to do */
272 }
273 else // Should not occur
274 {
275 delete commandToUndo;
276 }
277}
278
279
281{
282 std::vector<SCH_ITEM*> bulkAddedItems;
283 std::vector<SCH_ITEM*> bulkRemovedItems;
284 std::vector<SCH_ITEM*> bulkChangedItems;
285 std::set<SCH_TABLE*> changedTables;
286 bool dirtyConnectivity = false;
287 bool rebuildHierarchyNavigator = false;
288 bool refreshHierarchy = false;
289 SCH_CLEANUP_FLAGS connectivityCleanUp = NO_CLEANUP;
290 SCH_SHEET_LIST sheets;
291 bool clearedRepeatItems = false;
292
293 // Undo in the reverse order of list creation: (this can allow stacked changes like the
294 // same item can be changed and deleted in the same complex command).
295 // After hitting 0, subtracting 1 will roll the value over to its max representation
296 for( unsigned ii = aList->GetCount() - 1; ii < std::numeric_limits<unsigned>::max(); ii-- )
297 {
298 UNDO_REDO status = aList->GetPickedItemStatus( ii );
299 EDA_ITEM* eda_item = aList->GetPickedItem( ii );
300 SCH_SCREEN* screen = dynamic_cast<SCH_SCREEN*>( aList->GetScreenForItem( ii ) );
301
302 eda_item->SetFlags( aList->GetPickerFlags( ii ) );
303 eda_item->ClearEditFlags();
304 eda_item->ClearTempFlags();
305
306 SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( eda_item );
307
308 // Set connectable object connectivity status.
309 auto updateConnectivityFlag =
310 [&]()
311 {
312 if( schItem->IsConnectable() )
313 {
314 schItem->SetConnectivityDirty();
315
316 if( schItem->Type() == SCH_SYMBOL_T )
317 {
318 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( schItem );
319
320 wxCHECK( symbol, /* void */ );
321
322 for( SCH_PIN* pin : symbol->GetPins() )
323 pin->SetConnectivityDirty();
324 }
325 else if( schItem->Type() == SCH_SHEET_T )
326 {
327 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( schItem );
328
329 wxCHECK( sheet, /* void */ );
330
331 for( SCH_SHEET_PIN* pin : sheet->GetPins() )
332 pin->SetConnectivityDirty();
333 }
334
336 dirtyConnectivity = true;
337
338 // Do a local clean up if there are any connectable objects in the commit
339 if( connectivityCleanUp == NO_CLEANUP )
340 connectivityCleanUp = LOCAL_CLEANUP;
341
342 // Do a full rebauild of the connectivity if there is a sheet in the commit
343 if( schItem->Type() == SCH_SHEET_T )
344 connectivityCleanUp = GLOBAL_CLEANUP;
345 }
346 else if( schItem->Type() == SCH_RULE_AREA_T )
347 {
348 dirtyConnectivity = true;
349 }
350 };
351
352 if( status == UNDO_REDO::NEWITEM )
353 {
354 if( schItem )
355 updateConnectivityFlag();
356
357 // If we are removing the current sheet, get out first
358 if( eda_item->Type() == SCH_SHEET_T )
359 {
360 rebuildHierarchyNavigator = true;
361 refreshHierarchy = true;
362
363 if( static_cast<SCH_SHEET*>( eda_item )->GetScreen() == GetScreen() )
365 }
366
367 RemoveFromScreen( eda_item, screen );
368 aList->SetPickedItemStatus( UNDO_REDO::DELETED, ii );
369
370 bulkRemovedItems.emplace_back( schItem );
371 }
372 else if( status == UNDO_REDO::DELETED )
373 {
374 if( eda_item->Type() == SCH_SHEET_T )
375 {
376 rebuildHierarchyNavigator = true;
377 refreshHierarchy = true;
378 }
379
380 if( schItem )
381 updateConnectivityFlag();
382
383 // deleted items are re-inserted on undo
384 AddToScreen( eda_item, screen );
385 aList->SetPickedItemStatus( UNDO_REDO::NEWITEM, ii );
386
387 bulkAddedItems.emplace_back( schItem );
388 }
389 else if( status == UNDO_REDO::PAGESETTINGS )
390 {
391 // Lazy eval of sheet list; this is expensive even when unsorted
392 if( sheets.empty() )
393 sheets = m_schematic->Hierarchy();
394
395 SCH_SHEET_PATH undoSheet = sheets.FindSheetForScreen( screen );
396
397 if( GetCurrentSheet() != undoSheet )
398 {
399 SetCurrentSheet( undoSheet );
401 }
402
403 // swap current settings with stored settings
404 DS_PROXY_UNDO_ITEM alt_item( this );
405 DS_PROXY_UNDO_ITEM* item = static_cast<DS_PROXY_UNDO_ITEM*>( eda_item );
406 item->Restore( this );
407 *item = std::move( alt_item );
408 }
409 else if( status == UNDO_REDO::REPEAT_ITEM )
410 {
411 if( !clearedRepeatItems )
412 {
414 clearedRepeatItems = true;
415 }
416
417 if( schItem )
418 {
419 updateConnectivityFlag();
420 AddCopyForRepeatItem( schItem );
421
422 if( schItem->Type() == SCH_SHEET_T )
423 {
424 rebuildHierarchyNavigator = true;
425 refreshHierarchy = true;
426 }
427 }
428 }
429 else if( schItem )
430 {
431 SCH_ITEM* itemCopy = dynamic_cast<SCH_ITEM*>( aList->GetPickedItemLink( ii ) );
432
433 wxCHECK2( itemCopy, continue );
434
435 if( schItem->HasConnectivityChanges( itemCopy, &GetCurrentSheet() ) )
436 updateConnectivityFlag();
437
438 // The root sheet is a pseudo object that owns the root screen object but is not on
439 // the root screen so do not attempt to remove it from the screen it owns.
440 if( schItem != &Schematic().Root() )
441 RemoveFromScreen( schItem, screen );
442
443 switch( status )
444 {
445 case UNDO_REDO::CHANGED:
446 if( schItem->Type() == SCH_SHEET_T )
447 {
448 const SCH_SHEET* origSheet = static_cast<const SCH_SHEET*>( schItem );
449 const SCH_SHEET* copySheet = static_cast<const SCH_SHEET*>( itemCopy );
450
451 wxCHECK2( origSheet && copySheet, continue );
452
453 if( ( origSheet->GetName() != copySheet->GetName() )
454 || ( origSheet->GetFileName() != copySheet->GetFileName() )
455 || origSheet->HasPageNumberChanges( *copySheet ) )
456 {
457 rebuildHierarchyNavigator = true;
458 }
459
460 // Sheet name changes do not require rebuilding the hiearchy.
461 if( ( origSheet->GetFileName() != copySheet->GetFileName() )
462 || origSheet->HasPageNumberChanges( *copySheet ) )
463 {
464 refreshHierarchy = true;
465 }
466 }
467
468 schItem->SwapData( itemCopy );
469 bulkChangedItems.emplace_back( schItem );
470
471 // Special cases for items which have instance data
472 if( schItem->GetParent() && schItem->GetParent()->Type() == SCH_SYMBOL_T
473 && schItem->Type() == SCH_FIELD_T )
474 {
475 SCH_FIELD* field = static_cast<SCH_FIELD*>( schItem );
476 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( schItem->GetParent() );
477
478 if( field->GetId() == REFERENCE_FIELD )
479 {
480 // Lazy eval of sheet list; this is expensive even when unsorted
481 if( sheets.empty() )
482 sheets = m_schematic->Hierarchy();
483
484 SCH_SHEET_PATH sheet = sheets.FindSheetForScreen( screen );
485 symbol->SetRef( &sheet, field->GetText() );
486 }
487
488 bulkChangedItems.emplace_back( symbol );
489 }
490
491 break;
492
493 default:
494 wxFAIL_MSG( wxString::Format( wxT( "Unknown undo/redo command %d" ),
495 aList->GetPickedItemStatus( ii ) ) );
496 break;
497 }
498
499 if( schItem->Type() == SCH_SYMBOL_T )
500 {
501 SCH_SYMBOL* sym = static_cast<SCH_SYMBOL*>( schItem );
502 sym->UpdatePins();
503 }
504
505 if( schItem != &Schematic().Root() )
506 AddToScreen( schItem, screen );
507 }
508 }
509
511
512 // Notify our listeners
513 if( bulkAddedItems.size() > 0 )
514 Schematic().OnItemsAdded( bulkAddedItems );
515
516 if( bulkRemovedItems.size() > 0 )
517 Schematic().OnItemsRemoved( bulkRemovedItems );
518
519 if( bulkChangedItems.size() > 0 )
520 Schematic().OnItemsChanged( bulkChangedItems );
521
522 if( refreshHierarchy )
524
525 if( dirtyConnectivity )
526 {
527 wxLogTrace( wxS( "CONN_PROFILE" ),
528 wxS( "Undo/redo %s clean up connectivity rebuild." ),
529 ( connectivityCleanUp == LOCAL_CLEANUP ) ? wxS( "local" ) : wxS( "global" ) );
530
531 SCH_COMMIT localCommit( m_toolManager );
532
533 RecalculateConnections( &localCommit, connectivityCleanUp );
534
535 if( connectivityCleanUp == GLOBAL_CLEANUP )
537 }
538
539 // Update the hierarchy navigator when there are sheet changes.
540 if( rebuildHierarchyNavigator )
542}
543
544
546{
548
549 // Skip empty frames
550 while( undo && !undo->GetCount() )
551 {
552 delete undo;
554 }
555
556 if( undo )
557 {
559 undo->ClearListAndDeleteItems( []( EDA_ITEM* aItem )
560 {
561 delete aItem;
562 } );
563
564 delete undo;
565
566 m_toolManager->GetTool<EE_SELECTION_TOOL>()->RebuildSelection();
567 }
568
569 GetCanvas()->Refresh();
570}
571
572
574{
575 if( aItemCount == 0 )
576 return;
577
578 UNDO_REDO_CONTAINER& list = ( whichList == UNDO_LIST ) ? m_undoList : m_redoList;
579
580 if( aItemCount < 0 )
581 {
582 list.ClearCommandList();
583 }
584 else
585 {
586 for( int ii = 0; ii < aItemCount; ii++ )
587 {
588 if( list.m_CommandsList.size() == 0 )
589 break;
590
591 PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
592 list.m_CommandsList.erase( list.m_CommandsList.begin() );
593
594 curr_cmd->ClearListAndDeleteItems( []( EDA_ITEM* aItem )
595 {
596 delete aItem;
597 } );
598 delete curr_cmd; // Delete command
599 }
600 }
601}
602
603
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
Specifies 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 base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
virtual void ClearEditFlags()
Definition: eda_item.h:141
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition: eda_item.h:127
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:101
EDA_ITEM * GetParent() const
Definition: eda_item.h:103
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition: eda_item.cpp:85
EDA_ITEM_FLAGS GetFlags() const
Definition: eda_item.h:130
virtual void ClearTempFlags()
Definition: eda_item.h:153
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:94
static TOOL_ACTION leaveSheet
Definition: ee_actions.h:233
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:179
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
ITEM_PICKER GetItemWrapper(unsigned int aIdx) const
EDA_ITEM * GetPickedItemLink(unsigned int aIdx) const
wxString GetDescription() 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.
Definition: schematic.cpp:768
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.
Definition: schematic.cpp:774
SCH_SHEET_LIST Hierarchy() const override
Return the full schematic flattened hierarchical sheet list.
Definition: schematic.cpp:214
SCH_SHEET & Root() const
Definition: schematic.h:121
void RefreshHierarchy()
Definition: schematic.cpp:222
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.
Definition: schematic.cpp:780
void AddToScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen=nullptr)
Add an item to 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 RemoveFromScreen(EDA_ITEM *aItem, SCH_SCREEN *aScreen)
Remove an item from the screen (and view) aScreen is the screen the item is located on,...
bool HasDriverChanged() const
wxString Name(bool aIgnoreSheet=false) const
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.
bool m_highlightedConnChanged
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
void UpdateHierarchyNavigator(bool aRefreshNetNavigator=true)
Update the hierarchy navigation tree and history.
void SaveCopyInUndoList(SCH_SCREEN *aScreen, SCH_ITEM *aItemToCopy, UNDO_REDO aTypeCommand, bool aAppend, bool aDirtyConnectivity=true)
Create a copy of the current schematic item, and put it in the undo list.
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
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 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.
void RecalculateConnections(SCH_COMMIT *aCommit, SCH_CLEANUP_FLAGS aCleanupFlags)
Generate the connection data for the entire schematic hierarchy.
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)
wxString m_highlightedConn
The highlighted net or bus or empty string.
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
int GetId() const
Definition: sch_field.h:133
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:166
virtual bool IsConnectable() const
Definition: sch_item.h:449
virtual void SwapData(SCH_ITEM *aItem)
Swap the internal data structures aItem with the schematic item.
Definition: sch_item.cpp:348
void SetConnectivityDirty(bool aDirty=true)
Definition: sch_item.h:512
bool IsConnectivityDirty() const
Definition: sch_item.h:510
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:529
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
Definition: sch_item.cpp:221
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
Definition: sch_item.cpp:131
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.
Definition: sch_sheet_pin.h:66
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition: sch_sheet.h:306
wxString GetName() const
Definition: sch_sheet.h:107
bool HasPageNumberChanges(const SCH_SHEET &aOther) const
Check if the instance data of this sheet has any changes compared to aOther.
Definition: sch_sheet.cpp:1545
std::vector< SCH_SHEET_PIN * > & GetPins()
Definition: sch_sheet.h:181
Schematic symbol object.
Definition: sch_symbol.h:104
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
Definition: sch_symbol.cpp:315
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
Definition: sch_symbol.cpp:779
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve a list of the SCH_PINs for the given sheet path.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:167
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:55
bool PostAction(const std::string &aActionName, T aParam)
Run the specified action after the current action (coroutine) ends.
Definition: tool_manager.h:235
A holder to handle a list of undo (or redo) commands.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
#define UR_TRANSIENT
indicates the item is owned by the undo/redo stack
SCH_CLEANUP_FLAGS
@ LOCAL_CLEANUP
@ NO_CLEANUP
@ GLOBAL_CLEANUP
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
@ SCH_SYMBOL_T
Definition: typeinfo.h:172
@ SCH_FIELD_T
Definition: typeinfo.h:150
@ SCH_SHEET_T
Definition: typeinfo.h:174
@ SCH_RULE_AREA_T
Definition: typeinfo.h:170
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...