3 * This file is a part of LEMON, a generic C++ optimization library
5 * Copyright (C) 2003-2006
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
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.
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
19 #include <gui_reader.h>
20 #include <mapstorage.h>
23 #include "io_helper.h"
24 #include <lemon/dim2.h>
27 // bool GuiReader::header(const std::string& line)
29 // std::istringstream ls(line);
32 // return head == "@gui";
35 //void GuiReader::read(std::istream& is)
36 void GuiReader::operator()(std::istream& is, int& ln)
47 { x("main_node_map_names", gui_data.main_node_map_names); }
48 { x("gui_node_map_names", gui_data.gui_node_map_names); }
50 { x("node_map_types", gui_data.node_map_types); }
52 { x("main_arc_map_names", gui_data.main_arc_map_names); }
53 { x("gui_arc_map_names", gui_data.gui_arc_map_names); }
55 { x("arc_map_types", gui_data.arc_map_types); }
57 for (vector<string>::const_iterator it = gui_data.gui_node_map_names.begin();
58 it != gui_data.gui_node_map_names.end(); ++it)
60 MapValue::Type type = gui_data.node_map_types[*it];
63 case MapValue::NUMERIC:
65 map<int, double>* p_map_data =
67 gui_data.numeric_node_maps[*it] = p_map_data;
68 { x(*it, *p_map_data); }
71 case MapValue::STRING:
73 map<int, string>* p_map_data =
75 gui_data.string_node_maps[*it] = p_map_data;
76 { x(*it, *p_map_data); }
82 for (vector<string>::const_iterator it = gui_data.gui_arc_map_names.begin();
83 it != gui_data.gui_arc_map_names.end(); ++it)
85 MapValue::Type type = gui_data.arc_map_types[*it];
88 case MapValue::NUMERIC:
90 map<int, double>* p_map_data =
92 gui_data.numeric_arc_maps[*it] = p_map_data;
93 { x(*it, *p_map_data); }
96 case MapValue::STRING:
98 map<int, string>* p_map_data =
100 gui_data.string_arc_maps[*it] = p_map_data;
101 { x(*it, *p_map_data); }
108 std::string node_coords_save_dest;
109 { x("node_coords_save_dest", node_coords_save_dest); }
110 if (node_coords_save_dest == "gui_sect")
112 // read the node coorinates
113 gui_data.node_coords_save_dest = MapStorage::SpecMapSaveOpts::GUI_SECT;
114 { x("node_coord_map", gui_data.node_coord_map); }
116 else if (node_coords_save_dest == "nodeset_sect_1_map")
118 gui_data.node_coords_save_dest = MapStorage::SpecMapSaveOpts::NESET_SECT;
119 gui_data.node_coords_save_map_num = MapStorage::SpecMapSaveOpts::ONE_MAP;
120 { x("map_name", gui_data.node_coords_one_map_name); }
122 else if (node_coords_save_dest == "nodeset_sect_2_maps")
124 gui_data.node_coords_save_dest = MapStorage::SpecMapSaveOpts::NESET_SECT;
125 gui_data.node_coords_save_map_num = MapStorage::SpecMapSaveOpts::TWO_MAPS;
126 { x("map1_name", gui_data.node_coords_two_maps_1_name); }
127 { x("map2_name", gui_data.node_coords_two_maps_2_name); }
132 std::string arrow_coords_save_dest;
133 { x("arrow_coords_save_dest", arrow_coords_save_dest); }
134 if (arrow_coords_save_dest == "gui_sect")
136 // read the arrow coorinates
137 gui_data.arrow_coords_save_dest = MapStorage::SpecMapSaveOpts::GUI_SECT;
138 { x("arrow_coord_map", gui_data.arrow_coord_map); }
140 else if (arrow_coords_save_dest == "arcset_sect_1_map")
142 gui_data.arrow_coords_save_dest = MapStorage::SpecMapSaveOpts::NESET_SECT;
143 gui_data.arrow_coords_save_map_num = MapStorage::SpecMapSaveOpts::ONE_MAP;
144 { x("map_name", gui_data.arrow_coords_one_map_name); }
146 else if (arrow_coords_save_dest == "arcset_sect_2_maps")
148 gui_data.arrow_coords_save_dest = MapStorage::SpecMapSaveOpts::NESET_SECT;
149 gui_data.arrow_coords_save_map_num = MapStorage::SpecMapSaveOpts::TWO_MAPS;
150 { x("map1_name", gui_data.arrow_coords_two_maps_1_name); }
151 { x("map2_name", gui_data.arrow_coords_two_maps_2_name); }
157 std::map<int, std::string> nm;
158 x("active_nodemaps", nm);
160 for(int i=0;i<NODE_PROPERTY_NUM;i++)
162 mapstorage->changeActiveMap(false, i, nm[i]);
165 std::map<int, std::string> em;
166 x("active_arcmaps", em);
167 for(int i=0;i<EDGE_PROPERTY_NUM;i++)
169 mapstorage->changeActiveMap(true, i, em[i]);
176 x("redesign-attraction", attraction);
177 x("redesign-propulsation", propulsation);
178 x("redesign-iteration", iteration);
180 mapstorage->set_attraction(attraction);
181 mapstorage->set_propulsation(propulsation);
182 mapstorage->set_iteration(iteration);
184 mapstorage->redesign_data_changed();
187 //GuiReader::GuiReader(LemonReader& reader, MapStorage* _mapstorage,
188 GuiReader::GuiReader(MapStorage* _mapstorage,
189 MapStorage::GUISectData& _gui_data) :
191 mapstorage(_mapstorage),