コード例 #1
0
ファイル: example.cpp プロジェクト: mjwybrow/adaptagrams
int main(void)
{
    Avoid::Router *router = new Avoid::Router(Avoid::PolyLineRouting);
    
    Avoid::Point srcPt(1.2, 0.5);
    Avoid::Point dstPt(1.5, 4);
    Avoid::ConnRef *connRef = new Avoid::ConnRef(router, srcPt, dstPt);
    connRef->setCallback(connCallback, connRef);
    // Force inital callback:
    router->processTransaction();

    printf("\nAdding a shape.\n");
    // Create the ShapeRef:
    Avoid::Polygon shapePoly(3);
    shapePoly.ps[0] = Avoid::Point(1, 1);
    shapePoly.ps[1] = Avoid::Point(2.5, 1.5);
    shapePoly.ps[2] = Avoid::Point(1.5, 2.5);
    Avoid::ShapeRef *shapeRef = new Avoid::ShapeRef(router, shapePoly);
    router->processTransaction();

    printf("\nShifting endpoint.\n");
    Avoid::Point dstPt2(6, 4.5);
    connRef->setDestEndpoint(dstPt2);
    // It's expected you know the connector needs rerouting, so the callback
    // isn't called.  You can force it to be called though, via:
    router->processTransaction();

    printf("\nMoving shape right by 0.5.\n");
    router->moveShape(shapeRef, 0.5, 0);
    router->processTransaction();

    router->outputDiagram("output/example");
    delete router;
    return 0;
}
コード例 #2
0
int main(void)
{
    Avoid::Router *router = new Avoid::Router(Avoid::OrthogonalRouting);
    
    Avoid::Point srcPt(0,400);
    Avoid::Point dstPt(775,400);
    Avoid::ConnRef *connRef = new Avoid::ConnRef(router, srcPt, dstPt);
    connRef->setCallback(connCallback, connRef);

    Avoid::Point srcPt2(775,625);
    Avoid::Point dstPt2(350,475);
    Avoid::ConnRef *connRef2 = new Avoid::ConnRef(router, srcPt2, dstPt2);
    connRef2->setCallback(connCallback, connRef2);
    
    router->processTransaction();

    printf("\nShifting endpoint.\n");
    connRef->setEndpoints(Avoid::Point(0,375), Avoid::Point(775,400));
    connRef2->setEndpoints(Avoid::Point(775,625), Avoid::Point(350,450));
    router->processTransaction();

    printf("\nShifting endpoint.\n");
    connRef->setEndpoints(Avoid::Point(0,400), Avoid::Point(775,400));
    connRef2->setEndpoints(Avoid::Point(775,625), Avoid::Point(350,475));
    router->processTransaction();

    delete router;
    return 0;
}