gui/mapstorage.h
author alpar
Fri, 02 Dec 2005 10:02:40 +0000
changeset 1843 1e386f4047c9
parent 1645 4a04bb856ac7
child 1860 27a9a75b957b
permissions -rw-r--r--
bugfix
     1 // -*- C++ -*- //
     2 
     3 #ifndef MAPSTORAGE_H
     4 #define MAPSTORAGE_H
     5 
     6 class Mapstorage;
     7 
     8 #include "all_include.h"
     9 #include "xymap.h"
    10 #include <libgnomecanvasmm.h>
    11 
    12 ///Class MapStorage is responsible for storing
    13 ///NodeMaps and EdgeMaps that can be shown later
    14 ///on GUI. Therefore maps can be added to it,
    15 ///and datas over the added maps can be queried.
    16 ///The maps will be stored in an std::map,
    17 ///referenced with their names. Unfortunately at
    18 ///the moment it works only with double type maps
    19 ///
    20 ///\todo too many things are public!!
    21 class MapStorage
    22 {
    23 public:
    24 
    25   Graph graph;
    26   XYMap<Graph::NodeMap<double> > coords;
    27 
    28   bool modified;
    29   std::string file_name;
    30 
    31   ///Stores double type NodeMaps
    32   std::map< std::string,Graph::NodeMap<double> * > nodemap_storage;
    33 
    34   ///Stores double type EdgeMaps
    35   std::map< std::string,Graph::EdgeMap<double> * > edgemap_storage;
    36 
    37   //Stores the default values for the different visualization node attributes
    38   std::vector<Graph::NodeMap<double> > default_nodemaps;
    39 
    40   //Stores the default values for the different visualization edge attributes
    41   std::vector<Graph::EdgeMap<double> > default_edgemaps;
    42 
    43   //Stores the active maps for the different visualization node attributes
    44   std::vector< std::string > active_nodemaps;
    45 
    46   //Stores the active maps for the different visualization edge attributes
    47   std::vector< std::string > active_edgemaps;
    48 
    49   // Default values for the maps
    50   std::map< std::string, double > nodemap_default;
    51 
    52   // Default values for the maps
    53   std::map< std::string, double > edgemap_default;
    54 
    55 protected:
    56   typedef sigc::signal<void, bool, int> Signal_Prop;
    57   Signal_Prop signal_prop;
    58 
    59 public:
    60   ///Constructor of MapStorage. Expects the Graph of
    61   ///which maps will be stored in it.
    62   ///Its all activity is initializing default values
    63   ///for different visualization attributes
    64   ///
    65   ///\param graph is the graph for which the maps are stored in this object.
    66   MapStorage();
    67 
    68   ~MapStorage();
    69 
    70   void changeActiveMap(bool, int, std::string);
    71 
    72   std::string getActiveEdgeMap(int);
    73   std::string getActiveNodeMap(int);
    74 
    75   std::vector<std::string> getEdgeMapList();
    76   std::vector<std::string> getNodeMapList();
    77 
    78   Signal_Prop signal_prop_ch();
    79 
    80   ///Adds given map to storage. A name and the map itself has to be provided.
    81   ///\param name is the name of map
    82   ///\nodemap is the pointer of the given nodemap
    83   ///\todo map should be given by reference!
    84   int addNodeMap(const std::string &,Graph::NodeMap<double> *, double);
    85 
    86   ///Adds given map to storage. A name and the map itself has to be provided.
    87   ///\param name is the name of map
    88   ///\edgemap is the pointer of the given edgemap
    89   ///\todo map should be given by reference!
    90   int addEdgeMap(const std::string &,Graph::EdgeMap<double> *, double);
    91 
    92   ///Returns how much nodemaps is stored in \ref MapStorage
    93   int numOfNodeMaps() {return nodemap_storage.size();};
    94 
    95   ///Returns how much edgemaps is stored in \ref MapStorage
    96   int numOfEdgeMaps() {return edgemap_storage.size();};
    97 
    98   ///Returns the maximum value of the given NodeMap. NodeMap has to be given by its name.
    99   ///\param name is the name of map of which maximum is searched
   100   double maxOfNodeMap(const std::string &);
   101 
   102   ///Returns the maximum value of the given EdgeMap. EdgeMap has to be given by its name.
   103   ///\param name is the name of map of which maximum is searched
   104   double maxOfEdgeMap(const std::string &);
   105 
   106   ///Returns the minimum value of the given NodeMap. NodeMap has to be given by its name.
   107   ///\param name is the name of map of which minimum is searched
   108   double minOfNodeMap(const std::string &);
   109 
   110   ///Returns the minimum value of the given EdgeMap. EdgeMap has to be given by its name.
   111   ///\param name is the name of map of which minimum is searched
   112   double minOfEdgeMap(const std::string &);
   113 
   114   ///To be able to iterate through each maps this function returns an iterator pointing to the first nodemap in the storage.
   115   std::map< std::string,Graph::NodeMap<double> * >::iterator beginOfNodeMaps(){return nodemap_storage.begin();};
   116 
   117   ///To be able to iterate through each maps this function returns an iterator pointing to the first edgemap in the storage.
   118   std::map< std::string,Graph::EdgeMap<double> * >::iterator beginOfEdgeMaps(){return edgemap_storage.begin();};
   119 
   120   ///To be able to iterate through each maps this function returns an iterator pointing to the last nodemap in the storage.
   121   std::map< std::string,Graph::NodeMap<double> * >::iterator endOfNodeMaps(){return nodemap_storage.end();};
   122 
   123   ///To be able to iterate through each maps this function returns an iterator pointing to the last edgemap in the storage.
   124   std::map< std::string,Graph::EdgeMap<double> * >::iterator endOfEdgeMaps(){return edgemap_storage.end();};
   125 
   126   int readFromFile(const std::string &);
   127   void writeToFile(const std::string &);
   128 
   129   void clear();
   130 };
   131 
   132 #endif //MAPSTORAGE_H