예제 #1
0
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);
    
    // Create the ShapeRef:
    Avoid::Rectangle shapeRect1(Avoid::Point(0, 0), Avoid::Point(10, 10));
    Avoid::ShapeRef *shapeRef1 = new Avoid::ShapeRef(router, shapeRect1);
    const unsigned int CENTRE = 1;
    new Avoid::ShapeConnectionPin(shapeRef1, CENTRE, 
            Avoid::ATTACH_POS_CENTRE, Avoid::ATTACH_POS_CENTRE, true, 0.0, Avoid::ConnDirNone);
    
    Avoid::Rectangle shapeRect2(Avoid::Point(0, 0), Avoid::Point(10, 10));
    Avoid::ShapeRef *shapeRef2 = new Avoid::ShapeRef(router, shapeRect1);

    Avoid::ConnEnd dstPt(shapeRef1, CENTRE); 
    Avoid::Point srcPt(1.5, 4);
    Avoid::ConnRef *connRef = new Avoid::ConnRef(router, srcPt, dstPt);
    // Force inital callback:
    router->processTransaction();
    router->outputDiagram("output/connendmove-1");

    Avoid::Point dstPt2(20, 20);
    connRef->setDestEndpoint(dstPt2);
    router->moveShape(shapeRef1, 0.5, 0);

    router->processTransaction();
    router->outputDiagram("output/connendmove-2");

    srcPt.x += 0.5;
    connRef->setSourceEndpoint(srcPt);
    router->moveShape(shapeRef1, 0.5, 0);
    router->moveShape(shapeRef2, 0, 0.5);
    
    srcPt.x += 0.5;
    connRef->setSourceEndpoint(srcPt);
    router->moveShape(shapeRef1, 0.5, 0);
    router->moveShape(shapeRef2, 0, 0.5);
    
    srcPt.x += 0.5;
    connRef->setSourceEndpoint(srcPt);
    router->moveShape(shapeRef1, 0.5, 0);
    router->moveShape(shapeRef2, 0, 0.5);
    
    srcPt.x += 0.5;
    connRef->setSourceEndpoint(srcPt);
    router->moveShape(shapeRef1, 0.5, 0);
    router->moveShape(shapeRef2, 0, 0.5);
    
    router->processTransaction();
    router->outputDiagram("output/connendmove-3");

    delete router;
    return 0;
}