gui/graph_displayer_canvas-node.cc
changeset 1596 44897b1ba4e2
parent 1581 9bb83c7f479b
child 1599 c2f95eac652b
equal deleted inserted replaced
3:1a3337989b03 4:9887175e8d0a
   147 	{
   147 	{
   148 	  if(mapname!="Default")
   148 	  if(mapname!="Default")
   149 	    {
   149 	    {
   150 	      nodemap_to_edit=mapname;
   150 	      nodemap_to_edit=mapname;
   151 	      double number=(*actual_map)[i];
   151 	      double number=(*actual_map)[i];
   152 	      int length=1;
   152 
   153 	      //if number is smaller than one, length would be negative, or invalid
   153 	      std::ostringstream ostr;
   154 	      if(number>=1)
   154 	      ostr << number;
   155 		{
   155 	      
   156 		  length=(int)(floor(log(number)/log(10)))+1;
   156       	      nodetextmap[i]->property_text().set_value(ostr.str());
   157 		}
       
   158 	      int maxpos=(int)(pow(10,length-1));
       
   159 	      int strl=length+1+RANGE;
       
   160 	      char * str=new char[strl];
       
   161 	      str[length]='.';
       
   162 	      str[strl]='\0';
       
   163       
       
   164 	      for(int j=0;j<strl;j++)
       
   165 		{
       
   166 		  if(j!=length)
       
   167 		    {
       
   168 //  		      std::cout << (number) << "-" << (int)number << "=" << (number)-(int)number << std::endl;
       
   169 		      if((number-(int)number)>ALMOST_ONE)
       
   170 			{
       
   171 // 			  std::cout<<"rounding: " <<number<<std::endl;
       
   172 			  number=round(number);
       
   173 			}
       
   174  		      int digit=(int)(number/maxpos);
       
   175 // 		      std::cout << number << "/" << maxpos << "=" << digit << std::endl;
       
   176 		      str[j]=(digit+'0');
       
   177 		      number-=digit*maxpos;
       
   178 		      number*=10;
       
   179 		    }
       
   180 		}
       
   181       
       
   182 	      nodetextmap[i]->property_text().set_value(str);
       
   183 	    }
   157 	    }
   184 	  else
   158 	  else
   185 	    {
   159 	    {
   186 	      nodemap_to_edit="";
   160 	      nodemap_to_edit="";
   187 	      nodetextmap[i]->property_text().set_value("");
   161 	      nodetextmap[i]->property_text().set_value("");
   191   else
   165   else
   192     {
   166     {
   193       if(mapname!="Default")
   167       if(mapname!="Default")
   194 	{
   168 	{
   195 	  double number=(*actual_map)[node];
   169 	  double number=(*actual_map)[node];
   196 	  int length=1;
   170 
   197 	  //if number is smaller than one, length would be negative, or invalid
   171 	  std::ostringstream ostr;
   198 	  if(number>=1)
   172 	  ostr << number;
   199 	    {
   173 	      
   200 	      length=(int)(floor(log(number)/log(10)))+1;
   174 	  nodetextmap[node]->property_text().set_value(ostr.str());
   201 	    }
       
   202 	  int maxpos=(int)(pow(10,length-1));
       
   203 	  int strl=length+1+RANGE;
       
   204 	  char * str=new char[strl];
       
   205 	  str[length]='.';
       
   206 	  str[strl]='\0';
       
   207       
       
   208 	  for(int j=0;j<strl;j++)
       
   209 	    {
       
   210 	      if(j!=length)
       
   211 		{
       
   212 		  if((number-(int)number)>ALMOST_ONE)
       
   213 		    {
       
   214 		      number=round(number);
       
   215 		    }
       
   216 		  int digit=(int)(number/maxpos);
       
   217 		  str[j]=(digit+'0');
       
   218 		  number-=digit*maxpos;
       
   219 		  number*=10;
       
   220 		}
       
   221 	    }
       
   222       
       
   223 	  nodetextmap[node]->property_text().set_value(str);
       
   224 	}
   175 	}
   225       else
   176       else
   226 	{
   177 	{
   227 	  nodetextmap[node]->property_text().set_value("");
   178 	  nodetextmap[node]->property_text().set_value("");
   228 	}
   179 	}