Exemplo n.º 1
0
 def testRevokedListener(self):
     self.listener.Revoke()
     with UsdQt.UndoBlock():
         self.stage.DefinePrim('/World')
     with UsdQt.UndoBlock():
         self.stage.DefinePrim('/World/Child')
     self.assertEqual(self.localUndoStack, [])
Exemplo n.º 2
0
    def testEmptyUndoBlock(self):
        with UsdQt.UndoBlock():
            pass
        self.assertEqual(self.localUndoStack, [])

        with UsdQt.UndoBlock():
            with UsdQt.UndoBlock():
                with UsdQt.UndoBlock():
                    pass
        self.assertEqual(self.localUndoStack, [])
Exemplo n.º 3
0
    def testMidEditBlockInversion(self):
        self.stage.DefinePrim('/World')
        with UsdQt.UndoBlock():
            with self.assertRaisesRegexp(
                    Tf.ErrorException, 'Inversion during \
open edit block may result in corrupted undo stack.'):
                self.localUndoStack[-1].Invert()
Exemplo n.º 4
0
    def testExpiredStage(self):
        with UsdQt.UndoBlock():
            self.stage.DefinePrim('/World')

        self.stage = None
        with self.assertRaises(Tf.ErrorException):
            self.localUndoStack[-1].Invert()
Exemplo n.º 5
0
    def testNestedUndoBlock(self):
        with UsdQt.UndoBlock():
            prim = self.stage.DefinePrim('/World')

        self.assertTrue(bool(prim))
        with UsdQt.UndoBlock():
            prim.SetActive(False)
            with UsdQt.UndoBlock():
                prim.SetActive(True)
                with UsdQt.UndoBlock():
                    prim.SetActive(False)

        self.assertFalse(prim.IsActive())
        self.assertEqual(len(self.localUndoStack), 2)

        with UsdQt.UndoBlock():
            prim.SetActive(False)
            with UsdQt.UndoBlock():
                prim.SetActive(True)

        self.assertTrue(prim.IsActive())
        self.assertEqual(len(self.localUndoStack), 3)

        self.localUndoStack[-1].Invert()  # undo
        self.assertFalse(prim.IsActive())
        self.localUndoStack[-1].Invert()  # redo
        self.assertTrue(prim.IsActive())
        self.localUndoStack[-1].Invert()  # undo
        self.assertFalse(prim.IsActive())
        self.localUndoStack[-2].Invert()  # undo
        self.assertTrue(prim.IsActive())
        self.localUndoStack[-3].Invert()  # undo
        self.assertFalse(bool(prim))
        self.localUndoStack[-3].Invert()  # redo
        prim = self.stage.GetPrimAtPath('/World')
        self.assertTrue(bool(prim))
        self.assertTrue(prim.IsActive())

        self.assertEqual(len(self.localUndoStack), 3)