Changeset 63:59768817442a in glemon-0.x for mapstorage.cc
- Timestamp:
- 08/23/05 09:36:09 (19 years ago)
- Branch:
- gui
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk/gui@2158
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mapstorage.cc
r62 r63 1 1 #include "mapstorage.h" 2 #include <gtkmm.h> 2 3 #include <cmath> 3 4 … … 27 28 } 28 29 29 int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap<double> *nodemap )30 int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap<double> *nodemap, double default_value = 0.0) 30 31 { 31 32 if( nodemap_storage.find(name) == nodemap_storage.end() ) 32 33 { 33 34 nodemap_storage[name]=nodemap; 35 // set the maps default value 36 nodemap_default[name] = default_value; 34 37 return 0; 35 38 } … … 37 40 } 38 41 39 int MapStorage::addEdgeMap(const std::string & name, Graph::EdgeMap<double> *edgemap )42 int MapStorage::addEdgeMap(const std::string & name, Graph::EdgeMap<double> *edgemap, double default_value = 0.0) 40 43 { 41 44 if( edgemap_storage.find(name) == edgemap_storage.end() ) 42 45 { 43 46 edgemap_storage[name]=edgemap; 47 // set the maps default value 48 edgemap_default[name] = default_value; 44 49 return 0; 45 50 } … … 117 122 } 118 123 119 void MapStorage::initMapsForEdge(Edge e) 120 { 121 std::map< std::string,Graph::EdgeMap<double> * >::iterator ems_it; 122 for(ems_it=edgemap_storage.begin();ems_it!=edgemap_storage.end();ems_it++) 123 { 124 (*((*ems_it).second))[e]=5; 125 } 126 } 127 128 void MapStorage::readFromFile(const std::string &filename) 124 int MapStorage::readFromFile(const std::string &filename) 129 125 { 130 126 bool read_x = false; … … 180 176 greader.run(); 181 177 } catch (DataFormatError& error) { 182 /*183 178 Gtk::MessageDialog mdialog("Read Error"); 184 179 mdialog.set_message(error.what()); 185 180 mdialog.run(); 186 */ 187 // reset graph and mapstorage ? 188 return; 181 clear(); 182 return 1; 189 183 } 190 184 … … 206 200 } 207 201 } 202 203 // fill in the default values for the maps 204 for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it = 205 nodemap_storage.begin(); it != nodemap_storage.end(); ++it) 206 { 207 if ((it->first != "id") && 208 (it->first != "coordiantes_x") && 209 (it->first != "coordinates_y")) 210 { 211 nodemap_default[it->first] = 0.0; 212 } 213 } 214 for (std::map<std::string, Graph::EdgeMap<double>*>::const_iterator it = 215 edgemap_storage.begin(); it != edgemap_storage.end(); ++it) 216 { 217 if (it->first != "id") 218 { 219 edgemap_default[it->first] = 0.0; 220 } 221 } 222 223 return 0; 208 224 } 209 225 … … 249 265 } 250 266 } 267 for (std::map<std::string, double>::iterator it = 268 nodemap_default.begin(); it != nodemap_default.end(); ++it) 269 { 270 nodemap_default.erase(it); 271 } 272 for (std::map<std::string, double>::iterator it = 273 edgemap_default.begin(); it != edgemap_default.end(); ++it) 274 { 275 edgemap_default.erase(it); 276 } 251 277 graph.clear(); 252 278 file_name = "";
Note: See TracChangeset
for help on using the changeset viewer.