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

Lemon SVN svn at lemon.cs.elte.hu
Wed Apr 18 22:30:37 CEST 2007


Author: ladanyi
Date: Wed Apr 18 22:30:36 2007
New Revision: 3258

Modified:
   glemon/branches/akos/algobox.cc
   glemon/branches/akos/gui_reader.cc
   glemon/branches/akos/gui_writer.cc
   glemon/branches/akos/io_helper.h
   glemon/branches/akos/map_value.cc
   glemon/branches/akos/map_value.h
   glemon/branches/akos/map_win.cc
   glemon/branches/akos/map_win.h
   glemon/branches/akos/mapselector.cc
   glemon/branches/akos/mapselector.h
   glemon/branches/akos/nbtab.cc
   glemon/branches/akos/new_map_win.cc

Log:
MapType and other improvements.


Modified: glemon/branches/akos/algobox.cc
==============================================================================
--- glemon/branches/akos/algobox.cc	(original)
+++ glemon/branches/akos/algobox.cc	Wed Apr 18 22:30:36 2007
@@ -156,9 +156,7 @@
 
 void AlgoBox::addMapSelector(std::string inputname, bool itisedge, MapType type)
 {
-  std::vector<std::string> empty_vector;
-
-  MapSelector * msp=new MapSelector(empty_vector,"",inputname,itisedge, false, type);
+  MapSelector * msp=new MapSelector(inputname,itisedge, false, type);
 
   if(itisedge)
     {

Modified: glemon/branches/akos/gui_reader.cc
==============================================================================
--- glemon/branches/akos/gui_reader.cc	(original)
+++ glemon/branches/akos/gui_reader.cc	Wed Apr 18 22:30:36 2007
@@ -43,7 +43,7 @@
       int edgeid = (int) mapstorage->getLabel(e);
       mapstorage->setArrowCoords(e, m[edgeid]);
     }
-    mapstorage->ArrowPosReadOK();
+    //mapstorage->ArrowPosReadOK();
   }
 
   std::map<int, std::string> nm;

Modified: glemon/branches/akos/gui_writer.cc
==============================================================================
--- glemon/branches/akos/gui_writer.cc	(original)
+++ glemon/branches/akos/gui_writer.cc	Wed Apr 18 22:30:36 2007
@@ -42,14 +42,14 @@
   for (vector<string>::const_iterator it = all_node_map_names.begin();
       it != all_node_map_names.end(); ++it)
   {
-    if (mapstorage->getNodeMapSaveDest() != MapStorage::DONT_SAVE)
+    if (mapstorage->getNodeMapSaveDest(*it) != MapStorage::DONT_SAVE)
       node_map_names.push_back(*it);
   }
 
   // write node map names
-  { x("node_map_names" node_map_names); }
+  { x("node_map_names", node_map_names); }
 
-  vector<MapStorage::MapElementType> node_map_types;
+  vector<MapValue::Type> node_map_types;
   for (vector<string>::const_iterator it = node_map_names.begin();
       it != node_map_names.end(); ++it)
   {
@@ -57,7 +57,7 @@
   }
 
   // write node map types
-  { x("node_map_types" node_map_types); }
+  { x("node_map_types", node_map_types); }
 
 
   vector<string> all_edge_map_names = mapstorage->getEdgeMapList();
@@ -67,14 +67,14 @@
   for (vector<string>::const_iterator it = all_edge_map_names.begin();
       it != all_edge_map_names.end(); ++it)
   {
-    if (mapstorage->getEdgeMapSaveDest() != MapStorage::DONT_SAVE)
+    if (mapstorage->getEdgeMapSaveDest(*it) != MapStorage::DONT_SAVE)
       edge_map_names.push_back(*it);
   }
 
   // write edge map names
-  { x("edge_map_names" edge_map_names); }
+  { x("edge_map_names", edge_map_names); }
 
-  vector<MapStorage::MapElementType> edge_map_types;
+  vector<MapValue::Type> edge_map_types;
   for (vector<string>::const_iterator it = edge_map_names.begin();
       it != edge_map_names.end(); ++it)
   {
@@ -82,7 +82,7 @@
   }
 
   // write edge map types
-  { x("edge_map_types" edge_map_types); }
+  { x("edge_map_types", edge_map_types); }
 
 
   // collect the names of the node maps that are saved to the gui section
