Index: gdc-broken_edge.cc
===================================================================
--- gdc-broken_edge.cc	(revision 93)
+++ gdc-broken_edge.cc	(revision 98)
@@ -2,13 +2,11 @@
 #include <cmath>
 
-GraphDisplayerCanvas::BrokenEdge::BrokenEdge(Gnome::Canvas::Group & g, Gnome::Canvas::Points p, GraphDisplayerCanvas & gc) : Line(g), gdc(gc), isbutton(false)
+GraphDisplayerCanvas::BrokenEdge::BrokenEdge(Gnome::Canvas::Group & g, Edge _edge, GraphDisplayerCanvas & gc) : Line(g), edge(_edge), gdc(gc), isbutton(false)
 {
-  my_points=new Gnome::Art::Point[3];
-
   arrow=new Gnome::Canvas::Polygon(g);
   *arrow << Gnome::Canvas::Properties::fill_color("red");
   arrow->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::BrokenEdge::edgeFormerEventHandler));
   arrow->lower_to_bottom();
-  setPoints(p);
+  draw();
 }
 
@@ -18,153 +16,69 @@
 }
 
-void GraphDisplayerCanvas::BrokenEdge::setPoints(Gnome::Canvas::Points p, bool move)
+void GraphDisplayerCanvas::BrokenEdge::draw()
 {
-  bool set_arrow=false;
-  //red arrow losts its position-right button
-  if(!move)
-    {
-      if(p.size()==2)
-	{
-	  set_arrow=true;
-	  Gnome::Canvas::Points points_with_center;
-	  points_with_center.push_back(my_points[0]=p[0]);
-	  points_with_center.push_back(my_points[1]=Gnome::Art::Point( (p[0].get_x()+p[1].get_x())/2+0 , (p[0].get_y()+p[1].get_y())/2 )+0 );
-	  points_with_center.push_back(my_points[2]=p[1]);
-	  property_points().set_value(points_with_center);
-	}  
-      if(p.size()==3)
-	{
-	  set_arrow=true;
-	  property_points().set_value(p);
-	  for(int i=0;i<3;i++)
-	    {
-	      my_points[i]=p[i];
-	    }
-	}
+  MapStorage& ms = gdc.mytab.mapstorage;
+
+  // update the edge
+  {
+    Gnome::Canvas::Points points;
+    Node source = ms.graph.source(edge);
+    Node target = ms.graph.target(edge);
+    points.push_back(Gnome::Art::Point(ms.coords[source].x,
+          ms.coords[source].y));
+    points.push_back(Gnome::Art::Point(ms.arrow_pos[edge].x,
+          ms.arrow_pos[edge].y));
+    points.push_back(Gnome::Art::Point(ms.coords[target].x,
+          ms.coords[target].y));
+    property_points().set_value(points);
+  }
+
+  // update the arrow
+  {
+    //calculating coordinates of the direction indicator arrow
+    XY target(ms.coords[ms.graph.target(edge)]);
+    XY center(ms.arrow_pos[edge]);
+
+    XY unit_vector_in_dir(target-center);
+    double length=sqrt( unit_vector_in_dir.normSquare() );
+
+    //       std::cout << target << " - " << center << " = " << unit_vector_in_dir << "    / " <<unit_vector_in_dir.normSquare() ;
+    unit_vector_in_dir/=length;
+    //       std::cout << " = " << unit_vector_in_dir << std::endl;
+
+    XY unit_norm_vector(0-unit_vector_in_dir.y, unit_vector_in_dir.x);
+    //       std::cout << unit_norm_vector << std::endl;
+
+    {      
+      //       /\       // top
+      //      /  \      //
+      //      -  -      // c(enter)l(eft), ccl, ccr, cr
+      //       ||       //
+      //       ||       // b(ottom)l, br
     }
-  else
-    {
-      //arrow keeps its position-left button
 
-//       if(p.size()==2)
-//       	{
-//       	  Gnome::Canvas::Points points;
-//       	  my_points[0]=p[0];
-//       	  my_points[2]=p[1];
-//       	  for(int i=0;i<3;i++)
-//       	    {
-//       	      points.push_back(my_points[i]);
-//       	    }
-//       	  property_points().set_value(points);
-//       	}
-      set_arrow=true;
+    double size=3;
 
-      //////////////////////////////////////////////////////////////////////////////////////////////////////
-      /////////// keeps shape-with scalar multiplication - version 2.
-      //////////////////////////////////////////////////////////////////////////////////////////////////////
+    XY bl (center - unit_vector_in_dir * 3 * size + unit_norm_vector * size );
+    XY br (center - unit_vector_in_dir * 3 * size - unit_norm_vector * size );
+    XY ccl(center + unit_vector_in_dir *  size + unit_norm_vector * size );
+    XY ccr(center + unit_vector_in_dir *  size - unit_norm_vector * size );
+    XY cl (center + unit_vector_in_dir *  size + unit_norm_vector * 2 * size );
+    XY cr (center + unit_vector_in_dir *  size - unit_norm_vector * 2 * size );
+    XY top(center + unit_vector_in_dir * 3 * size);
 
-      if(p.size()==2)
-      	{
-	  //old vector from one to the other node - a
-	  xy<double> a_v(my_points[2].get_x()-my_points[0].get_x(),my_points[2].get_y()-my_points[0].get_y());
-	  //new vector from one to the other node - b
-	  xy<double> b_v(p[1].get_x()-p[0].get_x(),p[1].get_y()-p[0].get_y());
+    //std::cout << bl << " " << br << " " << ccl << " "  << ccr << " " << cl << " " << cr << " " << top << std::endl;
 
-	  double absa=sqrt(a_v.normSquare());
-	  double absb=sqrt(b_v.normSquare());
+    Gnome::Canvas::Points arrow_points;
+    arrow_points.push_back(Gnome::Art::Point( bl.x , bl.y  ) );
+    arrow_points.push_back(Gnome::Art::Point( br.x , br.y  ) );
+    arrow_points.push_back(Gnome::Art::Point( ccr.x, ccr.y ) );
+    arrow_points.push_back(Gnome::Art::Point( cr.x , cr.y  ) );
+    arrow_points.push_back(Gnome::Art::Point( top.x, top.y ) );
+    arrow_points.push_back(Gnome::Art::Point( cl.x , cl.y  ) );
+    arrow_points.push_back(Gnome::Art::Point( ccl.x, ccl.y ) );
 
-	  if((absa!=0)&&(absb!=0))
-	    {
-	      //old vector from one node to the breakpoint - c
-	      xy<double> c_v(my_points[1].get_x()-my_points[0].get_x(),my_points[1].get_y()-my_points[0].get_y());
-
-	      //unit vector with the same direction to a_v
-	      xy<double> a_v_u(a_v.x/absa,a_v.y/absa);
-
-	      //normal vector of unit vector with the same direction to a_v
-	      xy<double> a_v_u_n(((-1)*a_v_u.y),a_v_u.x);
-
-	      //unit vector with the same direction to b_v
-	      xy<double> b_v_u(b_v.x/absb,b_v.y/absb);
-
-	      //normal vector of unit vector with the same direction to b_v
-	      xy<double> b_v_u_n(((-1)*b_v_u.y),b_v_u.x);
-
-	      //vector c in a_v_u and a_v_u_n co-ordinate system
-	      xy<double> c_a(c_v*a_v_u,c_v*a_v_u_n);
-
-	      //new vector from one node to the breakpoint - d - we have to calculate this one
-	      xy<double> d_v=absb/absa*(c_a.x*b_v_u+c_a.y*b_v_u_n);
-
-	      my_points[1]=Gnome::Art::Point(d_v.x+p[0].get_x(),d_v.y+p[0].get_y());
-
-	      my_points[0]=p[0];
-	      my_points[2]=p[1];
-	  
-	      Gnome::Canvas::Points points;
-	      for(int i=0;i<3;i++)
-		{
-		  points.push_back(my_points[i]);
-		}
-	      property_points().set_value(points);
-	    }
-	  else
-	    {
-	      //if distance is 0, segmentation would be occured
-	      //in calculations, because of division by zero
-	      //But we have luck: the edge cannot be seen in
-	      //this case, so no update needed
-	      set_arrow=false;
-	    }
-	}
-    }
-  if(set_arrow)
-    {
-      //calculating coordinates of the direction indicator arrow
-
-      xy<gdouble> target( my_points[2].get_x(), my_points[2].get_y() );
-      xy<gdouble> center( my_points[1].get_x(), my_points[1].get_y() );
-
-      xy<gdouble> unit_vector_in_dir(target-center);
-      double length=sqrt( unit_vector_in_dir.normSquare() );
-
-      //       std::cout << target << " - " << center << " = " << unit_vector_in_dir << "    / " <<unit_vector_in_dir.normSquare() ;
-      unit_vector_in_dir/=length;
-      //       std::cout << " = " << unit_vector_in_dir << std::endl;
-
-      xy<gdouble> unit_norm_vector(0-unit_vector_in_dir.y, unit_vector_in_dir.x);
-      //       std::cout << unit_norm_vector << std::endl;
-
-      {      
-	//       /\       // top
-	//      /  \      //
-	//      -  -      // c(enter)l(eft), ccl, ccr, cr
-	//       ||       //
-	//       ||       // b(ottom)l, br
-      }
-
-      double size=3;
-
-      xy<gdouble> bl (center - unit_vector_in_dir * 3 * size + unit_norm_vector * size );
-      xy<gdouble> br (center - unit_vector_in_dir * 3 * size - unit_norm_vector * size );
-      xy<gdouble> ccl(center + unit_vector_in_dir *  size + unit_norm_vector * size );
-      xy<gdouble> ccr(center + unit_vector_in_dir *  size - unit_norm_vector * size );
-      xy<gdouble> cl (center + unit_vector_in_dir *  size + unit_norm_vector * 2 * size );
-      xy<gdouble> cr (center + unit_vector_in_dir *  size - unit_norm_vector * 2 * size );
-      xy<gdouble> top(center + unit_vector_in_dir * 3 * size);
-	 
-      //std::cout << bl << " " << br << " " << ccl << " "  << ccr << " " << cl << " " << cr << " " << top << std::endl;
-
-      Gnome::Canvas::Points arrow_points;
-      arrow_points.push_back(Gnome::Art::Point( bl.x , bl.y  ) );
-      arrow_points.push_back(Gnome::Art::Point( br.x , br.y  ) );
-      arrow_points.push_back(Gnome::Art::Point( ccr.x, ccr.y ) );
-      arrow_points.push_back(Gnome::Art::Point( cr.x , cr.y  ) );
-      arrow_points.push_back(Gnome::Art::Point( top.x, top.y ) );
-      arrow_points.push_back(Gnome::Art::Point( cl.x , cl.y  ) );
-      arrow_points.push_back(Gnome::Art::Point( ccl.x, ccl.y ) );
-
-      arrow->property_points().set_value(arrow_points);
-    }
+    arrow->property_points().set_value(arrow_points);
+  }
 }
 
@@ -204,10 +118,8 @@
 	  Gnome::Canvas::Points points_new;
 
-	  points_new.push_back(my_points[0]);
-	  points_new.push_back(my_points[1]=Gnome::Art::Point(my_points[1].get_x()+dx,my_points[1].get_y()+dy));
-	  points_new.push_back(my_points[2]);
+          gdc.mytab.mapstorage.arrow_pos.set(edge, gdc.mytab.mapstorage.arrow_pos[edge] + XY(dx, dy));
 
-	  setPoints(points_new);
-	  gdc.textReposition(xy<double>(my_points[1].get_x(),my_points[1].get_y()));
+	  draw();
+	  gdc.textReposition(gdc.mytab.mapstorage.arrow_pos[edge]);
 
 	  clicked_x=e->motion.x;
@@ -220,8 +132,2 @@
   return true;
 }
-
-xy<double> GraphDisplayerCanvas::BrokenEdge::getArrowPos()
-{
-  xy<double> ret_val(my_points[1].get_x(),my_points[1].get_y());
-  return ret_val;
-}
