gui/graph_displayer_canvas-edge.cc
changeset 1596 44897b1ba4e2
parent 1595 3bde58e2d5ca
child 1598 739df601808d
equal deleted inserted replaced
6:85d01fb45f4e 7:0b899270b652
   117 	{
   117 	{
   118 	  if(mapname!="Default")
   118 	  if(mapname!="Default")
   119 	    {
   119 	    {
   120 	      edgemap_to_edit=mapname;
   120 	      edgemap_to_edit=mapname;
   121 	      double number=(*(mapstorage.edgemap_storage)[mapname])[i];
   121 	      double number=(*(mapstorage.edgemap_storage)[mapname])[i];
   122 // 	      int length=1;
       
   123 // 	      //if number is smaller than one, length would be negative, or invalid
       
   124 // 	      if(number>=1)
       
   125 // 		{
       
   126 // 		  length=(int)(floor(log(number)/log(10)))+1;
       
   127 // 		}
       
   128 // 	      int maxpos=(int)(pow(10,length-1));
       
   129 // 	      int strl=length+1+RANGE;
       
   130 // 	      char * str=new char[strl];
       
   131 // 	      str[length]='.';
       
   132 // 	      str[strl]='\0';
       
   133       
       
   134 // 	      for(int j=0;j<strl;j++)
       
   135 // 		{
       
   136 // 		  if(j!=length)
       
   137 // 		    {
       
   138 // 		      if((number-(int)number)>ALMOST_ONE)
       
   139 // 			{
       
   140 // 			  number=round(number);
       
   141 // 			}
       
   142 // 		      int digit=(int)(number/maxpos);
       
   143 // 		      str[j]=(digit+'0');
       
   144 // 		      number-=digit*maxpos;
       
   145 // 		      number*=10;
       
   146 // 		    }
       
   147 // 		}
       
   148 //       	      edgetextmap[i]->property_text().set_value(str);
       
   149 
   122 
   150 	      std::ostringstream ostr;
   123 	      std::ostringstream ostr;
   151 	      ostr << number;
   124 	      ostr << number;
   152 
   125 	      
   153       	      edgetextmap[i]->property_text().set_value(ostr.str());
   126       	      edgetextmap[i]->property_text().set_value(ostr.str());
   154 	    }
   127 	    }
   155 	  else
   128 	  else
   156 	    {
   129 	    {
   157 	      edgemap_to_edit="";
   130 	      edgemap_to_edit="";
   163   else
   136   else
   164     {
   137     {
   165       if(mapname!="Default")
   138       if(mapname!="Default")
   166 	{
   139 	{
   167 	  double number=(*(mapstorage.edgemap_storage)[mapname])[edge];
   140 	  double number=(*(mapstorage.edgemap_storage)[mapname])[edge];
   168 	  int length=1;
   141 
   169 	  //if number is smaller than one, length would be negative, or invalid
   142 	  std::ostringstream ostr;
   170 	  if(number>=1)
   143 	  ostr << number;
   171 	    {
   144 	  
   172 	      length=(int)(floor(log(number)/log(10)))+1;
   145 	  edgetextmap[edge]->property_text().set_value(ostr.str());
   173 	    }
       
   174 	  int maxpos=(int)(pow(10,length-1));
       
   175 	  int strl=length+1+RANGE;
       
   176 	  char * str=new char[strl];
       
   177 	  str[length]='.';
       
   178 	  str[strl]='\0';
       
   179       
       
   180 	  for(int j=0;j<strl;j++)
       
   181 	    {
       
   182 	      if(j!=length)
       
   183 		{
       
   184 		  if((number-(int)number)>ALMOST_ONE)
       
   185 		    {
       
   186 		      number=round(number);
       
   187 		    }
       
   188 		  int digit=(int)(number/maxpos);
       
   189 		  str[j]=(digit+'0');
       
   190 		  number-=digit*maxpos;
       
   191 		  number*=10;
       
   192 		}
       
   193 	    }
       
   194       
       
   195 	  edgetextmap[edge]->property_text().set_value(str);
       
   196 	}
   146 	}
   197       else
   147       else
   198 	{
   148 	{
   199 	  edgetextmap[edge]->property_text().set_value("");
   149 	  edgetextmap[edge]->property_text().set_value("");
   200 	}
   150 	}