[Lemon-commits] ladanyi: r3345 - glemon/branches/akos

Lemon SVN svn at lemon.cs.elte.hu
Thu Oct 25 19:58:26 CEST 2007


Author: ladanyi
Date: Thu Oct 25 19:58:25 2007
New Revision: 3345

Modified:
   glemon/branches/akos/all_include.h
   glemon/branches/akos/dijkstrabox.cc
   glemon/branches/akos/graph_displayer_canvas-edge.cc
   glemon/branches/akos/graph_displayer_canvas-event.cc
   glemon/branches/akos/graph_displayer_canvas-node.cc
   glemon/branches/akos/gui_writer.cc
   glemon/branches/akos/io_helper.h
   glemon/branches/akos/kruskalbox.cc
   glemon/branches/akos/map_value.cc
   glemon/branches/akos/map_value.h
   glemon/branches/akos/map_win.cc
   glemon/branches/akos/mapselector.cc
   glemon/branches/akos/mapstorage.cc
   glemon/branches/akos/mapstorage.h
   glemon/branches/akos/new_map_win.cc

Log:
Misc.

Modified: glemon/branches/akos/all_include.h
==============================================================================
--- glemon/branches/akos/all_include.h	(original)
+++ glemon/branches/akos/all_include.h	Thu Oct 25 19:58:25 2007
@@ -66,10 +66,9 @@
 
 enum MapType
 {
-  INT  = 1 << 0,
-  SCAL = 1 << 1,
-  STR  = 1 << 2,
-  ALL  = (1 << 0) | (1 << 1) | (1 << 2)
+  NUM  = 1 << 0,
+  STR  = 1 << 1,
+  ALL  = (1 << 0) | (1 << 1)
 };
 
 #endif // ALL_INCLUDE_H

Modified: glemon/branches/akos/dijkstrabox.cc
==============================================================================
--- glemon/branches/akos/dijkstrabox.cc	(original)
+++ glemon/branches/akos/dijkstrabox.cc	Thu Oct 25 19:58:25 2007
@@ -71,8 +71,8 @@
       std::string inputmapName = edgemapcbts[INPUT]->get_active_text();
       std::string outputmapName = edgemapcbts[OUTPUT]->get_active_text();
 
-      MapValueEdgeMap inputmap = mapstorage->getEdgeMap(inputmapName);
-      MapValueEdgeMap outputmap = mapstorage->getEdgeMap(outputmapName);
+      MapStorage::NumericEdgeMap& inputmap = mapstorage->getNumericEdgeMap(inputmapName);
+      MapStorage::NumericEdgeMap& outputmap = mapstorage->getNumericEdgeMap(outputmapName);
 
       //zero out output map
       for (EdgeIt i(g); i!=INVALID; ++i)
@@ -80,7 +80,7 @@
         outputmap[i]=0;
       }
 
-      Dijkstra<Graph, MapValueEdgeMap > dijkstra(g, inputmap);
+      Dijkstra<Graph, MapStorage::NumericEdgeMap > dijkstra(g, inputmap);
       dijkstra.run(from, to);
 
       if(dijkstra.reached(to))
@@ -131,10 +131,10 @@
 
       if(!(from==to))
 	{
-	  MapValueEdgeMap inputmap=
-	    mapstorage->getEdgeMap(edgemapcbts[INPUT]->get_active_text());
-	  MapValueEdgeMap outputmap=
-	    mapstorage->getEdgeMap(edgemapcbts[OUTPUT]->get_active_text());
+          MapStorage::NumericEdgeMap& inputmap=
+	    mapstorage->getNumericEdgeMap(edgemapcbts[INPUT]->get_active_text());
+          MapStorage::NumericEdgeMap& outputmap=
+	    mapstorage->getNumericEdgeMap(edgemapcbts[OUTPUT]->get_active_text());
 
 	  //zero out output map
 	  for (EdgeIt i(g); i!=INVALID; ++i)
@@ -142,7 +142,7 @@
 	      outputmap[i]=0;
 	    }
 	  
-	  Suurballe<Graph, MapValueEdgeMap > sb((Graph&)g, inputmap, from, to);
+	  Suurballe<Graph, MapStorage::NumericEdgeMap > sb((Graph&)g, inputmap, from, to);
 	  
 	  int found=sb.run(num_set->get_value_as_int());
 	  if(found)
@@ -181,8 +181,8 @@
   //this can be done after the maps are loaded into ComboBoxes
   signal_upon_maplist_updated().connect(sigc::mem_fun(*this, &DijkstraBox::maplists_updated));
 
-  addMapSelector("Cost map: ", true, MapType(INT | SCAL));
-  addMapSelector("Edges of path here: ", true, MapType(INT | SCAL));
+  addMapSelector("Cost map: ", true, NUM);
+  addMapSelector("Edges of path here: ", true, NUM);
 
   Gtk::Label * source_label=new Gtk::Label("Source: ");
   Gtk::Label * target_label=new Gtk::Label("Target: ");

Modified: glemon/branches/akos/graph_displayer_canvas-edge.cc
==============================================================================
--- glemon/branches/akos/graph_displayer_canvas-edge.cc	(original)
+++ glemon/branches/akos/graph_displayer_canvas-edge.cc	Thu Oct 25 19:58:25 2007
@@ -72,9 +72,9 @@
     min = max = mytab.mapstorage.get(mapname, e);
     for (; e != INVALID; ++e)
     {
-      if (mytab.mapstorage.get(mapname, e) > MapValue(max))
+      if (static_cast<double>(mytab.mapstorage.get(mapname, e)) > max)
         max = mytab.mapstorage.get(mapname, e);
-      if (mytab.mapstorage.get(mapname, e) < MapValue(min))
+      if (static_cast<double>(mytab.mapstorage.get(mapname, e)) < min)
         min = mytab.mapstorage.get(mapname, e);
     }
   }
@@ -145,9 +145,9 @@
     min = max = mytab.mapstorage.get(mapname, e);
     for (; e != INVALID; ++e)
     {
-      if (mytab.mapstorage.get(mapname, e) > MapValue(max))
+      if (static_cast<double>(mytab.mapstorage.get(mapname, e)) > max)
         max = mytab.mapstorage.get(mapname, e);
-      if (mytab.mapstorage.get(mapname, e) < MapValue(min))
+      if (static_cast<double>(mytab.mapstorage.get(mapname, e)) < min)
         min = mytab.mapstorage.get(mapname, e);
     }
   }

Modified: glemon/branches/akos/graph_displayer_canvas-event.cc
==============================================================================
--- glemon/branches/akos/graph_displayer_canvas-event.cc	(original)
+++ glemon/branches/akos/graph_displayer_canvas-event.cc	Thu Oct 25 19:58:25 2007
@@ -634,11 +634,7 @@
                 case Gtk::RESPONSE_ACCEPT:
                   switch (mytab.mapstorage.getNodeMapElementType(nodemap_to_edit))
                   {
-                    case MapValue::INTEGER:
-                      mytab.mapstorage.set(nodemap_to_edit, active_node,
-                          atoi(entry.get_text().c_str()));
-                      break;
-                    case MapValue::SCALAR:
+                    case MapValue::NUMERIC:
                       mytab.mapstorage.set(nodemap_to_edit, active_node,
                           atof(entry.get_text().c_str()));
                       break;
@@ -698,11 +694,7 @@
                   case Gtk::RESPONSE_ACCEPT:
                     switch (mytab.mapstorage.getNodeMapElementType(edgemap_to_edit))
                     {
-                      case MapValue::INTEGER:
-                        mytab.mapstorage.set(edgemap_to_edit, active_edge,
-                            atoi(entry.get_text().c_str()));
-                        break;
-                      case MapValue::SCALAR:
+                      case MapValue::NUMERIC:
                         mytab.mapstorage.set(edgemap_to_edit, active_edge,
                             atof(entry.get_text().c_str()));
                         break;

Modified: glemon/branches/akos/graph_displayer_canvas-node.cc
==============================================================================
--- glemon/branches/akos/graph_displayer_canvas-node.cc	(original)
+++ glemon/branches/akos/graph_displayer_canvas-node.cc	Thu Oct 25 19:58:25 2007
@@ -30,9 +30,9 @@
     min = max = mytab.mapstorage.get(mapname, n);
     for (; n != INVALID; ++n)
     {
-      if (mytab.mapstorage.get(mapname, n) > MapValue(max))
+      if (static_cast<double>(mytab.mapstorage.get(mapname, n)) > max)
         max = mytab.mapstorage.get(mapname, n);
-      if (mytab.mapstorage.get(mapname, n) < MapValue(min))
+      if (static_cast<double>(mytab.mapstorage.get(mapname, n)) < min)
         min = mytab.mapstorage.get(mapname, n);
     }
   }
@@ -181,9 +181,9 @@
     min = max = mytab.mapstorage.get(mapname, n);
     for (; n != INVALID; ++n)
     {
-      if (mytab.mapstorage.get(mapname, n) > MapValue(max))
+      if (static_cast<double>(mytab.mapstorage.get(mapname, n)) > max)
         max = mytab.mapstorage.get(mapname, n);
-      if (mytab.mapstorage.get(mapname, n) < MapValue(min))
+      if (static_cast<double>(mytab.mapstorage.get(mapname, n)) < min)
         min = mytab.mapstorage.get(mapname, n);
     }
   }

