Code

* src/document.cpp, src/document.h, src/sp-conn-end-pair.cpp,
[inkscape.git] / src / libavoid / router.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 */
24 #ifndef AVOID_ROUTER_H
25 #define AVOID_ROUTER_H
27 //#define LINEDEBUG
29 #include "libavoid/shape.h"
30 #include "libavoid/graph.h"
31 #include "libavoid/timer.h"
32 #ifdef LINEDEBUG       
33     #include <SDL.h>
34 #endif
37 namespace Avoid {
39 class ConnRef;
40 typedef std::list<ConnRef *> ConnRefList;
41 typedef std::list<unsigned int> IntList;
44 static const unsigned int runningTo = 1;
45 static const unsigned int runningFrom = 2;
46 static const unsigned int runningToAndFrom = runningTo | runningFrom;
49 class Router {
50     public:
51         Router();
53         ShapeRefList shapeRefs;
54         ConnRefList connRefs;
55         EdgeList visGraph;
56         EdgeList invisGraph;
57         ContainsMap contains;
58         VertInfList vertices;
59         
60         bool PartialTime;
61         double segmt_penalty;
62         double angle_penalty;
64         bool UseAStarSearch;
65         bool IgnoreRegions;
66         bool SelectiveReroute;
67         bool IncludeEndpoints;
68         bool UseLeesAlgorithm;
69         bool InvisibilityGrph;
70         bool PartialFeedback;
72         // Instrumentation:
73         Timer timers;
74         int st_checked_edges;
75 #ifdef LINEDEBUG
76         SDL_Surface *avoid_screen;
77 #endif
79         void addShape(ShapeRef *shape);
80         void delShape(ShapeRef *shape);
81         ShapeRef *moveShape(ShapeRef *oldShape, Polygn *newPoly,
82                 const bool first_move = false);
83         
84         void attachedConns(IntList &conns, const unsigned int shapeId,
85                 const unsigned int type);
86         void attachedShapes(IntList &shapes, const unsigned int shapeId,
87                 const unsigned int type);
88         
89         void markConnectors(ShapeRef *shape);
90         void generateContains(VertInf *pt);
91         void printInfo(void);
92     private:
93         void newBlockingShape(Polygn *poly, int pid);
94         void checkAllBlockedEdges(int pid);
95         void checkAllMissingEdges(void);
96         void adjustContainsWithAdd(const Polygn& poly, const int p_shape);
97         void adjustContainsWithDel(const int p_shape);
98         void callbackAllInvalidConnectors(void);
99 };
105 #endif