예제 #1
0
def testNodeDeletion():
    coralApp.init()

    coralApp.createNode("Float", "test", coralApp.findNode("root"))
    coralApp.deleteNodes([coralApp.findNode("root.test")])

    assert _coral.NetworkManager.objectCount() == 1

    coralApp.finalize()
예제 #2
0
def testNodeDeletion():
    coralApp.init()
    
    coralApp.createNode("Float", "test", coralApp.findNode("root"))
    coralApp.deleteNodes([coralApp.findNode("root.test")])
    
    assert _coral.NetworkManager.objectCount() == 1
    
    coralApp.finalize()
예제 #3
0
def testDeletingAttributes():
    coralApp.init()

    root = coralApp.findNode("root")
    n1 = coralApp.createNode("Float", "n1", root)
    n2 = coralApp.createNode("Float", "n2", root)
    n3 = coralApp.createNode("Add", "n3", root)
    n4 = coralApp.createNode("Add", "n4", root)
    n5 = coralApp.createNode("Float", "n5", root)
    n6 = coralApp.createNode("Add", "n6", root)

    _coral.NetworkManager.connect(n1.outputAttributeAt(0),
                                  n3.inputAttributeAt(0))
    _coral.NetworkManager.connect(n2.outputAttributeAt(0),
                                  n3.inputAttributeAt(1))
    _coral.NetworkManager.connect(n3.outputAttributeAt(0),
                                  n4.inputAttributeAt(0))
    _coral.NetworkManager.connect(n5.outputAttributeAt(0),
                                  n4.inputAttributeAt(1))
    _coral.NetworkManager.connect(n3.outputAttributeAt(0),
                                  n6.inputAttributeAt(1))

    coralApp.deleteNodes([n3, n5, n6])

    coralApp.finalize()
예제 #4
0
파일: nodeBox.py 프로젝트: achayan/coraline
    def _createFromItemData(itemData):
        from nodeEditor import nodeEditor
        
        sceneItem = None
        className = itemData["data"]["className"]
        parentNode = nodeEditor.NodeEditor.focusedInstance().currentNode().fullName()
        
        if itemData["type"] == "attributeClassName":
            name = "input"
            if itemData["data"]["output"]:
                name = "output"
            
            newAttributeName = coralApp.executeCommand("CreateAttribute", 
                className = className, 
                name = name, 
                parentNode = parentNode, 
                input = itemData["data"]["input"], output = itemData["data"]["output"])

            if newAttributeName:
                newAttribute = coralApp.findAttribute(newAttributeName)
                attributeUi = nodeEditor.NodeEditor.findAttributeUi(newAttribute.id())
                if attributeUi.proxy():
                    sceneItem = attributeUi.proxy()

        elif itemData["type"] == "nodeClassName":
            newNodeName = coralApp.executeCommand("CreateNode",
                                                className = className,
                                                name = className,
                                                parentNode = parentNode)
            if newNodeName:
                newNode = coralApp.findNode(newNodeName)
                sceneItem = nodeEditor.NodeEditor.findNodeUi(newNode.id())
        
        return sceneItem
예제 #5
0
def testNesting():
    coralApp.init()
    
    root = coralApp.findNode("root")
    n1 = coralApp.createNode("CollapsedNode", "n1", root)
    n2 = coralApp.createNode("CollapsedNode", "n2", n1)

    coralApp.finalize()
예제 #6
0
def testNesting():
    coralApp.init()

    root = coralApp.findNode("root")
    n1 = coralApp.createNode("CollapsedNode", "n1", root)
    n2 = coralApp.createNode("CollapsedNode", "n2", n1)

    coralApp.finalize()
예제 #7
0
def testFindObject():
    coralApp.init()
    
    root = coralApp.findNode("root")
    n1 = coralApp.createNode("CollapsedNode", "n1", root)
    n2 = coralApp.createNode("CollapsedNode", "n2", n1)
    
    assert coralApp.findObject(n2.fullName()) is n2
    
    coralApp.finalize()
예제 #8
0
def testFindObject():
    coralApp.init()

    root = coralApp.findNode("root")
    n1 = coralApp.createNode("CollapsedNode", "n1", root)
    n2 = coralApp.createNode("CollapsedNode", "n2", n1)

    assert coralApp.findObject(n2.fullName()) is n2

    coralApp.finalize()
예제 #9
0
def testCollapsedNode():
    coralApp.init()
    
    root = coralApp.findNode("root")
    n1 = coralApp.createNode("Float", "n1", root)
    n2 = coralApp.createNode("Float", "n2", root)
    n3 = coralApp.createNode("Add", "n3", root)
    
    _coral.NetworkManager.connect(n1.outputAttributeAt(0), n3.inputAttributeAt(0))
    
    collapsedNode = coralApp.collapseNodes([n3])
    
    assert collapsedNode in root.nodes()
    
    coralApp.finalize()
예제 #10
0
def testCollapsedNode():
    coralApp.init()

    root = coralApp.findNode("root")
    n1 = coralApp.createNode("Float", "n1", root)
    n2 = coralApp.createNode("Float", "n2", root)
    n3 = coralApp.createNode("Add", "n3", root)

    _coral.NetworkManager.connect(n1.outputAttributeAt(0),
                                  n3.inputAttributeAt(0))

    collapsedNode = coralApp.collapseNodes([n3])

    assert collapsedNode in root.nodes()

    coralApp.finalize()
