#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 Default, 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]; std::ostringstream ostr; ostr << number; edgetextmap[i]->property_text().set_value(ostr.str()); } else { edgemap_to_edit=""; edgetextmap[i]->property_text().set_value(""); } } } else { if(mapname!="Default") { double number=(*(mapstorage.edgemap_storage)[mapname])[edge]; std::ostringstream ostr; ostr << number; edgetextmap[edge]->property_text().set_value(ostr.str()); } else { edgetextmap[edge]->property_text().set_value(""); } } return 0; };