예제 #1
0
def testStringCache():
    value1 = "!1+"
    value2 = "+2+"
    value3 = "+3!"
    
    add = MT.createNode("Math.Add")
    valuenode = MT.createNode("Values.String Value")
    valuenode2 = MT.createNode("Values.String Value")

    valuenode.insockets[0].value = value1
    valuenode2.insockets[0].value = value2

    print("setting the input of valuenode to %s" % value1)

    MT.project.root.addNode(add)
    MT.project.root.addNode(valuenode)
    MT.project.root.addNode(valuenode2)

    pos = valuenode.pos
    valuenode.pos = (pos[0] - 150, pos[1] - 50)
    valuenode2.pos = (pos[0] - 150, pos[1] + 50)

    add.insockets[0].connected = valuenode.outsockets[0]
    add.insockets[1].connected = valuenode2.outsockets[0]
    add.insockets[2].value = value3

    cache = MT.cache.DataCache(add.outsockets[0])

    print("resulting value: %s" % cache.getOutput())
    print("expected value: %s" % value1 + value2 + value3)
    return (value1 + value2 + value3) == cache.getOutput()
예제 #2
0
파일: __init__.py 프로젝트: yazici/MindTree
    def __init__(self, node, raw=False):
        super().__init__(node, raw)
        if raw:
            return

        data = MT.createNode(self.datanode)
        obj = MT.createNode("Objects.Object")
        node.graph.addNode(data)
        node.graph.addNode(obj)

        obj.insockets[0].connected = node.graph[0].outsockets[-1]
        obj.insockets[1].connected = node.graph[0].outsockets[-1]
        obj.insockets[2].connected = data.outsockets[0]
        obj.insockets[3].connected = node.graph[0].outsockets[-1]

        for s in data.insockets:
            default = s.value
            s.connected = node.graph[0].outsockets[-1]
            node.insockets[-1].value = default

        node.graph[1].insockets[0].connected = obj.outsockets[0]

        node.graph[2].pos = (-70, 80)
        node.graph[3].pos = (70, 80)
        node.graph[1].pos = (70, 160)
예제 #3
0
def testStringCache():
    value1 = "!1+"
    value2 = "+2+"
    value3 = "+3!"

    add = MT.createNode("Math.Add")
    valuenode = MT.createNode("Values.String Value")
    valuenode2 = MT.createNode("Values.String Value")

    valuenode.insockets[0].value = value1
    valuenode2.insockets[0].value = value2

    print("setting the input of valuenode to %s" % value1)

    MT.project.root.addNode(add)
    MT.project.root.addNode(valuenode)
    MT.project.root.addNode(valuenode2)

    pos = valuenode.pos
    valuenode.pos = (pos[0] - 150, pos[1] - 50)
    valuenode2.pos = (pos[0] - 150, pos[1] + 50)

    add.insockets[0].connected = valuenode.outsockets[0]
    add.insockets[1].connected = valuenode2.outsockets[0]
    add.insockets[2].value = value3

    cache = MT.cache.DataCache(add.outsockets[0])

    print("resulting value: %s" % cache.getOutput())
    print("expected value: %s" % value1 + value2 + value3)
    return (value1 + value2 + value3) == cache.getOutput()
예제 #4
0
파일: __init__.py 프로젝트: frigge/MindTree
    def __init__(self, node, raw=False):
        super().__init__(node, raw)
        if raw:
            return

        data = MT.createNode(self.datanode)
        obj = MT.createNode("Objects.Object")
        node.graph.addNode(data)
        node.graph.addNode(obj)

        obj.insockets[0].connected = node.graph[0].outsockets[-1]
        obj.insockets[1].connected = node.graph[0].outsockets[-1]
        obj.insockets[2].connected = data.outsockets[0]
        obj.insockets[3].connected = node.graph[0].outsockets[-1]

        for s in data.insockets:
            default = s.value
            s.connected = node.graph[0].outsockets[-1]
            node.insockets[-1].value = default

        node.graph[1].insockets[0].connected = obj.outsockets[0]

        node.graph[2].pos = (-70, 80)
        node.graph[3].pos = (70, 80)
        node.graph[1].pos = (70, 160)
예제 #5
0
def testSimulation():
    simNode = MT.createNode("General.Simulation")
    add = MT.createNode("Math.Add")
    startValue = MT.createNode("Values.Int Value")

    MT.project.root.addNode(simNode)
    MT.project.root.addNode(startValue)
    simNode.graph.addNode(add)

    innode = simNode.graph[1]
    outnode = simNode.graph[2]

    test = TestCase()

    test.equal(len(simNode.graph[2].insockets), 0,
               "Amount of outputs before connection")

    add.insockets[0].connected = innode.outsockets[0]
    test.equal(len(simNode.graph[2].insockets), 1,
               "Amount of outputs after connection")

    simNode.insockets[1].connected = startValue.outsockets[0]
    add.insockets[1].value = 1
    startValue.insockets[0].value = 0

    outnode.insockets[0].connected = add.outsockets[0]

    test.equal(simNode.insockets[1].type, "INTEGER")
    test.equal(innode.outsockets[0].type, "INTEGER")
    test.equal(add.insockets[0].type, "INTEGER")
    test.equal(add.outsockets[0].type, "INTEGER")
    test.equal(outnode.insockets[0].type, "INTEGER", "outnode")
    test.equal(simNode.outsockets[0].type, "INTEGER", "simnode output")
    simNode.insockets[0].value = 1
    cache = MT.cache.DataCache(simNode.outsockets[0])
    test.equal(cache.getOutput(), 1, "Simulation Step: 1")

    simNode.insockets[0].value = 2
    MT.cache.DataCache.invalidate(simNode)
    cache = MT.cache.DataCache(simNode.outsockets[0])
    test.equal(cache.getOutput(), 2, "Simulation Step: 2")

    simNode.insockets[0].value = 3
    MT.cache.DataCache.invalidate(simNode)
    cache = MT.cache.DataCache(simNode.outsockets[0])
    test.equal(cache.getOutput(), 3, "Simulation Step: 3")

    simNode.insockets[0].value = 4
    MT.cache.DataCache.invalidate(simNode)
    cache = MT.cache.DataCache(simNode.outsockets[0])
    test.equal(cache.getOutput(), 4, "Simulation Step: 4")

    simNode.insockets[0].value = 5
    MT.cache.DataCache.invalidate(simNode)
    cache = MT.cache.DataCache(simNode.outsockets[0])
    test.equal(cache.getOutput(), 5, "Simulation Step: 5")
    return test.exit()
