当前位置: 首页>>代码示例>>Python>>正文


Python MT类代码示例

本文整理汇总了Python中MT的典型用法代码示例。如果您正苦于以下问题:Python MT类的具体用法?Python MT怎么用?Python MT使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MT类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testStringCache

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()
开发者ID:frigge,项目名称:MindTree,代码行数:31,代码来源:stringcachetest.py

示例2: _decrypt

 def _decrypt(self, buf, seed):
     rseed = (seed << 7) ^ 0xA9C36DE1
     MT.sgenrand(rseed)
     buf = bytearray(buf)
     for i in range(len(buf)):
         buf[i] ^= MT.genrand() & 0xFF
     return bytes(buf)
开发者ID:Tachiorz,项目名称:mabinogi_character_simulator,代码行数:7,代码来源:package.py

示例3: __init__

    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)
开发者ID:frigge,项目名称:MindTree,代码行数:25,代码来源:__init__.py

示例4: dropEvent

    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())
开发者ID:viviwu,项目名称:MindTree,代码行数:56,代码来源:node.py

示例5: testSimulation

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()
开发者ID:frigge,项目名称:MindTree,代码行数:56,代码来源:simulationtests.py

示例6: testInheritSocketTypeMath

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()
开发者ID:frigge,项目名称:MindTree,代码行数:11,代码来源:connectsockets.py

示例7: testNewProject

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
开发者ID:frigge,项目名称:MindTree,代码行数:12,代码来源:project_tests.py

示例8: testSwitchNode

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()
开发者ID:frigge,项目名称:MindTree,代码行数:52,代码来源:switchtests.py

示例9: testConnectSockets

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();
开发者ID:frigge,项目名称:MindTree,代码行数:13,代码来源:connectsockets.py

示例10: testSaveProject

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)
开发者ID:frigge,项目名称:MindTree,代码行数:14,代码来源:project_tests.py

示例11: __init__

    def __init__(self,
            data,
            parent=None,
            options=True,
            width=NodeDesigner.width,
            height=NodeDesigner.height):
        QGraphicsSvgItem.__init__(self, parent)
        self.data = data

        self._width = width
        self.height = height

        self.viewed = False

        self._viewSockets = False
        self._visibleSockets = []

        self.setFlag(QGraphicsItem.ItemIsMovable, True)
        self.setFlag(QGraphicsItem.ItemIsFocusable, True)
        self.setFlag(QGraphicsItem.ItemIsSelectable, True)

        self.setFlag(QGraphicsItem.ItemSendsGeometryChanges, True)

        self.setAcceptHoverEvents(True)
        self.setAcceptsHoverEvents(True)
        self.setAcceptDrops(True)

        self.nameBG = NodeNameBG(self)
        self.name = NodeName(self)
        self.nameBG._width = self.name.boundingRect().width()
        self.nameBG.height = self.name.boundingRect().height()

        self.out = []
        pos = width;
        colors = QColor()
        altcolor = False
        for out in self.data.outsockets:
            vis = NodeOutSocket(self, out, altcolor)
            altcolor = not altcolor
            vis.setPos(QPoint(pos, 0))
            pos += vis._width + 2 #slight margin
            self.out.append(vis)

        self.addsocketcb = MT.attachToBoundSignal(data, "outSocketAdded", self.newOutSocket)

        if options:
            self.nodeOptions = NodeOptionsButton(self)
        self.posCB = MT.attachToBoundSignal(data, "nodePositionChanged", self.updatePositionFromData)
开发者ID:viviwu,项目名称:MindTree,代码行数:48,代码来源:node.py

示例12: testTimeline

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
开发者ID:frigge,项目名称:MindTree,代码行数:16,代码来源:timelinetests.py

示例13: testInheritSocketTypeContainer

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()
开发者ID:frigge,项目名称:MindTree,代码行数:17,代码来源:connectsockets.py

示例14: testForLoopCache

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()
开发者ID:frigge,项目名称:MindTree,代码行数:44,代码来源:datacachetests.py

示例15: testFloatCache

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()
开发者ID:frigge,项目名称:MindTree,代码行数:42,代码来源:floatcachetest.py


注:本文中的MT类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。