@@ -90,43 +90,43 @@
   for (vector<string>::const_iterator it = all_node_map_names.begin();
       it != all_node_map_names.end(); ++it)
   {
-    if (mapstorage->getNodeMapSaveDest() == MapStorage::GUI_SECT)
+    if (mapstorage->getNodeMapSaveDest(*it) == MapStorage::GUI_SECT)
       gui_node_map_names.push_back(*it);
   }
 
   // write the names
-  { x("gui_node_map_names" gui_node_map_names); }
+  { x("gui_node_map_names", gui_node_map_names); }
 
   // write the maps
   for (vector<string>::const_iterator it = gui_node_map_names.begin();
       it != gui_node_map_names.end(); ++it)
   {
-    MapStorage::ElementType type = mapstorage->getNodeMapElementType();
+    MapValue::Type type = mapstorage->getNodeMapElementType(*it);
     switch (type)
     {
-      case MapStorage::INTEGER:
+      case MapValue::INTEGER:
         {
           NodeData<int> data(
               mapstorage->graph,
-              mapstorage->getNodeLabel(),
+              mapstorage->getNodeLabelMap(),
               mapstorage->getIntegerNodeMap(*it));
           { x(*it, data); }
         }
         break;
-      case MapStorage::SCALAR:
+      case MapValue::SCALAR:
         {
           NodeData<double> data(
               mapstorage->graph,
-              mapstorage->getNodeLabel(),
+              mapstorage->getNodeLabelMap(),
               mapstorage->getScalarNodeMap(*it));
           { x(*it, data); }
         }
         break;
-      case MapStorage::STRING:
+      case MapValue::STRING:
         {
           NodeData<string> data(
               mapstorage->graph,
-              mapstorage->getNodeLabel(),
+              mapstorage->getNodeLabelMap(),
               mapstorage->getStringNodeMap(*it));
           { x(*it, data); }
         }
@@ -140,43 +140,43 @@
   for (vector<string>::const_iterator it = all_edge_map_names.begin();
       it != all_edge_map_names.end(); ++it)
   {
-    if (mapstorage->getEdgeMapSaveDest() == MapStorage::GUI_SECT)
+    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); }
+  { x("gui_edge_map_names", gui_edge_map_names); }
 
   // write the maps
   for (vector<string>::const_iterator it = gui_edge_map_names.begin();
       it != gui_edge_map_names.end(); ++it)
   {
-    MapStorage::ElementType type = mapstorage->getEdgeMapElementType();
+    MapValue::Type type = mapstorage->getEdgeMapElementType(*it);
     switch (type)
     {
-      case MapStorage::INTEGER:
+      case MapValue::INTEGER:
         {
           EdgeData<int> data(
               mapstorage->graph,
-              mapstorage->getEdgeLabel(),
+              mapstorage->getEdgeLabelMap(),
               mapstorage->getIntegerEdgeMap(*it));
           { x(*it, data); }
         }
         break;
-      case MapStorage::SCALAR:
+      case MapValue::SCALAR:
         {
           EdgeData<double> data(
               mapstorage->graph,
-              mapstorage->getEdgeLabel(),
+              mapstorage->getEdgeLabelMap(),
               mapstorage->getScalarEdgeMap(*it));
           { x(*it, data); }
         }
         break;
-      case MapStorage::STRING:
+      case MapValue::STRING:
         {
           EdgeData<string> data(
               mapstorage->graph,
-              mapstorage->getEdgeLabel(),
+              mapstorage->getEdgeLabelMap(),
               mapstorage->getStringEdgeMap(*it));
           { x(*it, data); }
         }

Modified: glemon/branches/akos/io_helper.h
==============================================================================
--- glemon/branches/akos/io_helper.h	(original)
+++ glemon/branches/akos/io_helper.h	Wed Apr 18 22:30:36 2007
@@ -3,14 +3,15 @@
 
 #include "all_include.h"
 #include "xml.h"
+#include "map_value.h"
 
 template<class T>
 struct NodeData
 {
   const Graph& graph;
-  const Graph::NodeMap<std::string>& label;
+  const Graph::NodeMap<int>& label;
   const Graph::NodeMap<T>& map;
-  NodeData(const Graph& _graph, const Graph::NodeMap<std::int>& _label,
+  NodeData(const Graph& _graph, const Graph::NodeMap<int>& _label,
       const Graph::NodeMap<T>& _map) :
     graph(_graph),
     label(_label),
@@ -22,9 +23,9 @@
 struct EdgeData
 {
   const Graph& graph;
-  const Graph::NodeMap<std::int>& label;
+  const Graph::EdgeMap<int>& label;
   const Graph::EdgeMap<T>& map;
-  EdgeData(const Graph& _graph, const Graph::EdgeMap<std::int>& _label,
+  EdgeData(const Graph& _graph, const Graph::EdgeMap<int>& _label,
       const Graph::EdgeMap<T>& _map) :
     graph(_graph),
     label(_label),
@@ -53,6 +54,39 @@
       { XmlIo::ContTag t(x,"value"); x(v.map[e]); }
     }
   }
+
+  /*
+  void xml(XmlIo &x, MapType &v)
+  {
+    if (x.write()) os << v;
+    else {
+      skipWhiteSpaces();
+      //if (!(is >> const_cast<MapType &>(v))) 
+      if (!(is >> v)) 
+        throw DataFormatError("",line_number,"Not a 'MapType'");
+    }
+    return *this;
+  }
+
+  template<class T>
+  void xml(XmlIo &x,lemon::dim2::BoundingBox<T> &v)
+  {
+    if(x.write()) {
+      if(!v.empty()) {
+        x("point",v.bottomLeft());
+        if(v.bottomLeft()!=v.topRight()) x("point",v.topRight());
+      }
+    }
+    else {
+      v.clear();
+      while(x.nextTag()=="point") {
+        lemon::dim2::Point<T> co;
+        x("point",co);
+        v.add(co);
+      }
+    }
+  }
+  */
 };
 
 #endif

Modified: glemon/branches/akos/map_value.cc
==============================================================================
--- glemon/branches/akos/map_value.cc	(original)
+++ glemon/branches/akos/map_value.cc	Wed Apr 18 22:30:36 2007
@@ -1,26 +1,49 @@
 #include "map_value.h"
 #include <sstream>
+#include <iostream>
+
+MapValue::MapValue()
+{
+  //std::cout << __PRETTY_FUNCTION__ << std::endl;
+  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;
+  has_value = true;
 }
 
 MapValue::MapValue(std::string str)
 {
+  //std::cout << __PRETTY_FUNCTION__ << std::endl;
+  p_value = new std::string(str);
+  type = STRING;
+  has_value = true;
+}
+
+MapValue::MapValue(const char* str)
+{
+  //std::cout << __PRETTY_FUNCTION__ << std::endl;
   p_value = new std::string(str);
   type = STRING;
+  has_value = true;
 }
 
-MapValue::operator int()
+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)
@@ -29,8 +52,10 @@
     throw IllegalOperation();
 }
 
-MapValue::operator double()
+MapValue::operator double() const
 {
+  //std::cout << __PRETTY_FUNCTION__ << std::endl;
+  if (!has_value) throw IllegalOperation();
   if (type == SCALAR)
     return *(static_cast<double*>(p_value));
   if (type == INTEGER)
@@ -39,8 +64,10 @@
     throw IllegalOperation();
 }
 
-MapValue::operator std::string()
+MapValue::operator std::string() const
 {
+  //std::cout << __PRETTY_FUNCTION__ << std::endl;
+  if (!has_value) throw IllegalOperation();
   std::string ret;
   switch (type)
   {
@@ -69,48 +96,43 @@
 
 MapValue::MapValue(const MapValue& v)
 {
+  //std::cout << __PRETTY_FUNCTION__ << std::endl;
+  if (!v.has_value) throw IllegalOperation();
+  has_value = true;
   type = v.type;
   switch (v.type)
   {
     case INTEGER:
-      p_value = new int(static_cast<int>(v));
+      p_value = new int(*(static_cast<int*>(v.p_value)));
       break;
     case SCALAR:
-      p_value = new double(static_cast<double>(v));
+      p_value = new double(*(static_cast<double*>(v.p_value)));
       break;
     case STRING:
-      p_value = new std::string(static_cast<std::string>(v));
+      p_value = new std::string(*(static_cast<std::string*>(v.p_value)));
       break;
   }
 }
 
 MapValue& MapValue::operator=(const MapValue& v)
 {
+  //std::cout << __PRETTY_FUNCTION__ << std::endl;
   if (&v != this)
   {
-    switch (type)
-    {
-      case INTEGER:
-        delete static_cast<int*>(p_value);
-        break;
-      case SCALAR:
-        delete static_cast<double*>(p_value);
-        break;
-      case STRING:
-        delete static_cast<std::string*>(p_value);
-        break;
-    }
+    if (!v.has_value) throw IllegalOperation();
+    clear();
+    has_value = true;
     type = v.type;
     switch (v.type)
     {
       case INTEGER:
-        p_value = new int(static_cast<int>(v));
+        p_value = new int(*(static_cast<int*>(v.p_value)));
         break;
       case SCALAR:
-        p_value = new double(static_cast<double>(v));
+        p_value = new double(*(static_cast<double*>(v.p_value)));
         break;
       case STRING:
-        p_value = new std::string(static_cast<std::string>(v));
+        p_value = new std::string(*(static_cast<std::string*>(v.p_value)));
         break;
     }
   }
@@ -119,22 +141,16 @@
 
 MapValue::~MapValue()
 {
-  switch (type)
-  {
-    case INTEGER:
-      delete static_cast<int*>(p_value);
-      break;
-    case SCALAR:
-      delete static_cast<double*>(p_value);
-      break;
-    case STRING:
-      delete static_cast<std::string*>(p_value);
-      break;
-  }
+  //std::cout << __PRETTY_FUNCTION__ << std::endl;
+  clear();
 }
 
 bool MapValue::operator<(const MapValue& v)
 {
+  //std::cout << __PRETTY_FUNCTION__ << std::endl;
+  if (!has_value || !v.has_value)
+    throw IllegalOperation();
+
   if (type == STRING || v.type == STRING)
     throw IllegalOperation();
 
@@ -146,6 +162,10 @@
 
 bool MapValue::operator>(const MapValue& v)
 {
+  //std::cout << __PRETTY_FUNCTION__ << std::endl;
+  if (!has_value || !v.has_value)
+    throw IllegalOperation();
+
   if (type == STRING || v.type == STRING)
     throw IllegalOperation();
 
@@ -154,3 +174,121 @@
 
   return lhs > rhs;
 }
+
+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:
+      delete static_cast<double*>(p_value);
+      break;
+    case STRING:
+      delete static_cast<std::string*>(p_value);
+      break;
+  }
+}
+
+std::istream& operator>>(std::istream &is, MapValue& v)
+{
+  //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;
+}
+
+std::ostream& operator<<(std::ostream &os, const MapValue& v)
+{
+  //std::cout << __PRETTY_FUNCTION__ << std::endl;
+  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)) << ")";
+      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 << ")";
+      }
+      break;
+  }
+  return os;
+}

