Example #1
0
 def setUp(self):
     self.testDag = Dag('self.testDag', autoUpdate=False)
Example #2
0
class testGraphEval(unittest.TestCase):
    def setUp(self):
        self.testDag = Dag('self.testDag', autoUpdate=False)

    def testMathNodes(self):
        """
        Test the basic math nodes
        """

        node1 = IntegerNode("Two", value=2)
        node2 = IntegerNode("Four", value=4)
        node3 = MathNode("Addition", operation="Add")
        node4 = IntegerNode("Two2", value=2)
        node5 = MathNode("Addition2", operation="Add")

        nodeView = StdOutNode('StdOutView')

        self.testDag.connectNode(parent=node1, child=node3, ptIn="a")
        self.testDag.connectNode(parent=node2, child=node3, ptIn="b")
        self.testDag.connectNode(parent=node4, child=node5, ptIn="a")
        self.testDag.connectNode(parent=node3, child=node5, ptIn="b")
        self.testDag.connectNode(parent=node5, child=nodeView)

        self.testDag.setViewer(nodeView)

        self.testDag.update()

        self.assertEqual(nodeView.data["val"], 8)

    def X_testProjectionNodes(self):
        '''
        Test projection nodes.
        '''

        self.testDag = self.testproj.addScene("vector_proj_test")

        nodeView = Node_Info("Get Info")
        self.testDag.setViewer(nodeView)

        cam = Node_Camera("Camera")

        nodeVector1 = Node_Vector_Screen("Test_Vector1")
        nodeTrans1 = Node_Screen_to_Layout("Transform1")

        nodeVector2 = Node_Vector_CamXYZ("Test_Vector2")
        nodeTrans2 = Node_Layout_to_Screen("Transform2")

        self.testDag.connectNode(parent=nodeVector1, child=nodeTrans1, ptIn="obj")
        self.testDag.connectNode(parent=cam, child=nodeTrans1, ptIn="cam")
        self.testDag.connectNode(parent=nodeTrans1, child=nodeView)

        self.testDag.refresh()

        self.testDag.connectNode(parent=nodeVector2, child=nodeTrans2, ptIn="obj")
        self.testDag.connectNode(parent=cam, child=nodeTrans2, ptIn="cam")
        self.testDag.connectNode(parent=nodeTrans2, child=nodeView)

    def ImageNodes(self):
        '''
        Test image operations
        '''
        self.testDag = self.testproj.addScene("image_test")

        node1 = Node_Read_Image("img1", file='test1.tif')
        node2 = Node_Read_Image("img2", file='test2.tif')

        nodeMix = Node_Composite_Over("Over")

        nodeView = Node_View_Image("Show_Image_Result")

        self.testDag.connectNode(parent=node1, child=nodeMix, ptIn="layerA")
        self.testDag.connectNode(parent=node2, child=nodeMix, ptIn="layerB")
        self.testDag.connectNode(parent=nodeMix, child=nodeView)

        self.testDag.setViewer(nodeView)

        self.testDag.refresh()

    def X_BasicColorNodes(self):
        self.testDag = self.testproj.addScene("colornode_test")

        node1 = Node_Constant_Color("Grey", color=(100, 100, 100, 100), resolution=(640, 480))
        node2 = Node_Constant_Color("White", color=(155, 155, 155, 155), resolution=(640, 480))

        nodeMix = Node_Composite_Over("Over")

        nodeView = Node_View_Image("Show_Image_Result")

        self.testDag.connectNode(parent=node1, child=nodeMix, ptIn="layerA")
        self.testDag.connectNode(parent=node2, child=nodeMix, ptIn="layerB")
        self.testDag.connectNode(parent=nodeMix, child=nodeView)

        self.testDag.setViewer(nodeView)

        self.testDag.refresh()