[Lemon-commits] [lemon_svn] hegyi: r3065 - glemon/trunk

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 21:52:09 CET 2006


Author: hegyi
Date: Mon Nov  6 16:40:44 2006
New Revision: 3065

Added:
   glemon/trunk/color.lgf
Modified:
   glemon/trunk/graph_displayer_canvas-edge.cc
   glemon/trunk/graph_displayer_canvas-event.cc
   glemon/trunk/graph_displayer_canvas-node.cc
   glemon/trunk/graph_displayer_canvas.h

Log:
Color handling of maps is a bit better now.

Added: glemon/trunk/color.lgf
==============================================================================
--- (empty file)
+++ glemon/trunk/color.lgf	Mon Nov  6 16:40:44 2006
@@ -0,0 +1,368 @@
+ at nodeset 
+coordinates_x	coordinates_y	label	
+-357	-128	1	
+-298	-135	2	
+-229	-140	3	
+-160	-146	4	
+-84	-149	5	
+-3	-155	6	
+76	-155	7	
+155	-151	8	
+229	-138	9	
+298	-113	10	
+362	-88	11	
+433	-53	12	
+447	3	13	
+416	59	14	
+338	69	15	
+281	31	16	
+217	6	17	
+143	-1	18	
+69	-1	19	
+-7	3	20	
+-73	3	21	
+-137	-3	22	
+-193	-26	23	
+-255	-30	24	
+-303	-2	25	
+-348	37	26	
+-355	92	27	
+-335	145	28	
+-299	181	29	
+-229	186	30	
+-164	154	31	
+-104	126	32	
+-46	134	33	
+0	169	34	
+47	197	35	
+100	195	36	
+141	161	37	
+195	134	38	
+256	146	39	
+314	182	40	
+370	207	41	
+431	244	42	
+ at edgeset 
+		label	
+42	41	1	
+41	40	2	
+40	39	3	
+39	38	4	
+38	37	5	
+37	36	6	
+36	35	7	
+35	34	8	
+34	33	9	
+33	32	10	
+32	31	11	
+31	30	12	
+30	29	13	
+29	28	14	
+28	27	15	
+27	26	16	
+26	25	17	
+25	24	18	
+24	23	19	
+23	22	20	
+22	21	21	
+21	20	22	
+20	19	23	
+19	18	24	
+18	17	25	
+17	16	26	
+16	15	27	
+15	14	28	
+14	13	29	
+13	12	30	
+12	11	31	
+11	10	32	
+10	9	33	
+9	8	34	
+8	7	35	
+7	6	36	
+6	5	37	
+5	4	38	
+4	3	39	
+3	2	40	
+2	1	41	
+ at gui
+<arrow_pos>
+ <item>
+  <first>1</first>
+  <second>
+   <x>400.5</x><y>225.5</y>
+  </second>
+ </item>
+ <item>
+  <first>2</first>
+  <second>
+   <x>342</x><y>194.5</y>
+  </second>
+ </item>
+ <item>
+  <first>3</first>
+  <second>
+   <x>285</x><y>164</y>
+  </second>
+ </item>
+ <item>
+  <first>4</first>
+  <second>
+   <x>225.5</x><y>140</y>
+  </second>
+ </item>
+ <item>
+  <first>5</first>
+  <second>
+   <x>168</x><y>147.5</y>
+  </second>
+ </item>
+ <item>
+  <first>6</first>
+  <second>
+   <x>120.5</x><y>178</y>
+  </second>
+ </item>
+ <item>
+  <first>7</first>
+  <second>
+   <x>73.5</x><y>196</y>
+  </second>
+ </item>
+ <item>
+  <first>8</first>
+  <second>
+   <x>23.5</x><y>183</y>
+  </second>
+ </item>
+ <item>
+  <first>9</first>
+  <second>
+   <x>-23</x><y>151.5</y>
+  </second>
+ </item>
+ <item>
+  <first>10</first>
+  <second>
+   <x>-75</x><y>130</y>
+  </second>
+ </item>
+ <item>
+  <first>11</first>
+  <second>
+   <x>-134</x><y>140</y>
+  </second>
+ </item>
+ <item>
+  <first>12</first>
+  <second>
+   <x>-196.5</x><y>170</y>
+  </second>
+ </item>
+ <item>
+  <first>13</first>
+  <second>
+   <x>-264</x><y>183.5</y>
+  </second>
+ </item>
+ <item>
+  <first>14</first>
+  <second>
+   <x>-317</x><y>163</y>
+  </second>
+ </item>
+ <item>
+  <first>15</first>
+  <second>
+   <x>-345</x><y>118.5</y>
+  </second>
+ </item>
+ <item>
+  <first>16</first>
+  <second>
+   <x>-351.5</x><y>64.5</y>
+  </second>
+ </item>
+ <item>
+  <first>17</first>
+  <second>
+   <x>-325.5</x><y>17.5</y>
+  </second>
+ </item>
+ <item>
+  <first>18</first>
+  <second>
+   <x>-279</x><y>-16</y>
+  </second>
+ </item>
+ <item>
+  <first>19</first>
+  <second>
+   <x>-224</x><y>-28</y>
+  </second>
+ </item>
+ <item>
+  <first>20</first>
+  <second>
+   <x>-165</x><y>-14.5</y>
+  </second>
+ </item>
+ <item>
+  <first>21</first>
+  <second>
+   <x>-105</x><y>0</y>
+  </second>
+ </item>
+ <item>
+  <first>22</first>
+  <second>
+   <x>-40</x><y>3</y>
+  </second>
+ </item>
+ <item>
+  <first>23</first>
+  <second>
+   <x>31</x><y>1</y>
+  </second>
+ </item>
+ <item>
+  <first>24</first>
+  <second>
+   <x>106</x><y>-1</y>
+  </second>
+ </item>
+ <item>
+  <first>25</first>
+  <second>
+   <x>180</x><y>2.5</y>
+  </second>
+ </item>
+ <item>
+  <first>26</first>
+  <second>
+   <x>249</x><y>18.5</y>
+  </second>
+ </item>
+ <item>
+  <first>27</first>
+  <second>
+   <x>309.5</x><y>50</y>
+  </second>
+ </item>
+ <item>
+  <first>28</first>
+  <second>
+   <x>377</x><y>64</y>
+  </second>
+ </item>
+ <item>
+  <first>29</first>
+  <second>
+   <x>431.5</x><y>31</y>
+  </second>
+ </item>
+ <item>
+  <first>30</first>
+  <second>
+   <x>440</x><y>-25</y>
+  </second>
+ </item>
+ <item>
+  <first>31</first>
+  <second>
+   <x>397.5</x><y>-70.5</y>
+  </second>
+ </item>
+ <item>
+  <first>32</first>
+  <second>
+   <x>330</x><y>-100.5</y>
+  </second>
+ </item>
+ <item>
+  <first>33</first>
+  <second>
+   <x>263.5</x><y>-125.5</y>
+  </second>
+ </item>
+ <item>
+  <first>34</first>
+  <second>
+   <x>192</x><y>-144.5</y>
+  </second>
+ </item>
+ <item>
+  <first>35</first>
+  <second>
+   <x>115.5</x><y>-153</y>
+  </second>
+ </item>
+ <item>
+  <first>36</first>
+  <second>
+   <x>36.5</x><y>-155</y>
+  </second>
+ </item>
+ <item>
+  <first>37</first>
+  <second>
+   <x>-43.5</x><y>-152</y>
+  </second>
+ </item>
+ <item>
+  <first>38</first>
+  <second>
+   <x>-122</x><y>-147.5</y>
+  </second>
+ </item>
+ <item>
+  <first>39</first>
+  <second>
+   <x>-194.5</x><y>-143</y>
+  </second>
+ </item>
+ <item>
+  <first>40</first>
+  <second>
+   <x>-263.5</x><y>-137.5</y>
+  </second>
+ </item>
+ <item>
+  <first>41</first>
+  <second>
+   <x>-327.5</x><y>-131.5</y>
+  </second>
+ </item>
+</arrow_pos>
+<active_nodemaps>
+ <item>
+  <first>0</first>
+  <second></second>
+ </item>
+ <item>
+  <first>1</first>
+  <second>label</second>
+ </item>
+ <item>
+  <first>2</first>
+  <second></second>
+ </item>
+</active_nodemaps>
+<active_edgemaps>
+ <item>
+  <first>0</first>
+  <second></second>
+ </item>
+ <item>
+  <first>1</first>
+  <second>label</second>
+ </item>
+ <item>
+  <first>2</first>
+  <second></second>
+ </item>
+</active_edgemaps>
+<redesign-attraction>0.05</redesign-attraction>
+<redesign-propulsation>40000</redesign-propulsation>
+<redesign-iteration>20</redesign-iteration>
+ at end

