COIN-OR::LEMON - Graph Library

Changeset 26:b0c76a4d5801 in glemon-0.x


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

A bug, explored by Alpar is corrected, but with value-checking, and not with correct values. (There is some problem with map values of new items! Maybe refreshemnt is the responsible thing?)

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • graph_displayer_canvas.cc

    r25 r26  
    9696{
    9797  for (EdgeIt i(g); i!=INVALID; ++i)
    98   {
    99     int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i];
    100     edgesmap[i]->property_width_pixels().set_value(w);
    101   }
     98    {
     99      int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i];
     100      if(w>=0)
     101        {
     102          edgesmap[i]->property_width_pixels().set_value(w);
     103        }
     104    }
    102105  return 0;
    103106};
     
    142145
    143146  for (EdgeIt i(g); i!=INVALID; ++i)
    144   {
    145     if(mapname!="Text")
    146     {
    147       double number=(*(mapstorage.edgemap_storage)[mapname])[i];
    148       int length=(int)(floor(log(number)/log(10)))+1;
    149       int maxpos=(int)(pow(10,length-1));
    150       int strl=length+1+RANGE;
    151       char * str=new char[strl];
    152       str[length]='.';
    153       str[strl]='\0';
     147    {
     148      if(mapname!="Text")
     149        {
     150          double number=(*(mapstorage.edgemap_storage)[mapname])[i];
     151          int length=1;
     152          //if number is smaller than one, length would be negative, or invalid
     153          if(number>=1)
     154            {
     155              length=(int)(floor(log(number)/log(10)))+1;
     156            }
     157          int maxpos=(int)(pow(10,length-1));
     158          int strl=length+1+RANGE;
     159          char * str=new char[strl];
     160          str[length]='.';
     161          str[strl]='\0';
    154162     
    155       for(int j=0;j<strl;j++)
    156       {
    157         if(j!=length)
    158         {
    159           int digit=(int)(number/maxpos);
    160           str[j]=(digit+'0');
    161           number-=digit*maxpos;
    162           number*=10;
    163         }
    164       }
     163          for(int j=0;j<strl;j++)
     164            {
     165              if(j!=length)
     166                {
     167                  int digit=(int)(number/maxpos);
     168                  str[j]=(digit+'0');
     169                  number-=digit*maxpos;
     170                  number*=10;
     171                }
     172            }
    165173     
    166       edgetextmap[i]->property_text().set_value(str);
    167     }
    168     else
    169     {
    170       edgetextmap[i]->property_text().set_value("");
    171     }
    172   }
     174          edgetextmap[i]->property_text().set_value(str);
     175        }
     176      else
     177        {
     178          edgetextmap[i]->property_text().set_value("");
     179        }
     180    }
    173181  return 0;
    174182};
     
    475483
    476484      active_node=NodeIt(g,g.addNode());
     485
     486      //initiating values corresponding to new node in maps
     487     
    477488
    478489      window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
     
    517528    {
    518529    case GDK_BUTTON_PRESS:
    519       //in edge creatino right button has special meaning
     530      //in edge creation right button has special meaning
    520531      if(e->button.button!=3)
    521532        {
     
    570581                  //creating new edge
    571582                  active_edge=EdgeIt(g,g.addEdge(active_node, target_node));
     583
     584                  //initiating values corresponding to new edge in maps
     585                  mapstorage.init_maps_for_edge(active_edge);
    572586         
    573587                  //calculating coordinates of new edge
  • mapstorage.cc

    r6 r26  
    8787}
    8888
     89void MapStorage::init_maps_for_edge(Graph::Edge e)
     90{
     91  e=e;
     92// beragad, aztan csovez
     93//   std::map< std::string,Graph::EdgeMap<double> * >::iterator ems_it;
     94//   for(ems_it=edgemap_storage.begin();ems_it!=edgemap_storage.end();ems_it++)
     95//     {
     96//       std::cout << "szevasz\n";
     97//       (*((*ems_it).second))[e]=0;
     98//     }
     99//   std::cout << std::endl;
     100
     101// g_closure_invoke...
     102//   for(int i=0;i<PROPERTY_NUM;i++)
     103//     {
     104//       (default_edgemaps[i])[e]=property_defaults[i];
     105//     }
     106}
  • mapstorage.h

    r6 r26  
    8181  ///To be able to iterate through each maps this function returns an iterator pointing to the first edgemap in the storage.
    8282  std::map< std::string,Graph::EdgeMap<double> * >::iterator beginOfEdgeMaps(){return edgemap_storage.begin();};
     83
     84  ///This function sets a default base value for the newly created node
     85  void init_maps_for_node(NodeIt);
     86
     87  ///This function sets a default base value for the newly created node
     88  void init_maps_for_edge(Graph::Edge);
    8389};
    8490
Note: See TracChangeset for help on using the changeset viewer.