예제 #6
0
def testSimulation():
    simNode = MT.createNode("General.Simulation")
    add = MT.createNode("Math.Add")
    startValue = MT.createNode("Values.Int Value")

    MT.project.root.addNode(simNode)
    MT.project.root.addNode(startValue)
    simNode.graph.addNode(add)

    innode = simNode.graph[1]
    outnode = simNode.graph[2]

    test = TestCase()

    test.equal(len(simNode.graph[2].insockets), 0, "Amount of outputs before connection")

    add.insockets[0].connected = innode.outsockets[0]
    test.equal(len(simNode.graph[2].insockets), 1, "Amount of outputs after connection")

    simNode.insockets[1].connected = startValue.outsockets[0]
    add.insockets[1].value = 1
    startValue.insockets[0].value = 0

    outnode.insockets[0].connected = add.outsockets[0]


    test.equal(simNode.insockets[1].type, "INTEGER")
    test.equal(innode.outsockets[0].type, "INTEGER")
    test.equal(add.insockets[0].type, "INTEGER")
    test.equal(add.outsockets[0].type, "INTEGER")
    test.equal(outnode.insockets[0].type, "INTEGER", "outnode")
    test.equal(simNode.outsockets[0].type, "INTEGER", "simnode output")
    simNode.insockets[0].value = 1
    cache = MT.cache.DataCache(simNode.outsockets[0])
    test.equal(cache.getOutput(), 1, "Simulation Step: 1")

    simNode.insockets[0].value = 2
    MT.cache.DataCache.invalidate(simNode)
    cache = MT.cache.DataCache(simNode.outsockets[0])
    test.equal(cache.getOutput(), 2, "Simulation Step: 2")

    simNode.insockets[0].value = 3
    MT.cache.DataCache.invalidate(simNode)
    cache = MT.cache.DataCache(simNode.outsockets[0])
    test.equal(cache.getOutput(), 3, "Simulation Step: 3")

    simNode.insockets[0].value = 4
    MT.cache.DataCache.invalidate(simNode)
    cache = MT.cache.DataCache(simNode.outsockets[0])
    test.equal(cache.getOutput(), 4, "Simulation Step: 4")

    simNode.insockets[0].value = 5
    MT.cache.DataCache.invalidate(simNode)
    cache = MT.cache.DataCache(simNode.outsockets[0])
    test.equal(cache.getOutput(), 5, "Simulation Step: 5")
    return test.exit()
예제 #7
0
def testInheritSocketTypeMath():
    add = MT.createNode("Math.Add")
    flnode = MT.createNode("Values.Float Value")

    add.insockets[0].connected = flnode.outsockets[0]

    test = TestCase()
    test.equal(add.insockets[0].type, flnode.outsockets[0].type, "connected")
    test.equal(add.insockets[0].type, add.outsockets[0].type, "in to out")

    return test.exit()
예제 #8
0
def testNewProject():
    node = MT.createNode("Math.Add")
    node1 = MT.createNode("Values.Float Value")
    node2 = MT.createNode("Values.Int Value")

    MT.project.root.addNode(node)
    MT.project.root.addNode(node1)
    MT.project.root.addNode(node2)

    MT.newProject()

    return len(MT.project.root) == 0
예제 #9
0
def testNewProject():
    node = MT.createNode("Math.Add")
    node1 = MT.createNode("Values.Float Value")
    node2 = MT.createNode("Values.Int Value")

    MT.project.root.addNode(node)
    MT.project.root.addNode(node1)
    MT.project.root.addNode(node2)

    MT.newProject()

    return len(MT.project.root) == 0
예제 #10
0
def testSwitchNode():
    value1 = MT.createNode("Values.Float Value")
    value2 = MT.createNode("Values.Float Value")
    value3 = MT.createNode("Values.Float Value")
    
    value1.insockets[0].value = 1
    value2.insockets[0].value = 3
    value3.insockets[0].value = 6

    switch = MT.createNode("General.Switch")

    MT.project.root.addNode(value1)
    MT.project.root.addNode(value2)
    MT.project.root.addNode(value3)
    MT.project.root.addNode(switch)

    #find array converter ... this is still kinda ugly
    array = None
    for child in switch.insockets[1].childNodes:
        if child.name == "ArrayNode":
            array = child
            break

    print(array.type)
    print(dir(array))
            
    array.insockets[0].connected = value1.outsockets[0]
    array.insockets[1].connected = value2.outsockets[0]
    array.insockets[2].connected = value3.outsockets[0]

    switch.insockets[1].connected = array.outsockets[0]

    test = TestCase()

    print("Test1:")
    switch.insockets[0].value = 0
    cache = MT.cache.DataCache(switch.outsockets[0])
    test.equal(cache.getOutput(), value1.insockets[0].value)

    print("Test2:")
    switch.insockets[0].value = 1
    MT.cache.DataCache.invalidate(switch)
    cache = MT.cache.DataCache(switch.outsockets[0])
    test.equal(cache.getOutput(), value2.insockets[0].value)

    print("Test3:")
    switch.insockets[0].value = 2
    MT.cache.DataCache.invalidate(switch)
    cache = MT.cache.DataCache(switch.outsockets[0])
    test.equal(cache.getOutput(), value3.insockets[0].value)

    return test.exit()
예제 #11
0
def testSwitchNode():
    value1 = MT.createNode("Values.Float Value")
    value2 = MT.createNode("Values.Float Value")
    value3 = MT.createNode("Values.Float Value")

    value1.insockets[0].value = 1
    value2.insockets[0].value = 3
    value3.insockets[0].value = 6

    switch = MT.createNode("General.Switch")

    MT.project.root.addNode(value1)
    MT.project.root.addNode(value2)
    MT.project.root.addNode(value3)
    MT.project.root.addNode(switch)

    # find array converter ... this is still kinda ugly
    array = None
    for child in switch.insockets[1].childNodes:
        if child.name == "ArrayNode":
            array = child
            break

    print(array.type)
    print(dir(array))

    array.insockets[0].connected = value1.outsockets[0]
    array.insockets[1].connected = value2.outsockets[0]
    array.insockets[2].connected = value3.outsockets[0]

    switch.insockets[1].connected = array.outsockets[0]

    test = TestCase()

    print("Test1:")
    switch.insockets[0].value = 0
    cache = MT.cache.DataCache(switch.outsockets[0])
    test.equal(cache.getOutput(), value1.insockets[0].value)

    print("Test2:")
    switch.insockets[0].value = 1
    MT.cache.DataCache.invalidate(switch)
    cache = MT.cache.DataCache(switch.outsockets[0])
    test.equal(cache.getOutput(), value2.insockets[0].value)

    print("Test3:")
    switch.insockets[0].value = 2
    MT.cache.DataCache.invalidate(switch)
    cache = MT.cache.DataCache(switch.outsockets[0])
    test.equal(cache.getOutput(), value3.insockets[0].value)

    return test.exit()
