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