Пример #1
0
	def test_dgmod( self ):
		persp = Node( "persp" )
		front = Node( "front" )
		side = Node( "side" )

		# SIMPLE CONNECTION
		################
		# start undo
		uobj = undo.StartUndo( )
		dgmod = undo.DGModifier( )
		assert len( sys._maya_stack ) == 1 

		dgmod.connect( persp.message, front.isHistoricallyInteresting )
		dgmod.doIt( )

		# create undo step
		del( uobj )

		assert len( sys._maya_stack ) == 0 
		cmds.undo()	# undo connection
		# check connection - should be undone
		assert not persp.message.misConnectedTo( front.isHistoricallyInteresting ) 

		cmds.redo()
		# redo it and check connection
		assert persp.message.misConnectedTo( front.isHistoricallyInteresting ) 

		# connect and break existing conenction
		uobj = undo.StartUndo( )
		dgmod = undo.DGModifier( )
		dgmod.disconnect( persp.message, front.isHistoricallyInteresting )
		dgmod.connect( side.message, front.isHistoricallyInteresting )
		dgmod.doIt( )
		del( uobj )

		assert side.message.misConnectedTo( front.isHistoricallyInteresting ) 
		cmds.undo()

		# old connection should be back
		assert persp.message.misConnectedTo( front.isHistoricallyInteresting ) 


		# undo first change
		cmds.undo()

		# EMPTY DOIT
		################
		undo.startUndo( )
		dgmod = undo.DGModifier( )
		dgmod.doIt( )
		undo.endUndo( )

		cmds.undo()
Пример #2
0
    def test_dgmod(self):
        persp = Node("persp")
        front = Node("front")
        side = Node("side")

        # SIMPLE CONNECTION
        ################
        # start undo
        uobj = undo.StartUndo()
        dgmod = undo.DGModifier()
        assert len(sys._maya_stack) == 1

        dgmod.connect(persp.message, front.isHistoricallyInteresting)
        dgmod.doIt()

        # create undo step
        del (uobj)

        assert len(sys._maya_stack) == 0
        cmds.undo()  # undo connection
        # check connection - should be undone
        assert not persp.message.misConnectedTo(
            front.isHistoricallyInteresting)

        cmds.redo()
        # redo it and check connection
        assert persp.message.misConnectedTo(front.isHistoricallyInteresting)

        # connect and break existing conenction
        uobj = undo.StartUndo()
        dgmod = undo.DGModifier()
        dgmod.disconnect(persp.message, front.isHistoricallyInteresting)
        dgmod.connect(side.message, front.isHistoricallyInteresting)
        dgmod.doIt()
        del (uobj)

        assert side.message.misConnectedTo(front.isHistoricallyInteresting)
        cmds.undo()

        # old connection should be back
        assert persp.message.misConnectedTo(front.isHistoricallyInteresting)

        # undo first change
        cmds.undo()

        # EMPTY DOIT
        ################
        undo.startUndo()
        dgmod = undo.DGModifier()
        dgmod.doIt()
        undo.endUndo()

        cmds.undo()
Пример #3
0
    def _recurseUndo( numOps, curDepth, maxDepth ):
        """Recurse and create operations according to args
        :note: decorator used !"""
        if curDepth == maxDepth:
            return 0
        undo.startUndo()

        numops = 0
        for i in xrange( numOps ):
            op = TestUndoQueue.TestOperation()
            op.doIt( )          # apply operation
            numops += TestUndoPerformance._recurseUndo( numOps, curDepth+1, maxDepth )
            numops += 1
        # END for each op

        undo.endUndo()
        return numops
Пример #4
0
    def test_dagmod(self):
        undo.startUndo()
        dagmod = undo.DagModifier()
        obj = dagmod.createNode("transform")
        dagmod.renameNode(obj, "thisnewnode")
        dagmod.doIt()

        handle = api.MObjectHandle(obj)
        assert handle.isValid() and handle.isAlive()

        undo.endUndo()

        cmds.undo()
        assert not handle.isValid() and handle.isAlive()

        cmds.redo()
        assert handle.isValid() and handle.isAlive()
