#include "graph_displayer_canvas.h" #include int GraphDisplayerCanvas::resetEdgeWidth (Edge edge) { double min, max; min=edge_property_defaults[E_WIDTH]; max=edge_property_defaults[E_WIDTH]; Graph::EdgeMap actual_map(mapstorage.graph,edge_property_defaults[E_WIDTH]); if(edge==INVALID) { for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i) { double v=fabs(actual_map[i]); int w; if(min==max) { w=(int)(edge_property_defaults[E_WIDTH]); } else { w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH)); } edgesmap[i]->property_width_units().set_value(w); } } else { int w=(int)actual_map[edge]; if(w>=0) { edgesmap[edge]->property_width_units().set_value(w); } } return 0; } int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Edge edge) { Graph::EdgeMap * actual_map; double min, max; min=mapstorage.minOfEdgeMap(mapname); max=mapstorage.maxOfEdgeMap(mapname); actual_map=(mapstorage.edgemap_storage)[mapname]; if(edge==INVALID) { for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i) { double v=fabs((*actual_map)[i]); int w; if(min==max) { w=(int)(edge_property_defaults[E_WIDTH]); } else { w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH)); } edgesmap[i]->property_width_units().set_value(w); } } else { int w=(int)(*actual_map)[edge]; if(w>=0) { edgesmap[edge]->property_width_units().set_value(w); } } return 0; }; int GraphDisplayerCanvas::changeEdgeColor (std::string mapname, 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; actual_map=(mapstorage.edgemap_storage)[mapname]; double max, min; max=mapstorage.maxOfEdgeMap(mapname); min=mapstorage.minOfEdgeMap(mapname); if(edge==INVALID) { for (EdgeIt i(mapstorage.graph); 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::resetEdgeColor (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(mapstorage.graph,edge_property_defaults[E_COLOR]); double max, min; max=edge_property_defaults[E_COLOR]; min=edge_property_defaults[E_COLOR]; if(edge==INVALID) { for (EdgeIt i(mapstorage.graph); 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, 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(mapstorage.graph); i!=INVALID; ++i) { 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 { double number=(*(mapstorage.edgemap_storage)[mapname])[edge]; std::ostringstream ostr; ostr << number; edgetextmap[edge]->property_text().set_value(ostr.str()); } return 0; }; int GraphDisplayerCanvas::resetEdgeText (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(mapstorage.graph); i!=INVALID; ++i) { edgemap_to_edit=""; edgetextmap[i]->property_text().set_value(""); } } else { edgetextmap[edge]->property_text().set_value(""); } return 0; };