Loop edges.
authorladanyi
Wed, 13 Sep 2006 09:16:29 +0000
changeset 14710ef59f6633c
parent 146 afd1d8bfcccd
child 148 5adf29662354
Loop edges.
gdc-broken_edge.cc
graph_displayer_canvas-edge.cc
graph_displayer_canvas-event.cc
graph_displayer_canvas.cc
graph_displayer_canvas.h
     1.1 --- a/gdc-broken_edge.cc	Wed Aug 30 15:55:18 2006 +0000
     1.2 +++ b/gdc-broken_edge.cc	Wed Sep 13 09:16:29 2006 +0000
     1.3 @@ -1,133 +1,203 @@
     1.4  #include "graph_displayer_canvas.h"
     1.5  #include <cmath>
     1.6  
     1.7 -GraphDisplayerCanvas::BrokenEdge::BrokenEdge(Gnome::Canvas::Group & g, Edge _edge, GraphDisplayerCanvas & gc) : Line(g), edge(_edge), gdc(gc), isbutton(false)
     1.8 +GraphDisplayerCanvas::EdgeBase::EdgeBase(Gnome::Canvas::Group& _group, Edge _edge, GraphDisplayerCanvas& _canvas) : 
     1.9 +  Gnome::Canvas::Group(_group), edge(_edge), canvas(_canvas), arrow(*this)
    1.10  {
    1.11 -  arrow=new Gnome::Canvas::Polygon(g);
    1.12 -  *arrow << Gnome::Canvas::Properties::fill_color("red");
    1.13 -  arrow->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::BrokenEdge::edgeFormerEventHandler));
    1.14 -  arrow->lower_to_bottom();
    1.15 +  arrow.property_fill_color().set_value("red");
    1.16 +  arrow.lower_to_bottom();
    1.17 +}
    1.18 +
    1.19 +GraphDisplayerCanvas::EdgeBase::~EdgeBase()
    1.20 +{
    1.21 +}
    1.22 +
    1.23 +void GraphDisplayerCanvas::EdgeBase::drawArrow(XY unit_vector_in_dir)
    1.24 +{
    1.25 +  MapStorage& ms = canvas.mytab.mapstorage;
    1.26 +  XY center(ms.arrow_pos[edge]);
    1.27 +  XY unit_norm_vector(0-unit_vector_in_dir.y, unit_vector_in_dir.x);
    1.28 +
    1.29 +  //       /\       // top
    1.30 +  //      /  \      //
    1.31 +  //      -  -      // c(enter)l(eft), ccl, ccr, cr
    1.32 +  //       ||       //
    1.33 +  //       ||       // b(ottom)l, br
    1.34 +
    1.35 +  double size=3;
    1.36 +
    1.37 +  XY bl (center - unit_vector_in_dir * 3 * size + unit_norm_vector * size );
    1.38 +  XY br (center - unit_vector_in_dir * 3 * size - unit_norm_vector * size );
    1.39 +  XY ccl(center + unit_vector_in_dir *  size + unit_norm_vector * size );
    1.40 +  XY ccr(center + unit_vector_in_dir *  size - unit_norm_vector * size );
    1.41 +  XY cl (center + unit_vector_in_dir *  size + unit_norm_vector * 2 * size );
    1.42 +  XY cr (center + unit_vector_in_dir *  size - unit_norm_vector * 2 * size );
    1.43 +  XY top(center + unit_vector_in_dir * 3 * size);
    1.44 +
    1.45 +  Gnome::Canvas::Points arrow_points;
    1.46 +  arrow_points.push_back(Gnome::Art::Point( bl.x , bl.y  ) );
    1.47 +  arrow_points.push_back(Gnome::Art::Point( br.x , br.y  ) );
    1.48 +  arrow_points.push_back(Gnome::Art::Point( ccr.x, ccr.y ) );
    1.49 +  arrow_points.push_back(Gnome::Art::Point( cr.x , cr.y  ) );
    1.50 +  arrow_points.push_back(Gnome::Art::Point( top.x, top.y ) );
    1.51 +  arrow_points.push_back(Gnome::Art::Point( cl.x , cl.y  ) );
    1.52 +  arrow_points.push_back(Gnome::Art::Point( ccl.x, ccl.y ) );
    1.53 +
    1.54 +  arrow.property_points().set_value(arrow_points);
    1.55 +}
    1.56 +
    1.57 +GraphDisplayerCanvas::BrokenEdge::BrokenEdge(Gnome::Canvas::Group & g,
    1.58 +    Edge _edge, GraphDisplayerCanvas & gc) : EdgeBase(g, _edge, gc),
    1.59 +  isbutton(false), line(*this)
    1.60 +{
    1.61 +  arrow.signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::BrokenEdge::edgeFormerEventHandler));
    1.62 +
    1.63 +  line.property_fill_color().set_value("green");
    1.64 +  line.property_width_units().set_value(10);    
    1.65 +  line.lower_to_bottom();
    1.66 +
    1.67    draw();
    1.68  }
    1.69  
    1.70  GraphDisplayerCanvas::BrokenEdge::~BrokenEdge()
    1.71  {
    1.72 -  if(arrow)delete(arrow);
    1.73  }
    1.74  
    1.75  void GraphDisplayerCanvas::BrokenEdge::draw()
    1.76  {
    1.77 -  MapStorage& ms = gdc.mytab.mapstorage;
    1.78 +  MapStorage& ms = canvas.mytab.mapstorage;
    1.79 +
    1.80 +  //calculating coordinates of the direction indicator arrow
    1.81 +  XY head(ms.coords[ms.graph.target(edge)]);
    1.82 +  XY center(ms.arrow_pos[edge]);
    1.83 +
    1.84 +  XY unit_vector_in_dir(head-center);
    1.85 +  double length=sqrt( unit_vector_in_dir.normSquare() );
    1.86 +
    1.87 +  unit_vector_in_dir/=length;
    1.88 +
    1.89 +  // update the arrow
    1.90 +  drawArrow(unit_vector_in_dir);
    1.91  
    1.92    // update the edge
    1.93 -  {
    1.94 -    Gnome::Canvas::Points points;
    1.95 -    Node source = ms.graph.source(edge);
    1.96 -    Node target = ms.graph.target(edge);
    1.97 -    points.push_back(Gnome::Art::Point(ms.coords[source].x,
    1.98 -          ms.coords[source].y));
    1.99 -    points.push_back(Gnome::Art::Point(ms.arrow_pos[edge].x,
   1.100 -          ms.arrow_pos[edge].y));
   1.101 -    points.push_back(Gnome::Art::Point(ms.coords[target].x,
   1.102 -          ms.coords[target].y));
   1.103 -    property_points().set_value(points);
   1.104 -  }
   1.105 -
   1.106 -  // update the arrow
   1.107 -  {
   1.108 -    //calculating coordinates of the direction indicator arrow
   1.109 -    XY target(ms.coords[ms.graph.target(edge)]);
   1.110 -    XY center(ms.arrow_pos[edge]);
   1.111 -
   1.112 -    XY unit_vector_in_dir(target-center);
   1.113 -    double length=sqrt( unit_vector_in_dir.normSquare() );
   1.114 -
   1.115 -    //       std::cout << target << " - " << center << " = " << unit_vector_in_dir << "    / " <<unit_vector_in_dir.normSquare() ;
   1.116 -    unit_vector_in_dir/=length;
   1.117 -    //       std::cout << " = " << unit_vector_in_dir << std::endl;
   1.118 -
   1.119 -    XY unit_norm_vector(0-unit_vector_in_dir.y, unit_vector_in_dir.x);
   1.120 -    //       std::cout << unit_norm_vector << std::endl;
   1.121 -
   1.122 -    {      
   1.123 -      //       /\       // top
   1.124 -      //      /  \      //
   1.125 -      //      -  -      // c(enter)l(eft), ccl, ccr, cr
   1.126 -      //       ||       //
   1.127 -      //       ||       // b(ottom)l, br
   1.128 -    }
   1.129 -
   1.130 -    double size=3;
   1.131 -
   1.132 -    XY bl (center - unit_vector_in_dir * 3 * size + unit_norm_vector * size );
   1.133 -    XY br (center - unit_vector_in_dir * 3 * size - unit_norm_vector * size );
   1.134 -    XY ccl(center + unit_vector_in_dir *  size + unit_norm_vector * size );
   1.135 -    XY ccr(center + unit_vector_in_dir *  size - unit_norm_vector * size );
   1.136 -    XY cl (center + unit_vector_in_dir *  size + unit_norm_vector * 2 * size );
   1.137 -    XY cr (center + unit_vector_in_dir *  size - unit_norm_vector * 2 * size );
   1.138 -    XY top(center + unit_vector_in_dir * 3 * size);
   1.139 -
   1.140 -    //std::cout << bl << " " << br << " " << ccl << " "  << ccr << " " << cl << " " << cr << " " << top << std::endl;
   1.141 -
   1.142 -    Gnome::Canvas::Points arrow_points;
   1.143 -    arrow_points.push_back(Gnome::Art::Point( bl.x , bl.y  ) );
   1.144 -    arrow_points.push_back(Gnome::Art::Point( br.x , br.y  ) );
   1.145 -    arrow_points.push_back(Gnome::Art::Point( ccr.x, ccr.y ) );
   1.146 -    arrow_points.push_back(Gnome::Art::Point( cr.x , cr.y  ) );
   1.147 -    arrow_points.push_back(Gnome::Art::Point( top.x, top.y ) );
   1.148 -    arrow_points.push_back(Gnome::Art::Point( cl.x , cl.y  ) );
   1.149 -    arrow_points.push_back(Gnome::Art::Point( ccl.x, ccl.y ) );
   1.150 -
   1.151 -    arrow->property_points().set_value(arrow_points);
   1.152 -  }
   1.153 +  Gnome::Canvas::Points points;
   1.154 +  Node source = ms.graph.source(edge);
   1.155 +  Node target = ms.graph.target(edge);
   1.156 +  points.push_back(Gnome::Art::Point(ms.coords[source].x,
   1.157 +        ms.coords[source].y));
   1.158 +  points.push_back(Gnome::Art::Point(ms.arrow_pos[edge].x,
   1.159 +        ms.arrow_pos[edge].y));
   1.160 +  points.push_back(Gnome::Art::Point(ms.coords[target].x,
   1.161 +        ms.coords[target].y));
   1.162 +  line.property_points().set_value(points);
   1.163  }
   1.164  
   1.165  bool GraphDisplayerCanvas::BrokenEdge::edgeFormerEventHandler(GdkEvent* e)
   1.166  {
   1.167    switch(e->type)
   1.168 -    {
   1.169 +  {
   1.170      case GDK_BUTTON_PRESS:
   1.171 -      //we mark the location of the event to be able to calculate parameters of dragging
   1.172 -      if(gdc.getActualTool()!=CREATE_NODE)
   1.173 -	{
   1.174 -	  gdc.toggleEdgeActivity(this, true);
   1.175 -	  clicked_x=e->button.x;
   1.176 -	  clicked_y=e->button.y;
   1.177 -	  isbutton=true;
   1.178 -	}
   1.179 +      //we mark the location of the event to be able to calculate parameters
   1.180 +      //of dragging
   1.181 +      if(canvas.getActualTool()!=CREATE_NODE)
   1.182 +      {
   1.183 +        canvas.toggleEdgeActivity(this, true);
   1.184 +        clicked_x=e->button.x;
   1.185 +        clicked_y=e->button.y;
   1.186 +        isbutton=true;
   1.187 +      }
   1.188        break;
   1.189      case GDK_BUTTON_RELEASE:
   1.190 -      if(gdc.getActualTool()!=CREATE_NODE)
   1.191 -	{
   1.192 -	  gdc.toggleEdgeActivity(this, false);
   1.193 -	  isbutton=false;
   1.194 -	}
   1.195 +      if(canvas.getActualTool()!=CREATE_NODE)
   1.196 +      {
   1.197 +        canvas.toggleEdgeActivity(this, false);
   1.198 +        isbutton=false;
   1.199 +      }
   1.200        break;
   1.201      case GDK_MOTION_NOTIFY:
   1.202        //we only have to do sg. if the mouse button is pressed
   1.203        if(isbutton)
   1.204 -	{
   1.205 -	  //new coordinates will be the old values,
   1.206 -	  //because the item will be moved to the
   1.207 -	  //new coordinate therefore the new movement
   1.208 -	  //has to be calculated from here
   1.209 +      {
   1.210 +        //new coordinates will be the old values,
   1.211 +        //because the item will be moved to the
   1.212 +        //new coordinate therefore the new movement
   1.213 +        //has to be calculated from here
   1.214  
   1.215 -	  double dx=e->motion.x-clicked_x;
   1.216 -	  double dy=e->motion.y-clicked_y;
   1.217 +        double dx=e->motion.x-clicked_x;
   1.218 +        double dy=e->motion.y-clicked_y;
   1.219  
   1.220 -	  Gnome::Canvas::Points points_new;
   1.221 +        Gnome::Canvas::Points points_new;
   1.222  
   1.223 -          gdc.mytab.mapstorage.arrow_pos.set(edge, gdc.mytab.mapstorage.arrow_pos[edge] + XY(dx, dy));
   1.224 +        canvas.mytab.mapstorage.arrow_pos.set(edge, canvas.mytab.mapstorage.arrow_pos[edge] + XY(dx, dy));
   1.225  
   1.226 -	  draw();
   1.227 -	  gdc.textReposition(gdc.mytab.mapstorage.arrow_pos[edge]);
   1.228 +        draw();
   1.229 +        canvas.textReposition(canvas.mytab.mapstorage.arrow_pos[edge]);
   1.230  
   1.231 -	  clicked_x=e->motion.x;
   1.232 -	  clicked_y=e->motion.y;
   1.233 +        clicked_x=e->motion.x;
   1.234 +        clicked_y=e->motion.y;
   1.235  
   1.236 -	}
   1.237 +      }
   1.238      default: break;
   1.239 -    }
   1.240 +  }
   1.241  
   1.242    return true;
   1.243  }
   1.244 +
   1.245 +void GraphDisplayerCanvas::BrokenEdge::setLineWidth(int w)
   1.246 +{
   1.247 +  line.property_width_units().set_value(w);
   1.248 +}
   1.249 +
   1.250 +void GraphDisplayerCanvas::BrokenEdge::setFillColor(Gdk::Color c)
   1.251 +{
   1.252 +  line.property_fill_color_gdk().set_value(c);
   1.253 +}
   1.254 +
   1.255 +GraphDisplayerCanvas::LoopEdge::LoopEdge(Gnome::Canvas::Group& _group,
   1.256 +    Edge _edge, GraphDisplayerCanvas& _canvas) :
   1.257 +  EdgeBase(_group, _edge, _canvas), line(*this)
   1.258 +{
   1.259 +  line.property_fill_color().set_value("green");
   1.260 +  line.property_width_units().set_value(10);    
   1.261 +  line.lower_to_bottom();
   1.262 +
   1.263 +  draw();
   1.264 +}
   1.265 +
   1.266 +GraphDisplayerCanvas::LoopEdge::~LoopEdge()
   1.267 +{
   1.268 +}
   1.269 +
   1.270 +void GraphDisplayerCanvas::LoopEdge::draw()
   1.271 +{
   1.272 +  MapStorage& ms = canvas.mytab.mapstorage;
   1.273 +
   1.274 +  Node node = ms.graph.source(edge);
   1.275 +  XY center = (ms.coords[node] + ms.arrow_pos[edge]) / 2.0;
   1.276 +
   1.277 +  XY unit_vector_in_dir(rot90(center - ms.arrow_pos[edge]));
   1.278 +  double length = sqrt(unit_vector_in_dir.normSquare());
   1.279 +  unit_vector_in_dir /= length;
   1.280 +
   1.281 +  drawArrow(unit_vector_in_dir);
   1.282 +
   1.283 +  double radius =
   1.284 +    sqrt((ms.arrow_pos[edge] - ms.coords[node]).normSquare()) / 2.0;
   1.285 +
   1.286 +  XY p1 = center + XY(-radius,  radius);
   1.287 +  XY p2 = center + XY( radius, -radius);
   1.288 +  line.property_x1().set_value(p1.x);
   1.289 +  line.property_y1().set_value(p1.y);
   1.290 +  line.property_x2().set_value(p2.x);
   1.291 +  line.property_y2().set_value(p2.y);
   1.292 +}
   1.293 +
   1.294 +void GraphDisplayerCanvas::LoopEdge::setLineWidth(int w)
   1.295 +{
   1.296 +  line.property_width_units().set_value(w);
   1.297 +}
   1.298 +
   1.299 +void GraphDisplayerCanvas::LoopEdge::setFillColor(Gdk::Color c)
   1.300 +{
   1.301 +  line.property_fill_color_gdk().set_value(c);
   1.302 +}
     2.1 --- a/graph_displayer_canvas-edge.cc	Wed Aug 30 15:55:18 2006 +0000
     2.2 +++ b/graph_displayer_canvas-edge.cc	Wed Sep 13 09:16:29 2006 +0000
     2.3 @@ -24,7 +24,7 @@
     2.4  	    {
     2.5  	      w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH));
     2.6  	    }
     2.7 -	  edgesmap[i]->property_width_units().set_value(w);
     2.8 +	  edgesmap[i]->setLineWidth(w);
     2.9  	}
    2.10      }
    2.11    else
    2.12 @@ -32,7 +32,7 @@
    2.13        int w=(int)actual_map[edge];
    2.14        if(w>=0)
    2.15  	{
    2.16 -	  edgesmap[edge]->property_width_units().set_value(w);
    2.17 +	  edgesmap[edge]->setLineWidth(w);
    2.18  	}
    2.19      }
    2.20    return 0;
    2.21 @@ -62,7 +62,7 @@
    2.22  	    {
    2.23  	      w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH));
    2.24  	    }
    2.25 -	  edgesmap[i]->property_width_units().set_value(w);
    2.26 +	  edgesmap[i]->setLineWidth(w);
    2.27  	}
    2.28      }
    2.29    else
    2.30 @@ -70,7 +70,7 @@
    2.31        int w=(int)(*actual_map)[edge];
    2.32        if(w>=0)
    2.33  	{
    2.34 -	  edgesmap[edge]->property_width_units().set_value(w);
    2.35 +	  edgesmap[edge]->setLineWidth(w);
    2.36  	}
    2.37      }
    2.38    return 0;
    2.39 @@ -105,7 +105,7 @@
    2.40  	    {
    2.41  	      color.set_rgb_p (0, 100, 0);
    2.42  	    }
    2.43 -	  edgesmap[i]->property_fill_color_gdk().set_value(color);
    2.44 +	  edgesmap[i]->setFillColor(color);
    2.45  	}
    2.46      }
    2.47    else
    2.48 @@ -123,7 +123,7 @@
    2.49  	  color.set_rgb_p (0, 100, 0);
    2.50  	}
    2.51  
    2.52 -      edgesmap[edge]->property_fill_color_gdk().set_value(color);
    2.53 +      edgesmap[edge]->setFillColor(color);
    2.54      }
    2.55    return 0;
    2.56  };
    2.57 @@ -156,7 +156,7 @@
    2.58  	    {
    2.59  	      color.set_rgb_p (0, 100, 0);
    2.60  	    }
    2.61 -	  edgesmap[i]->property_fill_color_gdk().set_value(color);
    2.62 +	  edgesmap[i]->setFillColor(color);
    2.63  	}
    2.64      }
    2.65    else
    2.66 @@ -174,7 +174,7 @@
    2.67  	  color.set_rgb_p (0, 100, 0);
    2.68  	}
    2.69  
    2.70 -      edgesmap[edge]->property_fill_color_gdk().set_value(color);
    2.71 +      edgesmap[edge]->setFillColor(color);
    2.72      }
    2.73    return 0;
    2.74  };
     3.1 --- a/graph_displayer_canvas-event.cc	Wed Aug 30 15:55:18 2006 +0000
     3.2 +++ b/graph_displayer_canvas-event.cc	Wed Sep 13 09:16:29 2006 +0000
     3.3 @@ -462,11 +462,6 @@
     3.4                //drawing new edge
     3.5                edgesmap[active_edge]=new BrokenEdge(displayed_graph, active_edge,
     3.6                    *this);
     3.7 -              *(edgesmap[active_edge]) <<
     3.8 -                Gnome::Canvas::Properties::fill_color("green");
     3.9 -              edgesmap[active_edge]->property_width_pixels().set_value(10);
    3.10 -
    3.11 -              edgesmap[active_edge]->lower_to_bottom();
    3.12  
    3.13                //initializing edge-text as well, to empty string
    3.14                XY text_pos=mytab.mapstorage.arrow_pos[active_edge];
    3.15 @@ -829,34 +824,34 @@
    3.16    edgetextmap[forming_edge]->property_y().set_value(new_place.y);
    3.17  }
    3.18  
    3.19 -void GraphDisplayerCanvas::toggleEdgeActivity(BrokenEdge* active_bre, bool on)
    3.20 +void GraphDisplayerCanvas::toggleEdgeActivity(EdgeBase* active_bre, bool on)
    3.21  {
    3.22    if(on)
    3.23 +  {
    3.24 +    if(forming_edge!=INVALID)
    3.25      {
    3.26 -      if(forming_edge!=INVALID)
    3.27 -	{
    3.28 -	  std::cerr << "ERROR!!!! Valid edge found!" << std::endl;
    3.29 -	}
    3.30 -      else
    3.31 -	{
    3.32 -	  for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    3.33 -	    {
    3.34 -	      if(edgesmap[i]==active_bre)
    3.35 -		{
    3.36 -		  forming_edge=i;
    3.37 -		}
    3.38 -	    }
    3.39 -	}
    3.40 +      std::cerr << "ERROR!!!! Valid edge found!" << std::endl;
    3.41      }
    3.42 +    else
    3.43 +    {
    3.44 +      for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
    3.45 +      {
    3.46 +        if(edgesmap[i]==active_bre)
    3.47 +        {
    3.48 +          forming_edge=i;
    3.49 +        }
    3.50 +      }
    3.51 +    }
    3.52 +  }
    3.53    else
    3.54 +  {
    3.55 +    if(forming_edge!=INVALID)
    3.56      {
    3.57 -      if(forming_edge!=INVALID)
    3.58 -	{
    3.59 -	  forming_edge=INVALID;
    3.60 -	}
    3.61 -      else
    3.62 -	{
    3.63 -	  std::cerr << "ERROR!!!! Invalid edge found!" << std::endl;
    3.64 -	}
    3.65 +      forming_edge=INVALID;
    3.66      }
    3.67 +    else
    3.68 +    {
    3.69 +      std::cerr << "ERROR!!!! Invalid edge found!" << std::endl;
    3.70 +    }
    3.71 +  }
    3.72  }
     4.1 --- a/graph_displayer_canvas.cc	Wed Aug 30 15:55:18 2006 +0000
     4.2 +++ b/graph_displayer_canvas.cc	Wed Sep 13 09:16:29 2006 +0000
     4.3 @@ -169,9 +169,6 @@
     4.4            (mytab.mapstorage).coords[(mytab.mapstorage).graph.target(i)].y));
     4.5      
     4.6      edgesmap[i]=new BrokenEdge(displayed_graph, i, *this);
     4.7 -    *(edgesmap[i]) << Gnome::Canvas::Properties::fill_color("green");
     4.8 -    edgesmap[i]->property_width_units().set_value(10);    
     4.9 -    edgesmap[i]->lower_to_bottom();
    4.10      
    4.11      //initializing edge-text as well, to empty string
    4.12  
     5.1 --- a/graph_displayer_canvas.h	Wed Aug 30 15:55:18 2006 +0000
     5.2 +++ b/graph_displayer_canvas.h	Wed Sep 13 09:16:29 2006 +0000
     5.3 @@ -15,6 +15,35 @@
     5.4  class GraphDisplayerCanvas : public Gnome::Canvas::CanvasAA
     5.5  {
     5.6    friend class BrokenEdge;
     5.7 +  friend class LoopEdge;
     5.8 +
     5.9 +  class EdgeBase : public Gnome::Canvas::Group
    5.10 +  {
    5.11 +    protected:
    5.12 +      ///Reference to the canvas, on which the graph is drawn.
    5.13 +
    5.14 +      ///It is needed, because some datas needed from
    5.15 +      ///graph can be accessed by this or should be sent
    5.16 +      ///as parameter, but it would be complicated
    5.17 +      GraphDisplayerCanvas& canvas;
    5.18 +
    5.19 +      ///The edge that the class displays.
    5.20 +
    5.21 +      ///It is needed, because some datas needed from
    5.22 +      ///graph can be accessed by this or should be sent
    5.23 +      ///as parameter, but it would be complicated
    5.24 +      Edge edge;
    5.25 +
    5.26 +      Gnome::Canvas::Polygon arrow;
    5.27 +
    5.28 +      void drawArrow(XY);
    5.29 +    public:
    5.30 +      EdgeBase(Gnome::Canvas::Group&, Edge, GraphDisplayerCanvas&);
    5.31 +      virtual ~EdgeBase();
    5.32 +      virtual void draw() = 0;
    5.33 +      virtual void setLineWidth(int) = 0;
    5.34 +      virtual void setFillColor(Gdk::Color) = 0;
    5.35 +  };
    5.36  
    5.37    ///Edge displayer class
    5.38  
    5.39 @@ -23,65 +52,63 @@
    5.40    ///aim of this is to be able to indicate direction of edges
    5.41    ///and to be able to display more then one edges between the
    5.42    ///same source and target
    5.43 -  class BrokenEdge : public Gnome::Canvas::Line
    5.44 +  class BrokenEdge : public EdgeBase
    5.45    {
    5.46 -    ///The edge that the class displays.
    5.47 +    private:
    5.48 +      Gnome::Canvas::Line line;
    5.49  
    5.50 -    ///It is needed, because some datas needed from
    5.51 -    ///graph can be accessed by this or should be sent
    5.52 -    ///as parameter, but it would be complicated
    5.53 -    Edge edge;
    5.54 +      ///Indicates whether the button of mouse is pressed or not at the moment.
    5.55 +      bool isbutton;
    5.56  
    5.57 -    ///Reference to the canvas, on which the graph is drawn.
    5.58 +      ///At this location was the mousebutton pressed. Horizontal component.
    5.59  
    5.60 -    ///It is needed, because some datas needed from
    5.61 -    ///graph can be accessed by this or should be sent
    5.62 -    ///as parameter, but it would be complicated
    5.63 -    GraphDisplayerCanvas & gdc;
    5.64 +      ///It helps to calculate the
    5.65 +      ///distance of dragging.
    5.66 +      double clicked_x;
    5.67  
    5.68 -    ///An arrow that indicates the direction of the edges
    5.69 +      ///At this location was the mousebutton pressed. Vertical component.
    5.70  
    5.71 -    ///in case of directional graph direction can be indicated
    5.72 -    ///by this polygon. The polygon formulates a red arrow.
    5.73 -    Gnome::Canvas::Polygon * arrow;
    5.74 +      ///It helps to calculate the
    5.75 +      ///distance of dragging.
    5.76 +      double clicked_y;
    5.77  
    5.78 -    ///Indicates whether the button of mouse is pressed or not at the moment.
    5.79 -    bool isbutton;
    5.80 +      ///event handler for forming broken edges
    5.81  
    5.82 -    ///At this location was the mousebutton pressed. Horizontal component.
    5.83 +      ///\param event the
    5.84 +      ///event to handle
    5.85 +      bool edgeFormerEventHandler(GdkEvent* event);
    5.86  
    5.87 -    ///It helps to calculate the
    5.88 -    ///distance of dragging.
    5.89 -    double clicked_x;
    5.90 +    public:
    5.91 +      ///Constructor of broken edge class.
    5.92  
    5.93 -    ///At this location was the mousebutton pressed. Vertical component.
    5.94 +      ///\param g the group to which the edge belongs
    5.95 +      ///\param _edge the represented edge
    5.96 +      ///\param gc the canvas
    5.97 +      BrokenEdge(Gnome::Canvas::Group&, Edge, GraphDisplayerCanvas&);
    5.98  
    5.99 -    ///It helps to calculate the
   5.100 -    ///distance of dragging.
   5.101 -    double clicked_y;
   5.102 +      ///Destructor of broken edge class
   5.103  
   5.104 -    ///event handler for forming broken edges
   5.105 +      ///Frees up
   5.106 +      ///reserved memory
   5.107 +      ~BrokenEdge();
   5.108  
   5.109 -    ///\param event the
   5.110 -    ///event to handle
   5.111 -    bool edgeFormerEventHandler(GdkEvent* event);
   5.112 -  public:
   5.113 +      ///The function that draws the edge based on collected data
   5.114 +      void draw();
   5.115  
   5.116 -    ///Constructor of broken edge class.
   5.117 +      void setLineWidth(int);
   5.118 +      void setFillColor(Gdk::Color);
   5.119 +  };
   5.120  
   5.121 -    ///\param g the group to which the edge belongs
   5.122 -    ///\param _edge the represented edge
   5.123 -    ///\param gc the canvas
   5.124 -    BrokenEdge(Gnome::Canvas::Group & g, Edge _edge, GraphDisplayerCanvas & gc);
   5.125 -
   5.126 -    ///Destructor of broken edge class
   5.127 -
   5.128 -    ///Frees up
   5.129 -    ///reserved memory
   5.130 -    ~BrokenEdge();
   5.131 -
   5.132 -    ///The function that draws the edge based on collected data
   5.133 -    void draw();
   5.134 +  class LoopEdge : public EdgeBase
   5.135 +  {
   5.136 +    private:
   5.137 +      Gnome::Canvas::Ellipse line;
   5.138 +    public:
   5.139 +      LoopEdge(Gnome::Canvas::Group&, Edge, GraphDisplayerCanvas&);
   5.140 +      ~LoopEdge();
   5.141 +      void draw();
   5.142 +      void setLineWidth(int);
   5.143 +      void setFillColor(Gdk::Color);
   5.144    };
   5.145  
   5.146    ///Type of canvas, on which the graph is drawn
   5.147 @@ -241,14 +268,14 @@
   5.148    ///Moves the text to new place
   5.149    void textReposition(xy<double>);
   5.150  
   5.151 -  ///Activates an edge belonging to a BrokenEdge
   5.152 +  ///Activates an edge belonging to an EdgeBase
   5.153  
   5.154    ///After we have activated an edge this way,
   5.155    ///the GDC object will know, which edge is under forming
   5.156    ///therefore it can redraw the necessary elements on the canvas,
   5.157 -  ///for example the text belonging to the \ref BrokenEdge can be
   5.158 +  ///for example the text belonging to the \ref EdgeBase can be
   5.159    ///redrawn (\ref textReposition).
   5.160 -  void toggleEdgeActivity(BrokenEdge*, bool);
   5.161 +  void toggleEdgeActivity(EdgeBase*, bool);
   5.162  
   5.163  public:
   5.164  
   5.165 @@ -289,7 +316,7 @@
   5.166    Graph::NodeMap<Gnome::Canvas::Ellipse *> nodesmap;
   5.167  
   5.168    ///Map of edges of graph
   5.169 -  Graph::EdgeMap<BrokenEdge *> edgesmap;
   5.170 +  Graph::EdgeMap<EdgeBase*> edgesmap;
   5.171  
   5.172    ///Map of texts to write on edges
   5.173    Graph::EdgeMap<Gnome::Canvas::Text *> edgetextmap;