gui/mapstorage.cc
author hegyi
Wed, 29 Jun 2005 19:44:30 +0000
changeset 1525 6d94de269ab1
parent 1524 587a823bcdd0
child 1597 15b51d278bf0
permissions -rw-r--r--
Uh, long comment arrives... Zoom update does not happen after editorial steps. Nodes initial color is light blue, if there is any item under them. Strange node-text relations disappeared. Initial values of new items are given now in a more common way. The wood-cutter way of handling default values of properties is now changed.
     1 #include <mapstorage.h>
     2 
     3 MapStorage::MapStorage(Graph & graph):g(graph)
     4 {
     5 };
     6 
     7 int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap<double> *nodemap)
     8 {
     9   nodemap_storage[name]=nodemap;
    10   return 0;
    11 }
    12 
    13 int MapStorage::addEdgeMap(const std::string & name, Graph::EdgeMap<double> *edgemap)
    14 {
    15   edgemap_storage[name]=edgemap;
    16   return 0;
    17 }
    18 
    19 double MapStorage::maxOfNodeMap(const std::string & name)
    20 {
    21   double max=0;
    22   for (NodeIt j(g); j!=INVALID; ++j)
    23   {
    24     if( (*nodemap_storage[name])[j]>max )
    25     {
    26       max=(*nodemap_storage[name])[j];
    27     }
    28   }
    29   return max;
    30 }
    31 
    32 double MapStorage::maxOfEdgeMap(const std::string & name)
    33 {
    34   double max=0;
    35   for (EdgeIt j(g); j!=INVALID; ++j)
    36   {
    37     if( (*edgemap_storage[name])[j]>max )
    38     {
    39       max=(*edgemap_storage[name])[j];
    40     }
    41   }
    42   return max;
    43 }
    44 
    45 double MapStorage::minOfNodeMap(const std::string & name)
    46 {
    47   NodeIt j(g);
    48   double min=(*nodemap_storage[name])[j];
    49   for (; j!=INVALID; ++j)
    50   {
    51     if( (*nodemap_storage[name])[j]<min )
    52     {
    53       min=(*nodemap_storage[name])[j];
    54     }
    55   }
    56   return min;
    57 }
    58 
    59 double MapStorage::minOfEdgeMap(const std::string & name)
    60 {
    61   EdgeIt j(g);
    62   double min=(*edgemap_storage[name])[j];
    63   for (EdgeIt j(g); j!=INVALID; ++j)
    64   {
    65     if( (*edgemap_storage[name])[j]<min )
    66     {
    67       min=(*edgemap_storage[name])[j];
    68     }
    69   }
    70   return min;
    71 }
    72 
    73 void MapStorage::initMapsForEdge(Graph::Edge e)
    74 {
    75   std::map< std::string,Graph::EdgeMap<double> * >::iterator ems_it;
    76   for(ems_it=edgemap_storage.begin();ems_it!=edgemap_storage.end();ems_it++)
    77     {
    78       (*((*ems_it).second))[e]=5;
    79     }
    80 }