Little beauty fault is corrected.
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>
11 #include <libgnomecanvasmm.h>
12 #include <libgnomecanvasmm/polygon.h>
14 ///This class is the canvas, on which the graph can be drawn.
15 class GraphDisplayerCanvas : public Gnome::Canvas::CanvasAA
17 typedef Gnome::Canvas::CanvasAA Parent;
20 GraphDisplayerCanvas(Graph &, CoordinatesMap &, MapStorage &);
21 virtual ~GraphDisplayerCanvas();
23 ///Changes the linewidth attribute according to the given map.
24 ///\param mapname is the name of the map which contains the new values
25 int changeLineWidth (std::string mapname);
27 ///Changes the linecolor attribute according to the given map.
28 ///\param mapname is the name of the map which contains the new values
29 int changeColor (std::string mapname);
31 ///Changes the text of line attribute according to the given map.
32 ///\param mapname is the name of the map which contains the new values
33 int changeText (std::string mapname);
35 ///Callback for 'ViewZoomIn' action.
36 virtual void zoomIn();
37 ///Callback for 'ViewZoomOut' action.
38 virtual void zoomOut();
39 ///Callback for 'ViewZoomFit' action.
40 virtual void zoomFit();
41 ///Callback for 'ViewZoom100' action.
42 virtual void zoom100();
43 ///Sets the scroll region of the convas to the bounding box of the graph.
44 void updateScrollRegion();
46 ///This function changes the tool in the graph-editor's hand
47 void changeEditorialTool(int);
51 //maximizing, minimizing, restoring window, etc.
52 virtual bool on_expose_event(GdkEventExpose *);
56 ///This function is responsible for the correct
57 ///reaction of any action happened in the territory
59 bool event_handler(GdkEvent* e, Node n);
61 ///actual event handler
63 ///Actual event handler should be stored, to be able to disconnect it and later reconnect it.
64 sigc::connection actual_handler;
66 ///event handler for the case when move-tool is active
67 bool move_event_handler(GdkEvent*);
68 ///event handler for the case when create_node-tool is active
69 bool create_node_event_handler(GdkEvent*);
70 ///event handler for the case when create_edge-tool is active
71 bool create_edge_event_handler(GdkEvent*);
72 ///event handler for the case when eraser-tool is active
73 bool eraser_event_handler(GdkEvent*);
74 ///event handler for the case when eraser-tool is active
75 bool edge_map_edit_event_handler(GdkEvent*);
78 ///\return the actual tool in hand
79 int get_actual_tool();
82 ///Deletes the given element.
83 void delete_item(NodeIt);
84 ///Deletes the given element.
85 void delete_item(EdgeIt);
86 ///Deletes the given element.
87 void delete_item(Graph::Edge);
91 ///The graph, on which we work
94 ///Map of nodes of graph
95 Graph::NodeMap<Gnome::Canvas::Ellipse *> nodesmap;
97 ///Map of edges of graph
98 Graph::EdgeMap<BrokenEdge *> edgesmap;
100 ///Map of texts to write on edges
101 Graph::EdgeMap<Gnome::Canvas::Text *> edgetextmap;
103 ///Group of graphical elements of displayed_graph
104 Gnome::Canvas::Group displayed_graph;
106 ///Here we store the maps that can be displayed through properties.
107 MapStorage mapstorage;
109 ///Indicates whether the button of mouse is pressed or not
112 ///Stores the actual tool in hand
115 ///At this location was the mousebutton pressed.
116 ///It helps to calculate the distance of dragging.
117 double clicked_x, clicked_y;
119 ///Remembers which Gnome::Canvas::Item was pressed.
120 ///this variable is needed, because
121 ///1. we cannot query the item at he cursor as fast as it could not cause a Segmentation Fault
122 ///2. we would like to handle only ony item per movement, therefore quering it is not a working solution
123 Gnome::Canvas::Item * active_item, * target_item;
124 Graph::NodeIt active_node;
125 Graph::EdgeIt active_edge;
127 static const int zoom_step = 5;
131 #endif //GRAPH_DISPLAYER_CANVAS_H