COIN-OR::LEMON - Graph Library

Changeset 201:879e47e5b731 in glemon-0.x for graph_displayer_canvas-node.cc


Ignore:
Timestamp:
01/02/08 22:03:09 (16 years ago)
Author:
Akos Ladanyi
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/glemon/trunk@3431
Message:

Merge branches/akos to trunk.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • graph_displayer_canvas-node.cc

    r194 r201  
    2626int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Node node)
    2727{
    28   Graph::NodeMap<double> * actual_map;
     28  MapStorage& ms = *mytab.mapstorage;
     29
    2930  double min, max;
    30   min=(mytab.mapstorage)->minOfNodeMap(mapname);
    31   max=(mytab.mapstorage)->maxOfNodeMap(mapname);
    32   actual_map=((mytab.mapstorage)->nodemap_storage)[mapname];
    33 
    34   if(node==INVALID)
    35     {
    36       for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
    37         {
    38           double v=fabs((*actual_map)[i]);
     31
     32  {
     33    NodeIt n(ms.graph);
     34    min = max = ms.get(mapname, n);
     35    for (; n != INVALID; ++n)
     36    {
     37      if (static_cast<double>(ms.get(mapname, n)) > max)
     38        max = ms.get(mapname, n);
     39      if (static_cast<double>(ms.get(mapname, n)) < min)
     40        min = ms.get(mapname, n);
     41    }
     42  }
     43
     44  if(node==INVALID)
     45    {
     46      for (NodeIt i(ms.graph); i!=INVALID; ++i)
     47        {
     48          double v=fabs(ms.get(mapname,i));
    3949          int w;
    4050          if(autoscale)
     
    103113int GraphDisplayerCanvas::resetNodeRadius (Node node)
    104114{
     115  MapStorage& ms = *mytab.mapstorage;
     116
    105117  double min, max;
    106118  min=node_property_defaults[N_RADIUS];
    107119  max=node_property_defaults[N_RADIUS];
    108   Graph::NodeMap<double> actual_map((mytab.mapstorage)->graph,node_property_defaults[N_RADIUS]);
     120  Graph::NodeMap<double> actual_map(ms.graph,node_property_defaults[N_RADIUS]);
    109121 
    110122  if(node==INVALID)
    111123    {
    112       for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
     124      for (NodeIt i(ms.graph); i!=INVALID; ++i)
    113125        {
    114126          double v=fabs(actual_map[i]);
     
    164176int GraphDisplayerCanvas::changeNodeColor (std::string mapname, Node node)
    165177
     178  MapStorage& ms = *mytab.mapstorage;
    166179
    167180  //function maps the range of the maximum and
     
    169182  //green in RGB
    170183
    171   Graph::NodeMap<double> * actual_map;
    172   actual_map=((mytab.mapstorage)->nodemap_storage)[mapname];
    173 
    174184  double max, min;
    175185
    176   max=(mytab.mapstorage)->maxOfNodeMap(mapname);
    177   min=(mytab.mapstorage)->minOfNodeMap(mapname);
    178 
    179   if(node==INVALID)
    180     {
    181 
    182       for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
     186  {
     187    NodeIt n(ms.graph);
     188    min = max = ms.get(mapname, n);
     189    for (; n != INVALID; ++n)
     190    {
     191      if (static_cast<double>(ms.get(mapname, n)) > max)
     192        max = ms.get(mapname, n);
     193      if (static_cast<double>(ms.get(mapname, n)) < min)
     194        min = ms.get(mapname, n);
     195    }
     196  }
     197
     198  if(node==INVALID)
     199    {
     200
     201      for (NodeIt i(ms.graph); i!=INVALID; ++i)
    183202        {
    184203          Gdk::Color color;
    185204
    186           double w=(*actual_map)[i];
     205          double w=ms.get(mapname, i);
    187206
    188207          if(max!=min)
     
    202221      Gdk::Color color;
    203222
    204       double w=(*actual_map)[node];
     223      double w=ms.get(mapname, node);
    205224
    206225      if(max!=min)
     
    220239int GraphDisplayerCanvas::resetNodeColor (Node node)
    221240
     241  MapStorage& ms = *mytab.mapstorage;
    222242
    223243  //function maps the range of the maximum and
     
    225245  //green in RGB
    226246
    227   Graph::NodeMap<double> actual_map((mytab.mapstorage)->graph,node_property_defaults[N_COLOR]);
     247  Graph::NodeMap<double> actual_map(ms.graph,node_property_defaults[N_COLOR]);
    228248
    229249  double max, min;
     
    235255    {
    236256
    237       for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
     257      for (NodeIt i(ms.graph); i!=INVALID; ++i)
    238258        {
    239259          Gdk::Color color;
     
    275295int GraphDisplayerCanvas::changeNodeText (std::string mapname, Node node)
    276296{
     297  MapStorage& ms = *mytab.mapstorage;
    277298
    278299  //the number in the map will be written on the node
     
    281302  //that is the deleter map
    282303
    283   Graph::NodeMap<double> * actual_map=NULL;
    284   actual_map=((mytab.mapstorage)->nodemap_storage)[mapname];
    285 
    286   if(node==INVALID)
    287     {
    288       for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
     304  if(node==INVALID)
     305    {
     306      for (NodeIt i(ms.graph); i!=INVALID; ++i)
    289307        {
    290308          nodemap_to_edit=mapname;
    291           double number=(*actual_map)[i];
    292 
    293           std::ostringstream ostr;
    294           ostr << number;
    295              
    296           nodetextmap[i]->property_text().set_value(ostr.str());
    297         }
    298     }
    299   else
    300     {
    301       double number=(*actual_map)[node];
    302 
    303       std::ostringstream ostr;
    304       ostr << number;
    305              
    306       nodetextmap[node]->property_text().set_value(ostr.str());
     309
     310          nodetextmap[i]->property_text().set_value(
     311              static_cast<std::string>(ms.get(mapname, i)));
     312        }
     313    }
     314  else
     315    {
     316      nodetextmap[node]->property_text().set_value(
     317          static_cast<std::string>(ms.get(mapname, node)));
    307318    }
    308319  return 0;
     
    311322int GraphDisplayerCanvas::resetNodeText (Node node)
    312323{
     324  MapStorage& ms = *mytab.mapstorage;
    313325
    314326  //the number in the map will be written on the node
     
    319331  if(node==INVALID)
    320332    {
    321       for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
     333      for (NodeIt i(ms.graph); i!=INVALID; ++i)
    322334        {
    323335          nodemap_to_edit="";
Note: See TracChangeset for help on using the changeset viewer.