Changeset 1592:4708b716d2f4 in lemon-0.x for gui/graph_displayer_canvas-event.cc
- Timestamp:
- 07/26/05 23:19:41 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2096
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gui/graph_displayer_canvas-event.cc
r1589 r1592 671 671 case GDK_Return: 672 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++) 673 bool valid_double=true; 674 int point_num=0; 675 Glib::ustring mapvalue_str = entrywidget.get_text(); 676 677 char * mapvalue_ch=new char [mapvalue_str.length()]; 678 for(int i=0;i<(int)(mapvalue_str.length());i++) 681 679 { 682 if(((mapvalue [i]<='9')&&(mapvalue[i]>='0'))||(mapvalue[i]=='.'))680 if(((mapvalue_str[i]<'0')||(mapvalue_str[i]>'9'))&&(mapvalue_str[i]!='.')) 683 681 { 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 } 682 valid_double=false; 705 683 } 706 684 else 707 685 { 708 found_letter++; 709 continue; 686 if(mapvalue_str[i]=='.') 687 { 688 point_num++; 689 } 710 690 } 691 mapvalue_ch[i]=mapvalue_str[i]; 711 692 } 712 713 if(!found_letter) 693 694 double mapvalue_d=atof(mapvalue_ch); 695 696 // double double_map_fract_value=0; 697 // double double_map_value=0; 698 // int offset=0; 699 // int found_letter=0; 700 //converting text to double 701 // for(int i=0;i<(int)(mapvalue.length());i++) 702 // { 703 // if(((mapvalue[i]<='9')&&(mapvalue[i]>='0'))||(mapvalue[i]=='.')) 704 // { 705 // if(mapvalue[i]=='.') 706 // { 707 // //for calculating non-integer part of double we step backward from the end 708 // //after each step the number will be divided by ten, and the new value will be added 709 // //to step backward from the end until the point the actual character of the string is the following: 710 // // mapvalue.length()-(i-position_of_point) 711 // //if i was the number of the first character after the decimal point the selected character will be the last 712 // //if i was the number of the last character, the selected character will be the first after the decimal point 713 // offset=mapvalue.length()+i; 714 // } 715 // else 716 // { 717 // if(!offset) 718 // { 719 // double_map_value=10*double_map_value+mapvalue[i]-'0'; 720 // } 721 // else 722 // { 723 // double_map_fract_value=double_map_fract_value/10+(double)(mapvalue[offset-i]-'0')/10; 724 // } 725 // } 726 // } 727 // else 728 // { 729 // found_letter++; 730 // continue; 731 // } 732 // } 733 734 if((point_num<=1)&&(valid_double)) 714 735 { 715 736 switch(actual_tool) 716 737 { 717 738 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;739 edgetextmap[active_edge]->property_text().set_value(mapvalue_str); 740 (*(mapstorage.edgemap_storage)[edgemap_to_edit])[active_edge]=mapvalue_d; 720 741 break; 721 742 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;743 nodetextmap[active_node]->property_text().set_value(mapvalue_str); 744 (*(mapstorage.nodemap_storage)[nodemap_to_edit])[active_node]=mapvalue_d; 724 745 break; 725 746 default: … … 804 825 } 805 826 806 void GraphDisplayerCanvas::addNewEdgeMap() 807 { 808 Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (g,20); 809 mapstorage.addEdgeMap("NewEdgeMap",emptr); 810 mapwin->registerNewEdgeMap("NewEdgeMap"); 811 changeEdgeText("NewEdgeMap"); 812 } 813 814 void GraphDisplayerCanvas::addNewNodeMap() 815 { 816 std::cout << "Add New NodeMap is not yet implemented." << std::endl; 817 } 818 827 void GraphDisplayerCanvas::addNewEdgeMap(double default_value, std::string mapname) 828 { 829 Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (g,default_value); 830 mapstorage.addEdgeMap(mapname,emptr); 831 mapwin->registerNewEdgeMap(mapname); 832 changeEdgeText(mapname); 833 } 834 835 void GraphDisplayerCanvas::addNewNodeMap(double default_value, std::string mapname) 836 { 837 Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (g,default_value); 838 mapstorage.addNodeMap(mapname,emptr); 839 mapwin->registerNewNodeMap(mapname); 840 changeNodeText(mapname); 841 } 842
Note: See TracChangeset
for help on using the changeset viewer.