예제 #1
0
파일: 3d.cpp 프로젝트: denji/antimony
Node* CubeNode(float x, float y, float z, float scale, QObject* parent)
{
    Node* n = new Node(NodeType::CUBE, parent);
    new NameDatum("name", NodeManager::manager()->getName("c"), n);
    Point3DNode(x, y, z, 0, n)->setObjectName("a");
    Point3DNode(x + scale, y + scale, z + scale, 0, n)->setObjectName("b");
    new ShapeFunctionDatum("shape", n, "cube",
        {"a.x", "b.x", "a.y", "b.y", "a.z", "b.z"});
    return n;
}
예제 #2
0
void TestProxy::DatumNameChange()
{
    Node* a = Point3DNode("a", "0.0", "1.0", "2.0", r);
    Node* b = Point3DNode("b", "a.x", "1.0", "2.0", r);
    QVERIFY(b->getDatum("x")->getValid() == true);
    a->getDatum<NameDatum>("_name")->setExpr("q");
    QVERIFY(b->getDatum("x")->getValid() == false);

    delete a;
    delete b;
}
예제 #3
0
void TestProxy::MakeProxy()
{
    Node* p = Point3DNode("p", "0.0", "1.0", "2.0", r);
    PyObject* proxy = p->proxy();
    QVERIFY(proxy);
    Py_DECREF(proxy);
    delete p;
}
예제 #4
0
void TestProxy::GetNonexistentDatum()
{
    Node* p = Point3DNode("p", "0.0", "1.0", "2.0", r);
    PyObject* proxy = p->proxy();
    PyObject* q = PyObject_GetAttrString(proxy, "q");
    QVERIFY(q == NULL);
    PyErr_Clear();
    Py_DECREF(proxy);
    Py_XDECREF(q);
    delete p;
}
예제 #5
0
void TestProxy::GetInvalidDatum()
{
    Node* p = Point3DNode("p", "not a float", "1.0", "2.0", r);
    PyObject* proxy = p->proxy();
    PyObject* x = PyObject_GetAttrString(proxy, "x");
    QVERIFY(x == NULL);
    PyErr_Clear();
    Py_DECREF(proxy);
    Py_XDECREF(x);
    delete p;
}
예제 #6
0
void TestProxy::GetValidDatum()
{
    Node* p = Point3DNode("p", "0.0", "1.0", "2.0", r);
    PyObject* proxy = p->proxy();
    PyObject* x = PyObject_GetAttrString(proxy, "x");
    QVERIFY(x == p->getDatum("x")->getValue());
    QVERIFY(x->ob_refcnt == 2);
    Py_DECREF(proxy);
    Py_DECREF(x);
    delete p;
}
예제 #7
0
void TestScript::UseOtherDatum()
{
    Node* p = Point3DNode("p", "0.!", "0.0", "0.0", r);
    Node* n = ScriptNode("s", "0.0", "0.0", "0.0", "p.x + 1", r);
    QVERIFY(n->getDatum("_script")->getValid() == false);

    QSignalSpy s(n->getDatum("_script"), SIGNAL(changed()));
    p->getDatum<FloatDatum>("x")->setExpr("1.0");

    QCOMPARE(s.count(), 1);
    QVERIFY(n->getDatum("_script")->getValid() == true);

    delete p;
    delete n;
}
예제 #8
0
void TestShape::ShapeInput()
{
    Node* p = Point3DNode("p", "0.0", "0.0", "1.0");
    ShapeFunctionDatum* a = new ShapeFunctionDatum("a", p, "circle", {"x","y","z"});

    ShapeDatum* d = new ShapeDatum("d");
    Link* link = a->linkFrom();
    QVERIFY(d->acceptsLink(link));

    d->addLink(link);
    QVERIFY(d->getValid());

    delete p;
    delete d;
}
예제 #9
0
void TestShape::DeleteInput()
{
    Node* p = Point3DNode("p", "0.0", "1.0", "!.0");
    ShapeFunctionDatum* a = new ShapeFunctionDatum("a", p, "circle", {"x","y","z"});

    ShapeDatum* d = new ShapeDatum("d");
    Link* link = a->linkFrom();

    d->addLink(link);
    QVERIFY(d->getValid() == false);

    QSignalSpy s(d, SIGNAL(changed()));
    delete link;

    QVERIFY(d->getValid() == true);
    QVERIFY(s.count() == 1);

    delete p;
    delete d;
}
예제 #10
0
void TestShape::MultiShapeInput()
{
    Node* p = Point3DNode("p", "0.0", "1.0", "!.0");
    ShapeFunctionDatum* a = new ShapeFunctionDatum("a", p, "circle", {"x","x","y"});
    ShapeFunctionDatum* b = new ShapeFunctionDatum("b", p, "circle", {"x","y","z"});

    ShapeDatum* d = new ShapeDatum("d");
    Link* la = a->linkFrom();
    Link* lb = b->linkFrom();

    d->addLink(la);
    QVERIFY(d->acceptsLink(lb));
    d->addLink(lb);
    QVERIFY(d->getValid() == false);

    QSignalSpy s(d, SIGNAL(changed()));
    p->getDatum<FloatDatum>("z")->setExpr("2.0");
    QVERIFY(d->getValid() == true);
    QCOMPARE(s.count(), 1);

    delete p;
    delete d;
}