node_scene_history Module¶
A module containing all code for working with History (Undo/Redo)
Events¶
- History Modified
after History Stamp has been stored or restored
- History Stored
after History Stamp has been stored
- History Restored
after History Stamp has been restored
SceneHistory Class¶
-
class
nodeeditor.node_scene_history.SceneHistory(scene: Scene)¶ Bases:
objectClass contains all the code for undo/redo operations
scene - reference to the
Scenehistory_limit - number of history steps that can be stored
-
clear()¶ Reset the history stack
-
storeInitialHistoryStamp()¶ Helper function usually used when new or open file requested
-
addHistoryModifiedListener(callback: function)¶ Register callback for HistoryModified event
- Parameters
callback – callback function
-
addHistoryStoredListener(callback: function)¶ Register callback for HistoryStored event
- Parameters
callback – callback function
-
addHistoryRestoredListener(callback: function)¶ Register callback for HistoryRestored event
- Parameters
callback – callback function
-
canUndo() → bool¶ Return
Trueif Undo is available for current History Stack- Return type
bool
-
canRedo() → bool¶ Return
Trueif Redo is available for current History Stack- Return type
bool
-
undo()¶ Undo operation
-
redo()¶ Redo operation
-
restoreHistory()¶ Restore History Stamp from History stack.
Triggers:
History Modified event
History Restored event
-
storeHistory(desc: str, setModified: bool = False)¶ Store History Stamp into History Stack
- Parameters
desc (
str) – Description of current History StampsetModified (
bool) – ifTruemarksScenewith has_been_modified
Triggers:
History Modified
History Stored
-
captureCurrentSelection() → dict¶ Create dictionary with a list of selected nodes and a list of selected edges :return:
dict‘nodes’ - list of selected nodes, ‘edges’ - list of selected edges :rtype:dict
-
createHistoryStamp(desc: str) → dict¶ Create History Stamp. Internally serialize whole scene and the current selection
- Parameters
desc – Descriptive label for the History Stamp
- Returns
History stamp serializing state of Scene and current selection
- Return type
dict
-
restoreHistoryStamp(history_stamp: dict)¶ Restore History Stamp to current Scene with selection of items included
- Parameters
history_stamp (
dict) – History Stamp to restore