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;
10 if(mapname=="Default")
12 min=node_property_defaults[N_RADIUS];
13 max=node_property_defaults[N_RADIUS];
14 actual_map=new Graph::NodeMap<double>(mapstorage.graph,node_property_defaults[N_RADIUS]);
18 min=mapstorage.minOfNodeMap(mapname);
19 max=mapstorage.maxOfNodeMap(mapname);
20 actual_map=(mapstorage.nodemap_storage)[mapname];
25 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
27 double v=abs((*actual_map)[i]);
31 w=(int)(node_property_defaults[N_RADIUS]);
35 w=(int)(MIN_NODE_RADIUS+(v-min)/(max-min)*(MAX_NODE_RADIUS-MIN_NODE_RADIUS));
39 double x1, y1, x2, y2;
40 x1=nodesmap[i]->property_x1().get_value();
41 x2=nodesmap[i]->property_x2().get_value();
42 y1=nodesmap[i]->property_y1().get_value();
43 y2=nodesmap[i]->property_y2().get_value();
44 nodesmap[i]->property_x1().set_value((x1+x2)/2-w);
45 nodesmap[i]->property_x2().set_value((x1+x2)/2+w);
46 nodesmap[i]->property_y1().set_value((y1+y2)/2-w);
47 nodesmap[i]->property_y2().set_value((y1+y2)/2+w);
53 //I think only new nodes use this case
54 // int w=(int)(*actual_map)[node];
55 int w=(int)(node_property_defaults[N_RADIUS]);
58 double x1, y1, x2, y2;
59 x1=nodesmap[node]->property_x1().get_value();
60 x2=nodesmap[node]->property_x2().get_value();
61 y1=nodesmap[node]->property_y1().get_value();
62 y2=nodesmap[node]->property_y2().get_value();
63 nodesmap[node]->property_x1().set_value((x1+x2)/2-w);
64 nodesmap[node]->property_x2().set_value((x1+x2)/2+w);
65 nodesmap[node]->property_y1().set_value((y1+y2)/2-w);
66 nodesmap[node]->property_y2().set_value((y1+y2)/2+w);
72 int GraphDisplayerCanvas::changeNodeColor (std::string mapname, Graph::Node node)
75 //function maps the range of the maximum and
76 //the minimum of the nodemap to the range of
79 Graph::NodeMap<double> * actual_map;
80 if(mapname=="Default")
82 actual_map=new Graph::NodeMap<double>(mapstorage.graph,node_property_defaults[N_COLOR]);
86 actual_map=(mapstorage.nodemap_storage)[mapname];
91 if(mapname!="Default")
93 max=mapstorage.maxOfNodeMap(mapname);
94 min=mapstorage.minOfNodeMap(mapname);
98 max=node_property_defaults[N_COLOR];
99 min=node_property_defaults[N_COLOR];
106 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
110 double w=(*actual_map)[i];
114 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
118 color.set_rgb_p (0, 0, 100);
121 nodesmap[i]->property_fill_color_gdk().set_value(color);
128 double w=(*actual_map)[node];
132 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
136 color.set_rgb_p (0, 0, 100);
139 nodesmap[node]->property_fill_color_gdk().set_value(color);
144 int GraphDisplayerCanvas::changeNodeText (std::string mapname, Graph::Node node)
147 //the number in the map will be written on the node
148 //EXCEPT when the name of the map is Text, because
149 //in that case empty string will be written, because
150 //that is the deleter map
152 Graph::NodeMap<double> * actual_map=NULL;
153 if(mapname!="Default")
155 actual_map=(mapstorage.nodemap_storage)[mapname];
160 for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
162 if(mapname!="Default")
164 nodemap_to_edit=mapname;
165 double number=(*actual_map)[i];
167 std::ostringstream ostr;
170 nodetextmap[i]->property_text().set_value(ostr.str());
175 nodetextmap[i]->property_text().set_value("");
181 if(mapname!="Default")
183 double number=(*actual_map)[node];
185 std::ostringstream ostr;
188 nodetextmap[node]->property_text().set_value(ostr.str());
192 nodetextmap[node]->property_text().set_value("");