Modified: glemon/trunk/graph_displayer_canvas-edge.cc
==============================================================================
--- glemon/trunk/graph_displayer_canvas-edge.cc	(original)
+++ glemon/trunk/graph_displayer_canvas-edge.cc	Mon Nov  6 16:40:44 2006
@@ -147,11 +147,11 @@
 	  Gdk::Color color;
 	  if(max!=min)
 	    {
-	      color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
+	      color=rainbowColorCounter(min, max, w);
 	    }
 	  else
 	    {
-	      color.set_rgb_p (0, 100, 0);
+	      color.set_rgb_p (0, 1, 0);
 	    }
 	  edgesmap[i]->setFillColor(color);
 	}
@@ -164,11 +164,11 @@
 
       if(max!=min)
 	{
-	  color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
+	  color=rainbowColorCounter(min, max, w);
 	}
       else
 	{
-	  color.set_rgb_p (0, 100, 0);
+	  color.set_rgb_p (0, 1, 0);
 	}
 
       edgesmap[edge]->setFillColor(color);

Modified: glemon/trunk/graph_displayer_canvas-event.cc
==============================================================================
--- glemon/trunk/graph_displayer_canvas-event.cc	(original)
+++ glemon/trunk/graph_displayer_canvas-event.cc	Mon Nov  6 16:40:44 2006
@@ -453,12 +453,12 @@
       {
         if(active_item)
         {
-          *active_item << Gnome::Canvas::Properties::fill_color("blue");
+	  propertyUpdate(active_node,N_COLOR);
           active_item=NULL;
         }
         if(target_item)
         {
-          *target_item << Gnome::Canvas::Properties::fill_color("blue");
+	  propertyUpdate((mytab.mapstorage).graph.target(active_edge),N_COLOR);
           target_item=NULL;
         }
         active_node=INVALID;
@@ -874,3 +874,61 @@
 	}
     }
 }
