Changeset 1500:a222eb109e52 in lemon-0.x
- Timestamp:
- 06/16/05 20:58:15 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1981
- Location:
- gui
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
gui/broken_edge.cc
r1499 r1500 18 18 } 19 19 20 void BrokenEdge::set_points(Gnome::Canvas::Points p )20 void BrokenEdge::set_points(Gnome::Canvas::Points p, bool move) 21 21 { 22 22 bool set_arrow=false; 23 if( p.size()==2)23 if(!move) 24 24 { 25 set_arrow=true; 26 Gnome::Canvas::Points points_with_center; 27 points_with_center.push_back(my_points[0]=p[0]); 28 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 ); 29 points_with_center.push_back(my_points[2]=p[1]); 30 property_points().set_value(points_with_center); 31 } 32 if(p.size()==3) 25 if(p.size()==2) 26 { 27 set_arrow=true; 28 Gnome::Canvas::Points points_with_center; 29 points_with_center.push_back(my_points[0]=p[0]); 30 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 ); 31 points_with_center.push_back(my_points[2]=p[1]); 32 property_points().set_value(points_with_center); 33 } 34 if(p.size()==3) 35 { 36 set_arrow=true; 37 property_points().set_value(p); 38 for(int i=0;i<3;i++) 39 { 40 my_points[i]=p[i]; 41 } 42 } 43 } 44 else 33 45 { 34 set_arrow=true; 35 property_points().set_value(p); 36 for(int i=0;i<3;i++) 46 if(p.size()==2) 37 47 { 38 my_points[i]=p[i]; 48 Gnome::Canvas::Points points; 49 my_points[0]=p[0]; 50 my_points[2]=p[1]; 51 for(int i=0;i<3;i++) 52 { 53 points.push_back(my_points[i]); 54 } 55 property_points().set_value(points); 39 56 } 40 57 } -
gui/broken_edge.h
r1499 r1500 25 25 BrokenEdge(Gnome::Canvas::Group &, Gnome::Canvas::Points); 26 26 ~BrokenEdge(); 27 void set_points(Gnome::Canvas::Points );27 void set_points(Gnome::Canvas::Points, bool move=false); 28 28 }; 29 29 -
gui/graph_displayer_canvas.cc
r1499 r1500 3 3 #include <math.h> 4 4 5 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)5 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) 6 6 { 7 7 … … 182 182 clicked_y=e->button.y; 183 183 active_item=(get_item_at(e->button.x, e->button.y)); 184 isbutton= true;184 isbutton=1; 185 185 break; 186 186 case GDK_BUTTON_RELEASE: 187 isbutton= false;187 isbutton=0; 188 188 active_item=NULL; 189 189 updateScrollRegion(); … … 351 351 } 352 352 } 353 isbutton=true; 353 switch(e->button.button) 354 { 355 case 3: 356 isbutton=3; 357 break; 358 default: 359 isbutton=1; 360 break; 361 } 354 362 break; 355 363 case GDK_BUTTON_RELEASE: 356 isbutton= false;364 isbutton=0; 357 365 active_item=NULL; 358 366 active_node=INVALID; … … 377 385 378 386 //all the edges connected to the moved point has to be redrawn 379 EdgeIt e ;380 381 g.firstOut(e ,active_node);382 383 for(;e !=INVALID;g.nextOut(e))387 EdgeIt ei; 388 389 g.firstOut(ei,active_node); 390 391 for(;ei!=INVALID;g.nextOut(ei)) 384 392 { 385 393 Gnome::Canvas::Points coos; 386 394 double x1, x2, y1, y2; 387 395 388 nodesmap[g.source(e )]->get_bounds(x1, y1, x2, y2);396 nodesmap[g.source(ei)]->get_bounds(x1, y1, x2, y2); 389 397 coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); 390 398 391 nodesmap[g.target(e )]->get_bounds(x1, y1, x2, y2);399 nodesmap[g.target(ei)]->get_bounds(x1, y1, x2, y2); 392 400 coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); 393 401 394 edgesmap[e]->set_points(coos); 395 396 edgesmap[e]->get_bounds(x1, y1, x2, y2); 397 398 edgetextmap[e]->property_x().set_value((x1+x2)/2); 399 edgetextmap[e]->property_y().set_value((y1+y2)/2); 402 if(isbutton==3) 403 { 404 edgesmap[ei]->set_points(coos); 405 } 406 else 407 { 408 edgesmap[ei]->set_points(coos,true); 409 } 410 411 edgesmap[ei]->get_bounds(x1, y1, x2, y2); 412 413 edgetextmap[ei]->property_x().set_value((x1+x2)/2); 414 edgetextmap[ei]->property_y().set_value((y1+y2)/2); 400 415 } 401 416 402 g.firstIn(e ,active_node);403 for(;e !=INVALID;g.nextIn(e))417 g.firstIn(ei,active_node); 418 for(;ei!=INVALID;g.nextIn(ei)) 404 419 { 405 420 Gnome::Canvas::Points coos; 406 421 double x1, x2, y1, y2; 407 422 408 nodesmap[g.source(e )]->get_bounds(x1, y1, x2, y2);423 nodesmap[g.source(ei)]->get_bounds(x1, y1, x2, y2); 409 424 coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); 410 425 411 nodesmap[g.target(e )]->get_bounds(x1, y1, x2, y2);426 nodesmap[g.target(ei)]->get_bounds(x1, y1, x2, y2); 412 427 coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); 413 428 414 edgesmap[e]->set_points(coos); 415 416 edgesmap[e]->get_bounds(x1, y1, x2, y2); 417 418 edgetextmap[e]->property_x().set_value((x1+x2)/2); 419 edgetextmap[e]->property_y().set_value((y1+y2)/2); 429 if(isbutton==3) 430 { 431 edgesmap[ei]->set_points(coos); 432 } 433 else 434 { 435 edgesmap[ei]->set_points(coos,true); 436 } 437 438 edgesmap[ei]->get_bounds(x1, y1, x2, y2); 439 440 edgetextmap[ei]->property_x().set_value((x1+x2)/2); 441 edgetextmap[ei]->property_y().set_value((y1+y2)/2); 420 442 } 421 443 } … … 433 455 //draw the new node in red at the clicked place 434 456 case GDK_BUTTON_PRESS: 435 isbutton= true;457 isbutton=1; 436 458 437 459 active_node=NodeIt(g,g.addNode()); … … 461 483 //finalize the new node 462 484 case GDK_BUTTON_RELEASE: 463 isbutton= false;485 isbutton=0; 464 486 *active_item << Gnome::Canvas::Properties::fill_color("blue"); 465 487 active_item=NULL; … … 500 522 { 501 523 *(nodesmap[active_node]) << Gnome::Canvas::Properties::fill_color("red"); 502 isbutton= true;524 isbutton=1; 503 525 } 504 526 //clicked item was not a node. It could be e.g. edge. … … 565 587 break; 566 588 case GDK_BUTTON_RELEASE: 567 isbutton= false;589 isbutton=0; 568 590 //we clear settings in two cases 569 591 //1: the edge is ready (target_item has valid value) -
gui/graph_displayer_canvas.h
r1499 r1500 97 97 98 98 ///Indicates whether the button of mouse is pressed or not 99 boolisbutton;99 int isbutton; 100 100 101 101 ///At this location was the mousebutton pressed.
Note: See TracChangeset
for help on using the changeset viewer.