gui/graph_displayer_canvas-edge.cc
changeset 1828 fd3771591a5c
parent 1819 fd82adfbe905
child 1837 8dd6160ff699
equal deleted inserted replaced
16:56020b1871b4 17:7445f78c9147
     2 #include <cmath>
     2 #include <cmath>
     3 
     3 
     4 
     4 
     5 int GraphDisplayerCanvas::resetEdgeWidth (Edge edge)
     5 int GraphDisplayerCanvas::resetEdgeWidth (Edge edge)
     6 {
     6 {
     7   Graph::EdgeMap<double> * actual_map;
       
     8   double min, max;
     7   double min, max;
     9 
     8 
    10   min=edge_property_defaults[E_WIDTH];
     9   min=edge_property_defaults[E_WIDTH];
    11   max=edge_property_defaults[E_WIDTH];
    10   max=edge_property_defaults[E_WIDTH];
    12   actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_WIDTH]);
    11   Graph::EdgeMap<double> actual_map(mapstorage.graph,edge_property_defaults[E_WIDTH]);
    13   
    12   
    14   if(edge==INVALID)
    13   if(edge==INVALID)
    15     {
    14     {
    16       for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
    15       for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
    17 	{
    16 	{
    18 	  double v=fabs((*actual_map)[i]);
    17 	  double v=fabs(actual_map[i]);
    19 	  int w;
    18 	  int w;
    20 	  if(min==max)
    19 	  if(min==max)
    21 	    {
    20 	    {
    22 	      w=(int)(edge_property_defaults[E_WIDTH]);
    21 	      w=(int)(edge_property_defaults[E_WIDTH]);
    23 	    }
    22 	    }
    28 	  edgesmap[i]->property_width_units().set_value(w);
    27 	  edgesmap[i]->property_width_units().set_value(w);
    29 	}
    28 	}
    30     }
    29     }
    31   else
    30   else
    32     {
    31     {
    33       int w=(int)(*actual_map)[edge];
    32       int w=(int)actual_map[edge];
    34       if(w>=0)
    33       if(w>=0)
    35 	{
    34 	{
    36 	  edgesmap[edge]->property_width_units().set_value(w);
    35 	  edgesmap[edge]->property_width_units().set_value(w);
    37 	}
    36 	}
    38     }
    37     }
   133 {  
   132 {  
   134 
   133 
   135   //function maps the range of the maximum and
   134   //function maps the range of the maximum and
   136   //the minimum of the nodemap to the range of
   135   //the minimum of the nodemap to the range of
   137   //green in RGB
   136   //green in RGB
   138   Graph::EdgeMap<double> * actual_map;
   137   Graph::EdgeMap<double> actual_map(mapstorage.graph,edge_property_defaults[E_COLOR]);
   139   actual_map=new Graph::EdgeMap<double>(mapstorage.graph,edge_property_defaults[E_COLOR]);
       
   140 
   138 
   141   double max, min;
   139   double max, min;
   142 
   140 
   143   max=edge_property_defaults[E_COLOR];
   141   max=edge_property_defaults[E_COLOR];
   144   min=edge_property_defaults[E_COLOR];
   142   min=edge_property_defaults[E_COLOR];
   145 
   143 
   146   if(edge==INVALID)
   144   if(edge==INVALID)
   147     {
   145     {
   148       for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
   146       for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
   149 	{
   147 	{
   150 	  double w=(*actual_map)[i];
   148 	  double w=actual_map[i];
   151 
   149 
   152 	  Gdk::Color color;
   150 	  Gdk::Color color;
   153 	  if(max!=min)
   151 	  if(max!=min)
   154 	    {
   152 	    {
   155 	      color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
   153 	      color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
   163     }
   161     }
   164   else
   162   else
   165     {
   163     {
   166       Gdk::Color color;
   164       Gdk::Color color;
   167 
   165 
   168       double w=(*actual_map)[edge];
   166       double w=actual_map[edge];
   169 
   167 
   170       if(max!=min)
   168       if(max!=min)
   171 	{
   169 	{
   172 	  color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
   170 	  color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
   173 	}
   171 	}