Undo and Redo Example
 
 
 

As a simple example consider a utility plug-in that allows the user to change the wire-frame color of a node in the scene. The restore object needs to save the previous color and a pointer to the node being changed. It also needs storage to save the current color prior to an undo. This allows it to revert the undo.

To register the restore object with the system, the developer calls theHold. Put(), passing the restore object pointer. For example:

if ( theHold.Holding() ) {
  //The INode you are changing the color of
  theHold.Put(new ColorRestoreObj(currentColor,INode*));
}

In the example above the ColorRestoreObj is a developer defined class derived from RestoreObj.

Once the restore object has been registered with theHold, there are two potential cases to terminate the Begin(). The user can complete the operation or cancel it.