28 return "@gui"; |
31 return "@gui"; |
29 } |
32 } |
30 |
33 |
31 void GuiWriter::write(std::ostream& os) |
34 void GuiWriter::write(std::ostream& os) |
32 { |
35 { |
|
36 using std::vector; |
|
37 using std::string; |
|
38 using std::map; |
|
39 using std::string; |
|
40 |
33 XmlIo x(os); |
41 XmlIo x(os); |
34 std::map<int, XY > m; |
42 |
35 for (EdgeIt e(mapstorage->graph); e != INVALID; ++e) |
43 vector<string> all_node_map_names = mapstorage->getNodeMapList(); |
36 { |
44 // name of the maps saved to the nodeset section |
37 int edgeid = (int)(*(mapstorage->edgemap_storage["label"]))[e]; |
45 vector<string> main_node_map_names; |
38 m[edgeid] = mapstorage->arrow_pos[e]; |
46 // name of the maps saved to the gui section |
39 } |
47 vector<string> gui_node_map_names; |
40 x("arrow_pos", m); |
48 |
|
49 for (vector<string>::const_iterator it = all_node_map_names.begin(); |
|
50 it != all_node_map_names.end(); ++it) |
|
51 { |
|
52 if (mapstorage->getNodeMapSaveDest(*it) == MapStorage::NESET_SECT) |
|
53 main_node_map_names.push_back(*it); |
|
54 else if (mapstorage->getNodeMapSaveDest(*it) == MapStorage::GUI_SECT) |
|
55 gui_node_map_names.push_back(*it); |
|
56 } |
|
57 |
|
58 { x("main_node_map_names", main_node_map_names); } |
|
59 { x("gui_node_map_names", gui_node_map_names); } |
|
60 |
|
61 map<string, MapValue::Type> node_map_types; |
|
62 for (vector<string>::const_iterator it = main_node_map_names.begin(); |
|
63 it != main_node_map_names.end(); ++it) |
|
64 { |
|
65 node_map_types[*it] = mapstorage->getNodeMapElementType(*it); |
|
66 } |
|
67 for (vector<string>::const_iterator it = gui_node_map_names.begin(); |
|
68 it != gui_node_map_names.end(); ++it) |
|
69 { |
|
70 node_map_types[*it] = mapstorage->getNodeMapElementType(*it); |
|
71 } |
|
72 |
|
73 { x("node_map_types", node_map_types); } |
|
74 |
|
75 |
|
76 vector<string> all_edge_map_names = mapstorage->getEdgeMapList(); |
|
77 // name of the maps saved to the edgeset section |
|
78 vector<string> main_edge_map_names; |
|
79 // name of the maps saved to the gui section |
|
80 vector<string> gui_edge_map_names; |
|
81 |
|
82 for (vector<string>::const_iterator it = all_edge_map_names.begin(); |
|
83 it != all_edge_map_names.end(); ++it) |
|
84 { |
|
85 if (mapstorage->getEdgeMapSaveDest(*it) == MapStorage::NESET_SECT) |
|
86 main_edge_map_names.push_back(*it); |
|
87 if (mapstorage->getEdgeMapSaveDest(*it) == MapStorage::GUI_SECT) |
|
88 gui_edge_map_names.push_back(*it); |
|
89 } |
|
90 |
|
91 { x("main_edge_map_names", main_edge_map_names); } |
|
92 { x("gui_edge_map_names", gui_edge_map_names); } |
|
93 |
|
94 map<string, MapValue::Type> edge_map_types; |
|
95 for (vector<string>::const_iterator it = main_edge_map_names.begin(); |
|
96 it != main_edge_map_names.end(); ++it) |
|
97 { |
|
98 edge_map_types[*it] = mapstorage->getEdgeMapElementType(*it); |
|
99 } |
|
100 for (vector<string>::const_iterator it = gui_edge_map_names.begin(); |
|
101 it != gui_edge_map_names.end(); ++it) |
|
102 { |
|
103 edge_map_types[*it] = mapstorage->getEdgeMapElementType(*it); |
|
104 } |
|
105 |
|
106 { x("edge_map_types", edge_map_types); } |
|
107 |
|
108 // write the gui node maps |
|
109 for (vector<string>::const_iterator it = gui_node_map_names.begin(); |
|
110 it != gui_node_map_names.end(); ++it) |
|
111 { |
|
112 MapValue::Type type = mapstorage->getNodeMapElementType(*it); |
|
113 const MapStorage::NodeLabelMap& labels = mapstorage->getNodeLabelMap(); |
|
114 switch (type) |
|
115 { |
|
116 case MapValue::NUMERIC: |
|
117 { |
|
118 std::map<int, double> map_data; |
|
119 MapStorage::NumericNodeMap& map = |
|
120 mapstorage->getNumericNodeMap(*it); |
|
121 for (NodeIt n(mapstorage->getGraph()); n != INVALID; ++n) |
|
122 { |
|
123 map_data[labels[n]] = map[n]; |
|
124 } |
|
125 { x(*it, map_data); } |
|
126 } |
|
127 break; |
|
128 case MapValue::STRING: |
|
129 { |
|
130 std::map<int, std::string> map_data; |
|
131 MapStorage::StringNodeMap& map = |
|
132 mapstorage->getStringNodeMap(*it); |
|
133 for (NodeIt n(mapstorage->getGraph()); n != INVALID; ++n) |
|
134 { |
|
135 map_data[labels[n]] = map[n]; |
|
136 } |
|
137 { x(*it, map_data); } |
|
138 } |
|
139 break; |
|
140 } |
|
141 } |
|
142 |
|
143 // write the gui edge maps |
|
144 for (vector<string>::const_iterator it = gui_edge_map_names.begin(); |
|
145 it != gui_edge_map_names.end(); ++it) |
|
146 { |
|
147 MapValue::Type type = mapstorage->getEdgeMapElementType(*it); |
|
148 const MapStorage::EdgeLabelMap& labels = mapstorage->getEdgeLabelMap(); |
|
149 switch (type) |
|
150 { |
|
151 case MapValue::NUMERIC: |
|
152 { |
|
153 std::map<int, double> map_data; |
|
154 MapStorage::NumericEdgeMap& map = |
|
155 mapstorage->getNumericEdgeMap(*it); |
|
156 for (EdgeIt e(mapstorage->getGraph()); e != INVALID; ++e) |
|
157 { |
|
158 map_data[labels[e]] = map[e]; |
|
159 } |
|
160 { x(*it, map_data); } |
|
161 } |
|
162 break; |
|
163 case MapValue::STRING: |
|
164 { |
|
165 std::map<int, std::string> map_data; |
|
166 MapStorage::StringEdgeMap& map = |
|
167 mapstorage->getStringEdgeMap(*it); |
|
168 for (EdgeIt e(mapstorage->getGraph()); e != INVALID; ++e) |
|
169 { |
|
170 map_data[labels[e]] = map[e]; |
|
171 } |
|
172 { x(*it, map_data); } |
|
173 } |
|
174 break; |
|
175 } |
|
176 } |
|
177 |
|
178 { |
|
179 switch (mapstorage->getNodeCoordsSaveDest()) |
|
180 { |
|
181 case MapStorage::SpecMapSaveOpts::GUI_SECT: |
|
182 { x("node_coords_save_dest", string("gui_sect")); } |
|
183 // write the node coorinates |
|
184 { |
|
185 const MapStorage::NodeLabelMap& labels = |
|
186 mapstorage->getNodeLabelMap(); |
|
187 std::map<int, XY> node_coord_map; |
|
188 MapStorage::NodeCoordMap& map = mapstorage->getNodeCoordMap(); |
|
189 for (NodeIt n(mapstorage->getGraph()); n != INVALID; ++n) |
|
190 { |
|
191 node_coord_map[labels[n]] = map[n]; |
|
192 } |
|
193 { x("node_coord_map", node_coord_map); } |
|
194 } |
|
195 break; |
|
196 case MapStorage::SpecMapSaveOpts::NESET_SECT: |
|
197 switch (mapstorage->getNodeCoordsSaveMapNum()) |
|
198 { |
|
199 case MapStorage::SpecMapSaveOpts::ONE_MAP: |
|
200 { x("node_coords_save_dest", string("nodeset_sect_1_map")); } |
|
201 { x("map_name", mapstorage->getNodeCoordsOneMapName()); } |
|
202 break; |
|
203 case MapStorage::SpecMapSaveOpts::TWO_MAPS: |
|
204 { x("node_coords_save_dest", string("nodeset_sect_2_maps")); } |
|
205 { x("map1_name", mapstorage->getNodeCoordsTwoMaps1Name()); } |
|
206 { x("map2_name", mapstorage->getNodeCoordsTwoMaps2Name()); } |
|
207 break; |
|
208 } |
|
209 break; |
|
210 } |
|
211 } |
|
212 |
|
213 { |
|
214 switch (mapstorage->getArrowCoordsSaveDest()) |
|
215 { |
|
216 case MapStorage::SpecMapSaveOpts::GUI_SECT: |
|
217 { x("arrow_coords_save_dest", string("gui_sect")); } |
|
218 // write the arrow coorinates |
|
219 { |
|
220 const MapStorage::EdgeLabelMap& labels = |
|
221 mapstorage->getEdgeLabelMap(); |
|
222 std::map<int, XY> arrow_coord_map; |
|
223 MapStorage::ArrowCoordMap& map = mapstorage->getArrowCoordMap(); |
|
224 for (EdgeIt e(mapstorage->getGraph()); e != INVALID; ++e) |
|
225 { |
|
226 arrow_coord_map[labels[e]] = map[e]; |
|
227 } |
|
228 { x("arrow_coord_map", arrow_coord_map); } |
|
229 } |
|
230 break; |
|
231 case MapStorage::SpecMapSaveOpts::NESET_SECT: |
|
232 switch (mapstorage->getArrowCoordsSaveMapNum()) |
|
233 { |
|
234 case MapStorage::SpecMapSaveOpts::ONE_MAP: |
|
235 { x("arrow_coords_save_dest", string("edgeset_sect_1_map")); } |
|
236 { x("map_name", mapstorage->getArrowCoordsOneMapName()); } |
|
237 break; |
|
238 case MapStorage::SpecMapSaveOpts::TWO_MAPS: |
|
239 { x("arrow_coords_save_dest", string("edgeset_sect_2_maps")); } |
|
240 { x("map1_name", mapstorage->getArrowCoordsTwoMaps1Name()); } |
|
241 { x("map2_name", mapstorage->getArrowCoordsTwoMaps2Name()); } |
|
242 break; |
|
243 } |
|
244 break; |
|
245 } |
|
246 } |
|
247 |
41 |
248 |
42 std::map<int, std::string> nm; |
249 std::map<int, std::string> nm; |
43 for(int i=0;i<NODE_PROPERTY_NUM;i++) |
250 for(int i=0;i<NODE_PROPERTY_NUM;i++) |
44 { |
251 { |
45 nm[i]=mapstorage->active_nodemaps[i]; |
252 nm[i]=mapstorage->active_nodemaps[i]; |
46 } |
253 } |
47 x("active_nodemaps", nm); |
254 { x("active_nodemaps", nm); } |
48 |
255 |
49 std::map<int, std::string> em; |
256 std::map<int, std::string> em; |
50 for(int i=0;i<EDGE_PROPERTY_NUM;i++) |
257 for(int i=0;i<EDGE_PROPERTY_NUM;i++) |
51 { |
258 { |
52 em[i]=mapstorage->active_edgemaps[i]; |
259 em[i]=mapstorage->active_edgemaps[i]; |
53 } |
260 } |
54 x("active_edgemaps", em); |
261 { x("active_edgemaps", em); } |
55 |
262 |
56 double attraction; |
263 double attraction; |
57 double propulsation; |
264 double propulsation; |
58 int iteration; |
265 int iteration; |
59 |
266 |
60 mapstorage->get_design_data(attraction, propulsation, iteration); |
267 mapstorage->get_design_data(attraction, propulsation, iteration); |
61 |
268 |
62 x("redesign-attraction", attraction); |
269 { x("redesign-attraction", attraction); } |
63 x("redesign-propulsation", propulsation); |
270 { x("redesign-propulsation", propulsation); } |
64 x("redesign-iteration", iteration); |
271 { x("redesign-iteration", iteration); } |
65 } |
272 } |
66 |
273 |
67 GuiWriter::GuiWriter(LemonWriter& writer, MapStorage* ms) : Parent(writer), mapstorage(ms) |
274 GuiWriter::GuiWriter(LemonWriter& writer, MapStorage* ms) : |
|
275 Parent(writer), |
|
276 mapstorage(ms) |
68 { |
277 { |
69 } |
278 } |