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

Lemon SVN svn at lemon.cs.elte.hu
Fri Oct 26 10:04:07 CEST 2007


Author: ladanyi
Date: Fri Oct 26 10:03:58 2007
New Revision: 3347

Modified:
   glemon/branches/akos/Makefile.am
   glemon/branches/akos/gui_reader.cc
   glemon/branches/akos/gui_reader.h
   glemon/branches/akos/gui_writer.cc
   glemon/branches/akos/io_helper.h
   glemon/branches/akos/map_value.h
   glemon/branches/akos/mapstorage.cc
   glemon/branches/akos/mapstorage.h

Log:
Loading files saved by glemon should work now.

Modified: glemon/branches/akos/Makefile.am
==============================================================================
--- glemon/branches/akos/Makefile.am	(original)
+++ glemon/branches/akos/Makefile.am	Fri Oct 26 10:03:58 2007
@@ -58,7 +58,9 @@
 	save_details_widget.h \
 	save_details_widget.cc \
 	save_details_dialog.h \
-	save_details_dialog.cc
+	save_details_dialog.cc \
+	io_helper.h \
+	io_helper.cc
 
 glemon_CXXFLAGS = $(GTK_CFLAGS) $(LEMON_CFLAGS)
 # glemon_LDFLAGS = $(GTK_LIBS) $(LEMON_LIBS)

Modified: glemon/branches/akos/gui_reader.cc
==============================================================================
--- glemon/branches/akos/gui_reader.cc	(original)
+++ glemon/branches/akos/gui_reader.cc	Fri Oct 26 10:03:58 2007
@@ -19,6 +19,7 @@
 #include "gui_reader.h"
 #include "xml.h"
 #include "mapstorage.h"
+#include "io_helper.h"
 #include <lemon/dim2.h>
 #include <vector>
 
@@ -32,20 +33,79 @@
 
 void GuiReader::read(std::istream& is)
 {
+  using std::vector;
+  using std::string;
+  using std::pair;
+  using std::make_pair;
+  using std::string;
+  using std::map;
+
   XmlIo x(is);
-  std::map<int, XY > m;
-  x("arrow_pos", m);
 
-  if ((int)m.size() == countEdges(mapstorage->graph))
+  { x("main_node_map_names", gui_data.main_node_map_names); }
+  { x("gui_node_map_names", gui_data.gui_node_map_names); }
+
+  { x("node_map_types", gui_data.node_map_types); }
+
+  { x("main_edge_map_names", gui_data.main_edge_map_names); }
+  { x("gui_edge_map_names", gui_data.gui_edge_map_names); }
+
+  { x("edge_map_types", gui_data.edge_map_types); }
+
+  for (vector<string>::const_iterator it = gui_data.gui_node_map_names.begin();
+      it != gui_data.gui_node_map_names.end(); ++it)
   {
-    for (EdgeIt e(mapstorage->graph); e != INVALID; ++e)
+    MapValue::Type type = gui_data.node_map_types[*it];
+    switch (type)
     {
-      int edgeid = (int) mapstorage->getLabel(e);
-      mapstorage->setArrowCoords(e, m[edgeid]);
+      case MapValue::NUMERIC:
+        {
+          vector<pair<int, double> >* p_map_data =
+            new vector<pair<int, double> >;
+          gui_data.numeric_node_maps[*it] = p_map_data;
+          { x(*it, *p_map_data); }
+        }
+        break;
+      case MapValue::STRING:
+        {
+          vector<pair<int, string> >* p_map_data =
+            new vector<pair<int, string> >;
+          gui_data.string_node_maps[*it] = p_map_data;
+          { x(*it, *p_map_data); }
+        }
+        break;
     }
-    //mapstorage->ArrowPosReadOK();
   }
 
+  for (vector<string>::const_iterator it = gui_data.gui_edge_map_names.begin();
+      it != gui_data.gui_edge_map_names.end(); ++it)
+  {
+    MapValue::Type type = gui_data.edge_map_types[*it];
+    switch (type)
+    {
+      case MapValue::NUMERIC:
+        {
+          vector<pair<int, double> >* p_map_data =
+            new vector<pair<int, double> >;
+          gui_data.numeric_edge_maps[*it] = p_map_data;
+          { x(*it, *p_map_data); }
+        }
+        break;
+      case MapValue::STRING:
+        {
+          vector<pair<int, string> >* p_map_data =
+            new vector<pair<int, string> >;
+          gui_data.string_edge_maps[*it] = p_map_data;
+          { x(*it, *p_map_data); }
+        }
+        break;
+    }
+  }
+
+
+
+
+  /*
   std::map<int, std::string> nm;
   x("active_nodemaps", nm);
 
@@ -74,8 +134,11 @@
   mapstorage->set_iteration(iteration);
 
   mapstorage->redesign_data_changed();
+  */
 }
 