예제 #12
0
def testConnectSockets():
    add = MT.createNode("Math.Add")
    add2 = MT.createNode("Math.Add")

    MT.project.root.addNode(add)
    MT.project.root.addNode(add2)

    add.insockets[0].connected = add2.outsockets[0]

    test = TestCase()
    test.equal(add.insockets[0].connected.ptr, add2.outsockets[0].ptr)

    return test.exit();
예제 #13
0
def testForLoopCache():
    test = TestCase()

    loop = MT.createNode("General.For")
    MT.project.root.addNode(loop)

    loop.insockets[0].value = 0
    loop.insockets[1].value = 10
    loop.insockets[2].value = 1

    add = MT.createNode("Math.Add")
    loop.graph.addNode(add)
    test.equal(len(loop.graph[2].insockets), 0,
               "outsockets of loop container before (direct) connection")
    test.equal(len(loop.graph[1].outsockets), 1,
               "looped insockets node has too many sockets")
    loopsocket = loop.graph[1].outsockets[0]
    add.insockets[0].connected = loopsocket
    test.equal(len(loop.graph[2].insockets), 1,
               "outsockets of loop container before (indirect) connection")
    add.insockets[1].value = 1

    loop.graph[2].insockets[0].connected = add.outsockets[0]

    loop.insockets[3].value = 1

    test.equal(add.outsockets[0].type, "INTEGER", "output of Add")
    test.equal(add.insockets[0].type, "INTEGER", "1st input of Add")
    test.equal(add.insockets[1].type, "INTEGER", "2nd input of Add")
    test.equal(loop.outsockets[0].type, "INTEGER", "output of ForNode")
    test.equal(loop.insockets[3].type, "INTEGER",
               "input of startvalue into ForLoop")
    test.equal(loop.graph[1].outsockets[0].type, "INTEGER",
               "input of ForLoop Container")
    test.equal(loop.graph[2].insockets[0].type, "INTEGER",
               "output of ForLoop Container")
    test.equal(len(loop.graph), 4, "nodes inside loop container")
    test.equal(len(loop.graph[0].outsockets), 4, "static loop inputs")
    test.equal(len(loop.graph[1].outsockets), 2, "looped inputs")
    if not test.equal(len(loop.graph[2].insockets), 1, "loop outputs"):
        print("the sockets on this node: {}".format(
            [s.name for s in loop.graph[2].insockets]))
    test.equal(len(loop.outsockets), 1, "number of outsockes on forloop node")
    test.equal(len(loop.insockets), 4, "number of insockets on forloop node")

    cache = MT.cache.DataCache(loop.outsockets[0])

    expected_result = 11

    test.equal(cache.getOutput(), expected_result, "Loop Result")
    return test.exit()
예제 #14
0
def testSaveProject():
    node = MT.createNode("Math.Add")
    node1 = MT.createNode("Values.Float Value")
    node2 = MT.createNode("Values.Int Value")

    MT.project.root.addNode(node)
    MT.project.root.addNode(node1)
    MT.project.root.addNode(node2)

    now = datetime.datetime.now()
    MT.project.filename = "projectTest" + now.strftime("%d%m%y%H%M%S") + ".mt"
    MT.project.save()

    return os.path.exists(MT.project.filename)
예제 #15
0
def testSaveProject():
    node = MT.createNode("Math.Add")
    node1 = MT.createNode("Values.Float Value")
    node2 = MT.createNode("Values.Int Value")

    MT.project.root.addNode(node)
    MT.project.root.addNode(node1)
    MT.project.root.addNode(node2)

    now = datetime.datetime.now()
    MT.project.filename = "projectTest" + now.strftime("%d%m%y%H%M%S") + ".mt"
    MT.project.save()

    return os.path.exists(MT.project.filename)
예제 #16
0
파일: node.py 프로젝트: taroyuyu/MindTree
    def dropEvent(self, event):
        nodeLabel = str(event.mimeData().text())
        event.mimeData().setText("")
        self.drop = False

        if nodeLabel == "":
            return

        _node = MT.createNode(nodeLabel)

        if _node is not None:
            self.scene().space.addNode(_node)
            scenePos = self.mapToScene(event.pos())
            nw = NodeDesigner.width
            nh = NodeDesigner.height
            _node.pos = (scenePos.x() - nw / 2, scenePos.y() - nh / 2)

            #link it
            #find sockets this corresponds to
            insocket = None
            for socket in self.start.data.insockets:
                if (socket.connected is not None
                        and socket.connected.node.ptr == self.end.data.ptr):
                    insocket = socket
                    break

            out = insocket.connected

            #find new matching insocket and link
            insockets = MT.getCompatibleSockets(out, node_)

            if len(insockets) == 1:
                insockets[0].connected = out
            else:
                menu = QMenu()
                for socket in insockets:
                    action = menu.addAction(socket.name)

                    def connect():
                        socket.connected = out

                    action.triggered.connect(connect)
                menu.exec_(event.screenPos())

            outsockets = list(
                filter(lambda o: MT.isCompatible(insocket, o),
                       _node.outsockets))

            if len(outsockets) == 1:
                insocket.connected = outsockets[0]
            else:
                menu = QMenu()
                for socket in outsockets:
                    action = menu.addAction(socket.name)

                    def connect():
                        insocket.connected = socket

                    action.triggered.connect(connect)
                menu.exec_(event.screenPos())
예제 #17
0
def testTimeline():
   timelinenode = MT.createNode("Values.Frame")
   floatnode = MT.createNode("Values.Float Value")

   floatnode.insockets[0].connected = timelinenode.outsockets[0]

   cache = MT.cache.DataCache(floatnode.outsockets[0])
   print("initial frame value as {}: {}".format(cache.type, cache.getOutput()))
   
   MT.timeline.setFrame(44)
   MT.cache.DataCache.invalidate(timelinenode)
   cache = MT.cache.DataCache(floatnode.outsockets[0])
   print("new cached frame value as %s: %d" % (cache.type, cache.getOutput()))
   print("new frame value: %d" % (MT.timeline.frame()))

   return int(cache.getOutput()) == 44