Modified: glemon/branches/akos/map_value.h
==============================================================================
--- glemon/branches/akos/map_value.h	(original)
+++ glemon/branches/akos/map_value.h	Wed Apr 18 22:30:36 2007
@@ -1,8 +1,14 @@
+#ifndef MAP_VALUE_H
+#define MAP_VALUE_H
+
 #include <exception>
+#include <iosfwd>
 
 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
     {
       virtual const char* what() const throw()
@@ -12,15 +18,24 @@
     };
     typedef enum { INTEGER, SCALAR, STRING } Type;
   private:
+    bool has_value;
     void* p_value;
     MapValue::Type type;
+    void clear();
   public:
+    MapValue();
     MapValue(int);
     MapValue(double);
     MapValue(std::string);
-    operator std::string();
-    operator int();
-    operator double();
+    MapValue(const char* str);
+    MapValue(const MapValue& v);
+    MapValue& operator=(const MapValue& v);
+    ~MapValue();
+    operator std::string() const;
+    operator int() const;
+    operator double() const;
     bool operator<(const MapValue& v);
     bool operator>(const MapValue& v);
 };
+
+#endif

Modified: glemon/branches/akos/map_win.cc
==============================================================================
--- glemon/branches/akos/map_win.cc	(original)
+++ glemon/branches/akos/map_win.cc	Wed Apr 18 22:30:36 2007
@@ -29,7 +29,7 @@
   return true;
 }
 
-MapWin::MapWin(const std::string& title, std::vector<std::string> eml, std::vector<std::string> nml, NoteBookTab & mw):mytab(mw)
+MapWin::MapWin(const std::string& title, NoteBookTab & mw):mytab(mw)
 {
   set_title(title);
   set_default_size(200, 50);
@@ -46,7 +46,7 @@
 
   for(int i=0;i<EDGE_PROPERTY_NUM;i++)
   {
-    e_combo_array[i]=new MapSelector(eml, mytab.getActiveEdgeMap(i), edge_property_strings[i], true);
+    e_combo_array[i]=new MapSelector(&mytab.mapstorage, mytab.getActiveEdgeMap(i), edge_property_strings[i], true);
 
     (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
 
@@ -66,7 +66,7 @@
 
   for(int i=0;i<NODE_PROPERTY_NUM;i++)
   {
-    n_combo_array[i]=new MapSelector(nml, mytab.getActiveNodeMap(i), node_property_strings[i], false);
+    n_combo_array[i]=new MapSelector(&mytab.mapstorage, mytab.getActiveNodeMap(i), node_property_strings[i], false);
 
     (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
 
@@ -99,7 +99,7 @@
   mytab.popupNewMapWin(itisedge);
 }
 
-void MapWin::update(std::vector<std::string> eml, std::vector<std::string> nml)
+void MapWin::update()
 {
   for(int i=0;i<EDGE_PROPERTY_NUM;i++)
   {

Modified: glemon/branches/akos/map_win.h
==============================================================================
--- glemon/branches/akos/map_win.h	(original)
+++ glemon/branches/akos/map_win.h	Wed Apr 18 22:30:36 2007
@@ -65,10 +65,8 @@
   ///It creates the widgets shown in \ref MapWin and
   ///binds the needed signal to the correct place.
   ///\param title title of window
-  ///\param eml edgemap list
-  ///\param nml nodemap list
   ///\param mw the owner \ref NoteBookTab (\ref mytab)
-  MapWin(const std::string& title, std::vector<std::string> eml, std::vector<std::string> nml, NoteBookTab & mw);
+  MapWin(const std::string& title, NoteBookTab & mw);
 
   ///Deregistrates \ref MapWin in its \ref NoteBookTab (\ref mytab)
   virtual bool on_delete_event(GdkEventAny *);
@@ -125,9 +123,7 @@
   ///have changed as well. \ref NoteBookTab knows, whether it
   ///has to call this function or not from the \ref NoteBookTab::mapwinexists
   ///variable.
-  ///\param eml edge map list
-  ///\param nml node map list
-  void update(std::vector<std::string> eml, std::vector<std::string> nml);
+  void update();
 
   void changeEntry(bool, int, std::string);
 

Modified: glemon/branches/akos/mapselector.cc
==============================================================================
--- glemon/branches/akos/mapselector.cc	(original)
+++ glemon/branches/akos/mapselector.cc	Wed Apr 18 22:30:36 2007
@@ -18,9 +18,28 @@
 
 #include "mapselector.h"
 
-MapSelector::MapSelector(std::vector<std::string> ml, std::string act, std::string labeltext, bool edge, bool d, MapType type):def(d),itisedge(edge),set_new_map(false), map_type(type)
+MapSelector::MapSelector(std::string labeltext, bool edge, bool d,
+    MapType type) :
+  def(d),
+  itisedge(edge),
+  set_new_map(false),
+  map_type(type),
+  newbut(Gtk::Stock::NEW)
+{
+  set_sensitive(false);
+  default_state = false;
+  init();
+}
+
+MapSelector::MapSelector(MapStorage* mapstorage, std::string act, 
+    std::string labeltext, bool edge, bool d, MapType type) :
+  def(d),
+  itisedge(edge),
+  set_new_map(false),
+  map_type(type),
+  newbut(Gtk::Stock::NEW)
 {
-  update_list(ml);
+  update_list(mapstorage);
 
   if(act=="")
     {
@@ -33,6 +52,11 @@
       default_state=false;
     }
 
+  init();
+}
+
+void MapSelector::init()
+{
   //binding signal to the actual entry
   cbt.signal_changed().connect
     (
@@ -40,39 +64,33 @@
      false
      );
   
-  label=new Gtk::Label(labeltext);
-
-  label->set_width_chars(longest_property_string_length);
+  label.set_width_chars(longest_property_string_length);
 
-  defbut=NULL;
   if(def)
     {
-      defbut=new Gtk::Button();
-      defbut->set_label("Reset");
-      
-      defbut->signal_pressed().connect
+      defbut.set_label("Reset");
+      defbut.signal_pressed().connect
 	(
 	 sigc::mem_fun(*this, &MapSelector::reset)
 	 );
     }
 
-  newbut=new Gtk::Button(Gtk::Stock::NEW);
 
-  newbut->signal_pressed().connect
+  newbut.signal_pressed().connect
     (
      sigc::mem_fun(*this, &MapSelector::new_but_pressed)
      );
 
-  add(*label);
+  add(label);
 
   add(cbt);
 
   if(def)
     {
-      add(*defbut);
+      add(defbut);
     }
 
-  add(*newbut);
+  add(newbut);
 }
 
 void MapSelector::new_but_pressed()
@@ -85,6 +103,7 @@
 {
   using std::string;
   using std::vector;
+  set_sensitive();
   int prev_act=cbt.get_active_row_number();
   cbt.clear();
   cbt_content.clear();
@@ -95,7 +114,7 @@
   else
     v = ms->getNodeMapList(map_type);
 
-  for (vector<string>::const_iterator it = v.begin(); it != v.end(); ++v)
+  for (vector<string>::const_iterator it = v.begin(); it != v.end(); ++it)
   {
     cbt.append_text(*it);
     cbt_content.push_back(*it);

Modified: glemon/branches/akos/mapselector.h
==============================================================================
--- glemon/branches/akos/mapselector.h	(original)
+++ glemon/branches/akos/mapselector.h	Wed Apr 18 22:30:36 2007
@@ -83,7 +83,7 @@
 
   ///By pressing it
   ///\ref NewMapWin wilol pop-up
-  Gtk::Button * newbut;
+  Gtk::Button newbut;
 
   ///Reset button.
 
@@ -91,28 +91,33 @@
   ///set to 'Default' option.
   ///
   ///It is visible only if \ref def is true.
-  Gtk::Button * defbut;
+  Gtk::Button defbut;
 
   ///Container in which GUI elements are packed.
   Gtk::HBox hbox;
 
   ///Shows purpose of \ref MapSelector piece.
-  Gtk::Label * label;
+  Gtk::Label label;
 
   /// Which types of maps (integer, string, ...) to display.
   MapType map_type;
 
+  void init();
+
  public:
 
   ///Constructor of \ref MapSelector
 
   ///Creates the layout and binds signal to the correct place.
-  ///\param optionlist list of names to place in \ref cbt
+  ///\param mapstorage Pointer to the \ref MapStorage to get the map list from.
   ///\param act preselected option
   ///\param purpose text of label indicating purpose of \ref MapStorage
   ///\param itisedge do \ref MapSelector contains edgemap names or nodemapnames.
   ///\param def do we need 'Default' option. See \ref def.
-  MapSelector(std::vector<std::string> optionlist, std::string act, std::string purpose, bool itisedge, bool def=true, MapType type = ALL);
+  ///\param type Specifies which types of maps to display.
+  MapSelector(MapStorage* mapstorage, std::string act, std::string purpose, bool itisedge, bool def=true, MapType type = ALL);
+
+  MapSelector(std::string labeltext, bool edge, bool d, MapType type);
 
   ///Returns signal emitted if the user has changed the selection. (\ref signal_cbt)
   sigc::signal<void, std::string> signal_cbt_ch();

Modified: glemon/branches/akos/nbtab.cc
==============================================================================
--- glemon/branches/akos/nbtab.cc	(original)
+++ glemon/branches/akos/nbtab.cc	Wed Apr 18 22:30:36 2007
@@ -42,7 +42,7 @@
   gd_canvas->drawGraph();
   if(mapwinexists)
     {
-      mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
+      mapwin->update();
     }
   signal_title.emit(Glib::filename_display_basename(file));
 }
@@ -71,7 +71,7 @@
   mapstorage.clear();
   if(mapwinexists)
     {
-      mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
+      mapwin->update();
     }
   signal_title.emit("unsaved file");
 }
@@ -111,7 +111,7 @@
       gd_canvas->drawGraph();
       if(mapwinexists)
 	{
-	  mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
+	  mapwin->update();
 	}
       signal_title.emit(Glib::filename_display_basename(filename));
     }
@@ -172,7 +172,7 @@
   mapstorage.clear();
   if(mapwinexists)
     {
-      mapwin->update(mapstorage.getEdgeMapList(), mapstorage.getNodeMapList());
+      mapwin->update();
     }
   signal_title.emit("unsaved file");
 }
@@ -222,7 +222,7 @@
 {
   if(!mapwinexists)
     {
-      mapwin=new MapWin("Map Setup - "+name, mapstorage.getEdgeMapList(), mapstorage.getNodeMapList(), *this);
+      mapwin=new MapWin("Map Setup - "+name, *this);
       mapst2mapwin=mapstorage.signal_map_win_ch().connect(sigc::mem_fun(*mapwin, &MapWin::changeEntry));
       mapwin->show();
       mapwinexists=true;

Modified: glemon/branches/akos/new_map_win.cc
==============================================================================
--- glemon/branches/akos/new_map_win.cc	(original)
+++ glemon/branches/akos/new_map_win.cc	Wed Apr 18 22:30:36 2007
@@ -124,7 +124,8 @@
           break;
         default:
           //substitute variable
-          std::vector<std::string> ems = mytab.mapstorage.getEdgeMapList(INT | SCAL);
+          std::vector<std::string> ems =
+            mytab.mapstorage.getEdgeMapList(MapType(INT | SCAL));
           bool itisvar=(std::find(ems.begin(), ems.end(), ch2var[ polishform[i] ]) != ems.end());
           if(itisvar)
           {
@@ -184,7 +185,7 @@
     {
       if (mytab.mapstorage.edgeMapExists(map_name))
       {
-        setErrorMsg("Map '" + map_name "' already exists.");
+        setErrorMsg("Map '" + map_name + "' already exists.");
         return;
       }
     }
@@ -192,21 +193,22 @@
     {
       if (mytab.mapstorage.nodeMapExists(map_name))
       {
-        setErrorMsg("Map '" + map_name "' already exists.");
+        setErrorMsg("Map '" + map_name + "' already exists.");
         return;
       }
     }
 
-    Glib::ustring text cbType.get_active_text();
+    Glib::ustring text = cbType.get_active_text();
     if (text == "integer")
     {
+      // TODO
     }
     else if (text == "scalar")
     {
       double d;
       char *endptr;
       d = strtod(def_val.c_str(), &endptr);
-      if (s.c_str() + s.length() == endptr)
+      if (def_val.c_str() + def_val.length() == endptr)
       {
         // the full string was a number
         if (edge.get_active())
@@ -226,8 +228,8 @@
         {
           mytab.mapstorage.createEdgeMap(map_name, MapValue::SCALAR,
               MapValue(d));
-          std::vector<double>::const_iterator vit = values.begin()
-          for (NodeIt it(mytab.mapstorage.graph); it != INVALID; +it)
+          std::vector<double>::const_iterator vit = values->begin();
+          for (NodeIt it(mytab.mapstorage.graph); it != INVALID; ++it)
           {
             mytab.mapstorage.set(map_name, it, MapValue(*vit));
             ++vit;
@@ -237,8 +239,8 @@
         {
           mytab.mapstorage.createNodeMap(map_name, MapValue::SCALAR,
               MapValue(d));
-          std::vector<double>::const_iterator vit = values.begin()
-          for (NodeIt it(mytab.mapstorage.graph); it != INVALID; +it)
+          std::vector<double>::const_iterator vit = values->begin();
+          for (NodeIt it(mytab.mapstorage.graph); it != INVALID; ++it)
           {
             mytab.mapstorage.set(map_name, it, MapValue(*vit));
             ++vit;
@@ -664,12 +666,14 @@
   //is it mapname?
   if(itisedge)
   {
-    std::vector<std::string> edge_maps = mytab.mapstorage.getEdgeMapList(INT | SCAL);
+    std::vector<std::string> edge_maps =
+      mytab.mapstorage.getEdgeMapList(MapType(INT | SCAL));
     cancel=(std::find(edge_maps.begin(), edge_maps.end(), variable)==edge_maps.end());
   }
   else
   {
-    std::vector<std::string> node_maps = mytab.mapstorage.getNodeMapList(INT | SCAL);
+    std::vector<std::string> node_maps =
+      mytab.mapstorage.getNodeMapList(MapType(INT | SCAL));
     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