Beispiel #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()
Beispiel #2
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()
def testSpecializingPass():
    coralApp.init()
    
    collapsed0 = coralApp.createNode("CollapsedNode", "collapsed0", coralApp.rootNode())
    in0 = coralApp.createAttribute("PassThroughAttribute", "in0", collapsed0, input = True)
    out0 = coralApp.createAttribute("PassThroughAttribute", "out0", collapsed0, output = True)
    
    collapsed = coralApp.createNode("CollapsedNode", "collapsed", collapsed0)
    in1 = coralApp.createAttribute("PassThroughAttribute", "in", collapsed, input = True)
    out1 = coralApp.createAttribute("PassThroughAttribute", "out", collapsed, output = True)
    add = coralApp.createNode("Add", "addNode", collapsed)
    
    _coral.NetworkManager.connect(in1, add.inputAttributeAt(0))
    _coral.NetworkManager.connect(add.outputAttributeAt(0), out1)
    
    _coral.NetworkManager.connect(in0, in1)
    _coral.NetworkManager.connect(out1, out0)

    float1 = coralApp.createNode("Float", "float1", coralApp.rootNode())
    floats = coralApp.createNode("Vec3", "floats", coralApp.rootNode())
    
    _coral.NetworkManager.connect(out0, floats.inputAttributeAt(0))
    _coral.NetworkManager.connect(float1.outputAttributeAt(0), in0)
    
    assert add.inputAttributeAt(0).specialization() == ["Float"]
    assert add.outputAttributeAt(0).specialization() == ["Float"]
    
    assert in0.specialization() == ["Float"]
    assert in1.specialization() == ["Float"]
    
    assert out1.specialization() == ["Float"] 
    
    coralApp.finalize()
Beispiel #4
0
def testNesting():
    coralApp.init()

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

    coralApp.finalize()
def testNesting():
    coralApp.init()
    
    root = coralApp.findNode("root")
    n1 = coralApp.createNode("CollapsedNode", "n1", root)
    n2 = coralApp.createNode("CollapsedNode", "n2", n1)

    coralApp.finalize()
Beispiel #6
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()
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 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()
Beispiel #9
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()
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()
Beispiel #11
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()
Beispiel #12
0
def testSpecializingPass():
    coralApp.init()

    collapsed0 = coralApp.createNode("CollapsedNode", "collapsed0",
                                     coralApp.rootNode())
    in0 = coralApp.createAttribute("PassThroughAttribute",
                                   "in0",
                                   collapsed0,
                                   input=True)
    out0 = coralApp.createAttribute("PassThroughAttribute",
                                    "out0",
                                    collapsed0,
                                    output=True)

    collapsed = coralApp.createNode("CollapsedNode", "collapsed", collapsed0)
    in1 = coralApp.createAttribute("PassThroughAttribute",
                                   "in",
                                   collapsed,
                                   input=True)
    out1 = coralApp.createAttribute("PassThroughAttribute",
                                    "out",
                                    collapsed,
                                    output=True)
    add = coralApp.createNode("Add", "addNode", collapsed)

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

    _coral.NetworkManager.connect(in0, in1)
    _coral.NetworkManager.connect(out1, out0)

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

    _coral.NetworkManager.connect(out0, floats.inputAttributeAt(0))
    _coral.NetworkManager.connect(float1.outputAttributeAt(0), in0)

    assert add.inputAttributeAt(0).specialization() == ["Float"]
    assert add.outputAttributeAt(0).specialization() == ["Float"]

    assert in0.specialization() == ["Float"]
    assert in1.specialization() == ["Float"]

    assert out1.specialization() == ["Float"]

    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 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()
Beispiel #15
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()
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()
Beispiel #17
0
#      notice, this list of conditions and the following disclaimer.
# 
#    * Redistributions in binary form must reproduce the above copyright
#      notice, this list of conditions and the following disclaimer in the
#      documentation and/or other materials provided with the distribution.
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# </license>


from coral import coralApp
from coral.coralUi import coralUi
import coralStandaloneConfig

coralUi.init(configModule = coralStandaloneConfig)
coralApp.scanAutoLoadPaths()
coralUi.scanAutoLoadPaths()
coralUi.startApp()

coralApp.finalize()
Beispiel #18
0
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# </license>
import logging
import sys

import sip

sip.setapi(u'QDate', 2)
sip.setapi(u'QDateTime', 2)
sip.setapi(u'QString', 2)
sip.setapi(u'QTextStream', 2)
sip.setapi(u'QTime', 2)
sip.setapi(u'QUrl', 2)
sip.setapi(u'QVariant', 2)

from coral import coralApp
from coral.coralUi import coralUi
import coralStandaloneConfig

logger = logging.getLogger("coraline")
if len(sys.argv) and "debug" in sys.argv:
    logger.setLevel(logging.DEBUG)

coralUi.init(configModule = coralStandaloneConfig)
coralApp.scanAutoLoadPaths()
coralUi.scanAutoLoadPaths()
coralUi.startApp()
coralApp.finalize()
# sys.exit()