Little red arrows appear in breakpoints of edges.
3 #ifndef GRAPH_DISPLAYER_CANVAS_H
4 #define GRAPH_DISPLAYER_CANVAS_H
6 #include <all_include.h>
7 #include <mapstorage.h>
8 #include <broken_edge.h>
9 #include <libgnomecanvasmm.h>
10 #include <libgnomecanvasmm/polygon.h>
12 ///This class is the canvas, on which the graph can be drawn.
13 class GraphDisplayerCanvas : public Gnome::Canvas::CanvasAA
15 typedef Gnome::Canvas::CanvasAA Parent;
18 GraphDisplayerCanvas(Graph &, CoordinatesMap &, MapStorage &);
19 virtual ~GraphDisplayerCanvas();
21 ///Changes the linewidth attribute according to the given map.
22 ///\param mapname is the name of the map which contains the new values
23 int changeLineWidth (std::string mapname);
25 ///Changes the linecolor attribute according to the given map.
26 ///\param mapname is the name of the map which contains the new values
27 int changeColor (std::string mapname);
29 ///Changes the text of line attribute according to the given map.
30 ///\param mapname is the name of the map which contains the new values
31 int changeText (std::string mapname);
33 ///Callback for 'ViewZoomIn' action.
34 virtual void zoomIn();
35 ///Callback for 'ViewZoomOut' action.
36 virtual void zoomOut();
37 ///Callback for 'ViewZoomFit' action.
38 virtual void zoomFit();
39 ///Callback for 'ViewZoom100' action.
40 virtual void zoom100();
41 ///Sets the scroll region of the convas to the bounding box of the graph.
42 void updateScrollRegion();
44 ///This function changes the tool in the graph-editor's hand
45 void changeEditorialTool(int);
49 //maximizing, minimizing, restoring window, etc.
50 virtual bool on_expose_event(GdkEventExpose *);
54 ///This function is responsible for the correct
55 ///reaction of any action happened in the territory
57 bool event_handler(GdkEvent* e, Node n);
59 ///actual event handler
61 ///Actual event handler should be stored, to be able to disconnect it and later reconnect it.
62 sigc::connection actual_handler;
64 ///event handler for the case when move-tool is active
65 bool move_event_handler(GdkEvent*);
66 ///event handler for the case when create_node-tool is active
67 bool create_node_event_handler(GdkEvent*);
68 ///event handler for the case when create_edge-tool is active
69 bool create_edge_event_handler(GdkEvent*);
70 ///event handler for the case when eraser-tool is active
71 bool eraser_event_handler(GdkEvent*);
73 ///Deletes the given element.
74 void delete_item(NodeIt);
75 ///Deletes the given element.
76 void delete_item(EdgeIt);
77 ///Deletes the given element.
78 void delete_item(Graph::Edge);
80 ///The graph, on which we work
83 ///Map of nodes of graph
84 Graph::NodeMap<Gnome::Canvas::Ellipse *> nodesmap;
86 ///Map of edges of graph
87 Graph::EdgeMap<BrokenEdge *> edgesmap;
89 ///Map of texts to write on edges
90 Graph::EdgeMap<Gnome::Canvas::Text *> edgetextmap;
92 ///Group of graphical elements of displayed_graph
93 Gnome::Canvas::Group displayed_graph;
95 ///Here we store the maps that can be displayed through properties.
96 MapStorage mapstorage;
98 ///Indicates whether the button of mouse is pressed or not
101 ///At this location was the mousebutton pressed.
102 ///It helps to calculate the distance of dragging.
103 double clicked_x, clicked_y;
105 ///Remembers which Gnome::Canvas::Item was pressed.
106 ///this variable is needed, because
107 ///1. we cannot query the item at he cursor as fast as it could not cause a Segmentation Fault
108 ///2. we would like to handle only ony item per movement, therefore quering it is not a working solution
109 Gnome::Canvas::Item * active_item, * target_item;
110 Graph::NodeIt active_node;
111 Graph::EdgeIt active_edge;
113 static const int zoom_step = 5;
117 #endif //GRAPH_DISPLAYER_CANVAS_H