First of all: revision 1981 is mine, what is important me because I was born in 1981. But what is new in my revision? If you drag nodes with left button, edge-breakpoints do not change location. If you drag nodes by right button, they do, they take up their base situation at the halfpoint of the edge.
authorhegyi
Thu, 16 Jun 2005 18:58:15 +0000
changeset 1500a222eb109e52
parent 1499 9316dcc0a355
child 1501 39d59aee2a1a
First of all: revision 1981 is mine, what is important me because I was born in 1981. But what is new in my revision? If you drag nodes with left button, edge-breakpoints do not change location. If you drag nodes by right button, they do, they take up their base situation at the halfpoint of the edge.
gui/broken_edge.cc
gui/broken_edge.h
gui/graph_displayer_canvas.cc
gui/graph_displayer_canvas.h
     1.1 --- a/gui/broken_edge.cc	Thu Jun 16 18:08:04 2005 +0000
     1.2 +++ b/gui/broken_edge.cc	Thu Jun 16 18:58:15 2005 +0000
     1.3 @@ -17,25 +17,42 @@
     1.4    if(arrow)delete(arrow);
     1.5  }
     1.6  
     1.7 -void BrokenEdge::set_points(Gnome::Canvas::Points p)
     1.8 +void BrokenEdge::set_points(Gnome::Canvas::Points p, bool move)
     1.9  {
    1.10    bool set_arrow=false;
    1.11 -  if(p.size()==2)
    1.12 +  if(!move)
    1.13      {
    1.14 -      set_arrow=true;
    1.15 -      Gnome::Canvas::Points points_with_center;
    1.16 -      points_with_center.push_back(my_points[0]=p[0]);
    1.17 -      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 );
    1.18 -      points_with_center.push_back(my_points[2]=p[1]);
    1.19 -      property_points().set_value(points_with_center);
    1.20 -    }  
    1.21 -  if(p.size()==3)
    1.22 +      if(p.size()==2)
    1.23 +	{
    1.24 +	  set_arrow=true;
    1.25 +	  Gnome::Canvas::Points points_with_center;
    1.26 +	  points_with_center.push_back(my_points[0]=p[0]);
    1.27 +	  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 );
    1.28 +	  points_with_center.push_back(my_points[2]=p[1]);
    1.29 +	  property_points().set_value(points_with_center);
    1.30 +	}  
    1.31 +      if(p.size()==3)
    1.32 +	{
    1.33 +	  set_arrow=true;
    1.34 +	  property_points().set_value(p);
    1.35 +	  for(int i=0;i<3;i++)
    1.36 +	    {
    1.37 +	      my_points[i]=p[i];
    1.38 +	    }
    1.39 +	}
    1.40 +    }
    1.41 +  else
    1.42      {
    1.43 -      set_arrow=true;
    1.44 -      property_points().set_value(p);
    1.45 -      for(int i=0;i<3;i++)
    1.46 +      if(p.size()==2)
    1.47  	{
    1.48 -	  my_points[i]=p[i];
    1.49 +	  Gnome::Canvas::Points points;
    1.50 +	  my_points[0]=p[0];
    1.51 +	  my_points[2]=p[1];
    1.52 +	  for(int i=0;i<3;i++)
    1.53 +	    {
    1.54 +	      points.push_back(my_points[i]);
    1.55 +	    }
    1.56 +	  property_points().set_value(points);
    1.57  	}
    1.58      }
    1.59  
     2.1 --- a/gui/broken_edge.h	Thu Jun 16 18:08:04 2005 +0000
     2.2 +++ b/gui/broken_edge.h	Thu Jun 16 18:58:15 2005 +0000
     2.3 @@ -24,7 +24,7 @@
     2.4   public:
     2.5    BrokenEdge(Gnome::Canvas::Group &, Gnome::Canvas::Points);
     2.6    ~BrokenEdge();
     2.7 -  void set_points(Gnome::Canvas::Points);
     2.8 +  void set_points(Gnome::Canvas::Points, bool move=false);
     2.9  };
    2.10  
    2.11  
     3.1 --- a/gui/graph_displayer_canvas.cc	Thu Jun 16 18:08:04 2005 +0000
     3.2 +++ b/gui/graph_displayer_canvas.cc	Thu Jun 16 18:58:15 2005 +0000
     3.3 @@ -2,7 +2,7 @@
     3.4  #include <broken_edge.h>
     3.5  #include <math.h>
     3.6  
     3.7 -GraphDisplayerCanvas::GraphDisplayerCanvas(Graph & gr, CoordinatesMap & cm, MapStorage & ms):g(gr),nodesmap(g),edgesmap(g),edgetextmap(g),displayed_graph(*(root()), 0, 0),mapstorage(ms),isbutton(false),active_item(NULL),target_item(NULL)
     3.8 +GraphDisplayerCanvas::GraphDisplayerCanvas(Graph & gr, CoordinatesMap & cm, MapStorage & ms):g(gr),nodesmap(g),edgesmap(g),edgetextmap(g),displayed_graph(*(root()), 0, 0),mapstorage(ms),isbutton(0),active_item(NULL),target_item(NULL)
     3.9  {
    3.10    
    3.11    actual_handler=displayed_graph.signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::create_edge_event_handler), false);
    3.12 @@ -181,10 +181,10 @@
    3.13        clicked_x=e->button.x;
    3.14        clicked_y=e->button.y;
    3.15        active_item=(get_item_at(e->button.x, e->button.y));
    3.16 -      isbutton=true;
    3.17 +      isbutton=1;
    3.18        break;
    3.19      case GDK_BUTTON_RELEASE:
    3.20 -      isbutton=false;
    3.21 +      isbutton=0;
    3.22        active_item=NULL;
    3.23        updateScrollRegion();
    3.24        break;
    3.25 @@ -350,10 +350,18 @@
    3.26  	      active_node=i;
    3.27  	    }
    3.28  	}
    3.29 -      isbutton=true;
    3.30 +      switch(e->button.button)
    3.31 +	{
    3.32 +	case 3:      
    3.33 +	  isbutton=3;
    3.34 +	  break;
    3.35 +	default:
    3.36 +	  isbutton=1;
    3.37 +	  break;
    3.38 +	}
    3.39        break;
    3.40      case GDK_BUTTON_RELEASE:
    3.41 -      isbutton=false;
    3.42 +      isbutton=0;
    3.43        active_item=NULL;
    3.44        active_node=INVALID;
    3.45        updateScrollRegion();
    3.46 @@ -376,47 +384,61 @@
    3.47          clicked_y=e->motion.y;
    3.48  
    3.49  	//all the edges connected to the moved point has to be redrawn
    3.50 -        EdgeIt e;
    3.51 +        EdgeIt ei;
    3.52  
    3.53 -        g.firstOut(e,active_node);
    3.54 +        g.firstOut(ei,active_node);
    3.55  
    3.56 -        for(;e!=INVALID;g.nextOut(e))
    3.57 +        for(;ei!=INVALID;g.nextOut(ei))
    3.58          {
    3.59              Gnome::Canvas::Points coos;
    3.60              double x1, x2, y1, y2;
    3.61  
    3.62 -            nodesmap[g.source(e)]->get_bounds(x1, y1, x2, y2);
    3.63 +            nodesmap[g.source(ei)]->get_bounds(x1, y1, x2, y2);
    3.64              coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
    3.65  
    3.66 -            nodesmap[g.target(e)]->get_bounds(x1, y1, x2, y2);
    3.67 +            nodesmap[g.target(ei)]->get_bounds(x1, y1, x2, y2);
    3.68              coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
    3.69  
    3.70 -            edgesmap[e]->set_points(coos);
    3.71 +	    if(isbutton==3)
    3.72 +	      {
    3.73 +		edgesmap[ei]->set_points(coos);
    3.74 +	      }
    3.75 +	    else
    3.76 +	      {
    3.77 +		edgesmap[ei]->set_points(coos,true);
    3.78 +	      }
    3.79  
    3.80 -	    edgesmap[e]->get_bounds(x1, y1, x2, y2);
    3.81 +	    edgesmap[ei]->get_bounds(x1, y1, x2, y2);
    3.82  
    3.83 -	    edgetextmap[e]->property_x().set_value((x1+x2)/2);
    3.84 -	    edgetextmap[e]->property_y().set_value((y1+y2)/2);
    3.85 +	    edgetextmap[ei]->property_x().set_value((x1+x2)/2);
    3.86 +	    edgetextmap[ei]->property_y().set_value((y1+y2)/2);
    3.87          }
    3.88  
    3.89 -        g.firstIn(e,active_node);
    3.90 -        for(;e!=INVALID;g.nextIn(e))
    3.91 +        g.firstIn(ei,active_node);
    3.92 +        for(;ei!=INVALID;g.nextIn(ei))
    3.93          {
    3.94              Gnome::Canvas::Points coos;
    3.95              double x1, x2, y1, y2;
    3.96  
    3.97 -            nodesmap[g.source(e)]->get_bounds(x1, y1, x2, y2);
    3.98 +            nodesmap[g.source(ei)]->get_bounds(x1, y1, x2, y2);
    3.99              coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   3.100  
   3.101 -            nodesmap[g.target(e)]->get_bounds(x1, y1, x2, y2);
   3.102 +            nodesmap[g.target(ei)]->get_bounds(x1, y1, x2, y2);
   3.103              coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   3.104  
   3.105 -            edgesmap[e]->set_points(coos);
   3.106 +	    if(isbutton==3)
   3.107 +	      {
   3.108 +		edgesmap[ei]->set_points(coos);
   3.109 +	      }
   3.110 +	    else
   3.111 +	      {
   3.112 +		edgesmap[ei]->set_points(coos,true);
   3.113 +	      }
   3.114  
   3.115 -	    edgesmap[e]->get_bounds(x1, y1, x2, y2);
   3.116 +	    edgesmap[ei]->get_bounds(x1, y1, x2, y2);
   3.117  
   3.118 -	    edgetextmap[e]->property_x().set_value((x1+x2)/2);
   3.119 -	    edgetextmap[e]->property_y().set_value((y1+y2)/2);
   3.120 +	    edgetextmap[ei]->property_x().set_value((x1+x2)/2);
   3.121 +	    edgetextmap[ei]->property_y().set_value((y1+y2)/2);
   3.122          }
   3.123        }
   3.124      default: break;
   3.125 @@ -432,7 +454,7 @@
   3.126  
   3.127        //draw the new node in red at the clicked place
   3.128      case GDK_BUTTON_PRESS:
   3.129 -      isbutton=true;
   3.130 +      isbutton=1;
   3.131  
   3.132        active_node=NodeIt(g,g.addNode());
   3.133  
   3.134 @@ -460,7 +482,7 @@
   3.135  
   3.136        //finalize the new node
   3.137      case GDK_BUTTON_RELEASE:
   3.138 -      isbutton=false;
   3.139 +      isbutton=0;
   3.140        *active_item << Gnome::Canvas::Properties::fill_color("blue");
   3.141        active_item=NULL;
   3.142        active_node=INVALID;
   3.143 @@ -499,7 +521,7 @@
   3.144  	      if(active_node!=INVALID)
   3.145  		{
   3.146  		  *(nodesmap[active_node]) << Gnome::Canvas::Properties::fill_color("red");
   3.147 -		  isbutton=true;
   3.148 +		  isbutton=1;
   3.149  		}
   3.150  	      //clicked item was not a node. It could be e.g. edge.
   3.151  	      else
   3.152 @@ -564,7 +586,7 @@
   3.153  	}
   3.154        break;
   3.155      case GDK_BUTTON_RELEASE:
   3.156 -      isbutton=false;
   3.157 +      isbutton=0;
   3.158        //we clear settings in two cases
   3.159        //1: the edge is ready (target_item has valid value)
   3.160        //2: the edge creation is cancelled with right button
     4.1 --- a/gui/graph_displayer_canvas.h	Thu Jun 16 18:08:04 2005 +0000
     4.2 +++ b/gui/graph_displayer_canvas.h	Thu Jun 16 18:58:15 2005 +0000
     4.3 @@ -96,7 +96,7 @@
     4.4    MapStorage mapstorage;
     4.5  
     4.6    ///Indicates whether the button of mouse is pressed or not
     4.7 -  bool isbutton;
     4.8 +  int isbutton;
     4.9  
    4.10    ///At this location was the mousebutton pressed.
    4.11    ///It helps to calculate the distance of dragging.