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