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