Open
Graph Drawing
Framework

 v.2012.05
 

SugiyamaLayout.h
Go to the documentation of this file.
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  
00043 #ifdef _MSC_VER
00044 #pragma once
00045 #endif
00046 
00047 #ifndef OGDF_SUGIYAMA_LAYOUT_H
00048 #define OGDF_SUGIYAMA_LAYOUT_H
00049 
00050 
00051 
00052 #include <ogdf/module/LayoutModule.h>
00053 #include <ogdf/module/RankingModule.h>
00054 #include <ogdf/simultaneous/TwoLayerCrossMinSimDraw.h>
00055 #include <ogdf/module/HierarchyLayoutModule.h>
00056 #include <ogdf/module/HierarchyClusterLayoutModule.h>
00057 #include <ogdf/module/CCLayoutPackModule.h>
00058 #include <ogdf/basic/ModuleOption.h>
00059 #include <ogdf/cluster/ClusterGraphAttributes.h>
00060 
00061 
00062 namespace ogdf {
00063 
00064     class OGDF_EXPORT ExtendedNestingGraph;
00065 
00177 class OGDF_EXPORT SugiyamaLayout : public LayoutModule {
00178 
00179 protected:
00180 
00182     ModuleOption<RankingModule>                m_ranking;
00183 
00185     ModuleOption<TwoLayerCrossMin>             m_crossMin;
00186 
00187     ModuleOption<TwoLayerCrossMinSimDraw>      m_crossMinSimDraw;
00188 
00190     ModuleOption<HierarchyLayoutModule>        m_layout;
00191 
00193     ModuleOption<HierarchyClusterLayoutModule> m_clusterLayout;
00194 
00196     ModuleOption<CCLayoutPackModule>           m_packer;
00197 
00198     int    m_fails;      
00199     int    m_runs;       
00200     bool   m_transpose;  
00201     bool   m_arrangeCCs; 
00202     double m_minDistCC;  
00203     double m_pageRatio;  
00204     bool   m_permuteFirst;
00205 
00206     int m_nCrossings;    
00207     RCCrossings m_nCrossingsCluster;
00208     Array<bool> m_levelChanged;
00209 
00210     bool m_alignBaseClasses; 
00211     bool m_alignSiblings;    
00212     
00213     EdgeArray<unsigned int> *m_subgraphs; 
00214 
00215 public:
00216 
00218     SugiyamaLayout();
00219 
00220     // destructor
00221     ~SugiyamaLayout() { }
00222 
00223 
00234     void call(GraphAttributes &AG);
00235 
00241     void call(ClusterGraphAttributes &AG);
00242 
00251     void call(GraphAttributes &AG, NodeArray<int> &rank);
00252 
00253     // special call for UML graphs
00254     void callUML(GraphAttributes &AG);
00255 
00256 
00269     int fails() const { return m_fails; }
00270 
00272     void fails(int nFails) { m_fails = nFails; }
00273 
00282     int runs() const { return m_runs; }
00283 
00285     void runs(int nRuns) { m_runs = nRuns; }
00286 
00294     bool transpose() const { return m_transpose; }
00295 
00297     void transpose(bool bTranspose) { m_transpose = bTranspose; }
00298 
00305     bool arrangeCCs() const { return m_arrangeCCs; }
00306 
00308     void arrangeCCs(bool bArrange) { m_arrangeCCs = bArrange; }
00309 
00316     double minDistCC() const { return m_minDistCC; }
00317 
00319     void minDistCC(double x) { m_minDistCC = x; }
00320 
00328     double pageRatio() const { return m_pageRatio; }
00329 
00331     void pageRatio(double x) { m_pageRatio = x; }
00332 
00339     bool alignBaseClasses() const { return m_alignBaseClasses; }
00340 
00342     void alignBaseClasses(bool b) { m_alignBaseClasses = b; }
00343 
00350     bool alignSiblings() const { return m_alignSiblings; }
00351 
00353     void alignSiblings(bool b) { m_alignSiblings = b; }
00354 
00356     void setSubgraphs(EdgeArray<unsigned int> *esg) { m_subgraphs = esg; }
00357 
00359     bool useSubgraphs() const { return (m_subgraphs == 0) ? 0 : 1; }
00360 
00361 
00362     bool permuteFirst() const { return m_permuteFirst; }
00363     void permuteFirst(bool b) { m_permuteFirst = b; }
00364 
00365 
00381     void setRanking(RankingModule *pRanking) {
00382         m_ranking.set(pRanking);
00383     }
00384 
00391     void setCrossMin(TwoLayerCrossMin *pCrossMin) {
00392         m_crossMin.set(pCrossMin);
00393     }
00394 
00402     void setLayout(HierarchyLayoutModule *pLayout) {
00403         m_layout.set(pLayout);
00404     }
00405 
00413     void setClusterLayout(HierarchyClusterLayoutModule *pLayout) {
00414         m_clusterLayout.set(pLayout);
00415     }
00416 
00424     void setPacker(CCLayoutPackModule *pPacker) {
00425         m_packer.set(pPacker);
00426     }
00427 
00434 
00435     int numberOfCrossings() const { return m_nCrossings; }
00436 
00438     RCCrossings numberOfCrossingsCluster() const { return m_nCrossingsCluster; }
00439 
00441     int numberOfLevels() { return m_numLevels; }
00442 
00444     int maxLevelSize() { return m_maxLevelSize; }
00445 
00446     double timeReduceCrossings() { return m_timeReduceCrossings; }
00447 
00448 protected:
00449 
00450     void reduceCrossings(Hierarchy &H);
00451     //void reduceCrossings2(Hierarchy &H);
00452     void reduceCrossings(ExtendedNestingGraph &H);
00453 
00454 private:
00455     int m_numCC;
00456     NodeArray<int> m_compGC;
00457 
00458     void doCall(GraphAttributes &AG, bool umlCall);
00459     void doCall(GraphAttributes &AG, bool umlCall, NodeArray<int> &rank);
00460 
00461     int traverseTopDown (Hierarchy &H);
00462     int traverseBottomUp(Hierarchy &H);
00463     //int traverseTopDown2 (Hierarchy &H);
00464     //int traverseBottomUp2(Hierarchy &H);
00465 
00466     bool transposeLevel(int i, Hierarchy &H);
00467     void doTranspose(Hierarchy &H);
00468     void doTransposeRev(Hierarchy &H);
00469 
00470     int m_numLevels;
00471     int m_maxLevelSize;
00472     double m_timeReduceCrossings;
00473 
00474     RCCrossings traverseTopDown (ExtendedNestingGraph &H);
00475     RCCrossings traverseBottomUp(ExtendedNestingGraph &H);
00476 
00477     //NodeArray<double> m_weight;
00478 };
00479 
00480 
00481 }
00482 
00483 #endif