23 |
23 |
24 const int minimum_node_radius=5; |
24 const int minimum_node_radius=5; |
25 |
25 |
26 int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Node node) |
26 int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Node node) |
27 { |
27 { |
28 Graph::NodeMap<double> * actual_map; |
28 MapStorage& ms = *mytab.mapstorage; |
|
29 |
29 double min, max; |
30 double min, max; |
30 min=(mytab.mapstorage)->minOfNodeMap(mapname); |
31 |
31 max=(mytab.mapstorage)->maxOfNodeMap(mapname); |
32 { |
32 actual_map=((mytab.mapstorage)->nodemap_storage)[mapname]; |
33 NodeIt n(ms.graph); |
33 |
34 min = max = ms.get(mapname, n); |
34 if(node==INVALID) |
35 for (; n != INVALID; ++n) |
35 { |
36 { |
36 for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i) |
37 if (static_cast<double>(ms.get(mapname, n)) > max) |
37 { |
38 max = ms.get(mapname, n); |
38 double v=fabs((*actual_map)[i]); |
39 if (static_cast<double>(ms.get(mapname, n)) < min) |
|
40 min = ms.get(mapname, n); |
|
41 } |
|
42 } |
|
43 |
|
44 if(node==INVALID) |
|
45 { |
|
46 for (NodeIt i(ms.graph); i!=INVALID; ++i) |
|
47 { |
|
48 double v=fabs(ms.get(mapname,i)); |
39 int w; |
49 int w; |
40 if(autoscale) |
50 if(autoscale) |
41 { |
51 { |
42 if(min==max) |
52 if(min==max) |
43 { |
53 { |
100 return 0; |
110 return 0; |
101 }; |
111 }; |
102 |
112 |
103 int GraphDisplayerCanvas::resetNodeRadius (Node node) |
113 int GraphDisplayerCanvas::resetNodeRadius (Node node) |
104 { |
114 { |
|
115 MapStorage& ms = *mytab.mapstorage; |
|
116 |
105 double min, max; |
117 double min, max; |
106 min=node_property_defaults[N_RADIUS]; |
118 min=node_property_defaults[N_RADIUS]; |
107 max=node_property_defaults[N_RADIUS]; |
119 max=node_property_defaults[N_RADIUS]; |
108 Graph::NodeMap<double> actual_map((mytab.mapstorage)->graph,node_property_defaults[N_RADIUS]); |
120 Graph::NodeMap<double> actual_map(ms.graph,node_property_defaults[N_RADIUS]); |
109 |
121 |
110 if(node==INVALID) |
122 if(node==INVALID) |
111 { |
123 { |
112 for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i) |
124 for (NodeIt i(ms.graph); i!=INVALID; ++i) |
113 { |
125 { |
114 double v=fabs(actual_map[i]); |
126 double v=fabs(actual_map[i]); |
115 int w; |
127 int w; |
116 if(min==max) |
128 if(min==max) |
117 { |
129 { |
161 return 0; |
173 return 0; |
162 }; |
174 }; |
163 |
175 |
164 int GraphDisplayerCanvas::changeNodeColor (std::string mapname, Node node) |
176 int GraphDisplayerCanvas::changeNodeColor (std::string mapname, Node node) |
165 { |
177 { |
|
178 MapStorage& ms = *mytab.mapstorage; |
166 |
179 |
167 //function maps the range of the maximum and |
180 //function maps the range of the maximum and |
168 //the minimum of the nodemap to the range of |
181 //the minimum of the nodemap to the range of |
169 //green in RGB |
182 //green in RGB |
170 |
183 |
171 Graph::NodeMap<double> * actual_map; |
|
172 actual_map=((mytab.mapstorage)->nodemap_storage)[mapname]; |
|
173 |
|
174 double max, min; |
184 double max, min; |
175 |
185 |
176 max=(mytab.mapstorage)->maxOfNodeMap(mapname); |
186 { |
177 min=(mytab.mapstorage)->minOfNodeMap(mapname); |
187 NodeIt n(ms.graph); |
178 |
188 min = max = ms.get(mapname, n); |
179 if(node==INVALID) |
189 for (; n != INVALID; ++n) |
180 { |
190 { |
181 |
191 if (static_cast<double>(ms.get(mapname, n)) > max) |
182 for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i) |
192 max = ms.get(mapname, n); |
|
193 if (static_cast<double>(ms.get(mapname, n)) < min) |
|
194 min = ms.get(mapname, n); |
|
195 } |
|
196 } |
|
197 |
|
198 if(node==INVALID) |
|
199 { |
|
200 |
|
201 for (NodeIt i(ms.graph); i!=INVALID; ++i) |
183 { |
202 { |
184 Gdk::Color color; |
203 Gdk::Color color; |
185 |
204 |
186 double w=(*actual_map)[i]; |
205 double w=ms.get(mapname, i); |
187 |
206 |
188 if(max!=min) |
207 if(max!=min) |
189 { |
208 { |
190 color=rainbowColorCounter(min, max, w); |
209 color=rainbowColorCounter(min, max, w); |
191 } |
210 } |
217 return 0; |
236 return 0; |
218 }; |
237 }; |
219 |
238 |
220 int GraphDisplayerCanvas::resetNodeColor (Node node) |
239 int GraphDisplayerCanvas::resetNodeColor (Node node) |
221 { |
240 { |
|
241 MapStorage& ms = *mytab.mapstorage; |
222 |
242 |
223 //function maps the range of the maximum and |
243 //function maps the range of the maximum and |
224 //the minimum of the nodemap to the range of |
244 //the minimum of the nodemap to the range of |
225 //green in RGB |
245 //green in RGB |
226 |
246 |
227 Graph::NodeMap<double> actual_map((mytab.mapstorage)->graph,node_property_defaults[N_COLOR]); |
247 Graph::NodeMap<double> actual_map(ms.graph,node_property_defaults[N_COLOR]); |
228 |
248 |
229 double max, min; |
249 double max, min; |
230 |
250 |
231 max=node_property_defaults[N_COLOR]; |
251 max=node_property_defaults[N_COLOR]; |
232 min=node_property_defaults[N_COLOR]; |
252 min=node_property_defaults[N_COLOR]; |
233 |
253 |
234 if(node==INVALID) |
254 if(node==INVALID) |
235 { |
255 { |
236 |
256 |
237 for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i) |
257 for (NodeIt i(ms.graph); i!=INVALID; ++i) |
238 { |
258 { |
239 Gdk::Color color; |
259 Gdk::Color color; |
240 |
260 |
241 double w=actual_map[i]; |
261 double w=actual_map[i]; |
242 |
262 |
272 return 0; |
292 return 0; |
273 }; |
293 }; |
274 |
294 |
275 int GraphDisplayerCanvas::changeNodeText (std::string mapname, Node node) |
295 int GraphDisplayerCanvas::changeNodeText (std::string mapname, Node node) |
276 { |
296 { |
|
297 MapStorage& ms = *mytab.mapstorage; |
277 |
298 |
278 //the number in the map will be written on the node |
299 //the number in the map will be written on the node |
279 //EXCEPT when the name of the map is Text, because |
300 //EXCEPT when the name of the map is Text, because |
280 //in that case empty string will be written, because |
301 //in that case empty string will be written, because |
281 //that is the deleter map |
302 //that is the deleter map |
282 |
303 |
283 Graph::NodeMap<double> * actual_map=NULL; |
304 if(node==INVALID) |
284 actual_map=((mytab.mapstorage)->nodemap_storage)[mapname]; |
305 { |
285 |
306 for (NodeIt i(ms.graph); i!=INVALID; ++i) |
286 if(node==INVALID) |
|
287 { |
|
288 for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i) |
|
289 { |
307 { |
290 nodemap_to_edit=mapname; |
308 nodemap_to_edit=mapname; |
291 double number=(*actual_map)[i]; |
309 |
292 |
310 nodetextmap[i]->property_text().set_value( |
293 std::ostringstream ostr; |
311 static_cast<std::string>(ms.get(mapname, i))); |
294 ostr << number; |
312 } |
295 |
313 } |
296 nodetextmap[i]->property_text().set_value(ostr.str()); |
314 else |
297 } |
315 { |
298 } |
316 nodetextmap[node]->property_text().set_value( |
299 else |
317 static_cast<std::string>(ms.get(mapname, node))); |
300 { |
|
301 double number=(*actual_map)[node]; |
|
302 |
|
303 std::ostringstream ostr; |
|
304 ostr << number; |
|
305 |
|
306 nodetextmap[node]->property_text().set_value(ostr.str()); |
|
307 } |
318 } |
308 return 0; |
319 return 0; |
309 }; |
320 }; |
310 |
321 |
311 int GraphDisplayerCanvas::resetNodeText (Node node) |
322 int GraphDisplayerCanvas::resetNodeText (Node node) |
312 { |
323 { |
|
324 MapStorage& ms = *mytab.mapstorage; |
313 |
325 |
314 //the number in the map will be written on the node |
326 //the number in the map will be written on the node |
315 //EXCEPT when the name of the map is Text, because |
327 //EXCEPT when the name of the map is Text, because |
316 //in that case empty string will be written, because |
328 //in that case empty string will be written, because |
317 //that is the deleter map |
329 //that is the deleter map |
318 |
330 |
319 if(node==INVALID) |
331 if(node==INVALID) |
320 { |
332 { |
321 for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i) |
333 for (NodeIt i(ms.graph); i!=INVALID; ++i) |
322 { |
334 { |
323 nodemap_to_edit=""; |
335 nodemap_to_edit=""; |
324 nodetextmap[i]->property_text().set_value(""); |
336 nodetextmap[i]->property_text().set_value(""); |
325 } |
337 } |
326 } |
338 } |