1 #include "graph_displayer_canvas.h"
2 #include "broken_edge.h"
6 int GraphDisplayerCanvas::resetEdgeWidth (Edge edge)
8 Graph::EdgeMap<double> * actual_map;
11 min=edge_property_defaults[E_WIDTH];
12 max=edge_property_defaults[E_WIDTH];
13 actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_WIDTH]);
17 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
19 double v=fabs((*actual_map)[i]);
23 w=(int)(edge_property_defaults[E_WIDTH]);
27 w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH));
29 edgesmap[i]->property_width_units().set_value(w);
34 int w=(int)(*actual_map)[edge];
37 edgesmap[edge]->property_width_units().set_value(w);
44 int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Edge edge)
46 Graph::EdgeMap<double> * actual_map;
49 min=mapstorage.minOfEdgeMap(mapname);
50 max=mapstorage.maxOfEdgeMap(mapname);
51 actual_map=(mapstorage.edgemap_storage)[mapname];
55 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
57 double v=fabs((*actual_map)[i]);
61 w=(int)(edge_property_defaults[E_WIDTH]);
65 w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH));
67 edgesmap[i]->property_width_units().set_value(w);
72 int w=(int)(*actual_map)[edge];
75 edgesmap[edge]->property_width_units().set_value(w);
81 int GraphDisplayerCanvas::changeEdgeColor (std::string mapname, Edge edge)
84 //function maps the range of the maximum and
85 //the minimum of the nodemap to the range of
87 Graph::EdgeMap<double> * actual_map;
88 actual_map=(mapstorage.edgemap_storage)[mapname];
92 max=mapstorage.maxOfEdgeMap(mapname);
93 min=mapstorage.minOfEdgeMap(mapname);
97 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
99 double w=(*actual_map)[i];
104 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
108 color.set_rgb_p (0, 100, 0);
110 edgesmap[i]->property_fill_color_gdk().set_value(color);
117 double w=(*actual_map)[edge];
121 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
125 color.set_rgb_p (0, 100, 0);
128 edgesmap[edge]->property_fill_color_gdk().set_value(color);
133 int GraphDisplayerCanvas::resetEdgeColor (Edge edge)
136 //function maps the range of the maximum and
137 //the minimum of the nodemap to the range of
139 Graph::EdgeMap<double> * actual_map;
140 actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_COLOR]);
144 max=edge_property_defaults[E_COLOR];
145 min=edge_property_defaults[E_COLOR];
149 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
151 double w=(*actual_map)[i];
156 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
160 color.set_rgb_p (0, 100, 0);
162 edgesmap[i]->property_fill_color_gdk().set_value(color);
169 double w=(*actual_map)[edge];
173 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
177 color.set_rgb_p (0, 100, 0);
180 edgesmap[edge]->property_fill_color_gdk().set_value(color);
185 int GraphDisplayerCanvas::changeEdgeText (std::string mapname, Edge edge)
187 //the number in the map will be written on the edge
188 //EXCEPT when the name of the map is Default, because
189 //in that case empty string will be written, because
190 //that is the deleter map
194 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
196 edgemap_to_edit=mapname;
197 double number=(*(mapstorage.edgemap_storage)[mapname])[i];
199 std::ostringstream ostr;
202 edgetextmap[i]->property_text().set_value(ostr.str());
208 double number=(*(mapstorage.edgemap_storage)[mapname])[edge];
210 std::ostringstream ostr;
213 edgetextmap[edge]->property_text().set_value(ostr.str());
220 int GraphDisplayerCanvas::resetEdgeText (Edge edge)
222 //the number in the map will be written on the edge
223 //EXCEPT when the name of the map is Default, because
224 //in that case empty string will be written, because
225 //that is the deleter map
229 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
232 edgetextmap[i]->property_text().set_value("");
238 edgetextmap[edge]->property_text().set_value("");