Exemplo n.º 1
0
        /// <summary>
        /// Restores the most recent reversion to the manipulator's transformation
        /// </summary>
        /// <returns>True if the operation was successful, false otherwise</returns>
        public bool Redo()
        {
            // no redos while we're active or in manipulation mode
            if (!Active || mManipulating)
            {
                return(false);
            }

            // nothing to redo...
            if (mRedoStack.Count == 0)
            {
                return(false);
            }

            // push the current transform onto the undo stack
            mUndoStack.Push(new TransformState(mTransform));

            // pop the topmost transform state from the redo stack
            // and apply it to the current transform
            TransformState state = mRedoStack.Pop();

            state.Apply();

            // success
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Reverts the most recent change to the manipulator's transformation
        /// </summary>
        /// <returns>True if the operation was successful, false otherwise</returns>
        public bool Undo()
        {
            // no undos while we're inactive
            if (!Active)
            {
                return(false);
            }

            // nothing to undo...
            if (mUndoStack.Count == 0)
            {
                return(false);
            }

            // user requested an undo while manipulating. we must reset the
            // manipulation flag, requiring that the user release and press the
            // mouse button again in order to start a new operation. otherwise,
            // the mouse position and manipulator position will be out of sync
            // after the transform is reverted
            if (mManipulating)
            {
                mRedoStack.Clear();
                mManipulating = false;
            }

            // push the current transform state onto the redo stack
            mRedoStack.Push(new TransformState(mTransform));

            // pop the top transform state from the undo stack and apply
            // it to the current transform
            TransformState state = mUndoStack.Pop();

            state.Apply();

            // success
            return(true);
        }