Changeset 201:879e47e5b731 in glemon-0.x for gui_reader.cc
- Timestamp:
- 01/02/08 22:03:09 (16 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/glemon/trunk@3431
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gui_reader.cc
r194 r201 21 21 22 22 #include <xml.h> 23 #include "io_helper.h" 23 24 #include <lemon/dim2.h> 24 25 #include <vector> … … 34 35 void GuiReader::read(std::istream& is) 35 36 { 37 using std::vector; 38 using std::string; 39 using std::pair; 40 using std::make_pair; 41 using std::string; 42 using std::map; 43 36 44 XmlIo x(is); 37 std::map<int, XY > m;38 x("arrow_pos", m);39 45 40 if ((int)m.size() == countEdges(mapstorage->graph)) 46 { x("main_node_map_names", gui_data.main_node_map_names); } 47 { x("gui_node_map_names", gui_data.gui_node_map_names); } 48 49 { x("node_map_types", gui_data.node_map_types); } 50 51 { x("main_edge_map_names", gui_data.main_edge_map_names); } 52 { x("gui_edge_map_names", gui_data.gui_edge_map_names); } 53 54 { x("edge_map_types", gui_data.edge_map_types); } 55 56 for (vector<string>::const_iterator it = gui_data.gui_node_map_names.begin(); 57 it != gui_data.gui_node_map_names.end(); ++it) 58 { 59 MapValue::Type type = gui_data.node_map_types[*it]; 60 switch (type) 41 61 { 42 for (EdgeIt e(mapstorage->graph); e != INVALID; ++e) 43 { 44 int edgeid = (int)(*mapstorage->edgemap_storage["label"])[e]; 45 mapstorage->arrow_pos.set(e, m[edgeid]); 46 } 47 mapstorage->ArrowPosReadOK(); 62 case MapValue::NUMERIC: 63 { 64 map<int, double>* p_map_data = 65 new map<int, double>; 66 gui_data.numeric_node_maps[*it] = p_map_data; 67 { x(*it, *p_map_data); } 68 } 69 break; 70 case MapValue::STRING: 71 { 72 map<int, string>* p_map_data = 73 new map<int, string>; 74 gui_data.string_node_maps[*it] = p_map_data; 75 { x(*it, *p_map_data); } 76 } 77 break; 48 78 } 49 79 } 80 81 for (vector<string>::const_iterator it = gui_data.gui_edge_map_names.begin(); 82 it != gui_data.gui_edge_map_names.end(); ++it) 83 { 84 MapValue::Type type = gui_data.edge_map_types[*it]; 85 switch (type) 86 { 87 case MapValue::NUMERIC: 88 { 89 map<int, double>* p_map_data = 90 new map<int, double>; 91 gui_data.numeric_edge_maps[*it] = p_map_data; 92 { x(*it, *p_map_data); } 93 } 94 break; 95 case MapValue::STRING: 96 { 97 map<int, string>* p_map_data = 98 new map<int, string>; 99 gui_data.string_edge_maps[*it] = p_map_data; 100 { x(*it, *p_map_data); } 101 } 102 break; 103 } 104 } 105 106 { 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") 110 { 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); } 114 } 115 else if (node_coords_save_dest == "nodeset_sect_1_map") 116 { 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); } 120 } 121 else if (node_coords_save_dest == "nodeset_sect_2_maps") 122 { 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); } 127 } 128 } 129 130 { 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") 134 { 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); } 138 } 139 else if (arrow_coords_save_dest == "edgeset_sect_1_map") 140 { 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); } 144 } 145 else if (arrow_coords_save_dest == "edgeset_sect_2_maps") 146 { 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); } 151 } 152 } 153 154 155 50 156 std::map<int, std::string> nm; 51 157 x("active_nodemaps", nm); 52 158 53 159 for(int i=0;i<NODE_PROPERTY_NUM;i++) 54 55 56 160 { 161 mapstorage->changeActiveMap(false, i, nm[i]); 162 } 57 163 58 164 std::map<int, std::string> em; 59 165 x("active_edgemaps", em); 60 166 for(int i=0;i<EDGE_PROPERTY_NUM;i++) 61 62 63 167 { 168 mapstorage->changeActiveMap(true, i, em[i]); 169 } 64 170 65 171 double attraction; … … 78 184 } 79 185 80 GuiReader::GuiReader(LemonReader& reader, MapStorage* ms) : Parent(reader), mapstorage(ms) 186 GuiReader::GuiReader(LemonReader& reader, MapStorage* _mapstorage, 187 MapStorage::GUISectData& _gui_data) : 188 Parent(reader), 189 mapstorage(_mapstorage), 190 gui_data(_gui_data) 81 191 { 82 192 }
Note: See TracChangeset
for help on using the changeset viewer.