OMC::History Class Reference

Detailed Description

Undo History for the Application.

The undo history for the application. Allows access to the command history and provides the ability to create new undo accumulations from scripts being run in the Object Model.
Provided via the project attribute OMC::Project::history.

Create an Action and Undo It.

from ToonBoom import harmony #Import the Harmony Module
sess = harmony.session() #Get access to the Harmony session, this class.
proj = sess.project
history = proj.history
history.begin( "Accumulate Actions" ) #Accumulate all Actions Between begin and end.
scn = proj.scene #Get the main scene.
top = scn.top #Get the top group of the main scene.
new_node = top.nodes.create( "PEG", "PEG_001" ) #Action 1 - In history.
new_node = top.nodes.create( "PEG", "PEG_002" ) #Action 2 - In history.
new_node = top.nodes.create( "PEG", "PEG_003" ) #Action 3 - In history.
history.end() #This closes the block of actions, the history will only show the one action.
#Print all actions in History.
print( "Items in History: %s"%(len(history)) )
for idx in range( len(history) ):
print( "History Item %s : %s"%(idx, history[idx]) )
history.undo() #Undo this first action.
history.undo( len(history) ) #Undo everything in the history.
print( "Actions Executed : %s"%(history.size_executed) ) #How many actions have been executed? Expecting 0, as we've undone everything.
print( "Actions Unexecuted : %s"%(history.size_unexecuted) ) #How many actions have been unexecuted (and can be redone)?

Public Member Functions

void begin (const QString &commandName)
 Begin accumulating actions into a single history item. This function starts the accumulation of all of the functions between it and the endUndoRedoAccum function as one command that will appear in the undo/redo list.
 
void end ()
 Ends the accumulation of actions into a single history item. This function ends the accumulation all of the functions between it and the beginUndoRedoAccum function as one command that will appear in the undo/redo list.
 
void cancel ()
 Cancels the currently accumulating history item. This function cancels the accumulation of undo/redo commands. No command will be added to the undo/redo list and all commands that have already been executed will be rolled-back (undone)
 
void undo (unsigned int depth=1)
 Undo events in the history. Undoes the last n operations. If n is not specified, it will be 1.
 
void redo (unsigned int depth=1)
 Redo events in the history. Redoes the last n operations. If n is not specified, it will be 1.
 
void clear ()
 Clears the history. Clears the command history. The events are not undone, but the history is cleared.
 
virtual size_t size () const
 Returns the size of history items that have been performed, and not undone.
 

Public Attributes

QString current
 Returns the name of the currently accumulating action - if one is available.
 
bool active
 Returns whether there is an accumulating action in the history.
 
size_t size_total
 The total size of the history, this includes both performed actions and undone actions.
 
size_t size_unexecuted
 The number of undone actions in the history. This is equivalent to size_total - size_performed.
 
size_t size_executed
 The number of executed actions in the history that can be undone.
 
size_t size_max
 The maximum number of actions that the history can maintain.
 
Inheritance diagram for OMC::History:
Collaboration diagram for OMC::History: