[Lemon-commits] [lemon_svn] hegyi: r2101 - hugo/trunk/gui
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:50:09 CET 2006
Author: hegyi
Date: Wed Jul 27 13:35:13 2005
New Revision: 2101
Modified:
hugo/trunk/gui/graph_displayer_canvas-event.cc
hugo/trunk/gui/graph_displayer_canvas.h
hugo/trunk/gui/mapstorage.cc
hugo/trunk/gui/new_map_win.cc
Log:
No maps with the same name can be added.
Modified: hugo/trunk/gui/graph_displayer_canvas-event.cc
==============================================================================
--- hugo/trunk/gui/graph_displayer_canvas-event.cc (original)
+++ hugo/trunk/gui/graph_displayer_canvas-event.cc Wed Jul 27 13:35:13 2005
@@ -854,29 +854,46 @@
}
-void GraphDisplayerCanvas::addNewEdgeMap(double default_value, std::string mapname)
+int GraphDisplayerCanvas::addNewEdgeMap(double default_value, std::string mapname)
{
//create the new map
Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (g,default_value);
- mapstorage.addEdgeMap(mapname,emptr);
+
+ //if addition was not successful addEdgeMap returns one.
+ //cause can be that there is already a map named like the new one
+ if(mapstorage.addEdgeMap(mapname,emptr))
+ {
+ return 1;
+ }
+
//add it to the list of the displayable maps
mapwin->registerNewEdgeMap(mapname);
//display it
changeEdgeText(mapname);
+
+ return 0;
}
-void GraphDisplayerCanvas::addNewNodeMap(double default_value, std::string mapname)
+int GraphDisplayerCanvas::addNewNodeMap(double default_value, std::string mapname)
{
//create the new map
Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (g,default_value);
- mapstorage.addNodeMap(mapname,emptr);
+
+ //if addition was not successful addNodeMap returns one.
+ //cause can be that there is already a map named like the new one
+ if(mapstorage.addNodeMap(mapname,emptr))
+ {
+ return 1;
+ }
//add it to the list of the displayable maps
mapwin->registerNewNodeMap(mapname);
//display it
changeNodeText(mapname);
+
+ return 0;
}
Modified: hugo/trunk/gui/graph_displayer_canvas.h
==============================================================================
--- hugo/trunk/gui/graph_displayer_canvas.h (original)
+++ hugo/trunk/gui/graph_displayer_canvas.h Wed Jul 27 13:35:13 2005
@@ -110,9 +110,9 @@
int getActualTool();
///creates a new Nodemap
- void addNewNodeMap(double,std::string);
+ int addNewNodeMap(double,std::string);
///creates a new Edgemap
- void addNewEdgeMap(double,std::string);
+ int addNewEdgeMap(double,std::string);
private:
///Deletes the given element.
Modified: hugo/trunk/gui/mapstorage.cc
==============================================================================
--- hugo/trunk/gui/mapstorage.cc (original)
+++ hugo/trunk/gui/mapstorage.cc Wed Jul 27 13:35:13 2005
@@ -6,14 +6,22 @@
int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap<double> *nodemap)
{
- nodemap_storage[name]=nodemap;
- return 0;
+ if( nodemap_storage.find(name) == nodemap_storage.end() )
+ {
+ nodemap_storage[name]=nodemap;
+ return 0;
+ }
+ return 1;
}
int MapStorage::addEdgeMap(const std::string & name, Graph::EdgeMap<double> *edgemap)
{
- edgemap_storage[name]=edgemap;
- return 0;
+ if( edgemap_storage.find(name) == edgemap_storage.end() )
+ {
+ edgemap_storage[name]=edgemap;
+ return 0;
+ }
+ return 1;
}
double MapStorage::maxOfNodeMap(const std::string & name)
Modified: hugo/trunk/gui/new_map_win.cc
==============================================================================
--- hugo/trunk/gui/new_map_win.cc (original)
+++ hugo/trunk/gui/new_map_win.cc Wed Jul 27 13:35:13 2005
@@ -89,17 +89,21 @@
if((point_num<=1)&&(valid_double)&&(!mapname.empty()))
{
+ int abortion=0;
if(edge.get_active())
{
- gdc.addNewEdgeMap(def_val,mapname);
+ abortion=gdc.addNewEdgeMap(def_val,mapname);
}
else
{
- gdc.addNewNodeMap(def_val,mapname);
+ abortion=gdc.addNewNodeMap(def_val,mapname);
+ }
+ if(!abortion)
+ {
+ name.set_text("");
+ default_value.set_text("0");
+ hide();
}
- name.set_text("");
- default_value.set_text("0");
- hide();
}
}
More information about the Lemon-commits
mailing list