00001 /* 00002 * $Revision: 2299 $ 00003 * 00004 * last checkin: 00005 * $Author: gutwenger $ 00006 * $Date: 2012-05-07 15:57:08 +0200 (Mon, 07 May 2012) $ 00007 ***************************************************************/ 00008 00041 //*** 00042 // Dominance Drawing Method. see "Graph Drawing" by Di Battista et al. 00043 //*** 00044 00045 00046 00047 #ifdef _MSC_VER 00048 #pragma once 00049 #endif 00050 00051 #ifndef OGDF_DOMINANCE_LAYOUT_H 00052 #define OGDF_DOMINANCE_LAYOUT_H 00053 00054 00055 #include <ogdf/module/LayoutModule.h> 00056 #include <ogdf/basic/ModuleOption.h> 00057 #include <ogdf/module/UpwardPlanarizerModule.h> 00058 #include <ogdf/upward/UpwardPlanRep.h> 00059 #include <ogdf/basic/GraphAttributes.h> 00060 #include <ogdf/upward/SubgraphUpwardPlanarizer.h> 00061 00062 namespace ogdf { 00063 00064 00065 class DominanceLayout : public LayoutModule 00066 { 00067 public: 00068 00069 DominanceLayout() { 00070 m_grid_dist = 1; 00071 // set default module 00072 m_upPlanarizer.set(new SubgraphUpwardPlanarizer()); 00073 00074 m_angle = 45.0/180.0*3.1415926535; 00075 00076 } 00077 00078 virtual void call(GraphAttributes &GA); 00079 00080 void layout(GraphAttributes &GA, const UpwardPlanRep &UPROrig); 00081 00082 void setUpwardPlanarizer(UpwardPlanarizerModule *upPlanarizer) { 00083 m_upPlanarizer.set(upPlanarizer); 00084 } 00085 00086 void setMinGridDistance(int dist) {m_grid_dist = dist;} 00087 00088 00089 00090 private: 00091 00092 double m_angle; //rotate angle to obtain an upward drawing; default is 45° 00093 00094 NodeArray<edge> firstout; 00095 NodeArray<edge> lastout; 00096 NodeArray<edge> firstin; 00097 NodeArray<edge> lastin; 00098 00099 int m_R; 00100 int m_L; 00101 00102 // list of nodes sorted by their x and y coordinate. 00103 List<node> xNodes; 00104 List<node> yNodes; 00105 00106 //coordinate in preliminary layout 00107 NodeArray<int> xPreCoord; 00108 NodeArray<int> yPreCoord; 00109 00110 //final coordinate of the nodes of the UPR 00111 NodeArray<int> xCoord; 00112 NodeArray<int> yCoord; 00113 00114 00115 //min grid distance 00116 int m_grid_dist; 00117 00118 ModuleOption<UpwardPlanarizerModule> m_upPlanarizer; // upward planarizer 00119 00120 void labelX(const UpwardPlanRep &UPR, node v, int &count); 00121 00122 void labelY(const UpwardPlanRep &UPR, node v, int &count); 00123 00124 void compact(const UpwardPlanRep &UPR, GraphAttributes &GA); 00125 00126 void findTransitiveEdges(const UpwardPlanRep &UPR, List<edge> &edges); 00127 00128 }; 00129 00130 00131 }//namespace 00132 00133 #endif