예제 #18
0
def testInheritSocketTypeContainer():
    test = TestCase()
    container = MT.createNode("General.Container")
    floatValue = MT.createNode("Values.Float Value")
    intValue = MT.createNode("Values.Int Value")

    MT.project.root.addNode(container)
    container.graph.addNode(floatValue)

    container.graph[1].insockets[0].connected = floatValue.outsockets[0]
    intValue.insockets[0].connected = container.graph[0].outsockets[0]

    test.equal(container.graph[1].insockets[0].type, "FLOAT")
    test.equal(container.outsockets[0].type, "FLOAT")
    test.equal(container.graph[0].outsockets[0].type, "INTEGER", "input sockets of container graph")
    test.equal(container.insockets[0].type, "INTEGER", "input of container itself")
    return test.exit()
예제 #19
0
def testFloatCache():
    '''Creating two add nodes, connecting them and trying to get a value from it'''
    add = MT.createNode("Math.Add")
    valuenode = MT.createNode("Values.Float Value")
    valuenode2 = MT.createNode("Values.Float Value")

    add.insockets[0].name = "add.in01"

    valuenode.insockets[0].name = "valuenode.in01"
    valuenode.insockets[0].value = 5.
    valuenode2.insockets[0].name = "valuenode2.in01"
    valuenode2.insockets[0].value = 8.

    MT.project.root.addNode(add)
    MT.project.root.addNode(valuenode)
    MT.project.root.addNode(valuenode2)
    pos = valuenode.pos
    valuenode.pos = (pos[0] - 150, pos[1] - 50)
    valuenode2.pos = (pos[0] - 150, pos[1] + 50)

    add.insockets[0].connected = valuenode.outsockets[0]
    add.insockets[1].connected = valuenode2.outsockets[0]
    add.insockets[2].value = 12.

    cache = MT.cache.DataCache(add.outsockets[0])

    test = TestCase()
    test.equal(len(MT.project.root), 3, "root space size")
    test.equal(len(MT.project.root[0].outsockets), 1, "add outsockets")
    test.equal(len(MT.project.root[0].insockets), 3, "add insockets")
    test.equal(len(MT.project.root[1].outsockets), 1,
               "float value 1 outsockets")
    test.equal(len(MT.project.root[1].insockets), 1, "float value 1 insockets")
    test.equal(len(MT.project.root[2].outsockets), 1,
               "float value 2 outsockets")
    test.equal(len(MT.project.root[2].insockets), 1, "float value 2 insockets")
    test.equal(MT.project.root[1].insockets[0].value, 5., "float value 1")
    test.equal(MT.project.root[2].insockets[0].value, 8., "float value 2")
    test.equal(MT.project.root[0].insockets[2].value, 12., "add input value")

    print("resulting value: %d" % cache.getOutput())
    print("expected value: %d" % (12 + 5 + 8))
    test.equal((12 + 5 + 8), cache.getOutput(), "cache output")
    return test.exit()
예제 #20
0
def testForLoopCache():
    test = TestCase()

    loop = MT.createNode("General.For")
    MT.project.root.addNode(loop)

    loop.insockets[0].value = 0
    loop.insockets[1].value = 10
    loop.insockets[2].value = 1

    add = MT.createNode("Math.Add")
    loop.graph.addNode(add)
    test.equal(len(loop.graph[2].insockets), 0, "outsockets of loop container before (direct) connection")
    test.equal(len(loop.graph[1].outsockets), 1, "looped insockets node has too many sockets")
    loopsocket = loop.graph[1].outsockets[0]
    add.insockets[0].connected = loopsocket
    test.equal(len(loop.graph[2].insockets), 1, "outsockets of loop container before (indirect) connection")
    add.insockets[1].value = 1

    loop.graph[2].insockets[0].connected = add.outsockets[0]

    loop.insockets[3].value = 1

    test.equal(add.outsockets[0].type, "INTEGER", "output of Add")
    test.equal(add.insockets[0].type, "INTEGER", "1st input of Add")
    test.equal(add.insockets[1].type, "INTEGER", "2nd input of Add")
    test.equal(loop.outsockets[0].type, "INTEGER", "output of ForNode")
    test.equal(loop.insockets[3].type, "INTEGER", "input of startvalue into ForLoop")
    test.equal(loop.graph[1].outsockets[0].type, "INTEGER", "input of ForLoop Container")
    test.equal(loop.graph[2].insockets[0].type, "INTEGER", "output of ForLoop Container")
    test.equal(len(loop.graph), 4, "nodes inside loop container")
    test.equal(len(loop.graph[0].outsockets), 4, "static loop inputs")
    test.equal(len(loop.graph[1].outsockets), 2, "looped inputs")
    if not test.equal(len(loop.graph[2].insockets), 1, "loop outputs"):
        print("the sockets on this node: {}".format([s.name for s in loop.graph[2].insockets]))
    test.equal(len(loop.outsockets), 1, "number of outsockes on forloop node")
    test.equal(len(loop.insockets), 4, "number of insockets on forloop node")

    cache = MT.cache.DataCache(loop.outsockets[0])

    expected_result = 11

    test.equal(cache.getOutput(), expected_result, "Loop Result")
    return test.exit()
예제 #21
0
파일: node.py 프로젝트: viviwu/MindTree
    def dropEvent(self, event):
        nodeLabel = str(event.mimeData().text())
        event.mimeData().setText("")
        self.drop = False

        if nodeLabel == "":
            return

        _node = MT.createNode(nodeLabel)

        if _node is not None:
            self.scene().space.addNode(_node)
            scenePos = self.mapToScene(event.pos())
            nw = NodeDesigner.width
            nh = NodeDesigner.height
            _node.pos = (scenePos.x() - nw/2, scenePos.y() - nh/2)

            #link it
            #find sockets this corresponds to
            insocket = None
            for socket in self.start.data.insockets:
                if (socket.connected is not None
                        and socket.connected.node.ptr == self.end.data.ptr):
                    insocket = socket
                    break

            out = insocket.connected

            #find new matching insocket and link
            insockets = MT.getCompatibleSockets(out, node_)

            if len(insockets) == 1:
                insockets[0].connected = out
            else:
                menu = QMenu()
                for socket in insockets:
                    action = menu.addAction(socket.name)
                    def connect():
                        socket.connected = out

                    action.triggered.connect(connect)
                menu.exec_(event.screenPos())

            outsockets = list(filter(lambda o: MT.isCompatible(insocket, o), _node.outsockets))

            if len(outsockets) == 1:
                insocket.connected = outsockets[0]
            else:
                menu = QMenu()
                for socket in outsockets:
                    action = menu.addAction(socket.name)
                    def connect():
                        insocket.connected = socket

                    action.triggered.connect(connect)
                menu.exec_(event.screenPos())
