Use hg changeset hash instead of svn revision.
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_writer.h"
20 #include "io_helper.h"
21 #include "mapstorage.h"
23 #include <lemon/dim2.h>
26 #include <gui_writer.h>
27 #include <mapstorage.h>
29 // std::string GuiWriter::header()
34 void GuiWriter::write(std::ostream& os)
41 os << "@gui" << std::endl;
45 vector<string> all_node_map_names = mapstorage->getNodeMapList();
46 // name of the maps saved to the nodeset section
47 vector<string> main_node_map_names;
48 // name of the maps saved to the gui section
49 vector<string> gui_node_map_names;
51 for (vector<string>::const_iterator it = all_node_map_names.begin();
52 it != all_node_map_names.end(); ++it)
54 if (mapstorage->getNodeMapSaveDest(*it) == MapStorage::NESET_SECT)
55 main_node_map_names.push_back(*it);
56 else if (mapstorage->getNodeMapSaveDest(*it) == MapStorage::GUI_SECT)
57 gui_node_map_names.push_back(*it);
60 { x("main_node_map_names", main_node_map_names); }
61 { x("gui_node_map_names", gui_node_map_names); }
63 map<string, MapValue::Type> node_map_types;
64 for (vector<string>::const_iterator it = main_node_map_names.begin();
65 it != main_node_map_names.end(); ++it)
67 node_map_types[*it] = mapstorage->getNodeMapElementType(*it);
69 for (vector<string>::const_iterator it = gui_node_map_names.begin();
70 it != gui_node_map_names.end(); ++it)
72 node_map_types[*it] = mapstorage->getNodeMapElementType(*it);
75 { x("node_map_types", node_map_types); }
78 vector<string> all_arc_map_names = mapstorage->getArcMapList();
79 // name of the maps saved to the arcset section
80 vector<string> main_arc_map_names;
81 // name of the maps saved to the gui section
82 vector<string> gui_arc_map_names;
84 for (vector<string>::const_iterator it = all_arc_map_names.begin();
85 it != all_arc_map_names.end(); ++it)
87 if (mapstorage->getArcMapSaveDest(*it) == MapStorage::NESET_SECT)
88 main_arc_map_names.push_back(*it);
89 if (mapstorage->getArcMapSaveDest(*it) == MapStorage::GUI_SECT)
90 gui_arc_map_names.push_back(*it);
93 { x("main_arc_map_names", main_arc_map_names); }
94 { x("gui_arc_map_names", gui_arc_map_names); }
96 map<string, MapValue::Type> arc_map_types;
97 for (vector<string>::const_iterator it = main_arc_map_names.begin();
98 it != main_arc_map_names.end(); ++it)
100 arc_map_types[*it] = mapstorage->getArcMapElementType(*it);
102 for (vector<string>::const_iterator it = gui_arc_map_names.begin();
103 it != gui_arc_map_names.end(); ++it)
105 arc_map_types[*it] = mapstorage->getArcMapElementType(*it);
108 { x("arc_map_types", arc_map_types); }
110 // write the gui node maps
111 for (vector<string>::const_iterator it = gui_node_map_names.begin();
112 it != gui_node_map_names.end(); ++it)
114 MapValue::Type type = mapstorage->getNodeMapElementType(*it);
115 const MapStorage::NodeLabelMap& labels = mapstorage->getNodeLabelMap();
118 case MapValue::NUMERIC:
120 std::map<int, double> map_data;
121 MapStorage::NumericNodeMap& map =
122 mapstorage->getNumericNodeMap(*it);
123 for (NodeIt n(mapstorage->getDigraph()); n != INVALID; ++n)
125 map_data[labels[n]] = map[n];
127 { x(*it, map_data); }
130 case MapValue::STRING:
132 std::map<int, std::string> map_data;
133 MapStorage::StringNodeMap& map =
134 mapstorage->getStringNodeMap(*it);
135 for (NodeIt n(mapstorage->getDigraph()); n != INVALID; ++n)
137 map_data[labels[n]] = map[n];
139 { x(*it, map_data); }
145 // write the gui arc maps
146 for (vector<string>::const_iterator it = gui_arc_map_names.begin();
147 it != gui_arc_map_names.end(); ++it)
149 MapValue::Type type = mapstorage->getArcMapElementType(*it);
150 const MapStorage::ArcLabelMap& labels = mapstorage->getArcLabelMap();
153 case MapValue::NUMERIC:
155 std::map<int, double> map_data;
156 MapStorage::NumericArcMap& map =
157 mapstorage->getNumericArcMap(*it);
158 for (ArcIt e(mapstorage->getDigraph()); e != INVALID; ++e)
160 map_data[labels[e]] = map[e];
162 { x(*it, map_data); }
165 case MapValue::STRING:
167 std::map<int, std::string> map_data;
168 MapStorage::StringArcMap& map =
169 mapstorage->getStringArcMap(*it);
170 for (ArcIt e(mapstorage->getDigraph()); e != INVALID; ++e)
172 map_data[labels[e]] = map[e];
174 { x(*it, map_data); }
181 switch (mapstorage->getNodeCoordsSaveDest())
183 case MapStorage::SpecMapSaveOpts::GUI_SECT:
184 { x("node_coords_save_dest", string("gui_sect")); }
185 // write the node coorinates
187 const MapStorage::NodeLabelMap& labels =
188 mapstorage->getNodeLabelMap();
189 std::map<int, XY> node_coord_map;
190 MapStorage::NodeCoordMap& map = mapstorage->getNodeCoordMap();
191 for (NodeIt n(mapstorage->getDigraph()); n != INVALID; ++n)
193 node_coord_map[labels[n]] = map[n];
195 { x("node_coord_map", node_coord_map); }
198 case MapStorage::SpecMapSaveOpts::NESET_SECT:
199 switch (mapstorage->getNodeCoordsSaveMapNum())
201 case MapStorage::SpecMapSaveOpts::ONE_MAP:
202 { x("node_coords_save_dest", string("nodeset_sect_1_map")); }
203 { x("map_name", mapstorage->getNodeCoordsOneMapName()); }
205 case MapStorage::SpecMapSaveOpts::TWO_MAPS:
206 { x("node_coords_save_dest", string("nodeset_sect_2_maps")); }
207 { x("map1_name", mapstorage->getNodeCoordsTwoMaps1Name()); }
208 { x("map2_name", mapstorage->getNodeCoordsTwoMaps2Name()); }
216 switch (mapstorage->getArrowCoordsSaveDest())
218 case MapStorage::SpecMapSaveOpts::GUI_SECT:
219 { x("arrow_coords_save_dest", string("gui_sect")); }
220 // write the arrow coorinates
222 const MapStorage::ArcLabelMap& labels =
223 mapstorage->getArcLabelMap();
224 std::map<int, XY> arrow_coord_map;
225 MapStorage::ArrowCoordMap& map = mapstorage->getArrowCoordMap();
226 for (ArcIt e(mapstorage->getDigraph()); e != INVALID; ++e)
228 arrow_coord_map[labels[e]] = map[e];
230 { x("arrow_coord_map", arrow_coord_map); }
233 case MapStorage::SpecMapSaveOpts::NESET_SECT:
234 switch (mapstorage->getArrowCoordsSaveMapNum())
236 case MapStorage::SpecMapSaveOpts::ONE_MAP:
237 { x("arrow_coords_save_dest", string("arcset_sect_1_map")); }
238 { x("map_name", mapstorage->getArrowCoordsOneMapName()); }
240 case MapStorage::SpecMapSaveOpts::TWO_MAPS:
241 { x("arrow_coords_save_dest", string("arcset_sect_2_maps")); }
242 { x("map1_name", mapstorage->getArrowCoordsTwoMaps1Name()); }
243 { x("map2_name", mapstorage->getArrowCoordsTwoMaps2Name()); }
251 std::map<int, std::string> nm;
252 for(int i=0;i<NODE_PROPERTY_NUM;i++)
254 nm[i]=mapstorage->active_nodemaps[i];
256 { x("active_nodemaps", nm); }
258 std::map<int, std::string> em;
259 for(int i=0;i<EDGE_PROPERTY_NUM;i++)
261 em[i]=mapstorage->active_arcmaps[i];
263 { x("active_arcmaps", em); }
269 mapstorage->get_design_data(attraction, propulsation, iteration);
271 { x("redesign-attraction", attraction); }
272 { x("redesign-propulsation", propulsation); }
273 { x("redesign-iteration", iteration); }
276 //GuiWriter::GuiWriter(LemonWriter& writer, MapStorage* ms) :
277 GuiWriter::GuiWriter(MapStorage* ms) :