Mainly doc review.
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)
110 //the number in the map will be written on the edge
111 //EXCEPT when the name of the map is Text, because
112 //in that case empty string will be written, because
113 //that is the deleter map
117 for (EdgeIt i(g); i!=INVALID; ++i)
119 if(mapname!="Default")
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 int digit=(int)(number/maxpos);
140 number-=digit*maxpos;
145 edgetextmap[i]->property_text().set_value(str);
149 edgetextmap[i]->property_text().set_value("");
156 if(mapname!="Default")
158 double number=(*(mapstorage.edgemap_storage)[mapname])[edge];
160 //if number is smaller than one, length would be negative, or invalid
163 length=(int)(floor(log(number)/log(10)))+1;
165 int maxpos=(int)(pow(10,length-1));
166 int strl=length+1+RANGE;
167 char * str=new char[strl];
171 for(int j=0;j<strl;j++)
175 int digit=(int)(number/maxpos);
177 number-=digit*maxpos;
182 edgetextmap[edge]->property_text().set_value(str);
186 edgetextmap[edge]->property_text().set_value("");