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 00044 #ifdef _MSC_VER 00045 #pragma once 00046 #endif 00047 00048 00049 #ifndef OGDF_GRID_LAYOUT_MAPPED_H 00050 #define OGDF_GRID_LAYOUT_MAPPED_H 00051 00052 00053 #include <ogdf/basic/GridLayout.h> 00054 00055 00056 namespace ogdf { 00057 00058 class OGDF_EXPORT PlanRep; 00059 class OGDF_EXPORT PlanRepUML; 00060 class OGDF_EXPORT OrthoRep; 00061 00062 00063 //--------------------------------------------------------- 00064 // GridLayoutMapped 00065 // extends GridLayout by a grid mapping mechanism 00066 //--------------------------------------------------------- 00067 class OGDF_EXPORT GridLayoutMapped : public GridLayout 00068 { 00069 //scaling to allow correct edge anchors 00070 enum { cGridScale = 2 }; 00071 00072 public: 00073 00074 // construction (determines mapping factor) 00075 GridLayoutMapped(const PlanRep &PG, 00076 const OrthoRep &OR, 00077 double separation, 00078 double cOverhang, 00079 int fineness = 4); 00080 00081 00082 // writes grid layout to layout using re-mapping 00083 void remap(Layout &drawing); 00084 00085 // transforms real coordinates to grid coordinates 00086 int toGrid(double x) const { 00087 return cGridScale*int(m_fMapping * x + 0.5); 00088 } 00089 00090 // transforms grid coordinates to real coordinates 00091 double toDouble(int i) const { 00092 return (i/cGridScale) / m_fMapping; 00093 } 00094 00095 00096 const NodeArray<int> &width() const { return m_gridWidth; } 00097 // returns a reference to the array storing grid widths of nodes 00098 NodeArray<int> &width() { return m_gridWidth; } 00099 00100 const NodeArray<int> &height() const { return m_gridHeight; } 00101 // returns a reference to the array storing grid heights of nodes 00102 NodeArray<int> &height() { return m_gridHeight; } 00103 00104 const int &width(node v) const { return m_gridWidth[v]; } 00105 // returns grid width of node v 00106 int &width(node v) { return m_gridWidth[v]; } 00107 00108 const int &height(node v) const { return m_gridWidth[v]; } 00109 // returns grid height of node v 00110 int &height(node v) { return m_gridWidth[v]; } 00111 00112 00113 private: 00114 NodeArray<int> m_gridWidth; // grid width of nodes 00115 NodeArray<int> m_gridHeight; // grid heights of nodes 00116 00117 const PlanRep *m_pPG; // planarized representation of grid layout 00118 double m_fMapping; // mapping factor 00119 }; 00120 00121 00122 } // end namespace ogdf 00123 00124 00125 #endif