Changeset 1599:c2f95eac652b in lemon-0.x
- Timestamp:
- 07/28/05 17:54:00 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2104
- Location:
- gui
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
gui/Makefile.am
r1592 r1599 19 19 map_win.cc \ 20 20 map_win.h \ 21 edit_win.cc \22 edit_win.h \23 21 broken_edge.cc \ 24 22 broken_edge.h \ -
gui/all_include.h
r1585 r1599 23 23 #define WIN_WIDTH 900 24 24 #define WIN_HEIGHT 600 25 #define ALMOST_ONE 0.9999999999 25 #define MIN_EDGE_WIDTH 2 26 #define MAX_EDGE_WIDTH 40 27 #define MIN_NODE_RADIUS 2 28 #define MAX_NODE_RADIUS 80 26 29 27 30 #ifndef MAIN_PART -
gui/graph_displayer_canvas-edge.cc
r1598 r1599 7 7 { 8 8 Graph::EdgeMap<double> * actual_map; 9 double min, max; 10 9 11 if(mapname=="Default") 10 12 { 13 min=edge_property_defaults[E_WIDTH]; 14 max=edge_property_defaults[E_WIDTH]; 11 15 actual_map=new Graph::EdgeMap<double>(g,edge_property_defaults[E_WIDTH]); 12 16 } 13 17 else 14 18 { 19 min=mapstorage.minOfEdgeMap(mapname); 20 max=mapstorage.maxOfEdgeMap(mapname); 15 21 actual_map=(mapstorage.edgemap_storage)[mapname]; 16 22 } … … 20 26 for (EdgeIt i(g); i!=INVALID; ++i) 21 27 { 22 int w=(int)(*actual_map)[i]; 23 if(w>=0) 28 double v=abs((*actual_map)[i]); 29 int w; 30 if(min==max) 24 31 { 25 edgesmap[i]->property_width_units().set_value(w);32 w=(int)(edge_property_defaults[E_WIDTH]); 26 33 } 34 else 35 { 36 w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH)); 37 } 38 edgesmap[i]->property_width_units().set_value(w); 27 39 } 28 40 } -
gui/graph_displayer_canvas-event.cc
r1598 r1599 217 217 //draw the new node in red at the clicked place 218 218 case GDK_2BUTTON_PRESS: 219 std::cout << "double click" << std::endl;219 //std::cout << "double click" << std::endl; 220 220 break; 221 221 case GDK_BUTTON_PRESS: … … 382 382 { 383 383 target_node=INVALID; 384 std::c out<< "Loop edge is not yet implemented!" << std::endl;384 std::cerr << "Loop edge is not yet implemented!" << std::endl; 385 385 } 386 386 } … … 528 528 bool GraphDisplayerCanvas::edgeMapEditEventHandler(GdkEvent* e) 529 529 { 530 switch(e->type) 531 { 532 case GDK_KEY_PRESS: 533 //for Escape or Enter hide the displayed widget 534 { 535 nodeMapEditEventHandler(e); 536 break; 537 } 538 case GDK_BUTTON_PRESS: 539 //If the click happened on an edge we place the entrywidget there and fill in the value of the activated map at that edge. 540 { 541 //find the activated item 542 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); 543 active_item=(get_item_at(clicked_x, clicked_y)); 544 545 //determine, whether it was an edge 546 Graph::EdgeIt clicked_edge=INVALID; 547 for (EdgeIt i(g); i!=INVALID; ++i) 530 if(actual_tool==EDGE_MAP_EDIT) 531 { 532 switch(e->type) 533 { 534 case GDK_KEY_PRESS: 535 //for Escape or Enter hide the displayed widget 548 536 { 549 if(edgesmap[i]==active_item) 550 { 551 clicked_edge=i; 552 } 537 nodeMapEditEventHandler(e); 538 break; 553 539 } 554 //if it was really an edge...555 if(clicked_edge!=INVALID)540 case GDK_BUTTON_PRESS: 541 //If the click happened on an edge we place the entrywidget there and fill in the value of the activated map at that edge. 556 542 { 557 //If there is already edited edge, it has to be saved first 558 if(entrywidget.is_visible()) 559 { 543 //for determine, whether it was an edge 544 Graph::EdgeIt clicked_edge=INVALID; 545 546 //find the activated item between texts 547 active_item=(get_item_at(e->button.x, e->button.y)); 548 for (EdgeIt i(g); i!=INVALID; ++i) 549 { 550 if(edgetextmap[i]==active_item) 551 { 552 clicked_edge=i; 553 } 554 } 555 556 //if it was not between texts, search for it between edges 557 if(clicked_edge==INVALID) 558 { 559 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); 560 active_item=(get_item_at(clicked_x, clicked_y)); 561 562 for (EdgeIt i(g); i!=INVALID; ++i) 563 { 564 //at the same time only one can be active 565 if((edgesmap[i]==active_item)||(edgetextmap[i]==active_item)) 566 { 567 clicked_edge=i; 568 } 569 } 570 } 571 //if it was really an edge... 572 if(clicked_edge!=INVALID) 573 { 574 //If there is already edited edge, it has to be saved first 575 if(entrywidget.is_visible()) 576 { 577 GdkEvent * generated=new GdkEvent(); 578 generated->type=GDK_KEY_PRESS; 579 ((GdkEventKey*)generated)->keyval=GDK_KP_Enter; 580 entryWidgetChangeHandler(generated); 581 } 582 //If the previous value could be saved, we can go further, otherwise not 583 if(!entrywidget.is_visible()) 584 { 585 //and there is activated map 586 if(edgetextmap[clicked_edge]->property_text().get_value()!="") 587 { 588 //activate the general variable for it 589 active_edge=clicked_edge; 590 //delete visible widget if there is 591 if(canvasentrywidget) 592 { 593 delete(canvasentrywidget); 594 } 595 596 //initialize the entry 597 entrywidget.show(); 598 599 //fill in the correct value 600 entrywidget.set_text(edgetextmap[active_edge]->property_text().get_value()); 601 602 //replace and resize the entry to the activated edge and put it in a Canvas::Widget to be able to display it on gdc 603 xy<double> entry_coos; 604 entry_coos.x=(edgetextmap[active_edge])->property_x().get_value(); 605 entry_coos.x-=edgetextmap[active_edge]->property_text_width().get_value()/2; 606 entry_coos.y=(edgetextmap[active_edge])->property_y().get_value(); 607 entry_coos.y-=edgetextmap[active_edge]->property_text_height().get_value()*1.5/2; 608 canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, entry_coos.x, entry_coos.y, entrywidget); 609 canvasentrywidget->property_width().set_value(edgetextmap[active_edge]->property_text_width().get_value()*4); 610 canvasentrywidget->property_height().set_value(edgetextmap[active_edge]->property_text_height().get_value()*1.5); 611 } 612 } 613 } 614 //if it was not an edge... 615 else 616 { 617 //In this case the click did not happen on an edge 618 //if there is visible entry we save the value in it 619 //we pretend like an Enter was presse din the Entry widget 560 620 GdkEvent * generated=new GdkEvent(); 561 621 generated->type=GDK_KEY_PRESS; … … 563 623 entryWidgetChangeHandler(generated); 564 624 } 565 //If the previous value could be saved, we can go further, otherwise not566 if(!entrywidget.is_visible())567 {568 //and there is activated map569 if(edgetextmap[clicked_edge]->property_text().get_value()!="")570 {571 //activate the general variable for it572 active_edge=clicked_edge;573 //delete visible widget if there is574 if(canvasentrywidget)575 {576 delete(canvasentrywidget);577 }578 579 //initialize the entry580 entrywidget.show();581 582 //fill in the correct value583 entrywidget.set_text(edgetextmap[active_edge]->property_text().get_value());584 585 //replace and resize the entry to the activated edge and put it in a Canvas::Widget to be able to display it on gdc586 xy<double> entry_coos;587 entry_coos.x=(edgetextmap[active_edge])->property_x().get_value();588 entry_coos.x-=edgetextmap[active_edge]->property_text_width().get_value()/2;589 entry_coos.y=(edgetextmap[active_edge])->property_y().get_value();590 entry_coos.y-=edgetextmap[active_edge]->property_text_height().get_value()*1.5/2;591 canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, entry_coos.x, entry_coos.y, entrywidget);592 canvasentrywidget->property_width().set_value(edgetextmap[active_edge]->property_text_width().get_value()*4);593 canvasentrywidget->property_height().set_value(edgetextmap[active_edge]->property_text_height().get_value()*1.5);594 }595 }596 }597 //if it was not an edge...598 else599 {600 //In this case the click did not happen on an edge601 //if there is visible entry we save the value in it602 //we pretend like an Enter was presse din the Entry widget603 GdkEvent * generated=new GdkEvent();604 generated->type=GDK_KEY_PRESS;605 ((GdkEventKey*)generated)->keyval=GDK_KP_Enter;606 entryWidgetChangeHandler(generated);607 }608 break;609 }610 default:611 break;612 }613 return false;614 }615 616 bool GraphDisplayerCanvas::nodeMapEditEventHandler(GdkEvent* e)617 {618 switch(e->type)619 {620 case GDK_KEY_PRESS:621 //for Escape or Enter hide the displayed widget622 {623 switch(((GdkEventKey*)e)->keyval)624 {625 case GDK_Escape:626 entrywidget.hide();627 break;628 case GDK_Return:629 case GDK_KP_Enter:630 entrywidget.hide();631 break;632 default:633 625 break; 634 626 } 627 default: 628 break; 629 } 630 } 631 return false; 632 } 633 634 bool GraphDisplayerCanvas::nodeMapEditEventHandler(GdkEvent* e) 635 { 636 if(actual_tool==NODE_MAP_EDIT) 637 { 638 switch(e->type) 639 { 640 case GDK_KEY_PRESS: 641 //for Escape or Enter hide the displayed widget 642 { 643 switch(((GdkEventKey*)e)->keyval) 644 { 645 case GDK_Escape: 646 entrywidget.hide(); 647 break; 648 case GDK_Return: 649 case GDK_KP_Enter: 650 entrywidget.hide(); 651 break; 652 default: 653 break; 654 } 635 655 636 break; 637 } 638 case GDK_BUTTON_PRESS: 639 //If the click happened on an edge we place the entrywidget there and fill in the value of the activated map at that edge. 640 { 641 //find the activated item 642 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); 643 active_item=(get_item_at(clicked_x, clicked_y)); 644 645 //determine, whether it was a node 646 Graph::NodeIt clicked_node=INVALID; 647 for (NodeIt i(g); i!=INVALID; ++i) 656 break; 657 } 658 case GDK_BUTTON_PRESS: 659 //If the click happened on an edge we place the entrywidget there and fill in the value of the activated map at that edge. 648 660 { 649 if(nodesmap[i]==active_item) 650 { 651 clicked_node=i; 652 } 653 } 654 655 //if it was really an edge... 656 if(clicked_node!=INVALID) 657 { 658 //If there is already edited edge, it has to be saved first 659 if(entrywidget.is_visible()) 660 { 661 //for determine, whether it was a node 662 Graph::NodeIt clicked_node=INVALID; 663 664 //find the activated item between texts 665 active_item=(get_item_at(e->button.x, e->button.y)); 666 for (NodeIt i(g); i!=INVALID; ++i) 667 { 668 //at the same time only one can be active 669 if(nodetextmap[i]==active_item) 670 { 671 clicked_node=i; 672 } 673 } 674 675 //if there was not, search for it between nodes 676 if(clicked_node==INVALID) 677 { 678 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); 679 active_item=(get_item_at(clicked_x, clicked_y)); 680 681 for (NodeIt i(g); i!=INVALID; ++i) 682 { 683 //at the same time only one can be active 684 if(nodesmap[i]==active_item) 685 { 686 clicked_node=i; 687 } 688 } 689 } 690 //if it was really an edge... 691 if(clicked_node!=INVALID) 692 { 693 //If there is already edited edge, it has to be saved first 694 if(entrywidget.is_visible()) 695 { 696 GdkEvent * generated=new GdkEvent(); 697 generated->type=GDK_KEY_PRESS; 698 ((GdkEventKey*)generated)->keyval=GDK_KP_Enter; 699 entryWidgetChangeHandler(generated); 700 } 701 //If the previous value could be saved, we can go further, otherwise not 702 if(!entrywidget.is_visible()) 703 { 704 //and there is activated map 705 if(nodetextmap[clicked_node]->property_text().get_value()!="") 706 { 707 //activate the general variable for it 708 active_node=clicked_node; 709 //delete visible widget if there is 710 if(canvasentrywidget) 711 { 712 delete(canvasentrywidget); 713 } 714 715 //initialize the entry 716 entrywidget.show(); 717 718 //fill in the correct value 719 entrywidget.set_text(nodetextmap[active_node]->property_text().get_value()); 720 721 //replace and resize the entry to the activated node and put it in a Canvas::Widget to be able to display it on gdc 722 xy<double> entry_coos; 723 entry_coos.x=(nodetextmap[active_node])->property_x().get_value(); 724 entry_coos.x-=nodetextmap[active_node]->property_text_width().get_value()/2; 725 entry_coos.y=(nodetextmap[active_node])->property_y().get_value(); 726 entry_coos.y-=nodetextmap[active_node]->property_text_height().get_value()*1.5/2; 727 canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, entry_coos.x, entry_coos.y, entrywidget); 728 canvasentrywidget->property_width().set_value(nodetextmap[active_node]->property_text_width().get_value()*4); 729 canvasentrywidget->property_height().set_value(nodetextmap[active_node]->property_text_height().get_value()*1.5); 730 } 731 } 732 } 733 //if it was not an edge... 734 else 735 { 736 //In this case the click did not happen on an edge 737 //if there is visible entry we save the value in it 738 //we pretend like an Enter was presse din the Entry widget 661 739 GdkEvent * generated=new GdkEvent(); 662 740 generated->type=GDK_KEY_PRESS; … … 664 742 entryWidgetChangeHandler(generated); 665 743 } 666 //If the previous value could be saved, we can go further, otherwise not 667 if(!entrywidget.is_visible()) 668 { 669 //and there is activated map 670 if(nodetextmap[clicked_node]->property_text().get_value()!="") 671 { 672 //activate the general variable for it 673 active_node=clicked_node; 674 //delete visible widget if there is 675 if(canvasentrywidget) 676 { 677 delete(canvasentrywidget); 678 } 679 680 //initialize the entry 681 entrywidget.show(); 682 683 //fill in the correct value 684 entrywidget.set_text(nodetextmap[active_node]->property_text().get_value()); 685 686 //replace and resize the entry to the activated node and put it in a Canvas::Widget to be able to display it on gdc 687 xy<double> entry_coos; 688 entry_coos.x=(nodetextmap[active_node])->property_x().get_value(); 689 entry_coos.x-=nodetextmap[active_node]->property_text_width().get_value()/2; 690 entry_coos.y=(nodetextmap[active_node])->property_y().get_value(); 691 entry_coos.y-=nodetextmap[active_node]->property_text_height().get_value()*1.5/2; 692 canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, entry_coos.x, entry_coos.y, entrywidget); 693 canvasentrywidget->property_width().set_value(nodetextmap[active_node]->property_text_width().get_value()*1.5); 694 canvasentrywidget->property_height().set_value(nodetextmap[active_node]->property_text_height().get_value()*1.5); 695 } 696 } 744 break; 697 745 } 698 //if it was not an edge... 699 else 700 { 701 //In this case the click did not happen on an edge 702 //if there is visible entry we save the value in it 703 //we pretend like an Enter was presse din the Entry widget 704 GdkEvent * generated=new GdkEvent(); 705 generated->type=GDK_KEY_PRESS; 706 ((GdkEventKey*)generated)->keyval=GDK_KP_Enter; 707 entryWidgetChangeHandler(generated); 708 } 709 break; 710 } 711 default: 712 break; 746 default: 747 break; 748 } 713 749 } 714 750 return false; … … 783 819 else 784 820 { 785 std::c out<< "ERROR: only handling of double values is implemented yet!" << std::endl;821 std::cerr << "ERROR: only handling of double values is implemented yet!" << std::endl; 786 822 } 787 823 … … 830 866 if(forming_edge!=INVALID) 831 867 { 832 std::c out<< "ERROR!!!! Valid edge found!" << std::endl;868 std::cerr << "ERROR!!!! Valid edge found!" << std::endl; 833 869 } 834 870 else … … 851 887 else 852 888 { 853 std::c out<< "ERROR!!!! Invalid edge found!" << std::endl;889 std::cerr << "ERROR!!!! Invalid edge found!" << std::endl; 854 890 } 855 891 } -
gui/graph_displayer_canvas-node.cc
r1596 r1599 7 7 { 8 8 Graph::NodeMap<double> * actual_map; 9 double min, max; 9 10 if(mapname=="Default") 10 11 { 12 min=node_property_defaults[N_RADIUS]; 13 max=node_property_defaults[N_RADIUS]; 11 14 actual_map=new Graph::NodeMap<double>(g,node_property_defaults[N_RADIUS]); 12 15 } 13 16 else 14 17 { 18 min=mapstorage.minOfNodeMap(mapname); 19 max=mapstorage.maxOfNodeMap(mapname); 15 20 actual_map=(mapstorage.nodemap_storage)[mapname]; 16 21 } … … 20 25 for (NodeIt i(g); i!=INVALID; ++i) 21 26 { 22 int w=(int)(*actual_map)[i]; 27 double v=abs((*actual_map)[i]); 28 int w; 29 if(min==max) 30 { 31 w=(int)(node_property_defaults[N_RADIUS]); 32 } 33 else 34 { 35 w=(int)(MIN_NODE_RADIUS+(v-min)/(max-min)*(MAX_NODE_RADIUS-MIN_NODE_RADIUS)); 36 } 23 37 if(w>=0) 24 38 { -
gui/graph_displayer_canvas.cc
r1598 r1599 42 42 edgetextmap[i]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, ""); 43 43 edgetextmap[i]->property_fill_color().set_value("darkgreen"); 44 edgetextmap[i]->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::edgeMapEditEventHandler), false); 44 45 } 45 46 … … 70 71 nodetextmap[i]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, ""); 71 72 nodetextmap[i]->property_fill_color().set_value("darkblue"); 73 nodetextmap[i]->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::nodeMapEditEventHandler), false); 72 74 } 73 75 -
gui/map_win.cc
r1594 r1599 145 145 break; 146 146 default: 147 std::c out<<"Error\n";147 std::cerr<<"Error\n"; 148 148 } 149 149 } … … 176 176 break; 177 177 default: 178 std::c out<<"Error\n";178 std::cerr<<"Error\n"; 179 179 } 180 180 } … … 208 208 break; 209 209 default: 210 std::c out<<"Error\n";210 std::cerr<<"Error\n"; 211 211 } 212 212 } … … 243 243 break; 244 244 default: 245 std::c out<<"Error\n";245 std::cerr<<"Error\n"; 246 246 } 247 247 }
Note: See TracChangeset
for help on using the changeset viewer.