1 #include "graph_displayer_canvas.h"
5 int GraphDisplayerCanvas::resetEdgeWidth (Edge edge)
7 Graph::EdgeMap<double> * actual_map;
10 min=edge_property_defaults[E_WIDTH];
11 max=edge_property_defaults[E_WIDTH];
12 actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_WIDTH]);
16 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
18 double v=fabs((*actual_map)[i]);
22 w=(int)(edge_property_defaults[E_WIDTH]);
26 w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH));
28 edgesmap[i]->property_width_units().set_value(w);
33 int w=(int)(*actual_map)[edge];
36 edgesmap[edge]->property_width_units().set_value(w);
43 int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Edge edge)
45 Graph::EdgeMap<double> * actual_map;
48 min=mapstorage.minOfEdgeMap(mapname);
49 max=mapstorage.maxOfEdgeMap(mapname);
50 actual_map=(mapstorage.edgemap_storage)[mapname];
54 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
56 double v=fabs((*actual_map)[i]);
60 w=(int)(edge_property_defaults[E_WIDTH]);
64 w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH));
66 edgesmap[i]->property_width_units().set_value(w);
71 int w=(int)(*actual_map)[edge];
74 edgesmap[edge]->property_width_units().set_value(w);
80 int GraphDisplayerCanvas::changeEdgeColor (std::string mapname, Edge edge)
83 //function maps the range of the maximum and
84 //the minimum of the nodemap to the range of
86 Graph::EdgeMap<double> * actual_map;
87 actual_map=(mapstorage.edgemap_storage)[mapname];
91 max=mapstorage.maxOfEdgeMap(mapname);
92 min=mapstorage.minOfEdgeMap(mapname);
96 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
98 double w=(*actual_map)[i];
103 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
107 color.set_rgb_p (0, 100, 0);
109 edgesmap[i]->property_fill_color_gdk().set_value(color);
116 double w=(*actual_map)[edge];
120 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
124 color.set_rgb_p (0, 100, 0);
127 edgesmap[edge]->property_fill_color_gdk().set_value(color);
132 int GraphDisplayerCanvas::resetEdgeColor (Edge edge)
135 //function maps the range of the maximum and
136 //the minimum of the nodemap to the range of
138 Graph::EdgeMap<double> * actual_map;
139 actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_COLOR]);
143 max=edge_property_defaults[E_COLOR];
144 min=edge_property_defaults[E_COLOR];
148 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
150 double w=(*actual_map)[i];
155 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
159 color.set_rgb_p (0, 100, 0);
161 edgesmap[i]->property_fill_color_gdk().set_value(color);
168 double w=(*actual_map)[edge];
172 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
176 color.set_rgb_p (0, 100, 0);
179 edgesmap[edge]->property_fill_color_gdk().set_value(color);
184 int GraphDisplayerCanvas::changeEdgeText (std::string mapname, Edge edge)
186 //the number in the map will be written on the edge
187 //EXCEPT when the name of the map is Default, because
188 //in that case empty string will be written, because
189 //that is the deleter map
193 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
195 edgemap_to_edit=mapname;
196 double number=(*(mapstorage.edgemap_storage)[mapname])[i];
198 std::ostringstream ostr;
201 edgetextmap[i]->property_text().set_value(ostr.str());
207 double number=(*(mapstorage.edgemap_storage)[mapname])[edge];
209 std::ostringstream ostr;
212 edgetextmap[edge]->property_text().set_value(ostr.str());
219 int GraphDisplayerCanvas::resetEdgeText (Edge edge)
221 //the number in the map will be written on the edge
222 //EXCEPT when the name of the map is Default, because
223 //in that case empty string will be written, because
224 //that is the deleter map
228 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
231 edgetextmap[i]->property_text().set_value("");
237 edgetextmap[edge]->property_text().set_value("");