1.1 --- a/gui/graph_displayer_canvas-event.cc Tue Jul 26 20:14:03 2005 +0000
1.2 +++ b/gui/graph_displayer_canvas-event.cc Tue Jul 26 21:19:41 2005 +0000
1.3 @@ -670,57 +670,78 @@
1.4 case GDK_KP_Enter:
1.5 case GDK_Return:
1.6 {
1.7 - Glib::ustring mapvalue = entrywidget.get_text();
1.8 + bool valid_double=true;
1.9 + int point_num=0;
1.10 + Glib::ustring mapvalue_str = entrywidget.get_text();
1.11
1.12 - double double_map_fract_value=0;
1.13 - double double_map_value=0;
1.14 - int offset=0;
1.15 - int found_letter=0;
1.16 - //converting text to double
1.17 - for(int i=0;i<(int)(mapvalue.length());i++)
1.18 + char * mapvalue_ch=new char [mapvalue_str.length()];
1.19 + for(int i=0;i<(int)(mapvalue_str.length());i++)
1.20 {
1.21 - if(((mapvalue[i]<='9')&&(mapvalue[i]>='0'))||(mapvalue[i]=='.'))
1.22 + if(((mapvalue_str[i]<'0')||(mapvalue_str[i]>'9'))&&(mapvalue_str[i]!='.'))
1.23 {
1.24 - if(mapvalue[i]=='.')
1.25 - {
1.26 - //for calculating non-integer part of double we step backward from the end
1.27 - //after each step the number will be divided by ten, and the new value will be added
1.28 - //to step backward from the end until the point the actual character of the string is the following:
1.29 - // mapvalue.length()-(i-position_of_point)
1.30 - //if i was the number of the first character after the decimal point the selected character will be the last
1.31 - //if i was the number of the last character, the selected character will be the first after the decimal point
1.32 - offset=mapvalue.length()+i;
1.33 - }
1.34 - else
1.35 - {
1.36 - if(!offset)
1.37 - {
1.38 - double_map_value=10*double_map_value+mapvalue[i]-'0';
1.39 - }
1.40 - else
1.41 - {
1.42 - double_map_fract_value=double_map_fract_value/10+(double)(mapvalue[offset-i]-'0')/10;
1.43 - }
1.44 - }
1.45 + valid_double=false;
1.46 }
1.47 else
1.48 {
1.49 - found_letter++;
1.50 - continue;
1.51 + if(mapvalue_str[i]=='.')
1.52 + {
1.53 + point_num++;
1.54 + }
1.55 }
1.56 + mapvalue_ch[i]=mapvalue_str[i];
1.57 }
1.58 +
1.59 + double mapvalue_d=atof(mapvalue_ch);
1.60
1.61 - if(!found_letter)
1.62 +// double double_map_fract_value=0;
1.63 +// double double_map_value=0;
1.64 +// int offset=0;
1.65 +// int found_letter=0;
1.66 + //converting text to double
1.67 +// for(int i=0;i<(int)(mapvalue.length());i++)
1.68 +// {
1.69 +// if(((mapvalue[i]<='9')&&(mapvalue[i]>='0'))||(mapvalue[i]=='.'))
1.70 +// {
1.71 +// if(mapvalue[i]=='.')
1.72 +// {
1.73 +// //for calculating non-integer part of double we step backward from the end
1.74 +// //after each step the number will be divided by ten, and the new value will be added
1.75 +// //to step backward from the end until the point the actual character of the string is the following:
1.76 +// // mapvalue.length()-(i-position_of_point)
1.77 +// //if i was the number of the first character after the decimal point the selected character will be the last
1.78 +// //if i was the number of the last character, the selected character will be the first after the decimal point
1.79 +// offset=mapvalue.length()+i;
1.80 +// }
1.81 +// else
1.82 +// {
1.83 +// if(!offset)
1.84 +// {
1.85 +// double_map_value=10*double_map_value+mapvalue[i]-'0';
1.86 +// }
1.87 +// else
1.88 +// {
1.89 +// double_map_fract_value=double_map_fract_value/10+(double)(mapvalue[offset-i]-'0')/10;
1.90 +// }
1.91 +// }
1.92 +// }
1.93 +// else
1.94 +// {
1.95 +// found_letter++;
1.96 +// continue;
1.97 +// }
1.98 +// }
1.99 +
1.100 + if((point_num<=1)&&(valid_double))
1.101 {
1.102 switch(actual_tool)
1.103 {
1.104 case EDGE_MAP_EDIT:
1.105 - edgetextmap[active_edge]->property_text().set_value(mapvalue);
1.106 - (*(mapstorage.edgemap_storage)[edgemap_to_edit])[active_edge]=double_map_value+double_map_fract_value;
1.107 + edgetextmap[active_edge]->property_text().set_value(mapvalue_str);
1.108 + (*(mapstorage.edgemap_storage)[edgemap_to_edit])[active_edge]=mapvalue_d;
1.109 break;
1.110 case NODE_MAP_EDIT:
1.111 - nodetextmap[active_node]->property_text().set_value(mapvalue);
1.112 - (*(mapstorage.nodemap_storage)[nodemap_to_edit])[active_node]=double_map_value+double_map_fract_value;
1.113 + nodetextmap[active_node]->property_text().set_value(mapvalue_str);
1.114 + (*(mapstorage.nodemap_storage)[nodemap_to_edit])[active_node]=mapvalue_d;
1.115 break;
1.116 default:
1.117 break;
1.118 @@ -803,16 +824,19 @@
1.119
1.120 }
1.121
1.122 -void GraphDisplayerCanvas::addNewEdgeMap()
1.123 +void GraphDisplayerCanvas::addNewEdgeMap(double default_value, std::string mapname)
1.124 {
1.125 - Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (g,20);
1.126 - mapstorage.addEdgeMap("NewEdgeMap",emptr);
1.127 - mapwin->registerNewEdgeMap("NewEdgeMap");
1.128 - changeEdgeText("NewEdgeMap");
1.129 + Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (g,default_value);
1.130 + mapstorage.addEdgeMap(mapname,emptr);
1.131 + mapwin->registerNewEdgeMap(mapname);
1.132 + changeEdgeText(mapname);
1.133 }
1.134
1.135 -void GraphDisplayerCanvas::addNewNodeMap()
1.136 +void GraphDisplayerCanvas::addNewNodeMap(double default_value, std::string mapname)
1.137 {
1.138 - std::cout << "Add New NodeMap is not yet implemented." << std::endl;
1.139 + Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (g,default_value);
1.140 + mapstorage.addNodeMap(mapname,emptr);
1.141 + mapwin->registerNewNodeMap(mapname);
1.142 + changeNodeText(mapname);
1.143 }
1.144