1 #include "graph_displayer_canvas.h"
2 #include "broken_edge.h"
6 int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Node node)
8 Graph::NodeMap<double> * actual_map;
10 min=mapstorage.minOfNodeMap(mapname);
11 max=mapstorage.maxOfNodeMap(mapname);
12 actual_map=(mapstorage.nodemap_storage)[mapname];
16 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
18 double v=fabs((*actual_map)[i]);
22 w=(int)(node_property_defaults[N_RADIUS]);
26 w=(int)(MIN_NODE_RADIUS+(v-min)/(max-min)*(MAX_NODE_RADIUS-MIN_NODE_RADIUS));
30 double x1, y1, x2, y2;
31 x1=nodesmap[i]->property_x1().get_value();
32 x2=nodesmap[i]->property_x2().get_value();
33 y1=nodesmap[i]->property_y1().get_value();
34 y2=nodesmap[i]->property_y2().get_value();
35 nodesmap[i]->property_x1().set_value((x1+x2)/2-w);
36 nodesmap[i]->property_x2().set_value((x1+x2)/2+w);
37 nodesmap[i]->property_y1().set_value((y1+y2)/2-w);
38 nodesmap[i]->property_y2().set_value((y1+y2)/2+w);
44 //I think only new nodes use this case
45 // int w=(int)(*actual_map)[node];
46 int w=(int)(node_property_defaults[N_RADIUS]);
49 double x1, y1, x2, y2;
50 x1=nodesmap[node]->property_x1().get_value();
51 x2=nodesmap[node]->property_x2().get_value();
52 y1=nodesmap[node]->property_y1().get_value();
53 y2=nodesmap[node]->property_y2().get_value();
54 nodesmap[node]->property_x1().set_value((x1+x2)/2-w);
55 nodesmap[node]->property_x2().set_value((x1+x2)/2+w);
56 nodesmap[node]->property_y1().set_value((y1+y2)/2-w);
57 nodesmap[node]->property_y2().set_value((y1+y2)/2+w);
63 int GraphDisplayerCanvas::resetNodeRadius (Node node)
65 Graph::NodeMap<double> * actual_map;
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]);
73 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
75 double v=fabs((*actual_map)[i]);
79 w=(int)(node_property_defaults[N_RADIUS]);
83 w=(int)(MIN_NODE_RADIUS+(v-min)/(max-min)*(MAX_NODE_RADIUS-MIN_NODE_RADIUS));
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);
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]);
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);
120 int GraphDisplayerCanvas::changeNodeColor (std::string mapname, Node node)
123 //function maps the range of the maximum and
124 //the minimum of the nodemap to the range of
127 Graph::NodeMap<double> * actual_map;
128 actual_map=(mapstorage.nodemap_storage)[mapname];
132 max=mapstorage.maxOfNodeMap(mapname);
133 min=mapstorage.minOfNodeMap(mapname);
138 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
142 double w=(*actual_map)[i];
146 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
150 color.set_rgb_p (0, 0, 100);
153 nodesmap[i]->property_fill_color_gdk().set_value(color);
160 double w=(*actual_map)[node];
164 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
168 color.set_rgb_p (0, 0, 100);
171 nodesmap[node]->property_fill_color_gdk().set_value(color);
176 int GraphDisplayerCanvas::resetNodeColor (Node node)
179 //function maps the range of the maximum and
180 //the minimum of the nodemap to the range of
183 Graph::NodeMap<double> * actual_map;
184 actual_map=new Graph::NodeMap<double>(mapstorage.graph,node_property_defaults[N_COLOR]);
188 max=node_property_defaults[N_COLOR];
189 min=node_property_defaults[N_COLOR];
194 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
198 double w=(*actual_map)[i];
202 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
206 color.set_rgb_p (0, 0, 100);
209 nodesmap[i]->property_fill_color_gdk().set_value(color);
216 double w=(*actual_map)[node];
220 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
224 color.set_rgb_p (0, 0, 100);
227 nodesmap[node]->property_fill_color_gdk().set_value(color);
232 int GraphDisplayerCanvas::changeNodeText (std::string mapname, Node node)
235 //the number in the map will be written on the node
236 //EXCEPT when the name of the map is Text, because
237 //in that case empty string will be written, because
238 //that is the deleter map
240 Graph::NodeMap<double> * actual_map=NULL;
241 actual_map=(mapstorage.nodemap_storage)[mapname];
245 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
247 nodemap_to_edit=mapname;
248 double number=(*actual_map)[i];
250 std::ostringstream ostr;
253 nodetextmap[i]->property_text().set_value(ostr.str());
258 double number=(*actual_map)[node];
260 std::ostringstream ostr;
263 nodetextmap[node]->property_text().set_value(ostr.str());
268 int GraphDisplayerCanvas::resetNodeText (Node node)
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
278 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
281 nodetextmap[i]->property_text().set_value("");
286 nodetextmap[node]->property_text().set_value("");