COIN-OR::LEMON - Graph Library

source: glemon-0.x/gui_reader.cc @ 195:125c56c1efda

Last change on this file since 195:125c56c1efda was 194:6b2b718420eb, checked in by Hegyi Péter, 17 years ago

Header reorganising

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