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