ladanyi@53
|
1 |
#include "mapstorage.h"
|
ladanyi@98
|
2 |
#include "gui_writer.h"
|
ladanyi@98
|
3 |
#include "gui_reader.h"
|
alpar@128
|
4 |
#include <limits>
|
alpar@128
|
5 |
#include <cmath>
|
ladanyi@63
|
6 |
#include <gtkmm.h>
|
deba@77
|
7 |
|
ladanyi@98
|
8 |
MapStorage::MapStorage() : modified(false), file_name(""), arrow_pos_read_ok(false)
|
ladanyi@6
|
9 |
{
|
ladanyi@53
|
10 |
nodemap_storage["coordinates_x"] = new Graph::NodeMap<double>(graph);
|
ladanyi@53
|
11 |
coords.setXMap(*nodemap_storage["coordinates_x"]);
|
ladanyi@53
|
12 |
nodemap_storage["coordinates_y"] = new Graph::NodeMap<double>(graph);
|
ladanyi@53
|
13 |
coords.setYMap(*nodemap_storage["coordinates_y"]);
|
ladanyi@53
|
14 |
|
ladanyi@98
|
15 |
edgemap_storage["arrow_pos_x"] = new Graph::EdgeMap<double>(graph);
|
ladanyi@98
|
16 |
arrow_pos.setXMap(*edgemap_storage["arrow_pos_x"]);
|
ladanyi@98
|
17 |
edgemap_storage["arrow_pos_y"] = new Graph::EdgeMap<double>(graph);
|
ladanyi@98
|
18 |
arrow_pos.setYMap(*edgemap_storage["arrow_pos_y"]);
|
ladanyi@98
|
19 |
|
ladanyi@134
|
20 |
nodemap_storage["label"] = new Graph::NodeMap<double>(graph);
|
ladanyi@134
|
21 |
edgemap_storage["label"] = new Graph::EdgeMap<double>(graph);
|
ladanyi@64
|
22 |
|
ladanyi@134
|
23 |
nodemap_default["label"] = 1.0;
|
ladanyi@134
|
24 |
edgemap_default["label"] = 1.0;
|
hegyi@94
|
25 |
|
hegyi@94
|
26 |
active_nodemaps.resize(NODE_PROPERTY_NUM);
|
hegyi@94
|
27 |
for(int i=0;i<NODE_PROPERTY_NUM;i++)
|
hegyi@94
|
28 |
{
|
hegyi@94
|
29 |
active_nodemaps[i]="";
|
hegyi@94
|
30 |
}
|
hegyi@94
|
31 |
|
hegyi@94
|
32 |
active_edgemaps.resize(EDGE_PROPERTY_NUM);
|
hegyi@94
|
33 |
for(int i=0;i<EDGE_PROPERTY_NUM;i++)
|
hegyi@94
|
34 |
{
|
hegyi@94
|
35 |
active_edgemaps[i]="";
|
hegyi@94
|
36 |
}
|
ladanyi@53
|
37 |
}
|
ladanyi@53
|
38 |
|
ladanyi@53
|
39 |
MapStorage::~MapStorage()
|
ladanyi@53
|
40 |
{
|
ladanyi@53
|
41 |
for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it =
|
ladanyi@53
|
42 |
nodemap_storage.begin(); it != nodemap_storage.end(); ++it)
|
ladanyi@53
|
43 |
{
|
ladanyi@53
|
44 |
delete it->second;
|
ladanyi@53
|
45 |
}
|
ladanyi@53
|
46 |
for (std::map<std::string, Graph::EdgeMap<double>*>::const_iterator it =
|
ladanyi@53
|
47 |
edgemap_storage.begin(); it != edgemap_storage.end(); ++it)
|
ladanyi@53
|
48 |
{
|
ladanyi@53
|
49 |
delete it->second;
|
ladanyi@53
|
50 |
}
|
ladanyi@53
|
51 |
}
|
ladanyi@6
|
52 |
|
hegyi@118
|
53 |
int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap<double> *nodemap, double default_value)
|
ladanyi@6
|
54 |
{
|
hegyi@118
|
55 |
std::cout << default_value << std::endl;
|
hegyi@46
|
56 |
if( nodemap_storage.find(name) == nodemap_storage.end() )
|
hegyi@46
|
57 |
{
|
hegyi@46
|
58 |
nodemap_storage[name]=nodemap;
|
ladanyi@63
|
59 |
// set the maps default value
|
ladanyi@63
|
60 |
nodemap_default[name] = default_value;
|
hegyi@108
|
61 |
|
hegyi@108
|
62 |
//announce changement in maps
|
hegyi@108
|
63 |
signal_node_map.emit(name);
|
hegyi@46
|
64 |
return 0;
|
hegyi@46
|
65 |
}
|
hegyi@46
|
66 |
return 1;
|
ladanyi@6
|
67 |
}
|
ladanyi@6
|
68 |
|
hegyi@94
|
69 |
void MapStorage::changeActiveMap(bool itisedge, int prop, std::string mapname)
|
hegyi@94
|
70 |
{
|
hegyi@94
|
71 |
if(itisedge)
|
hegyi@94
|
72 |
{
|
hegyi@94
|
73 |
active_edgemaps[prop]=mapname;
|
hegyi@94
|
74 |
}
|
hegyi@94
|
75 |
else
|
hegyi@94
|
76 |
{
|
hegyi@94
|
77 |
active_nodemaps[prop]=mapname;
|
hegyi@94
|
78 |
}
|
hegyi@94
|
79 |
signal_prop.emit(itisedge, prop);
|
hegyi@94
|
80 |
}
|
hegyi@94
|
81 |
|
hegyi@94
|
82 |
std::string MapStorage::getActiveEdgeMap(int prop)
|
hegyi@94
|
83 |
{
|
hegyi@94
|
84 |
return active_edgemaps[prop];
|
hegyi@94
|
85 |
}
|
hegyi@94
|
86 |
|
hegyi@94
|
87 |
std::string MapStorage::getActiveNodeMap(int prop)
|
hegyi@94
|
88 |
{
|
hegyi@94
|
89 |
return active_nodemaps[prop];
|
hegyi@94
|
90 |
}
|
hegyi@94
|
91 |
|
hegyi@94
|
92 |
std::vector<std::string> MapStorage::getEdgeMapList()
|
hegyi@94
|
93 |
{
|
hegyi@94
|
94 |
std::vector<std::string> eml;
|
hegyi@94
|
95 |
eml.resize(edgemap_storage.size());
|
hegyi@94
|
96 |
int i=0;
|
hegyi@94
|
97 |
std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=beginOfEdgeMaps();
|
hegyi@94
|
98 |
for(;emsi!=endOfEdgeMaps();emsi++)
|
hegyi@94
|
99 |
{
|
hegyi@94
|
100 |
eml[i]=(emsi->first);
|
hegyi@94
|
101 |
i++;
|
hegyi@94
|
102 |
}
|
hegyi@94
|
103 |
return eml;
|
hegyi@94
|
104 |
}
|
hegyi@94
|
105 |
|
hegyi@94
|
106 |
std::vector<std::string> MapStorage::getNodeMapList()
|
hegyi@94
|
107 |
{
|
hegyi@94
|
108 |
std::vector<std::string> nml;
|
hegyi@94
|
109 |
nml.resize(nodemap_storage.size());
|
hegyi@94
|
110 |
int i=0;
|
hegyi@94
|
111 |
std::map< std::string,Graph::NodeMap<double> * >::iterator nmsi=beginOfNodeMaps();
|
hegyi@94
|
112 |
for(;nmsi!=endOfNodeMaps();nmsi++)
|
hegyi@94
|
113 |
{
|
hegyi@94
|
114 |
nml[i]=(nmsi->first);
|
hegyi@94
|
115 |
i++;
|
hegyi@94
|
116 |
}
|
hegyi@94
|
117 |
return nml;
|
hegyi@94
|
118 |
}
|
hegyi@94
|
119 |
|
hegyi@94
|
120 |
MapStorage::Signal_Prop MapStorage::signal_prop_ch()
|
hegyi@94
|
121 |
{
|
hegyi@94
|
122 |
return signal_prop;
|
hegyi@94
|
123 |
}
|
hegyi@94
|
124 |
|
hegyi@118
|
125 |
int MapStorage::addEdgeMap(const std::string & name, Graph::EdgeMap<double> *edgemap, double default_value)
|
ladanyi@6
|
126 |
{
|
hegyi@46
|
127 |
if( edgemap_storage.find(name) == edgemap_storage.end() )
|
hegyi@46
|
128 |
{
|
hegyi@46
|
129 |
edgemap_storage[name]=edgemap;
|
ladanyi@63
|
130 |
// set the maps default value
|
ladanyi@63
|
131 |
edgemap_default[name] = default_value;
|
hegyi@108
|
132 |
|
hegyi@108
|
133 |
//announce changement in maps
|
hegyi@108
|
134 |
signal_edge_map.emit(name);
|
hegyi@46
|
135 |
return 0;
|
hegyi@46
|
136 |
}
|
hegyi@46
|
137 |
return 1;
|
ladanyi@6
|
138 |
}
|
ladanyi@6
|
139 |
|
ladanyi@6
|
140 |
double MapStorage::maxOfNodeMap(const std::string & name)
|
ladanyi@6
|
141 |
{
|
ladanyi@6
|
142 |
double max=0;
|
ladanyi@53
|
143 |
for (NodeIt j(graph); j!=INVALID; ++j)
|
ladanyi@6
|
144 |
{
|
ladanyi@6
|
145 |
if( (*nodemap_storage[name])[j]>max )
|
ladanyi@6
|
146 |
{
|
ladanyi@6
|
147 |
max=(*nodemap_storage[name])[j];
|
ladanyi@6
|
148 |
}
|
ladanyi@6
|
149 |
}
|
ladanyi@6
|
150 |
return max;
|
ladanyi@6
|
151 |
}
|
ladanyi@6
|
152 |
|
ladanyi@6
|
153 |
double MapStorage::maxOfEdgeMap(const std::string & name)
|
ladanyi@6
|
154 |
{
|
ladanyi@6
|
155 |
double max=0;
|
ladanyi@53
|
156 |
for (EdgeIt j(graph); j!=INVALID; ++j)
|
ladanyi@6
|
157 |
{
|
ladanyi@6
|
158 |
if( (*edgemap_storage[name])[j]>max )
|
ladanyi@6
|
159 |
{
|
ladanyi@6
|
160 |
max=(*edgemap_storage[name])[j];
|
ladanyi@6
|
161 |
}
|
ladanyi@6
|
162 |
}
|
ladanyi@6
|
163 |
return max;
|
ladanyi@6
|
164 |
}
|
ladanyi@6
|
165 |
|
ladanyi@6
|
166 |
double MapStorage::minOfNodeMap(const std::string & name)
|
ladanyi@6
|
167 |
{
|
ladanyi@53
|
168 |
NodeIt j(graph);
|
hegyi@58
|
169 |
double min;
|
hegyi@58
|
170 |
if(j!=INVALID)
|
hegyi@58
|
171 |
{
|
hegyi@58
|
172 |
min=(*nodemap_storage[name])[j];
|
hegyi@58
|
173 |
}
|
hegyi@58
|
174 |
else
|
hegyi@58
|
175 |
{
|
hegyi@58
|
176 |
min=0;
|
hegyi@58
|
177 |
}
|
ladanyi@6
|
178 |
for (; j!=INVALID; ++j)
|
ladanyi@6
|
179 |
{
|
ladanyi@6
|
180 |
if( (*nodemap_storage[name])[j]<min )
|
ladanyi@6
|
181 |
{
|
ladanyi@6
|
182 |
min=(*nodemap_storage[name])[j];
|
ladanyi@6
|
183 |
}
|
ladanyi@6
|
184 |
}
|
ladanyi@6
|
185 |
return min;
|
ladanyi@6
|
186 |
}
|
ladanyi@6
|
187 |
|
ladanyi@6
|
188 |
double MapStorage::minOfEdgeMap(const std::string & name)
|
ladanyi@6
|
189 |
{
|
ladanyi@53
|
190 |
EdgeIt j(graph);
|
hegyi@58
|
191 |
double min;
|
hegyi@58
|
192 |
if(j!=INVALID)
|
hegyi@58
|
193 |
{
|
hegyi@58
|
194 |
min=(*edgemap_storage[name])[j];
|
hegyi@58
|
195 |
}
|
hegyi@58
|
196 |
else
|
hegyi@58
|
197 |
{
|
hegyi@58
|
198 |
min=0;
|
hegyi@58
|
199 |
}
|
ladanyi@53
|
200 |
for (EdgeIt j(graph); j!=INVALID; ++j)
|
ladanyi@6
|
201 |
{
|
ladanyi@6
|
202 |
if( (*edgemap_storage[name])[j]<min )
|
ladanyi@6
|
203 |
{
|
ladanyi@6
|
204 |
min=(*edgemap_storage[name])[j];
|
ladanyi@6
|
205 |
}
|
ladanyi@6
|
206 |
}
|
ladanyi@6
|
207 |
return min;
|
ladanyi@6
|
208 |
}
|
ladanyi@6
|
209 |
|
ladanyi@63
|
210 |
int MapStorage::readFromFile(const std::string &filename)
|
ladanyi@53
|
211 |
{
|
ladanyi@53
|
212 |
bool read_x = false;
|
ladanyi@53
|
213 |
bool read_y = false;
|
ladanyi@64
|
214 |
bool read_edge_id = false;
|
ladanyi@53
|
215 |
|
ladanyi@53
|
216 |
try {
|
ladanyi@53
|
217 |
LemonReader lreader(filename);
|
ladanyi@53
|
218 |
ContentReader content(lreader);
|
ladanyi@53
|
219 |
lreader.run();
|
ladanyi@53
|
220 |
|
ladanyi@101
|
221 |
if (content.nodeSetNum() < 1)
|
ladanyi@101
|
222 |
{
|
ladanyi@101
|
223 |
Gtk::MessageDialog mdialog("No nodeset found in file.");
|
ladanyi@101
|
224 |
mdialog.run();
|
ladanyi@101
|
225 |
clear();
|
ladanyi@101
|
226 |
return 1;
|
ladanyi@101
|
227 |
}
|
ladanyi@101
|
228 |
|
ladanyi@101
|
229 |
if (content.edgeSetNum() < 1)
|
ladanyi@101
|
230 |
{
|
ladanyi@101
|
231 |
Gtk::MessageDialog mdialog("No edgeset found in file.");
|
ladanyi@101
|
232 |
mdialog.run();
|
ladanyi@101
|
233 |
clear();
|
ladanyi@101
|
234 |
return 1;
|
ladanyi@101
|
235 |
}
|
ladanyi@101
|
236 |
|
ladanyi@53
|
237 |
const std::vector<std::string>& nodeMapNames = content.nodeSetMaps(0);
|
ladanyi@53
|
238 |
const std::vector<std::string>& edgeMapNames = content.edgeSetMaps(0);
|
ladanyi@53
|
239 |
|
ladanyi@53
|
240 |
GraphReader<Graph> greader(filename, graph);
|
ladanyi@53
|
241 |
for (std::vector<std::string>::const_iterator it = nodeMapNames.begin();
|
ladanyi@53
|
242 |
it != nodeMapNames.end(); ++it)
|
ladanyi@53
|
243 |
{
|
ladanyi@53
|
244 |
if (*it == "coordinates_x")
|
ladanyi@53
|
245 |
{
|
ladanyi@53
|
246 |
read_x = true;
|
ladanyi@53
|
247 |
//std::cout << "read X nodemap" << std::endl;
|
ladanyi@53
|
248 |
}
|
ladanyi@53
|
249 |
else if (*it == "coordinates_y")
|
ladanyi@53
|
250 |
{
|
ladanyi@53
|
251 |
read_y = true;
|
ladanyi@53
|
252 |
//std::cout << "read Y nodemap" << std::endl;
|
ladanyi@53
|
253 |
}
|
ladanyi@134
|
254 |
else if (*it == "label")
|
ladanyi@53
|
255 |
{
|
ladanyi@53
|
256 |
//std::cout << "read id nodemap" << std::endl;
|
ladanyi@53
|
257 |
}
|
ladanyi@53
|
258 |
else
|
ladanyi@53
|
259 |
{
|
ladanyi@53
|
260 |
nodemap_storage[*it] = new Graph::NodeMap<double>(graph);
|
ladanyi@53
|
261 |
//std::cout << "read " << *it << " nodemap" << std::endl;
|
ladanyi@53
|
262 |
}
|
ladanyi@53
|
263 |
greader.readNodeMap(*it, *nodemap_storage[*it]);
|
ladanyi@53
|
264 |
}
|
ladanyi@53
|
265 |
for (std::vector<std::string>::const_iterator it = edgeMapNames.begin();
|
ladanyi@53
|
266 |
it != edgeMapNames.end(); ++it)
|
ladanyi@53
|
267 |
{
|
ladanyi@134
|
268 |
if (*it == "label")
|
ladanyi@53
|
269 |
{
|
ladanyi@53
|
270 |
//std::cout << "read id edgemap" << std::endl;
|
ladanyi@135
|
271 |
read_edge_id = true;
|
ladanyi@53
|
272 |
}
|
ladanyi@53
|
273 |
else
|
ladanyi@53
|
274 |
{
|
ladanyi@53
|
275 |
edgemap_storage[*it] = new Graph::EdgeMap<double>(graph);
|
ladanyi@53
|
276 |
//std::cout << "read " << *it << " edgemap" << std::endl;
|
ladanyi@53
|
277 |
}
|
ladanyi@53
|
278 |
greader.readEdgeMap(*it, *edgemap_storage[*it]);
|
ladanyi@53
|
279 |
}
|
ladanyi@98
|
280 |
GuiReader gui_reader(greader, this);
|
ladanyi@53
|
281 |
greader.run();
|
ladanyi@101
|
282 |
} catch (Exception& error) {
|
ladanyi@79
|
283 |
Gtk::MessageDialog mdialog(error.what());
|
ladanyi@53
|
284 |
mdialog.run();
|
ladanyi@63
|
285 |
clear();
|
ladanyi@63
|
286 |
return 1;
|
ladanyi@53
|
287 |
}
|
ladanyi@53
|
288 |
|
ladanyi@64
|
289 |
if (!read_edge_id)
|
ladanyi@64
|
290 |
{
|
ladanyi@134
|
291 |
edgemap_storage["label"] = new Graph::EdgeMap<double>(graph);
|
ladanyi@64
|
292 |
int i = 1;
|
ladanyi@64
|
293 |
for (EdgeIt e(graph); e != INVALID; ++e)
|
ladanyi@64
|
294 |
{
|
ladanyi@134
|
295 |
(*edgemap_storage["label"])[e] = i++;
|
ladanyi@64
|
296 |
}
|
ladanyi@64
|
297 |
}
|
ladanyi@64
|
298 |
|
ladanyi@53
|
299 |
if (!read_x || !read_y)
|
ladanyi@53
|
300 |
{
|
ladanyi@53
|
301 |
int node_num = 0;
|
ladanyi@53
|
302 |
for (NodeIt n(graph); n != INVALID; ++n)
|
ladanyi@53
|
303 |
{
|
ladanyi@53
|
304 |
node_num++;
|
ladanyi@53
|
305 |
}
|
ladanyi@53
|
306 |
const double pi = 3.142;
|
ladanyi@53
|
307 |
double step = 2 * pi / (double) node_num;
|
ladanyi@53
|
308 |
int i = 0;
|
ladanyi@53
|
309 |
for (NodeIt n(graph); n != INVALID; ++n)
|
ladanyi@53
|
310 |
{
|
deba@77
|
311 |
nodemap_storage["coordinates_x"]->set(n, 250.0 * std::cos(i * step));
|
deba@77
|
312 |
nodemap_storage["coordinates_y"]->set(n, 250.0 * std::sin(i * step));
|
ladanyi@53
|
313 |
i++;
|
ladanyi@53
|
314 |
}
|
ladanyi@53
|
315 |
}
|
ladanyi@63
|
316 |
|
ladanyi@98
|
317 |
if (!arrow_pos_read_ok)
|
ladanyi@98
|
318 |
{
|
ladanyi@98
|
319 |
arrow_pos_read_ok = false;
|
ladanyi@98
|
320 |
for (EdgeIt e(graph); e != INVALID; ++e)
|
ladanyi@98
|
321 |
{
|
ladanyi@98
|
322 |
arrow_pos.set(e, (coords[graph.source(e)] + coords[graph.target(e)]) / 2.0);
|
ladanyi@98
|
323 |
}
|
ladanyi@98
|
324 |
}
|
ladanyi@98
|
325 |
|
ladanyi@63
|
326 |
// fill in the default values for the maps
|
ladanyi@63
|
327 |
for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it =
|
ladanyi@63
|
328 |
nodemap_storage.begin(); it != nodemap_storage.end(); ++it)
|
ladanyi@63
|
329 |
{
|
ladanyi@134
|
330 |
if ((it->first != "label") &&
|
ladanyi@63
|
331 |
(it->first != "coordiantes_x") &&
|
ladanyi@63
|
332 |
(it->first != "coordinates_y"))
|
ladanyi@63
|
333 |
{
|
ladanyi@63
|
334 |
nodemap_default[it->first] = 0.0;
|
ladanyi@63
|
335 |
}
|
ladanyi@134
|
336 |
else if (it->first == "label")
|
ladanyi@64
|
337 |
{
|
ladanyi@64
|
338 |
NodeIt n(graph);
|
ladanyi@134
|
339 |
double max = (*nodemap_storage["label"])[n];
|
ladanyi@64
|
340 |
for (; n != INVALID; ++n)
|
ladanyi@64
|
341 |
{
|
ladanyi@134
|
342 |
if ((*nodemap_storage["label"])[n] > max)
|
ladanyi@134
|
343 |
max = (*nodemap_storage["label"])[n];
|
ladanyi@64
|
344 |
}
|
ladanyi@134
|
345 |
nodemap_default["label"] = max + 1.0;
|
ladanyi@64
|
346 |
}
|
ladanyi@63
|
347 |
}
|
ladanyi@63
|
348 |
for (std::map<std::string, Graph::EdgeMap<double>*>::const_iterator it =
|
ladanyi@63
|
349 |
edgemap_storage.begin(); it != edgemap_storage.end(); ++it)
|
ladanyi@63
|
350 |
{
|
ladanyi@134
|
351 |
if (it->first != "label")
|
ladanyi@63
|
352 |
{
|
ladanyi@63
|
353 |
edgemap_default[it->first] = 0.0;
|
ladanyi@63
|
354 |
}
|
ladanyi@64
|
355 |
else
|
ladanyi@64
|
356 |
{
|
ladanyi@67
|
357 |
double max = std::numeric_limits<double>::min();
|
ladanyi@67
|
358 |
for (EdgeIt e(graph); e != INVALID; ++e)
|
ladanyi@64
|
359 |
{
|
ladanyi@134
|
360 |
if ((*edgemap_storage["label"])[e] > max)
|
ladanyi@134
|
361 |
max = (*edgemap_storage["label"])[e];
|
ladanyi@64
|
362 |
}
|
ladanyi@67
|
363 |
if (max > std::numeric_limits<double>::min())
|
ladanyi@134
|
364 |
edgemap_default["label"] = max + 1.0;
|
ladanyi@67
|
365 |
else
|
ladanyi@134
|
366 |
edgemap_default["label"] = 1.0;
|
ladanyi@64
|
367 |
}
|
ladanyi@63
|
368 |
}
|
ladanyi@63
|
369 |
|
ladanyi@135
|
370 |
// filter loop edges
|
ladanyi@135
|
371 |
for (EdgeIt e(graph); e != INVALID; ++e)
|
ladanyi@135
|
372 |
{
|
ladanyi@135
|
373 |
if (graph.source(e) == graph.target(e))
|
ladanyi@135
|
374 |
{
|
ladanyi@135
|
375 |
std::cerr << "Removed loop edge " << (*edgemap_storage["label"])[e]
|
ladanyi@135
|
376 |
<< " (from " << (*nodemap_storage["label"])[graph.source(e)]
|
ladanyi@135
|
377 |
<< ", to " << (*nodemap_storage["label"])[graph.target(e)] << ")."
|
ladanyi@135
|
378 |
<< std::endl;
|
ladanyi@135
|
379 |
|
ladanyi@135
|
380 |
graph.erase(e);
|
ladanyi@135
|
381 |
}
|
ladanyi@135
|
382 |
}
|
ladanyi@135
|
383 |
|
ladanyi@63
|
384 |
return 0;
|
ladanyi@53
|
385 |
}
|
ladanyi@53
|
386 |
|
ladanyi@53
|
387 |
void MapStorage::writeToFile(const std::string &filename)
|
ladanyi@53
|
388 |
{
|
ladanyi@53
|
389 |
GraphWriter<Graph> gwriter(filename, graph);
|
ladanyi@53
|
390 |
|
ladanyi@53
|
391 |
for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it =
|
ladanyi@53
|
392 |
nodemap_storage.begin(); it != nodemap_storage.end(); ++it)
|
ladanyi@53
|
393 |
{
|
ladanyi@53
|
394 |
gwriter.writeNodeMap(it->first, *(it->second));
|
ladanyi@53
|
395 |
}
|
ladanyi@53
|
396 |
for (std::map<std::string, Graph::EdgeMap<double>*>::const_iterator it =
|
ladanyi@53
|
397 |
edgemap_storage.begin(); it != edgemap_storage.end(); ++it)
|
ladanyi@53
|
398 |
{
|
ladanyi@98
|
399 |
if ((it->first != "arrow_pos_x") &&
|
ladanyi@98
|
400 |
(it->first != "arrow_pos_y"))
|
ladanyi@98
|
401 |
{
|
ladanyi@98
|
402 |
gwriter.writeEdgeMap(it->first, *(it->second));
|
ladanyi@98
|
403 |
}
|
ladanyi@53
|
404 |
}
|
ladanyi@98
|
405 |
|
ladanyi@98
|
406 |
GuiWriter gui_writer(gwriter, this);
|
ladanyi@98
|
407 |
|
ladanyi@53
|
408 |
gwriter.run();
|
ladanyi@53
|
409 |
}
|
ladanyi@53
|
410 |
|
ladanyi@53
|
411 |
void MapStorage::clear()
|
ladanyi@53
|
412 |
{
|
ladanyi@53
|
413 |
for (std::map<std::string, Graph::NodeMap<double>*>::iterator it =
|
ladanyi@53
|
414 |
nodemap_storage.begin(); it != nodemap_storage.end(); ++it)
|
ladanyi@53
|
415 |
{
|
ladanyi@53
|
416 |
if ((it->first != "coordinates_x") &&
|
ladanyi@53
|
417 |
(it->first != "coordinates_y") &&
|
ladanyi@134
|
418 |
(it->first != "label"))
|
ladanyi@53
|
419 |
{
|
ladanyi@53
|
420 |
delete it->second;
|
ladanyi@53
|
421 |
nodemap_storage.erase(it);
|
ladanyi@53
|
422 |
}
|
ladanyi@53
|
423 |
}
|
ladanyi@53
|
424 |
for (std::map<std::string, Graph::EdgeMap<double>*>::iterator it =
|
ladanyi@53
|
425 |
edgemap_storage.begin(); it != edgemap_storage.end(); ++it)
|
ladanyi@53
|
426 |
{
|
ladanyi@134
|
427 |
if ((it->first != "label") &&
|
ladanyi@98
|
428 |
(it->first != "arrow_pos_x") &&
|
ladanyi@98
|
429 |
(it->first != "arrow_pos_y"))
|
ladanyi@53
|
430 |
{
|
ladanyi@53
|
431 |
delete it->second;
|
ladanyi@53
|
432 |
edgemap_storage.erase(it);
|
ladanyi@53
|
433 |
}
|
ladanyi@53
|
434 |
}
|
ladanyi@63
|
435 |
for (std::map<std::string, double>::iterator it =
|
ladanyi@63
|
436 |
nodemap_default.begin(); it != nodemap_default.end(); ++it)
|
ladanyi@63
|
437 |
{
|
ladanyi@134
|
438 |
if (it->first != "label")
|
ladanyi@64
|
439 |
nodemap_default.erase(it);
|
ladanyi@63
|
440 |
}
|
ladanyi@63
|
441 |
for (std::map<std::string, double>::iterator it =
|
ladanyi@63
|
442 |
edgemap_default.begin(); it != edgemap_default.end(); ++it)
|
ladanyi@63
|
443 |
{
|
ladanyi@134
|
444 |
if (it->first != "label")
|
ladanyi@64
|
445 |
edgemap_default.erase(it);
|
ladanyi@63
|
446 |
}
|
ladanyi@53
|
447 |
graph.clear();
|
ladanyi@53
|
448 |
file_name = "";
|
ladanyi@53
|
449 |
modified = false;
|
ladanyi@53
|
450 |
}
|
ladanyi@98
|
451 |
|
ladanyi@98
|
452 |
void MapStorage::ArrowPosReadOK()
|
ladanyi@98
|
453 |
{
|
ladanyi@98
|
454 |
arrow_pos_read_ok = true;
|
ladanyi@98
|
455 |
}
|
hegyi@111
|
456 |
|
hegyi@111
|
457 |
void MapStorage::mapChanged(bool itisedge, std::string mapname)
|
hegyi@111
|
458 |
{
|
hegyi@111
|
459 |
if(itisedge)
|
hegyi@111
|
460 |
{
|
hegyi@111
|
461 |
for(int i=0;i<EDGE_PROPERTY_NUM;i++)
|
hegyi@111
|
462 |
{
|
hegyi@111
|
463 |
if(active_edgemaps[i]==mapname)
|
hegyi@111
|
464 |
{
|
hegyi@111
|
465 |
signal_prop.emit(itisedge, i);
|
hegyi@111
|
466 |
}
|
hegyi@111
|
467 |
}
|
hegyi@111
|
468 |
}
|
hegyi@111
|
469 |
else
|
hegyi@111
|
470 |
{
|
hegyi@111
|
471 |
for(int i=0;i<NODE_PROPERTY_NUM;i++)
|
hegyi@111
|
472 |
{
|
hegyi@111
|
473 |
if(active_nodemaps[i]==mapname)
|
hegyi@111
|
474 |
{
|
hegyi@111
|
475 |
signal_prop.emit(itisedge, i);
|
hegyi@111
|
476 |
}
|
hegyi@111
|
477 |
}
|
hegyi@111
|
478 |
}
|
hegyi@111
|
479 |
}
|