gui/mapstorage.h
author hegyi
Mon, 09 Jan 2006 12:41:06 +0000
changeset 1887 22fdc00894aa
parent 1878 409a31271efd
child 1888 eed01ce27087
permissions -rw-r--r--
The tree that is created for evaluation of expression string at new map creation is deleted after usage.
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@1878
    63
  sigc::signal<void, std::string> signal_node_map;
hegyi@1878
    64
  sigc::signal<void, std::string> signal_edge_map;
hegyi@1837
    65
ladanyi@1442
    66
public:
ladanyi@1442
    67
  ///Constructor of MapStorage. Expects the Graph of
ladanyi@1442
    68
  ///which maps will be stored in it.
ladanyi@1442
    69
  ///Its all activity is initializing default values
ladanyi@1442
    70
  ///for different visualization attributes
ladanyi@1442
    71
  ///
ladanyi@1442
    72
  ///\param graph is the graph for which the maps are stored in this object.
ladanyi@1606
    73
  MapStorage();
ladanyi@1606
    74
ladanyi@1606
    75
  ~MapStorage();
ladanyi@1442
    76
hegyi@1837
    77
  void changeActiveMap(bool, int, std::string);
hegyi@1837
    78
hegyi@1837
    79
  std::string getActiveEdgeMap(int);
hegyi@1837
    80
  std::string getActiveNodeMap(int);
hegyi@1837
    81
hegyi@1837
    82
  std::vector<std::string> getEdgeMapList();
hegyi@1837
    83
  std::vector<std::string> getNodeMapList();
hegyi@1837
    84
hegyi@1837
    85
  Signal_Prop signal_prop_ch();
hegyi@1837
    86
hegyi@1878
    87
  sigc::signal<void, std::string> signal_node_map_ch(){return signal_node_map;};
hegyi@1878
    88
  sigc::signal<void, std::string> signal_edge_map_ch(){return signal_edge_map;};
hegyi@1878
    89
ladanyi@1442
    90
  ///Adds given map to storage. A name and the map itself has to be provided.
ladanyi@1442
    91
  ///\param name is the name of map
ladanyi@1442
    92
  ///\nodemap is the pointer of the given nodemap
ladanyi@1442
    93
  ///\todo map should be given by reference!
ladanyi@1645
    94
  int addNodeMap(const std::string &,Graph::NodeMap<double> *, double);
ladanyi@1442
    95
ladanyi@1442
    96
  ///Adds given map to storage. A name and the map itself has to be provided.
ladanyi@1442
    97
  ///\param name is the name of map
ladanyi@1442
    98
  ///\edgemap is the pointer of the given edgemap
ladanyi@1442
    99
  ///\todo map should be given by reference!
ladanyi@1645
   100
  int addEdgeMap(const std::string &,Graph::EdgeMap<double> *, double);
ladanyi@1442
   101
ladanyi@1442
   102
  ///Returns how much nodemaps is stored in \ref MapStorage
ladanyi@1442
   103
  int numOfNodeMaps() {return nodemap_storage.size();};
ladanyi@1442
   104
ladanyi@1442
   105
  ///Returns how much edgemaps is stored in \ref MapStorage
ladanyi@1442
   106
  int numOfEdgeMaps() {return edgemap_storage.size();};
ladanyi@1442
   107
ladanyi@1442
   108
  ///Returns the maximum value of the given NodeMap. NodeMap has to be given by its name.
ladanyi@1442
   109
  ///\param name is the name of map of which maximum is searched
ladanyi@1442
   110
  double maxOfNodeMap(const std::string &);
ladanyi@1442
   111
ladanyi@1442
   112
  ///Returns the maximum value of the given EdgeMap. EdgeMap has to be given by its name.
ladanyi@1442
   113
  ///\param name is the name of map of which maximum is searched
ladanyi@1442
   114
  double maxOfEdgeMap(const std::string &);
ladanyi@1442
   115
ladanyi@1442
   116
  ///Returns the minimum value of the given NodeMap. NodeMap has to be given by its name.
ladanyi@1442
   117
  ///\param name is the name of map of which minimum is searched
ladanyi@1442
   118
  double minOfNodeMap(const std::string &);
ladanyi@1442
   119
ladanyi@1442
   120
  ///Returns the minimum value of the given EdgeMap. EdgeMap has to be given by its name.
ladanyi@1442
   121
  ///\param name is the name of map of which minimum is searched
ladanyi@1442
   122
  double minOfEdgeMap(const std::string &);
ladanyi@1442
   123
ladanyi@1442
   124
  ///To be able to iterate through each maps this function returns an iterator pointing to the first nodemap in the storage.
ladanyi@1442
   125
  std::map< std::string,Graph::NodeMap<double> * >::iterator beginOfNodeMaps(){return nodemap_storage.begin();};
ladanyi@1442
   126
ladanyi@1442
   127
  ///To be able to iterate through each maps this function returns an iterator pointing to the first edgemap in the storage.
ladanyi@1442
   128
  std::map< std::string,Graph::EdgeMap<double> * >::iterator beginOfEdgeMaps(){return edgemap_storage.begin();};
hegyi@1509
   129
hegyi@1525
   130
  ///To be able to iterate through each maps this function returns an iterator pointing to the last nodemap in the storage.
hegyi@1525
   131
  std::map< std::string,Graph::NodeMap<double> * >::iterator endOfNodeMaps(){return nodemap_storage.end();};
hegyi@1525
   132
hegyi@1525
   133
  ///To be able to iterate through each maps this function returns an iterator pointing to the last edgemap in the storage.
hegyi@1525
   134
  std::map< std::string,Graph::EdgeMap<double> * >::iterator endOfEdgeMaps(){return edgemap_storage.end();};
hegyi@1525
   135
hegyi@1881
   136
  void mapChanged(bool, std::string);
hegyi@1881
   137
ladanyi@1645
   138
  int readFromFile(const std::string &);
ladanyi@1606
   139
  void writeToFile(const std::string &);
ladanyi@1606
   140
ladanyi@1606
   141
  void clear();
ladanyi@1860
   142
ladanyi@1860
   143
  void ArrowPosReadOK();
ladanyi@1442
   144
};
ladanyi@1442
   145
ladanyi@1442
   146
#endif //MAPSTORAGE_H