gui/mapstorage.cc
author hegyi
Fri, 17 Jun 2005 12:25:53 +0000
changeset 1501 39d59aee2a1a
parent 1440 3d2e3cfb2a6c
child 1509 f9113440b667
permissions -rw-r--r--
Very small bug is corrected: if node creator tool is active, the small red arrows won't move, if you click on them and if you drag the newly created node... 'was hard to notice it :-)
ladanyi@1442
     1
#include <mapstorage.h>
ladanyi@1442
     2
ladanyi@1442
     3
MapStorage::MapStorage(Graph & graph):g(graph)
ladanyi@1442
     4
{
ladanyi@1442
     5
  for(int i=0;i<PROPERTY_NUM;i++)
ladanyi@1442
     6
  {
ladanyi@1442
     7
    Graph::EdgeMap<double> emd(g);
ladanyi@1442
     8
    default_edgemaps.push_back(emd);
ladanyi@1442
     9
    Graph::NodeMap<double> nmd(g);
ladanyi@1442
    10
    default_nodemaps.push_back(nmd);
ladanyi@1442
    11
  }
ladanyi@1442
    12
  for(int i=0;i<PROPERTY_NUM;i++)
ladanyi@1442
    13
  {
ladanyi@1442
    14
      for (EdgeIt j(g); j!=INVALID; ++j)
ladanyi@1442
    15
      {
ladanyi@1442
    16
	(default_edgemaps[i])[j]=property_defaults[i];
ladanyi@1442
    17
      }
ladanyi@1442
    18
      addEdgeMap(property_strings[i],&(default_edgemaps[i]));
ladanyi@1442
    19
  }
ladanyi@1442
    20
ladanyi@1442
    21
};
ladanyi@1442
    22
ladanyi@1442
    23
int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap<double> *nodemap)
ladanyi@1442
    24
{
ladanyi@1442
    25
  nodemap_storage[name]=nodemap;
ladanyi@1442
    26
  return 0;
ladanyi@1442
    27
}
ladanyi@1442
    28
ladanyi@1442
    29
int MapStorage::addEdgeMap(const std::string & name, Graph::EdgeMap<double> *edgemap)
ladanyi@1442
    30
{
ladanyi@1442
    31
  edgemap_storage[name]=edgemap;
ladanyi@1442
    32
  return 0;
ladanyi@1442
    33
}
ladanyi@1442
    34
ladanyi@1442
    35
double MapStorage::maxOfNodeMap(const std::string & name)
ladanyi@1442
    36
{
ladanyi@1442
    37
  double max=0;
ladanyi@1442
    38
  for (NodeIt j(g); j!=INVALID; ++j)
ladanyi@1442
    39
  {
ladanyi@1442
    40
    if( (*nodemap_storage[name])[j]>max )
ladanyi@1442
    41
    {
ladanyi@1442
    42
      max=(*nodemap_storage[name])[j];
ladanyi@1442
    43
    }
ladanyi@1442
    44
  }
ladanyi@1442
    45
  return max;
ladanyi@1442
    46
}
ladanyi@1442
    47
ladanyi@1442
    48
double MapStorage::maxOfEdgeMap(const std::string & name)
ladanyi@1442
    49
{
ladanyi@1442
    50
  double max=0;
ladanyi@1442
    51
  for (EdgeIt j(g); j!=INVALID; ++j)
ladanyi@1442
    52
  {
ladanyi@1442
    53
    if( (*edgemap_storage[name])[j]>max )
ladanyi@1442
    54
    {
ladanyi@1442
    55
      max=(*edgemap_storage[name])[j];
ladanyi@1442
    56
    }
ladanyi@1442
    57
  }
ladanyi@1442
    58
  return max;
ladanyi@1442
    59
}
ladanyi@1442
    60
ladanyi@1442
    61
double MapStorage::minOfNodeMap(const std::string & name)
ladanyi@1442
    62
{
ladanyi@1442
    63
  NodeIt j(g);
ladanyi@1442
    64
  double min=(*nodemap_storage[name])[j];
ladanyi@1442
    65
  for (; j!=INVALID; ++j)
ladanyi@1442
    66
  {
ladanyi@1442
    67
    if( (*nodemap_storage[name])[j]<min )
ladanyi@1442
    68
    {
ladanyi@1442
    69
      min=(*nodemap_storage[name])[j];
ladanyi@1442
    70
    }
ladanyi@1442
    71
  }
ladanyi@1442
    72
  return min;
ladanyi@1442
    73
}
ladanyi@1442
    74
ladanyi@1442
    75
double MapStorage::minOfEdgeMap(const std::string & name)
ladanyi@1442
    76
{
ladanyi@1442
    77
  EdgeIt j(g);
ladanyi@1442
    78
  double min=(*edgemap_storage[name])[j];
ladanyi@1442
    79
  for (EdgeIt j(g); j!=INVALID; ++j)
ladanyi@1442
    80
  {
ladanyi@1442
    81
    if( (*edgemap_storage[name])[j]<min )
ladanyi@1442
    82
    {
ladanyi@1442
    83
      min=(*edgemap_storage[name])[j];
ladanyi@1442
    84
    }
ladanyi@1442
    85
  }
ladanyi@1442
    86
  return min;
ladanyi@1442
    87
}
ladanyi@1442
    88