Set arrow coordinates when creating a new edge.
1 #include "graph_displayer_canvas.h"
5 int GraphDisplayerCanvas::resetEdgeWidth (Edge edge)
9 min=edge_property_defaults[E_WIDTH];
10 max=edge_property_defaults[E_WIDTH];
11 Graph::EdgeMap<double> actual_map((mytab.mapstorage).graph,edge_property_defaults[E_WIDTH]);
15 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
17 double v=fabs(actual_map[i]);
21 w=(int)(edge_property_defaults[E_WIDTH]);
25 w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH));
27 edgesmap[i]->property_width_units().set_value(w);
32 int w=(int)actual_map[edge];
35 edgesmap[edge]->property_width_units().set_value(w);
42 int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Edge edge)
44 Graph::EdgeMap<double> * actual_map;
47 min=(mytab.mapstorage).minOfEdgeMap(mapname);
48 max=(mytab.mapstorage).maxOfEdgeMap(mapname);
49 actual_map=((mytab.mapstorage).edgemap_storage)[mapname];
53 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
55 double v=fabs((*actual_map)[i]);
59 w=(int)(edge_property_defaults[E_WIDTH]);
63 w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH));
65 edgesmap[i]->property_width_units().set_value(w);
70 int w=(int)(*actual_map)[edge];
73 edgesmap[edge]->property_width_units().set_value(w);
79 int GraphDisplayerCanvas::changeEdgeColor (std::string mapname, Edge edge)
82 //function maps the range of the maximum and
83 //the minimum of the nodemap to the range of
85 Graph::EdgeMap<double> * actual_map;
86 actual_map=((mytab.mapstorage).edgemap_storage)[mapname];
90 max=(mytab.mapstorage).maxOfEdgeMap(mapname);
91 min=(mytab.mapstorage).minOfEdgeMap(mapname);
95 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
97 double w=(*actual_map)[i];
102 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
106 color.set_rgb_p (0, 100, 0);
108 edgesmap[i]->property_fill_color_gdk().set_value(color);
115 double w=(*actual_map)[edge];
119 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
123 color.set_rgb_p (0, 100, 0);
126 edgesmap[edge]->property_fill_color_gdk().set_value(color);
131 int GraphDisplayerCanvas::resetEdgeColor (Edge edge)
134 //function maps the range of the maximum and
135 //the minimum of the nodemap to the range of
137 Graph::EdgeMap<double> actual_map((mytab.mapstorage).graph,edge_property_defaults[E_COLOR]);
141 max=edge_property_defaults[E_COLOR];
142 min=edge_property_defaults[E_COLOR];
146 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
148 double w=actual_map[i];
153 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
157 color.set_rgb_p (0, 100, 0);
159 edgesmap[i]->property_fill_color_gdk().set_value(color);
166 double w=actual_map[edge];
170 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
174 color.set_rgb_p (0, 100, 0);
177 edgesmap[edge]->property_fill_color_gdk().set_value(color);
182 int GraphDisplayerCanvas::changeEdgeText (std::string mapname, Edge edge)
184 //the number in the map will be written on the edge
185 //EXCEPT when the name of the map is Default, because
186 //in that case empty string will be written, because
187 //that is the deleter map
191 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
193 edgemap_to_edit=mapname;
194 double number=(*((mytab.mapstorage).edgemap_storage)[mapname])[i];
196 std::ostringstream ostr;
199 edgetextmap[i]->property_text().set_value(ostr.str());
205 double number=(*((mytab.mapstorage).edgemap_storage)[mapname])[edge];
207 std::ostringstream ostr;
210 edgetextmap[edge]->property_text().set_value(ostr.str());
217 int GraphDisplayerCanvas::resetEdgeText (Edge edge)
219 //the number in the map will be written on the edge
220 //EXCEPT when the name of the map is Default, because
221 //in that case empty string will be written, because
222 //that is the deleter map
226 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
229 edgetextmap[i]->property_text().set_value("");
235 edgetextmap[edge]->property_text().set_value("");