Code

* src/document.cpp, src/document.h, src/sp-conn-end-pair.cpp,
[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 moveRoute(const int& diff_x, const int& diff_y);
51         void freeRoute(void);
52         void calcRouteDist(void);
53         void updateEndPoint(const unsigned int type, const Point& point);
54         void setEndPointId(const unsigned int type, const unsigned int id);
55         void makeActive(void);
56         void makeInactive(void);
57         void lateSetup(const Point& src, const Point& dst);
58         VertInf *src(void);
59         VertInf *dst(void);
60         void removeFromGraph(void);
61         bool isInitialised(void);
62         void unInitialise(void);
63         void setCallback(void (*cb)(void *), void *ptr);
64         void handleInvalid(void);
65         int generatePath(Point p0, Point p1);
66         void makePathInvalid(void);
67         Router *router(void);
68         
69         friend void Router::attachedShapes(IntList &shapes,
70                 const unsigned int shapeId, const unsigned int type);
71         friend void Router::attachedConns(IntList &conns,
72                 const unsigned int shapeId, const unsigned int type);
73         friend void Router::markConnectors(ShapeRef *shape);
74         
75     private:
76         Router *_router;
77         unsigned int _id;
78         unsigned int _type;
79         unsigned int _srcId, _dstId;
80         bool _needs_reroute_flag;
81         bool _false_path;
82         bool _active;
83         PolyLine _route;
84         double _route_dist;
85         ConnRefList::iterator _pos;
86         VertInf *_srcVert;
87         VertInf *_dstVert;
88         bool _initialised;
89         void (*_callback)(void *);
90         void *_connector;
91 };
94 }
97 #endif