There were bugs, created yesterday, and there is still one. (I hope only one :) )
3 #ifndef GRAPH_DISPLAYER_CANVAS_H
4 #define GRAPH_DISPLAYER_CANVAS_H
6 class GraphDisplayerCanvas;
8 #include <all_include.h>
10 #include <mapstorage.h>
11 #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(Graph &, CoordinatesMap &, MapStorage &, MapWin *);
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, Graph::Edge new_item=INVALID);
28 ///Changes the linecolor attribute according to the given map.
29 ///\param mapname is the name of the map which contains the new values
30 int changeEdgeColor (std::string mapname, Graph::Edge new_item=INVALID);
32 ///Changes the text of line attribute according to the given map.
33 ///\param mapname is the name of the map which contains the new values
34 int changeEdgeText (std::string mapname, Graph::Edge new_item=INVALID);
36 ///Changes the linewidth attribute according to the given map.
37 ///\param mapname is the name of the map which contains the new values
38 int changeNodeRadius (std::string mapname, Graph::Node new_item=INVALID);
40 ///Changes the linecolor attribute according to the given map.
41 ///\param mapname is the name of the map which contains the new values
42 int changeNodeColor (std::string mapname, Graph::Node new_item=INVALID);
44 ///Changes the text of line attribute according to the given map.
45 ///\param mapname is the name of the map which contains the new values
46 int changeNodeText (std::string mapname, Graph::Node new_item=INVALID);
48 ///Callback for 'ViewZoomIn' action.
49 virtual void zoomIn();
50 ///Callback for 'ViewZoomOut' action.
51 virtual void zoomOut();
52 ///Callback for 'ViewZoomFit' action.
53 virtual void zoomFit();
54 ///Callback for 'ViewZoom100' action.
55 virtual void zoom100();
56 ///Sets the scroll region of the convas to the bounding box of the graph.
57 void updateScrollRegion();
59 ///This function changes the tool in the graph-editor's hand
60 void changeEditorialTool(int);
64 //maximizing, minimizing, restoring window, etc.
65 virtual bool on_expose_event(GdkEventExpose *);
69 ///This function is responsible for the correct
70 ///reaction of any action happened in the territory
73 bool eventHandler(GdkEvent* e, Node n);
75 ///actual event handler
77 ///Actual event handler should be stored, to be able to disconnect it and later reconnect it.
78 sigc::connection actual_handler;
80 ///event handler for the case when move-tool is active
81 bool moveEventHandler(GdkEvent*);
82 ///event handler for the case when create_node-tool is active
83 bool createNodeEventHandler(GdkEvent*);
84 ///event handler for the case when create_edge-tool is active
85 bool createEdgeEventHandler(GdkEvent*);
86 ///event handler for the case when eraser-tool is active
87 bool eraserEventHandler(GdkEvent*);
88 ///event handler for the case when edge map editor tool is active
89 bool edgeMapEditEventHandler(GdkEvent*);
90 ///event handler for the case when node map editor tool is active
91 bool nodeMapEditEventHandler(GdkEvent*);
93 ///event handler for the case when the entry widget is changed
94 bool entryWidgetChangeHandler(GdkEvent*);
97 ///Moves the text to new place
98 void textReposition(xy<double>);
99 ///Activates an edge belonging to a BrokenEdge
101 ///After we have activated an edge this way,
102 ///the GDC object will know, which edge is under forming
103 ///therefore it can redraw the necessarz elementy on the canvas,
104 ///for example the text belonging to the \ref BrokenEdge can be
105 ///redrawn (\ref textReposition).
106 void toggleEdgeActivity(BrokenEdge*, bool);
109 ///\return the actual tool in hand
113 ///Deletes the given element.
114 void deleteItem(NodeIt);
115 ///Deletes the given element.
116 void deleteItem(EdgeIt);
117 ///Deletes the given element.
118 void deleteItem(Graph::Edge);
122 ///The graph, on which we work
125 ///Map of nodes of graph
126 Graph::NodeMap<Gnome::Canvas::Ellipse *> nodesmap;
128 ///Map of edges of graph
129 Graph::EdgeMap<BrokenEdge *> edgesmap;
131 ///Map of texts to write on edges
132 Graph::EdgeMap<Gnome::Canvas::Text *> edgetextmap;
134 ///Map of texts to write on nodes
135 Graph::NodeMap<Gnome::Canvas::Text *> nodetextmap;
137 ///Group of graphical elements of displayed_graph
138 Gnome::Canvas::Group displayed_graph;
141 Gtk::Entry entrywidget;
143 ///GnomeCanvas holder for entry
144 Gnome::Canvas::Widget * canvasentrywidget;
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;
164 Graph::NodeIt active_node;
165 Graph::EdgeIt active_edge;
166 Graph::EdgeIt forming_edge;
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.
177 #endif //GRAPH_DISPLAYER_CANVAS_H