1 #include "graph_displayer_canvas.h"
5 int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Node node)
7 Graph::NodeMap<double> * actual_map;
9 min=(mytab.mapstorage).minOfNodeMap(mapname);
10 max=(mytab.mapstorage).maxOfNodeMap(mapname);
11 actual_map=((mytab.mapstorage).nodemap_storage)[mapname];
15 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
17 double v=fabs((*actual_map)[i]);
23 w=(int)(node_property_defaults[N_RADIUS]);
27 w=(int)(radius_min+(v-min)/(max-min)*(radius_max-radius_min));
32 w=5+(int)(v/radius_unit);
36 double x1, y1, x2, y2;
37 x1=nodesmap[i]->property_x1().get_value();
38 x2=nodesmap[i]->property_x2().get_value();
39 y1=nodesmap[i]->property_y1().get_value();
40 y2=nodesmap[i]->property_y2().get_value();
41 nodesmap[i]->property_x1().set_value((x1+x2)/2-w);
42 nodesmap[i]->property_x2().set_value((x1+x2)/2+w);
43 nodesmap[i]->property_y1().set_value((y1+y2)/2-w);
44 nodesmap[i]->property_y2().set_value((y1+y2)/2+w);
50 //I think only new nodes use this case
51 //that has no own value, only the default one
52 //int w=(int)(*actual_map)[node];
53 int w=(int)(node_property_defaults[N_RADIUS]);
56 double x1, y1, x2, y2;
57 x1=nodesmap[node]->property_x1().get_value();
58 x2=nodesmap[node]->property_x2().get_value();
59 y1=nodesmap[node]->property_y1().get_value();
60 y2=nodesmap[node]->property_y2().get_value();
61 nodesmap[node]->property_x1().set_value((x1+x2)/2-w);
62 nodesmap[node]->property_x2().set_value((x1+x2)/2+w);
63 nodesmap[node]->property_y1().set_value((y1+y2)/2-w);
64 nodesmap[node]->property_y2().set_value((y1+y2)/2+w);
70 int GraphDisplayerCanvas::resetNodeRadius (Node node)
73 min=node_property_defaults[N_RADIUS];
74 max=node_property_defaults[N_RADIUS];
75 Graph::NodeMap<double> actual_map((mytab.mapstorage).graph,node_property_defaults[N_RADIUS]);
79 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
81 double v=fabs(actual_map[i]);
85 w=(int)(node_property_defaults[N_RADIUS]);
89 w=(int)(MIN_NODE_RADIUS+(v-min)/(max-min)*(MAX_NODE_RADIUS-MIN_NODE_RADIUS));
93 double x1, y1, x2, y2;
94 x1=nodesmap[i]->property_x1().get_value();
95 x2=nodesmap[i]->property_x2().get_value();
96 y1=nodesmap[i]->property_y1().get_value();
97 y2=nodesmap[i]->property_y2().get_value();
98 nodesmap[i]->property_x1().set_value((x1+x2)/2-w);
99 nodesmap[i]->property_x2().set_value((x1+x2)/2+w);
100 nodesmap[i]->property_y1().set_value((y1+y2)/2-w);
101 nodesmap[i]->property_y2().set_value((y1+y2)/2+w);
107 //I think only new nodes use this case
108 // int w=(int)actual_map[node];
109 int w=(int)(node_property_defaults[N_RADIUS]);
112 double x1, y1, x2, y2;
113 x1=nodesmap[node]->property_x1().get_value();
114 x2=nodesmap[node]->property_x2().get_value();
115 y1=nodesmap[node]->property_y1().get_value();
116 y2=nodesmap[node]->property_y2().get_value();
117 nodesmap[node]->property_x1().set_value((x1+x2)/2-w);
118 nodesmap[node]->property_x2().set_value((x1+x2)/2+w);
119 nodesmap[node]->property_y1().set_value((y1+y2)/2-w);
120 nodesmap[node]->property_y2().set_value((y1+y2)/2+w);
126 int GraphDisplayerCanvas::changeNodeColor (std::string mapname, Node node)
129 //function maps the range of the maximum and
130 //the minimum of the nodemap to the range of
133 Graph::NodeMap<double> * actual_map;
134 actual_map=((mytab.mapstorage).nodemap_storage)[mapname];
138 max=(mytab.mapstorage).maxOfNodeMap(mapname);
139 min=(mytab.mapstorage).minOfNodeMap(mapname);
144 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
148 double w=(*actual_map)[i];
152 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
156 color.set_rgb_p (0, 0, 100);
159 nodesmap[i]->property_fill_color_gdk().set_value(color);
166 double w=(*actual_map)[node];
170 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
174 color.set_rgb_p (0, 0, 100);
177 nodesmap[node]->property_fill_color_gdk().set_value(color);
182 int GraphDisplayerCanvas::resetNodeColor (Node node)
185 //function maps the range of the maximum and
186 //the minimum of the nodemap to the range of
189 Graph::NodeMap<double> actual_map((mytab.mapstorage).graph,node_property_defaults[N_COLOR]);
193 max=node_property_defaults[N_COLOR];
194 min=node_property_defaults[N_COLOR];
199 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
203 double w=actual_map[i];
207 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
211 color.set_rgb_p (0, 0, 100);
214 nodesmap[i]->property_fill_color_gdk().set_value(color);
221 double w=actual_map[node];
225 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
229 color.set_rgb_p (0, 0, 100);
232 nodesmap[node]->property_fill_color_gdk().set_value(color);
237 int GraphDisplayerCanvas::changeNodeText (std::string mapname, Node node)
240 //the number in the map will be written on the node
241 //EXCEPT when the name of the map is Text, because
242 //in that case empty string will be written, because
243 //that is the deleter map
245 Graph::NodeMap<double> * actual_map=NULL;
246 actual_map=((mytab.mapstorage).nodemap_storage)[mapname];
250 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
252 nodemap_to_edit=mapname;
253 double number=(*actual_map)[i];
255 std::ostringstream ostr;
258 nodetextmap[i]->property_text().set_value(ostr.str());
263 double number=(*actual_map)[node];
265 std::ostringstream ostr;
268 nodetextmap[node]->property_text().set_value(ostr.str());
273 int GraphDisplayerCanvas::resetNodeText (Node node)
276 //the number in the map will be written on the node
277 //EXCEPT when the name of the map is Text, because
278 //in that case empty string will be written, because
279 //that is the deleter map
283 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
286 nodetextmap[i]->property_text().set_value("");
291 nodetextmap[node]->property_text().set_value("");