+
+Gdk::Color GraphDisplayerCanvas::rainbowColorCounter(double min, double max, double w)
+{
+  Gdk::Color color;
+
+  double pos=(w-min)/(max-min);
+  int phase=0;
+
+  //rainbow transitions contain 6 phase
+  //in each phase only one color is changed
+  //first we determine the phase, in which
+  //the actual value belongs to
+  for (int i=0;i<=5;i++)
+    {
+      if(((double)i/6<pos)&&(pos<=(double(i+1)/6)))
+	{
+	  phase=i;
+	}
+    }
+  if(phase<6)
+    {
+      //within its 1/6 long phase the relativ position
+      //determines the power of the color changed in
+      //that phase
+      //we normalize that to one, to be able to give percentage
+      //value for the function
+      double rel_pos=(pos-(phase/6))*6;
+
+      switch(phase)
+	{
+	case 0:
+	  color.set_rgb_p (1, 0, 1-rel_pos);
+	  break;
+	case 1:
+	  color.set_rgb_p (1, rel_pos, 0);
+	  break;
+	case 2:
+	  color.set_rgb_p (1-rel_pos, 1, 0);
+	  break;
+	case 3:
+	  color.set_rgb_p (0, 1, rel_pos);
+	  break;
+	case 4:
+	  color.set_rgb_p (0, 1-rel_pos, 1);
+	  break;
+	case 5:
+	  color.set_rgb_p ((rel_pos/3), 0, 1);
+	  break;
+	default:
+	  std::cout << "Wrong phase: " << phase << " " << pos << std::endl;
+	}
+    }
+  else
+    {
+      std::cout << "Wrong phase: " << phase << " " << pos << std::endl;
+    }
+  return color;
+}

Modified: glemon/trunk/graph_displayer_canvas-node.cc
==============================================================================
--- glemon/trunk/graph_displayer_canvas-node.cc	(original)
+++ glemon/trunk/graph_displayer_canvas-node.cc	Mon Nov  6 16:40:44 2006
@@ -185,11 +185,11 @@
 
 	  if(max!=min)
 	    {
-	      color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
+	      color=rainbowColorCounter(min, max, w);
 	    }
 	  else
 	    {
-	      color.set_rgb_p (0, 0, 100);
+	      color.set_rgb_p (0, 0, 1);
 	    }
 
 	  nodesmap[i]->property_fill_color_gdk().set_value(color);
@@ -203,11 +203,11 @@
 
       if(max!=min)
 	{
-	  color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
+	  color=rainbowColorCounter(min, max, w);
 	}
       else
 	{
-	  color.set_rgb_p (0, 0, 100);
+	  color.set_rgb_p (0, 0, 1);
 	}
 
       nodesmap[node]->property_fill_color_gdk().set_value(color);

Modified: glemon/trunk/graph_displayer_canvas.h
==============================================================================
--- glemon/trunk/graph_displayer_canvas.h	(original)
+++ glemon/trunk/graph_displayer_canvas.h	Mon Nov  6 16:40:44 2006
@@ -145,6 +145,11 @@
   ///destructor of the class
   virtual ~GraphDisplayerCanvas();
 
+  ///Returns a color of the rainbow based on a map value and the min and max value of the given map
+
+  ///min and max is purple, between them there is a linear assign
+  Gdk::Color rainbowColorCounter(double, double, double);
+
   ///Changes the width of edge(s) according to the given map.
 
   ///\param mapname is the name of the map which contains the values to be set



More information about the Lemon-commits mailing list