101 bool aDirtyConnectivity )
107 if( aDirtyConnectivity )
121 if( aAppend || !lastUndo->
GetCount() )
122 commandToUndo = lastUndo;
132 ITEM_PICKER itemWrapper( aScreen, aItem, aCommandType );
135 switch( aCommandType )
137 case UNDO_REDO::CHANGED:
139 commandToUndo->
PushItem( itemWrapper );
142 case UNDO_REDO::NEWITEM:
143 case UNDO_REDO::DELETED:
144 commandToUndo->
PushItem( itemWrapper );
148 wxFAIL_MSG( wxString::Format( wxT(
"SaveCopyInUndoList() error (unknown code %X)" ),
163 delete commandToUndo;
170 bool aDirtyConnectivity )
182 if( aAppend || !lastUndo->
GetCount() )
183 commandToUndo = lastUndo;
196 commandToUndo->
CopyList( aItemsList );
200 for(
unsigned ii = 0; ii < aItemsList.
GetCount(); ii++ )
205 for(
unsigned ii = 0; ii < commandToUndo->
GetCount(); ii++ )
215 if( command == UNDO_REDO::UNSPECIFIED )
217 command = aTypeCommand;
223 case UNDO_REDO::CHANGED:
235 case UNDO_REDO::NEWITEM:
236 case UNDO_REDO::DELETED:
237 case UNDO_REDO::PAGESETTINGS:
241 wxFAIL_MSG( wxString::Format( wxT(
"Unknown undo/redo command %d" ), command ) );
256 delete commandToUndo;
263 std::vector<SCH_ITEM*> bulkAddedItems;
264 std::vector<SCH_ITEM*> bulkRemovedItems;
265 std::vector<SCH_ITEM*> bulkChangedItems;
270 for(
unsigned ii = aList->
GetCount() - 1; ii < std::numeric_limits<unsigned>::max(); ii-- )
282 if( status == UNDO_REDO::NEWITEM )
299 bulkRemovedItems.emplace_back( schItem );
301 else if( status == UNDO_REDO::DELETED )
312 bulkAddedItems.emplace_back( schItem );
314 else if( status == UNDO_REDO::PAGESETTINGS )
332 if( item->IsConnectable() )
345 case UNDO_REDO::CHANGED:
346 item->SwapData( alt_item );
347 bulkChangedItems.emplace_back( item );
350 if( item->GetParent() && item->GetParent()->Type() ==
SCH_SYMBOL_T
362 bulkChangedItems.emplace_back( symbol );
368 wxFAIL_MSG( wxString::Format( wxT(
"Unknown undo/redo command %d" ),
387 if( bulkAddedItems.size() > 0 )
390 if( bulkRemovedItems.size() > 0 )
393 if( bulkChangedItems.size() > 0 )
432 if( aItemCount == 0 )
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.
void SetFlags(EDA_ITEM_FLAGS aMask)
KICAD_T Type() const
Returns the type of object.
EDA_ITEM_FLAGS GetFlags() const
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 GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
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,...
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 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
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
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 UpdateHierarchyNavigator()
Update the hierarchy navigation tree and history.
wxString m_highlightedConn
The highlighted net or bus or empty string.
void TestDanglingEnds()
Test all of the connectable objects in the schematic for unused connection points.
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
void SetConnectivityDirty(bool aDirty=true)
bool IsConnectivityDirty() const
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.
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...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
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.
A holder to handle a list of undo (or redo) commands.
std::vector< PICKED_ITEMS_LIST * > m_CommandsList
@ 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...