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 edgemap_to_edit=mapname;
122 double number=(*(mapstorage.edgemap_storage)[mapname])[i];
124 //if number is smaller than one, length would be negative, or invalid
127 length=(int)(floor(log(number)/log(10)))+1;
129 int maxpos=(int)(pow(10,length-1));
130 int strl=length+1+RANGE;
131 char * str=new char[strl];
135 for(int j=0;j<strl;j++)
139 if((number-(int)number)>ALMOST_ONE)
141 number=round(number);
143 int digit=(int)(number/maxpos);
145 number-=digit*maxpos;
150 edgetextmap[i]->property_text().set_value(str);
155 edgetextmap[i]->property_text().set_value("");
162 if(mapname!="Default")
164 double number=(*(mapstorage.edgemap_storage)[mapname])[edge];
166 //if number is smaller than one, length would be negative, or invalid
169 length=(int)(floor(log(number)/log(10)))+1;
171 int maxpos=(int)(pow(10,length-1));
172 int strl=length+1+RANGE;
173 char * str=new char[strl];
177 for(int j=0;j<strl;j++)
181 if((number-(int)number)>ALMOST_ONE)
183 number=round(number);
185 int digit=(int)(number/maxpos);
187 number-=digit*maxpos;
192 edgetextmap[edge]->property_text().set_value(str);
196 edgetextmap[edge]->property_text().set_value("");