Пример #5
0
    def test_dagmod(self):
        undo.startUndo()
        dagmod = undo.DagModifier()
        obj = dagmod.createNode("transform")
        dagmod.renameNode(obj, "thisnewnode")
        dagmod.doIt()

        handle = api.MObjectHandle(obj)
        assert handle.isValid() and handle.isAlive()

        undo.endUndo()

        cmds.undo()
        assert not handle.isValid() and handle.isAlive()

        cmds.redo()
        assert handle.isValid() and handle.isAlive()
Пример #6
0
    def _recurseUndo(numOps, curDepth, maxDepth):
        """Recurse and create operations according to args
		:note: decorator used !"""
        if curDepth == maxDepth:
            return 0
        undo.startUndo()

        numops = 0
        for i in xrange(numOps):
            op = TestUndoQueue.TestOperation()
            op.doIt()  # apply operation
            numops += TestUndoPerformance._recurseUndo(numOps, curDepth + 1,
                                                       maxDepth)
            numops += 1
        # END for each op

        undo.endUndo()
        return numops
Пример #7
0
    def test_undoBasics(self):
        undo.startUndo()

        # put some undoable operation
        op = TestUndoQueue.TestOperation()
        op.doIt()  # apply operation

        assert len(sys._maya_stack) == 1
        assert sys._maya_stack_depth == 1

        undo.endUndo()

        # STACK MUST BE EMPTY#
        # as it has been taken by the command
        assert len(sys._maya_stack) == 0

        # UNDO
        cmds.undo()
        assert op.numDoit == op.numUndoIt

        # REDO
        cmds.redo()
        assert op.numDoit - 1 == op.numUndoIt

        # OP WITHOUT PUSH
        self.failUnlessRaises(AssertionError, TestUndoQueue.TestOperation)

        mrvmaya.Mel.flushUndo()

        # handle undo ourselves
        persp = Node("persp")
        curvalue = persp.tx.asFloat()
        newvalue = curvalue + 1.0

        undo.startUndo()
        persp.tx.msetFloat(newvalue)
        assert persp.tx.asFloat() == newvalue

        undo.undoAndClear(
        )  # end undo must come afterwards, otherwise the comand takes the queue
        undo.endUndo()
        assert persp.tx.asFloat(
        ) == curvalue  # its back to normal without an official undo

        # UNDO AND FILE FLUSHES
        ########################
        # Our stack must be flused once maya's undo queue gets flushed
        # This is critical if an undoable method causes undo flushes, but also
        # built up our own intermediate stack which might now contain entries from
        # a non-existing scene
        # NOTE: Currently this is a known limitation that could be circumvented
        # with some pre-scene-callbacks
        trans = nt.createNode("mytrans", "transform")

        undo.startUndo()
        trans.tx.msetFloat(10.0)
        assert len(sys._maya_stack) == 1
        mrvmaya.Scene.new(force=1)
        # DO NOT FAIL - allow releases to be done which would fail otherwise
        # Print a reminder though
        # TODO: Try to fix this
        # assert len( sys._maya_stack ) == 0, "Known Undo-Limitation"
        # http://github.com/Byron/mrv/issues#issue/2
        print "FIX KNOWN UNDO LIMITATION WHICH HAS BEEN SKIPPED TO ALLOW RELEASES"
        undo.endUndo()
