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 00045 #ifdef _MSC_VER 00046 #pragma once 00047 #endif 00048 00049 00050 #ifndef OGDF_UML_ORTHO_LAYOUT_H 00051 #define OGDF_UML_ORTHO_LAYOUT_H 00052 00053 00054 #include <ogdf/module/LayoutPlanRepModule.h> 00055 #include <ogdf/orthogonal/OrthoRep.h> 00056 00057 00058 namespace ogdf { 00059 00060 enum OptionProfile {standard, minBendsperEdge, fullService}; //just to think about it... 00061 00062 enum OrthoDir; 00063 00064 00065 //--------------------------------------------------------- 00066 // OrthoLayout 00067 // represents planar orthogonal drawing algorithm for 00068 // mixed-upward planar embedded graphs (UML-diagrams) 00069 //--------------------------------------------------------- 00070 class OGDF_EXPORT OrthoLayout : public LayoutPlanRepModule 00071 { 00072 public: 00073 // constructor 00074 OrthoLayout(); 00075 00076 00077 // calls planar UML layout algorithm. Input is a planarized representation 00078 // PG of a connected component of the graph, output is a layout of the 00079 // (modified) planarized representation in drawing 00080 void call(PlanRepUML &PG, adjEntry adjExternal, Layout &drawing); 00081 00082 // 00083 // options 00084 00085 // the minimum distance between edges and vertices 00086 double separation() const { 00087 return m_separation; 00088 } 00089 00090 void separation(double sep) { 00091 m_separation = sep; 00092 } 00093 00094 // cOverhang * separation is the minimum distance between the glue point 00095 // of an edge and a corner of the vertex boundary 00096 double cOverhang() const { 00097 return m_cOverhang; 00098 } 00099 00100 void cOverhang(double c) { 00101 m_cOverhang = c; 00102 } 00103 00104 00105 // the distance from the tight bounding box to the boundary of the drawing 00106 double margin() const { 00107 return m_margin; 00108 } 00109 00110 void margin(double m) { 00111 m_margin = m; 00112 } 00113 00114 00115 // the preferred direction of generalizations 00116 OrthoDir preferedDir() const { 00117 return m_preferedDir; 00118 } 00119 00120 void preferedDir(OrthoDir dir) { 00121 m_preferedDir = dir; 00122 } 00123 00124 // cost of associations 00125 int costAssoc() const { 00126 return m_costAssoc; 00127 } 00128 00129 void costAssoc(int c) { 00130 m_costAssoc = c; 00131 } 00132 00133 // cost of generalizations 00134 int costGen() const { 00135 return m_costGen; 00136 } 00137 00138 void costGen(int c) { 00139 m_costGen = c; 00140 } 00141 00143 void optionProfile(int i) {m_optionProfile = i;} 00144 00146 void align(bool b) {m_align = b;} 00147 00149 void scaling(bool b) {m_useScalingCompaction = b;} 00150 00152 void setBendBound(int i) { OGDF_ASSERT(i >= 0); m_bendBound = i; } 00153 00154 //in planarlayout 00155 //enum LayoutOptions {umloptAlignment = 1, optScaling = 2, optProgressive = 4} 00156 //set generic options by setting field bits, 00157 //necessary to allow setting over base class pointer 00158 //bit 0 = alignment 00159 //bit 1 = scaling 00160 //bit 2 = progressive/traditional 00161 //=> 0 is standard 00162 virtual void setOptions(int optionField) 00163 { 00164 if (optionField & umlOpAlign) m_align = true; 00165 else m_align = false; 00166 if (optionField & umlOpScale) m_useScalingCompaction = true; 00167 else m_useScalingCompaction = false; 00168 if (optionField & umlOpProg) m_orthoStyle = 1; 00169 else m_orthoStyle = 0; //traditional 00170 }//setOptions 00171 00172 virtual int getOptions() 00173 { 00174 int result = 0; 00175 if (m_align) result = umlOpAlign; 00176 if (m_useScalingCompaction) result += umlOpScale; 00177 if (m_orthoStyle == 1) result += umlOpProg; 00178 00179 return result; 00180 }//getOptions 00181 00182 00183 protected: 00184 void classifyEdges(PlanRepUML &PG, adjEntry &adjExternal); 00185 00186 private: 00187 // compute bounding box and move final drawing such that it is 0 aligned 00188 // respecting margins 00189 void computeBoundingBox(const PlanRepUML &PG, Layout &drawing); 00190 00191 00192 // options 00193 double m_separation; 00194 double m_cOverhang; 00195 double m_margin; 00196 OrthoDir m_preferedDir; 00197 int m_optionProfile; 00198 int m_costAssoc; 00199 int m_costGen; 00200 //align merger sons on same level 00201 bool m_align; 00202 //settings for scaling compaction 00203 bool m_useScalingCompaction; 00204 int m_scalingSteps; 00205 //mainly used for OrthoShaper traditional/progressive 00206 int m_orthoStyle; 00207 int m_bendBound; 00208 }; 00209 00210 00211 } // end namespace ogdf 00212 00213 00214 #endif