Small modification in node view settings.
1 #include "graph_displayer_canvas.h"
4 const int minimum_node_radius=0;
6 int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Node node)
8 Graph::NodeMap<double> * actual_map;
10 min=(mytab.mapstorage).minOfNodeMap(mapname);
11 max=(mytab.mapstorage).maxOfNodeMap(mapname);
12 actual_map=((mytab.mapstorage).nodemap_storage)[mapname];
16 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
18 double v=fabs((*actual_map)[i]);
24 w=(int)(node_property_defaults[N_RADIUS]);
28 w=(int)(minimum_node_radius+(v-min)/(max-min)*(radius_max-minimum_node_radius));
33 w=(int)(v*radius_max);
43 double x1, y1, x2, y2;
44 x1=nodesmap[i]->property_x1().get_value();
45 x2=nodesmap[i]->property_x2().get_value();
46 y1=nodesmap[i]->property_y1().get_value();
47 y2=nodesmap[i]->property_y2().get_value();
48 nodesmap[i]->property_x1().set_value((x1+x2)/2-w);
49 nodesmap[i]->property_x2().set_value((x1+x2)/2+w);
50 nodesmap[i]->property_y1().set_value((y1+y2)/2-w);
51 nodesmap[i]->property_y2().set_value((y1+y2)/2+w);
57 //I think only new nodes use this case
58 //that has no own value, only the default one
59 //int w=(int)(*actual_map)[node];
60 int w=(int)(node_property_defaults[N_RADIUS]);
63 double x1, y1, x2, y2;
64 x1=nodesmap[node]->property_x1().get_value();
65 x2=nodesmap[node]->property_x2().get_value();
66 y1=nodesmap[node]->property_y1().get_value();
67 y2=nodesmap[node]->property_y2().get_value();
68 nodesmap[node]->property_x1().set_value((x1+x2)/2-w);
69 nodesmap[node]->property_x2().set_value((x1+x2)/2+w);
70 nodesmap[node]->property_y1().set_value((y1+y2)/2-w);
71 nodesmap[node]->property_y2().set_value((y1+y2)/2+w);
77 int GraphDisplayerCanvas::resetNodeRadius (Node node)
80 min=node_property_defaults[N_RADIUS];
81 max=node_property_defaults[N_RADIUS];
82 Graph::NodeMap<double> actual_map((mytab.mapstorage).graph,node_property_defaults[N_RADIUS]);
86 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
88 double v=fabs(actual_map[i]);
92 w=(int)(node_property_defaults[N_RADIUS]);
96 w=(int)(MIN_NODE_RADIUS+(v-min)/(max-min)*(MAX_NODE_RADIUS-MIN_NODE_RADIUS));
100 double x1, y1, x2, y2;
101 x1=nodesmap[i]->property_x1().get_value();
102 x2=nodesmap[i]->property_x2().get_value();
103 y1=nodesmap[i]->property_y1().get_value();
104 y2=nodesmap[i]->property_y2().get_value();
105 nodesmap[i]->property_x1().set_value((x1+x2)/2-w);
106 nodesmap[i]->property_x2().set_value((x1+x2)/2+w);
107 nodesmap[i]->property_y1().set_value((y1+y2)/2-w);
108 nodesmap[i]->property_y2().set_value((y1+y2)/2+w);
114 //I think only new nodes use this case
115 // int w=(int)actual_map[node];
116 int w=(int)(node_property_defaults[N_RADIUS]);
119 double x1, y1, x2, y2;
120 x1=nodesmap[node]->property_x1().get_value();
121 x2=nodesmap[node]->property_x2().get_value();
122 y1=nodesmap[node]->property_y1().get_value();
123 y2=nodesmap[node]->property_y2().get_value();
124 nodesmap[node]->property_x1().set_value((x1+x2)/2-w);
125 nodesmap[node]->property_x2().set_value((x1+x2)/2+w);
126 nodesmap[node]->property_y1().set_value((y1+y2)/2-w);
127 nodesmap[node]->property_y2().set_value((y1+y2)/2+w);
133 int GraphDisplayerCanvas::changeNodeColor (std::string mapname, Node node)
136 //function maps the range of the maximum and
137 //the minimum of the nodemap to the range of
140 Graph::NodeMap<double> * actual_map;
141 actual_map=((mytab.mapstorage).nodemap_storage)[mapname];
145 max=(mytab.mapstorage).maxOfNodeMap(mapname);
146 min=(mytab.mapstorage).minOfNodeMap(mapname);
151 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
155 double w=(*actual_map)[i];
159 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
163 color.set_rgb_p (0, 0, 100);
166 nodesmap[i]->property_fill_color_gdk().set_value(color);
173 double w=(*actual_map)[node];
177 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
181 color.set_rgb_p (0, 0, 100);
184 nodesmap[node]->property_fill_color_gdk().set_value(color);
189 int GraphDisplayerCanvas::resetNodeColor (Node node)
192 //function maps the range of the maximum and
193 //the minimum of the nodemap to the range of
196 Graph::NodeMap<double> actual_map((mytab.mapstorage).graph,node_property_defaults[N_COLOR]);
200 max=node_property_defaults[N_COLOR];
201 min=node_property_defaults[N_COLOR];
206 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
210 double w=actual_map[i];
214 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
218 color.set_rgb_p (0, 0, 100);
221 nodesmap[i]->property_fill_color_gdk().set_value(color);
228 double w=actual_map[node];
232 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
236 color.set_rgb_p (0, 0, 100);
239 nodesmap[node]->property_fill_color_gdk().set_value(color);
244 int GraphDisplayerCanvas::changeNodeText (std::string mapname, Node node)
247 //the number in the map will be written on the node
248 //EXCEPT when the name of the map is Text, because
249 //in that case empty string will be written, because
250 //that is the deleter map
252 Graph::NodeMap<double> * actual_map=NULL;
253 actual_map=((mytab.mapstorage).nodemap_storage)[mapname];
257 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
259 nodemap_to_edit=mapname;
260 double number=(*actual_map)[i];
262 std::ostringstream ostr;
265 nodetextmap[i]->property_text().set_value(ostr.str());
270 double number=(*actual_map)[node];
272 std::ostringstream ostr;
275 nodetextmap[node]->property_text().set_value(ostr.str());
280 int GraphDisplayerCanvas::resetNodeText (Node node)
283 //the number in the map will be written on the node
284 //EXCEPT when the name of the map is Text, because
285 //in that case empty string will be written, because
286 //that is the deleter map
290 for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
293 nodetextmap[i]->property_text().set_value("");
298 nodetextmap[node]->property_text().set_value("");