예제 #22
0
def testFloatCache():
    """Creating two add nodes, connecting them and trying to get a value from it"""
    add = MT.createNode("Math.Add")
    valuenode = MT.createNode("Values.Float Value")
    valuenode2 = MT.createNode("Values.Float Value")

    add.insockets[0].name = "add.in01"

    valuenode.insockets[0].name = "valuenode.in01"
    valuenode.insockets[0].value = 5.0
    valuenode2.insockets[0].name = "valuenode2.in01"
    valuenode2.insockets[0].value = 8.0

    MT.project.root.addNode(add)
    MT.project.root.addNode(valuenode)
    MT.project.root.addNode(valuenode2)
    pos = valuenode.pos
    valuenode.pos = (pos[0] - 150, pos[1] - 50)
    valuenode2.pos = (pos[0] - 150, pos[1] + 50)

    add.insockets[0].connected = valuenode.outsockets[0]
    add.insockets[1].connected = valuenode2.outsockets[0]
    add.insockets[2].value = 12.0

    cache = MT.cache.DataCache(add.outsockets[0])

    test = TestCase()
    test.equal(len(MT.project.root), 3, "root space size")
    test.equal(len(MT.project.root[0].outsockets), 1, "add outsockets")
    test.equal(len(MT.project.root[0].insockets), 3, "add insockets")
    test.equal(len(MT.project.root[1].outsockets), 1, "float value 1 outsockets")
    test.equal(len(MT.project.root[1].insockets), 1, "float value 1 insockets")
    test.equal(len(MT.project.root[2].outsockets), 1, "float value 2 outsockets")
    test.equal(len(MT.project.root[2].insockets), 1, "float value 2 insockets")
    test.equal(MT.project.root[1].insockets[0].value, 5.0, "float value 1")
    test.equal(MT.project.root[2].insockets[0].value, 8.0, "float value 2")
    test.equal(MT.project.root[0].insockets[2].value, 12.0, "add input value")

    print("resulting value: %d" % cache.getOutput())
    print("expected value: %d" % (12 + 5 + 8))
    test.equal((12 + 5 + 8), cache.getOutput(), "cache output")
    return test.exit()
예제 #23
0
def testForeachLoopCache():
    loop = MT.createNode("General.Foreach")
    listNode = MT.createNode("General.Create List")
    add = MT.createNode("Math.Add")
    value = MT.createNode("Values.Int Value")

    listNode.insockets[0].value = 12.5
    listNode.insockets[1].value = 10

    value.insockets[0].value = 2

    loop.insockets[0].connected = listNode.outsockets[0]

    test = TestCase()
    
    loopInputNode = loop.graph[1]

    test.equal(listNode.insockets[0].type, "FLOAT")
    test.equal(listNode.outsockets[0].type, "LIST:FLOAT")
    test.equal(len(loopInputNode.outsockets), 1, "inputs to the foreach node")

    add.insockets[0].connected = loopInputNode.outsockets[0]
    add.insockets[1].connected = value.outsockets[0]

    loop.graph[2].insockets[0].connected = add.outsockets[0]

    MT.project.root.addNode(loop)
    MT.project.root.addNode(listNode)

    loop.graph.addNode(add)
    loop.graph.addNode(value)

    cache = MT.cache.DataCache(loop.outsockets[0])

    output = cache.getOutput()
    test.equal(add.insockets[0].type, "FLOAT")
    test.equal(add.insockets[1].type, "INTEGER")
    test.equal(loop.graph[1].outsockets[0].type, "FLOAT")
    test.equal(len(output), 10)
    test.equal(cache.getOutput(), [14.5] * 10) 
    return test.exit()
예제 #24
0
def testForeachLoopCache():
    loop = MT.createNode("General.Foreach")
    listNode = MT.createNode("General.Create List")
    add = MT.createNode("Math.Add")
    value = MT.createNode("Values.Int Value")

    listNode.insockets[0].value = 12.5
    listNode.insockets[1].value = 10

    value.insockets[0].value = 2

    loop.insockets[0].connected = listNode.outsockets[0]

    test = TestCase()

    loopInputNode = loop.graph[1]

    test.equal(listNode.insockets[0].type, "FLOAT")
    test.equal(listNode.outsockets[0].type, "LIST:FLOAT")
    test.equal(len(loopInputNode.outsockets), 1, "inputs to the foreach node")

    add.insockets[0].connected = loopInputNode.outsockets[0]
    add.insockets[1].connected = value.outsockets[0]

    loop.graph[2].insockets[0].connected = add.outsockets[0]

    MT.project.root.addNode(loop)
    MT.project.root.addNode(listNode)

    loop.graph.addNode(add)
    loop.graph.addNode(value)

    cache = MT.cache.DataCache(loop.outsockets[0])

    output = cache.getOutput()
    test.equal(add.insockets[0].type, "FLOAT")
    test.equal(add.insockets[1].type, "INTEGER")
    test.equal(loop.graph[1].outsockets[0].type, "FLOAT")
    test.equal(len(output), 10)
    test.equal(cache.getOutput(), [14.5] * 10)
    return test.exit()
예제 #25
0
def testSocketProperties():
    value = MT.createNode("Values.Float Value")
    value.insockets[0].value = 2.5
    cache = MT.cache.DataCache(value.outsockets[0])
    success = cache.getData(0) == 2.5

    value = MT.createNode("Values.Int Value")
    value.insockets[0].value = 2
    cache = MT.cache.DataCache(value.outsockets[0])
    success = success and cache.getData(0) == 2

    value = MT.createNode("Values.Color Value")
    value.insockets[0].value = (1, 0, 0, 1)
    cache = MT.cache.DataCache(value.outsockets[0])
    success = success and cache.getData(0) == (1, 0, 0, 1)

    value = MT.createNode("Values.String Value")
    value.insockets[0].value = "bla bla HUBSGHDJ"
    cache = MT.cache.DataCache(value.outsockets[0])
    success = success and cache.getData(0) == "bla bla HUBSGHDJ"
    return success
예제 #26
0
def testSocketProperties():
    value = MT.createNode("Values.Float Value")
    value.insockets[0].value = 2.5
    cache = MT.cache.DataCache(value.outsockets[0])
    success = cache.getData(0) == 2.5

    value = MT.createNode("Values.Int Value")
    value.insockets[0].value = 2
    cache = MT.cache.DataCache(value.outsockets[0])
    success = success and cache.getData(0) == 2

    value = MT.createNode("Values.Color Value")
    value.insockets[0].value = (1, 0, 0, 1)
    cache = MT.cache.DataCache(value.outsockets[0])
    success = success and cache.getData(0) == (1, 0, 0, 1)

    value = MT.createNode("Values.String Value")
    value.insockets[0].value = "bla bla HUBSGHDJ"
    cache = MT.cache.DataCache(value.outsockets[0])
    success = success and cache.getData(0) == "bla bla HUBSGHDJ"
    return success
