diff -r 231191361de5 -r 5ad61c33487c graph_displayer_canvas-edge.cc --- a/graph_displayer_canvas-edge.cc Thu Oct 06 12:32:06 2005 +0000 +++ b/graph_displayer_canvas-edge.cc Thu Oct 20 15:50:23 2005 +0000 @@ -3,23 +3,52 @@ #include +int GraphDisplayerCanvas::resetEdgeWidth (Edge edge) +{ + Graph::EdgeMap * actual_map; + double min, max; + + min=edge_property_defaults[E_WIDTH]; + max=edge_property_defaults[E_WIDTH]; + actual_map=new Graph::EdgeMap(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; - if(mapname=="Default") - { - min=edge_property_defaults[E_WIDTH]; - max=edge_property_defaults[E_WIDTH]; - actual_map=new Graph::EdgeMap(mapstorage.graph,edge_property_defaults[E_WIDTH]); - } - else - { - min=mapstorage.minOfEdgeMap(mapname); - max=mapstorage.maxOfEdgeMap(mapname); - actual_map=(mapstorage.edgemap_storage)[mapname]; - } + min=mapstorage.minOfEdgeMap(mapname); + max=mapstorage.maxOfEdgeMap(mapname); + actual_map=(mapstorage.edgemap_storage)[mapname]; if(edge==INVALID) { @@ -56,27 +85,64 @@ //the minimum of the nodemap to the range of //green in RGB Graph::EdgeMap * actual_map; - if(mapname=="Default") + actual_map=(mapstorage.edgemap_storage)[mapname]; + + double max, min; + + max=mapstorage.maxOfEdgeMap(mapname); + min=mapstorage.minOfEdgeMap(mapname); + + if(edge==INVALID) { - actual_map=new Graph::EdgeMap(mapstorage.graph,edge_property_defaults[E_COLOR]); + 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 { - actual_map=(mapstorage.edgemap_storage)[mapname]; + 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; + actual_map=new Graph::EdgeMap(mapstorage.graph,edge_property_defaults[E_COLOR]); 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]; - } + max=edge_property_defaults[E_COLOR]; + min=edge_property_defaults[E_COLOR]; if(edge==INVALID) { @@ -127,42 +193,51 @@ { for (EdgeIt i(mapstorage.graph); 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(""); - } + 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 { - 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; }; + +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; + +};