-GuiReader::GuiReader(LemonReader& reader, MapStorage* ms) : Parent(reader), mapstorage(ms)
+GuiReader::GuiReader(LemonReader& reader, MapStorage::GUISectData& _gui_data) :
+  Parent(reader),
+  gui_data(_gui_data)
 {
 }

Modified: glemon/branches/akos/gui_reader.h
==============================================================================
--- glemon/branches/akos/gui_reader.h	(original)
+++ glemon/branches/akos/gui_reader.h	Fri Oct 26 10:03:58 2007
@@ -27,13 +27,13 @@
 class GuiReader : public LemonReader::SectionReader
 {
   private:
-    MapStorage* mapstorage;
+    MapStorage::GUISectData& gui_data;
   protected:
     virtual bool header(const std::string&);
     virtual void read(std::istream&);
   public:
     typedef LemonReader::SectionReader Parent;
-    GuiReader(LemonReader&, MapStorage*);
+    GuiReader(LemonReader&, MapStorage::GUISectData&);
 };
 
 #endif

Modified: glemon/branches/akos/gui_writer.cc
==============================================================================
--- glemon/branches/akos/gui_writer.cc	(original)
+++ glemon/branches/akos/gui_writer.cc	Fri Oct 26 10:03:58 2007
@@ -31,135 +31,141 @@
 {
   using std::vector;
   using std::string;
+  using std::map;
+  using std::string;
 
   XmlIo x(os);
 
   vector<string> all_node_map_names = mapstorage->getNodeMapList();
-  vector<string> node_map_names; // name of the maps need to be saved
+  // name of the maps saved to the nodeset section
+  vector<string> main_node_map_names;
+  // name of the maps saved to the gui section
+  vector<string> gui_node_map_names;
 
-  // collect the maps that need to be saved
   for (vector<string>::const_iterator it = all_node_map_names.begin();
       it != all_node_map_names.end(); ++it)
   {
-    if (mapstorage->getNodeMapSaveDest(*it) != MapStorage::DONT_SAVE)
-      node_map_names.push_back(*it);
+    if (mapstorage->getNodeMapSaveDest(*it) == MapStorage::NESET_SECT)
+      main_node_map_names.push_back(*it);
+    else if (mapstorage->getNodeMapSaveDest(*it) == MapStorage::GUI_SECT)
+      gui_node_map_names.push_back(*it);
   }
 
-  // write node map names
-  { x("node_map_names", node_map_names); }
+  { x("main_node_map_names", main_node_map_names); }
+  { x("gui_node_map_names", gui_node_map_names); }
 
-  vector<MapValue::Type> node_map_types;
-  for (vector<string>::const_iterator it = node_map_names.begin();
-      it != node_map_names.end(); ++it)
+  map<string, MapValue::Type> node_map_types;
+  for (vector<string>::const_iterator it = main_node_map_names.begin();
+      it != main_node_map_names.end(); ++it)
   {
-    node_map_types.push_back(mapstorage->getNodeMapElementType(*it));
+    node_map_types[*it] = mapstorage->getNodeMapElementType(*it);
+  }
+  for (vector<string>::const_iterator it = gui_node_map_names.begin();
+      it != gui_node_map_names.end(); ++it)
+  {
+    node_map_types[*it] = mapstorage->getNodeMapElementType(*it);
   }
 
-  // write node map types
   { x("node_map_types", node_map_types); }
 
 
   vector<string> all_edge_map_names = mapstorage->getEdgeMapList();
-  vector<string> edge_map_names; // name of the maps need to be saved
+  // name of the maps saved to the edgeset section
+  vector<string> main_edge_map_names;
+  // name of the maps saved to the gui section
+  vector<string> gui_edge_map_names;
 
-  // collect the maps that need to be saved
   for (vector<string>::const_iterator it = all_edge_map_names.begin();
       it != all_edge_map_names.end(); ++it)
   {
-    if (mapstorage->getEdgeMapSaveDest(*it) != MapStorage::DONT_SAVE)
-      edge_map_names.push_back(*it);
+    if (mapstorage->getEdgeMapSaveDest(*it) == MapStorage::NESET_SECT)
+      main_edge_map_names.push_back(*it);
+    if (mapstorage->getEdgeMapSaveDest(*it) == MapStorage::GUI_SECT)
+      gui_edge_map_names.push_back(*it);
   }
 
-  // write edge map names
-  { x("edge_map_names", edge_map_names); }
+  { x("main_edge_map_names", main_edge_map_names); }
+  { x("gui_edge_map_names", gui_edge_map_names); }
 
-  vector<MapValue::Type> edge_map_types;
-  for (vector<string>::const_iterator it = edge_map_names.begin();
-      it != edge_map_names.end(); ++it)
+  map<string, MapValue::Type> edge_map_types;
+  for (vector<string>::const_iterator it = main_edge_map_names.begin();
+      it != main_edge_map_names.end(); ++it)
   {
-    edge_map_types.push_back(mapstorage->getEdgeMapElementType(*it));
+    edge_map_types[*it] = mapstorage->getEdgeMapElementType(*it);
   }
-
-  // write edge map types
-  { x("edge_map_types", edge_map_types); }
-
-
-  // collect the names of the node maps that are saved to the gui section
-  vector<string> gui_node_map_names;
-  for (vector<string>::const_iterator it = all_node_map_names.begin();
-      it != all_node_map_names.end(); ++it)
+  for (vector<string>::const_iterator it = gui_edge_map_names.begin();
+      it != gui_edge_map_names.end(); ++it)
   {
-    if (mapstorage->getNodeMapSaveDest(*it) == MapStorage::GUI_SECT)
-      gui_node_map_names.push_back(*it);
+    edge_map_types[*it] = mapstorage->getEdgeMapElementType(*it);
   }
 
-  // write the names
-  { x("gui_node_map_names", gui_node_map_names); }
+  { x("edge_map_types", edge_map_types); }
 
-  // write the maps
+  // write the gui node maps
   for (vector<string>::const_iterator it = gui_node_map_names.begin();
       it != gui_node_map_names.end(); ++it)
   {
     MapValue::Type type = mapstorage->getNodeMapElementType(*it);
+    const MapStorage::NodeLabelMap& labels = mapstorage->getNodeLabelMap();
     switch (type)
     {
       case MapValue::NUMERIC:
         {
-          NodeData<double> data(
-              mapstorage->graph,
-              mapstorage->getNodeLabelMap(),
-              mapstorage->getNumericNodeMap(*it));
-          { x(*it, data); }
+          std::vector<std::pair<int, double> > map_data;
+          MapStorage::NumericNodeMap& map =
+            mapstorage->getNumericNodeMap(*it);
+          for (NodeIt n(mapstorage->getGraph()); n != INVALID; ++n)
+          {
+            map_data.push_back(std::make_pair(labels[n], map[n]));
+          }
+          { x(*it, map_data); }
         }
         break;
       case MapValue::STRING:
         {
-          NodeData<string> data(
-              mapstorage->graph,
-              mapstorage->getNodeLabelMap(),
-              mapstorage->getStringNodeMap(*it));
-          { x(*it, data); }
+          std::vector<std::pair<int, std::string> > map_data;
+          MapStorage::StringNodeMap& map =
+            mapstorage->getStringNodeMap(*it);
+          for (NodeIt n(mapstorage->getGraph()); n != INVALID; ++n)
+          {
+            map_data.push_back(std::make_pair(labels[n], map[n]));
+          }
+          { x(*it, map_data); }
         }
         break;
     }
   }
 
-
-  // collect the names of the edge maps that are saved to the gui section
-  vector<string> gui_edge_map_names;
-  for (vector<string>::const_iterator it = all_edge_map_names.begin();
-      it != all_edge_map_names.end(); ++it)
-  {
-    if (mapstorage->getEdgeMapSaveDest(*it) == MapStorage::GUI_SECT)
-      gui_edge_map_names.push_back(*it);
-  }
-
-  // write the names
-  { x("gui_edge_map_names", gui_edge_map_names); }
-
-  // write the maps
+  // write the gui edge maps
   for (vector<string>::const_iterator it = gui_edge_map_names.begin();
       it != gui_edge_map_names.end(); ++it)
   {
     MapValue::Type type = mapstorage->getEdgeMapElementType(*it);
+    const MapStorage::EdgeLabelMap& labels = mapstorage->getEdgeLabelMap();
     switch (type)
     {
       case MapValue::NUMERIC:
         {
-          EdgeData<double> data(
-              mapstorage->graph,
-              mapstorage->getEdgeLabelMap(),
-              mapstorage->getNumericEdgeMap(*it));
-          { x(*it, data); }
+          std::vector<std::pair<int, double> > map_data;
+          MapStorage::NumericEdgeMap& map =
+            mapstorage->getNumericEdgeMap(*it);
+          for (EdgeIt e(mapstorage->getGraph()); e != INVALID; ++e)
+          {
+            map_data.push_back(std::make_pair(labels[e], map[e]));
+          }
+          { x(*it, map_data); }
         }
         break;
       case MapValue::STRING:
         {
-          EdgeData<string> data(
-              mapstorage->graph,
-              mapstorage->getEdgeLabelMap(),
-              mapstorage->getStringEdgeMap(*it));
-          { x(*it, data); }
+          std::vector<std::pair<int, std::string> > map_data;
+          MapStorage::StringEdgeMap& map =
+            mapstorage->getStringEdgeMap(*it);
+          for (EdgeIt e(mapstorage->getGraph()); e != INVALID; ++e)
+          {
+            map_data.push_back(std::make_pair(labels[e], map[e]));
+          }
+          { x(*it, map_data); }
         }
         break;
     }

Modified: glemon/branches/akos/io_helper.h
==============================================================================
--- glemon/branches/akos/io_helper.h	(original)
+++ glemon/branches/akos/io_helper.h	Fri Oct 26 10:03:58 2007
@@ -1,132 +1,11 @@
 #ifndef IO_HELPER
 #define IO_HELPER
 
-#include "all_include.h"
 #include "xml.h"
 #include "map_value.h"
 
-template<class T>
-struct NodeData
-{
-  const Graph& graph;
-  const Graph::NodeMap<int>& label;
-  const Graph::NodeMap<T>& map;
-  NodeData(const Graph& _graph, const Graph::NodeMap<int>& _label,
-      const Graph::NodeMap<T>& _map) :
-    graph(_graph),
-    label(_label),
-    map(_map)
-  {}
-};
-
-template<class T>
-struct EdgeData
-{
-  const Graph& graph;
-  const Graph::EdgeMap<int>& label;
-  const Graph::EdgeMap<T>& map;
-  EdgeData(const Graph& _graph, const Graph::EdgeMap<int>& _label,
-      const Graph::EdgeMap<T>& _map) :
-    graph(_graph),
-    label(_label),
-    map(_map)
-  {}
-};
-
 namespace lemon {
-  template<class T>
-  void xml(XmlIo &x, NodeData<T> &v)
-  {
-    for (NodeIt n(v.graph); n != INVALID; ++n)
-    {
-      { XmlIo::LineTag t(x,"label"); x(v.label[n]); }
-      { XmlIo::ContTag t(x,"value"); x(v.map[n]); }
-    }
-  }
-
-  template<class T>
-  void xml(XmlIo &x, EdgeData<T> &v)
-  {
-    for (EdgeIt e(v.graph); e != INVALID; ++e)
-    {
-      { XmlIo::LineTag t(x,"from"); x(v.label[e]); }
-      { XmlIo::ContTag t(x,"value"); x(v.map[e]); }
-    }
-  }
-
-  void xml(XmlIo &x, MapValue::Type& v)
-  {
-    if(x.write()) {
-      switch (v)
-      {
-        case MapValue::NUMERIC:
-          { x("type", std::string("numeric")); }
-          break;
-        case MapValue::STRING:
-          { x("type", std::string("string")); }
-          break;
-      }
-    }
-    else {
-      std::string type;
-      { x("type", type); }
-      if (type == "numeric")
-      {
-        v = MapValue::NUMERIC;
-      }
-      else if (type == "string")
-      {
-        v = MapValue::STRING;
-      }
-      else
-      {
-        throw DataFormatError("Bad format");
-      }
-    }
-  }
-
-  /*
-  void xml(XmlIo &x, MapValue& v)
-  {
-    if(x.write()) {
-      switch (v.getType())
-      {
-        case MapValue::NUMERIC:
-          { x("type", "numeric"); }
-          { x("value", static_cast<double>(v)); }
-          break;
-        case MapValue::STRING:
-          { x("type", "string"); }
-          { x("value", static_cast<std::string>(v)); }
-          break;
-      }
-    }
-    else {
-      std::string type;
-      { x("type", type); }
-      if (type == "numeric")
-      {
-        double d;
-        { x("value", d); }
-        v = d;
-      }
-      else if (type == "string")
-      {
-        std::string s;
-        { x("value", s); }
-        v = s;
-      }
-      else {//TODO}
-
-      v.clear();
-      while(x.nextTag()=="point") {
-        lemon::dim2::Point<T> co;
-        x("point",co);
-        v.add(co);
-      }
-    }
-  }
-  */
+  void xml(XmlIo &x, MapValue::Type& v);
 };
 
 #endif

Modified: glemon/branches/akos/map_value.h
==============================================================================
--- glemon/branches/akos/map_value.h	(original)
+++ glemon/branches/akos/map_value.h	Fri Oct 26 10:03:58 2007
@@ -4,7 +4,6 @@
 #include <exception>
 #include <functional>
 #include <iosfwd>
-//#include <lemon/tolerance.h>
 
 class MapValue
 {

Modified: glemon/branches/akos/mapstorage.cc
==============================================================================
--- glemon/branches/akos/mapstorage.cc	(original)
+++ glemon/branches/akos/mapstorage.cc	Fri Oct 26 10:03:58 2007
@@ -219,17 +219,20 @@
 
 int MapStorage::readFromFile(const std::string &filename)
 {
+  using std::vector;
+  using std::string;
+
   // check whether the .conf file exists
-  bool conf_file_exists = g_file_test((filename + ".conf").c_str(),
+  bool gui_data_in_conf = g_file_test((filename + ".conf").c_str(),
       (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR));
 
-  if (conf_file_exists)
-    std::cerr << ".conf: exists" << std::endl;
+  if (gui_data_in_conf)
+    std::cerr << filename << ".conf file exists" << std::endl;
   else
-    std::cerr << ".conf: not found" << std::endl;
+    std::cerr << filename << ".conf file not found" << std::endl;
 
-  // check whether the file contains a gui section
-  bool gui_section_exists = false;
+  // check whether the .lgf file contains a gui section
+  bool gui_data_in_lgf = false;
   {
     std::ifstream ifs(filename.c_str());
     std::string line;
@@ -247,19 +250,21 @@
             break;
           }
         }
-        if (only_whitespace_before) gui_section_exists = true;
+        if (only_whitespace_before) gui_data_in_lgf = true;
       }
     }
   }
 
-  if (gui_section_exists)
-    std::cerr << "gui section: exists" << std::endl;
+  if (gui_data_in_lgf)
+    std::cerr << "found gui section in " << filename << ".lgf" << std::endl;
   else
-    std::cerr << "gui section: not found" << std::endl;
+    std::cerr << "no gui section in " << filename << ".lgf" << std::endl;
+
+  bool gui_data_found = gui_data_in_lgf || gui_data_in_conf;
 
   // ask for user input if both exist
-  bool prefer_gui_section = false;
-  if (conf_file_exists && gui_section_exists)
+  bool use_gui_data_in_lgf = false;
+  if (gui_data_in_conf && gui_data_in_lgf)
   {
     Gtk::MessageDialog mdialog(_("<b>Found both ") + filename +
         _(".conf and a gui section in ") + filename + _(".</b>"), true,
@@ -269,27 +274,125 @@
     switch (mdialog.run())
     {
       case 1:
-        prefer_gui_section = false;
+        use_gui_data_in_lgf = false;
         break;
       case 2:
-        prefer_gui_section = true;
+        use_gui_data_in_lgf = true;
         break;
       case Gtk::RESPONSE_NONE:
         return 1;
     }
   }
-
-  if (prefer_gui_section)
-    std::cerr << "prefer gui section: yes" << std::endl;
   else
-    std::cerr << "prefer gui section: no" << std::endl;
-
+  {
+    use_gui_data_in_lgf = gui_data_in_lgf;
+  }
 
+  /*
   {
     FileImportDialog fidialog;
     fidialog.run();
   }
+  */
+
+  if (gui_data_found)
+  {
+    GUISectData gui_data;
+    if (use_gui_data_in_lgf)
+    {
+      // read the gui section from the .lgf file
+      try
+      {
+        std::cerr << "reading gui section form file " << filename << std::endl;
+        LemonReader lreader(filename);
+        GuiReader gui_reader(lreader, gui_data);
+        lreader.run();
+      }
+      catch (Exception& error)
+      {
+        std::cerr << "reading gui section from file " << filename << "failed"
+          << std::endl;
+        clear();
+        return 1;
+      }
+    }
+    else
+    {
+      // read the gui section from the .conf file
+      try
+      {
+        std::cerr << "reading " << filename << ".conf file" << std::endl;
+        LemonReader lreader(filename + ".conf");
+        GuiReader gui_reader(lreader, gui_data);
+        lreader.run();
+      }
+      catch (Exception& error)
+      {
+        std::cerr << "reading " << filename << ".conf file failed" << std::endl;
+        clear();
+        return 1;
+      }
+    }
 
+    // read the graph and maps form the .lgf file
+    try
+    {
+      std::cerr << "reading the graph and maps form " << filename
+        << ".lgf file" << std::endl;
+      GraphReader<Graph> greader(filename, graph);
+      for (vector<string>::const_iterator
+          it = gui_data.main_node_map_names.begin();
+          it != gui_data.main_node_map_names.end(); ++it)
+      {
+        switch (gui_data.node_map_types[*it])
+        {
+          case MapValue::NUMERIC:
+            {
+              createNodeMap(*it, MapValue::NUMERIC, double());
+              greader.readNodeMap(*it, getNumericNodeMap(*it));
+              break;
+            }
+          case MapValue::STRING:
+            {
+              createNodeMap(*it, MapValue::STRING, string());
+              greader.readNodeMap(*it, getStringNodeMap(*it));
+              break;
+            }
+        }
+      }
+      for (vector<string>::const_iterator
+          it = gui_data.main_edge_map_names.begin();
+          it != gui_data.main_edge_map_names.end(); ++it)
+      {
+        switch (gui_data.edge_map_types[*it])
+        {
+          case MapValue::NUMERIC:
+            {
+              createEdgeMap(*it, MapValue::NUMERIC, double());
+              greader.readEdgeMap(*it, getNumericEdgeMap(*it));
+              break;
+            }
+          case MapValue::STRING:
+            {
+              createEdgeMap(*it, MapValue::STRING, string());
+              greader.readEdgeMap(*it, getStringEdgeMap(*it));
+              break;
+            }
+        }
+      }
+      greader.run();
+    }
+    catch (Exception& error)
+    {
+      clear();
+      return 1;
+    }
+  }
+  else
+  {
+    // there is no gui section neither in the .lgf file nor in the .conf file
+    // TODO
+  }
 
 
 
@@ -366,16 +469,16 @@
         greader.readEdgeMap(*it, *edgemap_storage[*it]);
       }
     }
