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