Open
Graph Drawing
Framework

 v.2010.10
 

OrthoLayout.h

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