graph_displayer_canvas-event.cc
changeset 179 1f436ea3ef4f
parent 178 a96d2a540454
child 187 b465e2c34f23
     1.1 --- a/graph_displayer_canvas-event.cc	Mon Oct 30 15:43:13 2006 +0000
     1.2 +++ b/graph_displayer_canvas-event.cc	Mon Nov 06 15:40:44 2006 +0000
     1.3 @@ -453,12 +453,12 @@
     1.4        {
     1.5          if(active_item)
     1.6          {
     1.7 -          *active_item << Gnome::Canvas::Properties::fill_color("blue");
     1.8 +	  propertyUpdate(active_node,N_COLOR);
     1.9            active_item=NULL;
    1.10          }
    1.11          if(target_item)
    1.12          {
    1.13 -          *target_item << Gnome::Canvas::Properties::fill_color("blue");
    1.14 +	  propertyUpdate((mytab.mapstorage).graph.target(active_edge),N_COLOR);
    1.15            target_item=NULL;
    1.16          }
    1.17          active_node=INVALID;
    1.18 @@ -874,3 +874,61 @@
    1.19  	}
    1.20      }
    1.21  }
    1.22 +
    1.23 +Gdk::Color GraphDisplayerCanvas::rainbowColorCounter(double min, double max, double w)
    1.24 +{
    1.25 +  Gdk::Color color;
    1.26 +
    1.27 +  double pos=(w-min)/(max-min);
    1.28 +  int phase=0;
    1.29 +
    1.30 +  //rainbow transitions contain 6 phase
    1.31 +  //in each phase only one color is changed
    1.32 +  //first we determine the phase, in which
    1.33 +  //the actual value belongs to
    1.34 +  for (int i=0;i<=5;i++)
    1.35 +    {
    1.36 +      if(((double)i/6<pos)&&(pos<=(double(i+1)/6)))
    1.37 +	{
    1.38 +	  phase=i;
    1.39 +	}
    1.40 +    }
    1.41 +  if(phase<6)
    1.42 +    {
    1.43 +      //within its 1/6 long phase the relativ position
    1.44 +      //determines the power of the color changed in
    1.45 +      //that phase
    1.46 +      //we normalize that to one, to be able to give percentage
    1.47 +      //value for the function
    1.48 +      double rel_pos=(pos-(phase/6))*6;
    1.49 +
    1.50 +      switch(phase)
    1.51 +	{
    1.52 +	case 0:
    1.53 +	  color.set_rgb_p (1, 0, 1-rel_pos);
    1.54 +	  break;
    1.55 +	case 1:
    1.56 +	  color.set_rgb_p (1, rel_pos, 0);
    1.57 +	  break;
    1.58 +	case 2:
    1.59 +	  color.set_rgb_p (1-rel_pos, 1, 0);
    1.60 +	  break;
    1.61 +	case 3:
    1.62 +	  color.set_rgb_p (0, 1, rel_pos);
    1.63 +	  break;
    1.64 +	case 4:
    1.65 +	  color.set_rgb_p (0, 1-rel_pos, 1);
    1.66 +	  break;
    1.67 +	case 5:
    1.68 +	  color.set_rgb_p ((rel_pos/3), 0, 1);
    1.69 +	  break;
    1.70 +	default:
    1.71 +	  std::cout << "Wrong phase: " << phase << " " << pos << std::endl;
    1.72 +	}
    1.73 +    }
    1.74 +  else
    1.75 +    {
    1.76 +      std::cout << "Wrong phase: " << phase << " " << pos << std::endl;
    1.77 +    }
    1.78 +  return color;
    1.79 +}