Open
Graph Drawing
Framework

 v.2012.05
 

ClusterGraphCopyAttributes.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  
00044 #ifdef _MSC_VER
00045 #pragma once
00046 #endif
00047 
00048 #ifndef OGDF_A_CLUSTER_GRAPH_COPY_H
00049 #define OGDF_A_CLUSTER_GRAPH_COPY_H
00050 
00051 
00052 
00053 #include <ogdf/layered/ExtendedNestingGraph.h>
00054 #include <ogdf/cluster/ClusterGraphAttributes.h>
00055 
00056 
00057 namespace ogdf {
00058 
00062 class OGDF_EXPORT ClusterGraphCopyAttributes {
00063 
00064     const ExtendedNestingGraph *m_pH;
00065     ClusterGraphAttributes     *m_pACG;
00066     NodeArray<double> m_x, m_y;
00067 
00068 public:
00070     ClusterGraphCopyAttributes(
00071         const ExtendedNestingGraph &H,
00072         ClusterGraphAttributes &ACG) :
00073         m_pH(&H), m_pACG(&ACG), m_x(H,0), m_y(H,0) { }
00074 
00075     ~ClusterGraphCopyAttributes() { }
00076 
00078     const ClusterGraphAttributes &getClusterGraphAttributes() const { return *m_pACG; }
00079 
00081     double getWidth(node v) const {
00082         node vOrig = m_pH->origNode(v);
00083         return (vOrig == 0) ? 0.0 : m_pACG->width(vOrig);
00084     }
00085 
00087     double getHeight(node v) const {
00088         node vOrig = m_pH->origNode(v);
00089         return (vOrig == 0) ? 0.0 : m_pACG->height(vOrig);
00090     }
00091 
00093     const double &x(node v) const {
00094         return m_x[v];
00095     }
00096 
00098     double &x(node v) {
00099         return m_x[v];
00100     }
00101 
00103     const double &y(node v) const {
00104         return m_y[v];
00105     }
00106 
00108     double &y(node v) {
00109         return m_y[v];
00110     }
00111 
00113     double top(cluster cOrig) const {
00114         return m_pACG->clusterYPos(cOrig);
00115     }
00117     double bottom(cluster cOrig) const {
00118         return m_pACG->clusterYPos(cOrig) + m_pACG->clusterHeight(cOrig);
00119     }
00120 
00122     void setClusterRect(
00123         cluster cOrig,
00124         double left,
00125         double right,
00126         double top,
00127         double bottom)
00128     {
00129         m_pACG->clusterXPos  (cOrig) = left;
00130         m_pACG->clusterYPos  (cOrig) = top;
00131         m_pACG->clusterWidth (cOrig) = right-left;
00132         m_pACG->clusterHeight(cOrig) = bottom-top;
00133     }
00134 
00135     void setClusterLeftRight(
00136         cluster cOrig,
00137         double left,
00138         double right)
00139     {
00140         m_pACG->clusterXPos  (cOrig) = left;
00141         m_pACG->clusterWidth (cOrig) = right-left;
00142     }
00143 
00144     void setClusterTopBottom(
00145         cluster cOrig,
00146         double top,
00147         double bottom)
00148     {
00149         m_pACG->clusterYPos  (cOrig) = top;
00150         m_pACG->clusterHeight(cOrig) = bottom-top;
00151     }
00152 
00154     void transform();
00155 };
00156 
00157 
00158 } // end namespace ogdf
00159 
00160 
00161 #endif