Пример #8
0
    def test_undo_stack(self):
        mrvmaya.Scene.new(force=1)
        ur = undo.UndoRecorder()

        # works inside of another undo level as well
        p = Node("persp")
        t = Node("top")

        # ===================
        undo.startUndo()
        p.t.mconnectTo(t.t)

        ########################
        # startRecording needs to come first
        self.failUnlessRaises(AssertionError, ur.stopRecording)
        ur.startRecording()
        ur.startRecording()  # doesnt matter
        p.r.mconnectTo(t.r)

        # second instance will fail
        ur2 = undo.UndoRecorder()
        self.failUnlessRaises(AssertionError, ur2.startRecording)
        self.failUnlessRaises(AssertionError, ur2.stopRecording)

        ur.stopRecording()
        ur.stopRecording()  # doesnt matter
        ########################
        assert p.r.misConnectedTo(t.r)
        assert p.t.misConnectedTo(t.t)
        ur.undo()
        assert not p.r.misConnectedTo(t.r)
        assert p.t.misConnectedTo(t.t)

        ur.redo()
        assert p.r.misConnectedTo(t.r)
        ur.undo()
        assert not p.r.misConnectedTo(t.r)

        undo.endUndo()
        # ===================

        assert p.t.misConnectedTo(t.t)
        cmds.undo()
        assert not p.t.misConnectedTo(t.t)
        cmds.redo()
        assert p.t.misConnectedTo(t.t)

        # we should be able to selectively redo it, even after messing with the queue
        ur.redo()
        assert p.r.misConnectedTo(t.r)
        cmds.undo()
        assert not p.t.misConnectedTo(t.t)

        # TEST UNDO GETS ENABLED
        try:
            cmds.undoInfo(swf=0)

            ur = undo.UndoRecorder()
            ur.startRecording()
            assert cmds.undoInfo(q=1, swf=1)

            p.s.mconnectTo(t.s)

            ur.stopRecording()
            assert not cmds.undoInfo(q=1, swf=1)
            assert p.s.misConnectedTo(t.s)
            ur.undo()
            assert not p.s.misConnectedTo(t.s)
            ur.redo()
            assert p.s.misConnectedTo(t.s)

        finally:
            cmds.undoInfo(swf=1)
        # END assure it gets turned back on

        # TEST UNDO QUEUE INTEGRATION
        # if we never called startRecording, it will not do anything
        ur = undo.UndoRecorder()
        p.tx.mconnectTo(t.tx)
        del (ur)

        assert p.tx.misConnectedTo(t.tx)
        cmds.undo()
        assert not p.tx.misConnectedTo(t.tx)
        cmds.redo()
        assert p.tx.misConnectedTo(t.tx)

        # If we recorded something, it will be part of the undo queue if
        # undo was not called
        ur = undo.UndoRecorder()
        ur.startRecording()
        p.ty.mconnectTo(t.ty)
        ur.stopRecording()

        assert p.ty.misConnectedTo(t.ty)
        cmds.undo()
        assert not p.ty.misConnectedTo(t.ty)
        cmds.redo()
        assert p.ty.misConnectedTo(t.ty)
Пример #9
0
    def test_undoBasics(self):
        undo.startUndo()

        # put some undoable operation
        op = TestUndoQueue.TestOperation()
        op.doIt()  # apply operation

        assert len(sys._maya_stack) == 1
        assert sys._maya_stack_depth == 1

        undo.endUndo()

        # STACK MUST BE EMPTY#
        # as it has been taken by the command
        assert len(sys._maya_stack) == 0

        # UNDO
        cmds.undo()
        assert op.numDoit == op.numUndoIt

        # REDO
        cmds.redo()
        assert op.numDoit - 1 == op.numUndoIt

        # OP WITHOUT PUSH
        self.failUnlessRaises(AssertionError, TestUndoQueue.TestOperation)

        mrvmaya.Mel.flushUndo()

        # handle undo ourselves
        persp = Node("persp")
        curvalue = persp.tx.asFloat()
        newvalue = curvalue + 1.0

        undo.startUndo()
        persp.tx.msetFloat(newvalue)
        assert persp.tx.asFloat() == newvalue

        undo.undoAndClear()  # end undo must come afterwards, otherwise the comand takes the queue
        undo.endUndo()
        assert persp.tx.asFloat() == curvalue  # its back to normal without an official undo

        # UNDO AND FILE FLUSHES
        ########################
        # Our stack must be flused once maya's undo queue gets flushed
        # This is critical if an undoable method causes undo flushes, but also
        # built up our own intermediate stack which might now contain entries from
        # a non-existing scene
        # NOTE: Currently this is a known limitation that could be circumvented
        # with some pre-scene-callbacks
        trans = nt.createNode("mytrans", "transform")

        undo.startUndo()
        trans.tx.msetFloat(10.0)
        assert len(sys._maya_stack) == 1
        mrvmaya.Scene.new(force=1)
        # DO NOT FAIL - allow releases to be done which would fail otherwise
        # Print a reminder though
        # TODO: Try to fix this
        # assert len( sys._maya_stack ) == 0, "Known Undo-Limitation"
        # http://github.com/Byron/mrv/issues#issue/2
        print "FIX KNOWN UNDO LIMITATION WHICH HAS BEEN SKIPPED TO ALLOW RELEASES"
        undo.endUndo()
