6 * $Date: 2012-07-02 20:59:27 +0200 (Mon, 02 Jul 2012) $
7 ***************************************************************/
10 * \brief Declares ClusterGraphCopyAttributes, which manages access
11 * on copy of an attributed clustered graph.
13 * \author Carsten Gutwenger
16 * This file is part of the Open Graph Drawing Framework (OGDF).
20 * See README.txt in the root directory of the OGDF installation for details.
23 * This program is free software; you can redistribute it and/or
24 * modify it under the terms of the GNU General Public License
25 * Version 2 or 3 as published by the Free Software Foundation;
26 * see the file LICENSE.txt included in the packaging of this file
30 * This program is distributed in the hope that it will be useful,
31 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 * GNU General Public License for more details.
36 * You should have received a copy of the GNU General Public
37 * License along with this program; if not, write to the Free
38 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
39 * Boston, MA 02110-1301, USA.
41 * \see http://www.gnu.org/copyleft/gpl.html
42 ***************************************************************/
49 #ifndef OGDF_A_CLUSTER_GRAPH_COPY_H
50 #define OGDF_A_CLUSTER_GRAPH_COPY_H
54 #include <ogdf/layered/ExtendedNestingGraph.h>
55 #include <ogdf/cluster/ClusterGraphAttributes.h>
61 * \brief Manages access on copy of an attributed clustered graph
63 class OGDF_EXPORT ClusterGraphCopyAttributes
{
65 const ExtendedNestingGraph
*m_pH
;
66 ClusterGraphAttributes
*m_pACG
;
67 NodeArray
<double> m_x
, m_y
;
70 //! Initializes instance of class ClusterGraphCopyAttributes.
71 ClusterGraphCopyAttributes(
72 const ExtendedNestingGraph
&H
,
73 ClusterGraphAttributes
&ACG
) :
74 m_pH(&H
), m_pACG(&ACG
), m_x(H
,0), m_y(H
,0) { }
76 ~ClusterGraphCopyAttributes() { }
78 //! Returns corresponding ClusterGraphAttributes.
79 const ClusterGraphAttributes
&getClusterGraphAttributes() const { return *m_pACG
; }
81 //! Returns width of node v.
82 double getWidth(node v
) const {
83 node vOrig
= m_pH
->origNode(v
);
84 return (vOrig
== 0) ? 0.0 : m_pACG
->width(vOrig
);
87 //! Returns height of node v.
88 double getHeight(node v
) const {
89 node vOrig
= m_pH
->origNode(v
);
90 return (vOrig
== 0) ? 0.0 : m_pACG
->height(vOrig
);
93 //! Returns reference to x-coord. of node v.
94 const double &x(node v
) const {
98 //! Returns reference to x-coord. of node v.
103 //! Returns reference to y-coord. of node v.
104 const double &y(node v
) const {
108 //! Returns reference to y-coord. of node v.
113 //! Returns coordinate of upper cluster boundary of original cluster \a cOrig.
114 double top(cluster cOrig
) const {
115 return m_pACG
->clusterYPos(cOrig
);
117 //! Returns coordinate of lower cluster boundary of original cluster \a cOrig.
118 double bottom(cluster cOrig
) const {
119 return m_pACG
->clusterYPos(cOrig
) + m_pACG
->clusterHeight(cOrig
);
122 //! Sets the position of the cluster rectangle for original cluster \a cOrig.
130 m_pACG
->clusterXPos (cOrig
) = left
;
131 m_pACG
->clusterYPos (cOrig
) = top
;
132 m_pACG
->clusterWidth (cOrig
) = right
-left
;
133 m_pACG
->clusterHeight(cOrig
) = bottom
-top
;
136 void setClusterLeftRight(
141 m_pACG
->clusterXPos (cOrig
) = left
;
142 m_pACG
->clusterWidth (cOrig
) = right
-left
;
145 void setClusterTopBottom(
150 m_pACG
->clusterYPos (cOrig
) = top
;
151 m_pACG
->clusterHeight(cOrig
) = bottom
-top
;
154 //! Sets attributes for the original graph in attributed graph.
159 } // end namespace ogdf