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-2005 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/geometry.h"
27 #include "libavoid/shape.h"
28 #include <list>
31 namespace Avoid {
33 typedef unsigned int uint;
35 class ConnRef;
37 typedef std::list<ConnRef *> ConnRefList;
40 class ConnRef
41 {
42 public:
43 ConnRef(const uint id);
44 ConnRef(const uint id, const Point& src, const Point& dst);
45 ~ConnRef();
47 PolyLine& route(void);
48 bool needsReroute(void);
49 void moveRoute(const int& diff_x, const int& diff_y);
50 void freeRoute(void);
51 void calcRouteDist(void);
52 void updateEndPoint(const uint type, const Point& point);
53 void makeActive(void);
54 void makeInactive(void);
55 void lateSetup(const Point& src, const Point& dst);
56 VertInf *src(void);
57 VertInf *dst(void);
58 void removeFromGraph(void);
59 bool isInitialised(void);
60 void unInitialise(void);
61 void setCallback(void (*cb)(void *), void *ptr);
62 void handleInvalid(void);
63 int generatePath(Point p0, Point p1);
64 void makePathInvalid(void);
66 friend void markConnectors(ShapeRef *shape);
68 private:
69 uint _id;
70 bool _needs_reroute_flag;
71 bool _false_path;
72 bool _active;
73 PolyLine _route;
74 double _route_dist;
75 ConnRefList::iterator _pos;
76 VertInf *_srcVert;
77 VertInf *_dstVert;
78 bool _initialised;
79 void (*_callback)(void *);
80 void *_connector;
81 };
84 extern ConnRefList connRefs;
86 extern void callbackAllInvalidConnectors(void);
88 }
91 #endif