예제 #27
0
    def _createNetwork(self):
        self.add = MT.createNode("Math.Add")
        self.add2 = MT.createNode("Math.Add")
        self.add3 = MT.createNode("Math.Add")

        self.valuenode = MT.createNode("Values.Float Value")
        self.valuenode2 = MT.createNode("Values.Float Value")
        self.valuenode3 = MT.createNode("Values.Float Value")

        MT.project.root.addNode(self.valuenode3)
        MT.project.root.addNode(self.add)
        MT.project.root.addNode(self.add2)
        MT.project.root.addNode(self.add3)
        MT.project.root.addNode(self.valuenode)
        MT.project.root.addNode(self.valuenode2)
        pos = self.valuenode.pos
        self.valuenode.pos = (pos[0] - 150, pos[1] - 50)
        self.valuenode2.pos = (pos[0] - 150, pos[1] + 50)

        self.add.insockets[0].connected = self.valuenode.outsockets[0]
        self.add.insockets[1].connected = self.valuenode2.outsockets[0]
        self.add.insockets[2].connected = self.valuenode3.outsockets[0]

        self.add2.insockets[0].connected = self.add.outsockets[0]
        self.add3.insockets[0].connected = self.add2.outsockets[0]
예제 #28
0
    def _createNetwork(self):
        self.add = MT.createNode("Math.Add")
        self.add2 = MT.createNode("Math.Add")
        self.add3 = MT.createNode("Math.Add")

        self.valuenode = MT.createNode("Values.Float Value")
        self.valuenode2 = MT.createNode("Values.Float Value")
        self.valuenode3 = MT.createNode("Values.Float Value")

        MT.project.root.addNode(self.valuenode3)
        MT.project.root.addNode(self.add)
        MT.project.root.addNode(self.add2)
        MT.project.root.addNode(self.add3)
        MT.project.root.addNode(self.valuenode)
        MT.project.root.addNode(self.valuenode2)
        pos = self.valuenode.pos
        self.valuenode.pos = (pos[0] - 150, pos[1] - 50)
        self.valuenode2.pos = (pos[0] - 150, pos[1] + 50)

        self.add.insockets[0].connected = self.valuenode.outsockets[0]
        self.add.insockets[1].connected = self.valuenode2.outsockets[0]
        self.add.insockets[2].connected = self.valuenode3.outsockets[0]

        self.add2.insockets[0].connected = self.add.outsockets[0]
        self.add3.insockets[0].connected = self.add2.outsockets[0]
예제 #29
0
def testCreateList():
    createListNode = MT.createNode("General.Create List")
    floatValueNode = MT.createNode("Values.Float Value")
    intValueNode = MT.createNode("Values.Int Value")

    MT.project.root.addNode(createListNode)
    MT.project.root.addNode(floatValueNode)
    MT.project.root.addNode(intValueNode)
    
    floatValueNode.insockets[0].value = 5.0
    intValueNode.insockets[0].value = 10

    createListNode.insockets[0].connected = floatValueNode.outsockets[0]
    createListNode.insockets[1].connected = intValueNode.outsockets[0]

    cache = MT.cache.DataCache(createListNode.outsockets[0])

    test = TestCase()
    test.equal(cache.getOutput(), [5, 5, 5, 5, 5, 5, 5, 5, 5, 5])
    test.equal(floatValueNode.insockets[0].value, 5.0)
    test.equal(intValueNode.insockets[0].value, 10)

    return test.exit()
예제 #30
0
def createContainer(nodes):
    space = nodes[0].space

    inconnections = {}
    outconnections = {}

    container = MT.createNode("General.Container")
    ci = container.graph[0]
    co = container.graph[1]

    middle = (0, 0)
    for n in nodes:
        middle = (middle[0] + n.pos[0], middle[1] + n.pos[1])

        #find ingoing node connections
        for socket in n.insockets:
            if not socket.connected:
                continue

            cntd = socket.connected
            if not cntd.node in nodes:
                inconnections[socket] = cntd

        #find outgoing node connections
        for socket in n.outsockets:
            if len(socket.cntdSockets) == 0:
                continue
            for s in socket.cntdSockets:
                if not s.node in nodes:
                    outconnections[s] = socket

        #remove nodes from current space
        space.removeNode(n)

        container.graph.addNode(n)

    space.addNode(container)

    #reconnect incoming and outgoing connections
    for isocket, osocket in inconnections.items():
        isocket.connected = ci.outsockets[-1]
        container.insockets[-1].connected = osocket

    for isocket, osocket in outconnections.items():
        co.insockets[-1].connected = osocket
        isocket.connected = container.outsockets[-1]

    middle = (middle[0] / 2, middle[1] / 2)

    container.pos = middle
예제 #31
0
def createContainer(nodes):
    space = nodes[0].space

    inconnections = {}
    outconnections = {}

    container = MT.createNode("General.Container")
    ci = container.graph[0]
    co = container.graph[1]

    middle = (0, 0)
    for n in nodes:
        middle = (middle[0] + n.pos[0], middle[1] + n.pos[1])

        #find ingoing node connections
        for socket in n.insockets:
            if not socket.connected:
                continue

            cntd = socket.connected
            if not cntd.node in nodes:
                inconnections[socket] = cntd

        #find outgoing node connections
        for socket in n.outsockets:
            if len(socket.cntdSockets) == 0:
                continue
            for s in socket.cntdSockets:
                if not s.node in nodes:
                    outconnections[s] = socket

        #remove nodes from current space
        space.removeNode(n)

        container.graph.addNode(n)

    space.addNode(container)

    #reconnect incoming and outgoing connections
    for isocket, osocket in inconnections.items():
        isocket.connected = ci.outsockets[-1]
        container.insockets[-1].connected = osocket

    for isocket, osocket in outconnections.items():
        co.insockets[-1].connected = osocket
        isocket.connected = container.outsockets[-1]

    middle = (middle[0] / 2, middle[1] / 2)

    container.pos = middle
