COIN-OR::LEMON - Graph Library

Changeset 179:1f436ea3ef4f in glemon-0.x


Ignore:
Timestamp:
11/06/06 16:40:44 (17 years ago)
Author:
Hegyi Péter
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/glemon/trunk@3065
Message:

Color handling of maps is a bit better now.

Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • graph_displayer_canvas-edge.cc

    r178 r179  
    148148          if(max!=min)
    149149            {
    150               color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
    151             }
    152           else
    153             {
    154               color.set_rgb_p (0, 100, 0);
     150              color=rainbowColorCounter(min, max, w);
     151            }
     152          else
     153            {
     154              color.set_rgb_p (0, 1, 0);
    155155            }
    156156          edgesmap[i]->setFillColor(color);
     
    165165      if(max!=min)
    166166        {
    167           color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
     167          color=rainbowColorCounter(min, max, w);
    168168        }
    169169      else
    170170        {
    171           color.set_rgb_p (0, 100, 0);
     171          color.set_rgb_p (0, 1, 0);
    172172        }
    173173
  • graph_displayer_canvas-event.cc

    r178 r179  
    454454        if(active_item)
    455455        {
    456           *active_item << Gnome::Canvas::Properties::fill_color("blue");
     456          propertyUpdate(active_node,N_COLOR);
    457457          active_item=NULL;
    458458        }
    459459        if(target_item)
    460460        {
    461           *target_item << Gnome::Canvas::Properties::fill_color("blue");
     461          propertyUpdate((mytab.mapstorage).graph.target(active_edge),N_COLOR);
    462462          target_item=NULL;
    463463        }
     
    875875    }
    876876}
     877
     878Gdk::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}
  • graph_displayer_canvas-node.cc

    r174 r179  
    186186          if(max!=min)
    187187            {
    188               color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
     188              color=rainbowColorCounter(min, max, w);
    189189            }
    190190          else
    191191            {
    192               color.set_rgb_p (0, 0, 100);
     192              color.set_rgb_p (0, 0, 1);
    193193            }
    194194
     
    204204      if(max!=min)
    205205        {
    206           color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
     206          color=rainbowColorCounter(min, max, w);
    207207        }
    208208      else
    209209        {
    210           color.set_rgb_p (0, 0, 100);
     210          color.set_rgb_p (0, 0, 1);
    211211        }
    212212
  • graph_displayer_canvas.h

    r177 r179  
    146146  virtual ~GraphDisplayerCanvas();
    147147
     148  ///Returns a color of the rainbow based on a map value and the min and max value of the given map
     149
     150  ///min and max is purple, between them there is a linear assign
     151  Gdk::Color rainbowColorCounter(double, double, double);
     152
    148153  ///Changes the width of edge(s) according to the given map.
    149154
Note: See TracChangeset for help on using the changeset viewer.