ladanyi@53: #include "graph_displayer_canvas.h" alpar@59: #include hegyi@27: hegyi@27: hegyi@81: int GraphDisplayerCanvas::resetEdgeWidth (Edge edge) hegyi@81: { hegyi@81: double min, max; hegyi@81: hegyi@81: min=edge_property_defaults[E_WIDTH]; hegyi@81: max=edge_property_defaults[E_WIDTH]; hegyi@96: Graph::EdgeMap actual_map((mytab.mapstorage).graph,edge_property_defaults[E_WIDTH]); hegyi@81: hegyi@81: if(edge==INVALID) hegyi@81: { hegyi@96: for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) hegyi@81: { ladanyi@91: double v=fabs(actual_map[i]); hegyi@81: int w; hegyi@81: if(min==max) hegyi@81: { hegyi@81: w=(int)(edge_property_defaults[E_WIDTH]); hegyi@81: } hegyi@81: else hegyi@81: { hegyi@81: w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH)); hegyi@81: } hegyi@81: edgesmap[i]->property_width_units().set_value(w); hegyi@81: } hegyi@81: } hegyi@81: else hegyi@81: { ladanyi@91: int w=(int)actual_map[edge]; hegyi@81: if(w>=0) hegyi@81: { hegyi@81: edgesmap[edge]->property_width_units().set_value(w); hegyi@81: } hegyi@81: } hegyi@81: return 0; hegyi@81: } hegyi@81: hegyi@81: alpar@62: int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Edge edge) hegyi@27: { hegyi@31: Graph::EdgeMap * actual_map; hegyi@48: double min, max; hegyi@48: hegyi@96: min=(mytab.mapstorage).minOfEdgeMap(mapname); hegyi@96: max=(mytab.mapstorage).maxOfEdgeMap(mapname); hegyi@96: actual_map=((mytab.mapstorage).edgemap_storage)[mapname]; hegyi@31: hegyi@28: if(edge==INVALID) hegyi@27: { hegyi@96: for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) hegyi@28: { hegyi@55: double v=fabs((*actual_map)[i]); hegyi@48: int w; hegyi@48: if(min==max) hegyi@28: { hegyi@48: w=(int)(edge_property_defaults[E_WIDTH]); hegyi@28: } hegyi@48: else hegyi@48: { hegyi@48: w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH)); hegyi@48: } hegyi@48: edgesmap[i]->property_width_units().set_value(w); hegyi@28: } hegyi@28: } hegyi@28: else hegyi@28: { hegyi@31: int w=(int)(*actual_map)[edge]; hegyi@27: if(w>=0) hegyi@27: { hegyi@47: edgesmap[edge]->property_width_units().set_value(w); hegyi@27: } hegyi@27: } hegyi@27: return 0; hegyi@27: }; hegyi@27: alpar@62: int GraphDisplayerCanvas::changeEdgeColor (std::string mapname, Edge edge) hegyi@27: { hegyi@27: hegyi@27: //function maps the range of the maximum and hegyi@27: //the minimum of the nodemap to the range of hegyi@27: //green in RGB hegyi@31: Graph::EdgeMap * actual_map; hegyi@96: actual_map=((mytab.mapstorage).edgemap_storage)[mapname]; hegyi@81: hegyi@81: double max, min; hegyi@81: hegyi@96: max=(mytab.mapstorage).maxOfEdgeMap(mapname); hegyi@96: min=(mytab.mapstorage).minOfEdgeMap(mapname); hegyi@81: hegyi@81: if(edge==INVALID) hegyi@31: { hegyi@96: for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) hegyi@81: { hegyi@81: double w=(*actual_map)[i]; hegyi@81: hegyi@81: Gdk::Color color; hegyi@81: if(max!=min) hegyi@81: { hegyi@81: color.set_rgb_p (0, 100*(w-min)/(max-min), 0); hegyi@81: } hegyi@81: else hegyi@81: { hegyi@81: color.set_rgb_p (0, 100, 0); hegyi@81: } hegyi@81: edgesmap[i]->property_fill_color_gdk().set_value(color); hegyi@81: } hegyi@31: } hegyi@31: else hegyi@31: { hegyi@81: Gdk::Color color; hegyi@81: hegyi@81: double w=(*actual_map)[edge]; hegyi@81: hegyi@81: if(max!=min) hegyi@81: { hegyi@81: color.set_rgb_p (0, 100*(w-min)/(max-min), 0); hegyi@81: } hegyi@81: else hegyi@81: { hegyi@81: color.set_rgb_p (0, 100, 0); hegyi@81: } hegyi@81: hegyi@81: edgesmap[edge]->property_fill_color_gdk().set_value(color); hegyi@31: } hegyi@81: return 0; hegyi@81: }; hegyi@81: hegyi@81: int GraphDisplayerCanvas::resetEdgeColor (Edge edge) hegyi@81: { hegyi@81: hegyi@81: //function maps the range of the maximum and hegyi@81: //the minimum of the nodemap to the range of hegyi@81: //green in RGB hegyi@96: Graph::EdgeMap actual_map((mytab.mapstorage).graph,edge_property_defaults[E_COLOR]); hegyi@31: hegyi@31: double max, min; hegyi@31: hegyi@81: max=edge_property_defaults[E_COLOR]; hegyi@81: min=edge_property_defaults[E_COLOR]; hegyi@31: hegyi@28: if(edge==INVALID) hegyi@28: { hegyi@96: for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) hegyi@28: { ladanyi@91: double w=actual_map[i]; hegyi@31: hegyi@28: Gdk::Color color; hegyi@28: if(max!=min) hegyi@28: { hegyi@28: color.set_rgb_p (0, 100*(w-min)/(max-min), 0); hegyi@28: } hegyi@28: else hegyi@28: { hegyi@28: color.set_rgb_p (0, 100, 0); hegyi@28: } hegyi@28: edgesmap[i]->property_fill_color_gdk().set_value(color); hegyi@28: } hegyi@28: } hegyi@28: else hegyi@27: { hegyi@28: Gdk::Color color; hegyi@31: ladanyi@91: double w=actual_map[edge]; hegyi@31: hegyi@28: if(max!=min) hegyi@28: { hegyi@28: color.set_rgb_p (0, 100*(w-min)/(max-min), 0); hegyi@28: } hegyi@28: else hegyi@28: { hegyi@28: color.set_rgb_p (0, 100, 0); hegyi@28: } hegyi@28: hegyi@28: edgesmap[edge]->property_fill_color_gdk().set_value(color); hegyi@27: } hegyi@27: return 0; hegyi@27: }; hegyi@27: alpar@62: int GraphDisplayerCanvas::changeEdgeText (std::string mapname, Edge edge) hegyi@27: { hegyi@27: //the number in the map will be written on the edge hegyi@40: //EXCEPT when the name of the map is Default, because hegyi@27: //in that case empty string will be written, because hegyi@27: //that is the deleter map ladanyi@63: hegyi@28: if(edge==INVALID) hegyi@27: { hegyi@96: for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) hegyi@27: { hegyi@81: edgemap_to_edit=mapname; hegyi@96: double number=(*((mytab.mapstorage).edgemap_storage)[mapname])[i]; hegyi@81: hegyi@81: std::ostringstream ostr; hegyi@81: ostr << number; hegyi@81: hegyi@81: edgetextmap[i]->property_text().set_value(ostr.str()); hegyi@28: } hegyi@28: hegyi@28: } hegyi@28: else hegyi@28: { hegyi@96: double number=(*((mytab.mapstorage).edgemap_storage)[mapname])[edge]; hegyi@45: hegyi@45: std::ostringstream ostr; hegyi@45: ostr << number; hegyi@45: hegyi@45: edgetextmap[edge]->property_text().set_value(ostr.str()); hegyi@27: } hegyi@28: hegyi@27: return 0; hegyi@28: hegyi@27: }; hegyi@81: hegyi@81: int GraphDisplayerCanvas::resetEdgeText (Edge edge) hegyi@81: { hegyi@81: //the number in the map will be written on the edge hegyi@81: //EXCEPT when the name of the map is Default, because hegyi@81: //in that case empty string will be written, because hegyi@81: //that is the deleter map hegyi@81: hegyi@81: if(edge==INVALID) hegyi@81: { hegyi@96: for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i) hegyi@81: { hegyi@81: edgemap_to_edit=""; hegyi@81: edgetextmap[i]->property_text().set_value(""); hegyi@81: } hegyi@81: hegyi@81: } hegyi@81: else hegyi@81: { hegyi@81: edgetextmap[edge]->property_text().set_value(""); hegyi@81: } hegyi@81: hegyi@81: return 0; hegyi@81: hegyi@81: };