File graph_displayer is split in functional parts.
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
60 bool event_handler(GdkEvent* e, Node n);
62 ///actual event handler
64 ///Actual event handler should be stored, to be able to disconnect it and later reconnect it.
65 sigc::connection actual_handler;
67 ///event handler for the case when move-tool is active
68 bool move_event_handler(GdkEvent*);
69 ///event handler for the case when create_node-tool is active
70 bool create_node_event_handler(GdkEvent*);
71 ///event handler for the case when create_edge-tool is active
72 bool create_edge_event_handler(GdkEvent*);
73 ///event handler for the case when eraser-tool is active
74 bool eraser_event_handler(GdkEvent*);
75 ///event handler for the case when eraser-tool is active
76 bool edge_map_edit_event_handler(GdkEvent*);
79 ///Moves the text to new place
80 void text_reposition(xy<double>);
81 ///Activates an edge belonging to a BrokenEdge
82 void toggle_edge_activity(BrokenEdge*, bool);
85 ///\return the actual tool in hand
86 int get_actual_tool();
89 ///Deletes the given element.
90 void delete_item(NodeIt);
91 ///Deletes the given element.
92 void delete_item(EdgeIt);
93 ///Deletes the given element.
94 void delete_item(Graph::Edge);
98 ///The graph, on which we work
101 ///Map of nodes of graph
102 Graph::NodeMap<Gnome::Canvas::Ellipse *> nodesmap;
104 ///Map of edges of graph
105 Graph::EdgeMap<BrokenEdge *> edgesmap;
107 ///Map of texts to write on edges
108 Graph::EdgeMap<Gnome::Canvas::Text *> edgetextmap;
110 ///Group of graphical elements of displayed_graph
111 Gnome::Canvas::Group displayed_graph;
113 ///Here we store the maps that can be displayed through properties.
114 MapStorage mapstorage;
116 ///Indicates whether the button of mouse is pressed or not
119 ///Stores the actual tool in hand
122 ///At this location was the mousebutton pressed.
123 ///It helps to calculate the distance of dragging.
124 double clicked_x, clicked_y;
126 ///Remembers which Gnome::Canvas::Item was pressed.
127 ///this variable is needed, because
128 ///1. we cannot query the item at he cursor as fast as it could not cause a Segmentation Fault
129 ///2. we would like to handle only ony item per movement, therefore quering it is not a working solution
130 Gnome::Canvas::Item * active_item, * target_item;
131 Graph::NodeIt active_node;
132 Graph::EdgeIt active_edge;
134 static const int zoom_step = 5;
138 #endif //GRAPH_DISPLAYER_CANVAS_H