hegyi@1: /* -*- C++ -*- hegyi@1: * hegyi@1: * This file is a part of LEMON, a generic C++ optimization library hegyi@1: * hegyi@1: * Copyright (C) 2003-2006 hegyi@1: * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport hegyi@1: * (Egervary Research Group on Combinatorial Optimization, EGRES). hegyi@1: * hegyi@1: * Permission to use, modify and distribute this software is granted hegyi@1: * provided that this copyright notice appears in all copies. For hegyi@1: * precise terms see the accompanying LICENSE file. hegyi@1: * hegyi@1: * This software is provided "AS IS" with no warranty of any kind, hegyi@1: * express or implied, and with no claim as to its suitability for any hegyi@1: * purpose. hegyi@1: * hegyi@1: */ hegyi@1: hegyi@1: #include hegyi@1: #include hegyi@1: hegyi@1: #include hegyi@1: #include "io_helper.h" hegyi@1: #include hegyi@1: #include hegyi@1: hegyi@1: // bool GuiReader::header(const std::string& line) hegyi@1: // { hegyi@1: // std::istringstream ls(line); hegyi@1: // std::string head; hegyi@1: // ls >> head; hegyi@1: // return head == "@gui"; hegyi@1: // } hegyi@1: hegyi@1: //void GuiReader::read(std::istream& is) hegyi@1: void GuiReader::operator()(std::istream& is, int& ln) hegyi@1: { hegyi@1: using std::vector; hegyi@1: using std::string; hegyi@1: using std::pair; hegyi@1: using std::make_pair; hegyi@1: using std::string; hegyi@1: using std::map; hegyi@1: hegyi@1: XmlIo x(is); hegyi@1: hegyi@1: { x("main_node_map_names", gui_data.main_node_map_names); } hegyi@1: { x("gui_node_map_names", gui_data.gui_node_map_names); } hegyi@1: hegyi@1: { x("node_map_types", gui_data.node_map_types); } hegyi@1: hegyi@1: { x("main_arc_map_names", gui_data.main_arc_map_names); } hegyi@1: { x("gui_arc_map_names", gui_data.gui_arc_map_names); } hegyi@1: hegyi@1: { x("arc_map_types", gui_data.arc_map_types); } hegyi@1: hegyi@1: for (vector::const_iterator it = gui_data.gui_node_map_names.begin(); hegyi@1: it != gui_data.gui_node_map_names.end(); ++it) hegyi@1: { hegyi@1: MapValue::Type type = gui_data.node_map_types[*it]; hegyi@1: switch (type) hegyi@1: { hegyi@1: case MapValue::NUMERIC: hegyi@1: { hegyi@1: map* p_map_data = hegyi@1: new map; hegyi@1: gui_data.numeric_node_maps[*it] = p_map_data; hegyi@1: { x(*it, *p_map_data); } hegyi@1: } hegyi@1: break; hegyi@1: case MapValue::STRING: hegyi@1: { hegyi@1: map* p_map_data = hegyi@1: new map; hegyi@1: gui_data.string_node_maps[*it] = p_map_data; hegyi@1: { x(*it, *p_map_data); } hegyi@1: } hegyi@1: break; hegyi@1: } hegyi@1: } hegyi@1: hegyi@1: for (vector::const_iterator it = gui_data.gui_arc_map_names.begin(); hegyi@1: it != gui_data.gui_arc_map_names.end(); ++it) hegyi@1: { hegyi@1: MapValue::Type type = gui_data.arc_map_types[*it]; hegyi@1: switch (type) hegyi@1: { hegyi@1: case MapValue::NUMERIC: hegyi@1: { hegyi@1: map* p_map_data = hegyi@1: new map; hegyi@1: gui_data.numeric_arc_maps[*it] = p_map_data; hegyi@1: { x(*it, *p_map_data); } hegyi@1: } hegyi@1: break; hegyi@1: case MapValue::STRING: hegyi@1: { hegyi@1: map* p_map_data = hegyi@1: new map; hegyi@1: gui_data.string_arc_maps[*it] = p_map_data; hegyi@1: { x(*it, *p_map_data); } hegyi@1: } hegyi@1: break; hegyi@1: } hegyi@1: } hegyi@1: hegyi@1: { hegyi@1: std::string node_coords_save_dest; hegyi@1: { x("node_coords_save_dest", node_coords_save_dest); } hegyi@1: if (node_coords_save_dest == "gui_sect") hegyi@1: { hegyi@1: // read the node coorinates hegyi@1: gui_data.node_coords_save_dest = MapStorage::SpecMapSaveOpts::GUI_SECT; hegyi@1: { x("node_coord_map", gui_data.node_coord_map); } hegyi@1: } hegyi@1: else if (node_coords_save_dest == "nodeset_sect_1_map") hegyi@1: { hegyi@1: gui_data.node_coords_save_dest = MapStorage::SpecMapSaveOpts::NESET_SECT; hegyi@1: gui_data.node_coords_save_map_num = MapStorage::SpecMapSaveOpts::ONE_MAP; hegyi@1: { x("map_name", gui_data.node_coords_one_map_name); } hegyi@1: } hegyi@1: else if (node_coords_save_dest == "nodeset_sect_2_maps") hegyi@1: { hegyi@1: gui_data.node_coords_save_dest = MapStorage::SpecMapSaveOpts::NESET_SECT; hegyi@1: gui_data.node_coords_save_map_num = MapStorage::SpecMapSaveOpts::TWO_MAPS; hegyi@1: { x("map1_name", gui_data.node_coords_two_maps_1_name); } hegyi@1: { x("map2_name", gui_data.node_coords_two_maps_2_name); } hegyi@1: } hegyi@1: } hegyi@1: hegyi@1: { hegyi@1: std::string arrow_coords_save_dest; hegyi@1: { x("arrow_coords_save_dest", arrow_coords_save_dest); } hegyi@1: if (arrow_coords_save_dest == "gui_sect") hegyi@1: { hegyi@1: // read the arrow coorinates hegyi@1: gui_data.arrow_coords_save_dest = MapStorage::SpecMapSaveOpts::GUI_SECT; hegyi@1: { x("arrow_coord_map", gui_data.arrow_coord_map); } hegyi@1: } hegyi@1: else if (arrow_coords_save_dest == "arcset_sect_1_map") hegyi@1: { hegyi@1: gui_data.arrow_coords_save_dest = MapStorage::SpecMapSaveOpts::NESET_SECT; hegyi@1: gui_data.arrow_coords_save_map_num = MapStorage::SpecMapSaveOpts::ONE_MAP; hegyi@1: { x("map_name", gui_data.arrow_coords_one_map_name); } hegyi@1: } hegyi@1: else if (arrow_coords_save_dest == "arcset_sect_2_maps") hegyi@1: { hegyi@1: gui_data.arrow_coords_save_dest = MapStorage::SpecMapSaveOpts::NESET_SECT; hegyi@1: gui_data.arrow_coords_save_map_num = MapStorage::SpecMapSaveOpts::TWO_MAPS; hegyi@1: { x("map1_name", gui_data.arrow_coords_two_maps_1_name); } hegyi@1: { x("map2_name", gui_data.arrow_coords_two_maps_2_name); } hegyi@1: } hegyi@1: } hegyi@1: hegyi@1: hegyi@1: hegyi@1: std::map nm; hegyi@1: x("active_nodemaps", nm); hegyi@1: hegyi@1: for(int i=0;ichangeActiveMap(false, i, nm[i]); hegyi@1: } hegyi@1: hegyi@1: std::map em; hegyi@1: x("active_arcmaps", em); hegyi@1: for(int i=0;ichangeActiveMap(true, i, em[i]); hegyi@1: } hegyi@1: hegyi@1: double attraction; hegyi@1: double propulsation; hegyi@1: int iteration; hegyi@1: hegyi@1: x("redesign-attraction", attraction); hegyi@1: x("redesign-propulsation", propulsation); hegyi@1: x("redesign-iteration", iteration); hegyi@1: hegyi@1: mapstorage->set_attraction(attraction); hegyi@1: mapstorage->set_propulsation(propulsation); hegyi@1: mapstorage->set_iteration(iteration); hegyi@1: hegyi@1: mapstorage->redesign_data_changed(); hegyi@1: } hegyi@1: hegyi@1: //GuiReader::GuiReader(LemonReader& reader, MapStorage* _mapstorage, hegyi@1: GuiReader::GuiReader(MapStorage* _mapstorage, hegyi@1: MapStorage::GUISectData& _gui_data) : hegyi@1: //Parent(reader), hegyi@1: mapstorage(_mapstorage), hegyi@1: gui_data(_gui_data) hegyi@1: { hegyi@1: }