Redesign parameters can now be saved and loaded.
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"
22 const int minimum_edge_width=0;
24 int GraphDisplayerCanvas::resetEdgeWidth (Edge edge)
28 min=edge_property_defaults[E_WIDTH];
29 max=edge_property_defaults[E_WIDTH];
30 Graph::EdgeMap<double> actual_map((mytab.mapstorage).graph,edge_property_defaults[E_WIDTH]);
34 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
36 double v=fabs(actual_map[i]);
40 w=(int)(edge_property_defaults[E_WIDTH]);
44 w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH));
48 double actual_ppu=get_pixels_per_unit();
49 w=(int)(w/actual_ppu*fixed_zoom_factor);
51 edgesmap[i]->setLineWidth(w);
56 int w=(int)actual_map[edge];
59 edgesmap[edge]->setLineWidth(w);
66 int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Edge edge)
68 Graph::EdgeMap<double> * actual_map;
71 min=(mytab.mapstorage).minOfEdgeMap(mapname);
72 max=(mytab.mapstorage).maxOfEdgeMap(mapname);
73 actual_map=((mytab.mapstorage).edgemap_storage)[mapname];
77 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
79 double v=fabs((*actual_map)[i]);
85 w=(int)(edge_property_defaults[E_WIDTH]);
89 w=(int)(minimum_edge_width+(v-min)/(max-min)*(edge_width-minimum_edge_width));
94 w=(int)(v*edge_width);
96 if(w<minimum_edge_width)
102 double actual_ppu=get_pixels_per_unit();
103 w=(int)(w/actual_ppu*fixed_zoom_factor);
105 edgesmap[i]->setLineWidth(w);
110 int w=(int)(*actual_map)[edge];
113 edgesmap[edge]->setLineWidth(w);
119 int GraphDisplayerCanvas::changeEdgeColor (std::string mapname, Edge edge)
122 //function maps the range of the maximum and
123 //the minimum of the nodemap to the range of
125 Graph::EdgeMap<double> * actual_map;
126 actual_map=((mytab.mapstorage).edgemap_storage)[mapname];
130 max=(mytab.mapstorage).maxOfEdgeMap(mapname);
131 min=(mytab.mapstorage).minOfEdgeMap(mapname);
135 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
137 double w=(*actual_map)[i];
142 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
146 color.set_rgb_p (0, 100, 0);
148 edgesmap[i]->setFillColor(color);
155 double w=(*actual_map)[edge];
159 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
163 color.set_rgb_p (0, 100, 0);
166 edgesmap[edge]->setFillColor(color);
171 int GraphDisplayerCanvas::resetEdgeColor (Edge edge)
174 //function maps the range of the maximum and
175 //the minimum of the nodemap to the range of
177 Graph::EdgeMap<double> actual_map((mytab.mapstorage).graph,edge_property_defaults[E_COLOR]);
181 max=edge_property_defaults[E_COLOR];
182 min=edge_property_defaults[E_COLOR];
186 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
188 double w=actual_map[i];
193 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
197 color.set_rgb_p (0, 100, 0);
199 edgesmap[i]->setFillColor(color);
206 double w=actual_map[edge];
210 color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
214 color.set_rgb_p (0, 100, 0);
217 edgesmap[edge]->setFillColor(color);
222 int GraphDisplayerCanvas::changeEdgeText (std::string mapname, Edge edge)
224 //the number in the map will be written on the edge
225 //EXCEPT when the name of the map is Default, because
226 //in that case empty string will be written, because
227 //that is the deleter map
231 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
233 edgemap_to_edit=mapname;
234 double number=(*((mytab.mapstorage).edgemap_storage)[mapname])[i];
236 std::ostringstream ostr;
239 edgetextmap[i]->property_text().set_value(ostr.str());
245 double number=(*((mytab.mapstorage).edgemap_storage)[mapname])[edge];
247 std::ostringstream ostr;
250 edgetextmap[edge]->property_text().set_value(ostr.str());
257 int GraphDisplayerCanvas::resetEdgeText (Edge edge)
259 //the number in the map will be written on the edge
260 //EXCEPT when the name of the map is Default, because
261 //in that case empty string will be written, because
262 //that is the deleter map
266 for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
269 edgetextmap[i]->property_text().set_value("");
275 edgetextmap[edge]->property_text().set_value("");