-    if ((gui_section_exists && !conf_file_exists) ||
-        (gui_section_exists && conf_file_exists && prefer_gui_section))
+    if ((gui_data_in_lgf && !gui_data_in_conf) ||
+        (gui_data_in_lgf && gui_data_in_conf && use_gui_data_in_lgf))
     {
       std::cerr << "reading gui section" << std::endl;
       GuiReader gui_reader(greader, this);
     }
     greader.run();
 
-    if ((!gui_section_exists && conf_file_exists) ||
-        (gui_section_exists && conf_file_exists && !prefer_gui_section))
+    if ((!gui_data_in_lgf && gui_data_in_conf) ||
+        (gui_data_in_lgf && gui_data_in_conf && !use_gui_data_in_lgf))
     {
       std::cerr << "reading .conf file" << std::endl;
       LemonReader lreader(filename + ".conf");
@@ -508,7 +611,27 @@
 
 
   // set max_node_label
+  {
+    max_node_label = std::numeric_limits<int>::min();
+    for (NodeIt n(graph); n != INVALID; ++n)
+    {
+      if (node_label[n] > max_node_label)
+      {
+        max_node_label = node_label[n];
+      }
+    }
+  }
   // set max_edge_label
+  {
+    max_edge_label = std::numeric_limits<int>::min();
+    for (EdgeIt e(graph); e != INVALID; ++e)
+    {
+      if (edge_label[e] > max_edge_label)
+      {
+        max_edge_label = edge_label[e];
+      }
+    }
+  }
 
   return 0;
 }

