# HG changeset patch # User hegyi # Date 1122463175 0 # Node ID 44897b1ba4e2f1c65b5f27e9ae7c1e0e139eba24 # Parent 3bde58e2d5ca883d2ab0012bc7ce837db390dfad Sorry for the previous commit, it was not ready yet, but that damned up arrow... So in this new revision string-double and double-string conversion is corrected to a more C++ way. diff -r 3bde58e2d5ca -r 44897b1ba4e2 gui/graph_displayer_canvas-edge.cc --- a/gui/graph_displayer_canvas-edge.cc Wed Jul 27 11:02:51 2005 +0000 +++ b/gui/graph_displayer_canvas-edge.cc Wed Jul 27 11:19:35 2005 +0000 @@ -119,37 +119,10 @@ { edgemap_to_edit=mapname; double number=(*(mapstorage.edgemap_storage)[mapname])[i]; -// int length=1; -// //if number is smaller than one, length would be negative, or invalid -// if(number>=1) -// { -// length=(int)(floor(log(number)/log(10)))+1; -// } -// int maxpos=(int)(pow(10,length-1)); -// int strl=length+1+RANGE; -// char * str=new char[strl]; -// str[length]='.'; -// str[strl]='\0'; - -// for(int j=0;jALMOST_ONE) -// { -// number=round(number); -// } -// int digit=(int)(number/maxpos); -// str[j]=(digit+'0'); -// number-=digit*maxpos; -// number*=10; -// } -// } -// edgetextmap[i]->property_text().set_value(str); std::ostringstream ostr; ostr << number; - + edgetextmap[i]->property_text().set_value(ostr.str()); } else @@ -165,34 +138,11 @@ if(mapname!="Default") { double number=(*(mapstorage.edgemap_storage)[mapname])[edge]; - int length=1; - //if number is smaller than one, length would be negative, or invalid - if(number>=1) - { - length=(int)(floor(log(number)/log(10)))+1; - } - int maxpos=(int)(pow(10,length-1)); - int strl=length+1+RANGE; - char * str=new char[strl]; - str[length]='.'; - str[strl]='\0'; - - for(int j=0;jALMOST_ONE) - { - number=round(number); - } - int digit=(int)(number/maxpos); - str[j]=(digit+'0'); - number-=digit*maxpos; - number*=10; - } - } - - edgetextmap[edge]->property_text().set_value(str); + + std::ostringstream ostr; + ostr << number; + + edgetextmap[edge]->property_text().set_value(ostr.str()); } else { diff -r 3bde58e2d5ca -r 44897b1ba4e2 gui/graph_displayer_canvas-event.cc --- a/gui/graph_displayer_canvas-event.cc Wed Jul 27 11:02:51 2005 +0000 +++ b/gui/graph_displayer_canvas-event.cc Wed Jul 27 11:19:35 2005 +0000 @@ -751,21 +751,25 @@ } mapvalue_ch[i]=mapvalue_str[i]; } - - double mapvalue_d=atof(mapvalue_ch); - + //if the text in the entry was correct if((point_num<=1)&&(valid_double)) { + double mapvalue_d=atof(mapvalue_ch); + + //reconvert the double to string for the correct format + std::ostringstream ostr; + ostr << mapvalue_d; + //save the value to the correct place switch(actual_tool) { case EDGE_MAP_EDIT: - edgetextmap[active_edge]->property_text().set_value(mapvalue_str); + edgetextmap[active_edge]->property_text().set_value(ostr.str()); (*(mapstorage.edgemap_storage)[edgemap_to_edit])[active_edge]=mapvalue_d; break; case NODE_MAP_EDIT: - nodetextmap[active_node]->property_text().set_value(mapvalue_str); + nodetextmap[active_node]->property_text().set_value(ostr.str()); (*(mapstorage.nodemap_storage)[nodemap_to_edit])[active_node]=mapvalue_d; break; default: diff -r 3bde58e2d5ca -r 44897b1ba4e2 gui/graph_displayer_canvas-node.cc --- a/gui/graph_displayer_canvas-node.cc Wed Jul 27 11:02:51 2005 +0000 +++ b/gui/graph_displayer_canvas-node.cc Wed Jul 27 11:19:35 2005 +0000 @@ -149,37 +149,11 @@ { nodemap_to_edit=mapname; double number=(*actual_map)[i]; - int length=1; - //if number is smaller than one, length would be negative, or invalid - if(number>=1) - { - length=(int)(floor(log(number)/log(10)))+1; - } - int maxpos=(int)(pow(10,length-1)); - int strl=length+1+RANGE; - char * str=new char[strl]; - str[length]='.'; - str[strl]='\0'; - - for(int j=0;j=1) - { - length=(int)(floor(log(number)/log(10)))+1; - } - int maxpos=(int)(pow(10,length-1)); - int strl=length+1+RANGE; - char * str=new char[strl]; - str[length]='.'; - str[strl]='\0'; - - for(int j=0;jALMOST_ONE) - { - number=round(number); - } - int digit=(int)(number/maxpos); - str[j]=(digit+'0'); - number-=digit*maxpos; - number*=10; - } - } - - nodetextmap[node]->property_text().set_value(str); + + std::ostringstream ostr; + ostr << number; + + nodetextmap[node]->property_text().set_value(ostr.str()); } else {