96 if( aAppend || !lastUndo->
GetCount() )
97 commandToUndo = lastUndo;
107 ITEM_PICKER itemWrapper( aScreen, aItem, aCommandType );
110 switch( aCommandType )
114 commandToUndo->
PushItem( itemWrapper );
119 commandToUndo->
PushItem( itemWrapper );
123 wxFAIL_MSG( wxString::Format( wxT(
"SaveCopyInUndoList() error (unknown code %X)" ), aCommandType ) );
137 delete commandToUndo;
155 if( aAppend || !lastUndo->
GetCount() )
156 commandToUndo = lastUndo;
170 commandToUndo->
CopyList( aItemsList );
178 commandToUndo->
PushItem( repeatItemPicker );
184 for(
unsigned ii = 0; ii < aItemsList.
GetCount(); ii++ )
189 for(
unsigned ii = 0; ii < commandToUndo->
GetCount(); ii++ )
201 command = aTypeCommand;
226 wxFAIL_MSG( wxString::Format( wxT(
"Unknown undo/redo command %d" ), command ) );
241 delete commandToUndo;
248 std::vector<SCH_ITEM*> bulkAddedItems;
249 std::vector<SCH_ITEM*> bulkRemovedItems;
250 std::vector<SCH_ITEM*> bulkChangedItems;
251 std::set<SCH_TABLE*> changedTables;
252 bool dirtyConnectivity =
false;
253 bool rebuildHierarchyNavigator =
false;
254 bool refreshHierarchy =
false;
257 bool clearedRepeatItems =
false;
262 for(
unsigned ii = aList->
GetCount() - 1; ii < std::numeric_limits<unsigned>::max(); ii-- )
274 auto propagateConnectivityDamage =
277 if( schItem->IsConnectable() )
279 schItem->SetConnectivityDirty();
286 pin->SetConnectivityDirty();
293 pin->SetConnectivityDirty();
297 dirtyConnectivity =
true;
309 dirtyConnectivity =
true;
318 propagateConnectivityDamage( schItem );
323 rebuildHierarchyNavigator =
true;
324 refreshHierarchy =
true;
333 bulkRemovedItems.emplace_back( schItem );
339 rebuildHierarchyNavigator =
true;
340 refreshHierarchy =
true;
344 propagateConnectivityDamage( schItem );
350 bulkAddedItems.emplace_back( schItem );
364 *item = std::move( alt_item );
368 if( !clearedRepeatItems )
371 clearedRepeatItems =
true;
376 propagateConnectivityDamage( schItem );
381 rebuildHierarchyNavigator =
true;
382 refreshHierarchy =
true;
390 wxCHECK2( itemCopy,
continue );
393 propagateConnectivityDamage( schItem );
408 wxCHECK2( origSheet && copySheet,
continue );
414 rebuildHierarchyNavigator =
true;
421 refreshHierarchy =
true;
427 bulkChangedItems.emplace_back( schItem );
446 bulkChangedItems.emplace_back( symbol );
452 wxFAIL_MSG( wxString::Format( wxT(
"Unknown undo/redo command %d" ), status ) );
469 for(
int ii = 0; ii < (int) aList->
GetCount(); ++ii )
477 wrapper.GetItem()->SetParentGroup(
dynamic_cast<SCH_GROUP*
>( parentGroup ) );
482 group->GetItems().clear();
484 for(
const KIID& member :
wrapper.GetGroupMembers() )
487 group->AddItem( memberItem );
499 if( bulkAddedItems.size() > 0 )
502 if( bulkRemovedItems.size() > 0 )
505 if( bulkChangedItems.size() > 0 )
508 if( refreshHierarchy )
511 if( dirtyConnectivity )
513 wxLogTrace( wxS(
"CONN_PROFILE" ), wxS(
"Undo/redo %s clean up connectivity rebuild." ),
514 connectivityCleanUp ==
LOCAL_CLEANUP ? wxS(
"local" ) : wxS(
"global" ) );
540 if( rebuildHierarchyNavigator )
575 if( aItemCount == 0 )
582 list.ClearCommandList();
586 for(
int ii = 0; ii < aItemCount; ii++ )
588 if( list.m_CommandsList.size() == 0 )
592 list.m_CommandsList.erase( list.m_CommandsList.begin() );
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).
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.
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
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
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.
bool m_highlightedConnChanged
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 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)
A set of SCH_ITEMs (i.e., without duplicates).
Base class for any item which can be embedded within the SCHEMATIC container class,...
SCH_ITEM * Duplicate(bool addToParentGroup, SCH_COMMIT *aCommit=nullptr, bool doClone=false) const
Routine to create a new copy of given item.
virtual bool HasConnectivityChanges(const SCH_ITEM *aItem, const SCH_SHEET_PATH *aInstance=nullptr) const
Check if aItem has connectivity changes against this object.
void SwapItemData(SCH_ITEM *aImage)
Swap data between aItem and aImage.
Segment description base class to describe items which have 2 end points (track, wire,...
bool IsWire() const
Return true if the line is a wire.
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) const
Retrieve a list of the SCH_PINs for the given sheet path.
A holder to handle a list of undo (or redo) commands.
#define IGNORE_PARENT_GROUP
#define UR_TRANSIENT
indicates the item is owned by the undo/redo stack
Class to handle a set of SCH_ITEMs.
@ REFERENCE
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...