Merge branches/akos to trunk.
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)
46 { x("main_node_map_names", gui_data.main_node_map_names); }
47 { x("gui_node_map_names", gui_data.gui_node_map_names); }
49 { x("node_map_types", gui_data.node_map_types); }
51 { x("main_edge_map_names", gui_data.main_edge_map_names); }
52 { x("gui_edge_map_names", gui_data.gui_edge_map_names); }
54 { x("edge_map_types", gui_data.edge_map_types); }
56 for (vector<string>::const_iterator it = gui_data.gui_node_map_names.begin();
57 it != gui_data.gui_node_map_names.end(); ++it)
59 MapValue::Type type = gui_data.node_map_types[*it];
62 case MapValue::NUMERIC:
64 map<int, double>* p_map_data =
66 gui_data.numeric_node_maps[*it] = p_map_data;
67 { x(*it, *p_map_data); }
70 case MapValue::STRING:
72 map<int, string>* p_map_data =
74 gui_data.string_node_maps[*it] = p_map_data;
75 { x(*it, *p_map_data); }
81 for (vector<string>::const_iterator it = gui_data.gui_edge_map_names.begin();
82 it != gui_data.gui_edge_map_names.end(); ++it)
84 MapValue::Type type = gui_data.edge_map_types[*it];
87 case MapValue::NUMERIC:
89 map<int, double>* p_map_data =
91 gui_data.numeric_edge_maps[*it] = p_map_data;
92 { x(*it, *p_map_data); }
95 case MapValue::STRING:
97 map<int, string>* p_map_data =
99 gui_data.string_edge_maps[*it] = p_map_data;
100 { x(*it, *p_map_data); }
107 std::string node_coords_save_dest;
108 { x("node_coords_save_dest", node_coords_save_dest); }
109 if (node_coords_save_dest == "gui_sect")
111 // read the node coorinates
112 gui_data.node_coords_save_dest = MapStorage::SpecMapSaveOpts::GUI_SECT;
113 { x("node_coord_map", gui_data.node_coord_map); }
115 else if (node_coords_save_dest == "nodeset_sect_1_map")
117 gui_data.node_coords_save_dest = MapStorage::SpecMapSaveOpts::NESET_SECT;
118 gui_data.node_coords_save_map_num = MapStorage::SpecMapSaveOpts::ONE_MAP;
119 { x("map_name", gui_data.node_coords_one_map_name); }
121 else if (node_coords_save_dest == "nodeset_sect_2_maps")
123 gui_data.node_coords_save_dest = MapStorage::SpecMapSaveOpts::NESET_SECT;
124 gui_data.node_coords_save_map_num = MapStorage::SpecMapSaveOpts::TWO_MAPS;
125 { x("map1_name", gui_data.node_coords_two_maps_1_name); }
126 { x("map2_name", gui_data.node_coords_two_maps_2_name); }
131 std::string arrow_coords_save_dest;
132 { x("arrow_coords_save_dest", arrow_coords_save_dest); }
133 if (arrow_coords_save_dest == "gui_sect")
135 // read the arrow coorinates
136 gui_data.arrow_coords_save_dest = MapStorage::SpecMapSaveOpts::GUI_SECT;
137 { x("arrow_coord_map", gui_data.arrow_coord_map); }
139 else if (arrow_coords_save_dest == "edgeset_sect_1_map")
141 gui_data.arrow_coords_save_dest = MapStorage::SpecMapSaveOpts::NESET_SECT;
142 gui_data.arrow_coords_save_map_num = MapStorage::SpecMapSaveOpts::ONE_MAP;
143 { x("map_name", gui_data.arrow_coords_one_map_name); }
145 else if (arrow_coords_save_dest == "edgeset_sect_2_maps")
147 gui_data.arrow_coords_save_dest = MapStorage::SpecMapSaveOpts::NESET_SECT;
148 gui_data.arrow_coords_save_map_num = MapStorage::SpecMapSaveOpts::TWO_MAPS;
149 { x("map1_name", gui_data.arrow_coords_two_maps_1_name); }
150 { x("map2_name", gui_data.arrow_coords_two_maps_2_name); }
156 std::map<int, std::string> nm;
157 x("active_nodemaps", nm);
159 for(int i=0;i<NODE_PROPERTY_NUM;i++)
161 mapstorage->changeActiveMap(false, i, nm[i]);
164 std::map<int, std::string> em;
165 x("active_edgemaps", em);
166 for(int i=0;i<EDGE_PROPERTY_NUM;i++)
168 mapstorage->changeActiveMap(true, i, em[i]);
175 x("redesign-attraction", attraction);
176 x("redesign-propulsation", propulsation);
177 x("redesign-iteration", iteration);
179 mapstorage->set_attraction(attraction);
180 mapstorage->set_propulsation(propulsation);
181 mapstorage->set_iteration(iteration);
183 mapstorage->redesign_data_changed();
186 GuiReader::GuiReader(LemonReader& reader, MapStorage* _mapstorage,
187 MapStorage::GUISectData& _gui_data) :
189 mapstorage(_mapstorage),