COIN-OR::LEMON - Graph Library

Changeset 1597:15b51d278bf0 in lemon-0.x


Ignore:
Timestamp:
07/27/05 13:35:13 (19 years ago)
Author:
Hegyi Péter
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2101
Message:

No maps with the same name can be added.

Location:
gui
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • gui/graph_displayer_canvas-event.cc

    r1596 r1597  
    855855}
    856856
    857 void GraphDisplayerCanvas::addNewEdgeMap(double default_value, std::string mapname)
     857int GraphDisplayerCanvas::addNewEdgeMap(double default_value, std::string mapname)
    858858{
    859859  //create the new map
    860860  Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (g,default_value);
    861   mapstorage.addEdgeMap(mapname,emptr);
     861
     862  //if addition was not successful addEdgeMap returns one.
     863  //cause can be that there is already a map named like the new one
     864  if(mapstorage.addEdgeMap(mapname,emptr))
     865    {
     866      return 1;
     867    }
     868
    862869
    863870  //add it to the list of the displayable maps
     
    866873  //display it
    867874  changeEdgeText(mapname);
    868 }
    869 
    870 void GraphDisplayerCanvas::addNewNodeMap(double default_value, std::string mapname)
     875
     876  return 0;
     877}
     878
     879int GraphDisplayerCanvas::addNewNodeMap(double default_value, std::string mapname)
    871880{
    872881  //create the new map
    873882  Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (g,default_value);
    874   mapstorage.addNodeMap(mapname,emptr);
     883
     884  //if addition was not successful addNodeMap returns one.
     885  //cause can be that there is already a map named like the new one
     886  if(mapstorage.addNodeMap(mapname,emptr))
     887    {
     888      return 1;
     889    }
    875890
    876891  //add it to the list of the displayable maps
     
    879894  //display it
    880895  changeNodeText(mapname);
    881 }
    882 
     896
     897  return 0;
     898}
     899
  • gui/graph_displayer_canvas.h

    r1592 r1597  
    111111
    112112  ///creates a new Nodemap
    113   void addNewNodeMap(double,std::string);
     113  int addNewNodeMap(double,std::string);
    114114  ///creates a new Edgemap
    115   void addNewEdgeMap(double,std::string);
     115  int addNewEdgeMap(double,std::string);
    116116
    117117private:
  • gui/mapstorage.cc

    r1525 r1597  
    77int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap<double> *nodemap)
    88{
    9   nodemap_storage[name]=nodemap;
    10   return 0;
     9  if( nodemap_storage.find(name) == nodemap_storage.end() )
     10    {
     11      nodemap_storage[name]=nodemap;
     12      return 0;
     13    }
     14  return 1;
    1115}
    1216
    1317int MapStorage::addEdgeMap(const std::string & name, Graph::EdgeMap<double> *edgemap)
    1418{
    15   edgemap_storage[name]=edgemap;
    16   return 0;
     19  if( edgemap_storage.find(name) == edgemap_storage.end() )
     20    {
     21      edgemap_storage[name]=edgemap;
     22      return 0;
     23    }
     24  return 1;
    1725}
    1826
  • gui/new_map_win.cc

    r1593 r1597  
    9090  if((point_num<=1)&&(valid_double)&&(!mapname.empty()))
    9191    {
     92      int abortion=0;
    9293      if(edge.get_active())
    9394        {
    94           gdc.addNewEdgeMap(def_val,mapname);
     95          abortion=gdc.addNewEdgeMap(def_val,mapname);
    9596        }
    9697      else
    9798        {
    98           gdc.addNewNodeMap(def_val,mapname);
     99          abortion=gdc.addNewNodeMap(def_val,mapname);
    99100        }
    100       name.set_text("");
    101       default_value.set_text("0");
    102       hide();
     101      if(!abortion)
     102        {
     103          name.set_text("");
     104          default_value.set_text("0");
     105          hide();
     106        }
    103107    }
    104108}
Note: See TracChangeset for help on using the changeset viewer.