예제 #32
0
def testLoadProject():
    MT.newProject()
    node = MT.createNode("Math.Add")
    node1 = MT.createNode("Values.Float Value")
    node2 = MT.createNode("Values.Int Value")
    node3 = MT.createNode("General.Container")

    node.insockets[0].connected = node1.outsockets[0]

    node.pos = (0, 0)
    node1.pos = (0, 20)
    node2.pos = (0, 40)
    node3.pos = (0, 60)

    node4 = MT.createNode("Values.String Value")
    node5 = MT.createNode("Values.Vector3D")
    node6 = MT.createNode("Values.Vector2D")
    node7 = MT.createNode("Values.Color Value")
    node8 = MT.createNode("Objects.Transform")
    node9 = MT.createNode("Objects.Lights.Spot Light")

    node4.pos = (0, 0)
    node5.pos = (0, 20)
    node6.pos = (0, 40)
    node7.pos = (0, 60)
    node8.pos = (0, 80)
    node9.pos = (0, 100)

    MT.project.root.addNode(node)
    MT.project.root.addNode(node1)
    MT.project.root.addNode(node2)
    MT.project.root.addNode(node3)

    node3.graph.addNode(node4)
    node3.graph.addNode(node5)
    node3.graph.addNode(node6)
    node3.graph.addNode(node7)
    node3.graph.addNode(node8)
    node3.graph.addNode(node9)

    graphsize = len(node3.graph)

    node9.insockets[6].value = True

    node1.insockets[0].value = 5.7
    node2.insockets[0].value = 14

    now = datetime.datetime.now()
    filename =  "projectTest.mt"
    MT.project.filename = filename
    print("saving project: " + filename)
    MT.project.save()

    print()
    MT.newProject()
    print("open project: " + filename)
    MT.openProject(filename)

    node = MT.project.root[0]
    node1 = MT.project.root[1]
    node2 = MT.project.root[2]
    node3 = MT.project.root[3]

    node4 = MT.project.root[3].graph[2]
    node5 = MT.project.root[3].graph[3]
    node6 = MT.project.root[3].graph[4]
    node7 = MT.project.root[3].graph[5]
    node8 = MT.project.root[3].graph[6]
    node9 = MT.project.root[3].graph[7]
    
    test = TestCase()

    test.equal(len(MT.project.root), 4, "Project size")
    test.contains("Add", node.name)
    test.contains("Float Value", node1.name)
    test.contains("Int Value", node2.name)
    test.contains("Container", node3.name)
    test.equal((0, 0), node.pos)
    test.equal((0, 20), node1.pos)
    test.equal((0, 40), node2.pos)
    test.equal((0, 60), node3.pos)
    test.equal((0, 0), node4.pos)
    test.equal((0, 20), node5.pos)
    test.equal((0, 40), node6.pos)
    test.equal((0, 60), node7.pos)
    test.equal((0, 80), node8.pos)
    test.equal(node.insockets[0].connected, node1.outsockets[0], "add insocket and float value out")
    test.equal(len(node3.graph), graphsize)
    test.contains("String Value", node4.name)
    test.contains("Vector3D", node5.name)
    test.contains("Vector2D", node6.name)
    test.contains("Color Value", node7.name)
    test.contains("Transform", node8.name)
    test.contains("Spot Light", node9.name)
    test.equal(len(node8.insockets), 2, "number of insockets")
    test.equal(node2.insockets[0].value, 14)
    test.floatEqual(node1.insockets[0].value, 5.7, 0.00001)
    test.equal(node9.insockets[5].value, False)
    test.equal(node9.insockets[6].value, True)
    test.equal(node9.insockets[7].value, 512)
    return test.exit()
예제 #33
0
def testContainerCache():
    '''Creating two add nodes, connecting them and trying to get a value from it'''
    add = MT.createNode("Math.Add")
    valuenode = MT.createNode("Values.Float Value")
    valuenode2 = MT.createNode("Values.Float Value")
    valuenode3 = MT.createNode("Values.Float Value")
    container = MT.createNode("General.Container")
    output = container.graph[1]
    inputnode = container.graph[0]

    value1 = 5.
    value2 = 8.
    value3 = 12.
    value4 = 23.

    add.insockets[0].name = "add.in01"

    valuenode.insockets[0].name = "valuenode.in01"
    valuenode.insockets[0].value = value1
    valuenode2.insockets[0].name = "valuenode2.in01"
    valuenode2.insockets[0].value = value2
    valuenode3.insockets[0].value = value4

    MT.project.root.addNode(container)
    MT.project.root.addNode(valuenode3)
    container.graph.addNode(add)
    container.graph.addNode(valuenode)
    container.graph.addNode(valuenode2)
    pos = valuenode.pos
    valuenode.pos = (pos[0] - 150, pos[1] - 50)
    valuenode2.pos = (pos[0] - 150, pos[1] + 50)

    add.insockets[0].connected = valuenode.outsockets[0]
    add.insockets[1].connected = valuenode2.outsockets[0]
    add.insockets[2].connected = inputnode.outsockets[0]

    output.insockets[0].connected = add.outsockets[0]
    container.insockets[0].connected = valuenode3.outsockets[0]
    add.insockets[3].value = value3

    cache = MT.cache.DataCache(container.outsockets[0])

    expected_result = value1 + value2 + value3 + value4

    test = TestCase()
    test.equal(cache.getOutput(), expected_result)
    test.equal(container.insockets[0].type, valuenode3.outsockets[0].type)
    test.equal(add.insockets[0].type, valuenode.outsockets[0].type)
    test.equal(add.insockets[1].type, valuenode2.outsockets[0].type)
    test.equal(add.insockets[2].type, inputnode.outsockets[0].type)
    test.equal(inputnode.outsockets[0].type, container.insockets[0].type)
    test.equal(container.insockets[0].type, "FLOAT")
    test.equal(add.insockets[0].type, "FLOAT")
    test.equal(add.insockets[1].type, "FLOAT")
    test.equal(add.insockets[2].type, "FLOAT")
    test.equal(inputnode.outsockets[0].type, "FLOAT")

    valuenode.insockets[0].value = 10.
    MT.cache.DataCache.invalidate(valuenode)
    cache = MT.cache.DataCache(container.outsockets[0])
    expected_result = 10. + value2 + value3 + value4
    test.equal(cache.getOutput(), expected_result, "invalidation")

    return test.exit()
예제 #34
0
def testWhileLoopCache():
    loop = MT.createNode("General.While")
    MT.project.root.addNode(loop)

    test = TestCase()
    return test.exit()