예제 #11
0
def testSaveScript():
    coralApp.init()

    root = coralApp.findNode("root")
    n1 = coralApp.createNode("Float", "n1", root)
    n2 = coralApp.createNode("Float", "n2", root)
    n3 = coralApp.createNode("Add", "n3", root)

    n1.outputAttributeAt(0).outValue().setFloatValueAt(0, 5.0)

    _coral.NetworkManager.connect(n1.outputAttributeAt(0),
                                  n3.inputAttributeAt(0))

    saveScript = root.contentAsScript()

    coralApp.finalize()

    coralApp.init()
    coralApp.setShouldLogInfos(False)

    coralApp._executeNetworkScript(saveScript)

    n1 = coralApp.findNode("root.n1")
    n2 = coralApp.findNode("root.n2")
    n3 = coralApp.findNode("root.n3")

    assert n1 is not None
    assert n2 is not None
    assert n3 is not None

    n1Floats = n1.outputAttributeAt(0).outValue().getFloat()
    assert n1Floats[0] == 5.0

    assert n3.inputAttributeAt(0).input() is n1.outputAttributeAt(0)

    collapsedNode = coralApp.collapseNodes([n3])

    root = coralApp.findNode("root")

    saveScript = root.contentAsScript()
    coralApp.finalize()

    coralApp.init()
    coralApp._executeNetworkScript(saveScript)

    collapseNode = coralApp.findNode("root.CollapsedNode")
    assert collapseNode is not None
    assert len(collapseNode.attributes()) > 0

    coralApp.finalize()
예제 #12
0
def testSaveScript():
    coralApp.init()
    
    root = coralApp.findNode("root")
    n1 = coralApp.createNode("Float", "n1", root)
    n2 = coralApp.createNode("Float", "n2", root)
    n3 = coralApp.createNode("Add", "n3", root)
    
    n1.outputAttributeAt(0).outValue().setFloatValueAt(0, 5.0)
    
    _coral.NetworkManager.connect(n1.outputAttributeAt(0), n3.inputAttributeAt(0))
    
    saveScript = root.contentAsScript()
    
    coralApp.finalize()
    
    coralApp.init()
    coralApp.setShouldLogInfos(False)
    
    coralApp._executeNetworkScript(saveScript)
    
    n1 = coralApp.findNode("root.n1")
    n2 = coralApp.findNode("root.n2")
    n3 = coralApp.findNode("root.n3")
    
    assert n1 is not None
    assert n2 is not None
    assert n3 is not None
    
    n1Floats = n1.outputAttributeAt(0).outValue().getFloat()
    assert n1Floats[0] == 5.0
    
    assert n3.inputAttributeAt(0).input() is n1.outputAttributeAt(0)
    
    collapsedNode = coralApp.collapseNodes([n3])
    
    root = coralApp.findNode("root")
    
    saveScript = root.contentAsScript()
    coralApp.finalize()
    
    coralApp.init()
    coralApp._executeNetworkScript(saveScript)
    
    collapseNode = coralApp.findNode("root.CollapsedNode")
    assert collapseNode is not None
    assert len(collapseNode.attributes()) > 0
    
    coralApp.finalize()
예제 #13
0
def testDeletingAttributes():
    coralApp.init()
    
    root = coralApp.findNode("root")
    n1 = coralApp.createNode("Float", "n1", root)
    n2 = coralApp.createNode("Float", "n2", root)
    n3 = coralApp.createNode("Add", "n3", root)
    n4 = coralApp.createNode("Add", "n4", root)
    n5 = coralApp.createNode("Float", "n5", root)
    n6 = coralApp.createNode("Add", "n6", root)

    _coral.NetworkManager.connect(n1.outputAttributeAt(0), n3.inputAttributeAt(0))
    _coral.NetworkManager.connect(n2.outputAttributeAt(0), n3.inputAttributeAt(1))
    _coral.NetworkManager.connect(n3.outputAttributeAt(0), n4.inputAttributeAt(0))
    _coral.NetworkManager.connect(n5.outputAttributeAt(0), n4.inputAttributeAt(1))
    _coral.NetworkManager.connect(n3.outputAttributeAt(0), n6.inputAttributeAt(1))

    coralApp.deleteNodes([n3, n5, n6])
    
    coralApp.finalize()
예제 #14
0
    def _createFromItemData(itemData):
        from nodeEditor import nodeEditor

        sceneItem = None
        className = itemData["data"]["className"]
        parentNode = nodeEditor.NodeEditor.focusedInstance().currentNode(
        ).fullName()

        if itemData["type"] == "attributeClassName":
            name = "input"
            if itemData["data"]["output"]:
                name = "output"

            newAttributeName = coralApp.executeCommand(
                "CreateAttribute",
                className=className,
                name=name,
                parentNode=parentNode,
                input=itemData["data"]["input"],
                output=itemData["data"]["output"])

            if newAttributeName:
                newAttribute = coralApp.findAttribute(newAttributeName)
                attributeUi = nodeEditor.NodeEditor.findAttributeUi(
                    newAttribute.id())
                if attributeUi.proxy():
                    sceneItem = attributeUi.proxy()

        elif itemData["type"] == "nodeClassName":
            newNodeName = coralApp.executeCommand("CreateNode",
                                                  className=className,
                                                  name=className,
                                                  parentNode=parentNode)
            if newNodeName:
                newNode = coralApp.findNode(newNodeName)
                sceneItem = nodeEditor.NodeEditor.findNodeUi(newNode.id())

        return sceneItem