1 /*
2  * vim: ts=4 sw=4 et tw=0 wm=0
3  *
4  * libavoid - Fast, Incremental, Object-avoiding Line Router
5  * Copyright (C) 2010  Monash University
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  * See the file LICENSE.LGPL distributed with the library.
12  *
13  * Licensees holding a valid commercial license may use this file in
14  * accordance with the commercial license agreement provided with the
15  * library.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20  *
21  * Author(s):   Michael Wybrow <mjwybrow@users.sourceforge.net>
22 */
23 
24 #include "libavoid/libavoid.h"
25 #include "libavoid/connectionpin.h"
26 
27 // A testcase to check the functionality for connection pins.
28 
29 
main(void)30 int main(void)
31 {
32     Avoid::Router *router = new Avoid::Router(Avoid::OrthogonalRouting);
33 
34     // Create the ShapeRef:
35     Avoid::Rectangle shapeRect1(Avoid::Point(0, 0), Avoid::Point(10, 10));
36     Avoid::ShapeRef *shapeRef1 = new Avoid::ShapeRef(router, shapeRect1);
37 
38 
39     Avoid::Rectangle shapeRect2(Avoid::Point(40, 20), Avoid::Point(50, 30));
40     Avoid::ShapeRef *shapeRef2 = new Avoid::ShapeRef(router, shapeRect2);
41 
42     const unsigned int CENTRE = 1;
43     new Avoid::ShapeConnectionPin(shapeRef1, CENTRE, Avoid::ATTACH_POS_CENTRE,
44             Avoid::ATTACH_POS_CENTRE, true, 0.0, Avoid::ConnDirNone);
45     new Avoid::ShapeConnectionPin(shapeRef2, CENTRE, Avoid::ATTACH_POS_CENTRE,
46             Avoid::ATTACH_POS_CENTRE, true, 0.0, Avoid::ConnDirNone);
47 
48     Avoid::ConnEnd dstEnd(shapeRef1, CENTRE);
49     Avoid::ConnEnd srcEnd(shapeRef2, CENTRE);
50     new Avoid::ConnRef(router, srcEnd, dstEnd);
51     // Force inital callback:
52     router->processTransaction();
53     router->outputDiagram("output/connectionpin01-1");
54 
55     router->moveShape(shapeRef2, 5, 0);
56 
57     router->processTransaction();
58     router->outputDiagram("output/connectionpin01-2");
59 
60     router->moveShape(shapeRef1, 0, -10);
61 
62     router->processTransaction();
63     router->outputDiagram("output/connectionpin01-3");
64 
65     delete router;
66     return 0;
67 }
68 
69