Modified: glemon/branches/akos/mapstorage.h
==============================================================================
--- glemon/branches/akos/mapstorage.h	(original)
+++ glemon/branches/akos/mapstorage.h	Fri Oct 26 10:03:58 2007
@@ -21,6 +21,9 @@
 
 class Mapstorage;
 
+#include <vector>
+#include <map>
+#include <string>
 #include "all_include.h"
 #include "xymap.h"
 #include <libgnomecanvasmm.h>
@@ -62,6 +65,8 @@
   typedef Graph::NodeMap<std::string> StringNodeMap;
   typedef Graph::EdgeMap<double> NumericEdgeMap;
   typedef Graph::EdgeMap<std::string> StringEdgeMap;
+  typedef Graph::NodeMap<int> NodeLabelMap;
+  typedef Graph::EdgeMap<int> EdgeLabelMap;
   struct EdgeMapData
   {
     /// where to save the map
@@ -141,7 +146,56 @@
     {}
   };
   enum GuiSectSaveDestination { LGF_FILE, CONF_FILE };
+  struct GUISectData
+  {
+    std::vector<std::string> main_node_map_names;
+    std::vector<std::string> main_edge_map_names;
+
+    std::vector<std::string> gui_node_map_names;
+    std::vector<std::string> gui_edge_map_names;
+
+    std::map<std::string, MapValue::Type> node_map_types;
+    std::map<std::string, MapValue::Type> edge_map_types;
+
+    std::map<std::string,
+      std::vector<std::pair<int, double> >* > numeric_node_maps;
+    std::map<std::string,
+      std::vector<std::pair<int, std::string> >* > string_node_maps;
+
+    std::map<std::string,
+      std::vector<std::pair<int, double> >* > numeric_edge_maps;
+    std::map<std::string,
+      std::vector<std::pair<int, std::string> >* > string_edge_maps;
 
+    ~GUISectData()
+    {
+      using std::map;
+      using std::vector;
+      using std::pair;
+      using std::string;
+
+      for (map<string, vector<pair<int, double> >* >::iterator it =
+          numeric_node_maps.begin(); it != numeric_node_maps.end(); ++it)
+      {
+        delete it->second;
+      }
+      for (map<string, vector<pair<int, string> >* >::iterator it =
+          string_node_maps.begin(); it != string_node_maps.end(); ++it)
+      {
+        delete it->second;
+      }
+      for (map<string, vector<pair<int, double> >* >::iterator it =
+          numeric_edge_maps.begin(); it != numeric_edge_maps.end(); ++it)
+      {
+        delete it->second;
+      }
+      for (map<string, vector<pair<int, string> >* >::iterator it =
+          string_edge_maps.begin(); it != string_edge_maps.end(); ++it)
+      {
+        delete it->second;
+      }
+    }
+  };
 public:
   ///The graph for which the datas are stored.
   Graph graph;
@@ -161,9 +215,7 @@
   Graph::EdgeMap<double> arrow_x_coord;
   Graph::EdgeMap<double> arrow_y_coord;
 
-  typedef Graph::NodeMap<int> NodeLabelMap;
   NodeLabelMap node_label;
-  typedef Graph::EdgeMap<int> EdgeLabelMap;
   EdgeLabelMap edge_label;
 
   /// the coordinates of the nodes



More information about the Lemon-commits mailing list