EpsWin and DesignWin does not need to know NoteBookTab.
3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
19 #include <graph_displayer_canvas.h>
20 #include <mapstorage.h>
24 const int minimum_node_radius=5;
26 int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Node node)
28 Graph::NodeMap<double> * actual_map;
30 min=(mytab.mapstorage)->minOfNodeMap(mapname);
31 max=(mytab.mapstorage)->maxOfNodeMap(mapname);
32 actual_map=((mytab.mapstorage)->nodemap_storage)[mapname];
36 for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
38 double v=fabs((*actual_map)[i]);
44 w=(int)(node_property_defaults[N_RADIUS]);
48 w=(int)(minimum_node_radius+(v-min)/(max-min)*(radius_size-minimum_node_radius));
53 w=(int)(v*radius_size);
56 if(w<minimum_node_radius)
58 w=minimum_node_radius;
63 double actual_ppu=get_pixels_per_unit();
64 w=(int)(w/actual_ppu*fixed_zoom_factor);
69 double x1, y1, x2, y2;
70 x1=nodesmap[i]->property_x1().get_value();
71 x2=nodesmap[i]->property_x2().get_value();
72 y1=nodesmap[i]->property_y1().get_value();
73 y2=nodesmap[i]->property_y2().get_value();
74 nodesmap[i]->property_x1().set_value((x1+x2)/2-w);
75 nodesmap[i]->property_x2().set_value((x1+x2)/2+w);
76 nodesmap[i]->property_y1().set_value((y1+y2)/2-w);
77 nodesmap[i]->property_y2().set_value((y1+y2)/2+w);
83 //I think only new nodes use this case
84 //that has no own value, only the default one
85 //int w=(int)(*actual_map)[node];
86 int w=(int)(node_property_defaults[N_RADIUS]);
89 double x1, y1, x2, y2;
90 x1=nodesmap[node]->property_x1().get_value();
91 x2=nodesmap[node]->property_x2().get_value();
92 y1=nodesmap[node]->property_y1().get_value();
93 y2=nodesmap[node]->property_y2().get_value();
94 nodesmap[node]->property_x1().set_value((x1+x2)/2-w);
95 nodesmap[node]->property_x2().set_value((x1+x2)/2+w);
96 nodesmap[node]->property_y1().set_value((y1+y2)/2-w);
97 nodesmap[node]->property_y2().set_value((y1+y2)/2+w);
103 int GraphDisplayerCanvas::resetNodeRadius (Node node)
106 min=node_property_defaults[N_RADIUS];
107 max=node_property_defaults[N_RADIUS];
108 Graph::NodeMap<double> actual_map((mytab.mapstorage)->graph,node_property_defaults[N_RADIUS]);
112 for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
114 double v=fabs(actual_map[i]);
118 w=(int)(node_property_defaults[N_RADIUS]);
122 w=(int)(MIN_NODE_RADIUS+(v-min)/(max-min)*(MAX_NODE_RADIUS-MIN_NODE_RADIUS));
126 double actual_ppu=get_pixels_per_unit();
127 w=(int)(w/actual_ppu*fixed_zoom_factor);
131 double x1, y1, x2, y2;
132 x1=nodesmap[i]->property_x1().get_value();
133 x2=nodesmap[i]->property_x2().get_value();
134 y1=nodesmap[i]->property_y1().get_value();
135 y2=nodesmap[i]->property_y2().get_value();
136 nodesmap[i]->property_x1().set_value((x1+x2)/2-w);
137 nodesmap[i]->property_x2().set_value((x1+x2)/2+w);
138 nodesmap[i]->property_y1().set_value((y1+y2)/2-w);
139 nodesmap[i]->property_y2().set_value((y1+y2)/2+w);
145 //I think only new nodes use this case
146 // int w=(int)actual_map[node];
147 int w=(int)(node_property_defaults[N_RADIUS]);
150 double x1, y1, x2, y2;
151 x1=nodesmap[node]->property_x1().get_value();
152 x2=nodesmap[node]->property_x2().get_value();
153 y1=nodesmap[node]->property_y1().get_value();
154 y2=nodesmap[node]->property_y2().get_value();
155 nodesmap[node]->property_x1().set_value((x1+x2)/2-w);
156 nodesmap[node]->property_x2().set_value((x1+x2)/2+w);
157 nodesmap[node]->property_y1().set_value((y1+y2)/2-w);
158 nodesmap[node]->property_y2().set_value((y1+y2)/2+w);
164 int GraphDisplayerCanvas::changeNodeColor (std::string mapname, Node node)
167 //function maps the range of the maximum and
168 //the minimum of the nodemap to the range of
171 Graph::NodeMap<double> * actual_map;
172 actual_map=((mytab.mapstorage)->nodemap_storage)[mapname];
176 max=(mytab.mapstorage)->maxOfNodeMap(mapname);
177 min=(mytab.mapstorage)->minOfNodeMap(mapname);
182 for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
186 double w=(*actual_map)[i];
190 color=rainbowColorCounter(min, max, w);
194 color.set_rgb_p (0, 0, 1);
197 nodesmap[i]->property_fill_color_gdk().set_value(color);
204 double w=(*actual_map)[node];
208 color=rainbowColorCounter(min, max, w);
212 color.set_rgb_p (0, 0, 1);
215 nodesmap[node]->property_fill_color_gdk().set_value(color);
220 int GraphDisplayerCanvas::resetNodeColor (Node node)
223 //function maps the range of the maximum and
224 //the minimum of the nodemap to the range of
227 Graph::NodeMap<double> actual_map((mytab.mapstorage)->graph,node_property_defaults[N_COLOR]);
231 max=node_property_defaults[N_COLOR];
232 min=node_property_defaults[N_COLOR];
237 for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
241 double w=actual_map[i];
245 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
249 color.set_rgb_p (0, 0, 100);
252 nodesmap[i]->property_fill_color_gdk().set_value(color);
259 double w=actual_map[node];
263 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
267 color.set_rgb_p (0, 0, 100);
270 nodesmap[node]->property_fill_color_gdk().set_value(color);
275 int GraphDisplayerCanvas::changeNodeText (std::string mapname, Node node)
278 //the number in the map will be written on the node
279 //EXCEPT when the name of the map is Text, because
280 //in that case empty string will be written, because
281 //that is the deleter map
283 Graph::NodeMap<double> * actual_map=NULL;
284 actual_map=((mytab.mapstorage)->nodemap_storage)[mapname];
288 for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
290 nodemap_to_edit=mapname;
291 double number=(*actual_map)[i];
293 std::ostringstream ostr;
296 nodetextmap[i]->property_text().set_value(ostr.str());
301 double number=(*actual_map)[node];
303 std::ostringstream ostr;
306 nodetextmap[node]->property_text().set_value(ostr.str());
311 int GraphDisplayerCanvas::resetNodeText (Node node)
314 //the number in the map will be written on the node
315 //EXCEPT when the name of the map is Text, because
316 //in that case empty string will be written, because
317 //that is the deleter map
321 for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
324 nodetextmap[i]->property_text().set_value("");
329 nodetextmap[node]->property_text().set_value("");