alpar@174
|
1 |
/* -*- C++ -*-
|
alpar@174
|
2 |
*
|
alpar@174
|
3 |
* This file is a part of LEMON, a generic C++ optimization library
|
alpar@174
|
4 |
*
|
alpar@174
|
5 |
* Copyright (C) 2003-2006
|
alpar@174
|
6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
alpar@174
|
7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES).
|
alpar@174
|
8 |
*
|
alpar@174
|
9 |
* Permission to use, modify and distribute this software is granted
|
alpar@174
|
10 |
* provided that this copyright notice appears in all copies. For
|
alpar@174
|
11 |
* precise terms see the accompanying LICENSE file.
|
alpar@174
|
12 |
*
|
alpar@174
|
13 |
* This software is provided "AS IS" with no warranty of any kind,
|
alpar@174
|
14 |
* express or implied, and with no claim as to its suitability for any
|
alpar@174
|
15 |
* purpose.
|
alpar@174
|
16 |
*
|
alpar@174
|
17 |
*/
|
alpar@174
|
18 |
|
ladanyi@98
|
19 |
#include "gui_reader.h"
|
ladanyi@98
|
20 |
#include "xml.h"
|
ladanyi@98
|
21 |
#include "mapstorage.h"
|
hegyi@150
|
22 |
#include <lemon/dim2.h>
|
ladanyi@98
|
23 |
#include <vector>
|
ladanyi@98
|
24 |
|
ladanyi@98
|
25 |
bool GuiReader::header(const std::string& line)
|
ladanyi@98
|
26 |
{
|
ladanyi@98
|
27 |
std::istringstream ls(line);
|
ladanyi@98
|
28 |
std::string head;
|
ladanyi@98
|
29 |
ls >> head;
|
ladanyi@98
|
30 |
return head == "@gui";
|
ladanyi@98
|
31 |
}
|
ladanyi@98
|
32 |
|
ladanyi@98
|
33 |
void GuiReader::read(std::istream& is)
|
ladanyi@98
|
34 |
{
|
ladanyi@98
|
35 |
XmlIo x(is);
|
hegyi@150
|
36 |
std::map<int, XY > m;
|
ladanyi@98
|
37 |
x("arrow_pos", m);
|
ladanyi@98
|
38 |
|
hegyi@176
|
39 |
if ((int)m.size() == countEdges(mapstorage->graph))
|
hegyi@176
|
40 |
{
|
hegyi@176
|
41 |
for (EdgeIt e(mapstorage->graph); e != INVALID; ++e)
|
hegyi@176
|
42 |
{
|
hegyi@176
|
43 |
int edgeid = (int)(*mapstorage->edgemap_storage["label"])[e];
|
hegyi@176
|
44 |
mapstorage->arrow_pos.set(e, m[edgeid]);
|
hegyi@176
|
45 |
}
|
hegyi@176
|
46 |
mapstorage->ArrowPosReadOK();
|
hegyi@176
|
47 |
}
|
hegyi@176
|
48 |
|
hegyi@172
|
49 |
std::map<int, std::string> nm;
|
hegyi@172
|
50 |
x("active_nodemaps", nm);
|
hegyi@172
|
51 |
|
hegyi@172
|
52 |
for(int i=0;i<NODE_PROPERTY_NUM;i++)
|
hegyi@172
|
53 |
{
|
hegyi@172
|
54 |
mapstorage->changeActiveMap(false, i, nm[i]);
|
hegyi@172
|
55 |
}
|
hegyi@172
|
56 |
|
hegyi@172
|
57 |
std::map<int, std::string> em;
|
hegyi@172
|
58 |
x("active_edgemaps", em);
|
hegyi@172
|
59 |
for(int i=0;i<EDGE_PROPERTY_NUM;i++)
|
hegyi@172
|
60 |
{
|
hegyi@172
|
61 |
mapstorage->changeActiveMap(true, i, em[i]);
|
hegyi@172
|
62 |
}
|
hegyi@177
|
63 |
|
hegyi@177
|
64 |
double attraction;
|
hegyi@177
|
65 |
double propulsation;
|
hegyi@177
|
66 |
int iteration;
|
hegyi@177
|
67 |
|
hegyi@177
|
68 |
x("redesign-attraction", attraction);
|
hegyi@177
|
69 |
x("redesign-propulsation", propulsation);
|
hegyi@177
|
70 |
x("redesign-iteration", iteration);
|
hegyi@177
|
71 |
|
hegyi@177
|
72 |
mapstorage->set_attraction(attraction);
|
hegyi@177
|
73 |
mapstorage->set_propulsation(propulsation);
|
hegyi@177
|
74 |
mapstorage->set_iteration(iteration);
|
hegyi@177
|
75 |
|
hegyi@177
|
76 |
mapstorage->redesign_data_changed();
|
ladanyi@98
|
77 |
}
|
ladanyi@98
|
78 |
|
ladanyi@98
|
79 |
GuiReader::GuiReader(LemonReader& reader, MapStorage* ms) : Parent(reader), mapstorage(ms)
|
ladanyi@98
|
80 |
{
|
ladanyi@98
|
81 |
}
|