COIN-OR::LEMON - Graph Library

source: glemon-0.x/gui_reader.cc @ 172:fc1e478697d3

Last change on this file since 172:fc1e478697d3 was 172:fc1e478697d3, checked in by Hegyi Péter, 17 years ago

Currently visualized map can be saved and loaded from file.

File size: 1.0 KB
Line 
1#include "gui_reader.h"
2#include "xml.h"
3#include "mapstorage.h"
4#include <lemon/dim2.h>
5#include <vector>
6
7bool GuiReader::header(const std::string& line)
8{
9  std::istringstream ls(line);
10  std::string head;
11  ls >> head;
12  return head == "@gui";
13}
14
15void GuiReader::read(std::istream& is)
16{
17  XmlIo x(is);
18  std::map<int, XY > m;
19  x("arrow_pos", m);
20
21  if ((int)m.size() != countEdges(mapstorage->graph)) return;
22
23  for (EdgeIt e(mapstorage->graph); e != INVALID; ++e)
24  {
25    int edgeid = (int)(*mapstorage->edgemap_storage["label"])[e];
26    mapstorage->arrow_pos.set(e, m[edgeid]);
27  }
28  mapstorage->ArrowPosReadOK();
29
30  std::map<int, std::string> nm;
31  x("active_nodemaps", nm);
32
33  for(int i=0;i<NODE_PROPERTY_NUM;i++)
34    {
35      mapstorage->changeActiveMap(false, i, nm[i]);
36    }
37
38  std::map<int, std::string> em;
39  x("active_edgemaps", em);
40  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
41    {
42      mapstorage->changeActiveMap(true, i, em[i]);
43    }
44}
45
46GuiReader::GuiReader(LemonReader& reader, MapStorage* ms) : Parent(reader), mapstorage(ms)
47{
48}
Note: See TracBrowser for help on using the repository browser.