Doxyfile for documenting glemon's architecture.
3 #ifndef GRAPH_DISPLAYER_CANVAS_H
4 #define GRAPH_DISPLAYER_CANVAS_H
6 class GraphDisplayerCanvas;
8 #include "all_include.h"
9 #include "mapstorage.h"
10 #include "broken_edge.h"
12 #include <libgnomecanvasmm.h>
13 #include <libgnomecanvasmm/polygon.h>
15 ///This class is the canvas, on which the graph can be drawn.
16 class GraphDisplayerCanvas : public Gnome::Canvas::CanvasAA
18 typedef Gnome::Canvas::CanvasAA Parent;
21 GraphDisplayerCanvas(MapStorage &, MapWin &, Gtk::Window *);
22 virtual ~GraphDisplayerCanvas();
24 ///Changes the linewidth attribute according to the given map.
25 ///\param mapname is the name of the map which contains the new values
26 int changeEdgeWidth (std::string mapname, Edge new_item=INVALID);
27 int resetEdgeWidth (Edge new_item=INVALID);
29 ///Changes the linecolor attribute according to the given map.
30 ///\param mapname is the name of the map which contains the new values
31 int changeEdgeColor (std::string mapname, Edge new_item=INVALID);
32 int resetEdgeColor (Edge new_item=INVALID);
34 ///Changes the text of line attribute according to the given map.
35 ///\param mapname is the name of the map which contains the new values
36 int changeEdgeText (std::string mapname, Edge new_item=INVALID);
37 int resetEdgeText (Edge new_item=INVALID);
39 ///Changes the linewidth attribute according to the given map.
40 ///\param mapname is the name of the map which contains the new values
41 int changeNodeRadius (std::string mapname, Node new_item=INVALID);
42 int resetNodeRadius (Node new_item=INVALID);
44 ///Changes the linecolor attribute according to the given map.
45 ///\param mapname is the name of the map which contains the new values
46 int changeNodeColor (std::string mapname, Node new_item=INVALID);
47 int resetNodeColor (Node new_item=INVALID);
49 ///Changes the text of line attribute according to the given map.
50 ///\param mapname is the name of the map which contains the new values
51 int changeNodeText (std::string mapname, Node new_item=INVALID);
52 int resetNodeText (Node new_item=INVALID);
54 ///Callback for 'ViewZoomIn' action.
55 virtual void zoomIn();
56 ///Callback for 'ViewZoomOut' action.
57 virtual void zoomOut();
58 ///Callback for 'ViewZoomFit' action.
59 virtual void zoomFit();
60 ///Callback for 'ViewZoom100' action.
61 virtual void zoom100();
62 ///Sets the scroll region of the convas to the bounding box of the graph.
63 void updateScrollRegion();
65 ///This function changes the tool in the graph-editor's hand
66 void changeEditorialTool(int);
70 //maximizing, minimizing, restoring window, etc.
71 virtual bool on_expose_event(GdkEventExpose *);
75 ///This function is responsible for the correct
76 ///reaction of any action happened in the territory
79 bool eventHandler(GdkEvent* e, Node n);
81 ///actual event handler
83 ///Actual event handler should be stored, to be able to disconnect it and later reconnect it.
84 sigc::connection actual_handler;
86 ///event handler for the case when move-tool is active
87 bool moveEventHandler(GdkEvent*);
88 ///event handler for the case when create_node-tool is active
89 bool createNodeEventHandler(GdkEvent*);
90 ///event handler for the case when create_edge-tool is active
91 bool createEdgeEventHandler(GdkEvent*);
92 ///event handler for the case when eraser-tool is active
93 bool eraserEventHandler(GdkEvent*);
94 ///event handler for the case when edge map editor tool is active
95 bool edgeMapEditEventHandler(GdkEvent*);
96 ///event handler for the case when node map editor tool is active
97 bool nodeMapEditEventHandler(GdkEvent*);
100 ///Moves the text to new place
101 void textReposition(xy<double>);
102 ///Activates an edge belonging to a BrokenEdge
104 ///After we have activated an edge this way,
105 ///the GDC object will know, which edge is under forming
106 ///therefore it can redraw the necessarz elementy on the canvas,
107 ///for example the text belonging to the \ref BrokenEdge can be
108 ///redrawn (\ref textReposition).
109 void toggleEdgeActivity(BrokenEdge*, bool);
112 ///\return the actual tool in hand
118 ///creates a new Nodemap
119 int addNewNodeMap(double,std::string);
120 ///creates a new Edgemap
121 int addNewEdgeMap(double,std::string);
124 ///Deletes the given element.
125 void deleteItem(Node);
126 ///Deletes the given element.
127 void deleteItem(Edge);
131 ///Map of nodes of graph
132 Graph::NodeMap<Gnome::Canvas::Ellipse *> nodesmap;
134 ///Map of edges of graph
135 Graph::EdgeMap<BrokenEdge *> edgesmap;
137 ///Map of texts to write on edges
138 Graph::EdgeMap<Gnome::Canvas::Text *> edgetextmap;
140 ///Map of texts to write on nodes
141 Graph::NodeMap<Gnome::Canvas::Text *> nodetextmap;
143 ///Group of graphical elements of displayed_graph
144 Gnome::Canvas::Group displayed_graph;
146 ///Here we store the maps that can be displayed through properties.
147 MapStorage & mapstorage;
149 ///Indicates whether the button of mouse is pressed or not
152 ///Stores the actual tool in hand
155 ///At this location was the mousebutton pressed.
156 ///It helps to calculate the distance of dragging.
157 double clicked_x, clicked_y;
159 ///Remembers which Gnome::Canvas::Item was pressed.
160 ///this variable is needed, because
161 ///1. we cannot query the item at he cursor as fast as it could not cause a Segmentation Fault
162 ///2. we would like to handle only ony item per movement, therefore quering it is not a working solution
163 Gnome::Canvas::Item * active_item, * target_item;
168 std::string nodemap_to_edit, edgemap_to_edit;
170 static const int zoom_step = 5;
172 ///We need to store mapwin, to be able to ask the appropriate values for properties of new items.
175 ///pointer to the parent window
176 Gtk::Window * parentwin;
180 #endif //GRAPH_DISPLAYER_CANVAS_H