#include #include #include int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Graph::Edge edge) { Graph::EdgeMap * actual_map; if(mapname=="Default") { actual_map=new Graph::EdgeMap(g,edge_property_defaults[E_WIDTH]); } else { actual_map=(mapstorage.edgemap_storage)[mapname]; } if(edge==INVALID) { for (EdgeIt i(g); i!=INVALID; ++i) { int w=(int)(*actual_map)[i]; if(w>=0) { edgesmap[i]->property_width_pixels().set_value(w); } } } else { int w=(int)(*actual_map)[edge]; if(w>=0) { edgesmap[edge]->property_width_pixels().set_value(w); } } return 0; }; int GraphDisplayerCanvas::changeEdgeColor (std::string mapname, Graph::Edge edge) { //function maps the range of the maximum and //the minimum of the nodemap to the range of //green in RGB Graph::EdgeMap * actual_map; if(mapname=="Default") { actual_map=new Graph::EdgeMap(g,edge_property_defaults[E_COLOR]); } else { actual_map=(mapstorage.edgemap_storage)[mapname]; } double max, min; if(mapname!="Default") { max=mapstorage.maxOfEdgeMap(mapname); min=mapstorage.minOfEdgeMap(mapname); } else { max=edge_property_defaults[E_COLOR]; min=edge_property_defaults[E_COLOR]; } if(edge==INVALID) { for (EdgeIt i(g); i!=INVALID; ++i) { double w=(*actual_map)[i]; Gdk::Color color; if(max!=min) { color.set_rgb_p (0, 100*(w-min)/(max-min), 0); } else { color.set_rgb_p (0, 100, 0); } edgesmap[i]->property_fill_color_gdk().set_value(color); } } else { Gdk::Color color; double w=(*actual_map)[edge]; if(max!=min) { color.set_rgb_p (0, 100*(w-min)/(max-min), 0); } else { color.set_rgb_p (0, 100, 0); } edgesmap[edge]->property_fill_color_gdk().set_value(color); } return 0; }; int GraphDisplayerCanvas::changeEdgeText (std::string mapname, Graph::Edge edge) { //the number in the map will be written on the edge //EXCEPT when the name of the map is Text, because //in that case empty string will be written, because //that is the deleter map if(edge==INVALID) { for (EdgeIt i(g); i!=INVALID; ++i) { if(mapname!="Default") { edgemap_to_edit=mapname; double number=(*(mapstorage.edgemap_storage)[mapname])[i]; int length=1; //if number is smaller than one, length would be negative, or invalid if(number>=1) { length=(int)(floor(log(number)/log(10)))+1; } int maxpos=(int)(pow(10,length-1)); int strl=length+1+RANGE; char * str=new char[strl]; str[length]='.'; str[strl]='\0'; for(int j=0;jALMOST_ONE) { number=round(number); } int digit=(int)(number/maxpos); str[j]=(digit+'0'); number-=digit*maxpos; number*=10; } } edgetextmap[i]->property_text().set_value(str); } else { edgemap_to_edit=""; edgetextmap[i]->property_text().set_value(""); } } } else { if(mapname!="Default") { double number=(*(mapstorage.edgemap_storage)[mapname])[edge]; int length=1; //if number is smaller than one, length would be negative, or invalid if(number>=1) { length=(int)(floor(log(number)/log(10)))+1; } int maxpos=(int)(pow(10,length-1)); int strl=length+1+RANGE; char * str=new char[strl]; str[length]='.'; str[strl]='\0'; for(int j=0;jALMOST_ONE) { number=round(number); } int digit=(int)(number/maxpos); str[j]=(digit+'0'); number-=digit*maxpos; number*=10; } } edgetextmap[edge]->property_text().set_value(str); } else { edgetextmap[edge]->property_text().set_value(""); } } return 0; };