1 #include "graph_displayer_canvas.h"
4 const int minimum_edge_width=0;
6 int GraphDisplayerCanvas::resetEdgeWidth (Edge edge)
10 min=edge_property_defaults[E_WIDTH];
11 max=edge_property_defaults[E_WIDTH];
12 Graph::EdgeMap<double> actual_map((mytab.mapstorage).graph,edge_property_defaults[E_WIDTH]);
16 for (EdgeIt i((mytab.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));
30 double actual_ppu=get_pixels_per_unit();
31 w=(int)(w/actual_ppu*fixed_zoom_factor);
33 edgesmap[i]->setLineWidth(w);
38 int w=(int)actual_map[edge];
41 edgesmap[edge]->setLineWidth(w);
48 int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Edge edge)
50 Graph::EdgeMap<double> * actual_map;
53 min=(mytab.mapstorage).minOfEdgeMap(mapname);
54 max=(mytab.mapstorage).maxOfEdgeMap(mapname);
55 actual_map=((mytab.mapstorage).edgemap_storage)[mapname];
59 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
61 double v=fabs((*actual_map)[i]);
67 w=(int)(edge_property_defaults[E_WIDTH]);
71 w=(int)(minimum_edge_width+(v-min)/(max-min)*(edge_width-minimum_edge_width));
76 w=(int)(v*edge_width);
78 if(w<minimum_edge_width)
84 double actual_ppu=get_pixels_per_unit();
85 w=(int)(w/actual_ppu*fixed_zoom_factor);
87 edgesmap[i]->setLineWidth(w);
92 int w=(int)(*actual_map)[edge];
95 edgesmap[edge]->setLineWidth(w);
101 int GraphDisplayerCanvas::changeEdgeColor (std::string mapname, Edge edge)
104 //function maps the range of the maximum and
105 //the minimum of the nodemap to the range of
107 Graph::EdgeMap<double> * actual_map;
108 actual_map=((mytab.mapstorage).edgemap_storage)[mapname];
112 max=(mytab.mapstorage).maxOfEdgeMap(mapname);
113 min=(mytab.mapstorage).minOfEdgeMap(mapname);
117 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
119 double w=(*actual_map)[i];
124 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
128 color.set_rgb_p (0, 100, 0);
130 edgesmap[i]->setFillColor(color);
137 double w=(*actual_map)[edge];
141 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
145 color.set_rgb_p (0, 100, 0);
148 edgesmap[edge]->setFillColor(color);
153 int GraphDisplayerCanvas::resetEdgeColor (Edge edge)
156 //function maps the range of the maximum and
157 //the minimum of the nodemap to the range of
159 Graph::EdgeMap<double> actual_map((mytab.mapstorage).graph,edge_property_defaults[E_COLOR]);
163 max=edge_property_defaults[E_COLOR];
164 min=edge_property_defaults[E_COLOR];
168 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
170 double w=actual_map[i];
175 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
179 color.set_rgb_p (0, 100, 0);
181 edgesmap[i]->setFillColor(color);
188 double w=actual_map[edge];
192 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
196 color.set_rgb_p (0, 100, 0);
199 edgesmap[edge]->setFillColor(color);
204 int GraphDisplayerCanvas::changeEdgeText (std::string mapname, Edge edge)
206 //the number in the map will be written on the edge
207 //EXCEPT when the name of the map is Default, because
208 //in that case empty string will be written, because
209 //that is the deleter map
213 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
215 edgemap_to_edit=mapname;
216 double number=(*((mytab.mapstorage).edgemap_storage)[mapname])[i];
218 std::ostringstream ostr;
221 edgetextmap[i]->property_text().set_value(ostr.str());
227 double number=(*((mytab.mapstorage).edgemap_storage)[mapname])[edge];
229 std::ostringstream ostr;
232 edgetextmap[edge]->property_text().set_value(ostr.str());
239 int GraphDisplayerCanvas::resetEdgeText (Edge edge)
241 //the number in the map will be written on the edge
242 //EXCEPT when the name of the map is Default, because
243 //in that case empty string will be written, because
244 //that is the deleter map
248 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
251 edgetextmap[i]->property_text().set_value("");
257 edgetextmap[edge]->property_text().set_value("");