Code

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