ladanyi@1606
|
1 |
#include "graph_displayer_canvas.h"
|
ladanyi@1606
|
2 |
#include "broken_edge.h"
|
alpar@1632
|
3 |
#include <cmath>
|
hegyi@1510
|
4 |
|
hegyi@1510
|
5 |
|
hegyi@1731
|
6 |
int GraphDisplayerCanvas::resetEdgeWidth (Edge edge)
|
hegyi@1731
|
7 |
{
|
hegyi@1731
|
8 |
Graph::EdgeMap<double> * actual_map;
|
hegyi@1731
|
9 |
double min, max;
|
hegyi@1731
|
10 |
|
hegyi@1731
|
11 |
min=edge_property_defaults[E_WIDTH];
|
hegyi@1731
|
12 |
max=edge_property_defaults[E_WIDTH];
|
hegyi@1731
|
13 |
actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_WIDTH]);
|
hegyi@1731
|
14 |
|
hegyi@1731
|
15 |
if(edge==INVALID)
|
hegyi@1731
|
16 |
{
|
hegyi@1731
|
17 |
for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
|
hegyi@1731
|
18 |
{
|
hegyi@1731
|
19 |
double v=fabs((*actual_map)[i]);
|
hegyi@1731
|
20 |
int w;
|
hegyi@1731
|
21 |
if(min==max)
|
hegyi@1731
|
22 |
{
|
hegyi@1731
|
23 |
w=(int)(edge_property_defaults[E_WIDTH]);
|
hegyi@1731
|
24 |
}
|
hegyi@1731
|
25 |
else
|
hegyi@1731
|
26 |
{
|
hegyi@1731
|
27 |
w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH));
|
hegyi@1731
|
28 |
}
|
hegyi@1731
|
29 |
edgesmap[i]->property_width_units().set_value(w);
|
hegyi@1731
|
30 |
}
|
hegyi@1731
|
31 |
}
|
hegyi@1731
|
32 |
else
|
hegyi@1731
|
33 |
{
|
hegyi@1731
|
34 |
int w=(int)(*actual_map)[edge];
|
hegyi@1731
|
35 |
if(w>=0)
|
hegyi@1731
|
36 |
{
|
hegyi@1731
|
37 |
edgesmap[edge]->property_width_units().set_value(w);
|
hegyi@1731
|
38 |
}
|
hegyi@1731
|
39 |
}
|
hegyi@1731
|
40 |
return 0;
|
hegyi@1731
|
41 |
}
|
hegyi@1731
|
42 |
|
hegyi@1731
|
43 |
|
alpar@1643
|
44 |
int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Edge edge)
|
hegyi@1510
|
45 |
{
|
hegyi@1525
|
46 |
Graph::EdgeMap<double> * actual_map;
|
hegyi@1599
|
47 |
double min, max;
|
hegyi@1599
|
48 |
|
hegyi@1731
|
49 |
min=mapstorage.minOfEdgeMap(mapname);
|
hegyi@1731
|
50 |
max=mapstorage.maxOfEdgeMap(mapname);
|
hegyi@1731
|
51 |
actual_map=(mapstorage.edgemap_storage)[mapname];
|
hegyi@1525
|
52 |
|
hegyi@1512
|
53 |
if(edge==INVALID)
|
hegyi@1510
|
54 |
{
|
ladanyi@1606
|
55 |
for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
|
hegyi@1512
|
56 |
{
|
hegyi@1614
|
57 |
double v=fabs((*actual_map)[i]);
|
hegyi@1599
|
58 |
int w;
|
hegyi@1599
|
59 |
if(min==max)
|
hegyi@1512
|
60 |
{
|
hegyi@1599
|
61 |
w=(int)(edge_property_defaults[E_WIDTH]);
|
hegyi@1512
|
62 |
}
|
hegyi@1599
|
63 |
else
|
hegyi@1599
|
64 |
{
|
hegyi@1599
|
65 |
w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH));
|
hegyi@1599
|
66 |
}
|
hegyi@1599
|
67 |
edgesmap[i]->property_width_units().set_value(w);
|
hegyi@1512
|
68 |
}
|
hegyi@1512
|
69 |
}
|
hegyi@1512
|
70 |
else
|
hegyi@1512
|
71 |
{
|
hegyi@1525
|
72 |
int w=(int)(*actual_map)[edge];
|
hegyi@1510
|
73 |
if(w>=0)
|
hegyi@1510
|
74 |
{
|
hegyi@1598
|
75 |
edgesmap[edge]->property_width_units().set_value(w);
|
hegyi@1510
|
76 |
}
|
hegyi@1510
|
77 |
}
|
hegyi@1510
|
78 |
return 0;
|
hegyi@1510
|
79 |
};
|
hegyi@1510
|
80 |
|
alpar@1643
|
81 |
int GraphDisplayerCanvas::changeEdgeColor (std::string mapname, Edge edge)
|
hegyi@1510
|
82 |
{
|
hegyi@1510
|
83 |
|
hegyi@1510
|
84 |
//function maps the range of the maximum and
|
hegyi@1510
|
85 |
//the minimum of the nodemap to the range of
|
hegyi@1510
|
86 |
//green in RGB
|
hegyi@1525
|
87 |
Graph::EdgeMap<double> * actual_map;
|
hegyi@1731
|
88 |
actual_map=(mapstorage.edgemap_storage)[mapname];
|
hegyi@1731
|
89 |
|
hegyi@1731
|
90 |
double max, min;
|
hegyi@1731
|
91 |
|
hegyi@1731
|
92 |
max=mapstorage.maxOfEdgeMap(mapname);
|
hegyi@1731
|
93 |
min=mapstorage.minOfEdgeMap(mapname);
|
hegyi@1731
|
94 |
|
hegyi@1731
|
95 |
if(edge==INVALID)
|
hegyi@1525
|
96 |
{
|
hegyi@1731
|
97 |
for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
|
hegyi@1731
|
98 |
{
|
hegyi@1731
|
99 |
double w=(*actual_map)[i];
|
hegyi@1731
|
100 |
|
hegyi@1731
|
101 |
Gdk::Color color;
|
hegyi@1731
|
102 |
if(max!=min)
|
hegyi@1731
|
103 |
{
|
hegyi@1731
|
104 |
color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
|
hegyi@1731
|
105 |
}
|
hegyi@1731
|
106 |
else
|
hegyi@1731
|
107 |
{
|
hegyi@1731
|
108 |
color.set_rgb_p (0, 100, 0);
|
hegyi@1731
|
109 |
}
|
hegyi@1731
|
110 |
edgesmap[i]->property_fill_color_gdk().set_value(color);
|
hegyi@1731
|
111 |
}
|
hegyi@1525
|
112 |
}
|
hegyi@1525
|
113 |
else
|
hegyi@1525
|
114 |
{
|
hegyi@1731
|
115 |
Gdk::Color color;
|
hegyi@1731
|
116 |
|
hegyi@1731
|
117 |
double w=(*actual_map)[edge];
|
hegyi@1731
|
118 |
|
hegyi@1731
|
119 |
if(max!=min)
|
hegyi@1731
|
120 |
{
|
hegyi@1731
|
121 |
color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
|
hegyi@1731
|
122 |
}
|
hegyi@1731
|
123 |
else
|
hegyi@1731
|
124 |
{
|
hegyi@1731
|
125 |
color.set_rgb_p (0, 100, 0);
|
hegyi@1731
|
126 |
}
|
hegyi@1731
|
127 |
|
hegyi@1731
|
128 |
edgesmap[edge]->property_fill_color_gdk().set_value(color);
|
hegyi@1525
|
129 |
}
|
hegyi@1731
|
130 |
return 0;
|
hegyi@1731
|
131 |
};
|
hegyi@1731
|
132 |
|
hegyi@1731
|
133 |
int GraphDisplayerCanvas::resetEdgeColor (Edge edge)
|
hegyi@1731
|
134 |
{
|
hegyi@1731
|
135 |
|
hegyi@1731
|
136 |
//function maps the range of the maximum and
|
hegyi@1731
|
137 |
//the minimum of the nodemap to the range of
|
hegyi@1731
|
138 |
//green in RGB
|
hegyi@1731
|
139 |
Graph::EdgeMap<double> * actual_map;
|
hegyi@1731
|
140 |
actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_COLOR]);
|
hegyi@1525
|
141 |
|
hegyi@1525
|
142 |
double max, min;
|
hegyi@1525
|
143 |
|
hegyi@1731
|
144 |
max=edge_property_defaults[E_COLOR];
|
hegyi@1731
|
145 |
min=edge_property_defaults[E_COLOR];
|
hegyi@1525
|
146 |
|
hegyi@1512
|
147 |
if(edge==INVALID)
|
hegyi@1512
|
148 |
{
|
ladanyi@1606
|
149 |
for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
|
hegyi@1512
|
150 |
{
|
hegyi@1525
|
151 |
double w=(*actual_map)[i];
|
hegyi@1525
|
152 |
|
hegyi@1512
|
153 |
Gdk::Color color;
|
hegyi@1512
|
154 |
if(max!=min)
|
hegyi@1512
|
155 |
{
|
hegyi@1512
|
156 |
color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
|
hegyi@1512
|
157 |
}
|
hegyi@1512
|
158 |
else
|
hegyi@1512
|
159 |
{
|
hegyi@1512
|
160 |
color.set_rgb_p (0, 100, 0);
|
hegyi@1512
|
161 |
}
|
hegyi@1512
|
162 |
edgesmap[i]->property_fill_color_gdk().set_value(color);
|
hegyi@1512
|
163 |
}
|
hegyi@1512
|
164 |
}
|
hegyi@1512
|
165 |
else
|
hegyi@1510
|
166 |
{
|
hegyi@1512
|
167 |
Gdk::Color color;
|
hegyi@1525
|
168 |
|
hegyi@1525
|
169 |
double w=(*actual_map)[edge];
|
hegyi@1525
|
170 |
|
hegyi@1512
|
171 |
if(max!=min)
|
hegyi@1512
|
172 |
{
|
hegyi@1512
|
173 |
color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
|
hegyi@1512
|
174 |
}
|
hegyi@1512
|
175 |
else
|
hegyi@1512
|
176 |
{
|
hegyi@1512
|
177 |
color.set_rgb_p (0, 100, 0);
|
hegyi@1512
|
178 |
}
|
hegyi@1512
|
179 |
|
hegyi@1512
|
180 |
edgesmap[edge]->property_fill_color_gdk().set_value(color);
|
hegyi@1510
|
181 |
}
|
hegyi@1510
|
182 |
return 0;
|
hegyi@1510
|
183 |
};
|
hegyi@1510
|
184 |
|
alpar@1643
|
185 |
int GraphDisplayerCanvas::changeEdgeText (std::string mapname, Edge edge)
|
hegyi@1510
|
186 |
{
|
hegyi@1510
|
187 |
//the number in the map will be written on the edge
|
hegyi@1589
|
188 |
//EXCEPT when the name of the map is Default, because
|
hegyi@1510
|
189 |
//in that case empty string will be written, because
|
hegyi@1510
|
190 |
//that is the deleter map
|
ladanyi@1645
|
191 |
|
hegyi@1512
|
192 |
if(edge==INVALID)
|
hegyi@1510
|
193 |
{
|
ladanyi@1606
|
194 |
for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
|
hegyi@1510
|
195 |
{
|
hegyi@1731
|
196 |
edgemap_to_edit=mapname;
|
hegyi@1731
|
197 |
double number=(*(mapstorage.edgemap_storage)[mapname])[i];
|
hegyi@1731
|
198 |
|
hegyi@1731
|
199 |
std::ostringstream ostr;
|
hegyi@1731
|
200 |
ostr << number;
|
hegyi@1731
|
201 |
|
hegyi@1731
|
202 |
edgetextmap[i]->property_text().set_value(ostr.str());
|
hegyi@1512
|
203 |
}
|
hegyi@1512
|
204 |
|
hegyi@1512
|
205 |
}
|
hegyi@1512
|
206 |
else
|
hegyi@1512
|
207 |
{
|
hegyi@1512
|
208 |
double number=(*(mapstorage.edgemap_storage)[mapname])[edge];
|
hegyi@1596
|
209 |
|
hegyi@1596
|
210 |
std::ostringstream ostr;
|
hegyi@1596
|
211 |
ostr << number;
|
hegyi@1596
|
212 |
|
hegyi@1596
|
213 |
edgetextmap[edge]->property_text().set_value(ostr.str());
|
hegyi@1510
|
214 |
}
|
hegyi@1512
|
215 |
|
hegyi@1510
|
216 |
return 0;
|
hegyi@1512
|
217 |
|
hegyi@1510
|
218 |
};
|
hegyi@1731
|
219 |
|
hegyi@1731
|
220 |
int GraphDisplayerCanvas::resetEdgeText (Edge edge)
|
hegyi@1731
|
221 |
{
|
hegyi@1731
|
222 |
//the number in the map will be written on the edge
|
hegyi@1731
|
223 |
//EXCEPT when the name of the map is Default, because
|
hegyi@1731
|
224 |
//in that case empty string will be written, because
|
hegyi@1731
|
225 |
//that is the deleter map
|
hegyi@1731
|
226 |
|
hegyi@1731
|
227 |
if(edge==INVALID)
|
hegyi@1731
|
228 |
{
|
hegyi@1731
|
229 |
for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
|
hegyi@1731
|
230 |
{
|
hegyi@1731
|
231 |
edgemap_to_edit="";
|
hegyi@1731
|
232 |
edgetextmap[i]->property_text().set_value("");
|
hegyi@1731
|
233 |
}
|
hegyi@1731
|
234 |
|
hegyi@1731
|
235 |
}
|
hegyi@1731
|
236 |
else
|
hegyi@1731
|
237 |
{
|
hegyi@1731
|
238 |
edgetextmap[edge]->property_text().set_value("");
|
hegyi@1731
|
239 |
}
|
hegyi@1731
|
240 |
|
hegyi@1731
|
241 |
return 0;
|
hegyi@1731
|
242 |
|
hegyi@1731
|
243 |
};
|