1 /** \file
2  * \brief Declaration of class NodeAttributes.
3  *
4  * \author Stefan Hachul
5  *
6  * \par License:
7  * This file is part of the Open Graph Drawing Framework (OGDF).
8  *
9  * \par
10  * Copyright (C)<br>
11  * See README.md in the OGDF root directory for details.
12  *
13  * \par
14  * This program is free software; you can redistribute it and/or
15  * modify it under the terms of the GNU General Public License
16  * Version 2 or 3 as published by the Free Software Foundation;
17  * see the file LICENSE.txt included in the packaging of this file
18  * for details.
19  *
20  * \par
21  * This program is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24  * GNU General Public License for more details.
25  *
26  * \par
27  * You should have received a copy of the GNU General Public
28  * License along with this program; if not, see
29  * http://www.gnu.org/copyleft/gpl.html
30  */
31 
32 #pragma once
33 
34 #include <ogdf/basic/geometry.h>
35 #include <ogdf/basic/Graph.h>
36 #include <ogdf/basic/List.h>
37 
38 namespace ogdf {
39 namespace energybased {
40 namespace fmmm {
41 
42 //! helping data structure that stores the graphical attributes of a node
43 //! that are needed for the force-directed algorithms.
44 class OGDF_EXPORT NodeAttributes
45 {
46 	//! outputstream for NodeAttributes
47 	friend OGDF_EXPORT std::ostream &operator<< (std::ostream &, const NodeAttributes &);
48 
49 	//! inputstream for NodeAttributes
50 	friend OGDF_EXPORT std::istream &operator>> (std::istream &, NodeAttributes &);
51 
52 public:
53 	//! Constructor
54 	NodeAttributes();
55 
set_NodeAttributes(double w,double h,DPoint pos,node v_low,node v_high)56 	void set_NodeAttributes(double w, double h, DPoint pos,node v_low,node
57 		v_high)
58 	{
59 		width = w;
60 		height = h;
61 		position = pos;
62 		v_lower_level = v_low;
63 		v_higher_level = v_high;
64 	}
65 
set_position(DPoint pos)66 	void set_position(DPoint pos) {position = pos;}
set_width(double w)67 	void set_width(double w) {width = w;}
set_height(double h)68 	void set_height(double h) {height = h;}
set_x(double x)69 	void set_x(double x) {position.m_x = x;}
set_y(double y)70 	void set_y(double y) {position.m_y = y;}
71 
get_position()72 	DPoint get_position() const { return position; }
get_x()73 	double get_x() const {return position.m_x;}
get_y()74 	double get_y() const {return position.m_y;}
get_width()75 	double get_width() const {return width;}
get_height()76 	double get_height() const {return height;}
77 
78 
79 	//! \name for preprocessing step in FMMM @{
80 
set_original_node(node v)81 	void set_original_node (node v) {v_lower_level = v;}
set_copy_node(node v)82 	void set_copy_node (node v) {v_higher_level = v;}
get_original_node()83 	node get_original_node() const {return v_lower_level;}
get_copy_node()84 	node get_copy_node() const {return v_higher_level;}
85 
86 	//! @}
87 	//! \name for divide et impera step in FMMM (set/get_original_node() are needed, too) @{
88 
set_subgraph_node(node v)89 	void set_subgraph_node (node v) {v_higher_level = v;}
get_subgraph_node()90 	node get_subgraph_node() const {return v_higher_level;}
91 
92 	//! @}
93 	//! \name for the multilevel step in FMMM @{
94 
set_lower_level_node(node v)95 	void set_lower_level_node (node v) {v_lower_level = v;}
set_higher_level_node(node v)96 	void set_higher_level_node (node v) {v_higher_level = v;}
get_lower_level_node()97 	node get_lower_level_node() const {return v_lower_level;}
get_higher_level_node()98 	node get_higher_level_node() const {return v_higher_level;}
set_mass(int m)99 	void set_mass(int m) {mass = m;}
set_type(int t)100 	void set_type(int t) {type = t;}
set_dedicated_sun_node(node v)101 	void set_dedicated_sun_node(node v){dedicated_sun_node = v;}
set_dedicated_sun_distance(double d)102 	void set_dedicated_sun_distance(double d) {dedicated_sun_distance = d;}
set_dedicated_pm_node(node v)103 	void set_dedicated_pm_node(node v) {dedicated_pm_node = v;}
place()104 	void place(){placed = true;}
set_angle_1(double a)105 	void set_angle_1(double a) {angle_1 = a;}
set_angle_2(double a)106 	void set_angle_2(double a) {angle_2 = a;}
107 
108 	//! @}
109 
get_mass()110 	int get_mass() const {return mass;}
get_type()111 	int get_type() const {return type;}
get_dedicated_sun_node()112 	node get_dedicated_sun_node() const {return dedicated_sun_node;}
get_dedicated_sun_distance()113 	double get_dedicated_sun_distance() const {return dedicated_sun_distance;}
get_dedicated_pm_node()114 	node get_dedicated_pm_node() const {return dedicated_pm_node;}
is_placed()115 	bool is_placed() const {return placed;}
get_angle_1()116 	double get_angle_1() const {return angle_1;}
get_angle_2()117 	double get_angle_2() const {return angle_2;}
118 
119 
get_lambda_List_ptr()120 	List<double>* get_lambda_List_ptr() {return lambda_List_ptr;}
get_neighbour_sun_node_List_ptr()121 	List<node>* get_neighbour_sun_node_List_ptr() {return neighbour_s_node_List_ptr;}
get_dedicated_moon_node_List_ptr()122 	List<node>* get_dedicated_moon_node_List_ptr() {return moon_List_ptr;}
123 
124 
125 	//! initialzes all values needed for multilevel representations
126 	void init_mult_values();
127 
128 private:
129 
130 	DPoint position;
131 	double width;
132 	double height;
133 
134 	//! \name for the multilevel and divide et impera and preprocessing step @{
135 
136 	node v_lower_level; //!< the corresponding node in the lower level graph
137 	node v_higher_level;//!< the corresponding node in the higher level graph
138 	//! for divide et impera v_lower_level is the original graph and
139 	//! v_higher_level is the copy of the copy of this node in the
140 	//! maximum connected subraph
141 
142 	//! @}
143 	//! \name for the multilevel step @{
144 
145 	int mass; //!< the mass (= number of previously collapsed nodes) of this node
146 	int type; //!< 1 = sun node (s_node); 2 = planet node (p_node) without a dedicate moon
147 	//! 3 = planet node with dedicated moons (pm_node);4 = moon node (m_node)
148 	node dedicated_sun_node; //!< the dedicates s_node of the solar system of this node
149 	double dedicated_sun_distance;//!< the distance to the dedicated sun node of the galaxy
150 	//! of this node
151 	node dedicated_pm_node;//!< if type == 4 the dedicated_pm_node is saved here
152 	List<double> lambda; //!< the factors lambda for scaling the length of this edge
153 	//! relative to the pass between v's sun and the sun of a
154 	//! neighbour solar system
155 	List<node> neighbour_s_node;//!< this is the list of the neighbour solar systems suns
156 	//! lambda[i] corresponds to neighbour_s_node[i]
157 	List<double>* lambda_List_ptr; //!< a pointer to the lambda list
158 	List<node>* neighbour_s_node_List_ptr; //!< a pointer to to the neighbour_s_node list
159 	List<node>  moon_List;//!< the list of all dedicated moon nodes (!= nil if type == 3)
160 	List<node>* moon_List_ptr;//!< a pointer to the moon_List
161 	bool placed;   //!< indicates weather an initial position has been assigned to this
162 	//! node or not
163 	double angle_1;//!< describes the sector where nodes that are not adjacent to other
164 	double angle_2;//!< solar systems have to be placed
165 
166 	//! @}
167 };
168 
169 }
170 }
171 }
172