Open
Graph Drawing
Framework

 v.2010.10
 

GridLayout.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  
00053 #ifdef _MSC_VER
00054 #pragma once
00055 #endif
00056 
00057 #ifndef OGDF_GRID_LAYOUT_H
00058 #define OGDF_GRID_LAYOUT_H
00059 
00060 
00061 #include <ogdf/basic/NodeArray.h>
00062 #include <ogdf/basic/geometry.h>
00063 
00064 
00065 namespace ogdf {
00066 
00067     class Layout;
00068 
00069 
00070 
00074 class OGDF_EXPORT GridLayout
00075 {
00076 public:
00078     GridLayout() { }
00079 
00081     GridLayout(const Graph &G) : m_x(G,0), m_y(G,0), m_bends(G) { }
00082 
00083     // destruction
00084     virtual ~GridLayout() { }
00085 
00086     
00088     const NodeArray<int> &x() const { return m_x; }
00090     NodeArray<int> &x() { return m_x; }
00091 
00093     const NodeArray<int> &y() const { return m_y; }
00095     NodeArray<int> &y() { return m_y; }
00096 
00098     const EdgeArray<IPolyline> &bends() const { return m_bends; }
00100     EdgeArray<IPolyline> &bends() { return m_bends; }
00101 
00102 
00104     const int &x(node v) const { return m_x[v]; }
00106     int &x(node v) { return m_x[v]; }
00107 
00109     const int &y(node v) const { return m_y[v]; }
00111     int &y(node v) { return m_y[v]; }
00112 
00113 
00115     const IPolyline &bends(edge e) const { return m_bends[e]; }
00117     IPolyline &bends(edge e) { return m_bends[e]; }
00118 
00120     IPolyline polyline(edge e) const;
00121 
00122 
00124     void init(const Graph &G) {
00125         m_x.init(G,0);
00126         m_y.init(G,0);
00127         m_bends.init(G);
00128     }
00129 
00131     void init() {
00132         m_x.init();
00133         m_y.init();
00134         m_bends.init();
00135     }
00136 
00138     IPolyline getCompactBends(edge e) const;
00139 
00141     void compactAllBends();
00142 
00151     bool checkLayout();
00152 
00163     void computeBoundingBox(int &xmin, int &xmax, int &ymin, int &ymax);
00164 
00166     int totalManhattanEdgeLength() const;
00167 
00169     double totalEdgeLength() const;
00170 
00172     int numberOfBends() const;
00173 
00180     virtual void remap(Layout &drawing);
00181 
00182     static int manhattanDistance(const IPoint &ip1, const IPoint &ip2);
00183     static double euclideanDistance(const IPoint &ip1, const IPoint &ip2);
00184 
00185 protected:
00186     NodeArray<int> m_x;  
00187     NodeArray<int> m_y;  
00188     EdgeArray<IPolyline> m_bends; 
00189 
00190 private:
00191     static bool isRedundant(IPoint &p1, IPoint &p2, IPoint &p3);
00192     static void compact(IPolyline &ip);
00193 
00194 
00195     OGDF_MALLOC_NEW_DELETE
00196 }; // class GridLayout
00197 
00198 
00199 } // end namespace ogdf
00200 
00201 #endif