Package mrv :: Package maya :: Module undo :: Class UndoRecorder
[hide private]
[frames] | no frames]

Class UndoRecorder

source code

object --+
         |
        UndoRecorder

Utility class allowing to undo and redo operations on the python command stack so far to be undone and redone separately and independently of maya's undo queue.

It can be used to define sections that need to be undone afterwards, for example to reset a scene to its original state after it was prepared for export.

Use the startRecording method to record all future undoable operations onto the stack. stopRecording will finalize the operation, allowing the undo and redo methods to be used.

If you never call startRecording, the instance does not do anything. If you call startRecording and stopRecording but do not call undo, it will integrate itself transparently with the default undo queue.


Notes:
Instance Methods [hide private]
 
__init__(self)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
__del__(self) source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

    Interface
 
startRecording(self)
Start recording all future undoable commands onto this stack.
source code
 
stopRecording(self)
Stop recording of undoable comamnds and restore the previous command stack.
source code
 
undo(self)
Undo all stored operations
source code
 
redo(self)
Redo all stored operations after they have been undone :raise AssertionError: if called before stopRecording
source code
    Internal
 
doIt(self)
Called only if the user didn't call undo
source code
 
undoIt(self)
called only if the user didnt call undo
source code
Class Variables [hide private]
  _is_recording = False
hash(x)
  _disable_undo = False
hash(x)
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

startRecording(self)

source code 
Start recording all future undoable commands onto this stack. The previous stack will be safed and restored once this class gets destroyed or once stopRecording gets called.
Notes:
  • this method may only be called once, subsequent calls have no effect
  • This will forcibly enable the undo queue if required until stopRecording is called.

stopRecording(self)

source code 
Stop recording of undoable comamnds and restore the previous command stack. The instance is now ready to undo and redo the recorded commands

Note: this method may only be called once, subsequent calls have no effect

undo(self)

source code 
Undo all stored operations
Raises:
Notes:
  • Must be called at the right time, otherwise the undo queue is in an inconsistent state.
  • If this method is never being called, the undo-stack will undo itself as part of mayas undo queue, and thus behaves transparently