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