13 |
13 |
14 ///This class is the canvas, on which the graph can be drawn. |
14 ///This class is the canvas, on which the graph can be drawn. |
15 class GraphDisplayerCanvas : public Gnome::Canvas::CanvasAA |
15 class GraphDisplayerCanvas : public Gnome::Canvas::CanvasAA |
16 { |
16 { |
17 friend class BrokenEdge; |
17 friend class BrokenEdge; |
|
18 friend class LoopEdge; |
|
19 |
|
20 class EdgeBase : public Gnome::Canvas::Group |
|
21 { |
|
22 protected: |
|
23 ///Reference to the canvas, on which the graph is drawn. |
|
24 |
|
25 ///It is needed, because some datas needed from |
|
26 ///graph can be accessed by this or should be sent |
|
27 ///as parameter, but it would be complicated |
|
28 GraphDisplayerCanvas& canvas; |
|
29 |
|
30 ///The edge that the class displays. |
|
31 |
|
32 ///It is needed, because some datas needed from |
|
33 ///graph can be accessed by this or should be sent |
|
34 ///as parameter, but it would be complicated |
|
35 Edge edge; |
|
36 |
|
37 Gnome::Canvas::Polygon arrow; |
|
38 |
|
39 void drawArrow(XY); |
|
40 public: |
|
41 EdgeBase(Gnome::Canvas::Group&, Edge, GraphDisplayerCanvas&); |
|
42 virtual ~EdgeBase(); |
|
43 virtual void draw() = 0; |
|
44 virtual void setLineWidth(int) = 0; |
|
45 virtual void setFillColor(Gdk::Color) = 0; |
|
46 }; |
18 |
47 |
19 ///Edge displayer class |
48 ///Edge displayer class |
20 |
49 |
21 ///This class is responsible for displaying edges in graph. |
50 ///This class is responsible for displaying edges in graph. |
22 ///The displayed edge is broken in the middle. The |
51 ///The displayed edge is broken in the middle. The |
23 ///aim of this is to be able to indicate direction of edges |
52 ///aim of this is to be able to indicate direction of edges |
24 ///and to be able to display more then one edges between the |
53 ///and to be able to display more then one edges between the |
25 ///same source and target |
54 ///same source and target |
26 class BrokenEdge : public Gnome::Canvas::Line |
55 class BrokenEdge : public EdgeBase |
27 { |
56 { |
28 ///The edge that the class displays. |
57 private: |
29 |
58 Gnome::Canvas::Line line; |
30 ///It is needed, because some datas needed from |
59 |
31 ///graph can be accessed by this or should be sent |
60 ///Indicates whether the button of mouse is pressed or not at the moment. |
32 ///as parameter, but it would be complicated |
61 bool isbutton; |
33 Edge edge; |
62 |
34 |
63 ///At this location was the mousebutton pressed. Horizontal component. |
35 ///Reference to the canvas, on which the graph is drawn. |
64 |
36 |
65 ///It helps to calculate the |
37 ///It is needed, because some datas needed from |
66 ///distance of dragging. |
38 ///graph can be accessed by this or should be sent |
67 double clicked_x; |
39 ///as parameter, but it would be complicated |
68 |
40 GraphDisplayerCanvas & gdc; |
69 ///At this location was the mousebutton pressed. Vertical component. |
41 |
70 |
42 ///An arrow that indicates the direction of the edges |
71 ///It helps to calculate the |
43 |
72 ///distance of dragging. |
44 ///in case of directional graph direction can be indicated |
73 double clicked_y; |
45 ///by this polygon. The polygon formulates a red arrow. |
74 |
46 Gnome::Canvas::Polygon * arrow; |
75 ///event handler for forming broken edges |
47 |
76 |
48 ///Indicates whether the button of mouse is pressed or not at the moment. |
77 ///\param event the |
49 bool isbutton; |
78 ///event to handle |
50 |
79 bool edgeFormerEventHandler(GdkEvent* event); |
51 ///At this location was the mousebutton pressed. Horizontal component. |
80 |
52 |
81 public: |
53 ///It helps to calculate the |
82 ///Constructor of broken edge class. |
54 ///distance of dragging. |
83 |
55 double clicked_x; |
84 ///\param g the group to which the edge belongs |
56 |
85 ///\param _edge the represented edge |
57 ///At this location was the mousebutton pressed. Vertical component. |
86 ///\param gc the canvas |
58 |
87 BrokenEdge(Gnome::Canvas::Group&, Edge, GraphDisplayerCanvas&); |
59 ///It helps to calculate the |
88 |
60 ///distance of dragging. |
89 ///Destructor of broken edge class |
61 double clicked_y; |
90 |
62 |
91 ///Frees up |
63 ///event handler for forming broken edges |
92 ///reserved memory |
64 |
93 ~BrokenEdge(); |
65 ///\param event the |
94 |
66 ///event to handle |
95 ///The function that draws the edge based on collected data |
67 bool edgeFormerEventHandler(GdkEvent* event); |
96 void draw(); |
68 public: |
97 |
69 |
98 void setLineWidth(int); |
70 ///Constructor of broken edge class. |
99 void setFillColor(Gdk::Color); |
71 |
100 }; |
72 ///\param g the group to which the edge belongs |
101 |
73 ///\param _edge the represented edge |
102 class LoopEdge : public EdgeBase |
74 ///\param gc the canvas |
103 { |
75 BrokenEdge(Gnome::Canvas::Group & g, Edge _edge, GraphDisplayerCanvas & gc); |
104 private: |
76 |
105 Gnome::Canvas::Ellipse line; |
77 ///Destructor of broken edge class |
106 public: |
78 |
107 LoopEdge(Gnome::Canvas::Group&, Edge, GraphDisplayerCanvas&); |
79 ///Frees up |
108 ~LoopEdge(); |
80 ///reserved memory |
109 void draw(); |
81 ~BrokenEdge(); |
110 void setLineWidth(int); |
82 |
111 void setFillColor(Gdk::Color); |
83 ///The function that draws the edge based on collected data |
|
84 void draw(); |
|
85 }; |
112 }; |
86 |
113 |
87 ///Type of canvas, on which the graph is drawn |
114 ///Type of canvas, on which the graph is drawn |
88 typedef Gnome::Canvas::CanvasAA Parent; |
115 typedef Gnome::Canvas::CanvasAA Parent; |
89 |
116 |
239 |
266 |
240 public: |
267 public: |
241 ///Moves the text to new place |
268 ///Moves the text to new place |
242 void textReposition(xy<double>); |
269 void textReposition(xy<double>); |
243 |
270 |
244 ///Activates an edge belonging to a BrokenEdge |
271 ///Activates an edge belonging to an EdgeBase |
245 |
272 |
246 ///After we have activated an edge this way, |
273 ///After we have activated an edge this way, |
247 ///the GDC object will know, which edge is under forming |
274 ///the GDC object will know, which edge is under forming |
248 ///therefore it can redraw the necessary elements on the canvas, |
275 ///therefore it can redraw the necessary elements on the canvas, |
249 ///for example the text belonging to the \ref BrokenEdge can be |
276 ///for example the text belonging to the \ref EdgeBase can be |
250 ///redrawn (\ref textReposition). |
277 ///redrawn (\ref textReposition). |
251 void toggleEdgeActivity(BrokenEdge*, bool); |
278 void toggleEdgeActivity(EdgeBase*, bool); |
252 |
279 |
253 public: |
280 public: |
254 |
281 |
255 ///Returns the actual tool in hand |
282 ///Returns the actual tool in hand |
256 int getActualTool(); |
283 int getActualTool(); |