Code

fix crash, allow combine to work transparently on groups
[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         virtual ~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         unsigned int getSrcShapeId(void);
55         unsigned int getDstShapeId(void);
56         void makeActive(void);
57         void makeInactive(void);
58         void lateSetup(const Point& src, const Point& dst);
59         unsigned int id(void);
60         VertInf *src(void);
61         VertInf *dst(void);
62         void removeFromGraph(void);
63         bool isInitialised(void);
64         void unInitialise(void);
65         void setCallback(void (*cb)(void *), void *ptr);
66         void handleInvalid(void);
67         int generatePath(Point p0, Point p1);
68         void makePathInvalid(void);
69         Router *router(void);
70         void setHateCrossings(bool value);
71         bool doesHateCrossings(void);
72         
73         friend void Router::attachedShapes(IntList &shapes,
74                 const unsigned int shapeId, const unsigned int type);
75         friend void Router::attachedConns(IntList &conns,
76                 const unsigned int shapeId, const unsigned int type);
77         friend void Router::markConnectors(ShapeRef *shape);
78         
79     private:
80         Router *_router;
81         unsigned int _id;
82         unsigned int _type;
83         unsigned int _srcId, _dstId;
84         bool _needs_reroute_flag;
85         bool _false_path;
86         bool _active;
87         PolyLine _route;
88         double _route_dist;
89         ConnRefList::iterator _pos;
90         VertInf *_srcVert;
91         VertInf *_dstVert;
92         bool _initialised;
93         void (*_callback)(void *);
94         void *_connector;
95         bool _hateCrossings;
96 };
99 }
102 #endif