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