gui/graph_displayer_canvas-node.cc
changeset 1596 44897b1ba4e2
parent 1581 9bb83c7f479b
child 1599 c2f95eac652b
     1.1 --- a/gui/graph_displayer_canvas-node.cc	Wed Jul 27 11:02:51 2005 +0000
     1.2 +++ b/gui/graph_displayer_canvas-node.cc	Wed Jul 27 11:19:35 2005 +0000
     1.3 @@ -149,37 +149,11 @@
     1.4  	    {
     1.5  	      nodemap_to_edit=mapname;
     1.6  	      double number=(*actual_map)[i];
     1.7 -	      int length=1;
     1.8 -	      //if number is smaller than one, length would be negative, or invalid
     1.9 -	      if(number>=1)
    1.10 -		{
    1.11 -		  length=(int)(floor(log(number)/log(10)))+1;
    1.12 -		}
    1.13 -	      int maxpos=(int)(pow(10,length-1));
    1.14 -	      int strl=length+1+RANGE;
    1.15 -	      char * str=new char[strl];
    1.16 -	      str[length]='.';
    1.17 -	      str[strl]='\0';
    1.18 -      
    1.19 -	      for(int j=0;j<strl;j++)
    1.20 -		{
    1.21 -		  if(j!=length)
    1.22 -		    {
    1.23 -//  		      std::cout << (number) << "-" << (int)number << "=" << (number)-(int)number << std::endl;
    1.24 -		      if((number-(int)number)>ALMOST_ONE)
    1.25 -			{
    1.26 -// 			  std::cout<<"rounding: " <<number<<std::endl;
    1.27 -			  number=round(number);
    1.28 -			}
    1.29 - 		      int digit=(int)(number/maxpos);
    1.30 -// 		      std::cout << number << "/" << maxpos << "=" << digit << std::endl;
    1.31 -		      str[j]=(digit+'0');
    1.32 -		      number-=digit*maxpos;
    1.33 -		      number*=10;
    1.34 -		    }
    1.35 -		}
    1.36 -      
    1.37 -	      nodetextmap[i]->property_text().set_value(str);
    1.38 +
    1.39 +	      std::ostringstream ostr;
    1.40 +	      ostr << number;
    1.41 +	      
    1.42 +      	      nodetextmap[i]->property_text().set_value(ostr.str());
    1.43  	    }
    1.44  	  else
    1.45  	    {
    1.46 @@ -193,34 +167,11 @@
    1.47        if(mapname!="Default")
    1.48  	{
    1.49  	  double number=(*actual_map)[node];
    1.50 -	  int length=1;
    1.51 -	  //if number is smaller than one, length would be negative, or invalid
    1.52 -	  if(number>=1)
    1.53 -	    {
    1.54 -	      length=(int)(floor(log(number)/log(10)))+1;
    1.55 -	    }
    1.56 -	  int maxpos=(int)(pow(10,length-1));
    1.57 -	  int strl=length+1+RANGE;
    1.58 -	  char * str=new char[strl];
    1.59 -	  str[length]='.';
    1.60 -	  str[strl]='\0';
    1.61 -      
    1.62 -	  for(int j=0;j<strl;j++)
    1.63 -	    {
    1.64 -	      if(j!=length)
    1.65 -		{
    1.66 -		  if((number-(int)number)>ALMOST_ONE)
    1.67 -		    {
    1.68 -		      number=round(number);
    1.69 -		    }
    1.70 -		  int digit=(int)(number/maxpos);
    1.71 -		  str[j]=(digit+'0');
    1.72 -		  number-=digit*maxpos;
    1.73 -		  number*=10;
    1.74 -		}
    1.75 -	    }
    1.76 -      
    1.77 -	  nodetextmap[node]->property_text().set_value(str);
    1.78 +
    1.79 +	  std::ostringstream ostr;
    1.80 +	  ostr << number;
    1.81 +	      
    1.82 +	  nodetextmap[node]->property_text().set_value(ostr.str());
    1.83  	}
    1.84        else
    1.85  	{