ladanyi@1606: #include "graph_displayer_canvas.h" ladanyi@1606: #include "broken_edge.h" alpar@1632: #include hegyi@1510: hegyi@1510: alpar@1643: int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Edge edge) hegyi@1510: { hegyi@1525: Graph::EdgeMap * actual_map; hegyi@1599: double min, max; hegyi@1599: hegyi@1525: if(mapname=="Default") hegyi@1525: { hegyi@1599: min=edge_property_defaults[E_WIDTH]; hegyi@1599: max=edge_property_defaults[E_WIDTH]; ladanyi@1606: actual_map=new Graph::EdgeMap(mapstorage.graph,edge_property_defaults[E_WIDTH]); hegyi@1525: } hegyi@1525: else hegyi@1525: { hegyi@1599: min=mapstorage.minOfEdgeMap(mapname); hegyi@1599: max=mapstorage.maxOfEdgeMap(mapname); hegyi@1525: actual_map=(mapstorage.edgemap_storage)[mapname]; hegyi@1525: } hegyi@1525: hegyi@1512: if(edge==INVALID) hegyi@1510: { ladanyi@1606: for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i) hegyi@1512: { hegyi@1614: double v=fabs((*actual_map)[i]); hegyi@1599: int w; hegyi@1599: if(min==max) hegyi@1512: { hegyi@1599: w=(int)(edge_property_defaults[E_WIDTH]); hegyi@1512: } hegyi@1599: else hegyi@1599: { hegyi@1599: w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH)); hegyi@1599: } hegyi@1599: edgesmap[i]->property_width_units().set_value(w); hegyi@1512: } hegyi@1512: } hegyi@1512: else hegyi@1512: { hegyi@1525: int w=(int)(*actual_map)[edge]; hegyi@1510: if(w>=0) hegyi@1510: { hegyi@1598: edgesmap[edge]->property_width_units().set_value(w); hegyi@1510: } hegyi@1510: } hegyi@1510: return 0; hegyi@1510: }; hegyi@1510: alpar@1643: int GraphDisplayerCanvas::changeEdgeColor (std::string mapname, Edge edge) hegyi@1510: { hegyi@1510: hegyi@1510: //function maps the range of the maximum and hegyi@1510: //the minimum of the nodemap to the range of hegyi@1510: //green in RGB hegyi@1525: Graph::EdgeMap * actual_map; hegyi@1525: if(mapname=="Default") hegyi@1525: { ladanyi@1606: actual_map=new Graph::EdgeMap(mapstorage.graph,edge_property_defaults[E_COLOR]); hegyi@1525: } hegyi@1525: else hegyi@1525: { hegyi@1525: actual_map=(mapstorage.edgemap_storage)[mapname]; hegyi@1525: } hegyi@1525: hegyi@1525: double max, min; hegyi@1525: hegyi@1525: if(mapname!="Default") hegyi@1525: { hegyi@1525: max=mapstorage.maxOfEdgeMap(mapname); hegyi@1525: min=mapstorage.minOfEdgeMap(mapname); hegyi@1525: } hegyi@1525: else hegyi@1525: { hegyi@1525: max=edge_property_defaults[E_COLOR]; hegyi@1525: min=edge_property_defaults[E_COLOR]; hegyi@1525: } hegyi@1525: hegyi@1512: if(edge==INVALID) hegyi@1512: { ladanyi@1606: for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i) hegyi@1512: { hegyi@1525: double w=(*actual_map)[i]; hegyi@1525: hegyi@1512: Gdk::Color color; hegyi@1512: if(max!=min) hegyi@1512: { hegyi@1512: color.set_rgb_p (0, 100*(w-min)/(max-min), 0); hegyi@1512: } hegyi@1512: else hegyi@1512: { hegyi@1512: color.set_rgb_p (0, 100, 0); hegyi@1512: } hegyi@1512: edgesmap[i]->property_fill_color_gdk().set_value(color); hegyi@1512: } hegyi@1512: } hegyi@1512: else hegyi@1510: { hegyi@1512: Gdk::Color color; hegyi@1525: hegyi@1525: double w=(*actual_map)[edge]; hegyi@1525: hegyi@1512: if(max!=min) hegyi@1512: { hegyi@1512: color.set_rgb_p (0, 100*(w-min)/(max-min), 0); hegyi@1512: } hegyi@1512: else hegyi@1512: { hegyi@1512: color.set_rgb_p (0, 100, 0); hegyi@1512: } hegyi@1512: hegyi@1512: edgesmap[edge]->property_fill_color_gdk().set_value(color); hegyi@1510: } hegyi@1510: return 0; hegyi@1510: }; hegyi@1510: alpar@1643: int GraphDisplayerCanvas::changeEdgeText (std::string mapname, Edge edge) hegyi@1510: { hegyi@1510: //the number in the map will be written on the edge hegyi@1589: //EXCEPT when the name of the map is Default, because hegyi@1510: //in that case empty string will be written, because hegyi@1510: //that is the deleter map ladanyi@1645: hegyi@1512: if(edge==INVALID) hegyi@1510: { ladanyi@1606: for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i) hegyi@1510: { hegyi@1525: if(mapname!="Default") hegyi@1512: { hegyi@1579: edgemap_to_edit=mapname; hegyi@1512: double number=(*(mapstorage.edgemap_storage)[mapname])[i]; hegyi@1595: hegyi@1595: std::ostringstream ostr; hegyi@1595: ostr << number; hegyi@1596: hegyi@1595: edgetextmap[i]->property_text().set_value(ostr.str()); hegyi@1512: } hegyi@1512: else hegyi@1512: { hegyi@1579: edgemap_to_edit=""; hegyi@1512: edgetextmap[i]->property_text().set_value(""); hegyi@1512: } hegyi@1512: } hegyi@1512: hegyi@1512: } hegyi@1512: else hegyi@1512: { hegyi@1525: if(mapname!="Default") hegyi@1512: { hegyi@1512: double number=(*(mapstorage.edgemap_storage)[mapname])[edge]; hegyi@1596: hegyi@1596: std::ostringstream ostr; hegyi@1596: ostr << number; hegyi@1596: hegyi@1596: edgetextmap[edge]->property_text().set_value(ostr.str()); hegyi@1510: } hegyi@1510: else hegyi@1510: { hegyi@1512: edgetextmap[edge]->property_text().set_value(""); hegyi@1510: } hegyi@1512: hegyi@1510: } hegyi@1512: hegyi@1510: return 0; hegyi@1512: hegyi@1510: };