graph_displayer_canvas.cc
branchgui
changeset 26 b0c76a4d5801
parent 25 c45a34eaa118
child 27 e2c86ae158cf
     1.1 --- a/graph_displayer_canvas.cc	Fri Jun 17 17:08:45 2005 +0000
     1.2 +++ b/graph_displayer_canvas.cc	Thu Jun 23 17:56:24 2005 +0000
     1.3 @@ -95,10 +95,13 @@
     1.4  int GraphDisplayerCanvas::changeLineWidth (std::string mapname)
     1.5  {
     1.6    for (EdgeIt i(g); i!=INVALID; ++i)
     1.7 -  {
     1.8 -    int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i];
     1.9 -    edgesmap[i]->property_width_pixels().set_value(w);
    1.10 -  }
    1.11 +    {
    1.12 +      int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i];
    1.13 +      if(w>=0)
    1.14 +	{
    1.15 +	  edgesmap[i]->property_width_pixels().set_value(w);
    1.16 +	}
    1.17 +    }
    1.18    return 0;
    1.19  };
    1.20  
    1.21 @@ -141,35 +144,40 @@
    1.22    //\todo isn't it a bit woodcutter?
    1.23  
    1.24    for (EdgeIt i(g); i!=INVALID; ++i)
    1.25 -  {
    1.26 -    if(mapname!="Text")
    1.27      {
    1.28 -      double number=(*(mapstorage.edgemap_storage)[mapname])[i];
    1.29 -      int length=(int)(floor(log(number)/log(10)))+1;
    1.30 -      int maxpos=(int)(pow(10,length-1));
    1.31 -      int strl=length+1+RANGE;
    1.32 -      char * str=new char[strl];
    1.33 -      str[length]='.';
    1.34 -      str[strl]='\0';
    1.35 +      if(mapname!="Text")
    1.36 +	{
    1.37 +	  double number=(*(mapstorage.edgemap_storage)[mapname])[i];
    1.38 +	  int length=1;
    1.39 +	  //if number is smaller than one, length would be negative, or invalid
    1.40 +	  if(number>=1)
    1.41 +	    {
    1.42 +	      length=(int)(floor(log(number)/log(10)))+1;
    1.43 +	    }
    1.44 +	  int maxpos=(int)(pow(10,length-1));
    1.45 +	  int strl=length+1+RANGE;
    1.46 +	  char * str=new char[strl];
    1.47 +	  str[length]='.';
    1.48 +	  str[strl]='\0';
    1.49        
    1.50 -      for(int j=0;j<strl;j++)
    1.51 -      {
    1.52 -	if(j!=length)
    1.53 -        {
    1.54 -	  int digit=(int)(number/maxpos);
    1.55 -	  str[j]=(digit+'0');
    1.56 -	  number-=digit*maxpos;
    1.57 -	  number*=10;
    1.58 -        }
    1.59 -      }
    1.60 +	  for(int j=0;j<strl;j++)
    1.61 +	    {
    1.62 +	      if(j!=length)
    1.63 +		{
    1.64 +		  int digit=(int)(number/maxpos);
    1.65 +		  str[j]=(digit+'0');
    1.66 +		  number-=digit*maxpos;
    1.67 +		  number*=10;
    1.68 +		}
    1.69 +	    }
    1.70        
    1.71 -      edgetextmap[i]->property_text().set_value(str);
    1.72 +	  edgetextmap[i]->property_text().set_value(str);
    1.73 +	}
    1.74 +      else
    1.75 +	{
    1.76 +	  edgetextmap[i]->property_text().set_value("");
    1.77 +	}
    1.78      }
    1.79 -    else
    1.80 -    {
    1.81 -      edgetextmap[i]->property_text().set_value("");
    1.82 -    }
    1.83 -  }
    1.84    return 0;
    1.85  };
    1.86  
    1.87 @@ -475,6 +483,9 @@
    1.88  
    1.89        active_node=NodeIt(g,g.addNode());
    1.90  
    1.91 +      //initiating values corresponding to new node in maps
    1.92 +      
    1.93 +
    1.94        window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
    1.95  
    1.96        nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph, clicked_x-20, clicked_y-20, clicked_x+20, clicked_y+20);
    1.97 @@ -516,7 +527,7 @@
    1.98    switch(e->type)
    1.99      {
   1.100      case GDK_BUTTON_PRESS:
   1.101 -      //in edge creatino right button has special meaning
   1.102 +      //in edge creation right button has special meaning
   1.103        if(e->button.button!=3)
   1.104  	{
   1.105  	  //there is not yet selected node
   1.106 @@ -569,6 +580,9 @@
   1.107  
   1.108  		  //creating new edge
   1.109  		  active_edge=EdgeIt(g,g.addEdge(active_node, target_node));
   1.110 +
   1.111 +		  //initiating values corresponding to new edge in maps
   1.112 +		  mapstorage.init_maps_for_edge(active_edge);
   1.113  	  
   1.114  		  //calculating coordinates of new edge
   1.115  		  Gnome::Canvas::Points coos;