graph_displayer_canvas.cc
branchgui
changeset 20 a3bd39d50930
parent 19 164783ceb9be
child 21 44bb92014108
     1.1 --- a/graph_displayer_canvas.cc	Thu Jun 16 18:08:04 2005 +0000
     1.2 +++ b/graph_displayer_canvas.cc	Thu Jun 16 18:58:15 2005 +0000
     1.3 @@ -2,7 +2,7 @@
     1.4  #include <broken_edge.h>
     1.5  #include <math.h>
     1.6  
     1.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)
     1.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)
     1.9  {
    1.10    
    1.11    actual_handler=displayed_graph.signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::create_edge_event_handler), false);
    1.12 @@ -181,10 +181,10 @@
    1.13        clicked_x=e->button.x;
    1.14        clicked_y=e->button.y;
    1.15        active_item=(get_item_at(e->button.x, e->button.y));
    1.16 -      isbutton=true;
    1.17 +      isbutton=1;
    1.18        break;
    1.19      case GDK_BUTTON_RELEASE:
    1.20 -      isbutton=false;
    1.21 +      isbutton=0;
    1.22        active_item=NULL;
    1.23        updateScrollRegion();
    1.24        break;
    1.25 @@ -350,10 +350,18 @@
    1.26  	      active_node=i;
    1.27  	    }
    1.28  	}
    1.29 -      isbutton=true;
    1.30 +      switch(e->button.button)
    1.31 +	{
    1.32 +	case 3:      
    1.33 +	  isbutton=3;
    1.34 +	  break;
    1.35 +	default:
    1.36 +	  isbutton=1;
    1.37 +	  break;
    1.38 +	}
    1.39        break;
    1.40      case GDK_BUTTON_RELEASE:
    1.41 -      isbutton=false;
    1.42 +      isbutton=0;
    1.43        active_item=NULL;
    1.44        active_node=INVALID;
    1.45        updateScrollRegion();
    1.46 @@ -376,47 +384,61 @@
    1.47          clicked_y=e->motion.y;
    1.48  
    1.49  	//all the edges connected to the moved point has to be redrawn
    1.50 -        EdgeIt e;
    1.51 +        EdgeIt ei;
    1.52  
    1.53 -        g.firstOut(e,active_node);
    1.54 +        g.firstOut(ei,active_node);
    1.55  
    1.56 -        for(;e!=INVALID;g.nextOut(e))
    1.57 +        for(;ei!=INVALID;g.nextOut(ei))
    1.58          {
    1.59              Gnome::Canvas::Points coos;
    1.60              double x1, x2, y1, y2;
    1.61  
    1.62 -            nodesmap[g.source(e)]->get_bounds(x1, y1, x2, y2);
    1.63 +            nodesmap[g.source(ei)]->get_bounds(x1, y1, x2, y2);
    1.64              coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
    1.65  
    1.66 -            nodesmap[g.target(e)]->get_bounds(x1, y1, x2, y2);
    1.67 +            nodesmap[g.target(ei)]->get_bounds(x1, y1, x2, y2);
    1.68              coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
    1.69  
    1.70 -            edgesmap[e]->set_points(coos);
    1.71 +	    if(isbutton==3)
    1.72 +	      {
    1.73 +		edgesmap[ei]->set_points(coos);
    1.74 +	      }
    1.75 +	    else
    1.76 +	      {
    1.77 +		edgesmap[ei]->set_points(coos,true);
    1.78 +	      }
    1.79  
    1.80 -	    edgesmap[e]->get_bounds(x1, y1, x2, y2);
    1.81 +	    edgesmap[ei]->get_bounds(x1, y1, x2, y2);
    1.82  
    1.83 -	    edgetextmap[e]->property_x().set_value((x1+x2)/2);
    1.84 -	    edgetextmap[e]->property_y().set_value((y1+y2)/2);
    1.85 +	    edgetextmap[ei]->property_x().set_value((x1+x2)/2);
    1.86 +	    edgetextmap[ei]->property_y().set_value((y1+y2)/2);
    1.87          }
    1.88  
    1.89 -        g.firstIn(e,active_node);
    1.90 -        for(;e!=INVALID;g.nextIn(e))
    1.91 +        g.firstIn(ei,active_node);
    1.92 +        for(;ei!=INVALID;g.nextIn(ei))
    1.93          {
    1.94              Gnome::Canvas::Points coos;
    1.95              double x1, x2, y1, y2;
    1.96  
    1.97 -            nodesmap[g.source(e)]->get_bounds(x1, y1, x2, y2);
    1.98 +            nodesmap[g.source(ei)]->get_bounds(x1, y1, x2, y2);
    1.99              coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   1.100  
   1.101 -            nodesmap[g.target(e)]->get_bounds(x1, y1, x2, y2);
   1.102 +            nodesmap[g.target(ei)]->get_bounds(x1, y1, x2, y2);
   1.103              coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   1.104  
   1.105 -            edgesmap[e]->set_points(coos);
   1.106 +	    if(isbutton==3)
   1.107 +	      {
   1.108 +		edgesmap[ei]->set_points(coos);
   1.109 +	      }
   1.110 +	    else
   1.111 +	      {
   1.112 +		edgesmap[ei]->set_points(coos,true);
   1.113 +	      }
   1.114  
   1.115 -	    edgesmap[e]->get_bounds(x1, y1, x2, y2);
   1.116 +	    edgesmap[ei]->get_bounds(x1, y1, x2, y2);
   1.117  
   1.118 -	    edgetextmap[e]->property_x().set_value((x1+x2)/2);
   1.119 -	    edgetextmap[e]->property_y().set_value((y1+y2)/2);
   1.120 +	    edgetextmap[ei]->property_x().set_value((x1+x2)/2);
   1.121 +	    edgetextmap[ei]->property_y().set_value((y1+y2)/2);
   1.122          }
   1.123        }
   1.124      default: break;
   1.125 @@ -432,7 +454,7 @@
   1.126  
   1.127        //draw the new node in red at the clicked place
   1.128      case GDK_BUTTON_PRESS:
   1.129 -      isbutton=true;
   1.130 +      isbutton=1;
   1.131  
   1.132        active_node=NodeIt(g,g.addNode());
   1.133  
   1.134 @@ -460,7 +482,7 @@
   1.135  
   1.136        //finalize the new node
   1.137      case GDK_BUTTON_RELEASE:
   1.138 -      isbutton=false;
   1.139 +      isbutton=0;
   1.140        *active_item << Gnome::Canvas::Properties::fill_color("blue");
   1.141        active_item=NULL;
   1.142        active_node=INVALID;
   1.143 @@ -499,7 +521,7 @@
   1.144  	      if(active_node!=INVALID)
   1.145  		{
   1.146  		  *(nodesmap[active_node]) << Gnome::Canvas::Properties::fill_color("red");
   1.147 -		  isbutton=true;
   1.148 +		  isbutton=1;
   1.149  		}
   1.150  	      //clicked item was not a node. It could be e.g. edge.
   1.151  	      else
   1.152 @@ -564,7 +586,7 @@
   1.153  	}
   1.154        break;
   1.155      case GDK_BUTTON_RELEASE:
   1.156 -      isbutton=false;
   1.157 +      isbutton=0;
   1.158        //we clear settings in two cases
   1.159        //1: the edge is ready (target_item has valid value)
   1.160        //2: the edge creation is cancelled with right button