graph_displayer_canvas-event.cc
changeset 179 1f436ea3ef4f
parent 178 a96d2a540454
child 187 b465e2c34f23
equal deleted inserted replaced
46:2bb30cab9f28 47:6f7e9365f983
   451       //2: the edge creation is cancelled with right button
   451       //2: the edge creation is cancelled with right button
   452       if((target_item)||(e->button.button==3))
   452       if((target_item)||(e->button.button==3))
   453       {
   453       {
   454         if(active_item)
   454         if(active_item)
   455         {
   455         {
   456           *active_item << Gnome::Canvas::Properties::fill_color("blue");
   456 	  propertyUpdate(active_node,N_COLOR);
   457           active_item=NULL;
   457           active_item=NULL;
   458         }
   458         }
   459         if(target_item)
   459         if(target_item)
   460         {
   460         {
   461           *target_item << Gnome::Canvas::Properties::fill_color("blue");
   461 	  propertyUpdate((mytab.mapstorage).graph.target(active_edge),N_COLOR);
   462           target_item=NULL;
   462           target_item=NULL;
   463         }
   463         }
   464         active_node=INVALID;
   464         active_node=INVALID;
   465         active_edge=INVALID;
   465         active_edge=INVALID;
   466       }
   466       }
   872 	  edgetextmap[ei]->property_x().set_value(text_pos.x);
   872 	  edgetextmap[ei]->property_x().set_value(text_pos.x);
   873 	  edgetextmap[ei]->property_y().set_value(text_pos.y);
   873 	  edgetextmap[ei]->property_y().set_value(text_pos.y);
   874 	}
   874 	}
   875     }
   875     }
   876 }
   876 }
       
   877 
       
   878 Gdk::Color GraphDisplayerCanvas::rainbowColorCounter(double min, double max, double w)
       
   879 {
       
   880   Gdk::Color color;
       
   881 
       
   882   double pos=(w-min)/(max-min);
       
   883   int phase=0;
       
   884 
       
   885   //rainbow transitions contain 6 phase
       
   886   //in each phase only one color is changed
       
   887   //first we determine the phase, in which
       
   888   //the actual value belongs to
       
   889   for (int i=0;i<=5;i++)
       
   890     {
       
   891       if(((double)i/6<pos)&&(pos<=(double(i+1)/6)))
       
   892 	{
       
   893 	  phase=i;
       
   894 	}
       
   895     }
       
   896   if(phase<6)
       
   897     {
       
   898       //within its 1/6 long phase the relativ position
       
   899       //determines the power of the color changed in
       
   900       //that phase
       
   901       //we normalize that to one, to be able to give percentage
       
   902       //value for the function
       
   903       double rel_pos=(pos-(phase/6))*6;
       
   904 
       
   905       switch(phase)
       
   906 	{
       
   907 	case 0:
       
   908 	  color.set_rgb_p (1, 0, 1-rel_pos);
       
   909 	  break;
       
   910 	case 1:
       
   911 	  color.set_rgb_p (1, rel_pos, 0);
       
   912 	  break;
       
   913 	case 2:
       
   914 	  color.set_rgb_p (1-rel_pos, 1, 0);
       
   915 	  break;
       
   916 	case 3:
       
   917 	  color.set_rgb_p (0, 1, rel_pos);
       
   918 	  break;
       
   919 	case 4:
       
   920 	  color.set_rgb_p (0, 1-rel_pos, 1);
       
   921 	  break;
       
   922 	case 5:
       
   923 	  color.set_rgb_p ((rel_pos/3), 0, 1);
       
   924 	  break;
       
   925 	default:
       
   926 	  std::cout << "Wrong phase: " << phase << " " << pos << std::endl;
       
   927 	}
       
   928     }
       
   929   else
       
   930     {
       
   931       std::cout << "Wrong phase: " << phase << " " << pos << std::endl;
       
   932     }
       
   933   return color;
       
   934 }