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 #ifdef _MSC_VER 00042 #pragma once 00043 #endif 00044 00045 #ifndef OGDF_UPWARD_PLANARIZATION_LAYOUT_H 00046 #define OGDF_UPWARD_PLANARIZATION_LAYOUT_H 00047 00048 00049 00050 #include <ogdf/module/LayoutModule.h> 00051 #include <ogdf/module/HierarchyLayoutModule.h> 00052 #include <ogdf/module/UpwardPlanarizerModule.h> 00053 #include <ogdf/module/UPRLayoutModule.h> 00054 #include <ogdf/basic/ModuleOption.h> 00055 #include <ogdf/upward/UpwardPlanRep.h> 00056 #include <ogdf/upward/LayerBasedUPRLayout.h> 00057 #include <ogdf/upward/SubgraphUpwardPlanarizer.h> 00058 00059 00060 00061 namespace ogdf { 00062 00063 00064 00065 class OGDF_EXPORT UpwardPlanarizationLayout : public LayoutModule 00066 { 00067 public: 00068 00069 // constructor: sets options to default values 00070 UpwardPlanarizationLayout() 00071 { 00072 m_cr_nr = 0; 00073 // set default module 00074 m_layout.set(new LayerBasedUPRLayout()); 00075 m_UpwardPlanarizer.set(new SubgraphUpwardPlanarizer()); 00076 }; 00077 00078 // destructor 00079 ~UpwardPlanarizationLayout() { } 00080 00081 00082 // calls the algorithm for attributed graph AG 00083 // returns layout information in AG 00084 void call(GraphAttributes &AG) 00085 { 00086 UpwardPlanRep UPR; 00087 UPR.createEmpty(AG.constGraph()); 00088 m_UpwardPlanarizer.get().call(UPR); 00089 m_layout.get().call(UPR, AG); 00090 m_cr_nr = UPR.numberOfCrossings(); 00091 m_numLevels = m_layout.get().numberOfLevels; 00092 } 00093 00094 00095 // module option for the computation of the final layout 00096 void setUPRLayout(UPRLayoutModule *pLayout) { 00097 m_layout.set(pLayout); 00098 } 00099 00100 00101 void setUpwardPlanarizer(UpwardPlanarizerModule *pUpwardPlanarizer) { 00102 m_UpwardPlanarizer.set(pUpwardPlanarizer); 00103 } 00104 00105 // returns the number of crossings in the layout after the algorithm 00106 // has been applied 00107 int numberOfCrossings() const { return m_cr_nr; } 00108 00109 int numberOfLevels() const {return m_numLevels;}; 00110 00111 protected: 00112 00113 int m_cr_nr; 00114 00115 int m_numLevels; 00116 00117 ModuleOption<UpwardPlanarizerModule> m_UpwardPlanarizer; 00118 00119 ModuleOption<UPRLayoutModule> m_layout; 00120 }; 00121 00122 00123 } 00124 00125 #endif