1 #include <graph_displayer_canvas.h>
2 #include <broken_edge.h>
6 int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Graph::Edge edge)
8 Graph::EdgeMap<double> * actual_map;
11 actual_map=new Graph::EdgeMap<double>(g,edge_property_defaults[E_WIDTH]);
15 actual_map=(mapstorage.edgemap_storage)[mapname];
20 for (EdgeIt i(g); i!=INVALID; ++i)
22 int w=(int)(*actual_map)[i];
25 edgesmap[i]->property_width_pixels().set_value(w);
31 int w=(int)(*actual_map)[edge];
34 edgesmap[edge]->property_width_pixels().set_value(w);
40 int GraphDisplayerCanvas::changeEdgeColor (std::string mapname, Graph::Edge edge)
43 //function maps the range of the maximum and
44 //the minimum of the nodemap to the range of
46 Graph::EdgeMap<double> * actual_map;
47 if(mapname=="Default")
49 actual_map=new Graph::EdgeMap<double>(g,edge_property_defaults[E_COLOR]);
53 actual_map=(mapstorage.edgemap_storage)[mapname];
58 if(mapname!="Default")
60 max=mapstorage.maxOfEdgeMap(mapname);
61 min=mapstorage.minOfEdgeMap(mapname);
65 max=edge_property_defaults[E_COLOR];
66 min=edge_property_defaults[E_COLOR];
71 for (EdgeIt i(g); i!=INVALID; ++i)
73 double w=(*actual_map)[i];
78 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
82 color.set_rgb_p (0, 100, 0);
84 edgesmap[i]->property_fill_color_gdk().set_value(color);
91 double w=(*actual_map)[edge];
95 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
99 color.set_rgb_p (0, 100, 0);
102 edgesmap[edge]->property_fill_color_gdk().set_value(color);
107 int GraphDisplayerCanvas::changeEdgeText (std::string mapname, Graph::Edge edge)
109 //the number in the map will be written on the edge
110 //EXCEPT when the name of the map is Default, because
111 //in that case empty string will be written, because
112 //that is the deleter map
116 for (EdgeIt i(g); i!=INVALID; ++i)
118 if(mapname!="Default")
120 edgemap_to_edit=mapname;
121 double number=(*(mapstorage.edgemap_storage)[mapname])[i];
123 //if number is smaller than one, length would be negative, or invalid
126 length=(int)(floor(log(number)/log(10)))+1;
128 int maxpos=(int)(pow(10,length-1));
129 int strl=length+1+RANGE;
130 char * str=new char[strl];
134 for(int j=0;j<strl;j++)
138 if((number-(int)number)>ALMOST_ONE)
140 number=round(number);
142 int digit=(int)(number/maxpos);
144 number-=digit*maxpos;
149 edgetextmap[i]->property_text().set_value(str);
154 edgetextmap[i]->property_text().set_value("");
161 if(mapname!="Default")
163 double number=(*(mapstorage.edgemap_storage)[mapname])[edge];
165 //if number is smaller than one, length would be negative, or invalid
168 length=(int)(floor(log(number)/log(10)))+1;
170 int maxpos=(int)(pow(10,length-1));
171 int strl=length+1+RANGE;
172 char * str=new char[strl];
176 for(int j=0;j<strl;j++)
180 if((number-(int)number)>ALMOST_ONE)
182 number=round(number);
184 int digit=(int)(number/maxpos);
186 number-=digit*maxpos;
191 edgetextmap[edge]->property_text().set_value(str);
195 edgetextmap[edge]->property_text().set_value("");