mapstorage.h
author ladanyi
Sat, 17 Dec 2005 20:55:41 +0000
branchgui
changeset 98 f60f89147531
parent 94 adfdc2f70548
child 108 bf355fd6563e
permissions -rw-r--r--
Save and load the coordinates of the arrows on the edges.
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@94
    63
ladanyi@6
    64
public:
ladanyi@6
    65
  ///Constructor of MapStorage. Expects the Graph of
ladanyi@6
    66
  ///which maps will be stored in it.
ladanyi@6
    67
  ///Its all activity is initializing default values
ladanyi@6
    68
  ///for different visualization attributes
ladanyi@6
    69
  ///
ladanyi@6
    70
  ///\param graph is the graph for which the maps are stored in this object.
ladanyi@53
    71
  MapStorage();
ladanyi@53
    72
ladanyi@53
    73
  ~MapStorage();
ladanyi@6
    74
hegyi@94
    75
  void changeActiveMap(bool, int, std::string);
hegyi@94
    76
hegyi@94
    77
  std::string getActiveEdgeMap(int);
hegyi@94
    78
  std::string getActiveNodeMap(int);
hegyi@94
    79
hegyi@94
    80
  std::vector<std::string> getEdgeMapList();
hegyi@94
    81
  std::vector<std::string> getNodeMapList();
hegyi@94
    82
hegyi@94
    83
  Signal_Prop signal_prop_ch();
hegyi@94
    84
ladanyi@6
    85
  ///Adds given map to storage. A name and the map itself has to be provided.
ladanyi@6
    86
  ///\param name is the name of map
ladanyi@6
    87
  ///\nodemap is the pointer of the given nodemap
ladanyi@6
    88
  ///\todo map should be given by reference!
ladanyi@63
    89
  int addNodeMap(const std::string &,Graph::NodeMap<double> *, double);
ladanyi@6
    90
ladanyi@6
    91
  ///Adds given map to storage. A name and the map itself has to be provided.
ladanyi@6
    92
  ///\param name is the name of map
ladanyi@6
    93
  ///\edgemap is the pointer of the given edgemap
ladanyi@6
    94
  ///\todo map should be given by reference!
ladanyi@63
    95
  int addEdgeMap(const std::string &,Graph::EdgeMap<double> *, double);
ladanyi@6
    96
ladanyi@6
    97
  ///Returns how much nodemaps is stored in \ref MapStorage
ladanyi@6
    98
  int numOfNodeMaps() {return nodemap_storage.size();};
ladanyi@6
    99
ladanyi@6
   100
  ///Returns how much edgemaps is stored in \ref MapStorage
ladanyi@6
   101
  int numOfEdgeMaps() {return edgemap_storage.size();};
ladanyi@6
   102
ladanyi@6
   103
  ///Returns the maximum value of the given NodeMap. NodeMap has to be given by its name.
ladanyi@6
   104
  ///\param name is the name of map of which maximum is searched
ladanyi@6
   105
  double maxOfNodeMap(const std::string &);
ladanyi@6
   106
ladanyi@6
   107
  ///Returns the maximum value of the given EdgeMap. EdgeMap has to be given by its name.
ladanyi@6
   108
  ///\param name is the name of map of which maximum is searched
ladanyi@6
   109
  double maxOfEdgeMap(const std::string &);
ladanyi@6
   110
ladanyi@6
   111
  ///Returns the minimum value of the given NodeMap. NodeMap has to be given by its name.
ladanyi@6
   112
  ///\param name is the name of map of which minimum is searched
ladanyi@6
   113
  double minOfNodeMap(const std::string &);
ladanyi@6
   114
ladanyi@6
   115
  ///Returns the minimum value of the given EdgeMap. EdgeMap has to be given by its name.
ladanyi@6
   116
  ///\param name is the name of map of which minimum is searched
ladanyi@6
   117
  double minOfEdgeMap(const std::string &);
ladanyi@6
   118
ladanyi@6
   119
  ///To be able to iterate through each maps this function returns an iterator pointing to the first nodemap in the storage.
ladanyi@6
   120
  std::map< std::string,Graph::NodeMap<double> * >::iterator beginOfNodeMaps(){return nodemap_storage.begin();};
ladanyi@6
   121
ladanyi@6
   122
  ///To be able to iterate through each maps this function returns an iterator pointing to the first edgemap in the storage.
ladanyi@6
   123
  std::map< std::string,Graph::EdgeMap<double> * >::iterator beginOfEdgeMaps(){return edgemap_storage.begin();};
hegyi@26
   124
hegyi@31
   125
  ///To be able to iterate through each maps this function returns an iterator pointing to the last nodemap in the storage.
hegyi@31
   126
  std::map< std::string,Graph::NodeMap<double> * >::iterator endOfNodeMaps(){return nodemap_storage.end();};
hegyi@31
   127
hegyi@31
   128
  ///To be able to iterate through each maps this function returns an iterator pointing to the last edgemap in the storage.
hegyi@31
   129
  std::map< std::string,Graph::EdgeMap<double> * >::iterator endOfEdgeMaps(){return edgemap_storage.end();};
hegyi@31
   130
ladanyi@63
   131
  int readFromFile(const std::string &);
ladanyi@53
   132
  void writeToFile(const std::string &);
ladanyi@53
   133
ladanyi@53
   134
  void clear();
ladanyi@98
   135
ladanyi@98
   136
  void ArrowPosReadOK();
ladanyi@6
   137
};
ladanyi@6
   138
ladanyi@6
   139
#endif //MAPSTORAGE_H