diff -r 164783ceb9be -r a3bd39d50930 graph_displayer_canvas.cc --- a/graph_displayer_canvas.cc Thu Jun 16 18:08:04 2005 +0000 +++ b/graph_displayer_canvas.cc Thu Jun 16 18:58:15 2005 +0000 @@ -2,7 +2,7 @@ #include #include -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) +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) { actual_handler=displayed_graph.signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::create_edge_event_handler), false); @@ -181,10 +181,10 @@ clicked_x=e->button.x; clicked_y=e->button.y; active_item=(get_item_at(e->button.x, e->button.y)); - isbutton=true; + isbutton=1; break; case GDK_BUTTON_RELEASE: - isbutton=false; + isbutton=0; active_item=NULL; updateScrollRegion(); break; @@ -350,10 +350,18 @@ active_node=i; } } - isbutton=true; + switch(e->button.button) + { + case 3: + isbutton=3; + break; + default: + isbutton=1; + break; + } break; case GDK_BUTTON_RELEASE: - isbutton=false; + isbutton=0; active_item=NULL; active_node=INVALID; updateScrollRegion(); @@ -376,47 +384,61 @@ clicked_y=e->motion.y; //all the edges connected to the moved point has to be redrawn - EdgeIt e; + EdgeIt ei; - g.firstOut(e,active_node); + g.firstOut(ei,active_node); - for(;e!=INVALID;g.nextOut(e)) + for(;ei!=INVALID;g.nextOut(ei)) { Gnome::Canvas::Points coos; double x1, x2, y1, y2; - nodesmap[g.source(e)]->get_bounds(x1, y1, x2, y2); + nodesmap[g.source(ei)]->get_bounds(x1, y1, x2, y2); coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); - nodesmap[g.target(e)]->get_bounds(x1, y1, x2, y2); + nodesmap[g.target(ei)]->get_bounds(x1, y1, x2, y2); coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); - edgesmap[e]->set_points(coos); + if(isbutton==3) + { + edgesmap[ei]->set_points(coos); + } + else + { + edgesmap[ei]->set_points(coos,true); + } - edgesmap[e]->get_bounds(x1, y1, x2, y2); + edgesmap[ei]->get_bounds(x1, y1, x2, y2); - edgetextmap[e]->property_x().set_value((x1+x2)/2); - edgetextmap[e]->property_y().set_value((y1+y2)/2); + edgetextmap[ei]->property_x().set_value((x1+x2)/2); + edgetextmap[ei]->property_y().set_value((y1+y2)/2); } - g.firstIn(e,active_node); - for(;e!=INVALID;g.nextIn(e)) + g.firstIn(ei,active_node); + for(;ei!=INVALID;g.nextIn(ei)) { Gnome::Canvas::Points coos; double x1, x2, y1, y2; - nodesmap[g.source(e)]->get_bounds(x1, y1, x2, y2); + nodesmap[g.source(ei)]->get_bounds(x1, y1, x2, y2); coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); - nodesmap[g.target(e)]->get_bounds(x1, y1, x2, y2); + nodesmap[g.target(ei)]->get_bounds(x1, y1, x2, y2); coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); - edgesmap[e]->set_points(coos); + if(isbutton==3) + { + edgesmap[ei]->set_points(coos); + } + else + { + edgesmap[ei]->set_points(coos,true); + } - edgesmap[e]->get_bounds(x1, y1, x2, y2); + edgesmap[ei]->get_bounds(x1, y1, x2, y2); - edgetextmap[e]->property_x().set_value((x1+x2)/2); - edgetextmap[e]->property_y().set_value((y1+y2)/2); + edgetextmap[ei]->property_x().set_value((x1+x2)/2); + edgetextmap[ei]->property_y().set_value((y1+y2)/2); } } default: break; @@ -432,7 +454,7 @@ //draw the new node in red at the clicked place case GDK_BUTTON_PRESS: - isbutton=true; + isbutton=1; active_node=NodeIt(g,g.addNode()); @@ -460,7 +482,7 @@ //finalize the new node case GDK_BUTTON_RELEASE: - isbutton=false; + isbutton=0; *active_item << Gnome::Canvas::Properties::fill_color("blue"); active_item=NULL; active_node=INVALID; @@ -499,7 +521,7 @@ if(active_node!=INVALID) { *(nodesmap[active_node]) << Gnome::Canvas::Properties::fill_color("red"); - isbutton=true; + isbutton=1; } //clicked item was not a node. It could be e.g. edge. else @@ -564,7 +586,7 @@ } break; case GDK_BUTTON_RELEASE: - isbutton=false; + isbutton=0; //we clear settings in two cases //1: the edge is ready (target_item has valid value) //2: the edge creation is cancelled with right button