105 bool aDirtyConnectivity )
111 if( aDirtyConnectivity )
128 if( aAppend || !lastUndo->
GetCount() )
129 commandToUndo = lastUndo;
139 ITEM_PICKER itemWrapper( aScreen, aItem, aCommandType );
142 switch( aCommandType )
144 case UNDO_REDO::CHANGED:
146 commandToUndo->
PushItem( itemWrapper );
149 case UNDO_REDO::NEWITEM:
150 case UNDO_REDO::DELETED:
151 commandToUndo->
PushItem( itemWrapper );
155 wxFAIL_MSG( wxString::Format( wxT(
"SaveCopyInUndoList() error (unknown code %X)" ),
170 delete commandToUndo;
177 bool aDirtyConnectivity )
189 if( aAppend || !lastUndo->
GetCount() )
190 commandToUndo = lastUndo;
204 commandToUndo->
CopyList( aItemsList );
211 ITEM_PICKER repeatItemPicker(
nullptr, repeatItemClone, UNDO_REDO::REPEAT_ITEM );
212 commandToUndo->
PushItem( repeatItemPicker );
218 for(
unsigned ii = 0; ii < aItemsList.
GetCount(); ii++ )
223 for(
unsigned ii = 0; ii < commandToUndo->
GetCount(); ii++ )
233 if( command == UNDO_REDO::UNSPECIFIED )
235 command = aTypeCommand;
241 case UNDO_REDO::CHANGED:
253 case UNDO_REDO::NEWITEM:
254 case UNDO_REDO::DELETED:
255 case UNDO_REDO::PAGESETTINGS:
256 case UNDO_REDO::REPEAT_ITEM:
260 wxFAIL_MSG( wxString::Format( wxT(
"Unknown undo/redo command %d" ), command ) );
275 delete commandToUndo;
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;
291 bool clearedRepeatItems =
false;
296 for(
unsigned ii = aList->
GetCount() - 1; ii < std::numeric_limits<unsigned>::max(); ii-- )
309 auto updateConnectivityFlag =
323 pin->SetConnectivityDirty();
332 pin->SetConnectivityDirty();
336 dirtyConnectivity =
true;
348 dirtyConnectivity =
true;
352 if( status == UNDO_REDO::NEWITEM )
355 updateConnectivityFlag();
360 rebuildHierarchyNavigator =
true;
361 refreshHierarchy =
true;
370 bulkRemovedItems.emplace_back( schItem );
372 else if( status == UNDO_REDO::DELETED )
376 rebuildHierarchyNavigator =
true;
377 refreshHierarchy =
true;
381 updateConnectivityFlag();
387 bulkAddedItems.emplace_back( schItem );
389 else if( status == UNDO_REDO::PAGESETTINGS )
407 *item = std::move( alt_item );
409 else if( status == UNDO_REDO::REPEAT_ITEM )
411 if( !clearedRepeatItems )
414 clearedRepeatItems =
true;
419 updateConnectivityFlag();
424 rebuildHierarchyNavigator =
true;
425 refreshHierarchy =
true;
433 wxCHECK2( itemCopy,
continue );
436 updateConnectivityFlag();
445 case UNDO_REDO::CHANGED:
451 wxCHECK2( origSheet && copySheet,
continue );
457 rebuildHierarchyNavigator =
true;
464 refreshHierarchy =
true;
469 bulkChangedItems.emplace_back( schItem );
488 bulkChangedItems.emplace_back( symbol );
494 wxFAIL_MSG( wxString::Format( wxT(
"Unknown undo/redo command %d" ),
513 if( bulkAddedItems.size() > 0 )
516 if( bulkRemovedItems.size() > 0 )
519 if( bulkChangedItems.size() > 0 )
522 if( refreshHierarchy )
525 if( dirtyConnectivity )
527 wxLogTrace( wxS(
"CONN_PROFILE" ),
528 wxS(
"Undo/redo %s clean up connectivity rebuild." ),
529 ( connectivityCleanUp ==
LOCAL_CLEANUP ) ? wxS(
"local" ) : wxS(
"global" ) );
540 if( rebuildHierarchyNavigator )
575 if( aItemCount == 0 )
586 for(
int ii = 0; ii < aItemCount; ii++ )
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.
virtual void ClearEditFlags()
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
EDA_ITEM * GetParent() const
virtual EDA_ITEM * Clone() const
Create a duplicate of this item with linked list members set to NULL.
EDA_ITEM_FLAGS GetFlags() const
virtual void ClearTempFlags()
virtual const wxString & GetText() const
Return the string associated with the text object.
static TOOL_ACTION leaveSheet
void SetLink(EDA_ITEM *aItem)
void SetFlags(EDA_ITEM_FLAGS aFlags)
void ClearHiddenFlags()
Clear the hide flag of all items in the view.
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.
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_SHEET_LIST Hierarchy() const override
Return the full schematic flattened hierarchical sheet list.
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.
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,...
Base class for any item which can be embedded within the SCHEMATIC container class,...
virtual bool IsConnectable() const
virtual void SwapData(SCH_ITEM *aItem)
Swap the internal data structures aItem with the schematic item.
void SetConnectivityDirty(bool aDirty=true)
bool IsConnectivityDirty() const
virtual bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const
Check if aItem has connectivity changes against this object.
SCH_CONNECTION * Connection(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve the connection associated with this object in the given sheet.
SCH_ITEM * Duplicate(bool doClone=false) const
Routine to create a new copy of given item.
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.
wxString GetFileName() const
Return the filename corresponding to this sheet.
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()
void UpdatePins()
Updates the cache of SCH_PIN objects for each pin.
void SetRef(const SCH_SHEET_PATH *aSheet, const wxString &aReference)
Set the reference for the given sheet path for this symbol.
std::vector< SCH_PIN * > GetPins(const SCH_SHEET_PATH *aSheet=nullptr) const
Retrieve a list of the SCH_PINs for the given sheet path.
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
@ REFERENCE_FIELD
Field Reference of part, i.e. "IC21".
UNDO_REDO
Undo Redo considerations: Basically we have 3 cases New item Deleted item Modified item there is also...