Пример #10
0
    def test_undo_stack(self):
        mrvmaya.Scene.new(force=1)
        ur = undo.UndoRecorder()

        # works inside of another undo level as well
        p = Node("persp")
        t = Node("top")

        # ===================
        undo.startUndo()
        p.t.mconnectTo(t.t)

        ########################
        # startRecording needs to come first
        self.failUnlessRaises(AssertionError, ur.stopRecording)
        ur.startRecording()
        ur.startRecording()  # doesnt matter
        p.r.mconnectTo(t.r)

        # second instance will fail
        ur2 = undo.UndoRecorder()
        self.failUnlessRaises(AssertionError, ur2.startRecording)
        self.failUnlessRaises(AssertionError, ur2.stopRecording)

        ur.stopRecording()
        ur.stopRecording()  # doesnt matter
        ########################
        assert p.r.misConnectedTo(t.r)
        assert p.t.misConnectedTo(t.t)
        ur.undo()
        assert not p.r.misConnectedTo(t.r)
        assert p.t.misConnectedTo(t.t)

        ur.redo()
        assert p.r.misConnectedTo(t.r)
        ur.undo()
        assert not p.r.misConnectedTo(t.r)

        undo.endUndo()
        # ===================

        assert p.t.misConnectedTo(t.t)
        cmds.undo()
        assert not p.t.misConnectedTo(t.t)
        cmds.redo()
        assert p.t.misConnectedTo(t.t)

        # we should be able to selectively redo it, even after messing with the queue
        ur.redo()
        assert p.r.misConnectedTo(t.r)
        cmds.undo()
        assert not p.t.misConnectedTo(t.t)

        # TEST UNDO GETS ENABLED
        try:
            cmds.undoInfo(swf=0)

            ur = undo.UndoRecorder()
            ur.startRecording()
            assert cmds.undoInfo(q=1, swf=1)

            p.s.mconnectTo(t.s)

            ur.stopRecording()
            assert not cmds.undoInfo(q=1, swf=1)
            assert p.s.misConnectedTo(t.s)
            ur.undo()
            assert not p.s.misConnectedTo(t.s)
            ur.redo()
            assert p.s.misConnectedTo(t.s)

        finally:
            cmds.undoInfo(swf=1)
        # END assure it gets turned back on

        # TEST UNDO QUEUE INTEGRATION
        # if we never called startRecording, it will not do anything
        ur = undo.UndoRecorder()
        p.tx.mconnectTo(t.tx)
        del (ur)

        assert p.tx.misConnectedTo(t.tx)
        cmds.undo()
        assert not p.tx.misConnectedTo(t.tx)
        cmds.redo()
        assert p.tx.misConnectedTo(t.tx)

        # If we recorded something, it will be part of the undo queue if
        # undo was not called
        ur = undo.UndoRecorder()
        ur.startRecording()
        p.ty.mconnectTo(t.ty)
        ur.stopRecording()

        assert p.ty.misConnectedTo(t.ty)
        cmds.undo()
        assert not p.ty.misConnectedTo(t.ty)
        cmds.redo()
        assert p.ty.misConnectedTo(t.ty)