mapstorage.h
branchgui
changeset 118 cfd49e5c8723
parent 111 ab3107255754
child 172 fc1e478697d3
     1.1 --- a/mapstorage.h	Mon Jan 09 12:41:06 2006 +0000
     1.2 +++ b/mapstorage.h	Tue Jan 10 15:15:57 2006 +0000
     1.3 @@ -9,6 +9,8 @@
     1.4  #include "xymap.h"
     1.5  #include <libgnomecanvasmm.h>
     1.6  
     1.7 +///class MapStorage handles NodeMaps and EdgeMaps.
     1.8 +
     1.9  ///Class MapStorage is responsible for storing
    1.10  ///NodeMaps and EdgeMaps that can be shown later
    1.11  ///on GUI. Therefore maps can be added to it,
    1.12 @@ -22,13 +24,17 @@
    1.13  {
    1.14  public:
    1.15  
    1.16 +  ///The graph for which the datas are stored.
    1.17    Graph graph;
    1.18    /// the coordinates of the nodes
    1.19    XYMap<Graph::NodeMap<double> > coords;
    1.20    /// the coordinates of the arrows on the edges
    1.21    XYMap<Graph::EdgeMap<double> > arrow_pos;
    1.22  
    1.23 +  ///The content of the object has changed, update is needed.
    1.24    bool modified;
    1.25 +
    1.26 +  ///Name of file loaded in object.
    1.27    std::string file_name;
    1.28  
    1.29    ///Stores double type NodeMaps
    1.30 @@ -37,67 +43,119 @@
    1.31    ///Stores double type EdgeMaps
    1.32    std::map< std::string,Graph::EdgeMap<double> * > edgemap_storage;
    1.33  
    1.34 -  //Stores the default values for the different visualization node attributes
    1.35 +  ///Stores the default values for the different visualization node attributes
    1.36    std::vector<Graph::NodeMap<double> > default_nodemaps;
    1.37  
    1.38 -  //Stores the default values for the different visualization edge attributes
    1.39 +  ///Stores the default values for the different visualization edge attributes
    1.40    std::vector<Graph::EdgeMap<double> > default_edgemaps;
    1.41  
    1.42 -  //Stores the active maps for the different visualization node attributes
    1.43 +  ///Stores the active maps for the different visualization node attributes
    1.44    std::vector< std::string > active_nodemaps;
    1.45  
    1.46 -  //Stores the active maps for the different visualization edge attributes
    1.47 +  /// Stores the active maps for the different visualization edge attributes
    1.48    std::vector< std::string > active_edgemaps;
    1.49  
    1.50 -  // Default values for the maps
    1.51 +  /// Default values for the maps
    1.52    std::map< std::string, double > nodemap_default;
    1.53  
    1.54 -  // Default values for the maps
    1.55 +  /// Default values for the maps
    1.56    std::map< std::string, double > edgemap_default;
    1.57  
    1.58    bool arrow_pos_read_ok;
    1.59  
    1.60  protected:
    1.61 +  /// type of the signal emitted if the visualization of the maps might have to be updated.
    1.62 +
    1.63 +  /// bool shows us whether the changed map is edge or nodemap.
    1.64 +  /// int tells us the refreshed property
    1.65    typedef sigc::signal<void, bool, int> Signal_Prop;
    1.66 +
    1.67 +  /// Signal emitted on any change made on map values
    1.68    Signal_Prop signal_prop;
    1.69 +
    1.70 +  /// Signal emitted in the case of nodemap addition
    1.71 +
    1.72 +  /// std::string is the
    1.73 +  ///name of the new map
    1.74    sigc::signal<void, std::string> signal_node_map;
    1.75 +
    1.76 +  /// Signal emitted in the case of edgemap addition
    1.77 +
    1.78 +  /// std::string is the
    1.79 +  ///name of the new map
    1.80    sigc::signal<void, std::string> signal_edge_map;
    1.81  
    1.82  public:
    1.83 -  ///Constructor of MapStorage. Expects the Graph of
    1.84 -  ///which maps will be stored in it.
    1.85 +  ///Constructor of MapStorage.
    1.86 +
    1.87    ///Its all activity is initializing default values
    1.88 -  ///for different visualization attributes
    1.89 -  ///
    1.90 -  ///\param graph is the graph for which the maps are stored in this object.
    1.91 +  ///for different visualization attributes.
    1.92    MapStorage();
    1.93  
    1.94 +  ///Destructor of MapStorage
    1.95 +
    1.96 +  ///Maps stored here are created with new. Destructor
    1.97 +  ///deletes them to free up the reserved memory.
    1.98    ~MapStorage();
    1.99  
   1.100 -  void changeActiveMap(bool, int, std::string);
   1.101 +  /// Registrates if the shown map by any attribute has changed to another.
   1.102  
   1.103 -  std::string getActiveEdgeMap(int);
   1.104 -  std::string getActiveNodeMap(int);
   1.105 +  ///It handles the \ref active_edgemaps and
   1.106 +  ///\ref active_nodemaps vectors. It also emits \ref signal_prop signal to let
   1.107 +  ///know the interested objects that the visible map of a certain
   1.108 +  ///attribute has changed.
   1.109 +  ///\param itisedge edgemap or nodemap has changed
   1.110 +  ///\param prop the property of which the map is changed
   1.111 +  ///\param mapname the visible map
   1.112 +  void changeActiveMap(bool itisedge , int prop , std::string mapname);
   1.113  
   1.114 +  /// Returns the active edgemap shown by a visualization property.
   1.115 +
   1.116 +  /// \param prop is the property
   1.117 +  ///that shows the requested map.
   1.118 +  std::string getActiveEdgeMap(int prop);
   1.119 +
   1.120 +  /// Returns the active nodemap shown by a visualization property.
   1.121 +
   1.122 +  /// \param prop is the property
   1.123 +  ///that shows the requested map.
   1.124 +  std::string getActiveNodeMap(int prop);
   1.125 +
   1.126 +  /// Returns the names of the edgemaps stored here.
   1.127    std::vector<std::string> getEdgeMapList();
   1.128 +
   1.129 +  /// Returns the names of the nodemaps stored here.
   1.130    std::vector<std::string> getNodeMapList();
   1.131  
   1.132 +  ///returns \ref signal_prop to be able to connect functions to it
   1.133    Signal_Prop signal_prop_ch();
   1.134  
   1.135 +  ///returns \ref signal_node_map to be able to connect functions to it
   1.136    sigc::signal<void, std::string> signal_node_map_ch(){return signal_node_map;};
   1.137 +
   1.138 +  ///returns \ref signal_edge_map to be able to connect functions to it
   1.139    sigc::signal<void, std::string> signal_edge_map_ch(){return signal_edge_map;};
   1.140  
   1.141 -  ///Adds given map to storage. A name and the map itself has to be provided.
   1.142 -  ///\param name is the name of map
   1.143 -  ///\nodemap is the pointer of the given nodemap
   1.144 +  ///Adds given map to storage.
   1.145 +
   1.146 +  ///A name and the map itself has to be provided.
   1.147 +  ///\param mapname is the name of map
   1.148 +  ///\param nodemap is the pointer of the given nodemap
   1.149 +  ///\param def the default value of the map. If not given, it will be 0.
   1.150 +  ///If new edge is added to graph the value of it in the map will be this.
   1.151    ///\todo map should be given by reference!
   1.152 -  int addNodeMap(const std::string &,Graph::NodeMap<double> *, double);
   1.153 +  ///\todo why is default value stored?
   1.154 +  int addNodeMap(const std::string & mapname,Graph::NodeMap<double> * nodemap, double def=0.0);
   1.155  
   1.156    ///Adds given map to storage. A name and the map itself has to be provided.
   1.157 -  ///\param name is the name of map
   1.158 -  ///\edgemap is the pointer of the given edgemap
   1.159 +
   1.160 +  ///A name and the map itself has to be provided.
   1.161 +  ///\param mapname is the name of map
   1.162 +  ///\param edgemap is the pointer of the given edgemap
   1.163 +  ///\param def the default value of the map. If not given, it will be 0.
   1.164 +  ///If new edge is added to graph the value of it in the map will be this.
   1.165    ///\todo map should be given by reference!
   1.166 -  int addEdgeMap(const std::string &,Graph::EdgeMap<double> *, double);
   1.167 +  int addEdgeMap(const std::string & mapname,Graph::EdgeMap<double> * edgemap, double def=0.0);
   1.168  
   1.169    ///Returns how much nodemaps is stored in \ref MapStorage
   1.170    int numOfNodeMaps() {return nodemap_storage.size();};
   1.171 @@ -105,39 +163,74 @@
   1.172    ///Returns how much edgemaps is stored in \ref MapStorage
   1.173    int numOfEdgeMaps() {return edgemap_storage.size();};
   1.174  
   1.175 -  ///Returns the maximum value of the given NodeMap. NodeMap has to be given by its name.
   1.176 -  ///\param name is the name of map of which maximum is searched
   1.177 -  double maxOfNodeMap(const std::string &);
   1.178 +  ///Returns the maximum value of the given NodeMap.
   1.179  
   1.180 -  ///Returns the maximum value of the given EdgeMap. EdgeMap has to be given by its name.
   1.181 -  ///\param name is the name of map of which maximum is searched
   1.182 -  double maxOfEdgeMap(const std::string &);
   1.183 +  ///NodeMap has to be given by its name.
   1.184 +  ///\param name the name of map of which maximum is searched
   1.185 +  double maxOfNodeMap(const std::string & name);
   1.186  
   1.187 -  ///Returns the minimum value of the given NodeMap. NodeMap has to be given by its name.
   1.188 -  ///\param name is the name of map of which minimum is searched
   1.189 -  double minOfNodeMap(const std::string &);
   1.190 +  ///Returns the maximum value of the given EdgeMap.
   1.191  
   1.192 -  ///Returns the minimum value of the given EdgeMap. EdgeMap has to be given by its name.
   1.193 -  ///\param name is the name of map of which minimum is searched
   1.194 -  double minOfEdgeMap(const std::string &);
   1.195 +  ///EdgeMap has to be given by its name.
   1.196 +  ///\param name the name of map of which maximum is searched
   1.197 +  double maxOfEdgeMap(const std::string & name);
   1.198  
   1.199 -  ///To be able to iterate through each maps this function returns an iterator pointing to the first nodemap in the storage.
   1.200 +  ///Returns the minimum value of the given NodeMap.
   1.201 +
   1.202 +  ///NodeMap has to be given by its name.
   1.203 +  ///\param name the name of map of which minimum is searched
   1.204 +  double minOfNodeMap(const std::string & name);
   1.205 +
   1.206 +  ///Returns the minimum value of the given EdgeMap.
   1.207 +
   1.208 +  ///EdgeMap has to be given by its name.
   1.209 +  ///\param name the name of map of which minimum is searched
   1.210 +  double minOfEdgeMap(const std::string & name);
   1.211 +
   1.212 +  ///Returns iterator pointing to the first NodeMap in storage.
   1.213 +
   1.214 +  ///To be able to iterate through each maps this function
   1.215 +  ///returns an iterator pointing to the first nodemap in
   1.216 +  ///the storage.
   1.217    std::map< std::string,Graph::NodeMap<double> * >::iterator beginOfNodeMaps(){return nodemap_storage.begin();};
   1.218  
   1.219 -  ///To be able to iterate through each maps this function returns an iterator pointing to the first edgemap in the storage.
   1.220 +  ///Returns iterator pointing to the first EdgeMap in storage.
   1.221 +
   1.222 +  ///To be able to iterate through each maps this function
   1.223 +  ///returns an iterator pointing to the first edgemap in
   1.224 +  ///the storage.
   1.225    std::map< std::string,Graph::EdgeMap<double> * >::iterator beginOfEdgeMaps(){return edgemap_storage.begin();};
   1.226  
   1.227 -  ///To be able to iterate through each maps this function returns an iterator pointing to the last nodemap in the storage.
   1.228 +  ///Returns iterator pointing after the last NodeMap in storage.
   1.229 +
   1.230 +  ///To be able to iterate through each maps this function
   1.231 +  ///returns an iterator pointing to the last nodemap in the storage.
   1.232    std::map< std::string,Graph::NodeMap<double> * >::iterator endOfNodeMaps(){return nodemap_storage.end();};
   1.233  
   1.234 -  ///To be able to iterate through each maps this function returns an iterator pointing to the last edgemap in the storage.
   1.235 +  ///Returns iterator pointing after the last EdgeMap in storage.
   1.236 +
   1.237 +  ///To be able to iterate through each maps this function
   1.238 +  ///returns an iterator pointing to the last edgemap in the storage.
   1.239    std::map< std::string,Graph::EdgeMap<double> * >::iterator endOfEdgeMaps(){return edgemap_storage.end();};
   1.240  
   1.241 -  void mapChanged(bool, std::string);
   1.242 +  ///Emits \ref signal_prop if mapvalues have changed, and MapStorage gets to know it.
   1.243  
   1.244 +  ///If values in a map have changed, this function checks, whether it is displayed.
   1.245 +  ///This check means searching the given mapname between active maps
   1.246 +  ///(\ref active_nodemaps, \ref active_edgemaps). If it is there at a certain property,
   1.247 +  ///it emits a signal with the property, where the gotten mapname was found. One signal
   1.248 +  ///is emitted for each property displaying the given map.
   1.249 +  ///\param itisedge whether the map an edgemap or nodemap
   1.250 +  ///\param mapname name of map to visualize
   1.251 +  void mapChanged(bool itisedge, std::string mapname);
   1.252 +
   1.253 +  ///Read datas from the given filename.
   1.254    int readFromFile(const std::string &);
   1.255 +
   1.256 +  ///Save datas to the given filename.
   1.257    void writeToFile(const std::string &);
   1.258  
   1.259 +  ///Deletes all datastructures stored here.
   1.260    void clear();
   1.261  
   1.262    void ArrowPosReadOK();