diff -r e2c86ae158cf -r fa28f1071bd6 graph_displayer_canvas-edge.cc --- a/graph_displayer_canvas-edge.cc Fri Jun 24 07:58:18 2005 +0000 +++ b/graph_displayer_canvas-edge.cc Fri Jun 24 18:16:12 2005 +0000 @@ -3,49 +3,82 @@ #include -int GraphDisplayerCanvas::changeLineWidth (std::string mapname) +int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Graph::Edge edge) { - for (EdgeIt i(g); i!=INVALID; ++i) + if(edge==INVALID) { - int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i]; + for (EdgeIt i(g); i!=INVALID; ++i) + { + int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i]; + if(w>=0) + { + edgesmap[i]->property_width_pixels().set_value(w); + } + } + } + else + { + int w=(int)(*(mapstorage.edgemap_storage)[mapname])[edge]; if(w>=0) { - edgesmap[i]->property_width_pixels().set_value(w); + edgesmap[edge]->property_width_pixels().set_value(w); } } return 0; }; -int GraphDisplayerCanvas::changeColor (std::string mapname) +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 + if(edge==INVALID) + { - for (EdgeIt i(g); i!=INVALID; ++i) - { - double w=(*(mapstorage.edgemap_storage)[mapname])[i]; - double max=mapstorage.maxOfEdgeMap(mapname); - double min=mapstorage.minOfEdgeMap(mapname); + for (EdgeIt i(g); i!=INVALID; ++i) + { + double w=(*(mapstorage.edgemap_storage)[mapname])[i]; + double max=mapstorage.maxOfEdgeMap(mapname); + double min=mapstorage.minOfEdgeMap(mapname); - //std::cout<property_fill_color_gdk().set_value(color); + } + } + else { - color.set_rgb_p (0, 100*(w-min)/(max-min), 0); + double w=(*(mapstorage.edgemap_storage)[mapname])[edge]; + double max=mapstorage.maxOfEdgeMap(mapname); + double min=mapstorage.minOfEdgeMap(mapname); + + //std::cout<property_fill_color_gdk().set_value(color); } - else - { - color.set_rgb_p (0, 100, 0); - } - - edgesmap[i]->property_fill_color_gdk().set_value(color); - } return 0; }; -int GraphDisplayerCanvas::changeText (std::string mapname) +int GraphDisplayerCanvas::changeEdgeText (std::string mapname, Graph::Edge edge) { //the number in the map will be written on the edge @@ -54,11 +87,50 @@ //that is the deleter map //\todo isn't it a bit woodcutter? - for (EdgeIt i(g); i!=INVALID; ++i) + if(edge==INVALID) { - if(mapname!="Text") + for (EdgeIt i(g); i!=INVALID; ++i) { - double number=(*(mapstorage.edgemap_storage)[mapname])[i]; + if(mapname!=edge_property_strings[E_TEXT]) + { + 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;jproperty_text().set_value(str); + } + else + { + edgetextmap[i]->property_text().set_value(""); + } + } + + } + else + { + if(mapname!=edge_property_strings[E_TEXT]) + { + 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) @@ -82,12 +154,15 @@ } } - edgetextmap[i]->property_text().set_value(str); + edgetextmap[edge]->property_text().set_value(str); } else { - edgetextmap[i]->property_text().set_value(""); + edgetextmap[edge]->property_text().set_value(""); } + } + return 0; + };