1.1 --- a/graph_displayer_canvas.h Wed Aug 30 15:55:18 2006 +0000
1.2 +++ b/graph_displayer_canvas.h Wed Sep 13 09:16:29 2006 +0000
1.3 @@ -15,6 +15,35 @@
1.4 class GraphDisplayerCanvas : public Gnome::Canvas::CanvasAA
1.5 {
1.6 friend class BrokenEdge;
1.7 + friend class LoopEdge;
1.8 +
1.9 + class EdgeBase : public Gnome::Canvas::Group
1.10 + {
1.11 + protected:
1.12 + ///Reference to the canvas, on which the graph is drawn.
1.13 +
1.14 + ///It is needed, because some datas needed from
1.15 + ///graph can be accessed by this or should be sent
1.16 + ///as parameter, but it would be complicated
1.17 + GraphDisplayerCanvas& canvas;
1.18 +
1.19 + ///The edge that the class displays.
1.20 +
1.21 + ///It is needed, because some datas needed from
1.22 + ///graph can be accessed by this or should be sent
1.23 + ///as parameter, but it would be complicated
1.24 + Edge edge;
1.25 +
1.26 + Gnome::Canvas::Polygon arrow;
1.27 +
1.28 + void drawArrow(XY);
1.29 + public:
1.30 + EdgeBase(Gnome::Canvas::Group&, Edge, GraphDisplayerCanvas&);
1.31 + virtual ~EdgeBase();
1.32 + virtual void draw() = 0;
1.33 + virtual void setLineWidth(int) = 0;
1.34 + virtual void setFillColor(Gdk::Color) = 0;
1.35 + };
1.36
1.37 ///Edge displayer class
1.38
1.39 @@ -23,65 +52,63 @@
1.40 ///aim of this is to be able to indicate direction of edges
1.41 ///and to be able to display more then one edges between the
1.42 ///same source and target
1.43 - class BrokenEdge : public Gnome::Canvas::Line
1.44 + class BrokenEdge : public EdgeBase
1.45 {
1.46 - ///The edge that the class displays.
1.47 + private:
1.48 + Gnome::Canvas::Line line;
1.49
1.50 - ///It is needed, because some datas needed from
1.51 - ///graph can be accessed by this or should be sent
1.52 - ///as parameter, but it would be complicated
1.53 - Edge edge;
1.54 + ///Indicates whether the button of mouse is pressed or not at the moment.
1.55 + bool isbutton;
1.56
1.57 - ///Reference to the canvas, on which the graph is drawn.
1.58 + ///At this location was the mousebutton pressed. Horizontal component.
1.59
1.60 - ///It is needed, because some datas needed from
1.61 - ///graph can be accessed by this or should be sent
1.62 - ///as parameter, but it would be complicated
1.63 - GraphDisplayerCanvas & gdc;
1.64 + ///It helps to calculate the
1.65 + ///distance of dragging.
1.66 + double clicked_x;
1.67
1.68 - ///An arrow that indicates the direction of the edges
1.69 + ///At this location was the mousebutton pressed. Vertical component.
1.70
1.71 - ///in case of directional graph direction can be indicated
1.72 - ///by this polygon. The polygon formulates a red arrow.
1.73 - Gnome::Canvas::Polygon * arrow;
1.74 + ///It helps to calculate the
1.75 + ///distance of dragging.
1.76 + double clicked_y;
1.77
1.78 - ///Indicates whether the button of mouse is pressed or not at the moment.
1.79 - bool isbutton;
1.80 + ///event handler for forming broken edges
1.81
1.82 - ///At this location was the mousebutton pressed. Horizontal component.
1.83 + ///\param event the
1.84 + ///event to handle
1.85 + bool edgeFormerEventHandler(GdkEvent* event);
1.86
1.87 - ///It helps to calculate the
1.88 - ///distance of dragging.
1.89 - double clicked_x;
1.90 + public:
1.91 + ///Constructor of broken edge class.
1.92
1.93 - ///At this location was the mousebutton pressed. Vertical component.
1.94 + ///\param g the group to which the edge belongs
1.95 + ///\param _edge the represented edge
1.96 + ///\param gc the canvas
1.97 + BrokenEdge(Gnome::Canvas::Group&, Edge, GraphDisplayerCanvas&);
1.98
1.99 - ///It helps to calculate the
1.100 - ///distance of dragging.
1.101 - double clicked_y;
1.102 + ///Destructor of broken edge class
1.103
1.104 - ///event handler for forming broken edges
1.105 + ///Frees up
1.106 + ///reserved memory
1.107 + ~BrokenEdge();
1.108
1.109 - ///\param event the
1.110 - ///event to handle
1.111 - bool edgeFormerEventHandler(GdkEvent* event);
1.112 - public:
1.113 + ///The function that draws the edge based on collected data
1.114 + void draw();
1.115
1.116 - ///Constructor of broken edge class.
1.117 + void setLineWidth(int);
1.118 + void setFillColor(Gdk::Color);
1.119 + };
1.120
1.121 - ///\param g the group to which the edge belongs
1.122 - ///\param _edge the represented edge
1.123 - ///\param gc the canvas
1.124 - BrokenEdge(Gnome::Canvas::Group & g, Edge _edge, GraphDisplayerCanvas & gc);
1.125 -
1.126 - ///Destructor of broken edge class
1.127 -
1.128 - ///Frees up
1.129 - ///reserved memory
1.130 - ~BrokenEdge();
1.131 -
1.132 - ///The function that draws the edge based on collected data
1.133 - void draw();
1.134 + class LoopEdge : public EdgeBase
1.135 + {
1.136 + private:
1.137 + Gnome::Canvas::Ellipse line;
1.138 + public:
1.139 + LoopEdge(Gnome::Canvas::Group&, Edge, GraphDisplayerCanvas&);
1.140 + ~LoopEdge();
1.141 + void draw();
1.142 + void setLineWidth(int);
1.143 + void setFillColor(Gdk::Color);
1.144 };
1.145
1.146 ///Type of canvas, on which the graph is drawn
1.147 @@ -241,14 +268,14 @@
1.148 ///Moves the text to new place
1.149 void textReposition(xy<double>);
1.150
1.151 - ///Activates an edge belonging to a BrokenEdge
1.152 + ///Activates an edge belonging to an EdgeBase
1.153
1.154 ///After we have activated an edge this way,
1.155 ///the GDC object will know, which edge is under forming
1.156 ///therefore it can redraw the necessary elements on the canvas,
1.157 - ///for example the text belonging to the \ref BrokenEdge can be
1.158 + ///for example the text belonging to the \ref EdgeBase can be
1.159 ///redrawn (\ref textReposition).
1.160 - void toggleEdgeActivity(BrokenEdge*, bool);
1.161 + void toggleEdgeActivity(EdgeBase*, bool);
1.162
1.163 public:
1.164
1.165 @@ -289,7 +316,7 @@
1.166 Graph::NodeMap<Gnome::Canvas::Ellipse *> nodesmap;
1.167
1.168 ///Map of edges of graph
1.169 - Graph::EdgeMap<BrokenEdge *> edgesmap;
1.170 + Graph::EdgeMap<EdgeBase*> edgesmap;
1.171
1.172 ///Map of texts to write on edges
1.173 Graph::EdgeMap<Gnome::Canvas::Text *> edgetextmap;