Changeset 1592:4708b716d2f4 in lemon-0.x
- Timestamp:
- 07/26/05 23:19:41 (19 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2096
- Location:
- gui
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
gui/Makefile.am
r1512 r1592 22 22 edit_win.h \ 23 23 broken_edge.cc \ 24 broken_edge.h 25 24 broken_edge.h \ 25 new_map_win.cc \ 26 new_map_win.h 26 27 27 28 gd_CXXFLAGS = $(GTK_CFLAGS) -
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 -
gui/graph_displayer_canvas.cc
r1581 r1592 6 6 { 7 7 8 8 //Initializing values. 9 9 active_node=INVALID; 10 10 active_edge=INVALID; -
gui/graph_displayer_canvas.h
r1589 r1592 111 111 112 112 ///creates a new Nodemap 113 void addNewNodeMap( );113 void addNewNodeMap(double,std::string); 114 114 ///creates a new Edgemap 115 void addNewEdgeMap( );115 void addNewEdgeMap(double,std::string); 116 116 117 117 private: -
gui/main_win.cc
r1585 r1592 2 2 3 3 MainWin::MainWin(const std::string& title, Graph & graph, CoordinatesMap & cm, 4 MapStorage & ms):mapwin("Map Setup", ms, gd_canvas),editwin("Editorial Window", gd_canvas), gd_canvas(graph, cm, ms, &mapwin)4 MapStorage & ms):mapwin("Map Setup", ms, gd_canvas),editwin("Editorial Window", gd_canvas),newmapwin("Creating new map",gd_canvas),gd_canvas(graph, cm, ms, &mapwin) 5 5 { 6 //Creating a window for setting new maps. 7 // newmapwin=new NewMapWi("Creating new map",*this); 8 9 6 10 set_title (title); 7 11 set_default_size(WIN_WIDTH,WIN_HEIGHT); … … 50 54 ag->add( Gtk::Action::create("EditNodeMap", Gtk::Stock::PREFERENCES), 51 55 sigc::bind( sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::changeEditorialTool ), 5) ); 52 ag->add( Gtk::Action::create("AddEdgeMap", Gtk::Stock::NEW), 53 sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::addNewEdgeMap ) ); 54 ag->add( Gtk::Action::create("AddNodeMap", Gtk::Stock::NEW), 55 sigc::mem_fun ( this->gd_canvas, &GraphDisplayerCanvas::addNewNodeMap ) ); 56 ag->add( Gtk::Action::create("AddMap", Gtk::Stock::NEW), 57 sigc::mem_fun ( this->newmapwin, &NewMapWin::show ) ); 56 58 57 59 uim=Gtk::UIManager::create(); … … 99 101 " <toolitem action='EditEdgeMap' />" 100 102 " <toolitem action='EditNodeMap' />" 101 " <toolitem action='AddEdgeMap' />" 102 " <toolitem action='AddNodeMap' />" 103 " <toolitem action='AddMap' />" 103 104 " </toolbar>" 104 105 "</ui>"; -
gui/main_win.h
r1468 r1592 7 7 #include <mapstorage.h> 8 8 #include <map_win.h> 9 #include <new_map_win.h> 9 10 #include <edit_win.h> 10 11 #include <libgnomecanvasmm.h> … … 29 30 ///Window of editorial tools. Its type is \ref EditWin 30 31 EditWin editwin; 32 33 ///We need to store newmapwin, to be able to set the appropriate values for properties of new map. 34 NewMapWin newmapwin; 31 35 32 36 ///The graph will be drawn on this \ref GraphDisplayerCanvas -
gui/map_win.cc
r1589 r1592 266 266 void MapWin::registerNewNodeMap(std::string newmapname) 267 267 { 268 for(int i=0;i< EDGE_PROPERTY_NUM;i++)268 for(int i=0;i<NODE_PROPERTY_NUM;i++) 269 269 { 270 270 //filling in combo box with choices … … 273 273 n_combo_array[i].set_popdown_strings(listStrings); 274 274 } 275 } 275 Gtk::Entry* entry = n_combo_array[N_TEXT].get_entry(); 276 entry->set_text((Glib::ustring)newmapname); 277 }
Note: See TracChangeset
for help on using the changeset viewer.