alpar@174: /* -*- C++ -*- alpar@174: * alpar@174: * This file is a part of LEMON, a generic C++ optimization library alpar@174: * alpar@174: * Copyright (C) 2003-2006 alpar@174: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport alpar@174: * (Egervary Research Group on Combinatorial Optimization, EGRES). alpar@174: * alpar@174: * Permission to use, modify and distribute this software is granted alpar@174: * provided that this copyright notice appears in all copies. For alpar@174: * precise terms see the accompanying LICENSE file. alpar@174: * alpar@174: * This software is provided "AS IS" with no warranty of any kind, alpar@174: * express or implied, and with no claim as to its suitability for any alpar@174: * purpose. alpar@174: * alpar@174: */ alpar@174: ladanyi@98: #include "gui_reader.h" ladanyi@98: #include "xml.h" ladanyi@98: #include "mapstorage.h" hegyi@150: #include ladanyi@98: #include ladanyi@98: ladanyi@98: bool GuiReader::header(const std::string& line) ladanyi@98: { ladanyi@98: std::istringstream ls(line); ladanyi@98: std::string head; ladanyi@98: ls >> head; ladanyi@98: return head == "@gui"; ladanyi@98: } ladanyi@98: ladanyi@98: void GuiReader::read(std::istream& is) ladanyi@98: { ladanyi@98: XmlIo x(is); hegyi@150: std::map m; ladanyi@98: x("arrow_pos", m); ladanyi@98: hegyi@176: if ((int)m.size() == countEdges(mapstorage->graph)) hegyi@176: { hegyi@176: for (EdgeIt e(mapstorage->graph); e != INVALID; ++e) hegyi@176: { hegyi@176: int edgeid = (int)(*mapstorage->edgemap_storage["label"])[e]; hegyi@176: mapstorage->arrow_pos.set(e, m[edgeid]); hegyi@176: } hegyi@176: mapstorage->ArrowPosReadOK(); hegyi@176: } hegyi@176: hegyi@172: std::map nm; hegyi@172: x("active_nodemaps", nm); hegyi@172: hegyi@172: for(int i=0;ichangeActiveMap(false, i, nm[i]); hegyi@172: } hegyi@172: hegyi@172: std::map em; hegyi@172: x("active_edgemaps", em); hegyi@172: for(int i=0;ichangeActiveMap(true, i, em[i]); hegyi@172: } hegyi@177: hegyi@177: double attraction; hegyi@177: double propulsation; hegyi@177: int iteration; hegyi@177: hegyi@177: x("redesign-attraction", attraction); hegyi@177: x("redesign-propulsation", propulsation); hegyi@177: x("redesign-iteration", iteration); hegyi@177: hegyi@177: mapstorage->set_attraction(attraction); hegyi@177: mapstorage->set_propulsation(propulsation); hegyi@177: mapstorage->set_iteration(iteration); hegyi@177: hegyi@177: mapstorage->redesign_data_changed(); ladanyi@98: } ladanyi@98: ladanyi@98: GuiReader::GuiReader(LemonReader& reader, MapStorage* ms) : Parent(reader), mapstorage(ms) ladanyi@98: { ladanyi@98: }