gui_reader.cc
author ladanyi
Wed, 02 May 2007 20:33:58 +0000
changeset 200 c7ae8642a8d8
parent 177 40f3006fba2e
child 201 879e47e5b731
permissions -rw-r--r--
Bugfix.
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
hegyi@194
    19
#include <gui_reader.h>
hegyi@194
    20
#include <mapstorage.h>
hegyi@194
    21
hegyi@194
    22
#include <xml.h>
hegyi@150
    23
#include <lemon/dim2.h>
ladanyi@98
    24
#include <vector>
ladanyi@98
    25
ladanyi@98
    26
bool GuiReader::header(const std::string& line)
ladanyi@98
    27
{
ladanyi@98
    28
  std::istringstream ls(line);
ladanyi@98
    29
  std::string head;
ladanyi@98
    30
  ls >> head;
ladanyi@98
    31
  return head == "@gui";
ladanyi@98
    32
}
ladanyi@98
    33
ladanyi@98
    34
void GuiReader::read(std::istream& is)
ladanyi@98
    35
{
ladanyi@98
    36
  XmlIo x(is);
hegyi@150
    37
  std::map<int, XY > m;
ladanyi@98
    38
  x("arrow_pos", m);
ladanyi@98
    39
hegyi@176
    40
  if ((int)m.size() == countEdges(mapstorage->graph))
hegyi@176
    41
    {
hegyi@176
    42
      for (EdgeIt e(mapstorage->graph); e != INVALID; ++e)
hegyi@176
    43
	{
hegyi@176
    44
	  int edgeid = (int)(*mapstorage->edgemap_storage["label"])[e];
hegyi@176
    45
	  mapstorage->arrow_pos.set(e, m[edgeid]);
hegyi@176
    46
	}
hegyi@176
    47
      mapstorage->ArrowPosReadOK();
hegyi@176
    48
    }
hegyi@176
    49
  
hegyi@172
    50
  std::map<int, std::string> nm;
hegyi@172
    51
  x("active_nodemaps", nm);
hegyi@172
    52
hegyi@172
    53
  for(int i=0;i<NODE_PROPERTY_NUM;i++)
hegyi@172
    54
    {
hegyi@172
    55
      mapstorage->changeActiveMap(false, i, nm[i]);
hegyi@172
    56
    }
hegyi@172
    57
hegyi@172
    58
  std::map<int, std::string> em;
hegyi@172
    59
  x("active_edgemaps", em);
hegyi@172
    60
  for(int i=0;i<EDGE_PROPERTY_NUM;i++)
hegyi@172
    61
    {
hegyi@172
    62
      mapstorage->changeActiveMap(true, i, em[i]);
hegyi@172
    63
    }
hegyi@177
    64
hegyi@177
    65
  double attraction;
hegyi@177
    66
  double propulsation;
hegyi@177
    67
  int iteration;
hegyi@177
    68
hegyi@177
    69
  x("redesign-attraction", attraction);
hegyi@177
    70
  x("redesign-propulsation", propulsation);
hegyi@177
    71
  x("redesign-iteration", iteration);
hegyi@177
    72
hegyi@177
    73
  mapstorage->set_attraction(attraction);
hegyi@177
    74
  mapstorage->set_propulsation(propulsation);
hegyi@177
    75
  mapstorage->set_iteration(iteration);
hegyi@177
    76
hegyi@177
    77
  mapstorage->redesign_data_changed();
ladanyi@98
    78
}
ladanyi@98
    79
ladanyi@98
    80
GuiReader::GuiReader(LemonReader& reader, MapStorage* ms) : Parent(reader), mapstorage(ms)
ladanyi@98
    81
{
ladanyi@98
    82
}