Changeset 35:79bffdf6aea2 in glemon-0.x
- Timestamp:
- 07/21/05 21:28:29 (19 years ago)
- Branch:
- gui
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk/gui@2081
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
graph_displayer_canvas-edge.cc
r31 r35 119 119 if(mapname!="Default") 120 120 { 121 edgemap_to_edit=mapname; 121 122 double number=(*(mapstorage.edgemap_storage)[mapname])[i]; 122 123 int length=1; … … 147 148 else 148 149 { 150 edgemap_to_edit=""; 149 151 edgetextmap[i]->property_text().set_value(""); 150 152 } -
graph_displayer_canvas-event.cc
r34 r35 30 30 } 31 31 case EDGE_MAP_EDIT: 32 break; 32 //has to do the same thing as in the case of NODE_MAP_EDIT 33 case NODE_MAP_EDIT: 34 { 35 GdkEvent * generated=new GdkEvent(); 36 generated->type=GDK_KEY_PRESS; 37 ((GdkEventKey*)generated)->keyval=GDK_KP_Enter; 38 entryWidgetChangeHandler(generated); 39 entrywidget.hide(); 40 break; 41 } 33 42 default: 34 43 break; … … 218 227 219 228 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); 220 221 target_item=NULL;222 target_item=get_item_at(clicked_x, clicked_y);223 229 224 230 nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph, clicked_x-20, clicked_y-20, clicked_x+20, clicked_y+20); … … 248 254 //finalize the new node 249 255 case GDK_BUTTON_RELEASE: 256 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); 257 258 active_item->lower_to_bottom(); 259 260 target_item=NULL; 261 target_item=get_item_at(clicked_x, clicked_y); 262 263 active_item->raise_to_top(); 264 250 265 isbutton=0; 251 if( !target_item)266 if(target_item==active_item) 252 267 { 253 268 //Its appropriate color is given by update. 254 //*active_item << Gnome::Canvas::Properties::fill_color("blue");269 *active_item << Gnome::Canvas::Properties::fill_color("blue"); 255 270 } 256 271 else … … 509 524 case GDK_KEY_PRESS: 510 525 { 511 std::cout << "Any button was pressed" << std::endl; 512 switch(((GdkEventKey*)e)->keyval) 513 { 514 case GDK_A: 515 std::cout << "A button was pressed" << std::endl; 516 break; 517 default: 518 break; 519 } 520 526 nodeMapEditEventHandler(e); 521 527 break; 522 528 } … … 556 562 else 557 563 { 558 //mentse el -> problema, hogy nem tudja melyik map-be 559 entrywidget.hide(); 564 GdkEvent * generated=new GdkEvent(); 565 generated->type=GDK_KEY_PRESS; 566 ((GdkEventKey*)generated)->keyval=GDK_KP_Enter; 567 entryWidgetChangeHandler(generated); 560 568 } 561 569 break; … … 569 577 bool GraphDisplayerCanvas::nodeMapEditEventHandler(GdkEvent* e) 570 578 { 571 e=e; 572 return false; 579 switch(e->type) 580 { 581 case GDK_KEY_PRESS: 582 { 583 switch(((GdkEventKey*)e)->keyval) 584 { 585 case GDK_Escape: 586 entrywidget.hide(); 587 break; 588 case GDK_Return: 589 case GDK_KP_Enter: 590 entrywidget.hide(); 591 break; 592 default: 593 break; 594 } 595 596 break; 597 } 598 case GDK_BUTTON_PRESS: 599 { 600 window_to_world (e->button.x, e->button.y, clicked_x, clicked_y); 601 active_item=(get_item_at(clicked_x, clicked_y)); 602 Graph::NodeIt clicked_node=INVALID; 603 for (NodeIt i(g); i!=INVALID; ++i) 604 { 605 if(nodesmap[i]==active_item) 606 { 607 clicked_node=i; 608 } 609 } 610 if(clicked_node!=INVALID) 611 { 612 //If there is already edited edge, it has to be saved first 613 if(entrywidget.is_visible()) 614 { 615 GdkEvent * generated=new GdkEvent(); 616 generated->type=GDK_KEY_PRESS; 617 ((GdkEventKey*)generated)->keyval=GDK_KP_Enter; 618 entryWidgetChangeHandler(generated); 619 } 620 //If the previous value could be saved, we can go further, otherwise not 621 if(!entrywidget.is_visible()) 622 { 623 624 if(nodetextmap[clicked_node]->property_text().get_value()!="") 625 { 626 active_node=clicked_node; 627 if(canvasentrywidget) 628 { 629 delete(canvasentrywidget); 630 } 631 entrywidget.show(); 632 entrywidget.set_text(nodetextmap[active_node]->property_text().get_value()); 633 xy<double> entry_coos; 634 entry_coos.x=(nodetextmap[active_node])->property_x().get_value(); 635 entry_coos.x-=nodetextmap[active_node]->property_text_width().get_value()/2; 636 entry_coos.y=(nodetextmap[active_node])->property_y().get_value(); 637 entry_coos.y-=nodetextmap[active_node]->property_text_height().get_value()*1.5/2; 638 canvasentrywidget=new Gnome::Canvas::Widget(displayed_graph, entry_coos.x, entry_coos.y, entrywidget); 639 canvasentrywidget->property_width().set_value(nodetextmap[active_node]->property_text_width().get_value()*1.5); 640 canvasentrywidget->property_height().set_value(nodetextmap[active_node]->property_text_height().get_value()*1.5); 641 } 642 } 643 } 644 else 645 { 646 GdkEvent * generated=new GdkEvent(); 647 generated->type=GDK_KEY_PRESS; 648 ((GdkEventKey*)generated)->keyval=GDK_KP_Enter; 649 entryWidgetChangeHandler(generated); 650 } 651 break; 652 } 653 default: 654 break; 655 } 656 return false; 573 657 } 574 658 575 659 bool GraphDisplayerCanvas::entryWidgetChangeHandler(GdkEvent* e) 576 660 { 577 Glib::ustring mapvalue = entrywidget.get_text(); 578 std::cout << mapvalue << std::endl; 579 e=e; 661 if(entrywidget.is_visible()) 662 { 663 if(e->type==GDK_KEY_PRESS) 664 { 665 switch(((GdkEventKey*)e)->keyval) 666 { 667 case GDK_Escape: 668 entrywidget.hide(); 669 break; 670 case GDK_KP_Enter: 671 case GDK_Return: 672 { 673 Glib::ustring mapvalue = entrywidget.get_text(); 674 675 double double_map_fract_value=0; 676 double double_map_value=0; 677 int offset=0; 678 int found_letter=0; 679 //converting text to double 680 for(int i=0;i<(int)(mapvalue.length());i++) 681 { 682 if(((mapvalue[i]<='9')&&(mapvalue[i]>='0'))||(mapvalue[i]=='.')) 683 { 684 if(mapvalue[i]=='.') 685 { 686 //for calculating non-integer part of double we step backward from the end 687 //after each step the number will be divided by ten, and the new value will be added 688 //to step backward from the end until the point the actual character of the string is the following: 689 // mapvalue.length()-(i-position_of_point) 690 //if i was the number of the first character after the decimal point the selected character will be the last 691 //if i was the number of the last character, the selected character will be the first after the decimal point 692 offset=mapvalue.length()+i; 693 } 694 else 695 { 696 if(!offset) 697 { 698 double_map_value=10*double_map_value+mapvalue[i]-'0'; 699 } 700 else 701 { 702 double_map_fract_value=double_map_fract_value/10+(double)(mapvalue[offset-i]-'0')/10; 703 } 704 } 705 } 706 else 707 { 708 found_letter++; 709 continue; 710 } 711 } 712 713 if(!found_letter) 714 { 715 switch(actual_tool) 716 { 717 case EDGE_MAP_EDIT: 718 edgetextmap[active_edge]->property_text().set_value(mapvalue); 719 (*(mapstorage.edgemap_storage)[edgemap_to_edit])[active_edge]=double_map_value+double_map_fract_value; 720 break; 721 case NODE_MAP_EDIT: 722 nodetextmap[active_node]->property_text().set_value(mapvalue); 723 (*(mapstorage.nodemap_storage)[nodemap_to_edit])[active_node]=double_map_value+double_map_fract_value; 724 break; 725 default: 726 break; 727 } 728 entrywidget.hide(); 729 } 730 else 731 { 732 std::cout << "ERROR: only handling of double values is implemented yet!" << std::endl; 733 } 734 735 break; 736 } 737 default: 738 break; 739 } 740 } 741 } 580 742 return false; 581 743 } … … 605 767 { 606 768 new_place+=(xy<double>(10,10)); 607 edgetextmap[ active_edge]->property_x().set_value(new_place.x);608 edgetextmap[ active_edge]->property_y().set_value(new_place.y);769 edgetextmap[forming_edge]->property_x().set_value(new_place.x); 770 edgetextmap[forming_edge]->property_y().set_value(new_place.y); 609 771 } 610 772 … … 613 775 if(on) 614 776 { 615 if( active_edge!=INVALID)777 if(forming_edge!=INVALID) 616 778 { 617 779 std::cout << "ERROR!!!! Valid edge found!" << std::endl; … … 623 785 if(edgesmap[i]==active_bre) 624 786 { 625 active_edge=i;787 forming_edge=i; 626 788 } 627 789 } … … 630 792 else 631 793 { 632 if( active_edge!=INVALID)633 { 634 active_edge=INVALID;794 if(forming_edge!=INVALID) 795 { 796 forming_edge=INVALID; 635 797 } 636 798 else -
graph_displayer_canvas-node.cc
r31 r35 137 137 138 138 Graph::NodeMap<double> * actual_map; 139 if(mapname=="Default") 140 { 141 actual_map=new Graph::NodeMap<double>(g,node_property_defaults[N_COLOR]); 142 } 143 else 139 if(mapname!="Default") 144 140 { 145 141 actual_map=(mapstorage.nodemap_storage)[mapname]; … … 152 148 if(mapname!="Default") 153 149 { 150 nodemap_to_edit=mapname; 154 151 double number=(*actual_map)[i]; 155 152 int length=1; … … 169 166 if(j!=length) 170 167 { 171 int digit=(int)(number/maxpos);168 int digit=(int)round(number/maxpos); 172 169 str[j]=(digit+'0'); 173 170 number-=digit*maxpos; … … 180 177 else 181 178 { 179 nodemap_to_edit=""; 182 180 nodetextmap[i]->property_text().set_value(""); 183 181 } -
graph_displayer_canvas.cc
r34 r35 3 3 #include <math.h> 4 4 5 GraphDisplayerCanvas::GraphDisplayerCanvas(Graph & gr, CoordinatesMap & cm, MapStorage & ms, MapWin * mw):g(gr),nodesmap(g),edgesmap(g),edgetextmap(g),nodetextmap(g),displayed_graph(*(root()), 0, 0),canvasentrywidget(NULL),mapstorage(ms),isbutton(0),active_item(NULL),target_item(NULL), mapwin(mw)5 GraphDisplayerCanvas::GraphDisplayerCanvas(Graph & gr, CoordinatesMap & cm, MapStorage & ms, MapWin * mw):g(gr),nodesmap(g),edgesmap(g),edgetextmap(g),nodetextmap(g),displayed_graph(*(root()), 0, 0),canvasentrywidget(NULL),mapstorage(ms),isbutton(0),active_item(NULL),target_item(NULL),edgemap_to_edit(""),nodemap_to_edit(""),mapwin(mw) 6 6 { 7 7 8 8 9 active_node=INVALID; 9 10 active_edge=INVALID; 11 forming_edge=INVALID; 10 12 11 13 //setting event handler for the editor widget … … 14 16 //base event handler is move tool 15 17 actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false); 16 actual_tool= CREATE_NODE;18 actual_tool=MOVE; 17 19 18 20 //set_center_scroll_region(true); -
graph_displayer_canvas.h
r34 r35 98 98 void textReposition(xy<double>); 99 99 ///Activates an edge belonging to a BrokenEdge 100 /// 101 ///After we have activated an edge this way, 102 ///the GDC object will know, which edge is under forming 103 ///therefore it can redraw the necessarz elementy on the canvas, 104 ///for example the text belonging to the \ref BrokenEdge can be 105 ///redrawn (\ref textReposition). 100 106 void toggleEdgeActivity(BrokenEdge*, bool); 101 107 … … 158 164 Graph::NodeIt active_node; 159 165 Graph::EdgeIt active_edge; 166 Graph::EdgeIt forming_edge; 167 168 std::string nodemap_to_edit, edgemap_to_edit; 160 169 161 170 static const int zoom_step = 5; -
graphocska.lgf
r1 r35 1 1 @nodeset 2 2 id coordinates_x coordinates_y data 3 1 230 -80 1 3 1 230 -80 1.123 4 4 2 230 100 3 5 5 3 120 -80 5
Note: See TracChangeset
for help on using the changeset viewer.