5 |
5 |
6 int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Node node) |
6 int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Node node) |
7 { |
7 { |
8 Graph::NodeMap<double> * actual_map; |
8 Graph::NodeMap<double> * actual_map; |
9 double min, max; |
9 double min, max; |
10 if(mapname=="Default") |
10 min=mapstorage.minOfNodeMap(mapname); |
11 { |
11 max=mapstorage.maxOfNodeMap(mapname); |
12 min=node_property_defaults[N_RADIUS]; |
12 actual_map=(mapstorage.nodemap_storage)[mapname]; |
13 max=node_property_defaults[N_RADIUS]; |
|
14 actual_map=new Graph::NodeMap<double>(mapstorage.graph,node_property_defaults[N_RADIUS]); |
|
15 } |
|
16 else |
|
17 { |
|
18 min=mapstorage.minOfNodeMap(mapname); |
|
19 max=mapstorage.maxOfNodeMap(mapname); |
|
20 actual_map=(mapstorage.nodemap_storage)[mapname]; |
|
21 } |
|
22 |
13 |
23 if(node==INVALID) |
14 if(node==INVALID) |
24 { |
15 { |
25 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) |
16 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) |
26 { |
17 { |
67 } |
58 } |
68 } |
59 } |
69 return 0; |
60 return 0; |
70 }; |
61 }; |
71 |
62 |
|
63 int GraphDisplayerCanvas::resetNodeRadius (Node node) |
|
64 { |
|
65 Graph::NodeMap<double> * actual_map; |
|
66 double min, max; |
|
67 min=node_property_defaults[N_RADIUS]; |
|
68 max=node_property_defaults[N_RADIUS]; |
|
69 actual_map=new Graph::NodeMap<double>(mapstorage.graph,node_property_defaults[N_RADIUS]); |
|
70 |
|
71 if(node==INVALID) |
|
72 { |
|
73 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) |
|
74 { |
|
75 double v=fabs((*actual_map)[i]); |
|
76 int w; |
|
77 if(min==max) |
|
78 { |
|
79 w=(int)(node_property_defaults[N_RADIUS]); |
|
80 } |
|
81 else |
|
82 { |
|
83 w=(int)(MIN_NODE_RADIUS+(v-min)/(max-min)*(MAX_NODE_RADIUS-MIN_NODE_RADIUS)); |
|
84 } |
|
85 if(w>=0) |
|
86 { |
|
87 double x1, y1, x2, y2; |
|
88 x1=nodesmap[i]->property_x1().get_value(); |
|
89 x2=nodesmap[i]->property_x2().get_value(); |
|
90 y1=nodesmap[i]->property_y1().get_value(); |
|
91 y2=nodesmap[i]->property_y2().get_value(); |
|
92 nodesmap[i]->property_x1().set_value((x1+x2)/2-w); |
|
93 nodesmap[i]->property_x2().set_value((x1+x2)/2+w); |
|
94 nodesmap[i]->property_y1().set_value((y1+y2)/2-w); |
|
95 nodesmap[i]->property_y2().set_value((y1+y2)/2+w); |
|
96 } |
|
97 } |
|
98 } |
|
99 else |
|
100 { |
|
101 //I think only new nodes use this case |
|
102 // int w=(int)(*actual_map)[node]; |
|
103 int w=(int)(node_property_defaults[N_RADIUS]); |
|
104 if(w>=0) |
|
105 { |
|
106 double x1, y1, x2, y2; |
|
107 x1=nodesmap[node]->property_x1().get_value(); |
|
108 x2=nodesmap[node]->property_x2().get_value(); |
|
109 y1=nodesmap[node]->property_y1().get_value(); |
|
110 y2=nodesmap[node]->property_y2().get_value(); |
|
111 nodesmap[node]->property_x1().set_value((x1+x2)/2-w); |
|
112 nodesmap[node]->property_x2().set_value((x1+x2)/2+w); |
|
113 nodesmap[node]->property_y1().set_value((y1+y2)/2-w); |
|
114 nodesmap[node]->property_y2().set_value((y1+y2)/2+w); |
|
115 } |
|
116 } |
|
117 return 0; |
|
118 }; |
|
119 |
72 int GraphDisplayerCanvas::changeNodeColor (std::string mapname, Node node) |
120 int GraphDisplayerCanvas::changeNodeColor (std::string mapname, Node node) |
73 { |
121 { |
74 |
122 |
75 //function maps the range of the maximum and |
123 //function maps the range of the maximum and |
76 //the minimum of the nodemap to the range of |
124 //the minimum of the nodemap to the range of |
77 //green in RGB |
125 //green in RGB |
78 |
126 |
79 Graph::NodeMap<double> * actual_map; |
127 Graph::NodeMap<double> * actual_map; |
80 if(mapname=="Default") |
128 actual_map=(mapstorage.nodemap_storage)[mapname]; |
81 { |
|
82 actual_map=new Graph::NodeMap<double>(mapstorage.graph,node_property_defaults[N_COLOR]); |
|
83 } |
|
84 else |
|
85 { |
|
86 actual_map=(mapstorage.nodemap_storage)[mapname]; |
|
87 } |
|
88 |
129 |
89 double max, min; |
130 double max, min; |
90 |
131 |
91 if(mapname!="Default") |
132 max=mapstorage.maxOfNodeMap(mapname); |
92 { |
133 min=mapstorage.minOfNodeMap(mapname); |
93 max=mapstorage.maxOfNodeMap(mapname); |
134 |
94 min=mapstorage.minOfNodeMap(mapname); |
135 if(node==INVALID) |
95 } |
136 { |
96 else |
137 |
97 { |
138 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) |
98 max=node_property_defaults[N_COLOR]; |
139 { |
99 min=node_property_defaults[N_COLOR]; |
140 Gdk::Color color; |
100 } |
141 |
101 |
142 double w=(*actual_map)[i]; |
|
143 |
|
144 if(max!=min) |
|
145 { |
|
146 color.set_rgb_p (0, 0, 100*(w-min)/(max-min)); |
|
147 } |
|
148 else |
|
149 { |
|
150 color.set_rgb_p (0, 0, 100); |
|
151 } |
|
152 |
|
153 nodesmap[i]->property_fill_color_gdk().set_value(color); |
|
154 } |
|
155 } |
|
156 else |
|
157 { |
|
158 Gdk::Color color; |
|
159 |
|
160 double w=(*actual_map)[node]; |
|
161 |
|
162 if(max!=min) |
|
163 { |
|
164 color.set_rgb_p (0, 0, 100*(w-min)/(max-min)); |
|
165 } |
|
166 else |
|
167 { |
|
168 color.set_rgb_p (0, 0, 100); |
|
169 } |
|
170 |
|
171 nodesmap[node]->property_fill_color_gdk().set_value(color); |
|
172 } |
|
173 return 0; |
|
174 }; |
|
175 |
|
176 int GraphDisplayerCanvas::resetNodeColor (Node node) |
|
177 { |
|
178 |
|
179 //function maps the range of the maximum and |
|
180 //the minimum of the nodemap to the range of |
|
181 //green in RGB |
|
182 |
|
183 Graph::NodeMap<double> * actual_map; |
|
184 actual_map=new Graph::NodeMap<double>(mapstorage.graph,node_property_defaults[N_COLOR]); |
|
185 |
|
186 double max, min; |
|
187 |
|
188 max=node_property_defaults[N_COLOR]; |
|
189 min=node_property_defaults[N_COLOR]; |
102 |
190 |
103 if(node==INVALID) |
191 if(node==INVALID) |
104 { |
192 { |
105 |
193 |
106 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) |
194 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) |
148 //EXCEPT when the name of the map is Text, because |
236 //EXCEPT when the name of the map is Text, because |
149 //in that case empty string will be written, because |
237 //in that case empty string will be written, because |
150 //that is the deleter map |
238 //that is the deleter map |
151 |
239 |
152 Graph::NodeMap<double> * actual_map=NULL; |
240 Graph::NodeMap<double> * actual_map=NULL; |
153 if(mapname!="Default") |
241 actual_map=(mapstorage.nodemap_storage)[mapname]; |
154 { |
242 |
155 actual_map=(mapstorage.nodemap_storage)[mapname]; |
243 if(node==INVALID) |
156 } |
244 { |
157 |
245 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) |
158 if(node==INVALID) |
246 { |
159 { |
247 nodemap_to_edit=mapname; |
160 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) |
248 double number=(*actual_map)[i]; |
161 { |
|
162 if(mapname!="Default") |
|
163 { |
|
164 nodemap_to_edit=mapname; |
|
165 double number=(*actual_map)[i]; |
|
166 |
|
167 std::ostringstream ostr; |
|
168 ostr << number; |
|
169 |
|
170 nodetextmap[i]->property_text().set_value(ostr.str()); |
|
171 } |
|
172 else |
|
173 { |
|
174 nodemap_to_edit=""; |
|
175 nodetextmap[i]->property_text().set_value(""); |
|
176 } |
|
177 } |
|
178 } |
|
179 else |
|
180 { |
|
181 if(mapname!="Default") |
|
182 { |
|
183 double number=(*actual_map)[node]; |
|
184 |
249 |
185 std::ostringstream ostr; |
250 std::ostringstream ostr; |
186 ostr << number; |
251 ostr << number; |
187 |
252 |
188 nodetextmap[node]->property_text().set_value(ostr.str()); |
253 nodetextmap[i]->property_text().set_value(ostr.str()); |
189 } |
254 } |
190 else |
255 } |
191 { |
256 else |
192 nodetextmap[node]->property_text().set_value(""); |
257 { |
193 } |
258 double number=(*actual_map)[node]; |
194 } |
259 |
195 return 0; |
260 std::ostringstream ostr; |
196 }; |
261 ostr << number; |
|
262 |
|
263 nodetextmap[node]->property_text().set_value(ostr.str()); |
|
264 } |
|
265 return 0; |
|
266 }; |
|
267 |
|
268 int GraphDisplayerCanvas::resetNodeText (Node node) |
|
269 { |
|
270 |
|
271 //the number in the map will be written on the node |
|
272 //EXCEPT when the name of the map is Text, because |
|
273 //in that case empty string will be written, because |
|
274 //that is the deleter map |
|
275 |
|
276 if(node==INVALID) |
|
277 { |
|
278 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i) |
|
279 { |
|
280 nodemap_to_edit=""; |
|
281 nodetextmap[i]->property_text().set_value(""); |
|
282 } |
|
283 } |
|
284 else |
|
285 { |
|
286 nodetextmap[node]->property_text().set_value(""); |
|
287 } |
|
288 return 0; |
|
289 }; |