Changeset 1500:a222eb109e52 in lemon-0.x for gui/graph_displayer_canvas.cc
- Timestamp:
- 06/16/05 20:58:15 (19 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1981
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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)
Note: See TracChangeset
for help on using the changeset viewer.