|
1 // -*- C++ -*- // |
|
2 |
|
3 #ifndef GRAPH_DISPLAYER_CANVAS_H |
|
4 #define GRAPH_DISPLAYER_CANVAS_H |
|
5 |
|
6 #include <all_include.h> |
|
7 #include <mapstorage.h> |
|
8 #include <libgnomecanvasmm.h> |
|
9 #include <libgnomecanvasmm/polygon.h> |
|
10 |
|
11 class GraphDisplayerCanvas : public Gnome::Canvas::CanvasAA |
|
12 { |
|
13 typedef Gnome::Canvas::CanvasAA Parent; |
|
14 |
|
15 public: |
|
16 GraphDisplayerCanvas(Graph &, CoordinatesMap &, MapStorage &); |
|
17 virtual ~GraphDisplayerCanvas(); |
|
18 |
|
19 int changeLineWidth (std::string mapname); |
|
20 int changeColor (std::string mapname); |
|
21 int changeText (std::string mapname); |
|
22 int rezoom(); |
|
23 |
|
24 protected: |
|
25 |
|
26 virtual bool on_expose_event(GdkEventExpose *); |
|
27 |
|
28 private: |
|
29 |
|
30 ///Event handler function that handles dragging nodes of displayed_graph |
|
31 bool event_handler(GdkEvent* e, Node n); |
|
32 |
|
33 ///The graph, on which we work |
|
34 Graph g; |
|
35 ///Map of nodes of planefigure |
|
36 Graph::NodeMap<Gnome::Canvas::Ellipse *> nodesmap; |
|
37 ///Map of edges of planefigure |
|
38 Graph::EdgeMap<Gnome::Canvas::Line *> edgesmap; |
|
39 |
|
40 ///Map of texts to write on edges |
|
41 Graph::EdgeMap<Gnome::Canvas::Text *> edgetextmap; |
|
42 |
|
43 ///Group of graphical elements of displayed_graph |
|
44 Gnome::Canvas::Group displayed_graph; |
|
45 |
|
46 ///Here we store the maps that can be displayed through properties. |
|
47 MapStorage mapstorage; |
|
48 |
|
49 ///Indicates whether the button of mouse is pressed or not |
|
50 bool isbutton; |
|
51 |
|
52 ///At this location was the mousebutton pressed. |
|
53 ///It helps to calculate the distance of dragging. |
|
54 double clicked_x, clicked_y; |
|
55 |
|
56 ///Remembers which Gnome::Canvas::Item was pressed. |
|
57 ///this variable is needed, because |
|
58 ///1. we cannot query the item at he cursor as fast as it could not cause a Segmentation Fault |
|
59 ///2. we would like to handle only ony item per movement, therefore quering it is not a working solution |
|
60 Gnome::Canvas::Item * active_item; |
|
61 |
|
62 |
|
63 }; |
|
64 |
|
65 #endif //GRAPH_DISPLAYER_CANVAS_H |