def testNodeDeletion(): coralApp.init() coralApp.createNode("Float", "test", coralApp.findNode("root")) coralApp.deleteNodes([coralApp.findNode("root.test")]) assert _coral.NetworkManager.objectCount() == 1 coralApp.finalize()
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()
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
def testNesting(): coralApp.init() root = coralApp.findNode("root") n1 = coralApp.createNode("CollapsedNode", "n1", root) n2 = coralApp.createNode("CollapsedNode", "n2", n1) coralApp.finalize()
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()
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()
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()
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