Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00044 #ifdef _MSC_VER
00045 #pragma once
00046 #endif
00047
00048 #ifndef OGDF_TREE_LAYOUT_H
00049 #define OGDF_TREE_LAYOUT_H
00050
00051 #include <ogdf/module/LayoutModule.h>
00052 #include <ogdf/basic/SList.h>
00053
00054 namespace ogdf {
00055
00109 class OGDF_EXPORT TreeLayout : public LayoutModule {
00110 public:
00112 enum RootSelectionType {
00113 rootIsSource,
00114 rootIsSink,
00115 rootByCoord
00116 };
00117
00118 private:
00119 double m_siblingDistance;
00120 double m_subtreeDistance;
00121 double m_levelDistance;
00122 double m_treeDistance;
00123
00124 bool m_orthogonalLayout;
00125 Orientation m_orientation;
00126 RootSelectionType m_selectRoot;
00127
00128 NodeArray<int> m_number;
00129
00130 NodeArray<node> m_parent;
00131 NodeArray<node> m_leftSibling;
00132 NodeArray<node> m_firstChild;
00133 NodeArray<node> m_lastChild;
00134 NodeArray<node> m_thread;
00135 NodeArray<node> m_ancestor;
00136
00137 NodeArray<double> m_preliminary;
00138 NodeArray<double> m_modifier;
00139 NodeArray<double> m_change;
00140 NodeArray<double> m_shift;
00141
00142 SListPure<edge> m_reversedEdges;
00143 Graph *m_pGraph;
00144
00145 public:
00147 TreeLayout();
00148
00150 TreeLayout(const TreeLayout &tl);
00151
00152
00153 ~TreeLayout();
00154
00155
00172 void call(GraphAttributes &GA);
00173
00184 void callSortByPositions(GraphAttributes &AG, Graph &G);
00185
00186
00192
00193 double siblingDistance() const { return m_siblingDistance; }
00194
00196 void siblingDistance(double x) { m_siblingDistance = x; }
00197
00199 double subtreeDistance() const { return m_subtreeDistance; }
00200
00202 void subtreeDistance(double x) { m_subtreeDistance = x; }
00203
00205 double levelDistance() const { return m_levelDistance; }
00206
00208 void levelDistance(double x) { m_levelDistance = x; }
00209
00211 double treeDistance() const { return m_treeDistance; }
00212
00214 void treeDistance(double x) { m_treeDistance = x; }
00215
00217 bool orthogonalLayout() const { return m_orthogonalLayout; }
00218
00220 void orthogonalLayout(bool b) { m_orthogonalLayout = b; }
00221
00223 Orientation orientation() const { return m_orientation; }
00224
00226 void orientation(Orientation orientation) { m_orientation = orientation; }
00227
00229 RootSelectionType rootSelection() const { return m_selectRoot; }
00230
00232 void rootSelection(RootSelectionType rootSelection) { m_selectRoot = rootSelection; }
00233
00234
00240
00241 TreeLayout &operator=(const TreeLayout &tl);
00242
00244
00245 private:
00246 class AdjComparer;
00247
00248 void adjustEdgeDirections(Graph &G, node v, node parent);
00249 void setRoot(GraphAttributes &AG, Graph &tree);
00250 void undoReverseEdges(GraphAttributes &AG);
00251
00252
00253
00254
00255
00256 void initializeTreeStructure(const Graph &tree, List<node> &roots);
00257
00258
00259 void deleteTreeStructure();
00260
00261
00262 int isLeaf(node v) const;
00263
00264
00265
00266 node nextOnLeftContour(node v) const;
00267 node nextOnRightContour(node v) const;
00268
00269
00270
00271 void firstWalk(node subtree,const GraphAttributes &AG,bool upDown);
00272
00273
00274
00275 void apportion(node subtree,
00276 node &defaultAncestor,
00277 const GraphAttributes &AG,
00278 bool upDown);
00279
00280
00281
00282 void secondWalkX(node subtree,
00283 double modifierSum,
00284 GraphAttributes &AG);
00285 void secondWalkY(node subtree,
00286 double modifierSum,
00287 GraphAttributes &AG);
00288
00289
00290 void computeYCoordinatesAndEdgeShapes(node root,GraphAttributes &AG);
00291 void computeXCoordinatesAndEdgeShapes(node root,GraphAttributes &AG);
00292
00293 void findMinX(GraphAttributes &AG, node root, double &minX);
00294 void findMinY(GraphAttributes &AG, node root, double &minY);
00295 void findMaxX(GraphAttributes &AG, node root, double &maxX);
00296 void findMaxY(GraphAttributes &AG, node root, double &maxY);
00297 void shiftTreeX(GraphAttributes &AG, node root, double shift);
00298 void shiftTreeY(GraphAttributes &AG, node root, double shift);
00299 };
00300
00301 }
00302
00303 #endif
00304