示例#1
0
def testCollapsingBug1():
    coralApp.init()

    collapsed = coralApp.createNode("CollapsedNode", "collapsed",
                                    coralApp.rootNode())
    in1 = coralApp.createAttribute("PassThroughAttribute",
                                   "in",
                                   collapsed,
                                   input=True)
    add = coralApp.createNode("Add", "addNode", collapsed)

    _coral.NetworkManager.connect(in1, add.inputAttributeAt(0))

    float1 = coralApp.createNode("Float", "float1", coralApp.rootNode())

    _coral.NetworkManager.connect(float1.outputAttributeAt(0), in1)

    newCollapsed = coralApp.collapseNodes([collapsed])
    print "testing collapsing operation won't add erroneous output attributes"
    assert newCollapsed.outputAttributes() == []

    print "testing collapsing operation won't disconnect erroneous attributes"
    assert in1.isConnectedTo(add.inputAttributeAt(0))

    coralApp.finalize()
示例#2
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()
示例#3
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()
示例#4
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()
示例#5
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()
示例#6
0
def testCollapsingBug1():
    coralApp.init()
    
    collapsed = coralApp.createNode("CollapsedNode", "collapsed", coralApp.rootNode())
    in1 = coralApp.createAttribute("PassThroughAttribute", "in", collapsed, input = True)
    add = coralApp.createNode("Add", "addNode", collapsed)
    
    _coral.NetworkManager.connect(in1, add.inputAttributeAt(0))

    float1 = coralApp.createNode("Float", "float1", coralApp.rootNode())
        
    _coral.NetworkManager.connect(float1.outputAttributeAt(0), in1)
    
    newCollapsed = coralApp.collapseNodes([collapsed])
    print "testing collapsing operation won't add erroneous output attributes"
    assert newCollapsed.outputAttributes() == []
    
    print "testing collapsing operation won't disconnect erroneous attributes"
    assert in1.isConnectedTo(add.inputAttributeAt(0))
    
    coralApp.finalize()
示例#7
0
 def _includeSelectedNodes(self):
     coralApp.collapseNodes(NodeEditor.selectedNodes(),
                            collapsedNode=self.coralNode())
示例#8
0
 def _includeSelectedNodes(self):
     coralApp.collapseNodes(NodeEditor.selectedNodes(), collapsedNode = self.coralNode())