Modified: glemon/branches/akos/gui_writer.cc
==============================================================================
--- glemon/branches/akos/gui_writer.cc	(original)
+++ glemon/branches/akos/gui_writer.cc	Thu Oct 25 19:58:25 2007
@@ -103,21 +103,12 @@
     MapValue::Type type = mapstorage->getNodeMapElementType(*it);
     switch (type)
     {
-      case MapValue::INTEGER:
-        {
-          NodeData<int> data(
-              mapstorage->graph,
-              mapstorage->getNodeLabelMap(),
-              mapstorage->getIntegerNodeMap(*it));
-          { x(*it, data); }
-        }
-        break;
-      case MapValue::SCALAR:
+      case MapValue::NUMERIC:
         {
           NodeData<double> data(
               mapstorage->graph,
               mapstorage->getNodeLabelMap(),
-              mapstorage->getScalarNodeMap(*it));
+              mapstorage->getNumericNodeMap(*it));
           { x(*it, data); }
         }
         break;
@@ -153,21 +144,12 @@
     MapValue::Type type = mapstorage->getEdgeMapElementType(*it);
     switch (type)
     {
-      case MapValue::INTEGER:
-        {
-          EdgeData<int> data(
-              mapstorage->graph,
-              mapstorage->getEdgeLabelMap(),
-              mapstorage->getIntegerEdgeMap(*it));
-          { x(*it, data); }
-        }
-        break;
-      case MapValue::SCALAR:
+      case MapValue::NUMERIC:
         {
           EdgeData<double> data(
               mapstorage->graph,
               mapstorage->getEdgeLabelMap(),
-              mapstorage->getScalarEdgeMap(*it));
+              mapstorage->getNumericEdgeMap(*it));
           { x(*it, data); }
         }
         break;

