No maps with the same name can be added.
1 #include <graph_displayer_canvas.h>
2 #include <broken_edge.h>
6 int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Graph::Node node)
8 Graph::NodeMap<double> * actual_map;
11 actual_map=new Graph::NodeMap<double>(g,node_property_defaults[N_RADIUS]);
15 actual_map=(mapstorage.nodemap_storage)[mapname];
20 for (NodeIt i(g); i!=INVALID; ++i)
22 int w=(int)(*actual_map)[i];
25 double x1, y1, x2, y2;
26 x1=nodesmap[i]->property_x1().get_value();
27 x2=nodesmap[i]->property_x2().get_value();
28 y1=nodesmap[i]->property_y1().get_value();
29 y2=nodesmap[i]->property_y2().get_value();
30 nodesmap[i]->property_x1().set_value((x1+x2)/2-w);
31 nodesmap[i]->property_x2().set_value((x1+x2)/2+w);
32 nodesmap[i]->property_y1().set_value((y1+y2)/2-w);
33 nodesmap[i]->property_y2().set_value((y1+y2)/2+w);
39 //I think only new nodes use this case
40 // int w=(int)(*actual_map)[node];
41 int w=(int)(node_property_defaults[N_RADIUS]);
44 double x1, y1, x2, y2;
45 x1=nodesmap[node]->property_x1().get_value();
46 x2=nodesmap[node]->property_x2().get_value();
47 y1=nodesmap[node]->property_y1().get_value();
48 y2=nodesmap[node]->property_y2().get_value();
49 nodesmap[node]->property_x1().set_value((x1+x2)/2-w);
50 nodesmap[node]->property_x2().set_value((x1+x2)/2+w);
51 nodesmap[node]->property_y1().set_value((y1+y2)/2-w);
52 nodesmap[node]->property_y2().set_value((y1+y2)/2+w);
58 int GraphDisplayerCanvas::changeNodeColor (std::string mapname, Graph::Node node)
61 //function maps the range of the maximum and
62 //the minimum of the nodemap to the range of
65 Graph::NodeMap<double> * actual_map;
66 if(mapname=="Default")
68 actual_map=new Graph::NodeMap<double>(g,node_property_defaults[N_COLOR]);
72 actual_map=(mapstorage.nodemap_storage)[mapname];
77 if(mapname!="Default")
79 max=mapstorage.maxOfNodeMap(mapname);
80 min=mapstorage.minOfNodeMap(mapname);
84 max=node_property_defaults[N_COLOR];
85 min=node_property_defaults[N_COLOR];
92 for (NodeIt i(g); i!=INVALID; ++i)
96 double w=(*actual_map)[i];
100 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
104 color.set_rgb_p (0, 0, 100);
107 nodesmap[i]->property_fill_color_gdk().set_value(color);
114 double w=(*actual_map)[node];
118 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
122 color.set_rgb_p (0, 0, 100);
125 nodesmap[node]->property_fill_color_gdk().set_value(color);
130 int GraphDisplayerCanvas::changeNodeText (std::string mapname, Graph::Node node)
133 //the number in the map will be written on the node
134 //EXCEPT when the name of the map is Text, because
135 //in that case empty string will be written, because
136 //that is the deleter map
138 Graph::NodeMap<double> * actual_map=NULL;
139 if(mapname!="Default")
141 actual_map=(mapstorage.nodemap_storage)[mapname];
146 for (NodeIt i(g); i!=INVALID; ++i)
148 if(mapname!="Default")
150 nodemap_to_edit=mapname;
151 double number=(*actual_map)[i];
153 std::ostringstream ostr;
156 nodetextmap[i]->property_text().set_value(ostr.str());
161 nodetextmap[i]->property_text().set_value("");
167 if(mapname!="Default")
169 double number=(*actual_map)[node];
171 std::ostringstream ostr;
174 nodetextmap[node]->property_text().set_value(ostr.str());
178 nodetextmap[node]->property_text().set_value("");