Shape keeping movement is implemented, at last. Many thanks to Alpar.
1 #include "graph_displayer_canvas.h"
2 #include "broken_edge.h"
6 int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Edge edge)
8 Graph::EdgeMap<double> * actual_map;
11 if(mapname=="Default")
13 min=edge_property_defaults[E_WIDTH];
14 max=edge_property_defaults[E_WIDTH];
15 actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_WIDTH]);
19 min=mapstorage.minOfEdgeMap(mapname);
20 max=mapstorage.maxOfEdgeMap(mapname);
21 actual_map=(mapstorage.edgemap_storage)[mapname];
26 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
28 double v=fabs((*actual_map)[i]);
32 w=(int)(edge_property_defaults[E_WIDTH]);
36 w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH));
38 edgesmap[i]->property_width_units().set_value(w);
43 int w=(int)(*actual_map)[edge];
46 edgesmap[edge]->property_width_units().set_value(w);
52 int GraphDisplayerCanvas::changeEdgeColor (std::string mapname, Edge edge)
55 //function maps the range of the maximum and
56 //the minimum of the nodemap to the range of
58 Graph::EdgeMap<double> * actual_map;
59 if(mapname=="Default")
61 actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_COLOR]);
65 actual_map=(mapstorage.edgemap_storage)[mapname];
70 if(mapname!="Default")
72 max=mapstorage.maxOfEdgeMap(mapname);
73 min=mapstorage.minOfEdgeMap(mapname);
77 max=edge_property_defaults[E_COLOR];
78 min=edge_property_defaults[E_COLOR];
83 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
85 double w=(*actual_map)[i];
90 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
94 color.set_rgb_p (0, 100, 0);
96 edgesmap[i]->property_fill_color_gdk().set_value(color);
103 double w=(*actual_map)[edge];
107 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
111 color.set_rgb_p (0, 100, 0);
114 edgesmap[edge]->property_fill_color_gdk().set_value(color);
119 int GraphDisplayerCanvas::changeEdgeText (std::string mapname, Edge edge)
121 //the number in the map will be written on the edge
122 //EXCEPT when the name of the map is Default, because
123 //in that case empty string will be written, because
124 //that is the deleter map
128 for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
130 if(mapname!="Default")
132 edgemap_to_edit=mapname;
133 double number=(*(mapstorage.edgemap_storage)[mapname])[i];
135 std::ostringstream ostr;
138 edgetextmap[i]->property_text().set_value(ostr.str());
143 edgetextmap[i]->property_text().set_value("");
150 if(mapname!="Default")
152 double number=(*(mapstorage.edgemap_storage)[mapname])[edge];
154 std::ostringstream ostr;
157 edgetextmap[edge]->property_text().set_value(ostr.str());
161 edgetextmap[edge]->property_text().set_value("");