diff -r 03aa0a6c8dca -r 4708b716d2f4 gui/graph_displayer_canvas-event.cc --- a/gui/graph_displayer_canvas-event.cc Tue Jul 26 20:14:03 2005 +0000 +++ b/gui/graph_displayer_canvas-event.cc Tue Jul 26 21:19:41 2005 +0000 @@ -670,57 +670,78 @@ case GDK_KP_Enter: case GDK_Return: { - Glib::ustring mapvalue = entrywidget.get_text(); + bool valid_double=true; + int point_num=0; + Glib::ustring mapvalue_str = entrywidget.get_text(); - double double_map_fract_value=0; - double double_map_value=0; - int offset=0; - int found_letter=0; - //converting text to double - for(int i=0;i<(int)(mapvalue.length());i++) + char * mapvalue_ch=new char [mapvalue_str.length()]; + for(int i=0;i<(int)(mapvalue_str.length());i++) { - if(((mapvalue[i]<='9')&&(mapvalue[i]>='0'))||(mapvalue[i]=='.')) + if(((mapvalue_str[i]<'0')||(mapvalue_str[i]>'9'))&&(mapvalue_str[i]!='.')) { - if(mapvalue[i]=='.') - { - //for calculating non-integer part of double we step backward from the end - //after each step the number will be divided by ten, and the new value will be added - //to step backward from the end until the point the actual character of the string is the following: - // mapvalue.length()-(i-position_of_point) - //if i was the number of the first character after the decimal point the selected character will be the last - //if i was the number of the last character, the selected character will be the first after the decimal point - offset=mapvalue.length()+i; - } - else - { - if(!offset) - { - double_map_value=10*double_map_value+mapvalue[i]-'0'; - } - else - { - double_map_fract_value=double_map_fract_value/10+(double)(mapvalue[offset-i]-'0')/10; - } - } + valid_double=false; } else { - found_letter++; - continue; + if(mapvalue_str[i]=='.') + { + point_num++; + } } + mapvalue_ch[i]=mapvalue_str[i]; } + + double mapvalue_d=atof(mapvalue_ch); - if(!found_letter) +// double double_map_fract_value=0; +// double double_map_value=0; +// int offset=0; +// int found_letter=0; + //converting text to double +// for(int i=0;i<(int)(mapvalue.length());i++) +// { +// if(((mapvalue[i]<='9')&&(mapvalue[i]>='0'))||(mapvalue[i]=='.')) +// { +// if(mapvalue[i]=='.') +// { +// //for calculating non-integer part of double we step backward from the end +// //after each step the number will be divided by ten, and the new value will be added +// //to step backward from the end until the point the actual character of the string is the following: +// // mapvalue.length()-(i-position_of_point) +// //if i was the number of the first character after the decimal point the selected character will be the last +// //if i was the number of the last character, the selected character will be the first after the decimal point +// offset=mapvalue.length()+i; +// } +// else +// { +// if(!offset) +// { +// double_map_value=10*double_map_value+mapvalue[i]-'0'; +// } +// else +// { +// double_map_fract_value=double_map_fract_value/10+(double)(mapvalue[offset-i]-'0')/10; +// } +// } +// } +// else +// { +// found_letter++; +// continue; +// } +// } + + if((point_num<=1)&&(valid_double)) { switch(actual_tool) { case EDGE_MAP_EDIT: - edgetextmap[active_edge]->property_text().set_value(mapvalue); - (*(mapstorage.edgemap_storage)[edgemap_to_edit])[active_edge]=double_map_value+double_map_fract_value; + edgetextmap[active_edge]->property_text().set_value(mapvalue_str); + (*(mapstorage.edgemap_storage)[edgemap_to_edit])[active_edge]=mapvalue_d; break; case NODE_MAP_EDIT: - nodetextmap[active_node]->property_text().set_value(mapvalue); - (*(mapstorage.nodemap_storage)[nodemap_to_edit])[active_node]=double_map_value+double_map_fract_value; + nodetextmap[active_node]->property_text().set_value(mapvalue_str); + (*(mapstorage.nodemap_storage)[nodemap_to_edit])[active_node]=mapvalue_d; break; default: break; @@ -803,16 +824,19 @@ } -void GraphDisplayerCanvas::addNewEdgeMap() +void GraphDisplayerCanvas::addNewEdgeMap(double default_value, std::string mapname) { - Graph::EdgeMap * emptr=new Graph::EdgeMap (g,20); - mapstorage.addEdgeMap("NewEdgeMap",emptr); - mapwin->registerNewEdgeMap("NewEdgeMap"); - changeEdgeText("NewEdgeMap"); + Graph::EdgeMap * emptr=new Graph::EdgeMap (g,default_value); + mapstorage.addEdgeMap(mapname,emptr); + mapwin->registerNewEdgeMap(mapname); + changeEdgeText(mapname); } -void GraphDisplayerCanvas::addNewNodeMap() +void GraphDisplayerCanvas::addNewNodeMap(double default_value, std::string mapname) { - std::cout << "Add New NodeMap is not yet implemented." << std::endl; + Graph::NodeMap * emptr=new Graph::NodeMap (g,default_value); + mapstorage.addNodeMap(mapname,emptr); + mapwin->registerNewNodeMap(mapname); + changeNodeText(mapname); }