Esempio n. 1
0
def collapseNodes(nodes, collapsedNode=None):
    parentNode = _checkNodesShareSameParent(nodes)

    if collapsedNode is None:
        collapsedNode = coralApp.createNode(
            CollapserData.collapsedNodeClassName,
            CollapserData.collapsedNodeClassName, parentNode)

    inPassAttrs = {}
    outPassAttrs = {}

    for node in nodes:
        disconnectedAttributes = _disconnectConnectedInputs(node, nodes)

        inputAttributes = disconnectedAttributes[0]
        inputAttributesWithOutputConnections = disconnectedAttributes[1]

        outputAttributes = _disconnectConnectedOutputs(node, nodes)

        parentNode.removeNode(node)
        collapsedNode.addNode(node)

        for attr in inputAttributes:
            sourceAttr = attr[0]
            destAttr = attr[1]

            passAttrName = sourceAttr.parent().name() + "_" + sourceAttr.name()
            if inPassAttrs.has_key(passAttrName) == False:
                passAttr = coralApp.createAttribute("PassThroughAttribute",
                                                    "input",
                                                    collapsedNode,
                                                    input=True)
                NetworkManager.connect(sourceAttr, passAttr)
                inPassAttrs[passAttrName] = passAttr
            else:
                passAttr = inPassAttrs[passAttrName]

            NetworkManager.connect(passAttr, destAttr)

        for attr in outputAttributes:
            sourceAttr = attr[0]
            destAttr = attr[1]

            passAttrName = sourceAttr.parent().name() + "_" + sourceAttr.name()
            if outPassAttrs.has_key(passAttrName) == False:
                passAttr = coralApp.createAttribute("PassThroughAttribute",
                                                    "output",
                                                    collapsedNode,
                                                    output=True)
                NetworkManager.connect(sourceAttr, passAttr)
                outPassAttrs[passAttrName] = passAttr
            else:
                passAttr = outPassAttrs[passAttrName]

            NetworkManager.connect(passAttr, destAttr)

    return collapsedNode
Esempio n. 2
0
def collapseNodes(nodes, collapsedNode = None):
    parentNode = _checkNodesShareSameParent(nodes)
    
    if collapsedNode is None:
        collapsedNode = coralApp.createNode(CollapserData.collapsedNodeClassName, CollapserData.collapsedNodeClassName, parentNode)
    
    inPassAttrs = {}
    outPassAttrs = {}
    
    for node in nodes:
        disconnectedAttributes = _disconnectConnectedInputs(node, nodes)
        
        inputAttributes = disconnectedAttributes[0]
        inputAttributesWithOutputConnections = disconnectedAttributes[1]
        
        outputAttributes = _disconnectConnectedOutputs(node, nodes)
        
        parentNode.removeNode(node)
        collapsedNode.addNode(node)
        
        for attr in inputAttributes:
            sourceAttr = attr[0]
            destAttr = attr[1]
            
            passAttrName = sourceAttr.parent().name() + "_" + sourceAttr.name()
            if inPassAttrs.has_key(passAttrName) == False:
                passAttr = coralApp.createAttribute("PassThroughAttribute", "input", collapsedNode, input = True)
                NetworkManager.connect(sourceAttr, passAttr)
                inPassAttrs[passAttrName] = passAttr
            else:
                passAttr = inPassAttrs[passAttrName]
            
            NetworkManager.connect(passAttr, destAttr)
        
        for attr in outputAttributes:
            sourceAttr = attr[0]
            destAttr = attr[1]
            
            passAttrName = sourceAttr.parent().name() + "_" + sourceAttr.name()
            if  outPassAttrs.has_key(passAttrName) == False:
                passAttr = coralApp.createAttribute("PassThroughAttribute", "output", collapsedNode, output = True)
                NetworkManager.connect(sourceAttr, passAttr)
                outPassAttrs[passAttrName] = passAttr
            else:
                passAttr = outPassAttrs[passAttrName]
                
            NetworkManager.connect(passAttr, destAttr)
    
    return collapsedNode
Esempio n. 3
0
    def doIt(self):
        className = self.argAsString("className")
        name = self.argAsString("name")
        parentNode = self.argAsString("parentNode")
        input = self.argAsBool("input")
        output = self.argAsBool("output")

        newAttr = None

        parentNode = coralApp.findNode(parentNode)
        if parentNode:
            newAttr = coralApp.createAttribute(className, name, parentNode, input, output)
            if newAttr:
                specializationOverride = self.argAsString("specializationOverride")
                if specializationOverride != "" and specializationOverride != "none":
                    newAttr.setSpecializationOverride(specializationOverride)

                self.setResultString(newAttr.fullName())

        if newAttr is None:
            coralApp.logDebug("CreateAttribute Command: failed to create new attribute.")
Esempio n. 4
0
    def doIt(self):
        className = self.argAsString("className")
        name = self.argAsString("name")
        parentNode = self.argAsString("parentNode")
        input = self.argAsBool("input")
        output = self.argAsBool("output")

        newAttr = None

        parentNode = coralApp.findNode(parentNode)
        if parentNode:
            newAttr = coralApp.createAttribute(className, name, parentNode,
                                               input, output)
            if newAttr:
                specializationOverride = self.argAsString(
                    "specializationOverride")
                if specializationOverride != "" and specializationOverride != "none":
                    newAttr.setSpecializationOverride(specializationOverride)

                self.setResultString(newAttr.fullName())

        if newAttr is None:
            coralApp.logDebug(
                "CreateAttribute Command: failed to create new attribute.")