gui/graph_displayer_canvas.cc
changeset 1501 39d59aee2a1a
parent 1500 a222eb109e52
child 1505 7121597da9ba
     1.1 --- a/gui/graph_displayer_canvas.cc	Thu Jun 16 18:58:15 2005 +0000
     1.2 +++ b/gui/graph_displayer_canvas.cc	Fri Jun 17 12:25:53 2005 +0000
     1.3 @@ -5,7 +5,8 @@
     1.4  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.5  {
     1.6    
     1.7 -  actual_handler=displayed_graph.signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::create_edge_event_handler), false);
     1.8 +  actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::create_node_event_handler), false);
     1.9 +  actual_tool=CREATE_NODE;
    1.10  
    1.11    active_node=INVALID;
    1.12    active_edge=INVALID;
    1.13 @@ -23,7 +24,7 @@
    1.14      coos.push_back(Gnome::Art::Point(cm[g.source(i)].x,cm[g.source(i)].y));
    1.15      coos.push_back(Gnome::Art::Point(cm[g.target(i)].x,cm[g.target(i)].y));
    1.16      
    1.17 -    edgesmap[i]=new BrokenEdge(displayed_graph, coos);
    1.18 +    edgesmap[i]=new BrokenEdge(displayed_graph, coos, *this);
    1.19      *(edgesmap[i]) << Gnome::Canvas::Properties::fill_color("green");
    1.20      edgesmap[i]->property_width_pixels().set_value(10);    
    1.21      
    1.22 @@ -309,6 +310,16 @@
    1.23  {
    1.24    actual_handler.disconnect();
    1.25  
    1.26 +  if(actual_tool==CREATE_EDGE)
    1.27 +    {
    1.28 +	GdkEvent * generated=new GdkEvent();
    1.29 +	generated->type=GDK_BUTTON_RELEASE;
    1.30 +	generated->button.button=3;
    1.31 +	create_edge_event_handler(generated);      
    1.32 +    }
    1.33 +
    1.34 +  actual_tool=newtool;
    1.35 +
    1.36    switch(newtool)
    1.37      {
    1.38      case MOVE:
    1.39 @@ -333,6 +344,11 @@
    1.40      }
    1.41  }
    1.42  
    1.43 +int GraphDisplayerCanvas::get_actual_tool()
    1.44 +{
    1.45 +  return actual_tool;
    1.46 +}
    1.47 +
    1.48  bool GraphDisplayerCanvas::move_event_handler(GdkEvent* e)
    1.49  {
    1.50    switch(e->type)
    1.51 @@ -564,7 +580,7 @@
    1.52  		  coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
    1.53  
    1.54  		  //drawing new edge
    1.55 -		  edgesmap[active_edge]=new BrokenEdge(displayed_graph, coos);
    1.56 +		  edgesmap[active_edge]=new BrokenEdge(displayed_graph, coos, *this);
    1.57  		  *(edgesmap[active_edge]) << Gnome::Canvas::Properties::fill_color("green");
    1.58  		  edgesmap[active_edge]->property_width_pixels().set_value(10);
    1.59