COIN-OR::LEMON - Graph Library

Changeset 28:fa28f1071bd6 in glemon-0.x for graph_displayer_canvas-edge.cc


Ignore:
Timestamp:
06/24/05 20:16:12 (19 years ago)
Author:
Hegyi Péter
Branch:
gui
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk/gui@1996
Message:

NodeMap? values are now visualizable. Todo: default map-values

File:
1 edited

Legend:

Unmodified
Added
Removed
  • graph_displayer_canvas-edge.cc

    r27 r28  
    44
    55
    6 int GraphDisplayerCanvas::changeLineWidth (std::string mapname)
     6int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Graph::Edge edge)
    77{
    8   for (EdgeIt i(g); i!=INVALID; ++i)
     8  if(edge==INVALID)
    99    {
    10       int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i];
     10      for (EdgeIt i(g); i!=INVALID; ++i)
     11        {
     12          int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i];
     13          if(w>=0)
     14            {
     15              edgesmap[i]->property_width_pixels().set_value(w);
     16            }
     17        }
     18    }
     19  else
     20    {
     21      int w=(int)(*(mapstorage.edgemap_storage)[mapname])[edge];
    1122      if(w>=0)
    1223        {
    13           edgesmap[i]->property_width_pixels().set_value(w);
     24          edgesmap[edge]->property_width_pixels().set_value(w);
    1425        }
    1526    }
     
    1728};
    1829
    19 int GraphDisplayerCanvas::changeColor (std::string mapname)
     30int GraphDisplayerCanvas::changeEdgeColor (std::string mapname, Graph::Edge edge)
    2031
    2132
     
    2334  //the minimum of the nodemap to the range of
    2435  //green in RGB
     36  if(edge==INVALID)
     37    {
    2538
    26   for (EdgeIt i(g); i!=INVALID; ++i)
    27   {
    28     double w=(*(mapstorage.edgemap_storage)[mapname])[i];
    29     double max=mapstorage.maxOfEdgeMap(mapname);
    30     double min=mapstorage.minOfEdgeMap(mapname);
     39      for (EdgeIt i(g); i!=INVALID; ++i)
     40        {
     41          double w=(*(mapstorage.edgemap_storage)[mapname])[i];
     42          double max=mapstorage.maxOfEdgeMap(mapname);
     43          double min=mapstorage.minOfEdgeMap(mapname);
    3144     
    32     //std::cout<<w<<" "<<max<<" "<<min<<" "<<100*(w-min)/(max-min)<<std::endl;
    33     Gdk::Color color;
    34     if(max!=min)
     45          //std::cout<<w<<" "<<max<<" "<<min<<" "<<100*(w-min)/(max-min)<<std::endl;
     46          Gdk::Color color;
     47          if(max!=min)
     48            {
     49              color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
     50            }
     51          else
     52            {
     53              color.set_rgb_p (0, 100, 0);
     54            }
     55
     56          edgesmap[i]->property_fill_color_gdk().set_value(color);
     57        }
     58    }
     59  else
    3560    {
    36       color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
     61      double w=(*(mapstorage.edgemap_storage)[mapname])[edge];
     62      double max=mapstorage.maxOfEdgeMap(mapname);
     63      double min=mapstorage.minOfEdgeMap(mapname);
     64     
     65      //std::cout<<w<<" "<<max<<" "<<min<<" "<<100*(w-min)/(max-min)<<std::endl;
     66      Gdk::Color color;
     67      if(max!=min)
     68        {
     69          color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
     70        }
     71      else
     72        {
     73          color.set_rgb_p (0, 100, 0);
     74        }
     75
     76      edgesmap[edge]->property_fill_color_gdk().set_value(color);
    3777    }
    38     else
    39     {
    40       color.set_rgb_p (0, 100, 0);
    41     }
    42 
    43     edgesmap[i]->property_fill_color_gdk().set_value(color);
    44   }
    4578  return 0;
    4679};
    4780
    48 int GraphDisplayerCanvas::changeText (std::string mapname)
     81int GraphDisplayerCanvas::changeEdgeText (std::string mapname, Graph::Edge edge)
    4982{
    5083
     
    5588  //\todo isn't it a bit woodcutter?
    5689
    57   for (EdgeIt i(g); i!=INVALID; ++i)
     90  if(edge==INVALID)
    5891    {
    59       if(mapname!="Text")
     92      for (EdgeIt i(g); i!=INVALID; ++i)
    6093        {
    61           double number=(*(mapstorage.edgemap_storage)[mapname])[i];
     94          if(mapname!=edge_property_strings[E_TEXT])
     95            {
     96              double number=(*(mapstorage.edgemap_storage)[mapname])[i];
     97              int length=1;
     98              //if number is smaller than one, length would be negative, or invalid
     99              if(number>=1)
     100                {
     101                  length=(int)(floor(log(number)/log(10)))+1;
     102                }
     103              int maxpos=(int)(pow(10,length-1));
     104              int strl=length+1+RANGE;
     105              char * str=new char[strl];
     106              str[length]='.';
     107              str[strl]='\0';
     108     
     109              for(int j=0;j<strl;j++)
     110                {
     111                  if(j!=length)
     112                    {
     113                      int digit=(int)(number/maxpos);
     114                      str[j]=(digit+'0');
     115                      number-=digit*maxpos;
     116                      number*=10;
     117                    }
     118                }
     119     
     120              edgetextmap[i]->property_text().set_value(str);
     121            }
     122          else
     123            {
     124              edgetextmap[i]->property_text().set_value("");
     125            }
     126        }
     127
     128    }
     129  else
     130    {
     131      if(mapname!=edge_property_strings[E_TEXT])
     132        {
     133          double number=(*(mapstorage.edgemap_storage)[mapname])[edge];
    62134          int length=1;
    63135          //if number is smaller than one, length would be negative, or invalid
     
    83155            }
    84156     
    85           edgetextmap[i]->property_text().set_value(str);
     157          edgetextmap[edge]->property_text().set_value(str);
    86158        }
    87159      else
    88160        {
    89           edgetextmap[i]->property_text().set_value("");
     161          edgetextmap[edge]->property_text().set_value("");
    90162        }
     163         
    91164    }
     165
    92166  return 0;
     167
    93168};
Note: See TracChangeset for help on using the changeset viewer.