예제 #35
0
def testContainerCache():
    '''Creating two add nodes, connecting them and trying to get a value from it'''
    add = MT.createNode("Math.Add")
    valuenode = MT.createNode("Values.Float Value")
    valuenode2 = MT.createNode("Values.Float Value")
    valuenode3 = MT.createNode("Values.Float Value")
    container = MT.createNode("General.Container")
    output = container.graph[1]
    inputnode = container.graph[0]

    value1 = 5.
    value2 = 8.
    value3 = 12.
    value4 = 23.

    add.insockets[0].name = "add.in01"

    valuenode.insockets[0].name = "valuenode.in01"
    valuenode.insockets[0].value = value1
    valuenode2.insockets[0].name = "valuenode2.in01"
    valuenode2.insockets[0].value = value2
    valuenode3.insockets[0].value = value4

    MT.project.root.addNode(container)
    MT.project.root.addNode(valuenode3)
    container.graph.addNode(add)
    container.graph.addNode(valuenode)
    container.graph.addNode(valuenode2)
    pos = valuenode.pos
    valuenode.pos = (pos[0] - 150, pos[1] - 50)
    valuenode2.pos = (pos[0] - 150, pos[1] + 50)

    add.insockets[0].connected = valuenode.outsockets[0]
    add.insockets[1].connected = valuenode2.outsockets[0]
    add.insockets[2].connected = inputnode.outsockets[0]

    output.insockets[0].connected = add.outsockets[0]
    container.insockets[0].connected = valuenode3.outsockets[0]
    add.insockets[3].value = value3

    cache = MT.cache.DataCache(container.outsockets[0])

    expected_result = value1 + value2 + value3 + value4

    test = TestCase()
    test.equal(cache.getOutput(), expected_result)
    test.equal(container.insockets[0].type, valuenode3.outsockets[0].type)
    test.equal(add.insockets[0].type, valuenode.outsockets[0].type)
    test.equal(add.insockets[1].type, valuenode2.outsockets[0].type)
    test.equal(add.insockets[2].type, inputnode.outsockets[0].type)
    test.equal(inputnode.outsockets[0].type, container.insockets[0].type)
    test.equal(container.insockets[0].type, "FLOAT")
    test.equal(add.insockets[0].type, "FLOAT")
    test.equal(add.insockets[1].type, "FLOAT")
    test.equal(add.insockets[2].type, "FLOAT")
    test.equal(inputnode.outsockets[0].type, "FLOAT")

    valuenode.insockets[0].value = 10.
    MT.cache.DataCache.invalidate(valuenode)
    cache = MT.cache.DataCache(container.outsockets[0])
    expected_result = 10. + value2 + value3 + value4
    test.equal(cache.getOutput(), expected_result, "invalidation")

    return test.exit()
예제 #36
0
def testLoadProject():
    MT.newProject()
    node = MT.createNode("Math.Add")
    node1 = MT.createNode("Values.Float Value")
    node2 = MT.createNode("Values.Int Value")
    node3 = MT.createNode("General.Container")

    node.insockets[0].connected = node1.outsockets[0]

    node.pos = (0, 0)
    node1.pos = (0, 20)
    node2.pos = (0, 40)
    node3.pos = (0, 60)

    node4 = MT.createNode("Values.String Value")
    node5 = MT.createNode("Values.Vector3D")
    node6 = MT.createNode("Values.Vector2D")
    node7 = MT.createNode("Values.Color Value")
    node8 = MT.createNode("Objects.Transform")
    node9 = MT.createNode("Objects.Lights.Spot Light")

    node4.pos = (0, 0)
    node5.pos = (0, 20)
    node6.pos = (0, 40)
    node7.pos = (0, 60)
    node8.pos = (0, 80)
    node9.pos = (0, 100)

    MT.project.root.addNode(node)
    MT.project.root.addNode(node1)
    MT.project.root.addNode(node2)
    MT.project.root.addNode(node3)

    node3.graph.addNode(node4)
    node3.graph.addNode(node5)
    node3.graph.addNode(node6)
    node3.graph.addNode(node7)
    node3.graph.addNode(node8)
    node3.graph.addNode(node9)

    graphsize = len(node3.graph)

    node9.insockets[6].value = True

    node1.insockets[0].value = 5.7
    node2.insockets[0].value = 14

    now = datetime.datetime.now()
    filename = "projectTest.mt"
    MT.project.filename = filename
    print("saving project: " + filename)
    MT.project.save()

    print()
    MT.newProject()
    print("open project: " + filename)
    MT.openProject(filename)

    node = MT.project.root[0]
    node1 = MT.project.root[1]
    node2 = MT.project.root[2]
    node3 = MT.project.root[3]

    node4 = MT.project.root[3].graph[2]
    node5 = MT.project.root[3].graph[3]
    node6 = MT.project.root[3].graph[4]
    node7 = MT.project.root[3].graph[5]
    node8 = MT.project.root[3].graph[6]
    node9 = MT.project.root[3].graph[7]

    test = TestCase()

    test.equal(len(MT.project.root), 4, "Project size")
    test.contains("Add", node.name)
    test.contains("Float Value", node1.name)
    test.contains("Int Value", node2.name)
    test.contains("Container", node3.name)
    test.equal((0, 0), node.pos)
    test.equal((0, 20), node1.pos)
    test.equal((0, 40), node2.pos)
    test.equal((0, 60), node3.pos)
    test.equal((0, 0), node4.pos)
    test.equal((0, 20), node5.pos)
    test.equal((0, 40), node6.pos)
    test.equal((0, 60), node7.pos)
    test.equal((0, 80), node8.pos)
    test.equal(node.insockets[0].connected, node1.outsockets[0],
               "add insocket and float value out")
    test.equal(len(node3.graph), graphsize)
    test.contains("String Value", node4.name)
    test.contains("Vector3D", node5.name)
    test.contains("Vector2D", node6.name)
    test.contains("Color Value", node7.name)
    test.contains("Transform", node8.name)
    test.contains("Spot Light", node9.name)
    test.equal(len(node8.insockets), 2, "number of insockets")
    test.equal(node2.insockets[0].value, 14)
    test.floatEqual(node1.insockets[0].value, 5.7, 0.00001)
    test.equal(node9.insockets[5].value, False)
    test.equal(node9.insockets[6].value, True)
    test.equal(node9.insockets[7].value, 512)
    return test.exit()
예제 #37
0
 def nodeSlot():
     node = MT.createNode(nodeType)
     self.graph.space.addNode(node)
예제 #38
0
def testWhileLoopCache():
    loop = MT.createNode("General.While")
    MT.project.root.addNode(loop)

    test = TestCase()
    return test.exit()
예제 #39
0
 def nodeSlot():
     node = MT.createNode(nodeType)
     self.graph.space.addNode(node)
예제 #40
0
 def dropNode(self, label, pos):
     _node = MT.createNode(label)
     if _node is not None:
         self.scene().space.addNode(_node)
         _node.pos = pos
     return _node
예제 #41
0
파일: graph.py 프로젝트: taroyuyu/MindTree
 def dropNode(self, label, pos):
     _node = MT.createNode(label)
     if _node is not None:
         self.scene().space.addNode(_node)
         _node.pos = pos
     return _node