If default value of a new map is constant, the newly created elements will get that value as well. Documentation is added to BrokenEdge, MapStorage and GraphDisplazCanvas classes.
1.1 --- a/gui/graph_displayer_canvas.cc Mon Jan 09 12:41:06 2006 +0000
1.2 +++ b/gui/graph_displayer_canvas.cc Tue Jan 10 15:15:57 2006 +0000
1.3 @@ -59,9 +59,9 @@
1.4 }
1.5 }
1.6
1.7 -void GraphDisplayerCanvas::propertyUpdate(Node node, int prop, int dummy)
1.8 +void GraphDisplayerCanvas::propertyUpdate(Node node, int prop)
1.9 {
1.10 - dummy=dummy;
1.11 + //dummy=dummy;
1.12
1.13 std::string mapname=mytab.getActiveNodeMap(prop);
1.14
1.15 @@ -106,9 +106,9 @@
1.16
1.17 }
1.18
1.19 -void GraphDisplayerCanvas::propertyUpdate(Edge edge, int prop, int dummy)
1.20 +void GraphDisplayerCanvas::propertyUpdate(Edge edge, int prop)
1.21 {
1.22 - dummy=dummy;
1.23 + //dummy=dummy;
1.24
1.25 std::string mapname=mytab.getActiveEdgeMap(prop);
1.26
2.1 --- a/gui/graph_displayer_canvas.h Mon Jan 09 12:41:06 2006 +0000
2.2 +++ b/gui/graph_displayer_canvas.h Tue Jan 10 15:15:57 2006 +0000
2.3 @@ -16,67 +16,180 @@
2.4 {
2.5 friend class BrokenEdge;
2.6
2.7 + ///Edge displayer class
2.8 +
2.9 + ///This class is responsible for displaying edges in graph.
2.10 + ///The displayed edge is broken in the middle. The
2.11 + ///aim of this is to be able to indicate direction of edges
2.12 + ///and to be able to display more then one edges between the
2.13 + ///same source and target
2.14 class BrokenEdge : public Gnome::Canvas::Line
2.15 {
2.16 + ///The edge that the class displays.
2.17 +
2.18 + ///It is needed, because some datas needed from
2.19 + ///graph can be accessed by this or should be sent
2.20 + ///as parameter, but it would be complicated
2.21 Edge edge;
2.22 +
2.23 + ///Reference to the canvas, on which the graph is drawn.
2.24 +
2.25 + ///It is needed, because some datas needed from
2.26 + ///graph can be accessed by this or should be sent
2.27 + ///as parameter, but it would be complicated
2.28 GraphDisplayerCanvas & gdc;
2.29 +
2.30 + ///An arrow that indicates the direction of the edges
2.31 +
2.32 + ///in case of directional graph direction can be indicated
2.33 + ///by this polygon. The polygon formulates a red arrow.
2.34 Gnome::Canvas::Polygon * arrow;
2.35
2.36 - ///Indicates whether the button of mouse is pressed or not
2.37 + ///Indicates whether the button of mouse is pressed or not at the moment.
2.38 bool isbutton;
2.39
2.40 - ///At this location was the mousebutton pressed.
2.41 - ///It helps to calculate the distance of dragging.
2.42 - double clicked_x, clicked_y;
2.43 + ///At this location was the mousebutton pressed. Horizontal component.
2.44
2.45 - ///event handler for forming edges
2.46 - bool edgeFormerEventHandler(GdkEvent*);
2.47 + ///It helps to calculate the
2.48 + ///distance of dragging.
2.49 + double clicked_x;
2.50 +
2.51 + ///At this location was the mousebutton pressed. Vertical component.
2.52 +
2.53 + ///It helps to calculate the
2.54 + ///distance of dragging.
2.55 + double clicked_y;
2.56 +
2.57 + ///event handler for forming broken edges
2.58 +
2.59 + ///\param event the
2.60 + ///event to handle
2.61 + bool edgeFormerEventHandler(GdkEvent* event);
2.62 public:
2.63 - BrokenEdge(Gnome::Canvas::Group &, Edge, GraphDisplayerCanvas &);
2.64 +
2.65 + ///Constructor of broken edge class.
2.66 +
2.67 + ///\param g the group to which the edge belongs
2.68 + ///\param _edge the represented edge
2.69 + ///\param gc the canvas
2.70 + BrokenEdge(Gnome::Canvas::Group & g, Edge _edge, GraphDisplayerCanvas & gc);
2.71 +
2.72 + ///Destructor of broken edge class
2.73 +
2.74 + ///Frees up
2.75 + ///reserved memory
2.76 ~BrokenEdge();
2.77 +
2.78 + ///The function that draws the edge based on collected data
2.79 void draw();
2.80 };
2.81 +
2.82 + ///Type of canvas, on which the graph is drawn
2.83 typedef Gnome::Canvas::CanvasAA Parent;
2.84
2.85 public:
2.86 - GraphDisplayerCanvas(NoteBookTab &);
2.87 + ///Constructor
2.88 +
2.89 + ///\param nbt the tab of the window, in which the graph is displayed
2.90 + GraphDisplayerCanvas(NoteBookTab & nbt);
2.91 +
2.92 + ///destructor of the class
2.93 virtual ~GraphDisplayerCanvas();
2.94
2.95 - ///Changes the linewidth attribute according to the given map.
2.96 + ///Changes the width of edge(s) according to the given map.
2.97 +
2.98 + ///\param mapname is the name of the map which contains the values to be set
2.99 + ///\param edge if it is given, only the width of the given edge will be set, instead of all of them.
2.100 + int changeEdgeWidth (std::string mapname, Edge edge=INVALID);
2.101 +
2.102 + ///Resets width of edge(s) to the default value
2.103 +
2.104 + ///\param edge if it is given, only the width of the
2.105 + ///given edge will be reset, instead of all of them.
2.106 + int resetEdgeWidth (Edge edge=INVALID);
2.107 +
2.108 + ///Changes the color of edge(s) according to the given map.
2.109 +
2.110 ///\param mapname is the name of the map which contains the new values
2.111 - int changeEdgeWidth (std::string mapname, Edge new_item=INVALID);
2.112 - int resetEdgeWidth (Edge new_item=INVALID);
2.113 + ///\param edge if it is given, only the color of the given edge will be set, instead of all of them.
2.114 + int changeEdgeColor (std::string mapname, Edge edge=INVALID);
2.115
2.116 - ///Changes the linecolor attribute according to the given map.
2.117 + ///Resets color of edge(s) to the default value
2.118 +
2.119 + ///\param edge if it is given, only the color of the
2.120 + ///given edge will be reset, instead of all of them.
2.121 + int resetEdgeColor (Edge edge=INVALID);
2.122 +
2.123 + ///Changes the label of edge(s) according to the given map.
2.124 +
2.125 ///\param mapname is the name of the map which contains the new values
2.126 - int changeEdgeColor (std::string mapname, Edge new_item=INVALID);
2.127 - int resetEdgeColor (Edge new_item=INVALID);
2.128 + ///\param edge if it is given, only the label of the given edge will be set, instead of all of them.
2.129 + int changeEdgeText (std::string mapname, Edge edge=INVALID);
2.130
2.131 - ///Changes the text of line attribute according to the given map.
2.132 + ///Resets label of edge(s) to the default value
2.133 +
2.134 + ///\param edge if it is given, only the color of the
2.135 + ///given edge will be reset, instead of all of them.
2.136 + int resetEdgeText (Edge edge=INVALID);
2.137 +
2.138 + ///Changes the radius of node(s) according to the given map.
2.139 +
2.140 ///\param mapname is the name of the map which contains the new values
2.141 - int changeEdgeText (std::string mapname, Edge new_item=INVALID);
2.142 - int resetEdgeText (Edge new_item=INVALID);
2.143 + ///\param node if it is given, only the radius of the given node will be set, instead of all of them.
2.144 + int changeNodeRadius (std::string mapname, Node node=INVALID);
2.145
2.146 - ///Changes the linewidth attribute according to the given map.
2.147 + ///Resets radius of node(s) to the default value
2.148 +
2.149 + ///\param node if it is given, only the radius of the
2.150 + ///given node will be reset, instead of all of them.
2.151 + int resetNodeRadius (Node node=INVALID);
2.152 +
2.153 + ///Changes the color of node(s) according to the given map.
2.154 +
2.155 ///\param mapname is the name of the map which contains the new values
2.156 - int changeNodeRadius (std::string mapname, Node new_item=INVALID);
2.157 - int resetNodeRadius (Node new_item=INVALID);
2.158 + ///\param node if it is given, only the color of the given node will be set, instead of all of them.
2.159 + int changeNodeColor (std::string mapname, Node node=INVALID);
2.160
2.161 - ///Changes the linecolor attribute according to the given map.
2.162 + ///Resets color of node(s) to the default value
2.163 +
2.164 + ///\param node if it is given, only the color of the
2.165 + ///given node will be reset, instead of all of them.
2.166 + int resetNodeColor (Node node=INVALID);
2.167 +
2.168 + ///Changes the label of node(s) according to the given map.
2.169 +
2.170 ///\param mapname is the name of the map which contains the new values
2.171 - int changeNodeColor (std::string mapname, Node new_item=INVALID);
2.172 - int resetNodeColor (Node new_item=INVALID);
2.173 + ///\param node if it is given, only the label of the given node will be set, instead of all of them.
2.174 + int changeNodeText (std::string mapname, Node node=INVALID);
2.175
2.176 - ///Changes the text of line attribute according to the given map.
2.177 - ///\param mapname is the name of the map which contains the new values
2.178 - int changeNodeText (std::string mapname, Node new_item=INVALID);
2.179 - int resetNodeText (Node new_item=INVALID);
2.180 + ///Resets label of node(s) to the default value
2.181
2.182 - void propertyChange(bool, int);
2.183 - void propertyUpdate(Edge, int, int dummy=0);
2.184 - void propertyUpdate(Node, int, int dummy=0);
2.185 + ///\param node if it is given, only the label of the
2.186 + ///given node will be reset, instead of all of them.
2.187 + int resetNodeText (Node node=INVALID);
2.188
2.189 + ///This function is called, when any of the displayed attributes have to be updated, or changed
2.190 +
2.191 + ///\param itisedge if true, edge property has to be changed, else node property
2.192 + ///\param prop the id of property that has to changed or updated
2.193 + void propertyChange(bool itisedge, int prop);
2.194 +
2.195 + ///updates the given property
2.196 +
2.197 + ///\param edge if it is not INVALID, only the property of the given edge will be updated, instead of all of them
2.198 + ///\param prop the property to update
2.199 + void propertyUpdate(Edge edge, int prop);
2.200 +
2.201 + ///updates the given property
2.202 +
2.203 + ///\param node if it is not INVALID, only the property of the given node will be updated, instead of all of them
2.204 + ///\param prop the property to update
2.205 + void propertyUpdate(Node node, int prop);
2.206 +
2.207 + ///updates all the property for the given edge
2.208 void propertyUpdate(Edge);
2.209 +
2.210 + ///updates all the property for the given node
2.211 void propertyUpdate(Node);
2.212
2.213 ///Callback for 'ViewZoomIn' action.
2.214 @@ -95,7 +208,7 @@
2.215
2.216 protected:
2.217
2.218 - //maximizing, minimizing, restoring window, etc.
2.219 + //maximizing, minimizing, restoring window, etc.
2.220 virtual bool on_expose_event(GdkEventExpose *);
2.221
2.222 private:
2.223 @@ -127,26 +240,42 @@
2.224 public:
2.225 ///Moves the text to new place
2.226 void textReposition(xy<double>);
2.227 +
2.228 ///Activates an edge belonging to a BrokenEdge
2.229 - ///
2.230 +
2.231 ///After we have activated an edge this way,
2.232 ///the GDC object will know, which edge is under forming
2.233 - ///therefore it can redraw the necessarz elementy on the canvas,
2.234 + ///therefore it can redraw the necessary elements on the canvas,
2.235 ///for example the text belonging to the \ref BrokenEdge can be
2.236 ///redrawn (\ref textReposition).
2.237 void toggleEdgeActivity(BrokenEdge*, bool);
2.238
2.239 public:
2.240 - ///\return the actual tool in hand
2.241 +
2.242 + ///Returns the actual tool in hand
2.243 int getActualTool();
2.244
2.245 + ///draws the graph
2.246 +
2.247 + ///Called when opening a file.
2.248 void drawGraph();
2.249 +
2.250 + ///Clears the canvas
2.251 +
2.252 + ///It achieves this by deleting all data
2.253 + ///structure used to help handle the displayed graph.
2.254 void clear();
2.255
2.256 ///creates a new Nodemap
2.257 - int addNewNodeMap(double,std::string);
2.258 +
2.259 + ///\param init initial value of the map
2.260 + ///\param mapname name of new map
2.261 + int addNewNodeMap(double init,std::string mapname);
2.262 ///creates a new Edgemap
2.263 - int addNewEdgeMap(double,std::string);
2.264 +
2.265 + ///\param init initial value of the map
2.266 + ///\param mapname name of new map
2.267 + int addNewEdgeMap(double init,std::string mapname);
2.268
2.269 private:
2.270 ///Deletes the given element.
2.271 @@ -183,21 +312,43 @@
2.272 double clicked_x, clicked_y;
2.273
2.274 ///Remembers which Gnome::Canvas::Item was pressed.
2.275 - ///this variable is needed, because
2.276 - ///1. we cannot query the item at he cursor as fast as it could not cause a Segmentation Fault
2.277 - ///2. we would like to handle only ony item per movement, therefore quering it is not a working solution
2.278 - Gnome::Canvas::Item * active_item, * target_item;
2.279 +
2.280 + ///this variable is needed, to work on it after selection
2.281 + Gnome::Canvas::Item * active_item;
2.282 +
2.283 + ///Remembers which Gnome::Canvas::Item was pressed.
2.284 +
2.285 + ///this variable is used at edge creation, it will
2.286 + ///be the secondly selected node. No local variable
2.287 + ///can be used for this purpose inside the function,
2.288 + ///because the node selected by button press, and
2.289 + ///the edge is created by button release. Both of
2.290 + ///them is different function call.
2.291 + Gnome::Canvas::Item * target_item;
2.292 +
2.293 + ///selected node (for any editing)
2.294 Node active_node;
2.295 +
2.296 + ///selected edge (for any editing)
2.297 Edge active_edge;
2.298 +
2.299 + ///the edge that is selected by clicking on the red arrow in the middle of it
2.300 +
2.301 + ///This edge is stored only for the purpose of reshape it.
2.302 + ///That is why it is selected in a different manner.
2.303 Edge forming_edge;
2.304
2.305 - std::string nodemap_to_edit, edgemap_to_edit;
2.306 + ///Map displayed by label can be edited.
2.307 + std::string nodemap_to_edit;
2.308 +
2.309 + ///Map displayed by label can be edited.
2.310 + std::string edgemap_to_edit;
2.311
2.312 static const int zoom_step = 5;
2.313
2.314 private:
2.315
2.316 - ///reference to the parent window
2.317 + ///reference to the container, in which the canvas is
2.318 NoteBookTab & mytab;
2.319
2.320 XY GraphDisplayerCanvas::calcArrowPos(XY, XY, XY, XY, bool);
3.1 --- a/gui/mapstorage.cc Mon Jan 09 12:41:06 2006 +0000
3.2 +++ b/gui/mapstorage.cc Tue Jan 10 15:15:57 2006 +0000
3.3 @@ -51,8 +51,9 @@
3.4 }
3.5 }
3.6
3.7 -int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap<double> *nodemap, double default_value = 0.0)
3.8 +int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap<double> *nodemap, double default_value)
3.9 {
3.10 + std::cout << default_value << std::endl;
3.11 if( nodemap_storage.find(name) == nodemap_storage.end() )
3.12 {
3.13 nodemap_storage[name]=nodemap;
3.14 @@ -122,7 +123,7 @@
3.15 return signal_prop;
3.16 }
3.17
3.18 -int MapStorage::addEdgeMap(const std::string & name, Graph::EdgeMap<double> *edgemap, double default_value = 0.0)
3.19 +int MapStorage::addEdgeMap(const std::string & name, Graph::EdgeMap<double> *edgemap, double default_value)
3.20 {
3.21 if( edgemap_storage.find(name) == edgemap_storage.end() )
3.22 {
4.1 --- a/gui/mapstorage.h Mon Jan 09 12:41:06 2006 +0000
4.2 +++ b/gui/mapstorage.h Tue Jan 10 15:15:57 2006 +0000
4.3 @@ -9,6 +9,8 @@
4.4 #include "xymap.h"
4.5 #include <libgnomecanvasmm.h>
4.6
4.7 +///class MapStorage handles NodeMaps and EdgeMaps.
4.8 +
4.9 ///Class MapStorage is responsible for storing
4.10 ///NodeMaps and EdgeMaps that can be shown later
4.11 ///on GUI. Therefore maps can be added to it,
4.12 @@ -22,13 +24,17 @@
4.13 {
4.14 public:
4.15
4.16 + ///The graph for which the datas are stored.
4.17 Graph graph;
4.18 /// the coordinates of the nodes
4.19 XYMap<Graph::NodeMap<double> > coords;
4.20 /// the coordinates of the arrows on the edges
4.21 XYMap<Graph::EdgeMap<double> > arrow_pos;
4.22
4.23 + ///The content of the object has changed, update is needed.
4.24 bool modified;
4.25 +
4.26 + ///Name of file loaded in object.
4.27 std::string file_name;
4.28
4.29 ///Stores double type NodeMaps
4.30 @@ -37,67 +43,119 @@
4.31 ///Stores double type EdgeMaps
4.32 std::map< std::string,Graph::EdgeMap<double> * > edgemap_storage;
4.33
4.34 - //Stores the default values for the different visualization node attributes
4.35 + ///Stores the default values for the different visualization node attributes
4.36 std::vector<Graph::NodeMap<double> > default_nodemaps;
4.37
4.38 - //Stores the default values for the different visualization edge attributes
4.39 + ///Stores the default values for the different visualization edge attributes
4.40 std::vector<Graph::EdgeMap<double> > default_edgemaps;
4.41
4.42 - //Stores the active maps for the different visualization node attributes
4.43 + ///Stores the active maps for the different visualization node attributes
4.44 std::vector< std::string > active_nodemaps;
4.45
4.46 - //Stores the active maps for the different visualization edge attributes
4.47 + /// Stores the active maps for the different visualization edge attributes
4.48 std::vector< std::string > active_edgemaps;
4.49
4.50 - // Default values for the maps
4.51 + /// Default values for the maps
4.52 std::map< std::string, double > nodemap_default;
4.53
4.54 - // Default values for the maps
4.55 + /// Default values for the maps
4.56 std::map< std::string, double > edgemap_default;
4.57
4.58 bool arrow_pos_read_ok;
4.59
4.60 protected:
4.61 + /// type of the signal emitted if the visualization of the maps might have to be updated.
4.62 +
4.63 + /// bool shows us whether the changed map is edge or nodemap.
4.64 + /// int tells us the refreshed property
4.65 typedef sigc::signal<void, bool, int> Signal_Prop;
4.66 +
4.67 + /// Signal emitted on any change made on map values
4.68 Signal_Prop signal_prop;
4.69 +
4.70 + /// Signal emitted in the case of nodemap addition
4.71 +
4.72 + /// std::string is the
4.73 + ///name of the new map
4.74 sigc::signal<void, std::string> signal_node_map;
4.75 +
4.76 + /// Signal emitted in the case of edgemap addition
4.77 +
4.78 + /// std::string is the
4.79 + ///name of the new map
4.80 sigc::signal<void, std::string> signal_edge_map;
4.81
4.82 public:
4.83 - ///Constructor of MapStorage. Expects the Graph of
4.84 - ///which maps will be stored in it.
4.85 + ///Constructor of MapStorage.
4.86 +
4.87 ///Its all activity is initializing default values
4.88 - ///for different visualization attributes
4.89 - ///
4.90 - ///\param graph is the graph for which the maps are stored in this object.
4.91 + ///for different visualization attributes.
4.92 MapStorage();
4.93
4.94 + ///Destructor of MapStorage
4.95 +
4.96 + ///Maps stored here are created with new. Destructor
4.97 + ///deletes them to free up the reserved memory.
4.98 ~MapStorage();
4.99
4.100 - void changeActiveMap(bool, int, std::string);
4.101 + /// Registrates if the shown map by any attribute has changed to another.
4.102
4.103 - std::string getActiveEdgeMap(int);
4.104 - std::string getActiveNodeMap(int);
4.105 + ///It handles the \ref active_edgemaps and
4.106 + ///\ref active_nodemaps vectors. It also emits \ref signal_prop signal to let
4.107 + ///know the interested objects that the visible map of a certain
4.108 + ///attribute has changed.
4.109 + ///\param itisedge edgemap or nodemap has changed
4.110 + ///\param prop the property of which the map is changed
4.111 + ///\param mapname the visible map
4.112 + void changeActiveMap(bool itisedge , int prop , std::string mapname);
4.113
4.114 + /// Returns the active edgemap shown by a visualization property.
4.115 +
4.116 + /// \param prop is the property
4.117 + ///that shows the requested map.
4.118 + std::string getActiveEdgeMap(int prop);
4.119 +
4.120 + /// Returns the active nodemap shown by a visualization property.
4.121 +
4.122 + /// \param prop is the property
4.123 + ///that shows the requested map.
4.124 + std::string getActiveNodeMap(int prop);
4.125 +
4.126 + /// Returns the names of the edgemaps stored here.
4.127 std::vector<std::string> getEdgeMapList();
4.128 +
4.129 + /// Returns the names of the nodemaps stored here.
4.130 std::vector<std::string> getNodeMapList();
4.131
4.132 + ///returns \ref signal_prop to be able to connect functions to it
4.133 Signal_Prop signal_prop_ch();
4.134
4.135 + ///returns \ref signal_node_map to be able to connect functions to it
4.136 sigc::signal<void, std::string> signal_node_map_ch(){return signal_node_map;};
4.137 +
4.138 + ///returns \ref signal_edge_map to be able to connect functions to it
4.139 sigc::signal<void, std::string> signal_edge_map_ch(){return signal_edge_map;};
4.140
4.141 - ///Adds given map to storage. A name and the map itself has to be provided.
4.142 - ///\param name is the name of map
4.143 - ///\nodemap is the pointer of the given nodemap
4.144 + ///Adds given map to storage.
4.145 +
4.146 + ///A name and the map itself has to be provided.
4.147 + ///\param mapname is the name of map
4.148 + ///\param nodemap is the pointer of the given nodemap
4.149 + ///\param def the default value of the map. If not given, it will be 0.
4.150 + ///If new edge is added to graph the value of it in the map will be this.
4.151 ///\todo map should be given by reference!
4.152 - int addNodeMap(const std::string &,Graph::NodeMap<double> *, double);
4.153 + ///\todo why is default value stored?
4.154 + int addNodeMap(const std::string & mapname,Graph::NodeMap<double> * nodemap, double def=0.0);
4.155
4.156 ///Adds given map to storage. A name and the map itself has to be provided.
4.157 - ///\param name is the name of map
4.158 - ///\edgemap is the pointer of the given edgemap
4.159 +
4.160 + ///A name and the map itself has to be provided.
4.161 + ///\param mapname is the name of map
4.162 + ///\param edgemap is the pointer of the given edgemap
4.163 + ///\param def the default value of the map. If not given, it will be 0.
4.164 + ///If new edge is added to graph the value of it in the map will be this.
4.165 ///\todo map should be given by reference!
4.166 - int addEdgeMap(const std::string &,Graph::EdgeMap<double> *, double);
4.167 + int addEdgeMap(const std::string & mapname,Graph::EdgeMap<double> * edgemap, double def=0.0);
4.168
4.169 ///Returns how much nodemaps is stored in \ref MapStorage
4.170 int numOfNodeMaps() {return nodemap_storage.size();};
4.171 @@ -105,39 +163,74 @@
4.172 ///Returns how much edgemaps is stored in \ref MapStorage
4.173 int numOfEdgeMaps() {return edgemap_storage.size();};
4.174
4.175 - ///Returns the maximum value of the given NodeMap. NodeMap has to be given by its name.
4.176 - ///\param name is the name of map of which maximum is searched
4.177 - double maxOfNodeMap(const std::string &);
4.178 + ///Returns the maximum value of the given NodeMap.
4.179
4.180 - ///Returns the maximum value of the given EdgeMap. EdgeMap has to be given by its name.
4.181 - ///\param name is the name of map of which maximum is searched
4.182 - double maxOfEdgeMap(const std::string &);
4.183 + ///NodeMap has to be given by its name.
4.184 + ///\param name the name of map of which maximum is searched
4.185 + double maxOfNodeMap(const std::string & name);
4.186
4.187 - ///Returns the minimum value of the given NodeMap. NodeMap has to be given by its name.
4.188 - ///\param name is the name of map of which minimum is searched
4.189 - double minOfNodeMap(const std::string &);
4.190 + ///Returns the maximum value of the given EdgeMap.
4.191
4.192 - ///Returns the minimum value of the given EdgeMap. EdgeMap has to be given by its name.
4.193 - ///\param name is the name of map of which minimum is searched
4.194 - double minOfEdgeMap(const std::string &);
4.195 + ///EdgeMap has to be given by its name.
4.196 + ///\param name the name of map of which maximum is searched
4.197 + double maxOfEdgeMap(const std::string & name);
4.198
4.199 - ///To be able to iterate through each maps this function returns an iterator pointing to the first nodemap in the storage.
4.200 + ///Returns the minimum value of the given NodeMap.
4.201 +
4.202 + ///NodeMap has to be given by its name.
4.203 + ///\param name the name of map of which minimum is searched
4.204 + double minOfNodeMap(const std::string & name);
4.205 +
4.206 + ///Returns the minimum value of the given EdgeMap.
4.207 +
4.208 + ///EdgeMap has to be given by its name.
4.209 + ///\param name the name of map of which minimum is searched
4.210 + double minOfEdgeMap(const std::string & name);
4.211 +
4.212 + ///Returns iterator pointing to the first NodeMap in storage.
4.213 +
4.214 + ///To be able to iterate through each maps this function
4.215 + ///returns an iterator pointing to the first nodemap in
4.216 + ///the storage.
4.217 std::map< std::string,Graph::NodeMap<double> * >::iterator beginOfNodeMaps(){return nodemap_storage.begin();};
4.218
4.219 - ///To be able to iterate through each maps this function returns an iterator pointing to the first edgemap in the storage.
4.220 + ///Returns iterator pointing to the first EdgeMap in storage.
4.221 +
4.222 + ///To be able to iterate through each maps this function
4.223 + ///returns an iterator pointing to the first edgemap in
4.224 + ///the storage.
4.225 std::map< std::string,Graph::EdgeMap<double> * >::iterator beginOfEdgeMaps(){return edgemap_storage.begin();};
4.226
4.227 - ///To be able to iterate through each maps this function returns an iterator pointing to the last nodemap in the storage.
4.228 + ///Returns iterator pointing after the last NodeMap in storage.
4.229 +
4.230 + ///To be able to iterate through each maps this function
4.231 + ///returns an iterator pointing to the last nodemap in the storage.
4.232 std::map< std::string,Graph::NodeMap<double> * >::iterator endOfNodeMaps(){return nodemap_storage.end();};
4.233
4.234 - ///To be able to iterate through each maps this function returns an iterator pointing to the last edgemap in the storage.
4.235 + ///Returns iterator pointing after the last EdgeMap in storage.
4.236 +
4.237 + ///To be able to iterate through each maps this function
4.238 + ///returns an iterator pointing to the last edgemap in the storage.
4.239 std::map< std::string,Graph::EdgeMap<double> * >::iterator endOfEdgeMaps(){return edgemap_storage.end();};
4.240
4.241 - void mapChanged(bool, std::string);
4.242 + ///Emits \ref signal_prop if mapvalues have changed, and MapStorage gets to know it.
4.243
4.244 + ///If values in a map have changed, this function checks, whether it is displayed.
4.245 + ///This check means searching the given mapname between active maps
4.246 + ///(\ref active_nodemaps, \ref active_edgemaps). If it is there at a certain property,
4.247 + ///it emits a signal with the property, where the gotten mapname was found. One signal
4.248 + ///is emitted for each property displaying the given map.
4.249 + ///\param itisedge whether the map an edgemap or nodemap
4.250 + ///\param mapname name of map to visualize
4.251 + void mapChanged(bool itisedge, std::string mapname);
4.252 +
4.253 + ///Read datas from the given filename.
4.254 int readFromFile(const std::string &);
4.255 +
4.256 + ///Save datas to the given filename.
4.257 void writeToFile(const std::string &);
4.258
4.259 + ///Deletes all datastructures stored here.
4.260 void clear();
4.261
4.262 void ArrowPosReadOK();
5.1 --- a/gui/new_map_win.cc Mon Jan 09 12:41:06 2006 +0000
5.2 +++ b/gui/new_map_win.cc Tue Jan 10 15:15:57 2006 +0000
5.3 @@ -72,79 +72,100 @@
5.4
5.5 //get and formulate text
5.6 std::string def_val_str=default_value.get_text();
5.7 - std::string polishform=string2Polishform(def_val_str,edge.get_active());
5.8 +
5.9 + bool only_nums=true;
5.10 + for(int i=0;i<(int)def_val_str.size() && only_nums;i++)
5.11 + {
5.12 + if( def_val_str[i]<'0' || def_val_str[i]>'9' )
5.13 + {
5.14 + only_nums=false;
5.15 + }
5.16 + }
5.17 + std::string polishform;
5.18 +
5.19 + if(only_nums)
5.20 + {
5.21 + def_val=atof(def_val_str.c_str());
5.22 + }
5.23 + else
5.24 + {
5.25 + polishform=string2Polishform(def_val_str,edge.get_active());
5.26 + }
5.27
5.28 //get name of text
5.29 std::string mapname=name.get_text();
5.30 -
5.31 - if(!mapname.empty()&&!polishform.empty())
5.32 +
5.33 + if(!mapname.empty()&&(!polishform.empty()||only_nums))
5.34 {
5.35 int abortion=0;
5.36 if(edge.get_active())
5.37 {
5.38 //create the new map
5.39 - Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (mytab.mapstorage.graph);
5.40 -
5.41 - std::stack<double> polishstack;
5.42 -
5.43 - for(EdgeIt k(mytab.mapstorage.graph); k!=INVALID; ++k)
5.44 + Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (mytab.mapstorage.graph, def_val);
5.45 +
5.46 + if(!only_nums)
5.47 {
5.48 - for(int i=0;i<(int)polishform.size();i++)
5.49 + std::stack<double> polishstack;
5.50 +
5.51 + for(EdgeIt k(mytab.mapstorage.graph); k!=INVALID; ++k)
5.52 {
5.53 - double op1, op2;
5.54 - bool operation=true;
5.55 - switch(polishform[i])
5.56 + for(int i=0;i<(int)polishform.size();i++)
5.57 {
5.58 - case '+':
5.59 - case '-':
5.60 - case '/':
5.61 - case '*':
5.62 - op1=polishstack.top();
5.63 - polishstack.pop();
5.64 - op2=polishstack.top();
5.65 - polishstack.pop();
5.66 - break;
5.67 - default:
5.68 - //substitute variable
5.69 - std::map< std::string,Graph::EdgeMap<double> * > ems=mytab.mapstorage.edgemap_storage;
5.70 - bool itisvar=(ems.find(ch2var[ polishform[i] ])!=ems.end());
5.71 - if(itisvar)
5.72 - {
5.73 - polishstack.push( (*(mytab.mapstorage.edgemap_storage[ ch2var[ polishform[i] ] ]))[k]);
5.74 - }
5.75 - else
5.76 - {
5.77 - polishstack.push(atof(ch2var[ polishform[i] ].c_str()));
5.78 - }
5.79 - operation=false;
5.80 - break;
5.81 - }
5.82 - if(operation)
5.83 - {
5.84 - double res;
5.85 + double op1=0, op2=0;
5.86 + bool operation=true;
5.87 switch(polishform[i])
5.88 {
5.89 case '+':
5.90 - res=op1+op2;
5.91 - break;
5.92 case '-':
5.93 - res=op2-op1;
5.94 - break;
5.95 case '/':
5.96 - res=op2/op1;
5.97 - break;
5.98 case '*':
5.99 - res=op1*op2;
5.100 + op1=polishstack.top();
5.101 + polishstack.pop();
5.102 + op2=polishstack.top();
5.103 + polishstack.pop();
5.104 break;
5.105 default:
5.106 - std::cout << "How could we get here?" << std::endl;
5.107 + //substitute variable
5.108 + std::map< std::string,Graph::EdgeMap<double> * > ems=mytab.mapstorage.edgemap_storage;
5.109 + bool itisvar=(ems.find(ch2var[ polishform[i] ])!=ems.end());
5.110 + if(itisvar)
5.111 + {
5.112 + polishstack.push( (*(mytab.mapstorage.edgemap_storage[ ch2var[ polishform[i] ] ]))[k]);
5.113 + }
5.114 + else
5.115 + {
5.116 + polishstack.push(atof(ch2var[ polishform[i] ].c_str()));
5.117 + }
5.118 + operation=false;
5.119 break;
5.120 }
5.121 - polishstack.push(res);
5.122 - }
5.123 - }
5.124 - (*emptr)[k]=polishstack.top();
5.125 - }
5.126 + if(operation)
5.127 + {
5.128 + double res;
5.129 + switch(polishform[i])
5.130 + {
5.131 + case '+':
5.132 + res=op1+op2;
5.133 + break;
5.134 + case '-':
5.135 + res=op2-op1;
5.136 + break;
5.137 + case '/':
5.138 + res=op2/op1;
5.139 + break;
5.140 + case '*':
5.141 + res=op1*op2;
5.142 + break;
5.143 + default:
5.144 + std::cout << "How could we get here?" << std::endl;
5.145 + break;
5.146 + }
5.147 + polishstack.push(res);
5.148 + }
5.149 + }//foreach letter in polishform
5.150 + (*emptr)[k]=polishstack.top();
5.151 + }//foreach edge
5.152 + }//!only_nums
5.153
5.154 //if addition was not successful addEdgeMap returns one.
5.155 //cause can be that there is already a map named like the new one
5.156 @@ -163,68 +184,70 @@
5.157 else //!edge.get_active()
5.158 {
5.159 //create the new map
5.160 - Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (mytab.mapstorage.graph);
5.161 + Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (mytab.mapstorage.graph, def_val);
5.162
5.163 - std::stack<double> polishstack;
5.164 + if(!only_nums)
5.165 + {
5.166 + std::stack<double> polishstack;
5.167
5.168 - for(NodeIt k(mytab.mapstorage.graph); k!=INVALID; ++k)
5.169 - {
5.170 - for(int i=0;i<(int)polishform.size();i++)
5.171 + for(NodeIt k(mytab.mapstorage.graph); k!=INVALID; ++k)
5.172 {
5.173 - double op1, op2;
5.174 - bool operation=true;
5.175 - switch(polishform[i])
5.176 + for(int i=0;i<(int)polishform.size();i++)
5.177 {
5.178 - case '+':
5.179 - case '-':
5.180 - case '/':
5.181 - case '*':
5.182 - op1=polishstack.top();
5.183 - polishstack.pop();
5.184 - op2=polishstack.top();
5.185 - polishstack.pop();
5.186 - break;
5.187 - default:
5.188 - std::map< std::string,Graph::NodeMap<double> * > nms=mytab.mapstorage.nodemap_storage;
5.189 - bool itisvar=(nms.find(ch2var[ polishform[i] ])!=nms.end());
5.190 - if(itisvar)
5.191 - {
5.192 - polishstack.push( (*(mytab.mapstorage.nodemap_storage[ ch2var[ polishform[i] ] ]))[k]);
5.193 - }
5.194 - else
5.195 - {
5.196 - polishstack.push(atof(ch2var[ polishform[i] ].c_str()));
5.197 - }
5.198 - operation=false;
5.199 - break;
5.200 - }
5.201 - if(operation)
5.202 - {
5.203 - double res;
5.204 + double op1=0, op2=0;
5.205 + bool operation=true;
5.206 switch(polishform[i])
5.207 {
5.208 case '+':
5.209 - res=op1+op2;
5.210 - break;
5.211 case '-':
5.212 - res=op2-op1;
5.213 - break;
5.214 case '/':
5.215 - res=op2/op1;
5.216 - break;
5.217 case '*':
5.218 - res=op1*op2;
5.219 + op1=polishstack.top();
5.220 + polishstack.pop();
5.221 + op2=polishstack.top();
5.222 + polishstack.pop();
5.223 break;
5.224 default:
5.225 - std::cout << "How could we get here?" << std::endl;
5.226 + std::map< std::string,Graph::NodeMap<double> * > nms=mytab.mapstorage.nodemap_storage;
5.227 + bool itisvar=(nms.find(ch2var[ polishform[i] ])!=nms.end());
5.228 + if(itisvar)
5.229 + {
5.230 + polishstack.push( (*(mytab.mapstorage.nodemap_storage[ ch2var[ polishform[i] ] ]))[k]);
5.231 + }
5.232 + else
5.233 + {
5.234 + polishstack.push(atof(ch2var[ polishform[i] ].c_str()));
5.235 + }
5.236 + operation=false;
5.237 break;
5.238 }
5.239 - polishstack.push(res);
5.240 + if(operation)
5.241 + {
5.242 + double res;
5.243 + switch(polishform[i])
5.244 + {
5.245 + case '+':
5.246 + res=op1+op2;
5.247 + break;
5.248 + case '-':
5.249 + res=op2-op1;
5.250 + break;
5.251 + case '/':
5.252 + res=op2/op1;
5.253 + break;
5.254 + case '*':
5.255 + res=op1*op2;
5.256 + break;
5.257 + default:
5.258 + std::cout << "How could we get here?" << std::endl;
5.259 + break;
5.260 + }
5.261 + polishstack.push(res);
5.262 + }
5.263 }
5.264 + (*emptr)[k]=polishstack.top();
5.265 }
5.266 - (*emptr)[k]=polishstack.top();
5.267 }
5.268 -
5.269 //if addition was not successful addNodeMap returns one.
5.270 //cause can be that there is already a map named like the new one
5.271 if(mytab.mapstorage.addNodeMap(mapname,emptr, def_val))