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 );
332
333 bulkRemovedItems.emplace_back( schItem );
334 }
335 else if( status == UNDO_REDO::DELETED )
336 {
337 if( eda_item->Type() == SCH_SHEET_T )
338 {
339 rebuildHierarchyNavigator = true;
340 refreshHierarchy = true;
341 }
342
343 if( schItem )
344 propagateConnectivityDamage( schItem );
345
346 // deleted items are re-inserted on undo
347 AddToScreen( eda_item, screen );
349
350 bulkAddedItems.emplace_back( schItem );
351 }
352 else if( status == UNDO_REDO::PAGESETTINGS )
353 {
354 if( GetCurrentSheet() != undoSheet )
355 {
356 SetCurrentSheet( undoSheet );
358 }
359
360 // swap current settings with stored settings
361 DS_PROXY_UNDO_ITEM alt_item( this );
362 DS_PROXY_UNDO_ITEM* item = static_cast<DS_PROXY_UNDO_ITEM*>( eda_item );
363 item->Restore( this );
364 *item = std::move( alt_item );
365 }
366 else if( status == UNDO_REDO::REPEAT_ITEM )
367 {
368 if( !clearedRepeatItems )
369 {
371 clearedRepeatItems = true;
372 }
373
374 if( schItem )
375 {
376 propagateConnectivityDamage( schItem );
377 AddCopyForRepeatItem( schItem );
378
379 if( schItem->Type() == SCH_SHEET_T )
380 {
381 rebuildHierarchyNavigator = true;
382 refreshHierarchy = true;
383 }
384 }
385 }
386 else if( status == UNDO_REDO::VARIANTS )
387 {
388 // swap current settings with stored settings
389 VARIANT_PROXY_UNDO_ITEM alt_item( &Schematic() );
390 VARIANT_PROXY_UNDO_ITEM* item = static_cast<VARIANT_PROXY_UNDO_ITEM*>( eda_item );
391 item->Restore( &Schematic() );
392 *item = std::move( alt_item );
393
394 UpdateVariantSelectionCtrl( Schematic().GetVariantNamesForUI() );
395 }
396 else if( schItem )
397 {
398 SCH_ITEM* itemCopy = dynamic_cast<SCH_ITEM*>( aList->GetPickedItemLink( ii ) );
399
400 wxCHECK2( itemCopy, continue );
401
402 bool fullSheetUpdate = true;
403
404 if( status == UNDO_REDO::CHANGED && schItem->Type() == SCH_SHEET_T )
405 {
406 const auto* originalSheet = static_cast<const SCH_SHEET*>( schItem );
407 const auto* modifiedSheet = static_cast<const SCH_SHEET*>( itemCopy );
408 const bool hierarchyChanged = originalSheet->HasHierarchyChanges( *modifiedSheet );
409 rebuildHierarchyNavigator |= hierarchyChanged;
410 refreshHierarchy |= hierarchyChanged;
411 // Local undo cleanup only visits the displayed screen
412 fullSheetUpdate = !ADVANCED_CFG::GetCfg().m_ConnectivityEngine
413 || screen != GetScreen()
414 || hierarchyChanged
415 || originalSheet->HasPinIdentityChanges( *modifiedSheet );
416 }
417
418 if( schItem->HasConnectivityChanges( itemCopy, &undoSheet ) )
419 propagateConnectivityDamage( schItem, fullSheetUpdate );
420
421 // The root sheet is a pseudo object that owns the root screen object but is not on
422 // the root screen so do not attempt to remove it from the screen it owns.
423 if( schItem != &Schematic().Root() )
424 RemoveFromScreen( schItem, screen );
425
426 switch( status )
427 {
429 if( schItem->Type() == SCH_SHEET_T || schItem->Type() == SCH_SYMBOL_T )
430 updateVariantCtrl = true;
431
432 schItem->SwapItemData( itemCopy );
433
434 bulkChangedItems.emplace_back( schItem );
435
436 // Special cases for items which have instance data
437 if( schItem->GetParent() && schItem->GetParent()->Type() == SCH_SYMBOL_T
438 && schItem->Type() == SCH_FIELD_T )
439 {
440 SCH_FIELD* field = static_cast<SCH_FIELD*>( schItem );
441 SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( schItem->GetParent() );
442
443 if( field->GetId() == FIELD_T::REFERENCE )
444 {
445 // Lazy eval of sheet list; this is expensive even when unsorted
446 if( sheets.empty() )
447 sheets = m_schematic->Hierarchy();
448
449 SCH_SHEET_PATH sheet = sheets.FindSheetForScreen( screen );
450 symbol->SetRef( &sheet, field->GetText() );
451 }
452
453 bulkChangedItems.emplace_back( symbol );
454 }
455
456 break;
457
458 default:
459 wxFAIL_MSG( wxString::Format( wxT( "Unknown undo/redo command %d" ), status ) );
460 break;
461 }
462
463 if( schItem->Type() == SCH_SYMBOL_T )
464 {
465 SCH_SYMBOL* sym = static_cast<SCH_SYMBOL*>( schItem );
466 sym->UpdatePins();
467 }
468
469 if( schItem != &Schematic().Root() )
470 AddToScreen( schItem, screen );
471 }
472 }
473
474 // We have now swapped all the group parent and group member pointers. But it is a
475 // risky proposition to bet on the pointers being invariant, so validate them all.
476 //
477 // Two passes: restore each item's parent group first, then rebuild each group's members. The
478 // rebuild comes last so a member keeps its group even if its item was restored before it.
479 for( int ii = 0; ii < (int) aList->GetCount(); ++ii )
480 {
481 ITEM_PICKER& wrapper = aList->GetItemWrapper( ii );
482
483 if( wrapper.GetStatus() == UNDO_REDO::DELETED )
484 continue;
485
486 SCH_ITEM* parentGroup = Schematic().ResolveItem( wrapper.GetGroupId(), nullptr, true );
487 wrapper.GetItem()->SetParentGroup( dynamic_cast<SCH_GROUP*>( parentGroup ) );
488 }
489
490 for( int ii = 0; ii < (int) aList->GetCount(); ++ii )
491 {
492 ITEM_PICKER& wrapper = aList->GetItemWrapper( ii );
493
494 if( wrapper.GetStatus() == UNDO_REDO::DELETED )
495 continue;
496
497 if( EDA_GROUP* group = dynamic_cast<SCH_GROUP*>( wrapper.GetItem() ) )
498 {
499 // Items list may contain dodgy pointers, so don't use RemoveAll(). AddItem() also
500 // re-links each member back to the group.
501 group->GetItems().clear();
502
503 for( const KIID& member : wrapper.GetGroupMembers() )
504 {
505 if( SCH_ITEM* memberItem = Schematic().ResolveItem( member, nullptr, true ) )
506 group->AddItem( memberItem );
507 }
508 }
509
510 // And prepare for a redo by updating group info based on current image
511 if( EDA_ITEM* item = wrapper.GetLink() )
512 wrapper.SetLink( item );
513 }
514
516
517 // Notify our listeners
518 if( bulkAddedItems.size() > 0 )
519 Schematic().OnItemsAdded( bulkAddedItems );
520
521 if( bulkRemovedItems.size() > 0 )
522 Schematic().OnItemsRemoved( bulkRemovedItems );
523
524 if( bulkChangedItems.size() > 0 )
525 Schematic().OnItemsChanged( bulkChangedItems );
526
527 if( refreshHierarchy )
529
530 if( dirtyConnectivity )
531 {
532 wxLogTrace( wxS( "CONN_PROFILE" ), wxS( "Undo/redo %s clean up connectivity rebuild." ),
533 connectivityCleanUp == LOCAL_CLEANUP ? wxS( "local" ) : wxS( "global" ) );
534
535 SCH_COMMIT localCommit( m_toolManager );
536
537 RecalculateConnections( &localCommit, connectivityCleanUp );
538
539 if( connectivityCleanUp == GLOBAL_CLEANUP )
541
542 // Restore hop over shapes of wires, if any
543 if( m_schematic->Settings().GetHopOverScale() > 0.0 )
544 {
545 for( SCH_ITEM* item : GetScreen()->Items() )
546 {
547 if( item->Type() != SCH_LINE_T )
548 continue;
549
550 SCH_LINE* line = static_cast<SCH_LINE*>( item );
551
552 if( line->IsWire() || line->IsBus() )
553 UpdateHopOveredWires( line );
554 }
555 }
556 }
557
558 // Update the hierarchy navigator when there are sheet changes.
559 if( rebuildHierarchyNavigator )
561
562 if( updateVariantCtrl && m_schematic )
563 {
564 m_schematic->LoadVariants();
565 UpdateVariantSelectionCtrl( m_schematic->GetVariantNamesForUI() );
566 }
567}
568
569
571{
573
574 // Skip empty frames
575 while( undo && !undo->GetCount() )
576 {
577 delete undo;
579 }
580
581 if( undo )
582 {
584 undo->ClearListAndDeleteItems( []( EDA_ITEM* aItem )
585 {
586 delete aItem;
587 } );
588
589 delete undo;
590
591 m_toolManager->GetTool<SCH_SELECTION_TOOL>()->RebuildSelection();
592 }
593
594 GetCanvas()->Refresh();
595}
596
597
599{
600 if( aItemCount == 0 )
601 return;
602
603 UNDO_REDO_CONTAINER& list = ( whichList == UNDO_LIST ) ? m_undoList : m_redoList;
604
605 if( aItemCount < 0 )
606 {
607 list.ClearCommandList();
608 }
609 else
610 {
611 for( int ii = 0; ii < aItemCount; ii++ )
612 {
613 if( list.m_CommandsList.size() == 0 )
614 break;
615
616 PICKED_ITEMS_LIST* curr_cmd = list.m_CommandsList[0];
617 list.m_CommandsList.erase( list.m_CommandsList.begin() );
618
619 curr_cmd->ClearListAndDeleteItems( []( EDA_ITEM* aItem )
620 {
621 delete aItem;
622 } );
623 delete curr_cmd; // Delete command
624 }
625 }
626}
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:294
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:194
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:545
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:654
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:243
Schematic symbol object.
Definition sch_symbol.h:73
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...