gui/broken_edge.cc
changeset 1515 dd7616b51333
parent 1504 4b14c60ecb2b
child 1524 587a823bcdd0
equal deleted inserted replaced
4:2c90c8e72ed9 5:e07b56fd9db8
     1 #include <broken_edge.h>
     1 #include <broken_edge.h>
     2 #include <lemon/xy.h>
       
     3 #include <math.h>
     2 #include <math.h>
     4 
     3 
     5 BrokenEdge::BrokenEdge(Gnome::Canvas::Group & g, Gnome::Canvas::Points p, GraphDisplayerCanvas & gc) : Line(g), gdc(gc), isbutton(false)
     4 BrokenEdge::BrokenEdge(Gnome::Canvas::Group & g, Gnome::Canvas::Points p, GraphDisplayerCanvas & gc) : Line(g), gdc(gc), isbutton(false)
     6 {
     5 {
     7   my_points=new Gnome::Art::Point[3];
     6   my_points=new Gnome::Art::Point[3];
   110     {
   109     {
   111     case GDK_BUTTON_PRESS:
   110     case GDK_BUTTON_PRESS:
   112       //we mark the location of the event to be able to calculate parameters of dragging
   111       //we mark the location of the event to be able to calculate parameters of dragging
   113       if(gdc.get_actual_tool()!=CREATE_NODE)
   112       if(gdc.get_actual_tool()!=CREATE_NODE)
   114 	{
   113 	{
       
   114 	  gdc.toggle_edge_activity(this, true);
   115 	  clicked_x=e->button.x;
   115 	  clicked_x=e->button.x;
   116 	  clicked_y=e->button.y;
   116 	  clicked_y=e->button.y;
   117 	  isbutton=true;
   117 	  isbutton=true;
   118 	}
   118 	}
   119       break;
   119       break;
   120     case GDK_BUTTON_RELEASE:
   120     case GDK_BUTTON_RELEASE:
   121       isbutton=false;
   121       if(gdc.get_actual_tool()!=CREATE_NODE)
       
   122 	{
       
   123 	  gdc.toggle_edge_activity(this, false);
       
   124 	  isbutton=false;
       
   125 	}
   122       break;
   126       break;
   123     case GDK_MOTION_NOTIFY:
   127     case GDK_MOTION_NOTIFY:
   124       //we only have to do sg. if the mouse button is pressed
   128       //we only have to do sg. if the mouse button is pressed
   125       if(isbutton)
   129       if(isbutton)
   126 	{
   130 	{
   137 	  points_new.push_back(my_points[0]);
   141 	  points_new.push_back(my_points[0]);
   138 	  points_new.push_back(my_points[1]=Gnome::Art::Point(my_points[1].get_x()+dx,my_points[1].get_y()+dy));
   142 	  points_new.push_back(my_points[1]=Gnome::Art::Point(my_points[1].get_x()+dx,my_points[1].get_y()+dy));
   139 	  points_new.push_back(my_points[2]);
   143 	  points_new.push_back(my_points[2]);
   140 
   144 
   141 	  set_points(points_new);
   145 	  set_points(points_new);
       
   146 	  gdc.text_reposition(xy<double>(my_points[1].get_x(),my_points[1].get_y()));
   142 
   147 
   143 	  clicked_x=e->motion.x;
   148 	  clicked_x=e->motion.x;
   144 	  clicked_y=e->motion.y;
   149 	  clicked_y=e->motion.y;
   145 
   150 
   146 	}
   151 	}
   147     default: break;
   152     default: break;
   148     }
   153     }
   149 
   154 
   150   return true;
   155   return true;
   151 }
   156 }
       
   157 
       
   158 xy<double> BrokenEdge::get_arrow_pos()
       
   159 {
       
   160   xy<double> ret_val(my_points[1].get_x(),my_points[1].get_y());
       
   161   return ret_val;
       
   162 }