Reorganizing.
1 #include "graph_displayer_canvas.h"
5 int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Node node)
7 Graph::NodeMap<double> * actual_map;
9 min=mapstorage.minOfNodeMap(mapname);
10 max=mapstorage.maxOfNodeMap(mapname);
11 actual_map=(mapstorage.nodemap_storage)[mapname];
15 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
17 double v=fabs((*actual_map)[i]);
21 w=(int)(node_property_defaults[N_RADIUS]);
25 w=(int)(MIN_NODE_RADIUS+(v-min)/(max-min)*(MAX_NODE_RADIUS-MIN_NODE_RADIUS));
29 double x1, y1, x2, y2;
30 x1=nodesmap[i]->property_x1().get_value();
31 x2=nodesmap[i]->property_x2().get_value();
32 y1=nodesmap[i]->property_y1().get_value();
33 y2=nodesmap[i]->property_y2().get_value();
34 nodesmap[i]->property_x1().set_value((x1+x2)/2-w);
35 nodesmap[i]->property_x2().set_value((x1+x2)/2+w);
36 nodesmap[i]->property_y1().set_value((y1+y2)/2-w);
37 nodesmap[i]->property_y2().set_value((y1+y2)/2+w);
43 //I think only new nodes use this case
44 // int w=(int)(*actual_map)[node];
45 int w=(int)(node_property_defaults[N_RADIUS]);
48 double x1, y1, x2, y2;
49 x1=nodesmap[node]->property_x1().get_value();
50 x2=nodesmap[node]->property_x2().get_value();
51 y1=nodesmap[node]->property_y1().get_value();
52 y2=nodesmap[node]->property_y2().get_value();
53 nodesmap[node]->property_x1().set_value((x1+x2)/2-w);
54 nodesmap[node]->property_x2().set_value((x1+x2)/2+w);
55 nodesmap[node]->property_y1().set_value((y1+y2)/2-w);
56 nodesmap[node]->property_y2().set_value((y1+y2)/2+w);
62 int GraphDisplayerCanvas::resetNodeRadius (Node node)
64 Graph::NodeMap<double> * actual_map;
66 min=node_property_defaults[N_RADIUS];
67 max=node_property_defaults[N_RADIUS];
68 actual_map=new Graph::NodeMap<double>(mapstorage.graph,node_property_defaults[N_RADIUS]);
72 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
74 double v=fabs((*actual_map)[i]);
78 w=(int)(node_property_defaults[N_RADIUS]);
82 w=(int)(MIN_NODE_RADIUS+(v-min)/(max-min)*(MAX_NODE_RADIUS-MIN_NODE_RADIUS));
86 double x1, y1, x2, y2;
87 x1=nodesmap[i]->property_x1().get_value();
88 x2=nodesmap[i]->property_x2().get_value();
89 y1=nodesmap[i]->property_y1().get_value();
90 y2=nodesmap[i]->property_y2().get_value();
91 nodesmap[i]->property_x1().set_value((x1+x2)/2-w);
92 nodesmap[i]->property_x2().set_value((x1+x2)/2+w);
93 nodesmap[i]->property_y1().set_value((y1+y2)/2-w);
94 nodesmap[i]->property_y2().set_value((y1+y2)/2+w);
100 //I think only new nodes use this case
101 // int w=(int)(*actual_map)[node];
102 int w=(int)(node_property_defaults[N_RADIUS]);
105 double x1, y1, x2, y2;
106 x1=nodesmap[node]->property_x1().get_value();
107 x2=nodesmap[node]->property_x2().get_value();
108 y1=nodesmap[node]->property_y1().get_value();
109 y2=nodesmap[node]->property_y2().get_value();
110 nodesmap[node]->property_x1().set_value((x1+x2)/2-w);
111 nodesmap[node]->property_x2().set_value((x1+x2)/2+w);
112 nodesmap[node]->property_y1().set_value((y1+y2)/2-w);
113 nodesmap[node]->property_y2().set_value((y1+y2)/2+w);
119 int GraphDisplayerCanvas::changeNodeColor (std::string mapname, Node node)
122 //function maps the range of the maximum and
123 //the minimum of the nodemap to the range of
126 Graph::NodeMap<double> * actual_map;
127 actual_map=(mapstorage.nodemap_storage)[mapname];
131 max=mapstorage.maxOfNodeMap(mapname);
132 min=mapstorage.minOfNodeMap(mapname);
137 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
141 double w=(*actual_map)[i];
145 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
149 color.set_rgb_p (0, 0, 100);
152 nodesmap[i]->property_fill_color_gdk().set_value(color);
159 double w=(*actual_map)[node];
163 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
167 color.set_rgb_p (0, 0, 100);
170 nodesmap[node]->property_fill_color_gdk().set_value(color);
175 int GraphDisplayerCanvas::resetNodeColor (Node node)
178 //function maps the range of the maximum and
179 //the minimum of the nodemap to the range of
182 Graph::NodeMap<double> * actual_map;
183 actual_map=new Graph::NodeMap<double>(mapstorage.graph,node_property_defaults[N_COLOR]);
187 max=node_property_defaults[N_COLOR];
188 min=node_property_defaults[N_COLOR];
193 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
197 double w=(*actual_map)[i];
201 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
205 color.set_rgb_p (0, 0, 100);
208 nodesmap[i]->property_fill_color_gdk().set_value(color);
215 double w=(*actual_map)[node];
219 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
223 color.set_rgb_p (0, 0, 100);
226 nodesmap[node]->property_fill_color_gdk().set_value(color);
231 int GraphDisplayerCanvas::changeNodeText (std::string mapname, Node node)
234 //the number in the map will be written on the node
235 //EXCEPT when the name of the map is Text, because
236 //in that case empty string will be written, because
237 //that is the deleter map
239 Graph::NodeMap<double> * actual_map=NULL;
240 actual_map=(mapstorage.nodemap_storage)[mapname];
244 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
246 nodemap_to_edit=mapname;
247 double number=(*actual_map)[i];
249 std::ostringstream ostr;
252 nodetextmap[i]->property_text().set_value(ostr.str());
257 double number=(*actual_map)[node];
259 std::ostringstream ostr;
262 nodetextmap[node]->property_text().set_value(ostr.str());
267 int GraphDisplayerCanvas::resetNodeText (Node node)
270 //the number in the map will be written on the node
271 //EXCEPT when the name of the map is Text, because
272 //in that case empty string will be written, because
273 //that is the deleter map
277 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
280 nodetextmap[i]->property_text().set_value("");
285 nodetextmap[node]->property_text().set_value("");