Code

Various snapping cleanups and bug fixes.
[inkscape.git] / src / libavoid / connector.h
1 /*
2  * vim: ts=4 sw=4 et tw=0 wm=0
3  *
4  * libavoid - Fast, Incremental, Object-avoiding Line Router
5  * Copyright (C) 2004-2006  Michael Wybrow <mjwybrow@users.sourceforge.net>
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  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  * 
21 */
23 #ifndef AVOID_CONNECTOR_H
24 #define AVOID_CONNECTOR_H
26 #include "libavoid/router.h"
27 #include "libavoid/geometry.h"
28 #include "libavoid/shape.h"
29 #include <list>
32 namespace Avoid {
35 static const int ConnType_PolyLine   = 1;
36 static const int ConnType_Orthogonal = 2;
39 class ConnRef
40 {
41     public:
42         ConnRef(Router *router, const unsigned int id);
43         ConnRef(Router *router, const unsigned int id,
44                 const Point& src, const Point& dst);
45         ~ConnRef();
46         
47         void setType(unsigned int type);
48         PolyLine& route(void);
49         bool needsReroute(void);
50         void freeRoute(void);
51         void calcRouteDist(void);
52         void updateEndPoint(const unsigned int type, const Point& point);
53         void setEndPointId(const unsigned int type, const unsigned int id);
54         void makeActive(void);
55         void makeInactive(void);
56         void lateSetup(const Point& src, const Point& dst);
57         VertInf *src(void);
58         VertInf *dst(void);
59         void removeFromGraph(void);
60         bool isInitialised(void);
61         void unInitialise(void);
62         void setCallback(void (*cb)(void *), void *ptr);
63         void handleInvalid(void);
64         int generatePath(Point p0, Point p1);
65         void makePathInvalid(void);
66         Router *router(void);
67         
68         friend void Router::attachedShapes(IntList &shapes,
69                 const unsigned int shapeId, const unsigned int type);
70         friend void Router::attachedConns(IntList &conns,
71                 const unsigned int shapeId, const unsigned int type);
72         friend void Router::markConnectors(ShapeRef *shape);
73         
74     private:
75         Router *_router;
76         unsigned int _id;
77         unsigned int _type;
78         unsigned int _srcId, _dstId;
79         bool _needs_reroute_flag;
80         bool _false_path;
81         bool _active;
82         PolyLine _route;
83         double _route_dist;
84         ConnRefList::iterator _pos;
85         VertInf *_srcVert;
86         VertInf *_dstVert;
87         bool _initialised;
88         void (*_callback)(void *);
89         void *_connector;
90 };
93 }
96 #endif