Modified: glemon/branches/akos/io_helper.h
==============================================================================
--- glemon/branches/akos/io_helper.h	(original)
+++ glemon/branches/akos/io_helper.h	Thu Oct 25 19:58:25 2007
@@ -59,11 +59,8 @@
     if(x.write()) {
       switch (v)
       {
-        case MapValue::INTEGER:
-          { x("type", std::string("integer")); }
-          break;
-        case MapValue::SCALAR:
-          { x("type", std::string("scalar")); }
+        case MapValue::NUMERIC:
+          { x("type", std::string("numeric")); }
           break;
         case MapValue::STRING:
           { x("type", std::string("string")); }
@@ -73,13 +70,9 @@
     else {
       std::string type;
       { x("type", type); }
-      if (type == "integer")
-      {
-        v = MapValue::INTEGER;
-      }
-      else if (type == "double")
+      if (type == "numeric")
       {
-        v = MapValue::SCALAR;
+        v = MapValue::NUMERIC;
       }
       else if (type == "string")
       {
@@ -93,17 +86,13 @@
   }
 
   /*
-  void xml(XmlIo &x, MapType& v)
+  void xml(XmlIo &x, MapValue& v)
   {
     if(x.write()) {
       switch (v.getType())
       {
-        case MapValue::INTEGER:
-          { x("type", "integer"); }
-          { x("value", static_cast<int>(v)); }
-          break;
-        case MapValue::SCALAR:
-          { x("type", "scalar"); }
+        case MapValue::NUMERIC:
+          { x("type", "numeric"); }
           { x("value", static_cast<double>(v)); }
           break;
         case MapValue::STRING:
@@ -115,13 +104,7 @@
     else {
       std::string type;
       { x("type", type); }
-      if (type == "integer")
-      {
-        int i;
-        { x("value", i); }
-        v = i;
-      }
-      else if (type == "double")
+      if (type == "numeric")
       {
         double d;
         { x("value", d); }

Modified: glemon/branches/akos/kruskalbox.cc
==============================================================================
--- glemon/branches/akos/kruskalbox.cc	(original)
+++ glemon/branches/akos/kruskalbox.cc	Thu Oct 25 19:58:25 2007
@@ -37,38 +37,19 @@
     const Graph &g=mapstorage->getGraph();
     std::string input_map_name = edgemapcbts[INPUT]->get_active_text();
     Graph::EdgeMap<bool> outputmap(g);
-    double res;
-    switch (mapstorage->getEdgeMapElementType(input_map_name))
-    {
-      case MapValue::INTEGER:
-        {
-          const MapStorage::IntegerEdgeMap& inputmap=
-            mapstorage->getIntegerEdgeMap(input_map_name);
-          res=kruskal(g, inputmap, outputmap);
-        }
-        break;
-      case MapValue::SCALAR:
-        {
-          const MapStorage::ScalarEdgeMap& inputmap=
-            mapstorage->getScalarEdgeMap(input_map_name);
-          res=kruskal(g, inputmap, outputmap);
-        }
-        break;
-      case MapValue::STRING:
-        std::cerr << "String maps can not be used here." << std::endl;
-        exit(1);
-        break;
-    }
+    const MapStorage::NumericEdgeMap& inputmap=
+      mapstorage->getNumericEdgeMap(input_map_name);
+    double res=kruskal(g, inputmap, outputmap);
 
     for (EdgeIt i(g); i!=INVALID; ++i)
     {
       if(outputmap[i])
       {
-        mapstorage->set(edgemapcbts[OUTPUT]->get_active_text(), i, 1);
+        mapstorage->set(edgemapcbts[OUTPUT]->get_active_text(), i, 1.0);
       }
       else
       {
-        mapstorage->set(edgemapcbts[OUTPUT]->get_active_text(), i, 0);
+        mapstorage->set(edgemapcbts[OUTPUT]->get_active_text(), i, 0.0);
       }
     }
 
@@ -89,8 +70,8 @@
 {
   std::vector<std::string> empty_vector;
 
-  addMapSelector("Edgecosts: ", true, MapType(INT | SCAL));
-  addMapSelector("Edges of tree here: ", true, MapType(INT | SCAL));
+  addMapSelector("Edgecosts: ", true, NUM);
+  addMapSelector("Edges of tree here: ", true, NUM);
 
   resultlabel.set_text("Result: algorithm is not run yet.");
   pack_start(resultlabel);

Modified: glemon/branches/akos/map_value.cc
==============================================================================
--- glemon/branches/akos/map_value.cc	(original)
+++ glemon/branches/akos/map_value.cc	Thu Oct 25 19:58:25 2007
@@ -8,19 +8,11 @@
   has_value = false;
 }
 
-MapValue::MapValue(int i)
-{
-  //std::cout << __PRETTY_FUNCTION__ << std::endl;
-  p_value = new int(i);
-  type = INTEGER;
-  has_value = true;
-}
-
 MapValue::MapValue(double d)
 {
   //std::cout << __PRETTY_FUNCTION__ << std::endl;
   p_value = new double(d);
-  type = SCALAR;
+  type = NUMERIC;
   has_value = true;
 }
 
@@ -40,26 +32,12 @@
   has_value = true;
 }
 
-MapValue::operator int() const
-{
-  //std::cout << __PRETTY_FUNCTION__ << std::endl;
-  if (!has_value) throw IllegalOperation();
-  if (type == INTEGER)
-    return *(static_cast<int*>(p_value));
-  if (type == SCALAR)
-    return static_cast<int>(*(static_cast<double*>(p_value)));
-  else
-    throw IllegalOperation();
-}
-
 MapValue::operator double() const
 {
   //std::cout << __PRETTY_FUNCTION__ << std::endl;
   if (!has_value) throw IllegalOperation();
-  if (type == SCALAR)
+  if (type == NUMERIC)
     return *(static_cast<double*>(p_value));
-  if (type == INTEGER)
-    return static_cast<double>(*(static_cast<int*>(p_value)));
   else
     throw IllegalOperation();
 }
@@ -71,15 +49,7 @@
   std::string ret;
   switch (type)
   {
-    case INTEGER:
-      {
-        int i = *(static_cast<int*>(p_value));
-        std::ostringstream ostr;
-        ostr << i;
-        ret = ostr.str();
-      }
-      break;
-    case SCALAR:
+    case NUMERIC:
       {
         double d = *(static_cast<double*>(p_value));
         std::ostringstream ostr;
@@ -102,10 +72,7 @@
   type = v.type;
   switch (v.type)
   {
-    case INTEGER:
-      p_value = new int(*(static_cast<int*>(v.p_value)));
-      break;
-    case SCALAR:
+    case NUMERIC:
       p_value = new double(*(static_cast<double*>(v.p_value)));
       break;
     case STRING:
@@ -125,10 +92,7 @@
     type = v.type;
     switch (v.type)
     {
-      case INTEGER:
-        p_value = new int(*(static_cast<int*>(v.p_value)));
-        break;
-      case SCALAR:
+      case NUMERIC:
         p_value = new double(*(static_cast<double*>(v.p_value)));
         break;
       case STRING:
@@ -145,306 +109,13 @@
   clear();
 }
 
-bool MapValue::operator<(const MapValue& v) const
-{
-  if (!has_value || !v.has_value)
-    throw IllegalOperation();
-
-  if (type != v.type)
-    throw IllegalOperation();
-
-  switch (type)
-  {
-    case INTEGER:
-      return getAsInt() < v.getAsInt();
-    case SCALAR:
-      return getAsDouble() < v.getAsDouble();
-    case STRING:
-      throw IllegalOperation();
-  }
-}
-
-bool MapValue::operator>(const MapValue& v) const
-{
-  if (!has_value || !v.has_value)
-    throw IllegalOperation();
-
-  if (type != v.type)
-    throw IllegalOperation();
-
-  switch (type)
-  {
-    case INTEGER:
-      return getAsInt() > v.getAsInt();
-    case SCALAR:
-      return getAsDouble() > v.getAsDouble();
-    case STRING:
-      throw IllegalOperation();
-  }
-}
-
-bool MapValue::operator<=(const MapValue& v) const
-{
-  if (!has_value || !v.has_value)
-    throw IllegalOperation();
-
-  if (type != v.type)
-    throw IllegalOperation();
-
-  switch (type)
-  {
-    case INTEGER:
-      return getAsInt() <= v.getAsInt();
-    case SCALAR:
-      return getAsDouble() <= v.getAsDouble();
-    case STRING:
-      throw IllegalOperation();
-  }
-}
-
-bool MapValue::operator>=(const MapValue& v) const
-{
-  if (!has_value || !v.has_value)
-    throw IllegalOperation();
-
-  if (type != v.type)
-    throw IllegalOperation();
-
-  switch (type)
-  {
-    case INTEGER:
-      return getAsInt() >= v.getAsInt();
-    case SCALAR:
-      return getAsDouble() >= v.getAsDouble();
-    case STRING:
-      throw IllegalOperation();
-  }
-}
-
-MapValue MapValue::operator-() const
-{
-  if (!has_value)
-    throw IllegalOperation();
-
-  switch (type)
-  {
-    case INTEGER:
-      return -getAsInt();
-    case SCALAR:
-      return -getAsDouble();
-    case STRING:
-      throw IllegalOperation();
-  }
-}
-
-MapValue MapValue::operator+(const MapValue& v) const
-{
-  if (!has_value || !v.has_value)
-    throw IllegalOperation();
-
-  if (type != v.type)
-    throw IllegalOperation();
-
-  switch (type)
-  {
-    case INTEGER:
-      return getAsInt() + v.getAsInt();
-    case SCALAR:
-      return getAsDouble() + v.getAsDouble();
-    case STRING:
-      throw IllegalOperation();
-  }
-}
-
-MapValue MapValue::operator-(const MapValue& v) const
-{
-  if (!has_value || !v.has_value)
-    throw IllegalOperation();
-
-  if (type != v.type)
-    throw IllegalOperation();
-
-  switch (type)
-  {
-    case INTEGER:
-      return getAsInt() - v.getAsInt();
-    case SCALAR:
-      return getAsDouble() - v.getAsDouble();
-    case STRING:
-      throw IllegalOperation();
-  }
-}
-
-MapValue MapValue::operator*(const MapValue& v) const
-{
-  if (!has_value || !v.has_value)
-    throw IllegalOperation();
-
-  if (type != v.type)
-    throw IllegalOperation();
-
-  switch (type)
-  {
-    case INTEGER:
-      return getAsInt() * v.getAsInt();
-    case SCALAR:
-      return getAsDouble() * v.getAsDouble();
-    case STRING:
-      throw IllegalOperation();
-  }
-}
-
-MapValue MapValue::operator/(const MapValue& v) const
-{
-  if (!has_value || !v.has_value)
-    throw IllegalOperation();
-
-  if (type != v.type)
-    throw IllegalOperation();
-
-  switch (type)
-  {
-    case INTEGER:
-      return getAsInt() / v.getAsInt();
-    case SCALAR:
-      return getAsDouble() / v.getAsDouble();
-    case STRING:
-      throw IllegalOperation();
-  }
-}
-
-MapValue& MapValue::operator+=(const MapValue& v)
-{
-  if (!has_value || !v.has_value)
-    throw IllegalOperation();
-
-  if (type != v.type)
-    throw IllegalOperation();
-
-  switch (type)
-  {
-    case INTEGER:
-      set(getAsInt() + v.getAsInt());
-    case SCALAR:
-      set(getAsDouble() + v.getAsDouble());
-    case STRING:
-      throw IllegalOperation();
-  }
-
-  return *this;
-}
-
-MapValue& MapValue::operator-=(const MapValue& v)
-{
-  if (!has_value || !v.has_value)
-    throw IllegalOperation();
-
-  if (type != v.type)
-    throw IllegalOperation();
-
-  switch (type)
-  {
-    case INTEGER:
-      set(getAsInt() - v.getAsInt());
-    case SCALAR:
-      set(getAsDouble() - v.getAsDouble());
-    case STRING:
-      throw IllegalOperation();
-  }
-
-  return *this;
-}
-
-MapValue& MapValue::operator*=(const MapValue& v)
-{
-  if (!has_value || !v.has_value)
-    throw IllegalOperation();
-
-  if (type != v.type)
-    throw IllegalOperation();
-
-  switch (type)
-  {
-    case INTEGER:
-      set(getAsInt() * v.getAsInt());
-    case SCALAR:
-      set(getAsDouble() * v.getAsDouble());
-    case STRING:
-      throw IllegalOperation();
-  }
-
-  return *this;
-}
-
-MapValue& MapValue::operator/=(const MapValue& v)
-{
-  if (!has_value || !v.has_value)
-    throw IllegalOperation();
-
-  if (type != v.type)
-    throw IllegalOperation();
-
-  switch (type)
-  {
-    case INTEGER:
-      set(getAsInt() / v.getAsInt());
-    case SCALAR:
-      set(getAsDouble() / v.getAsDouble());
-    case STRING:
-      throw IllegalOperation();
-  }
-
-  return *this;
-}
-
-bool MapValue::operator==(const MapValue& v) const
-{
-  if (!has_value || !v.has_value)
-    throw IllegalOperation();
-
-  if (type != v.type)
-    throw IllegalOperation();
-
-  switch (type)
-  {
-    case INTEGER:
-      return getAsInt() == v.getAsInt();
-    case SCALAR:
-      return getAsDouble() == v.getAsDouble();
-    case STRING:
-      return getAsString() == v.getAsString();
-  }
-}
-
-bool MapValue::operator!=(const MapValue& v) const
-{
-  if (!has_value || !v.has_value)
-    throw IllegalOperation();
-
-  if (type != v.type)
-    throw IllegalOperation();
-
-  switch (type)
-  {
-    case INTEGER:
-      return getAsInt() != v.getAsInt();
-    case SCALAR:
-      return getAsDouble() != v.getAsDouble();
-    case STRING:
-      return getAsString() != v.getAsString();
-  }
-}
-
 void MapValue::clear()
 {
   //std::cout << __PRETTY_FUNCTION__ << std::endl;
   if (!has_value) return;
   switch (type)
   {
-    case INTEGER:
-      delete static_cast<int*>(p_value);
-      break;
-    case SCALAR:
+    case NUMERIC:
       delete static_cast<double*>(p_value);
       break;
     case STRING:
@@ -453,67 +124,16 @@
   }
 }
 
-std::istream& operator>>(std::istream &is, MapValue& v)
+MapValue::Type MapValue::getType() const
 {
   //std::cout << __PRETTY_FUNCTION__ << std::endl;
-  char c1, c2;
-  if (!(is >> c1)) return is;
-  if ((c1 != 'i') && (c1 != 'd') && (c1 != 's'))
-  {
-    is.putback(c1);
-    return is;
-  }
-  if (!(is >> c2)) return is;
-  if (c2 != '(')
-  {
-    is.putback(c1);
-    return is;
-  }
-  switch (c1)
-  {
-    case 'i':
-      {
-        int i;
-        if (!(is >> i)) return is;
-        v = i;
-      }
-      break;
-    case 'd':
-      {
-        double d;
-        if (!(is >> d)) return is;
-        v = d;
-      }
-      break;
-    case 's':
-      {
-        std::string s;
-        char c;
-        while ((is >> c) && c != ')')
-        {
-          if (c == '\\')
-          {
-            if (!(is >> c)) return is;
-            if ((c != ')') && (c != '\\')) return is;
-          }
-          s.push_back(c);
-        }
-        if (c == ')')
-        {
-          is.putback(c);
-          v = s;
-        }
-        else return is;
-      }
-      break;
-  }
-  if (!(is >> c2)) return is;
-  if (c2 != ')')
-  {
-    is.putback(c2);
-    return is;
-  }
-  return is;
+  return type;
+}
+
+bool MapValue::hasValue() const
+{
+  //std::cout << __PRETTY_FUNCTION__ << std::endl;
+  return has_value;
 }
 
 std::ostream& operator<<(std::ostream &os, const MapValue& v)
@@ -522,97 +142,12 @@
   if (!v.has_value) return os;
   switch (v.type)
   {
-    case MapValue::INTEGER:
-      os << "i(" << *(static_cast<int*>(v.p_value)) << ")";
-      break;
-    case MapValue::SCALAR:
-      os << "d(" << *(static_cast<double*>(v.p_value)) << ")";
+    case MapValue::NUMERIC:
+      os << *(static_cast<double*>(v.p_value));
       break;
     case MapValue::STRING:
-      {
-        os << "s(";
-        std::string s = *(static_cast<std::string*>(v.p_value));
-        for (std::string::const_iterator it = s.begin(); it != s.end(); ++it)
-        {
-          switch (*it)
-          {
-            case ')':
-              os << "\\)";
-              break;
-            case '\\':
-              os << "\\\\";
-              break;
-            default:
-              os << *it;
-          }
-        }
-        os << ")";
-      }
+      os << *(static_cast<std::string*>(v.p_value));
       break;
   }
   return os;
 }
-
-MapValue::Type MapValue::getType() const
-{
-  //std::cout << __PRETTY_FUNCTION__ << std::endl;
-  return type;
-}
-
-int MapValue::getAsInt() const
-{
-  if (type != INTEGER)
-    throw IllegalOperation();
-
-  return *(static_cast<int*>(p_value));
-}
-
-double MapValue::getAsDouble() const
-{
-  if (type != SCALAR)
-    throw IllegalOperation();
-
-  return *(static_cast<double*>(p_value));
-}
-
-std::string MapValue::getAsString() const
-{
-  if (type != STRING)
-    throw IllegalOperation();
-
-  return *(static_cast<std::string*>(p_value));
-}
-
-void MapValue::set(int i)
-{
-  clear();
-  p_value = new int(i);
-  type = INTEGER;
-  has_value = true;
-}
-
-void MapValue::set(double d)
-{
-  clear();
-  p_value = new double(d);
-  type = SCALAR;
-  has_value = true;
-}
-
-void MapValue::set(const std::string& str)
-{
-  clear();
-  p_value = new std::string(str);
-  type = STRING;
-  has_value = true;
-}
-
-bool MapValue::hasValue() const
-{
-  return has_value;
-}
-
-namespace lemon
-{
-  double Tolerance<MapValue>::def_epsilon = 1e-10;
-}

Modified: glemon/branches/akos/map_value.h
==============================================================================
--- glemon/branches/akos/map_value.h	(original)
+++ glemon/branches/akos/map_value.h	Thu Oct 25 19:58:25 2007
@@ -4,12 +4,11 @@
 #include <exception>
 #include <functional>
 #include <iosfwd>
-#include <lemon/tolerance.h>
+//#include <lemon/tolerance.h>
 
 class MapValue
 {
   public:
-    friend std::istream& operator>>(std::istream &is, MapValue& v);
     friend std::ostream& operator<<(std::ostream &os, const MapValue& v);
     class IllegalOperation : public std::exception
     {
@@ -20,9 +19,8 @@
     };
     typedef enum
     {
-      INTEGER = 1 << 0,
-      SCALAR  = 1 << 1,
-      STRING  = 1 << 2
+      NUMERIC = 1 << 0,
+      STRING  = 1 << 1
     } Type;
   private:
     bool has_value;
@@ -31,7 +29,6 @@
     void clear();
   public:
     MapValue();
-    MapValue(int);
     MapValue(double);
     MapValue(std::string);
     MapValue(const char* str);
@@ -39,208 +36,9 @@
     MapValue& operator=(const MapValue& v);
     ~MapValue();
     operator std::string() const;
-    operator int() const;
     operator double() const;
-    bool operator<(const MapValue& v) const;
-    bool operator>(const MapValue& v) const;
-    bool operator<=(const MapValue& v) const;
-    bool operator>=(const MapValue& v) const;
-    MapValue operator-() const;
-    MapValue operator+(const MapValue& v) const;
-    MapValue operator-(const MapValue& v) const;
-    MapValue operator*(const MapValue& v) const;
-    MapValue operator/(const MapValue& v) const;
-    MapValue& operator+=(const MapValue& v);
-    MapValue& operator-=(const MapValue& v);
-    MapValue& operator*=(const MapValue& v);
-    MapValue& operator/=(const MapValue& v);
-    bool operator==(const MapValue& v) const;
-    bool operator!=(const MapValue& v) const;
     Type getType() const;
-    int getAsInt() const;
-    double getAsDouble() const;
-    std::string getAsString() const;
-    void set(int i);
-    void set(double d);
-    void set(const std::string& str);
     bool hasValue() const;
 };
 
-namespace std
-{
-  template<> struct less< MapValue > :
-  binary_function< MapValue, MapValue, bool >
-  {
-    result_type operator()( first_argument_type x, second_argument_type y ) const
-    {
-      if (!x.hasValue() || !y.hasValue())
-        throw MapValue::IllegalOperation();
-
-      if (x.getType() != y.getType())
-        throw MapValue::IllegalOperation();
-
-      switch (x.getType())
-      {
-        case MapValue::INTEGER:
-          return x.getAsInt() < y.getAsInt();
-        case MapValue::SCALAR:
-          return x.getAsDouble() < y.getAsDouble();
-        case MapValue::STRING:
-          throw MapValue::IllegalOperation();
-      }
-    }
-  };
-  /*
-  template <>
-  struct less : public binary_function<MapValue,MapValue,bool>
-  {
-    bool operator()(const MapValue& x, const MapValue& y) const
-    {
-      if (!x.hasValue() || !y.hasValue())
-        throw MapValue::IllegalOperation();
-
-      if (x.getType() != y.getType())
-        throw MapValue::IllegalOperation();
-
-      switch (x.getType())
-      {
-        case MapValue::INTEGER:
-          return x.getAsInt() < y.getAsInt();
-        case MapValue::SCALAR:
-          return x.getAsDouble() < y.getAsDouble();
-        case MapValue::STRING:
-          throw MapValue::IllegalOperation();
-      }
-    }
-  };
-  template <>
-  bool less<MapValue>::operator() (const MapValue &x, const MapValue &y) const
-  {
-    if (!x.hasValue() || !y.hasValue())
-      throw MapValue::IllegalOperation();
-
-    if (x.getType() != y.getType())
-      throw MapValue::IllegalOperation();
-
-    switch (x.getType())
-    {
-      case MapValue::INTEGER:
-        return x.getAsInt() < y.getAsInt();
-      case MapValue::SCALAR:
-        return x.getAsDouble() < y.getAsDouble();
-      case MapValue::STRING:
-        throw MapValue::IllegalOperation();
-    }
-  };
-  */
-}
-
-namespace lemon
-{
-  template <>
-  class Tolerance<MapValue>
-  {
-    private:
-      static double def_epsilon;
-      double _epsilon;
-    public:
-      typedef MapValue Value;
-
-      Tolerance() : _epsilon(def_epsilon) {}
-      Tolerance(double e) : _epsilon(e) {}
-
-      double epsilon() const {return _epsilon;}
-      void epsilon(double e) {_epsilon=e;}
-
-      static double defaultEpsilon() {return def_epsilon;}
-      static void defaultEpsilon(double e) {def_epsilon=e;}
-
-      bool less(Value a,Value b) const
-      {
-        if (!a.hasValue() || !b.hasValue())
-          throw MapValue::IllegalOperation();
-
-        if (a.getType() != b.getType())
-          throw MapValue::IllegalOperation();
-
-        switch (a.getType())
-        {
-          case MapValue::INTEGER:
-            return a.getAsInt() < b.getAsInt();
-          case MapValue::SCALAR:
-            return a.getAsDouble() + _epsilon < b.getAsDouble();
-          case MapValue::STRING:
-            throw MapValue::IllegalOperation();
-        }
-      }
-      bool different(Value a,Value b) const
-      {
-        if (!a.hasValue() || !b.hasValue())
-          throw MapValue::IllegalOperation();
-
-        if (a.getType() != b.getType())
-          throw MapValue::IllegalOperation();
-
-        switch (a.getType())
-        {
-          case MapValue::INTEGER:
-            return a.getAsInt() != b.getAsInt();
-          case MapValue::SCALAR:
-            return (a.getAsDouble() + _epsilon < b.getAsDouble()) ||
-                   (b.getAsDouble() + _epsilon < a.getAsDouble());
-          case MapValue::STRING:
-            throw MapValue::IllegalOperation();
-        }
-      }
-      bool positive(Value a) const
-      {
-        if (!a.hasValue())
-          throw MapValue::IllegalOperation();
-
-        switch (a.getType())
-        {
-          case MapValue::INTEGER:
-            return  0 < a.getAsInt();
-          case MapValue::SCALAR:
-            return _epsilon < a.getAsDouble();
-          case MapValue::STRING:
-            throw MapValue::IllegalOperation();
-        }
-      }
-      bool negative(Value a) const
-      {
-        if (!a.hasValue())
-          throw MapValue::IllegalOperation();
-
-        switch (a.getType())
-        {
-          case MapValue::INTEGER:
-            return  0 > a.getAsInt();
-          case MapValue::SCALAR:
-            return -_epsilon > a.getAsDouble();
-          case MapValue::STRING:
-            throw MapValue::IllegalOperation();
-        }
-      }
-      bool nonZero(Value a) const
-      {
-        if (!a.hasValue())
-          throw MapValue::IllegalOperation();
-
-        switch (a.getType())
-        {
-          case MapValue::INTEGER:
-            return  0 != a.getAsInt();
-          case MapValue::SCALAR:
-            return (_epsilon < a.getAsDouble()) ||
-                   (-_epsilon > a.getAsDouble());
-          case MapValue::STRING:
-            throw MapValue::IllegalOperation();
-        }
-      };
-
-      static Value zero() { return MapValue(0); }
-  };
-};
-
 #endif

Modified: glemon/branches/akos/map_win.cc
==============================================================================
--- glemon/branches/akos/map_win.cc	(original)
+++ glemon/branches/akos/map_win.cc	Thu Oct 25 19:58:25 2007
@@ -46,7 +46,21 @@
 
   for(int i=0;i<EDGE_PROPERTY_NUM;i++)
   {
-    e_combo_array[i]=new MapSelector(edge_property_strings[i], true, mytab.getActiveEdgeMap(i));
+    switch (i)
+    {
+      case E_WIDTH:
+        e_combo_array[i]=new MapSelector(edge_property_strings[i], true,
+            mytab.getActiveEdgeMap(i), true, NUM);
+        break;
+      case E_COLOR:
+        e_combo_array[i]=new MapSelector(edge_property_strings[i], true,
+            mytab.getActiveEdgeMap(i), true, NUM);
+        break;
+      case E_TEXT:
+        e_combo_array[i]=new MapSelector(edge_property_strings[i], true,
+            mytab.getActiveEdgeMap(i), true, ALL);
+        break;
+    }
 
     (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
 
@@ -66,7 +80,21 @@
 
   for(int i=0;i<NODE_PROPERTY_NUM;i++)
   {
-    n_combo_array[i]=new MapSelector(node_property_strings[i], false, mytab.getActiveNodeMap(i));
+    switch (i)
+    {
+      case N_RADIUS:
+        n_combo_array[i]=new MapSelector(node_property_strings[i], false,
+            mytab.getActiveNodeMap(i), true, NUM);
+        break;
+      case N_COLOR:
+        n_combo_array[i]=new MapSelector(node_property_strings[i], false,
+            mytab.getActiveNodeMap(i), true, NUM);
+        break;
+      case N_TEXT:
+        n_combo_array[i]=new MapSelector(node_property_strings[i], false,
+            mytab.getActiveNodeMap(i), true, ALL);
+        break;
+    }
 
     (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
 

Modified: glemon/branches/akos/mapselector.cc
==============================================================================
--- glemon/branches/akos/mapselector.cc	(original)
+++ glemon/branches/akos/mapselector.cc	Thu Oct 25 19:58:25 2007
@@ -91,9 +91,9 @@
 
   std::vector<std::string> ml;
   if (itisedge)
-    ml = ms->getEdgeMaps();
+    ml = ms->getEdgeMaps(map_type);
   else
-    ml = ms->getNodeMaps();
+    ml = ms->getNodeMaps(map_type);
 
   std::vector< std::string >::iterator emsi=ml.begin();
   for(;emsi!=ml.end();emsi++)

Modified: glemon/branches/akos/mapstorage.cc
==============================================================================
--- glemon/branches/akos/mapstorage.cc	(original)
+++ glemon/branches/akos/mapstorage.cc	Thu Oct 25 19:58:25 2007
@@ -26,7 +26,6 @@
 #include <fstream>
 #include <string>
 #include <gtkmm.h>
-#include <lemon/time_measure.h>
 #include "file_import_dialog.h"
 
 const int i_d=20;
@@ -68,9 +67,9 @@
     }
 }
 
-// TODO
 MapStorage::~MapStorage()
 {
+  clear();
 }
 
 void MapStorage::createNodeMap(const std::string& name, MapValue::Type type,
@@ -82,11 +81,8 @@
 
   switch (type)
   {
-    case MapValue::INTEGER:
-      nodemaps[name] = new IntegerNodeMapData(graph, def_val);
-      break;
-    case MapValue::SCALAR:
-      nodemaps[name] = new ScalarNodeMapData(graph, def_val);
+    case MapValue::NUMERIC:
+      nodemaps[name] = new NumericNodeMapData(graph, def_val);
       break;
     case MapValue::STRING:
       nodemaps[name] = new StringNodeMapData(graph, def_val);
@@ -107,11 +103,8 @@
 
   switch (type)
   {
-    case MapValue::INTEGER:
-      edgemaps[name] = new IntegerEdgeMapData(graph, def_val);
-      break;
-    case MapValue::SCALAR:
-      edgemaps[name] = new ScalarEdgeMapData(graph, def_val);
+    case MapValue::NUMERIC:
+      edgemaps[name] = new NumericEdgeMapData(graph, def_val);
       break;
     case MapValue::STRING:
       edgemaps[name] = new StringEdgeMapData(graph, def_val);
@@ -179,8 +172,7 @@
     {
       EdgeMapData* data = getEdgeMapData(it->first);
       MapValue::Type t = data->type();
-      if ((t == MapValue::INTEGER && (type & INT)) ||
-          (t == MapValue::SCALAR && (type & SCAL)) ||
+      if ((t == MapValue::NUMERIC && (type & NUM)) ||
           (t == MapValue::STRING && (type & STR)))
       {
         ret.push_back(it->first);
@@ -210,8 +202,7 @@
     {
       NodeMapData* data = getNodeMapData(it->first);
       MapValue::Type t = data->type();
-      if ((t == MapValue::INTEGER && (type & INT)) ||
-          (t == MapValue::SCALAR && (type & SCAL)) ||
+      if ((t == MapValue::NUMERIC && (type & NUM)) ||
           (t == MapValue::STRING && (type & STR)))
       {
         ret.push_back(it->first);
@@ -226,21 +217,16 @@
   return signal_prop;
 }
 
-//TODO
 int MapStorage::readFromFile(const std::string &filename)
 {
-  /*
-  std::cout << "MapStorage::readFromFile()" << std::endl;
-  lemon::Timer timer;
-
   // check whether the .conf file exists
   bool conf_file_exists = g_file_test((filename + ".conf").c_str(),
       (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR));
 
   if (conf_file_exists)
-    std::cout << ".conf: exists" << std::endl;
+    std::cerr << ".conf: exists" << std::endl;
   else
-    std::cout << ".conf: not found" << std::endl;
+    std::cerr << ".conf: not found" << std::endl;
 
   // check whether the file contains a gui section
   bool gui_section_exists = false;
@@ -267,9 +253,9 @@
   }
 
   if (gui_section_exists)
-    std::cout << "gui section: exists" << std::endl;
+    std::cerr << "gui section: exists" << std::endl;
   else
-    std::cout << "gui section: not found" << std::endl;
+    std::cerr << "gui section: not found" << std::endl;
 
   // ask for user input if both exist
   bool prefer_gui_section = false;
@@ -294,9 +280,10 @@
   }
 
   if (prefer_gui_section)
-    std::cout << "prefer gui section: yes" << std::endl;
+    std::cerr << "prefer gui section: yes" << std::endl;
   else
-    std::cout << "prefer gui section: no" << std::endl;
+    std::cerr << "prefer gui section: no" << std::endl;
+
 
   {
     FileImportDialog fidialog;
@@ -306,7 +293,7 @@
 
 
 
-
+/*
   bool read_x = false;
   bool read_y = false;
   bool read_edge_id = false;
@@ -343,24 +330,24 @@
       {
         read_x = true;
         greader.readNodeMap(*it, node_x_coord);
-        //std::cout << "read X nodemap" << std::endl;
+        //std::cerr << "read X nodemap" << std::endl;
       }
       else if (*it == "coordinates_y")
       {
         read_y = true;
         greader.readNodeMap(*it, node_y_coord);
-        //std::cout << "read Y nodemap" << std::endl;
+        //std::cerr << "read Y nodemap" << std::endl;
       }
       else if (*it == "label")
       {
         greader.readNodeMap(*it, node_label);
-        //std::cout << "read id nodemap" << std::endl;
+        //std::cerr << "read id nodemap" << std::endl;
       }
       else
       {
         nodemap_storage[*it] = new Graph::NodeMap<double>(graph);
         greader.readNodeMap(*it, *nodemap_storage[*it]);
-        //std::cout << "read " << *it << " nodemap" << std::endl;
+        //std::cerr << "read " << *it << " nodemap" << std::endl;
       }
     }
     for (std::vector<std::string>::const_iterator it = edgeMapNames.begin();
@@ -368,21 +355,21 @@
     {
       if (*it == "label")
       {
-        //std::cout << "read id edgemap" << std::endl;
+        //std::cerr << "read id edgemap" << std::endl;
         read_edge_id = true;
         greader.readEdgeMap(*it, edge_label);
       }
       else
       {
         edgemap_storage[*it] = new Graph::EdgeMap<double>(graph);
-        //std::cout << "read " << *it << " edgemap" << std::endl;
+        //std::cerr << "read " << *it << " edgemap" << std::endl;
         greader.readEdgeMap(*it, *edgemap_storage[*it]);
       }
     }
     if ((gui_section_exists && !conf_file_exists) ||
         (gui_section_exists && conf_file_exists && prefer_gui_section))
     {
-      std::cout << "reading gui section" << std::endl;
+      std::cerr << "reading gui section" << std::endl;
       GuiReader gui_reader(greader, this);
     }
     greader.run();
@@ -390,7 +377,7 @@
     if ((!gui_section_exists && conf_file_exists) ||
         (gui_section_exists && conf_file_exists && !prefer_gui_section))
     {
-      std::cout << "reading .conf file" << std::endl;
+      std::cerr << "reading .conf file" << std::endl;
       LemonReader lreader(filename + ".conf");
       GuiReader gui_reader(lreader, this);
       lreader.run();
@@ -515,11 +502,10 @@
         edgemap_default["label"] = 1.0;
     }
   }
+  */
 
-  std::cout << "Reading finished" << std::endl;
-  std::cout << "Time elapsed: " << timer << std::endl;
+  std::cerr << "reading finished" << std::endl;
 
-  */
 
   // set max_node_label
   // set max_edge_label
@@ -527,7 +513,6 @@
   return 0;
 }
 
-//TODO
 void MapStorage::writeToFile(const std::string &filename)
 {
   // relabel nodes and edges
@@ -582,7 +567,7 @@
     }
   }
 
-  // write .lgf file
+  // write .conf file
   if (gui_sect_save_dest == CONF_FILE)
   {
     LemonWriter lwriter(filename + ".conf");
@@ -591,50 +576,25 @@
   }
 }
 
-//TODO
 void MapStorage::clear()
 {
-  /*
-  for (std::map<std::string, Graph::NodeMap<double>*>::iterator it =
-      nodemap_storage.begin(); it != nodemap_storage.end(); ++it)
+  for (NodeMapStore::iterator it = nodemaps.begin(); it != nodemaps.end(); ++it)
   {
-    if ((it->first != "coordinates_x") &&
-        (it->first != "coordinates_y") &&
-        (it->first != "label"))
-    {
-      delete it->second;
-      nodemap_storage.erase(it);
-    }
+    delete it->second;
+    nodemaps.erase(it);
   }
-  for (std::map<std::string, Graph::EdgeMap<double>*>::iterator it =
-      edgemap_storage.begin(); it != edgemap_storage.end(); ++it)
+  for (EdgeMapStore::iterator it = edgemaps.begin(); it != edgemaps.end(); ++it)
   {
-    if ((it->first != "label") &&
-        (it->first != "arrow_pos_x") &&
-        (it->first != "arrow_pos_y"))
-    {
-      delete it->second;
-      edgemap_storage.erase(it);
-    }
-  }
-  for (std::map<std::string, double>::iterator it =
-      nodemap_default.begin(); it != nodemap_default.end(); ++it)
-  {
-    if (it->first != "label")
-      nodemap_default.erase(it);
-  }
-  for (std::map<std::string, double>::iterator it =
-      edgemap_default.begin(); it != edgemap_default.end(); ++it)
-  {
-    if (it->first != "label")
-      edgemap_default.erase(it);
+    delete it->second;
+    edgemaps.erase(it);
   }
   graph.clear();
   file_name = "";
   modified = false;
+  gui_sect_save_dest = LGF_FILE;
+  max_node_label = 0;
+  max_edge_label = 0;
 
-  arrow_pos_read_ok = false;
-  
   for(int i=0;i<NODE_PROPERTY_NUM;i++)
     {
       changeActiveMap(false, i, "");
@@ -652,7 +612,6 @@
   iterations=i_d;
 
   signal_design_win.emit(attraction, propulsation, iterations);
-  */
 }
 
 void MapStorage::mapChanged(bool itisedge, std::string mapname)
@@ -818,18 +777,11 @@
   return edge;
 }
 
-MapStorage::IntegerNodeMap& MapStorage::getIntegerNodeMap(const std::string& name)
-{
-  NodeMapData* data = getNodeMapData(name);
-  if (data->type() != MapValue::INTEGER) throw NonexistentMap();
-  return static_cast<IntegerNodeMapData*>(data)->map;
-}
-
-MapStorage::ScalarNodeMap& MapStorage::getScalarNodeMap(const std::string& name)
+MapStorage::NumericNodeMap& MapStorage::getNumericNodeMap(const std::string& name)
 {
   NodeMapData* data = getNodeMapData(name);
-  if (data->type() != MapValue::SCALAR) throw NonexistentMap();
-  return static_cast<ScalarNodeMapData*>(data)->map;
+  if (data->type() != MapValue::NUMERIC) throw NonexistentMap();
+  return static_cast<NumericNodeMapData*>(data)->map;
 }
 
 MapStorage::StringNodeMap& MapStorage::getStringNodeMap(const std::string& name)
@@ -839,18 +791,11 @@
   return static_cast<StringNodeMapData*>(data)->map;
 }
 
-MapStorage::IntegerEdgeMap& MapStorage::getIntegerEdgeMap(const std::string& name)
-{
-  EdgeMapData* data = getEdgeMapData(name);
-  if (data->type() != MapValue::INTEGER) throw NonexistentMap();
-  return static_cast<IntegerEdgeMapData*>(data)->map;
-}
-
-MapStorage::ScalarEdgeMap& MapStorage::getScalarEdgeMap(const std::string& name)
+MapStorage::NumericEdgeMap& MapStorage::getNumericEdgeMap(const std::string& name)
 {
   EdgeMapData* data = getEdgeMapData(name);
-  if (data->type() != MapValue::SCALAR) throw NonexistentMap();
-  return static_cast<ScalarEdgeMapData*>(data)->map;
+  if (data->type() != MapValue::NUMERIC) throw NonexistentMap();
+  return static_cast<NumericEdgeMapData*>(data)->map;
 }
 
 MapStorage::StringEdgeMap& MapStorage::getStringEdgeMap(const std::string& name)
@@ -989,11 +934,8 @@
     cout << it->first << " ";
     switch (it->second->type())
     {
-      case MapValue::INTEGER:
-        cout << "INTEGER";
-        break;
-      case MapValue::SCALAR:
-        cout << "SCALAR";
+      case MapValue::NUMERIC:
+        cout << "NUMERIC";
         break;
       case MapValue::STRING:
         cout << "STRING";
@@ -1025,11 +967,8 @@
     cout << it->first << " ";
     switch (it->second->type())
     {
-      case MapValue::INTEGER:
-        cout << "INTEGER";
-        break;
-      case MapValue::SCALAR:
-        cout << "SCALAR";
+      case MapValue::NUMERIC:
+        cout << "NUMERIC";
         break;
       case MapValue::STRING:
         cout << "STRING";

Modified: glemon/branches/akos/mapstorage.h
==============================================================================
--- glemon/branches/akos/mapstorage.h	(original)
+++ glemon/branches/akos/mapstorage.h	Thu Oct 25 19:58:25 2007
@@ -58,11 +58,9 @@
   };
 
   enum MapSaveDestination { GUI_SECT, NESET_SECT, DONT_SAVE };
-  typedef Graph::NodeMap<int> IntegerNodeMap;
-  typedef Graph::NodeMap<double> ScalarNodeMap;
+  typedef Graph::NodeMap<double> NumericNodeMap;
   typedef Graph::NodeMap<std::string> StringNodeMap;
-  typedef Graph::EdgeMap<int> IntegerEdgeMap;
-  typedef Graph::EdgeMap<double> ScalarEdgeMap;
+  typedef Graph::EdgeMap<double> NumericEdgeMap;
   typedef Graph::EdgeMap<std::string> StringEdgeMap;
   struct EdgeMapData
   {
@@ -81,24 +79,13 @@
       default_value(def_val)
     {}
   };
-  struct IntegerEdgeMapData : public EdgeMapData
+  struct NumericEdgeMapData : public EdgeMapData
   {
-    IntegerEdgeMap map;
-    MapValue::Type type() { return MapValue::INTEGER; }
+    NumericEdgeMap map;
+    MapValue::Type type() { return MapValue::NUMERIC; }
     MapValue get(Edge e) { return MapValue(map[e]); }
-    void set(Edge e, MapValue v) { map.set(e, v.getAsInt()); }
-    IntegerEdgeMapData(Graph& g, int def_val) :
-      EdgeMapData(MapValue(def_val)),
-      map(g, def_val)
-    {}
-  };
-  struct ScalarEdgeMapData : public EdgeMapData
-  {
-    ScalarEdgeMap map;
-    MapValue::Type type() { return MapValue::SCALAR; }
-    MapValue get(Edge e) { return MapValue(map[e]); }
-    void set(Edge e, MapValue v) { map.set(e, v.getAsDouble()); }
-    ScalarEdgeMapData(Graph& g, double def_val) :
+    void set(Edge e, MapValue v) { map.set(e, static_cast<double>(v)); }
+    NumericEdgeMapData(Graph& g, double def_val) :
       EdgeMapData(MapValue(def_val)),
       map(g, def_val)
     {}
@@ -108,7 +95,7 @@
     StringEdgeMap map;
     MapValue::Type type() { return MapValue::STRING; }
     MapValue get(Edge e) { return MapValue(map[e]); }
-    void set(Edge e, MapValue v) { map.set(e, v.getAsString()); }
+    void set(Edge e, MapValue v) { map.set(e, static_cast<std::string>(v)); }
     StringEdgeMapData(Graph& g, std::string def_val) :
       EdgeMapData(MapValue(def_val)),
       map(g, def_val)
@@ -131,24 +118,13 @@
       default_value(def_val)
     {}
   };
-  struct IntegerNodeMapData : public NodeMapData
-  {
-    IntegerNodeMap map;
-    MapValue::Type type() { return MapValue::INTEGER; }
-    MapValue get(Node e) { return MapValue(map[e]); }
-    void set(Node e, MapValue v) { map.set(e, v.getAsInt()); }
-    IntegerNodeMapData(Graph& g, int def_val) :
-      NodeMapData(MapValue(def_val)),
-      map(g, def_val)
-    {}
-  };
-  struct ScalarNodeMapData : public NodeMapData
+  struct NumericNodeMapData : public NodeMapData
   {
-    ScalarNodeMap map;
-    MapValue::Type type() { return MapValue::SCALAR; }
+    NumericNodeMap map;
+    MapValue::Type type() { return MapValue::NUMERIC; }
     MapValue get(Node e) { return MapValue(map[e]); }
-    void set(Node e, MapValue v) { map.set(e, v.getAsDouble()); }
-    ScalarNodeMapData(Graph& g, double def_val) :
+    void set(Node e, MapValue v) { map.set(e, static_cast<double>(v)); }
+    NumericNodeMapData(Graph& g, double def_val) :
       NodeMapData(MapValue(def_val)),
       map(g, def_val)
     {}
@@ -158,7 +134,7 @@
     StringNodeMap map;
     MapValue::Type type() { return MapValue::STRING; }
     MapValue get(Node e) { return MapValue(map[e]); }
-    void set(Node e, MapValue v) { map.set(e, v.getAsString()); }
+    void set(Node e, MapValue v) { map.set(e, static_cast<std::string>(v)); }
     StringNodeMapData(Graph& g, std::string def_val) :
       NodeMapData(MapValue(def_val)),
       map(g, def_val)
@@ -368,11 +344,9 @@
   Node addNode(XY);
   Edge addEdge(Node, Node);
 
-  IntegerNodeMap& getIntegerNodeMap(const std::string& name);
-  ScalarNodeMap& getScalarNodeMap(const std::string& name);
+  NumericNodeMap& getNumericNodeMap(const std::string& name);
   StringNodeMap& getStringNodeMap(const std::string& name);
-  IntegerEdgeMap& getIntegerEdgeMap(const std::string& name);
-  ScalarEdgeMap& getScalarEdgeMap(const std::string& name);
+  NumericEdgeMap& getNumericEdgeMap(const std::string& name);
   StringEdgeMap& getStringEdgeMap(const std::string& name);
 
   MapValueEdgeMap getEdgeMap(const std::string& name);

Modified: glemon/branches/akos/new_map_win.cc
==============================================================================
--- glemon/branches/akos/new_map_win.cc	(original)
+++ glemon/branches/akos/new_map_win.cc	Thu Oct 25 19:58:25 2007
@@ -46,12 +46,10 @@
   (*table).attach(name,1,2,0,1,Gtk::SHRINK,Gtk::SHRINK,10,3);
 
   lblType.set_label("Element type:");
-  if (map_type & INT)
-    cbType.append_text("integer");
-  if (map_type & SCAL)
-    cbType.append_text("scalar");
+  if (map_type & NUM)
+    cbType.append_text("Numeric");
   if (map_type & STR)
-    cbType.append_text("string");
+    cbType.append_text("String");
 
   (*table).attach(lblType,0,1,1,2,Gtk::SHRINK,Gtk::SHRINK,10,3);
   (*table).attach(cbType, 1,2,1,2,Gtk::SHRINK,Gtk::SHRINK,10,3);
@@ -97,7 +95,7 @@
 
 void NewMapWin::setErrorMsg(const Glib::ustring& msg)
 {
-  lblErrorMsg.set_markup("<i><small>" + msg + "</i></small>");
+  lblErrorMsg.set_markup("<i><small>" + msg + "</small></i>");
 }
 
 std::vector<double>* NewMapWin::evaluate_expr(const std::string polishform)
@@ -125,7 +123,7 @@
         default:
           //substitute variable
           std::vector<std::string> ems =
-            mytab.mapstorage.getEdgeMapList(MapType(INT | SCAL));
+            mytab.mapstorage.getEdgeMapList(NUM);
           bool itisvar=(std::find(ems.begin(), ems.end(), ch2var[ polishform[i] ]) != ems.end());
           if(itisvar)
           {
@@ -199,19 +197,7 @@
     }
 
     Glib::ustring text = cbType.get_active_text();
-    if (text == "integer")
-    {
-      // TODO
-      int i;
-      i = atoi(def_val.c_str());
-      if (edge.get_active())
-        mytab.mapstorage.createEdgeMap(map_name, MapValue::INTEGER,
-            MapValue(i));
-      else
-        mytab.mapstorage.createNodeMap(map_name, MapValue::INTEGER,
-            MapValue(i));
-    }
-    else if (text == "scalar")
+    if (text == "Numeric")
     {
       double d;
       char *endptr;
@@ -220,20 +206,20 @@
       {
         // the full string was a number
         if (edge.get_active())
-          mytab.mapstorage.createEdgeMap(map_name, MapValue::SCALAR,
+          mytab.mapstorage.createEdgeMap(map_name, MapValue::NUMERIC,
               MapValue(d));
         else
-          mytab.mapstorage.createNodeMap(map_name, MapValue::SCALAR,
+          mytab.mapstorage.createNodeMap(map_name, MapValue::NUMERIC,
               MapValue(d));
       }
       else
       {
         // TODO
         if (edge.get_active())
-          mytab.mapstorage.createEdgeMap(map_name, MapValue::SCALAR,
+          mytab.mapstorage.createEdgeMap(map_name, MapValue::NUMERIC,
               MapValue(0.0));
         else
-          mytab.mapstorage.createNodeMap(map_name, MapValue::SCALAR,
+          mytab.mapstorage.createNodeMap(map_name, MapValue::NUMERIC,
               MapValue(0.0));
         // let't try to evaluate the string as an arithmetic expression
         /*
@@ -241,7 +227,7 @@
         values = evaluate_expr(string2Polishform(def_val, edge.get_active()));
         if (edge.get_active())
         {
-          mytab.mapstorage.createEdgeMap(map_name, MapValue::SCALAR,
+          mytab.mapstorage.createEdgeMap(map_name, MapValue::NUMERIC,
               MapValue(d));
           std::vector<double>::const_iterator vit = values->begin();
           for (NodeIt it(mytab.mapstorage.graph); it != INVALID; ++it)
@@ -252,7 +238,7 @@
         }
         else
         {
-          mytab.mapstorage.createNodeMap(map_name, MapValue::SCALAR,
+          mytab.mapstorage.createNodeMap(map_name, MapValue::NUMERIC,
               MapValue(d));
           std::vector<double>::const_iterator vit = values->begin();
           for (NodeIt it(mytab.mapstorage.graph); it != INVALID; ++it)
@@ -265,7 +251,7 @@
         */
       }
     }
-    else if (text == "string")
+    else if (text == "String")
     {
       if (edge.get_active())
         mytab.mapstorage.createEdgeMap(map_name, MapValue::STRING,
@@ -683,13 +669,13 @@
   if(itisedge)
   {
     std::vector<std::string> edge_maps =
-      mytab.mapstorage.getEdgeMapList(MapType(INT | SCAL));
+      mytab.mapstorage.getEdgeMapList(NUM);
     cancel=(std::find(edge_maps.begin(), edge_maps.end(), variable)==edge_maps.end());
   }
   else
   {
     std::vector<std::string> node_maps =
-      mytab.mapstorage.getNodeMapList(MapType(INT | SCAL));
+      mytab.mapstorage.getNodeMapList(NUM);
     cancel=(std::find(node_maps.begin(), node_maps.end(), variable)==node_maps.end());
   }
   //maybe it is number



More information about the Lemon-commits mailing list