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, see <https://www.gnu.org/licenses/>.
19 */
20
21#include <sch_actions.h>
22#include <sch_edit_frame.h>
23#include <tool/tool_manager.h>
24#include <schematic.h>
25#include <sch_bus_entry.h>
26#include <sch_commit.h>
27#include <sch_group.h>
28#include <sch_junction.h>
29#include <sch_line.h>
30#include <sch_sheet_pin.h>
31#include <sch_table.h>
34#include <tool/actions.h>
35#include <wx/log.h>
36
37
38/* Functions to undo and redo edit commands.
39 *
40 * m_UndoList and m_RedoList handle a std::vector of PICKED_ITEMS_LIST. Each PICKED_ITEMS_LIST handles
41 * a std::vector of ITEM_PICKER that store the list of schematic items that are concerned by the command
42 * to undo or redo and is created for each command to undo/redo). Each picker has a pointer pointing to
43 * an item to undo or redo (in fact: deleted, added or modified), and has a pointer to a copy of this
44 * item, when this item has been modified (the old values of parameters are therefore saved).
45 *
46 * there are 3 cases:
47 * - delete item(s) command
48 * - change item(s) command
49 * - add item(s) command
50 *
51 * Undo command
52 * - delete item(s) command:
53 * => deleted items are moved in undo list
54 *
55 * - change item(s) command
56 * => A copy of item(s) is made (a DrawPickedStruct list of wrappers)
57 * the .m_Link member of each wrapper points the modified item.
58 * the .m_Item member of each wrapper points the old copy of this item.
59 *
60 * - add item(s) command
61 * =>A list of item(s) is made. The .m_Item member of each wrapper points
62 * the new item.
63 *
64 * Redo command
65 * - delete item(s) old command:
66 * => deleted items are moved into m_tree
67 *
68 * - change item(s) command
69 * => the copy of item(s) is moved in Undo list
70 *
71 * - add item(s) command
72 * => The list of item(s) is used to create a deleted list in undo
73 * list(same as a delete command)
74 *
75 * A problem is the hierarchical sheet handling. The data associated (sub-hierarchy, undo/redo list) is
76 * deleted only when the sheet is really deleted (i.e. when deleted from undo or redo list). This is
77 * handled by its destructor.
78 */
79
81 bool aAppend )
82{
83 PICKED_ITEMS_LIST* commandToUndo = nullptr;
84
85 wxCHECK( aItem, /* void */ );
86
88
89 // If the last stack was empty, use that one instead of creating a new stack
90 if( lastUndo )
91 {
92 if( aAppend || !lastUndo->GetCount() )
93 commandToUndo = lastUndo;
94 else
95 PushCommandToUndoList( lastUndo );
96 }
97
98 if( !commandToUndo )
99 {
100 commandToUndo = new PICKED_ITEMS_LIST();
101 }
102
103 ITEM_PICKER itemWrapper( aScreen, aItem, aCommandType );
104 itemWrapper.SetFlags( aItem->GetFlags() );
105
106 switch( aCommandType )
107 {
108 case UNDO_REDO::CHANGED: /* Create a copy of item */
109 itemWrapper.SetLink( aItem->Duplicate( IGNORE_PARENT_GROUP, nullptr, true ) );
110 commandToUndo->PushItem( itemWrapper );
111 break;
112
115 commandToUndo->PushItem( itemWrapper );
116 break;
117
118 default:
119 wxFAIL_MSG( wxString::Format( wxT( "SaveCopyInUndoList() error (unknown code %X)" ), aCommandType ) );
120 break;
121 }
122
123 if( commandToUndo->GetCount() )
124 {
125 /* Save the copy in undo list */
126 PushCommandToUndoList( commandToUndo );
127
128 /* Clear redo list, because after new save there is no redo to do */
130 }
131 else
132 {
133 delete commandToUndo;
134 }
135}
136
137
139 bool aAppend )
140{
141 PICKED_ITEMS_LIST* commandToUndo = nullptr;
142
143 if( !aItemsList.GetCount() )
144 return;
145
147
148 // If the last stack was empty, use that one instead of creating a new stack
149 if( lastUndo )
150 {
151 if( aAppend || !lastUndo->GetCount() )
152 commandToUndo = lastUndo;
153 else
154 PushCommandToUndoList( lastUndo );
155 }
156
157 if( !commandToUndo )
158 {
159 commandToUndo = new PICKED_ITEMS_LIST();
160 commandToUndo->SetDescription( aItemsList.GetDescription() );
161 }
162
163 // Copy picker list:
164 if( !commandToUndo->GetCount() )
165 {
166 commandToUndo->CopyList( aItemsList );
167
168 for( const std::unique_ptr<SCH_ITEM>& item : GetRepeatItems() )
169 {
170 EDA_ITEM* repeatItemClone = item->Clone();
171 repeatItemClone->SetFlags( UR_TRANSIENT );
172
173 ITEM_PICKER repeatItemPicker( nullptr, repeatItemClone, UNDO_REDO::REPEAT_ITEM );
174 commandToUndo->PushItem( repeatItemPicker );
175 }
176 }
177 else
178 {
179 // Unless we are appending, in which case, get the picker items
180 for( unsigned ii = 0; ii < aItemsList.GetCount(); ii++ )
181 commandToUndo->PushItem( aItemsList.GetItemWrapper( ii) );
182 }
183
184 // Verify list, and creates data if needed
185 for( unsigned ii = 0; ii < commandToUndo->GetCount(); ii++ )
186 {
187 SCH_ITEM* sch_item = dynamic_cast<SCH_ITEM*>( commandToUndo->GetPickedItem( ii ) );
188
189 // Common items implemented in EDA_DRAW_FRAME will not be SCH_ITEMs.
190 if( !sch_item )
191 continue;
192
193 UNDO_REDO command = commandToUndo->GetPickedItemStatus( ii );
194
195 if( command == UNDO_REDO::UNSPECIFIED )
196 {
197 command = aTypeCommand;
198 commandToUndo->SetPickedItemStatus( command, ii );
199 }
200
201 switch( command )
202 {
204
205 /* If needed, create a copy of item, and put in undo list
206 * in the picker, as link
207 * If this link is not null, the copy is already done
208 */
209 if( commandToUndo->GetPickedItemLink( ii ) == nullptr )
210 commandToUndo->SetPickedItemLink( sch_item->Duplicate( IGNORE_PARENT_GROUP, nullptr, true ), ii );
211
212 wxASSERT( commandToUndo->GetPickedItemLink( ii ) );
213 break;
214
219 break;
220
221 default:
222 wxFAIL_MSG( wxString::Format( wxT( "Unknown undo/redo command %d" ), command ) );
223 break;
224 }
225 }
226
227 if( commandToUndo->GetCount() )
228 {
229 /* Save the copy in undo list */
230 PushCommandToUndoList( commandToUndo );
231
232 /* Clear redo list, because after new save there is no redo to do */
234 }
235 else // Should not occur
236 {
237 delete commandToUndo;
238 }
239}
240
241
243{
244 std::vector<SCH_ITEM*> bulkAddedItems;
245 std::vector<SCH_ITEM*> bulkRemovedItems;
246 std::vector<SCH_ITEM*> bulkChangedItems;
247 std::set<SCH_TABLE*> changedTables;
248 bool updateVariantCtrl = false;
249 bool dirtyConnectivity = false;
250 bool rebuildHierarchyNavigator = false;
251 bool refreshHierarchy = false;
252 SCH_CLEANUP_FLAGS connectivityCleanUp = NO_CLEANUP;
253 SCH_SHEET_LIST sheets= m_schematic->Hierarchy();
254 bool clearedRepeatItems = false;
255
256 // Undo in the reverse order of list creation: (this can allow stacked changes like the
257 // same item can be changed and deleted in the same complex command).
258 // After hitting 0, subtracting 1 will roll the value over to its max representation
259 for( unsigned ii = aList->GetCount() - 1; ii < std::numeric_limits<unsigned>::max(); ii-- )
260 {
261 UNDO_REDO status = aList->GetPickedItemStatus( ii );
262 EDA_ITEM* eda_item = aList->GetPickedItem( ii );
263 SCH_SCREEN* screen = dynamic_cast<SCH_SCREEN*>( aList->GetScreenForItem( ii ) );
264 SCH_SHEET_PATH undoSheet = sheets.FindSheetForScreen( screen );
265
266 eda_item->SetFlags( aList->GetPickerFlags( ii ) );
267 eda_item->ClearEditFlags();
268 eda_item->ClearTempFlags();
269
270 // Set connectable object connectivity status.
271 auto propagateConnectivityDamage =
272 [&]( SCH_ITEM* schItem )
273 {
274 if( schItem->IsConnectable() )
275 {
276 schItem->SetConnectivityDirty();
277
278 if( schItem->Type() == SCH_SYMBOL_T )
279 {
280 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( schItem );
281
282 for( SCH_PIN* pin : symbol->GetPins( &undoSheet ) )
283 pin->SetConnectivityDirty();
284 }
285 else if( schItem->Type() == SCH_SHEET_T )
286 {
287 SCH_SHEET* sheet = static_cast<SCH_SHEET*>( schItem );
288
289 for( SCH_SHEET_PIN* pin : sheet->GetPins() )
290 pin->SetConnectivityDirty();
291 }
292
294 dirtyConnectivity = true;
295
296 // Do a local clean up if there are any connectable objects in the commit
297 if( connectivityCleanUp == NO_CLEANUP )
298 connectivityCleanUp = LOCAL_CLEANUP;
299
300 // Do a full rebauild of the connectivity if there is a sheet in the commit
301 if( schItem->Type() == SCH_SHEET_T )
302 connectivityCleanUp = GLOBAL_CLEANUP;
303 }
304 else if( schItem->Type() == SCH_RULE_AREA_T )
305 {
306 dirtyConnectivity = true;
307 }
308 };
309
310 SCH_ITEM* schItem = dynamic_cast<SCH_ITEM*>( eda_item );
311
312 if( status == UNDO_REDO::NEWITEM )
313 {
314 if( schItem )
315 propagateConnectivityDamage( schItem );
316
317 // If we are removing the current sheet, get out first
318 if( eda_item->Type() == SCH_SHEET_T )
319 {
320 rebuildHierarchyNavigator = true;
321 refreshHierarchy = true;
322
323 if( static_cast<SCH_SHEET*>( eda_item )->GetScreen() == GetScreen() )
325 }
326
327 RemoveFromScreen( eda_item, screen );
329
330 bulkRemovedItems.emplace_back( schItem );
331 }
332 else if( status == UNDO_REDO::DELETED )
333 {
334 if( eda_item->Type() == SCH_SHEET_T )
335 {
336 rebuildHierarchyNavigator = true;
337 refreshHierarchy = true;
338 }
339
340 if( schItem )
341 propagateConnectivityDamage( schItem );
342
343 // deleted items are re-inserted on undo
344 AddToScreen( eda_item, screen );
346
347 bulkAddedItems.emplace_back( schItem );
348 }
349 else if( status == UNDO_REDO::PAGESETTINGS )
350 {
351 if( GetCurrentSheet() != undoSheet )
352 {
353 SetCurrentSheet( undoSheet );
355 }
356
357 // swap current settings with stored settings
358 DS_PROXY_UNDO_ITEM alt_item( this );
359 DS_PROXY_UNDO_ITEM* item = static_cast<DS_PROXY_UNDO_ITEM*>( eda_item );
360 item->Restore( this );
361 *item = std::move( alt_item );
362 }
363 else if( status == UNDO_REDO::REPEAT_ITEM )
364 {
365 if( !clearedRepeatItems )
366 {
368 clearedRepeatItems = true;
369 }
370
371 if( schItem )
372 {
373 propagateConnectivityDamage( schItem );
374 AddCopyForRepeatItem( schItem );
375
376 if( schItem->Type() == SCH_SHEET_T )
377 {
378 rebuildHierarchyNavigator = true;
379 refreshHierarchy = true;
380 }
381 }
382 }
383 else if( schItem )
384 {
385 SCH_ITEM* itemCopy = dynamic_cast<SCH_ITEM*>( aList->GetPickedItemLink( ii ) );
386
387 wxCHECK2( itemCopy, continue );
388
389 if( schItem->HasConnectivityChanges( itemCopy, &GetCurrentSheet() ) )
390 propagateConnectivityDamage( schItem );
391
392 // The root sheet is a pseudo object that owns the root screen object but is not on
393 // the root screen so do not attempt to remove it from the screen it owns.
394 if( schItem != &Schematic().Root() )
395 RemoveFromScreen( schItem, screen );
396
397 switch( status )
398 {
400 if( schItem->Type() == SCH_SHEET_T )
401 {
402 const SCH_SHEET* origSheet = static_cast<const SCH_SHEET*>( schItem );
403 const SCH_SHEET* copySheet = static_cast<const SCH_SHEET*>( itemCopy );
404
405 wxCHECK2( origSheet && copySheet, continue );
406
407 if( origSheet->GetName() != copySheet->GetName()
408 || origSheet->GetFileName() != copySheet->GetFileName()
409 || origSheet->HasPageNumberChanges( *copySheet ) )
410 {
411 rebuildHierarchyNavigator = true;
412 }
413
414 // Sheet name changes do not require rebuilding the hiearchy.
415 if( origSheet->GetFileName() != copySheet->GetFileName()
416 || origSheet->HasPageNumberChanges( *copySheet ) )
417 {
418 refreshHierarchy = true;
419 }
420
421 updateVariantCtrl = true;
422 }
423
424 if( schItem->Type() == SCH_SYMBOL_T )
425 updateVariantCtrl = true;
426
427 schItem->SwapItemData( itemCopy );
428
429 bulkChangedItems.emplace_back( schItem );
430
431 // Special cases for items which have instance data
432 if( schItem->GetParent() && schItem->GetParent()->Type() == SCH_SYMBOL_T
433 && schItem->Type() == SCH_FIELD_T )
434 {
435 SCH_FIELD* field = static_cast<SCH_FIELD*>( schItem );
436 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( schItem->GetParent() );
437
438 if( field->GetId() == FIELD_T::REFERENCE )
439 {
440 // Lazy eval of sheet list; this is expensive even when unsorted
441 if( sheets.empty() )
442 sheets = m_schematic->Hierarchy();
443
444 SCH_SHEET_PATH sheet = sheets.FindSheetForScreen( screen );
445 symbol->SetRef( &sheet, field->GetText() );
446 }
447
448 bulkChangedItems.emplace_back( symbol );
449 }
450
451 break;
452
453 default:
454 wxFAIL_MSG( wxString::Format( wxT( "Unknown undo/redo command %d" ), status ) );
455 break;
456 }
457
458 if( schItem->Type() == SCH_SYMBOL_T )
459 {
460 SCH_SYMBOL* sym = static_cast<SCH_SYMBOL*>( schItem );
461 sym->UpdatePins();
462 }
463
464 if( schItem != &Schematic().Root() )
465 AddToScreen( schItem, screen );
466 }
467 }
468
469 // We have now swapped all the group parent and group member pointers. But it is a
470 // risky proposition to bet on the pointers being invariant, so validate them all.
471 //
472 // Two passes: restore each item's parent group first, then rebuild each group's members. The
473 // rebuild comes last so a member keeps its group even if its item was restored before it.
474 for( int ii = 0; ii < (int) aList->GetCount(); ++ii )
475 {
476 ITEM_PICKER& wrapper = aList->GetItemWrapper( ii );
477
478 if( wrapper.GetStatus() == UNDO_REDO::DELETED )
479 continue;
480
481 SCH_ITEM* parentGroup = Schematic().ResolveItem( wrapper.GetGroupId(), nullptr, true );
482 wrapper.GetItem()->SetParentGroup( dynamic_cast<SCH_GROUP*>( parentGroup ) );
483 }
484
485 for( int ii = 0; ii < (int) aList->GetCount(); ++ii )
486 {
487 ITEM_PICKER& wrapper = aList->GetItemWrapper( ii );
488
489 if( wrapper.GetStatus() == UNDO_REDO::DELETED )
490 continue;
491
492 if( EDA_GROUP* group = dynamic_cast<SCH_GROUP*>( wrapper.GetItem() ) )
493 {
494 // Items list may contain dodgy pointers, so don't use RemoveAll(). AddItem() also
495 // re-links each member back to the group.
496 group->GetItems().clear();
497
498 for( const KIID& member : wrapper.GetGroupMembers() )
499 {
500 if( SCH_ITEM* memberItem = Schematic().ResolveItem( member, nullptr, true ) )
501 group->AddItem( memberItem );
502 }
503 }
504
505 // And prepare for a redo by updating group info based on current image
506 if( EDA_ITEM* item = wrapper.GetLink() )
507 wrapper.SetLink( item );
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" ), wxS( "Undo/redo %s clean up connectivity rebuild." ),
528 connectivityCleanUp == LOCAL_CLEANUP ? wxS( "local" ) : wxS( "global" ) );
529
530 SCH_COMMIT localCommit( m_toolManager );
531
532 RecalculateConnections( &localCommit, connectivityCleanUp );
533
534 if( connectivityCleanUp == GLOBAL_CLEANUP )
536
537 // Restore hop over shapes of wires, if any
538 if( m_schematic->Settings().GetHopOverScale() > 0.0 )
539 {
540 for( SCH_ITEM* item : GetScreen()->Items() )
541 {
542 if( item->Type() != SCH_LINE_T )
543 continue;
544
545 SCH_LINE* line = static_cast<SCH_LINE*>( item );
546
547 if( line->IsWire() || line->IsBus() )
548 UpdateHopOveredWires( line );
549 }
550 }
551 }
552
553 // Update the hierarchy navigator when there are sheet changes.
554 if( rebuildHierarchyNavigator )
556
557 if( updateVariantCtrl && m_schematic )
558 {
559 m_schematic->LoadVariants();
560 UpdateVariantSelectionCtrl( m_schematic->GetVariantNamesForUI() );
561 }
562}
563
564
566{
568
569 // Skip empty frames
570 while( undo && !undo->GetCount() )
571 {
572 delete undo;
574 }
575
576 if( undo )
577 {
579 undo->ClearListAndDeleteItems( []( EDA_ITEM* aItem )
580 {
581 delete aItem;
582 } );
583
584 delete undo;
585
586 m_toolManager->GetTool<SCH_SELECTION_TOOL>()->RebuildSelection();
587 }
588
589 GetCanvas()->Refresh();
590}
591
592
594{
595 if( aItemCount == 0 )
596 return;
597
598 UNDO_REDO_CONTAINER& list = ( whichList == UNDO_LIST ) ? m_undoList : m_redoList;
599
600 if( aItemCount < 0 )
601 {
602 list.ClearCommandList();
603 }
604 else
605 {
606 for( int ii = 0; ii < aItemCount; ii++ )
607 {
608 if( list.m_CommandsList.size() == 0 )
609 break;
610
611 PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
612 list.m_CommandsList.erase( list.m_CommandsList.begin() );
613
614 curr_cmd->ClearListAndDeleteItems( []( EDA_ITEM* aItem )
615 {
616 delete aItem;
617 } );
618 delete curr_cmd; // Delete command
619 }
620 }
621}
622
623
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:42
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:96
virtual void ClearEditFlags()
Definition eda_item.h:166
void SetFlags(EDA_ITEM_FLAGS aMask)
Definition eda_item.h:152
KICAD_T Type() const
Returns the type of object.
Definition eda_item.h:108
EDA_ITEM * GetParent() const
Definition eda_item.h:110
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
Definition eda_item.cpp:143
EDA_ITEM_FLAGS GetFlags() const
Definition eda_item.h:155
virtual void ClearTempFlags()
Definition eda_item.h:179
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:254
Definition kiid.h:44
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:128
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:128
FIELD_T GetId() const
Definition sch_field.h:132
A set of SCH_ITEMs (i.e., without duplicates).
Definition sch_group.h:48
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:162
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:160
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:604
void SwapItemData(SCH_ITEM *aImage)
Swap data between aItem and aImage.
Definition sch_item.cpp:632
Segment description base class to describe items which have 2 end points (track, wire,...
Definition sch_line.h:38
bool IsWire() const
Return true if the line is a wire.
bool IsBus() const
Return true if the line is a bus.
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:44
wxString GetFileName() const
Return the filename corresponding to this sheet.
Definition sch_sheet.h:370
wxString GetName() const
Definition sch_sheet.h:136
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:227
Schematic symbol object.
Definition sch_symbol.h:69
std::vector< const SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet) const
Retrieve a list of the SCH_PINs for the given sheet path.
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.
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:53
#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:76
@ LOCAL_CLEANUP
Definition schematic.h:78
@ NO_CLEANUP
Definition schematic.h:77
@ GLOBAL_CLEANUP
Definition schematic.h:79
@ REFERENCE
Field Reference of part, i.e. "IC21".
KIBIS_PIN * pin
@ SCH_LINE_T
Definition typeinfo.h:160
@ SCH_SYMBOL_T
Definition typeinfo.h:169
@ SCH_FIELD_T
Definition typeinfo.h:147
@ SCH_SHEET_T
Definition typeinfo.h:172
@ SCH_RULE_AREA_T
Definition typeinfo.h:167
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...