[174] | 1 | /* -*- C++ -*- |
---|
| 2 | * |
---|
| 3 | * This file is a part of LEMON, a generic C++ optimization library |
---|
| 4 | * |
---|
| 5 | * Copyright (C) 2003-2006 |
---|
| 6 | * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
---|
| 7 | * (Egervary Research Group on Combinatorial Optimization, EGRES). |
---|
| 8 | * |
---|
| 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. |
---|
| 12 | * |
---|
| 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 |
---|
| 15 | * purpose. |
---|
| 16 | * |
---|
| 17 | */ |
---|
| 18 | |
---|
[53] | 19 | #include "mapstorage.h" |
---|
[184] | 20 | #include "nbtab.h" |
---|
[98] | 21 | #include "gui_writer.h" |
---|
| 22 | #include "gui_reader.h" |
---|
[128] | 23 | #include <limits> |
---|
| 24 | #include <cmath> |
---|
[63] | 25 | #include <gtkmm.h> |
---|
[77] | 26 | |
---|
[177] | 27 | const double i_d=20; |
---|
| 28 | const double a_d=0.05; |
---|
| 29 | const double p_d=40000; |
---|
| 30 | |
---|
[184] | 31 | MapStorage::MapStorage(NoteBookTab& tab) : mytab(tab), modified(false), file_name(""), arrow_pos_read_ok(false), iterations(i_d), attraction(a_d), propulsation(p_d), background_set(false) |
---|
[6] | 32 | { |
---|
[53] | 33 | nodemap_storage["coordinates_x"] = new Graph::NodeMap<double>(graph); |
---|
| 34 | coords.setXMap(*nodemap_storage["coordinates_x"]); |
---|
| 35 | nodemap_storage["coordinates_y"] = new Graph::NodeMap<double>(graph); |
---|
| 36 | coords.setYMap(*nodemap_storage["coordinates_y"]); |
---|
| 37 | |
---|
[98] | 38 | edgemap_storage["arrow_pos_x"] = new Graph::EdgeMap<double>(graph); |
---|
| 39 | arrow_pos.setXMap(*edgemap_storage["arrow_pos_x"]); |
---|
| 40 | edgemap_storage["arrow_pos_y"] = new Graph::EdgeMap<double>(graph); |
---|
| 41 | arrow_pos.setYMap(*edgemap_storage["arrow_pos_y"]); |
---|
| 42 | |
---|
[134] | 43 | nodemap_storage["label"] = new Graph::NodeMap<double>(graph); |
---|
| 44 | edgemap_storage["label"] = new Graph::EdgeMap<double>(graph); |
---|
[64] | 45 | |
---|
[134] | 46 | nodemap_default["label"] = 1.0; |
---|
| 47 | edgemap_default["label"] = 1.0; |
---|
[94] | 48 | |
---|
| 49 | active_nodemaps.resize(NODE_PROPERTY_NUM); |
---|
| 50 | for(int i=0;i<NODE_PROPERTY_NUM;i++) |
---|
| 51 | { |
---|
| 52 | active_nodemaps[i]=""; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | active_edgemaps.resize(EDGE_PROPERTY_NUM); |
---|
| 56 | for(int i=0;i<EDGE_PROPERTY_NUM;i++) |
---|
| 57 | { |
---|
| 58 | active_edgemaps[i]=""; |
---|
| 59 | } |
---|
[53] | 60 | } |
---|
| 61 | |
---|
| 62 | MapStorage::~MapStorage() |
---|
| 63 | { |
---|
| 64 | for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it = |
---|
| 65 | nodemap_storage.begin(); it != nodemap_storage.end(); ++it) |
---|
| 66 | { |
---|
| 67 | delete it->second; |
---|
| 68 | } |
---|
| 69 | for (std::map<std::string, Graph::EdgeMap<double>*>::const_iterator it = |
---|
| 70 | edgemap_storage.begin(); it != edgemap_storage.end(); ++it) |
---|
| 71 | { |
---|
| 72 | delete it->second; |
---|
| 73 | } |
---|
| 74 | } |
---|
[6] | 75 | |
---|
[118] | 76 | int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap<double> *nodemap, double default_value) |
---|
[6] | 77 | { |
---|
[46] | 78 | if( nodemap_storage.find(name) == nodemap_storage.end() ) |
---|
| 79 | { |
---|
| 80 | nodemap_storage[name]=nodemap; |
---|
[63] | 81 | // set the maps default value |
---|
| 82 | nodemap_default[name] = default_value; |
---|
[108] | 83 | |
---|
| 84 | //announce changement in maps |
---|
| 85 | signal_node_map.emit(name); |
---|
[46] | 86 | return 0; |
---|
| 87 | } |
---|
| 88 | return 1; |
---|
[6] | 89 | } |
---|
| 90 | |
---|
[94] | 91 | void MapStorage::changeActiveMap(bool itisedge, int prop, std::string mapname) |
---|
| 92 | { |
---|
| 93 | if(itisedge) |
---|
| 94 | { |
---|
| 95 | active_edgemaps[prop]=mapname; |
---|
| 96 | } |
---|
| 97 | else |
---|
| 98 | { |
---|
| 99 | active_nodemaps[prop]=mapname; |
---|
| 100 | } |
---|
| 101 | signal_prop.emit(itisedge, prop); |
---|
| 102 | } |
---|
| 103 | |
---|
[172] | 104 | void MapStorage::broadcastActiveMaps() |
---|
| 105 | { |
---|
| 106 | for(int i=0;i<NODE_PROPERTY_NUM;i++) |
---|
| 107 | { |
---|
| 108 | signal_map_win.emit(false, i, active_nodemaps[i]); |
---|
| 109 | } |
---|
| 110 | |
---|
| 111 | for(int i=0;i<EDGE_PROPERTY_NUM;i++) |
---|
| 112 | { |
---|
| 113 | signal_map_win.emit(true, i, active_edgemaps[i]); |
---|
| 114 | } |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | |
---|
[94] | 118 | std::string MapStorage::getActiveEdgeMap(int prop) |
---|
| 119 | { |
---|
| 120 | return active_edgemaps[prop]; |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | std::string MapStorage::getActiveNodeMap(int prop) |
---|
| 124 | { |
---|
| 125 | return active_nodemaps[prop]; |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | std::vector<std::string> MapStorage::getEdgeMapList() |
---|
| 129 | { |
---|
| 130 | std::vector<std::string> eml; |
---|
| 131 | eml.resize(edgemap_storage.size()); |
---|
| 132 | int i=0; |
---|
| 133 | std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=beginOfEdgeMaps(); |
---|
| 134 | for(;emsi!=endOfEdgeMaps();emsi++) |
---|
| 135 | { |
---|
| 136 | eml[i]=(emsi->first); |
---|
| 137 | i++; |
---|
| 138 | } |
---|
| 139 | return eml; |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | std::vector<std::string> MapStorage::getNodeMapList() |
---|
| 143 | { |
---|
| 144 | std::vector<std::string> nml; |
---|
| 145 | nml.resize(nodemap_storage.size()); |
---|
| 146 | int i=0; |
---|
| 147 | std::map< std::string,Graph::NodeMap<double> * >::iterator nmsi=beginOfNodeMaps(); |
---|
| 148 | for(;nmsi!=endOfNodeMaps();nmsi++) |
---|
| 149 | { |
---|
| 150 | nml[i]=(nmsi->first); |
---|
| 151 | i++; |
---|
| 152 | } |
---|
| 153 | return nml; |
---|
| 154 | } |
---|
| 155 | |
---|
[177] | 156 | sigc::signal<void, bool, int> MapStorage::signal_prop_ch() |
---|
[94] | 157 | { |
---|
| 158 | return signal_prop; |
---|
| 159 | } |
---|
| 160 | |
---|
[118] | 161 | int MapStorage::addEdgeMap(const std::string & name, Graph::EdgeMap<double> *edgemap, double default_value) |
---|
[6] | 162 | { |
---|
[46] | 163 | if( edgemap_storage.find(name) == edgemap_storage.end() ) |
---|
| 164 | { |
---|
| 165 | edgemap_storage[name]=edgemap; |
---|
[63] | 166 | // set the maps default value |
---|
| 167 | edgemap_default[name] = default_value; |
---|
[108] | 168 | |
---|
| 169 | //announce changement in maps |
---|
| 170 | signal_edge_map.emit(name); |
---|
[46] | 171 | return 0; |
---|
| 172 | } |
---|
| 173 | return 1; |
---|
[6] | 174 | } |
---|
| 175 | |
---|
| 176 | double MapStorage::maxOfNodeMap(const std::string & name) |
---|
| 177 | { |
---|
| 178 | double max=0; |
---|
[53] | 179 | for (NodeIt j(graph); j!=INVALID; ++j) |
---|
[6] | 180 | { |
---|
| 181 | if( (*nodemap_storage[name])[j]>max ) |
---|
| 182 | { |
---|
| 183 | max=(*nodemap_storage[name])[j]; |
---|
| 184 | } |
---|
| 185 | } |
---|
| 186 | return max; |
---|
| 187 | } |
---|
| 188 | |
---|
| 189 | double MapStorage::maxOfEdgeMap(const std::string & name) |
---|
| 190 | { |
---|
| 191 | double max=0; |
---|
[53] | 192 | for (EdgeIt j(graph); j!=INVALID; ++j) |
---|
[6] | 193 | { |
---|
| 194 | if( (*edgemap_storage[name])[j]>max ) |
---|
| 195 | { |
---|
| 196 | max=(*edgemap_storage[name])[j]; |
---|
| 197 | } |
---|
| 198 | } |
---|
| 199 | return max; |
---|
| 200 | } |
---|
| 201 | |
---|
| 202 | double MapStorage::minOfNodeMap(const std::string & name) |
---|
| 203 | { |
---|
[53] | 204 | NodeIt j(graph); |
---|
[58] | 205 | double min; |
---|
| 206 | if(j!=INVALID) |
---|
| 207 | { |
---|
| 208 | min=(*nodemap_storage[name])[j]; |
---|
| 209 | } |
---|
| 210 | else |
---|
| 211 | { |
---|
| 212 | min=0; |
---|
| 213 | } |
---|
[6] | 214 | for (; j!=INVALID; ++j) |
---|
| 215 | { |
---|
| 216 | if( (*nodemap_storage[name])[j]<min ) |
---|
| 217 | { |
---|
| 218 | min=(*nodemap_storage[name])[j]; |
---|
| 219 | } |
---|
| 220 | } |
---|
| 221 | return min; |
---|
| 222 | } |
---|
| 223 | |
---|
| 224 | double MapStorage::minOfEdgeMap(const std::string & name) |
---|
| 225 | { |
---|
[53] | 226 | EdgeIt j(graph); |
---|
[58] | 227 | double min; |
---|
| 228 | if(j!=INVALID) |
---|
| 229 | { |
---|
| 230 | min=(*edgemap_storage[name])[j]; |
---|
| 231 | } |
---|
| 232 | else |
---|
| 233 | { |
---|
| 234 | min=0; |
---|
| 235 | } |
---|
[53] | 236 | for (EdgeIt j(graph); j!=INVALID; ++j) |
---|
[6] | 237 | { |
---|
| 238 | if( (*edgemap_storage[name])[j]<min ) |
---|
| 239 | { |
---|
| 240 | min=(*edgemap_storage[name])[j]; |
---|
| 241 | } |
---|
| 242 | } |
---|
| 243 | return min; |
---|
| 244 | } |
---|
| 245 | |
---|
[63] | 246 | int MapStorage::readFromFile(const std::string &filename) |
---|
[53] | 247 | { |
---|
| 248 | bool read_x = false; |
---|
| 249 | bool read_y = false; |
---|
[64] | 250 | bool read_edge_id = false; |
---|
[53] | 251 | |
---|
| 252 | try { |
---|
| 253 | LemonReader lreader(filename); |
---|
| 254 | ContentReader content(lreader); |
---|
| 255 | lreader.run(); |
---|
| 256 | |
---|
[101] | 257 | if (content.nodeSetNum() < 1) |
---|
| 258 | { |
---|
| 259 | Gtk::MessageDialog mdialog("No nodeset found in file."); |
---|
| 260 | mdialog.run(); |
---|
| 261 | clear(); |
---|
| 262 | return 1; |
---|
| 263 | } |
---|
| 264 | |
---|
| 265 | if (content.edgeSetNum() < 1) |
---|
| 266 | { |
---|
| 267 | Gtk::MessageDialog mdialog("No edgeset found in file."); |
---|
| 268 | mdialog.run(); |
---|
| 269 | clear(); |
---|
| 270 | return 1; |
---|
| 271 | } |
---|
| 272 | |
---|
[53] | 273 | const std::vector<std::string>& nodeMapNames = content.nodeSetMaps(0); |
---|
| 274 | const std::vector<std::string>& edgeMapNames = content.edgeSetMaps(0); |
---|
| 275 | |
---|
| 276 | GraphReader<Graph> greader(filename, graph); |
---|
| 277 | for (std::vector<std::string>::const_iterator it = nodeMapNames.begin(); |
---|
| 278 | it != nodeMapNames.end(); ++it) |
---|
| 279 | { |
---|
| 280 | if (*it == "coordinates_x") |
---|
| 281 | { |
---|
| 282 | read_x = true; |
---|
| 283 | //std::cout << "read X nodemap" << std::endl; |
---|
| 284 | } |
---|
| 285 | else if (*it == "coordinates_y") |
---|
| 286 | { |
---|
| 287 | read_y = true; |
---|
| 288 | //std::cout << "read Y nodemap" << std::endl; |
---|
| 289 | } |
---|
[134] | 290 | else if (*it == "label") |
---|
[53] | 291 | { |
---|
| 292 | //std::cout << "read id nodemap" << std::endl; |
---|
| 293 | } |
---|
| 294 | else |
---|
| 295 | { |
---|
| 296 | nodemap_storage[*it] = new Graph::NodeMap<double>(graph); |
---|
| 297 | //std::cout << "read " << *it << " nodemap" << std::endl; |
---|
| 298 | } |
---|
| 299 | greader.readNodeMap(*it, *nodemap_storage[*it]); |
---|
| 300 | } |
---|
| 301 | for (std::vector<std::string>::const_iterator it = edgeMapNames.begin(); |
---|
| 302 | it != edgeMapNames.end(); ++it) |
---|
| 303 | { |
---|
[134] | 304 | if (*it == "label") |
---|
[53] | 305 | { |
---|
| 306 | //std::cout << "read id edgemap" << std::endl; |
---|
[135] | 307 | read_edge_id = true; |
---|
[53] | 308 | } |
---|
| 309 | else |
---|
| 310 | { |
---|
| 311 | edgemap_storage[*it] = new Graph::EdgeMap<double>(graph); |
---|
| 312 | //std::cout << "read " << *it << " edgemap" << std::endl; |
---|
| 313 | } |
---|
| 314 | greader.readEdgeMap(*it, *edgemap_storage[*it]); |
---|
| 315 | } |
---|
[98] | 316 | GuiReader gui_reader(greader, this); |
---|
[53] | 317 | greader.run(); |
---|
[101] | 318 | } catch (Exception& error) { |
---|
[79] | 319 | Gtk::MessageDialog mdialog(error.what()); |
---|
[53] | 320 | mdialog.run(); |
---|
[63] | 321 | clear(); |
---|
| 322 | return 1; |
---|
[53] | 323 | } |
---|
| 324 | |
---|
[64] | 325 | if (!read_edge_id) |
---|
| 326 | { |
---|
[134] | 327 | edgemap_storage["label"] = new Graph::EdgeMap<double>(graph); |
---|
[64] | 328 | int i = 1; |
---|
| 329 | for (EdgeIt e(graph); e != INVALID; ++e) |
---|
| 330 | { |
---|
[134] | 331 | (*edgemap_storage["label"])[e] = i++; |
---|
[64] | 332 | } |
---|
| 333 | } |
---|
| 334 | |
---|
[53] | 335 | if (!read_x || !read_y) |
---|
| 336 | { |
---|
| 337 | int node_num = 0; |
---|
| 338 | for (NodeIt n(graph); n != INVALID; ++n) |
---|
| 339 | { |
---|
| 340 | node_num++; |
---|
| 341 | } |
---|
| 342 | const double pi = 3.142; |
---|
| 343 | double step = 2 * pi / (double) node_num; |
---|
| 344 | int i = 0; |
---|
| 345 | for (NodeIt n(graph); n != INVALID; ++n) |
---|
| 346 | { |
---|
[77] | 347 | nodemap_storage["coordinates_x"]->set(n, 250.0 * std::cos(i * step)); |
---|
| 348 | nodemap_storage["coordinates_y"]->set(n, 250.0 * std::sin(i * step)); |
---|
[53] | 349 | i++; |
---|
| 350 | } |
---|
| 351 | } |
---|
[63] | 352 | |
---|
[98] | 353 | if (!arrow_pos_read_ok) |
---|
| 354 | { |
---|
| 355 | arrow_pos_read_ok = false; |
---|
| 356 | for (EdgeIt e(graph); e != INVALID; ++e) |
---|
| 357 | { |
---|
[151] | 358 | if (graph.source(e) == graph.target(e)) |
---|
| 359 | { |
---|
| 360 | arrow_pos.set(e, coords[graph.source(e)] + XY(0.0, 80.0)); |
---|
| 361 | } |
---|
| 362 | else |
---|
| 363 | { |
---|
| 364 | arrow_pos.set(e, (coords[graph.source(e)] + coords[graph.target(e)]) / 2.0); |
---|
| 365 | } |
---|
[98] | 366 | } |
---|
| 367 | } |
---|
| 368 | |
---|
[63] | 369 | // fill in the default values for the maps |
---|
| 370 | for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it = |
---|
| 371 | nodemap_storage.begin(); it != nodemap_storage.end(); ++it) |
---|
| 372 | { |
---|
[134] | 373 | if ((it->first != "label") && |
---|
[63] | 374 | (it->first != "coordiantes_x") && |
---|
| 375 | (it->first != "coordinates_y")) |
---|
| 376 | { |
---|
| 377 | nodemap_default[it->first] = 0.0; |
---|
| 378 | } |
---|
[134] | 379 | else if (it->first == "label") |
---|
[64] | 380 | { |
---|
| 381 | NodeIt n(graph); |
---|
[134] | 382 | double max = (*nodemap_storage["label"])[n]; |
---|
[64] | 383 | for (; n != INVALID; ++n) |
---|
| 384 | { |
---|
[134] | 385 | if ((*nodemap_storage["label"])[n] > max) |
---|
| 386 | max = (*nodemap_storage["label"])[n]; |
---|
[64] | 387 | } |
---|
[134] | 388 | nodemap_default["label"] = max + 1.0; |
---|
[64] | 389 | } |
---|
[63] | 390 | } |
---|
| 391 | for (std::map<std::string, Graph::EdgeMap<double>*>::const_iterator it = |
---|
| 392 | edgemap_storage.begin(); it != edgemap_storage.end(); ++it) |
---|
| 393 | { |
---|
[134] | 394 | if (it->first != "label") |
---|
[63] | 395 | { |
---|
| 396 | edgemap_default[it->first] = 0.0; |
---|
| 397 | } |
---|
[64] | 398 | else |
---|
| 399 | { |
---|
[67] | 400 | double max = std::numeric_limits<double>::min(); |
---|
| 401 | for (EdgeIt e(graph); e != INVALID; ++e) |
---|
[64] | 402 | { |
---|
[134] | 403 | if ((*edgemap_storage["label"])[e] > max) |
---|
| 404 | max = (*edgemap_storage["label"])[e]; |
---|
[64] | 405 | } |
---|
[67] | 406 | if (max > std::numeric_limits<double>::min()) |
---|
[134] | 407 | edgemap_default["label"] = max + 1.0; |
---|
[67] | 408 | else |
---|
[134] | 409 | edgemap_default["label"] = 1.0; |
---|
[64] | 410 | } |
---|
[63] | 411 | } |
---|
| 412 | |
---|
| 413 | return 0; |
---|
[53] | 414 | } |
---|
| 415 | |
---|
| 416 | void MapStorage::writeToFile(const std::string &filename) |
---|
| 417 | { |
---|
| 418 | GraphWriter<Graph> gwriter(filename, graph); |
---|
| 419 | |
---|
| 420 | for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it = |
---|
| 421 | nodemap_storage.begin(); it != nodemap_storage.end(); ++it) |
---|
| 422 | { |
---|
| 423 | gwriter.writeNodeMap(it->first, *(it->second)); |
---|
| 424 | } |
---|
| 425 | for (std::map<std::string, Graph::EdgeMap<double>*>::const_iterator it = |
---|
| 426 | edgemap_storage.begin(); it != edgemap_storage.end(); ++it) |
---|
| 427 | { |
---|
[98] | 428 | if ((it->first != "arrow_pos_x") && |
---|
| 429 | (it->first != "arrow_pos_y")) |
---|
| 430 | { |
---|
| 431 | gwriter.writeEdgeMap(it->first, *(it->second)); |
---|
| 432 | } |
---|
[53] | 433 | } |
---|
[98] | 434 | |
---|
| 435 | GuiWriter gui_writer(gwriter, this); |
---|
| 436 | |
---|
[53] | 437 | gwriter.run(); |
---|
| 438 | } |
---|
| 439 | |
---|
| 440 | void MapStorage::clear() |
---|
| 441 | { |
---|
| 442 | for (std::map<std::string, Graph::NodeMap<double>*>::iterator it = |
---|
| 443 | nodemap_storage.begin(); it != nodemap_storage.end(); ++it) |
---|
| 444 | { |
---|
| 445 | if ((it->first != "coordinates_x") && |
---|
| 446 | (it->first != "coordinates_y") && |
---|
[134] | 447 | (it->first != "label")) |
---|
[53] | 448 | { |
---|
| 449 | delete it->second; |
---|
| 450 | nodemap_storage.erase(it); |
---|
| 451 | } |
---|
| 452 | } |
---|
| 453 | for (std::map<std::string, Graph::EdgeMap<double>*>::iterator it = |
---|
| 454 | edgemap_storage.begin(); it != edgemap_storage.end(); ++it) |
---|
| 455 | { |
---|
[134] | 456 | if ((it->first != "label") && |
---|
[98] | 457 | (it->first != "arrow_pos_x") && |
---|
| 458 | (it->first != "arrow_pos_y")) |
---|
[53] | 459 | { |
---|
| 460 | delete it->second; |
---|
| 461 | edgemap_storage.erase(it); |
---|
| 462 | } |
---|
| 463 | } |
---|
[63] | 464 | for (std::map<std::string, double>::iterator it = |
---|
| 465 | nodemap_default.begin(); it != nodemap_default.end(); ++it) |
---|
| 466 | { |
---|
[134] | 467 | if (it->first != "label") |
---|
[64] | 468 | nodemap_default.erase(it); |
---|
[63] | 469 | } |
---|
| 470 | for (std::map<std::string, double>::iterator it = |
---|
| 471 | edgemap_default.begin(); it != edgemap_default.end(); ++it) |
---|
| 472 | { |
---|
[134] | 473 | if (it->first != "label") |
---|
[64] | 474 | edgemap_default.erase(it); |
---|
[63] | 475 | } |
---|
[53] | 476 | graph.clear(); |
---|
| 477 | file_name = ""; |
---|
| 478 | modified = false; |
---|
[172] | 479 | |
---|
| 480 | arrow_pos_read_ok = false; |
---|
| 481 | |
---|
| 482 | for(int i=0;i<NODE_PROPERTY_NUM;i++) |
---|
| 483 | { |
---|
| 484 | changeActiveMap(false, i, ""); |
---|
| 485 | signal_map_win.emit(false, i, ""); |
---|
| 486 | } |
---|
| 487 | |
---|
| 488 | for(int i=0;i<EDGE_PROPERTY_NUM;i++) |
---|
| 489 | { |
---|
| 490 | changeActiveMap(true, i, ""); |
---|
| 491 | signal_map_win.emit(true, i, ""); |
---|
| 492 | } |
---|
[177] | 493 | |
---|
| 494 | attraction=a_d; |
---|
| 495 | propulsation=p_d; |
---|
| 496 | iterations=i_d; |
---|
| 497 | |
---|
| 498 | signal_design_win.emit(attraction, propulsation, iterations); |
---|
[53] | 499 | } |
---|
[98] | 500 | |
---|
| 501 | void MapStorage::ArrowPosReadOK() |
---|
| 502 | { |
---|
| 503 | arrow_pos_read_ok = true; |
---|
| 504 | } |
---|
[111] | 505 | |
---|
| 506 | void MapStorage::mapChanged(bool itisedge, std::string mapname) |
---|
| 507 | { |
---|
| 508 | if(itisedge) |
---|
| 509 | { |
---|
| 510 | for(int i=0;i<EDGE_PROPERTY_NUM;i++) |
---|
| 511 | { |
---|
| 512 | if(active_edgemaps[i]==mapname) |
---|
| 513 | { |
---|
| 514 | signal_prop.emit(itisedge, i); |
---|
| 515 | } |
---|
| 516 | } |
---|
| 517 | } |
---|
| 518 | else |
---|
| 519 | { |
---|
| 520 | for(int i=0;i<NODE_PROPERTY_NUM;i++) |
---|
| 521 | { |
---|
| 522 | if(active_nodemaps[i]==mapname) |
---|
| 523 | { |
---|
| 524 | signal_prop.emit(itisedge, i); |
---|
| 525 | } |
---|
| 526 | } |
---|
| 527 | } |
---|
| 528 | } |
---|
[177] | 529 | |
---|
| 530 | void MapStorage::get_design_data(double & attraction_p, double & propulsation_p, int & iterations_p) |
---|
| 531 | { |
---|
| 532 | attraction_p=attraction; |
---|
| 533 | propulsation_p=propulsation; |
---|
| 534 | iterations_p=iterations; |
---|
| 535 | } |
---|
| 536 | |
---|
| 537 | void MapStorage::set_attraction(double attraction_p) |
---|
| 538 | { |
---|
| 539 | attraction=attraction_p; |
---|
| 540 | } |
---|
| 541 | |
---|
| 542 | void MapStorage::set_propulsation(double propulsation_p) |
---|
| 543 | { |
---|
| 544 | propulsation=propulsation_p; |
---|
| 545 | } |
---|
| 546 | |
---|
| 547 | void MapStorage::set_iteration(int iterations_p) |
---|
| 548 | { |
---|
| 549 | iterations=iterations_p; |
---|
| 550 | } |
---|
| 551 | |
---|
| 552 | void MapStorage::redesign_data_changed() |
---|
| 553 | { |
---|
| 554 | signal_design_win.emit(attraction, propulsation, iterations); |
---|
| 555 | } |
---|
[184] | 556 | |
---|
| 557 | void MapStorage::setBackground(const std::string& file_name) |
---|
| 558 | { |
---|
| 559 | if (file_name == background_file_name) return; |
---|
| 560 | if (file_name == "") |
---|
| 561 | { |
---|
| 562 | background_file_name = ""; |
---|
| 563 | background_set = false; |
---|
| 564 | } |
---|
| 565 | else |
---|
| 566 | { |
---|
| 567 | background_file_name = file_name; |
---|
| 568 | background_set = true; |
---|
| 569 | } |
---|
| 570 | mytab.gd_canvas->setBackground(); |
---|
| 571 | } |
---|
| 572 | |
---|
| 573 | const std::string& MapStorage::getBackgroundFilename() |
---|
| 574 | { |
---|
| 575 | return background_file_name; |
---|
| 576 | } |
---|
| 577 | |
---|
| 578 | bool MapStorage::isBackgroundSet() |
---|
| 579 | { |
---|
| 580 | return background_set; |
---|
| 581 | } |
---|
| 582 | |
---|
| 583 | double MapStorage::getBackgroundScaling() |
---|
| 584 | { |
---|
| 585 | return background_scaling; |
---|
| 586 | } |
---|
| 587 | |
---|
| 588 | void MapStorage::setBackgroundScaling(double scaling) |
---|
| 589 | { |
---|
| 590 | background_scaling = scaling; |
---|
| 591 | } |
---|