Merge branches/akos to trunk.
authorladanyi
Wed, 02 Jan 2008 21:03:09 +0000
changeset 201879e47e5b731
parent 200 c7ae8642a8d8
child 202 09f6dfdbb3b4
Merge branches/akos to trunk.
Makefile.am
algobox.cc
algobox.h
all_include.h
configure.ac
dijkstrabox.cc
eps_win.cc
eps_win.h
file_import_dialog.cc
file_import_dialog.h
gdc-broken_edge.cc
graph-displayer.cc
graph_displayer_canvas-edge.cc
graph_displayer_canvas-event.cc
graph_displayer_canvas-node.cc
graph_displayer_canvas.cc
gui_reader.cc
gui_reader.h
gui_writer.cc
io_helper.cc
io_helper.h
kruskalbox.cc
main_win.cc
main_win.h
map_value.cc
map_value.h
map_value_map.cc
map_value_map.h
map_win.cc
map_win.h
mapselector.cc
mapselector.h
mapstorage.cc
mapstorage.h
nbtab.cc
nbtab.h
new_map_win.cc
new_map_win.h
save_details_dialog.cc
save_details_dialog.h
save_details_widget.cc
save_details_widget.h
xml.h
     1.1 --- a/Makefile.am	Wed May 02 20:33:58 2007 +0000
     1.2 +++ b/Makefile.am	Wed Jan 02 21:03:09 2008 +0000
     1.3 @@ -47,6 +47,18 @@
     1.4  	design_win.cc \
     1.5  	dijkstrabox.h \
     1.6  	dijkstrabox.cc \
     1.7 +	file_import_dialog.h \
     1.8 +	file_import_dialog.cc \
     1.9 +	map_value.h \
    1.10 +	map_value.cc \
    1.11 +	map_value_map.h \
    1.12 +	map_value_map.cc \
    1.13 +	save_details_widget.h \
    1.14 +	save_details_widget.cc \
    1.15 +	save_details_dialog.h \
    1.16 +	save_details_dialog.cc \
    1.17 +	io_helper.h \
    1.18 +	io_helper.cc \
    1.19  	background_chooser_dialog.h \
    1.20  	background_chooser_dialog.cc \
    1.21  	eps_win.h \
     2.1 --- a/algobox.cc	Wed May 02 20:33:58 2007 +0000
     2.2 +++ b/algobox.cc	Wed Jan 02 21:03:09 2008 +0000
     2.3 @@ -82,41 +82,45 @@
     2.4  void AlgoBox::update_maplist(MapStorage * ms)
     2.5  {
     2.6    mapstorage=ms;
     2.7 -  std::vector<std::string> nml;
     2.8 -  std::vector<std::string> eml;
     2.9 +  std::vector<std::string> n_nml;
    2.10 +  std::vector<std::string> s_nml;
    2.11 +  std::vector<std::string> n_eml;
    2.12 +  std::vector<std::string> s_eml;
    2.13    if(mapstorage!=NULL)
    2.14      {
    2.15        mapstorage->signal_node_map_ch().connect(sigc::mem_fun(*this, &AlgoBox::nodemaplist_changed));
    2.16        mapstorage->signal_edge_map_ch().connect(sigc::mem_fun(*this, &AlgoBox::edgemaplist_changed));
    2.17 -      nml=mapstorage->getNodeMapList();
    2.18 -      eml=mapstorage->getEdgeMapList();
    2.19 +      n_nml=mapstorage->getNodeMapList(NUM);
    2.20 +      s_nml=mapstorage->getNodeMapList(STR);
    2.21 +      n_eml=mapstorage->getEdgeMapList(NUM);
    2.22 +      s_eml=mapstorage->getEdgeMapList(STR);
    2.23      }
    2.24    for(int i=0;i<(int)nodemapcbts.size();i++)
    2.25      {
    2.26 -      (nodemapcbts[i])->update_list(nml);
    2.27 +      (nodemapcbts[i])->update_list(n_nml, s_nml);
    2.28        //update_cbt(nml, *(nodemapcbts[i]));
    2.29      }
    2.30    for(int i=0;i<(int)edgemapcbts.size();i++)
    2.31      {
    2.32 -      (edgemapcbts[i])->update_list(eml);
    2.33 +      (edgemapcbts[i])->update_list(n_eml, s_eml);
    2.34        //update_cbt(eml, *(edgemapcbts[i]));
    2.35      }
    2.36    signal_maplist_updated.emit();
    2.37  }
    2.38  
    2.39 -void AlgoBox::nodemaplist_changed(std::string newmap)
    2.40 +void AlgoBox::nodemaplist_changed(std::string newmap, MapValue::Type type)
    2.41  {
    2.42    for(int i=0;i<(int)nodemapcbts.size();i++)
    2.43      {
    2.44 -      (nodemapcbts[i])->append_text(newmap);
    2.45 +      (nodemapcbts[i])->append_text(newmap, type);
    2.46      }
    2.47  }
    2.48  
    2.49 -void AlgoBox::edgemaplist_changed(std::string newmap)
    2.50 +void AlgoBox::edgemaplist_changed(std::string newmap, MapValue::Type type)
    2.51  {
    2.52    for(int i=0;i<(int)edgemapcbts.size();i++)
    2.53      {
    2.54 -      (edgemapcbts[i])->append_text(newmap);
    2.55 +      (edgemapcbts[i])->append_text(newmap, type);
    2.56      }
    2.57  }
    2.58  
    2.59 @@ -160,11 +164,11 @@
    2.60    pack_start(*(new Gtk::HSeparator()));
    2.61  }
    2.62  
    2.63 -void AlgoBox::addMapSelector(std::string inputname, bool itisedge)
    2.64 +void AlgoBox::addMapSelector(std::string inputname, bool itisedge, MapType type)
    2.65  {
    2.66    std::vector<std::string> empty_vector;
    2.67  
    2.68 -  MapSelector * msp=new MapSelector(empty_vector,"",inputname,itisedge, false);
    2.69 +  MapSelector * msp=new MapSelector(empty_vector,empty_vector,"",inputname,itisedge, false, type);
    2.70  
    2.71    if(itisedge)
    2.72      {
     3.1 --- a/algobox.h	Wed May 02 20:33:58 2007 +0000
     3.2 +++ b/algobox.h	Wed Jan 02 21:03:09 2008 +0000
     3.3 @@ -25,6 +25,7 @@
     3.4  #include <all_include.h>
     3.5  #include <libgnomecanvasmm.h>
     3.6  #include <libgnomecanvasmm/polygon.h>
     3.7 +#include "map_value.h"
     3.8  
     3.9  ///Ancestor class of algorithm graphical interface classes.
    3.10  
    3.11 @@ -138,14 +139,14 @@
    3.12    ///If new map was added to \ref MapStorage of currently selected \ref NoteBookTab
    3.13    ///a signal is emitted by it. This signal is connected to this function, so \ref MapSelector s
    3.14    ///in \ref nodemapcbts can be notified, and those can registrate the new map. (\ref MapSelector::append_text)
    3.15 -  void nodemaplist_changed(std::string);
    3.16 +  void nodemaplist_changed(std::string, MapValue::Type);
    3.17  
    3.18    ///Interface, through which \ref AlgoBox can be notified about edgemap addition.
    3.19  
    3.20    ///If new map was added to \ref MapStorage of currently selected \ref NoteBookTab
    3.21    ///a signal is emitted by it. This signal is connected to this function, so \ref MapSelector s
    3.22    ///in \ref edgemapcbts can be notified, and those can registrate the new map. (\ref MapSelector::append_text)
    3.23 -  void edgemaplist_changed(std::string);
    3.24 +  void edgemaplist_changed(std::string, MapValue::Type);
    3.25  
    3.26    ///Aid function to provide data for a given entry.
    3.27  
    3.28 @@ -183,6 +184,6 @@
    3.29  
    3.30    ///\param label label to show in \ref MapSelector
    3.31    ///\param itisedge whether edge or nodemaps stored in \ref MapSelector
    3.32 -  void addMapSelector(std::string label, bool itisedge);
    3.33 +  void addMapSelector(std::string label, bool itisedge, MapType type = ALL);
    3.34  };
    3.35  #endif //ALGOBOX_H
     4.1 --- a/all_include.h	Wed May 02 20:33:58 2007 +0000
     4.2 +++ b/all_include.h	Wed Jan 02 21:03:09 2008 +0000
     4.3 @@ -65,4 +65,11 @@
     4.4  
     4.5  const std::string prog_name = "LEMON Graph Editor";
     4.6  
     4.7 +enum MapType
     4.8 +{
     4.9 +  NUM  = 1 << 0,
    4.10 +  STR  = 1 << 1,
    4.11 +  ALL  = (1 << 0) | (1 << 1)
    4.12 +};
    4.13 +
    4.14  #endif // ALL_INCLUDE_H
     5.1 --- a/configure.ac	Wed May 02 20:33:58 2007 +0000
     5.2 +++ b/configure.ac	Wed Jan 02 21:03:09 2008 +0000
     5.3 @@ -26,33 +26,13 @@
     5.4  dnl Checks for libraries.
     5.5  PKG_CHECK_MODULES([GTK], [libgnomecanvasmm-2.6 >= 2.6.0 gtkmm-2.4 >= 2.6])
     5.6  
     5.7 -AC_ARG_WITH([lemon-prefix],
     5.8 -AS_HELP_STRING([--with-lemon-prefix@<:@=PREFIX@:>@], [search for LEMON under PREFIX]), [], [with_lemon_prefix=no])
     5.9 -if test x"$with_lemon_prefix" != x"no"; then
    5.10 -  export PKG_CONFIG_PATH="$with_lemon_prefix/lib/pkgconfig/:$PKG_CONFIG_PATH"
    5.11 +AC_ARG_WITH([lemon],
    5.12 +AS_HELP_STRING([--with-lemon@<:@=PREFIX@:>@], [search for LEMON under PREFIX]), [], [with_lemon=no])
    5.13 +if test x"$with_lemon" != x"no"; then
    5.14 +  export PKG_CONFIG_PATH="$with_lemon/lib/pkgconfig/:$PKG_CONFIG_PATH"
    5.15  fi
    5.16  
    5.17 -PKG_CHECK_MODULES([LEMON_0_5], [lemon >= 0.5],
    5.18 -  [lemon_0_5_found=yes], [
    5.19 -    AC_MSG_RESULT([no])
    5.20 -    lemon_0_5_found=no])
    5.21 -PKG_CHECK_MODULES([LEMON_SVNHEAD], [lemon = svnhead],
    5.22 -  [lemon_svn_head_found=yes], [
    5.23 -    AC_MSG_RESULT([no])
    5.24 -    lemon_svn_head_found=no])
    5.25 -if test x"$lemon_0_5_found" = x"no" -a x"$lemon_svn_head_found" = x"no"; then
    5.26 -  AC_MSG_ERROR([LEMON not found.])
    5.27 -else
    5.28 -  if test x"$lemon_svn_head_found" = x"yes"; then
    5.29 -    LEMON_CFLAGS="$LEMON_SVNHEAD_CFLAGS"
    5.30 -    LEMON_LIBS="$LEMON_SVNHEAD_LIBS"
    5.31 -  else
    5.32 -    LEMON_CFLAGS="$LEMON_0_5_CFLAGS"
    5.33 -    LEMON_LIBS="$LEMON_0_5_LIBS"
    5.34 -  fi
    5.35 -  AC_SUBST(LEMON_CFLAGS)
    5.36 -  AC_SUBST(LEMON_LIBS)
    5.37 -fi
    5.38 +PKG_CHECK_MODULES([LEMON], [lemon >= 0.6.90])
    5.39  
    5.40  dnl Checks for header files.
    5.41  AC_CHECK_HEADERS([libintl.h locale.h])
     6.1 --- a/dijkstrabox.cc	Wed May 02 20:33:58 2007 +0000
     6.2 +++ b/dijkstrabox.cc	Wed Jan 02 21:03:09 2008 +0000
     6.3 @@ -52,63 +52,64 @@
     6.4  void DijkstraBox::run()
     6.5  {
     6.6    if(
     6.7 -     tabcbt.get_active_text()!="" &&
     6.8 -     (edgemapcbts[INPUT])->get_active_text()!="" &&
     6.9 -     (edgemapcbts[OUTPUT])->get_active_text()!="" &&
    6.10 -     source.get_active_text()!="" &&
    6.11 -     target.get_active_text()!=""
    6.12 -     )
    6.13 +      tabcbt.get_active_text()!="" &&
    6.14 +      (edgemapcbts[INPUT])->get_active_text()!="" &&
    6.15 +      (edgemapcbts[OUTPUT])->get_active_text()!="" &&
    6.16 +      source.get_active_text()!="" &&
    6.17 +      target.get_active_text()!=""
    6.18 +    )
    6.19 +  {
    6.20 +    const Graph &g=mapstorage->graph;
    6.21 +    Node from, to;
    6.22 +
    6.23 +    get_from_to(from, to, (Graph&)g);
    6.24 +
    6.25 +    std::ostringstream o;
    6.26 +
    6.27 +    if(!(from==to))
    6.28      {
    6.29 -      const Graph &g=mapstorage->graph;
    6.30 -      Node from, to;
    6.31 +      std::string inputmapName = edgemapcbts[INPUT]->get_active_text();
    6.32 +      std::string outputmapName = edgemapcbts[OUTPUT]->get_active_text();
    6.33  
    6.34 -      get_from_to(from, to, (Graph&)g);
    6.35 +      MapStorage::NumericEdgeMap& inputmap = mapstorage->getNumericEdgeMap(inputmapName);
    6.36 +      MapStorage::NumericEdgeMap& outputmap = mapstorage->getNumericEdgeMap(outputmapName);
    6.37  
    6.38 -      std::ostringstream o;
    6.39 +      //zero out output map
    6.40 +      for (EdgeIt i(g); i!=INVALID; ++i)
    6.41 +      {
    6.42 +        outputmap[i]=0;
    6.43 +      }
    6.44  
    6.45 -      if(!(from==to))
    6.46 -	{
    6.47 -	  Graph::EdgeMap<double> * inputmap=
    6.48 -	    (mapstorage->edgemap_storage)[(edgemapcbts[INPUT])->get_active_text()];
    6.49 -	  Graph::EdgeMap<double> * outputmap=
    6.50 -	    (mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->get_active_text()];
    6.51 +      Dijkstra<Graph, MapStorage::NumericEdgeMap > dijkstra(g, inputmap);
    6.52 +      dijkstra.run(from, to);
    6.53  
    6.54 -	  //zero out output map
    6.55 -	  for (EdgeIt i(g); i!=INVALID; ++i)
    6.56 -	    {
    6.57 -	      (*outputmap)[i]=0;
    6.58 -	    }
    6.59 -	  
    6.60 -	  Dijkstra<Graph, Graph::EdgeMap<double> > dijkstra(g, *inputmap);
    6.61 -	  dijkstra.run(from, to);
    6.62 -	  
    6.63 -	  if(dijkstra.reached(to))
    6.64 -	    {
    6.65 -	      Node n=to;
    6.66 -	      int length=0;
    6.67 -	      while (n!=INVALID && n!=from)
    6.68 -		{
    6.69 -		  Edge e=dijkstra.predEdge(n);
    6.70 -		  (*outputmap)[e]=1;
    6.71 -		  n=dijkstra.predNode(n);
    6.72 -		  length++;
    6.73 -		}
    6.74 -	      o << "Result: " << length << " long path, with cost " << dijkstra.dist(to);
    6.75 -	    }
    6.76 -	  else
    6.77 -	    {
    6.78 -	      o << "Result: failed to find shortest path between ";
    6.79 -	      o << source.get_active_text() << " and " << target.get_active_text();
    6.80 -	    }
    6.81 -	  resultlabel.set_text(o.str());
    6.82 -	  
    6.83 -	  mapstorage->mapChanged(true, (edgemapcbts[OUTPUT])->get_active_text());
    6.84 -	  //   mapstorage->changeActiveMap(true, E_COLOR,
    6.85 -	  // 			      (edgemapcbts[OUTPUT])->get_active_text());
    6.86 -	  //   mapstorage->changeActiveMap(true, E_TEXT,
    6.87 -	  // 			      (edgemapcbts[INPUT])->get_active_text());
    6.88 -	}
    6.89 +      if(dijkstra.reached(to))
    6.90 +      {
    6.91 +        Node n=to;
    6.92 +        int length=0;
    6.93 +        while (n!=INVALID && n!=from)
    6.94 +        {
    6.95 +          Edge e=dijkstra.predEdge(n);
    6.96 +          outputmap[e]=1;
    6.97 +          n=dijkstra.predNode(n);
    6.98 +          length++;
    6.99 +        }
   6.100 +        o << "Result: " << length << " long path, with cost " << dijkstra.dist(to);
   6.101 +      }
   6.102 +      else
   6.103 +      {
   6.104 +        o << "Result: failed to find shortest path between ";
   6.105 +        o << source.get_active_text() << " and " << target.get_active_text();
   6.106 +      }
   6.107 +      resultlabel.set_text(o.str());
   6.108 +
   6.109 +      mapstorage->mapChanged(true, (edgemapcbts[OUTPUT])->get_active_text());
   6.110 +      //   mapstorage->changeActiveMap(true, E_COLOR,
   6.111 +      // 			      (edgemapcbts[OUTPUT])->get_active_text());
   6.112 +      //   mapstorage->changeActiveMap(true, E_TEXT,
   6.113 +      // 			      (edgemapcbts[INPUT])->get_active_text());
   6.114      }
   6.115 +  }
   6.116  }
   6.117  
   6.118  void SuurballeBox::run()
   6.119 @@ -130,18 +131,18 @@
   6.120  
   6.121        if(!(from==to))
   6.122  	{
   6.123 -	  Graph::EdgeMap<double> * inputmap=
   6.124 -	    (mapstorage->edgemap_storage)[(edgemapcbts[INPUT])->get_active_text()];
   6.125 -	  Graph::EdgeMap<double> * outputmap=
   6.126 -	    (mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->get_active_text()];
   6.127 +          MapStorage::NumericEdgeMap& inputmap=
   6.128 +	    mapstorage->getNumericEdgeMap(edgemapcbts[INPUT]->get_active_text());
   6.129 +          MapStorage::NumericEdgeMap& outputmap=
   6.130 +	    mapstorage->getNumericEdgeMap(edgemapcbts[OUTPUT]->get_active_text());
   6.131  
   6.132  	  //zero out output map
   6.133  	  for (EdgeIt i(g); i!=INVALID; ++i)
   6.134  	    {
   6.135 -	      (*outputmap)[i]=0;
   6.136 +	      outputmap[i]=0;
   6.137  	    }
   6.138  	  
   6.139 -	  Suurballe<Graph, Graph::EdgeMap<double> > sb((Graph&)g, *inputmap, from, to);
   6.140 +	  Suurballe<Graph, MapStorage::NumericEdgeMap > sb((Graph&)g, inputmap, from, to);
   6.141  	  
   6.142  	  int found=sb.run(num_set->get_value_as_int());
   6.143  	  if(found)
   6.144 @@ -152,7 +153,7 @@
   6.145  		  path=sb.path(j);
   6.146  		  for(int k=0;k<path.length();k++)
   6.147  		    {
   6.148 -		      (*outputmap)[path.nth(k)]=j+1;
   6.149 +		      outputmap[path.nth(k)]=j+1;
   6.150  		    }
   6.151  		}
   6.152  	      o << "Result: found " << found << " paths between ";
   6.153 @@ -180,8 +181,8 @@
   6.154    //this can be done after the maps are loaded into ComboBoxes
   6.155    signal_upon_maplist_updated().connect(sigc::mem_fun(*this, &DijkstraBox::maplists_updated));
   6.156  
   6.157 -  addMapSelector("Cost map: ", true);
   6.158 -  addMapSelector("Edges of path here: ", true);
   6.159 +  addMapSelector("Cost map: ", true, NUM);
   6.160 +  addMapSelector("Edges of path here: ", true, NUM);
   6.161  
   6.162    Gtk::Label * source_label=new Gtk::Label("Source: ");
   6.163    Gtk::Label * target_label=new Gtk::Label("Target: ");
   6.164 @@ -212,7 +213,7 @@
   6.165        for (NodeIt i(g); i!=INVALID; ++i)
   6.166  	{
   6.167  	  std::ostringstream text;
   6.168 -	  text << (*((mapstorage->nodemap_storage)["label"]))[i];
   6.169 +	  text << mapstorage->getLabel(i);
   6.170  	  source.prepend_text(text.str());
   6.171  	  target.prepend_text(text.str());
   6.172  	}
   6.173 @@ -225,7 +226,7 @@
   6.174    for (NodeIt i(g); (i!=INVALID) && (assigned<2); ++i)
   6.175      {
   6.176        std::ostringstream text;
   6.177 -      text << (*((mapstorage->nodemap_storage)["label"]))[i];
   6.178 +      text << mapstorage->getLabel(i);
   6.179        if(!(text.str().compare(source.get_active_text())))
   6.180  	{
   6.181  	  from=i;
     7.1 --- a/eps_win.cc	Wed May 02 20:33:58 2007 +0000
     7.2 +++ b/eps_win.cc	Wed Jan 02 21:03:09 2008 +0000
     7.3 @@ -31,7 +31,7 @@
     7.4    return true;
     7.5  }
     7.6  
     7.7 -EpsWin::EpsWin(const std::string& title, std::vector<std::string> nml):Gtk::Dialog(title, true, true)
     7.8 +EpsWin::EpsWin(const std::string& title, std::vector<std::string> n_nml, std::vector<std::string> s_nml):Gtk::Dialog(title, true, true)
     7.9  {
    7.10    set_default_size(200, 50);
    7.11  
    7.12 @@ -57,7 +57,7 @@
    7.13        (*table).attach(*(options[i]),0,1,i,i+1,Gtk::FILL,Gtk::SHRINK,10,3);
    7.14      }
    7.15  
    7.16 -  mapselector=new MapSelector(nml, "", "Nodeshapes", false);
    7.17 +  mapselector=new MapSelector(n_nml, s_nml, "", "Nodeshapes", false, true, NUM);
    7.18    mapselector->signal_newmapwin_needed().connect(sigc::mem_fun(*this, &EpsWin::newMapWinNeeded));
    7.19  
    7.20    hbox.pack_start(*(new Gtk::Label("Filename")));
    7.21 @@ -104,7 +104,7 @@
    7.22    signal_new_map.emit(false);
    7.23  }
    7.24  
    7.25 -void EpsWin::registerNewNodeMap(std::string newmapname)
    7.26 +void EpsWin::registerNewNodeMap(std::string newmapname, MapValue::Type type)
    7.27  {
    7.28 -    mapselector->append_text((Glib::ustring)newmapname);
    7.29 +    mapselector->append_text((Glib::ustring)newmapname, type);
    7.30  }
     8.1 --- a/eps_win.h	Wed May 02 20:33:58 2007 +0000
     8.2 +++ b/eps_win.h	Wed Jan 02 21:03:09 2008 +0000
     8.3 @@ -24,6 +24,7 @@
     8.4  #include <all_include.h>
     8.5  #include <libgnomecanvasmm.h>
     8.6  #include <libgnomecanvasmm/polygon.h>
     8.7 +#include "map_value.h"
     8.8  
     8.9  ///Graph visualization setup window.
    8.10  
    8.11 @@ -61,7 +62,7 @@
    8.12    ///\param eml edgemap list
    8.13    ///\param nml nodemap list
    8.14    ///\param mw the owner \ref NoteBookTab (\ref mytab)
    8.15 -  EpsWin(const std::string& title, std::vector<std::string>);
    8.16 +  EpsWin(const std::string& title, std::vector<std::string>, std::vector<std::string>);
    8.17  
    8.18    ///Deregistrates \ref EpsWin in its \ref NoteBookTab (\ref mytab)
    8.19    virtual bool on_delete_event(GdkEventAny *);
    8.20 @@ -102,7 +103,7 @@
    8.21  
    8.22    ///\param new_name
    8.23    ///name of new map
    8.24 -  void registerNewNodeMap(std::string new_name);
    8.25 +  void registerNewNodeMap(std::string new_name, MapValue::Type type);
    8.26  };
    8.27  
    8.28  #endif //EPS_WIN_H
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/file_import_dialog.cc	Wed Jan 02 21:03:09 2008 +0000
     9.3 @@ -0,0 +1,928 @@
     9.4 +#include "file_import_dialog.h"
     9.5 +#include <gtkmm/dialog.h>
     9.6 +#include <gtkmm/stock.h>
     9.7 +#include <gtkmm/notebook.h>
     9.8 +#include <gtkmm/messagedialog.h>
     9.9 +#include <gtkmm/frame.h>
    9.10 +#include <iostream>
    9.11 +
    9.12 +FileImportDialog::FileImportDialog(ImportData* d) :
    9.13 +  p_data(d)
    9.14 +{
    9.15 +  add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
    9.16 +  add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);
    9.17 +
    9.18 +  Gtk::VBox* pVBox = get_vbox();
    9.19 +
    9.20 +  Gtk::Notebook* nb = Gtk::manage(new Gtk::Notebook);
    9.21 +  pVBox->pack_start(*nb, Gtk::PACK_EXPAND_WIDGET);
    9.22 +
    9.23 +  Gtk::VBox* vbNodeMaps = Gtk::manage(new Gtk::VBox(false, 18));
    9.24 +  vbNodeMaps->set_border_width(12);
    9.25 +
    9.26 +  Gtk::VBox* vbEdgeMaps = Gtk::manage(new Gtk::VBox(false, 18));
    9.27 +  vbEdgeMaps->set_border_width(12);
    9.28 +
    9.29 +  Gtk::VBox* vbSpecMaps = Gtk::manage(new Gtk::VBox(false, 18));
    9.30 +  vbSpecMaps->set_border_width(12);
    9.31 +
    9.32 +  nb->append_page(*vbSpecMaps, "Special Maps");
    9.33 +  nb->append_page(*vbNodeMaps, "Node Maps");
    9.34 +  nb->append_page(*vbEdgeMaps, "Edge Maps");
    9.35 +
    9.36 +  // child widgets of vbSpecMaps
    9.37 +  {
    9.38 +    Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6));
    9.39 +    vbSpecMaps->pack_start(*box1, Gtk::PACK_SHRINK);
    9.40 +
    9.41 +    {
    9.42 +      Gtk::Label* label1 =
    9.43 +        Gtk::manage(new Gtk::Label("<b>Node Coordinates</b>"));
    9.44 +      label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
    9.45 +      label1->set_use_markup();
    9.46 +      box1->pack_start(*label1);
    9.47 +
    9.48 +      Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
    9.49 +      box1->pack_start(*box2);
    9.50 +
    9.51 +      Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
    9.52 +      box2->pack_start(*fill1, Gtk::PACK_SHRINK);
    9.53 +
    9.54 +      Gtk::VBox* box3 = Gtk::manage(new Gtk::VBox);
    9.55 +      box2->pack_start(*box3);
    9.56 +
    9.57 +      Gtk::VBox* box13 = Gtk::manage(new Gtk::VBox);
    9.58 +      box3->pack_start(*box13);
    9.59 +
    9.60 +      rbNodeCoordNone.set_label("None");
    9.61 +      Gtk::RadioButtonGroup group = rbNodeCoordNone.get_group();
    9.62 +      box13->pack_start(rbNodeCoordNone);
    9.63 +
    9.64 +      Gtk::VBox* box4 = Gtk::manage(new Gtk::VBox);
    9.65 +      box3->pack_start(*box4);
    9.66 +
    9.67 +      rbNodeCoordOneMap.set_label("One Map");
    9.68 +      rbNodeCoordOneMap.set_group(group);
    9.69 +      box4->pack_start(rbNodeCoordOneMap);
    9.70 +
    9.71 +      Gtk::HBox* box5 = Gtk::manage(new Gtk::HBox);
    9.72 +      box4->pack_start(*box5);
    9.73 +
    9.74 +      Gtk::Label* fill2 = Gtk::manage(new Gtk::Label("    "));
    9.75 +      box5->pack_start(*fill2, Gtk::PACK_SHRINK);
    9.76 +
    9.77 +      Gtk::VBox* box6 = Gtk::manage(new Gtk::VBox);
    9.78 +      box5->pack_start(*box6);
    9.79 +
    9.80 +      Gtk::HBox* box7 = Gtk::manage(new Gtk::HBox);
    9.81 +      box6->pack_start(*box7);
    9.82 +
    9.83 +      Gtk::Label* label2 = Gtk::manage(new Gtk::Label("(X, Y)"));
    9.84 +      box7->pack_start(*label2, Gtk::PACK_SHRINK, 4);
    9.85 +
    9.86 +      box7->pack_start(cbNodeCoordOneMap, Gtk::PACK_EXPAND_WIDGET);
    9.87 +
    9.88 +
    9.89 +      Gtk::VBox* box8 = Gtk::manage(new Gtk::VBox);
    9.90 +      box3->pack_start(*box8);
    9.91 +
    9.92 +      rbNodeCoordTwoMaps.set_label("Two Maps");
    9.93 +      rbNodeCoordTwoMaps.set_group(group);
    9.94 +      box8->pack_start(rbNodeCoordTwoMaps);
    9.95 +
    9.96 +      Gtk::HBox* box9 = Gtk::manage(new Gtk::HBox);
    9.97 +      box8->pack_start(*box9);
    9.98 +
    9.99 +      Gtk::Label* fill3 = Gtk::manage(new Gtk::Label("    "));
   9.100 +      box9->pack_start(*fill3, Gtk::PACK_SHRINK);
   9.101 +
   9.102 +      Gtk::VBox* box10 = Gtk::manage(new Gtk::VBox);
   9.103 +      box9->pack_start(*box10);
   9.104 +
   9.105 +      Gtk::HBox* box11 = Gtk::manage(new Gtk::HBox);
   9.106 +      box10->pack_start(*box11);
   9.107 +
   9.108 +      Gtk::Label* label3 = Gtk::manage(new Gtk::Label("X"));
   9.109 +      box11->pack_start(*label3, Gtk::PACK_SHRINK, 4);
   9.110 +
   9.111 +      box11->pack_start(cbNodeCoordTwoMaps1, Gtk::PACK_EXPAND_WIDGET);
   9.112 +
   9.113 +      Gtk::HBox* box12 = Gtk::manage(new Gtk::HBox);
   9.114 +      box10->pack_start(*box12);
   9.115 +
   9.116 +      Gtk::Label* label4 = Gtk::manage(new Gtk::Label("Y"));
   9.117 +      box12->pack_start(*label4, Gtk::PACK_SHRINK, 4);
   9.118 +
   9.119 +      box12->pack_start(cbNodeCoordTwoMaps2, Gtk::PACK_EXPAND_WIDGET);
   9.120 +
   9.121 +      cbNodeCoordOneMap.signal_changed().connect(
   9.122 +          sigc::mem_fun(*this, &FileImportDialog::onNodeCoordOneMapChanged));
   9.123 +      cbNodeCoordTwoMaps1.signal_changed().connect(
   9.124 +          sigc::mem_fun(*this, &FileImportDialog::onNodeCoordTwoMaps1Changed));
   9.125 +      cbNodeCoordTwoMaps2.signal_changed().connect(
   9.126 +          sigc::mem_fun(*this, &FileImportDialog::onNodeCoordTwoMaps2Changed));
   9.127 +    }
   9.128 +
   9.129 +    {
   9.130 +      Gtk::Label* label1 =
   9.131 +        Gtk::manage(new Gtk::Label("<b>Arrow Coordinates</b>"));
   9.132 +      label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
   9.133 +      label1->set_use_markup();
   9.134 +      box1->pack_start(*label1);
   9.135 +
   9.136 +      Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
   9.137 +      box1->pack_start(*box2);
   9.138 +
   9.139 +      Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
   9.140 +      box2->pack_start(*fill1, Gtk::PACK_SHRINK);
   9.141 +
   9.142 +      Gtk::VBox* box3 = Gtk::manage(new Gtk::VBox);
   9.143 +      box2->pack_start(*box3);
   9.144 +
   9.145 +      Gtk::VBox* box13 = Gtk::manage(new Gtk::VBox);
   9.146 +      box3->pack_start(*box13);
   9.147 +
   9.148 +      rbArrowCoordNone.set_label("None");
   9.149 +      Gtk::RadioButtonGroup group = rbArrowCoordNone.get_group();
   9.150 +      box13->pack_start(rbArrowCoordNone);
   9.151 +
   9.152 +      Gtk::VBox* box4 = Gtk::manage(new Gtk::VBox);
   9.153 +      box3->pack_start(*box4);
   9.154 +
   9.155 +      rbArrowCoordOneMap.set_label("One Map");
   9.156 +      rbArrowCoordOneMap.set_group(group);
   9.157 +      box4->pack_start(rbArrowCoordOneMap);
   9.158 +
   9.159 +      Gtk::HBox* box5 = Gtk::manage(new Gtk::HBox);
   9.160 +      box4->pack_start(*box5);
   9.161 +
   9.162 +      Gtk::Label* fill2 = Gtk::manage(new Gtk::Label("    "));
   9.163 +      box5->pack_start(*fill2, Gtk::PACK_SHRINK);
   9.164 +
   9.165 +      Gtk::VBox* box6 = Gtk::manage(new Gtk::VBox);
   9.166 +      box5->pack_start(*box6);
   9.167 +
   9.168 +      Gtk::HBox* box7 = Gtk::manage(new Gtk::HBox);
   9.169 +      box6->pack_start(*box7);
   9.170 +
   9.171 +      Gtk::Label* label2 = Gtk::manage(new Gtk::Label("(X, Y)"));
   9.172 +      box7->pack_start(*label2, Gtk::PACK_SHRINK, 4);
   9.173 +
   9.174 +      box7->pack_start(cbArrowCoordOneMap, Gtk::PACK_EXPAND_WIDGET);
   9.175 +
   9.176 +
   9.177 +      Gtk::VBox* box8 = Gtk::manage(new Gtk::VBox);
   9.178 +      box3->pack_start(*box8);
   9.179 +
   9.180 +      rbArrowCoordTwoMaps.set_label("Two Maps");
   9.181 +      rbArrowCoordTwoMaps.set_group(group);
   9.182 +      box8->pack_start(rbArrowCoordTwoMaps);
   9.183 +
   9.184 +      Gtk::HBox* box9 = Gtk::manage(new Gtk::HBox);
   9.185 +      box8->pack_start(*box9);
   9.186 +
   9.187 +      Gtk::Label* fill3 = Gtk::manage(new Gtk::Label("    "));
   9.188 +      box9->pack_start(*fill3, Gtk::PACK_SHRINK);
   9.189 +
   9.190 +      Gtk::VBox* box10 = Gtk::manage(new Gtk::VBox);
   9.191 +      box9->pack_start(*box10);
   9.192 +
   9.193 +      Gtk::HBox* box11 = Gtk::manage(new Gtk::HBox);
   9.194 +      box10->pack_start(*box11);
   9.195 +
   9.196 +      Gtk::Label* label3 = Gtk::manage(new Gtk::Label("X"));
   9.197 +      box11->pack_start(*label3, Gtk::PACK_SHRINK, 4);
   9.198 +
   9.199 +      box11->pack_start(cbArrowCoordTwoMaps1, Gtk::PACK_EXPAND_WIDGET);
   9.200 +
   9.201 +      Gtk::HBox* box12 = Gtk::manage(new Gtk::HBox);
   9.202 +      box10->pack_start(*box12);
   9.203 +
   9.204 +      Gtk::Label* label4 = Gtk::manage(new Gtk::Label("Y"));
   9.205 +      box12->pack_start(*label4, Gtk::PACK_SHRINK, 4);
   9.206 +
   9.207 +      box12->pack_start(cbArrowCoordTwoMaps2, Gtk::PACK_EXPAND_WIDGET);
   9.208 +
   9.209 +      cbArrowCoordOneMap.signal_changed().connect(
   9.210 +          sigc::mem_fun(*this, &FileImportDialog::onArrowCoordOneMapChanged));
   9.211 +      cbArrowCoordTwoMaps1.signal_changed().connect(
   9.212 +          sigc::mem_fun(*this, &FileImportDialog::onArrowCoordTwoMaps1Changed));
   9.213 +      cbArrowCoordTwoMaps2.signal_changed().connect(
   9.214 +          sigc::mem_fun(*this, &FileImportDialog::onArrowCoordTwoMaps2Changed));
   9.215 +    }
   9.216 +  }
   9.217 +
   9.218 +  // child widgets of vbNodeMaps
   9.219 +  {
   9.220 +    Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6));
   9.221 +    vbNodeMaps->pack_start(*box1, Gtk::PACK_SHRINK);
   9.222 +
   9.223 +    Gtk::Label* label1 =
   9.224 +      Gtk::manage(new Gtk::Label("<b>Element type</b>"));
   9.225 +    label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
   9.226 +    label1->set_use_markup();
   9.227 +    box1->pack_start(*label1, Gtk::PACK_SHRINK);
   9.228 +
   9.229 +    Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
   9.230 +    box1->pack_start(*box2, Gtk::PACK_SHRINK);
   9.231 +
   9.232 +    Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
   9.233 +    box2->pack_start(*fill1, Gtk::PACK_SHRINK);
   9.234 +
   9.235 +    Gtk::Frame* frame = Gtk::manage(new Gtk::Frame);
   9.236 +    box2->pack_start(*frame, Gtk::PACK_EXPAND_WIDGET);
   9.237 +
   9.238 +    Gtk::ScrolledWindow* swNodeMaps = Gtk::manage(new Gtk::ScrolledWindow);
   9.239 +    frame->add(*swNodeMaps);
   9.240 +
   9.241 +    swNodeMaps->add(twNodeMaps);
   9.242 +
   9.243 +    refNodeMapStore = Gtk::ListStore::create(NodeMapColumns);
   9.244 +
   9.245 +    for (std::vector<std::string>::const_iterator it =
   9.246 +        p_data->node_map_names.begin(); it != p_data->node_map_names.end();
   9.247 +        ++it)
   9.248 +    {
   9.249 +      node_tree_view_records.push_back(
   9.250 +          tree_view_record(*it, false, false, true));
   9.251 +    }
   9.252 +
   9.253 +    twNodeMaps.set_model(refNodeMapStore);
   9.254 +    twNodeMaps.append_column("Name", NodeMapColumns.colName);
   9.255 +    {
   9.256 +      int col = twNodeMaps.append_column_editable("Numeric",
   9.257 +          NodeMapColumns.colReadAsNumeric);
   9.258 +      Gtk::CellRendererToggle* pRenderer =
   9.259 +        static_cast<Gtk::CellRendererToggle*>(
   9.260 +            twNodeMaps.get_column_cell_renderer(col-1));
   9.261 +      pRenderer->signal_toggled().connect(
   9.262 +          sigc::mem_fun(*this, &FileImportDialog::onNodeMapNumericToggled));
   9.263 +    }
   9.264 +    {
   9.265 +      int col = twNodeMaps.append_column_editable("String",
   9.266 +          NodeMapColumns.colReadAsString);
   9.267 +      Gtk::CellRendererToggle* pRenderer =
   9.268 +        static_cast<Gtk::CellRendererToggle*>(
   9.269 +            twNodeMaps.get_column_cell_renderer(col-1));
   9.270 +      pRenderer->signal_toggled().connect(
   9.271 +          sigc::mem_fun(*this, &FileImportDialog::onNodeMapStringToggled));
   9.272 +    }
   9.273 +
   9.274 +    swNodeMaps->set_size_request(-1, 200);
   9.275 +    swNodeMaps->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
   9.276 +  }
   9.277 +
   9.278 +  // child widgets of vbEdgeMaps
   9.279 +  {
   9.280 +    Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6));
   9.281 +    vbEdgeMaps->pack_start(*box1, Gtk::PACK_SHRINK);
   9.282 +
   9.283 +    Gtk::Label* label1 =
   9.284 +      Gtk::manage(new Gtk::Label("<b>Element type</b>"));
   9.285 +    label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
   9.286 +    label1->set_use_markup();
   9.287 +    box1->pack_start(*label1, Gtk::PACK_SHRINK);
   9.288 +
   9.289 +    Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
   9.290 +    box1->pack_start(*box2, Gtk::PACK_SHRINK);
   9.291 +
   9.292 +    Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
   9.293 +    box2->pack_start(*fill1, Gtk::PACK_SHRINK);
   9.294 +
   9.295 +    Gtk::Frame* frame = Gtk::manage(new Gtk::Frame);
   9.296 +    box2->pack_start(*frame, Gtk::PACK_EXPAND_WIDGET);
   9.297 +
   9.298 +    Gtk::ScrolledWindow* swEdgeMaps = Gtk::manage(new Gtk::ScrolledWindow);
   9.299 +    frame->add(*swEdgeMaps);
   9.300 +
   9.301 +    swEdgeMaps->add(twEdgeMaps);
   9.302 +
   9.303 +    refEdgeMapStore = Gtk::ListStore::create(EdgeMapColumns);
   9.304 +
   9.305 +    for (std::vector<std::string>::const_iterator it =
   9.306 +        p_data->edge_map_names.begin(); it != p_data->edge_map_names.end();
   9.307 +        ++it)
   9.308 +    {
   9.309 +      edge_tree_view_records.push_back(
   9.310 +          tree_view_record(*it, false, false, true));
   9.311 +    }
   9.312 +
   9.313 +    twEdgeMaps.set_model(refEdgeMapStore);
   9.314 +    twEdgeMaps.append_column("Name", EdgeMapColumns.colName);
   9.315 +    {
   9.316 +      int col = twEdgeMaps.append_column_editable("Numeric",
   9.317 +          EdgeMapColumns.colReadAsNumeric);
   9.318 +      Gtk::CellRendererToggle* pRenderer =
   9.319 +        static_cast<Gtk::CellRendererToggle*>(
   9.320 +            twEdgeMaps.get_column_cell_renderer(col-1));
   9.321 +      pRenderer->signal_toggled().connect(
   9.322 +          sigc::mem_fun(*this, &FileImportDialog::onEdgeMapNumericToggled));
   9.323 +    }
   9.324 +    {
   9.325 +      int col = twEdgeMaps.append_column_editable("String",
   9.326 +          EdgeMapColumns.colReadAsString);
   9.327 +      Gtk::CellRendererToggle* pRenderer =
   9.328 +        static_cast<Gtk::CellRendererToggle*>(
   9.329 +            twEdgeMaps.get_column_cell_renderer(col-1));
   9.330 +      pRenderer->signal_toggled().connect(
   9.331 +          sigc::mem_fun(*this, &FileImportDialog::onEdgeMapStringToggled));
   9.332 +    }
   9.333 +
   9.334 +    swEdgeMaps->set_size_request(-1, 200);
   9.335 +    swEdgeMaps->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
   9.336 +  }
   9.337 +
   9.338 +  // fill in the ComboBoxes
   9.339 +  typedef std::vector<std::string> StrVec;
   9.340 +  for (StrVec::const_iterator it = p_data->node_map_names.begin();
   9.341 +      it != p_data->node_map_names.end(); ++it)
   9.342 +  {
   9.343 +    cbNodeCoordTwoMaps1.append_text(*it);
   9.344 +    cbNodeCoordTwoMaps2.append_text(*it);
   9.345 +  }
   9.346 +  for (StrVec::const_iterator it = p_data->edge_map_names.begin();
   9.347 +      it != p_data->edge_map_names.end(); ++it)
   9.348 +  {
   9.349 +    cbArrowCoordTwoMaps1.append_text(*it);
   9.350 +    cbArrowCoordTwoMaps2.append_text(*it);
   9.351 +  }
   9.352 +  for (StrVec::const_iterator it = p_data->xy_node_map_names.begin();
   9.353 +      it != p_data->xy_node_map_names.end(); ++it)
   9.354 +  {
   9.355 +    cbNodeCoordOneMap.append_text(*it);
   9.356 +  }
   9.357 +  for (StrVec::const_iterator it = p_data->xy_edge_map_names.begin();
   9.358 +      it != p_data->xy_edge_map_names.end(); ++it)
   9.359 +  {
   9.360 +    cbArrowCoordOneMap.append_text(*it);
   9.361 +  }
   9.362 +
   9.363 +  if (p_data->isXYNodeMap("coord"))
   9.364 +  {
   9.365 +    cbNodeCoordOneMap.set_active_text("coord");
   9.366 +  }
   9.367 +  else if (p_data->isXYNodeMap("coords"))
   9.368 +  {
   9.369 +    cbNodeCoordOneMap.set_active_text("coords");
   9.370 +  }
   9.371 +  else if (p_data->isNodeMap("coord_x") &&
   9.372 +           p_data->isNodeMap("coord_y"))
   9.373 +  {
   9.374 +    cbNodeCoordTwoMaps1.set_active_text("coord_x");
   9.375 +    cbNodeCoordTwoMaps2.set_active_text("coord_y");
   9.376 +  }
   9.377 +  else if (p_data->isNodeMap("coords_x") &&
   9.378 +           p_data->isNodeMap("coords_y"))
   9.379 +  {
   9.380 +    cbNodeCoordTwoMaps1.set_active_text("coords_x");
   9.381 +    cbNodeCoordTwoMaps2.set_active_text("coords_y");
   9.382 +  }
   9.383 +  else if (p_data->isNodeMap("x") &&
   9.384 +           p_data->isNodeMap("y"))
   9.385 +  {
   9.386 +    cbNodeCoordTwoMaps1.set_active_text("x");
   9.387 +    cbNodeCoordTwoMaps2.set_active_text("y");
   9.388 +  }
   9.389 +
   9.390 +  if (p_data->isXYEdgeMap("arrow"))
   9.391 +  {
   9.392 +    cbArrowCoordOneMap.set_active_text("arrow");
   9.393 +  }
   9.394 +  else if (p_data->isXYEdgeMap("arrows"))
   9.395 +  {
   9.396 +    cbArrowCoordOneMap.set_active_text("arrows");
   9.397 +  }
   9.398 +  else if (p_data->isXYEdgeMap("midpoint"))
   9.399 +  {
   9.400 +    cbArrowCoordOneMap.set_active_text("midpoint");
   9.401 +  }
   9.402 +  else if (p_data->isXYEdgeMap("midpoints"))
   9.403 +  {
   9.404 +    cbArrowCoordOneMap.set_active_text("midpoints");
   9.405 +  }
   9.406 +  else if (p_data->isXYEdgeMap("mid"))
   9.407 +  {
   9.408 +    cbArrowCoordOneMap.set_active_text("mid");
   9.409 +  }
   9.410 +  else if (p_data->isXYEdgeMap("mids"))
   9.411 +  {
   9.412 +    cbArrowCoordOneMap.set_active_text("mids");
   9.413 +  }
   9.414 +  else if (p_data->isEdgeMap("arrow_x") &&
   9.415 +           p_data->isEdgeMap("arrow_y"))
   9.416 +  {
   9.417 +    cbArrowCoordTwoMaps1.set_active_text("arrow_x");
   9.418 +    cbArrowCoordTwoMaps2.set_active_text("arrow_y");
   9.419 +  }
   9.420 +  else if (p_data->isEdgeMap("arrows_x") &&
   9.421 +           p_data->isEdgeMap("arrows_y"))
   9.422 +  {
   9.423 +    cbArrowCoordTwoMaps1.set_active_text("arrows_x");
   9.424 +    cbArrowCoordTwoMaps2.set_active_text("arrows_y");
   9.425 +  }
   9.426 +  else if (p_data->isEdgeMap("midpoint_x") &&
   9.427 +           p_data->isEdgeMap("midpoint_y"))
   9.428 +  {
   9.429 +    cbArrowCoordTwoMaps1.set_active_text("midpoint_x");
   9.430 +    cbArrowCoordTwoMaps2.set_active_text("midpoint_y");
   9.431 +  }
   9.432 +  else if (p_data->isEdgeMap("midpoints_x") &&
   9.433 +           p_data->isEdgeMap("midpoints_y"))
   9.434 +  {
   9.435 +    cbArrowCoordTwoMaps1.set_active_text("midpoints_x");
   9.436 +    cbArrowCoordTwoMaps2.set_active_text("midpoints_y");
   9.437 +  }
   9.438 +  else if (p_data->isEdgeMap("mid_x") &&
   9.439 +           p_data->isEdgeMap("mid_y"))
   9.440 +  {
   9.441 +    cbArrowCoordTwoMaps1.set_active_text("mid_x");
   9.442 +    cbArrowCoordTwoMaps2.set_active_text("mid_y");
   9.443 +  }
   9.444 +  else if (p_data->isEdgeMap("mids_x") &&
   9.445 +           p_data->isEdgeMap("mids_y"))
   9.446 +  {
   9.447 +    cbArrowCoordTwoMaps1.set_active_text("mids_x");
   9.448 +    cbArrowCoordTwoMaps2.set_active_text("mids_y");
   9.449 +  }
   9.450 +
   9.451 +  {
   9.452 +    if (cbNodeCoordOneMap.get_active_text() != "")
   9.453 +      rbNodeCoordOneMap.set_active();
   9.454 +    else if (cbNodeCoordTwoMaps1.get_active_text() != "")
   9.455 +      rbNodeCoordTwoMaps.set_active();
   9.456 +    else
   9.457 +      rbNodeCoordNone.set_active();
   9.458 +
   9.459 +    if (cbArrowCoordOneMap.get_active_text() != "")
   9.460 +      rbArrowCoordOneMap.set_active();
   9.461 +    else if (cbArrowCoordTwoMaps1.get_active_text() != "")
   9.462 +      rbArrowCoordTwoMaps.set_active();
   9.463 +    else
   9.464 +      rbArrowCoordNone.set_active();
   9.465 +
   9.466 +    onNodeCoordMapNumToggled();
   9.467 +    onArrowCoordMapNumToggled();
   9.468 +
   9.469 +    rbNodeCoordOneMap.signal_toggled().connect(
   9.470 +        sigc::mem_fun(*this, &FileImportDialog::onNodeCoordMapNumToggled));
   9.471 +    rbNodeCoordTwoMaps.signal_toggled().connect(
   9.472 +        sigc::mem_fun(*this, &FileImportDialog::onNodeCoordMapNumToggled));
   9.473 +    rbArrowCoordOneMap.signal_toggled().connect(
   9.474 +        sigc::mem_fun(*this, &FileImportDialog::onArrowCoordMapNumToggled));
   9.475 +    rbArrowCoordTwoMaps.signal_toggled().connect(
   9.476 +        sigc::mem_fun(*this, &FileImportDialog::onArrowCoordMapNumToggled));
   9.477 +  }
   9.478 +
   9.479 +  signal_response().connect(
   9.480 +      sigc::mem_fun(*this, &FileImportDialog::onResponse));
   9.481 +
   9.482 +  update_node_tree_view();
   9.483 +  update_edge_tree_view();
   9.484 +
   9.485 +  show_all_children();
   9.486 +}
   9.487 +
   9.488 +void FileImportDialog::onNodeCoordMapNumToggled()
   9.489 +{
   9.490 +  if (rbNodeCoordOneMap.get_active())
   9.491 +  {
   9.492 +    cbNodeCoordOneMap.get_parent()->set_sensitive(true);
   9.493 +    cbNodeCoordTwoMaps1.get_parent()->set_sensitive(false);
   9.494 +    cbNodeCoordTwoMaps2.get_parent()->set_sensitive(false);
   9.495 +
   9.496 +    p_data->node_coord_load_from = ImportData::ONE_MAP;
   9.497 +  }
   9.498 +  else if (rbNodeCoordTwoMaps.get_active())
   9.499 +  {
   9.500 +    cbNodeCoordOneMap.get_parent()->set_sensitive(false);
   9.501 +    cbNodeCoordTwoMaps1.get_parent()->set_sensitive(true);
   9.502 +    cbNodeCoordTwoMaps2.get_parent()->set_sensitive(true);
   9.503 +
   9.504 +    p_data->node_coord_load_from = ImportData::TWO_MAPS;
   9.505 +  }
   9.506 +  else if (rbNodeCoordNone.get_active())
   9.507 +  {
   9.508 +    cbNodeCoordOneMap.get_parent()->set_sensitive(false);
   9.509 +    cbNodeCoordTwoMaps1.get_parent()->set_sensitive(false);
   9.510 +    cbNodeCoordTwoMaps2.get_parent()->set_sensitive(false);
   9.511 +
   9.512 +    p_data->node_coord_load_from = ImportData::DONT_READ;
   9.513 +  }
   9.514 +  update_node_tree_view();
   9.515 +}
   9.516 +
   9.517 +void FileImportDialog::onArrowCoordMapNumToggled()
   9.518 +{
   9.519 +  if (rbArrowCoordOneMap.get_active())
   9.520 +  {
   9.521 +    cbArrowCoordOneMap.get_parent()->set_sensitive(true);
   9.522 +    cbArrowCoordTwoMaps1.get_parent()->set_sensitive(false);
   9.523 +    cbArrowCoordTwoMaps2.get_parent()->set_sensitive(false);
   9.524 +
   9.525 +    p_data->arrow_coord_load_from = ImportData::ONE_MAP;
   9.526 +  }
   9.527 +  else if (rbArrowCoordTwoMaps.get_active())
   9.528 +  {
   9.529 +    cbArrowCoordOneMap.get_parent()->set_sensitive(false);
   9.530 +    cbArrowCoordTwoMaps1.get_parent()->set_sensitive(true);
   9.531 +    cbArrowCoordTwoMaps2.get_parent()->set_sensitive(true);
   9.532 +
   9.533 +    p_data->arrow_coord_load_from = ImportData::TWO_MAPS;
   9.534 +  }
   9.535 +  else if (rbArrowCoordNone.get_active())
   9.536 +  {
   9.537 +    cbArrowCoordOneMap.get_parent()->set_sensitive(false);
   9.538 +    cbArrowCoordTwoMaps1.get_parent()->set_sensitive(false);
   9.539 +    cbArrowCoordTwoMaps2.get_parent()->set_sensitive(false);
   9.540 +
   9.541 +    p_data->arrow_coord_load_from = ImportData::DONT_READ;
   9.542 +  }
   9.543 +  update_edge_tree_view();
   9.544 +}
   9.545 +
   9.546 +FileImportDialog::~FileImportDialog()
   9.547 +{
   9.548 +}
   9.549 +
   9.550 +void FileImportDialog::onResponse(int id)
   9.551 +{
   9.552 +  if (id == Gtk::RESPONSE_OK)
   9.553 +  {
   9.554 +    if ((rbNodeCoordOneMap.get_active() &&
   9.555 +          cbNodeCoordOneMap.get_active_text() == "") ||
   9.556 +        (rbNodeCoordTwoMaps.get_active() &&
   9.557 +         (cbNodeCoordTwoMaps1.get_active_text() == "" ||
   9.558 +          cbNodeCoordTwoMaps2.get_active_text() == "")))
   9.559 +    {
   9.560 +      Gtk::MessageDialog mdialog("No node map selected.",
   9.561 +          false, Gtk::MESSAGE_ERROR);
   9.562 +      mdialog.run();
   9.563 +      return;
   9.564 +    }
   9.565 +    else if (rbNodeCoordTwoMaps.get_active() &&
   9.566 +             cbNodeCoordTwoMaps1.get_active_text() == 
   9.567 +             cbNodeCoordTwoMaps2.get_active_text())
   9.568 +    {
   9.569 +      Gtk::MessageDialog mdialog(
   9.570 +          "Same node map selected for both coordinates.",
   9.571 +          false, Gtk::MESSAGE_ERROR);
   9.572 +      mdialog.run();
   9.573 +      return;
   9.574 +    }
   9.575 +    if ((rbArrowCoordOneMap.get_active() &&
   9.576 +          cbArrowCoordOneMap.get_active_text() == "") ||
   9.577 +        (rbArrowCoordTwoMaps.get_active() &&
   9.578 +         (cbArrowCoordTwoMaps1.get_active_text() == "" ||
   9.579 +          cbArrowCoordTwoMaps2.get_active_text() == "")))
   9.580 +    {
   9.581 +      Gtk::MessageDialog mdialog("No edge map selected.",
   9.582 +          false, Gtk::MESSAGE_ERROR);
   9.583 +      mdialog.run();
   9.584 +      return;
   9.585 +    }
   9.586 +    else if (rbArrowCoordTwoMaps.get_active() &&
   9.587 +             cbArrowCoordTwoMaps1.get_active_text() == 
   9.588 +             cbArrowCoordTwoMaps2.get_active_text())
   9.589 +    {
   9.590 +      Gtk::MessageDialog mdialog(
   9.591 +          "Same edge map selected for both coordinates.",
   9.592 +          false, Gtk::MESSAGE_ERROR);
   9.593 +      mdialog.run();
   9.594 +      return;
   9.595 +    }
   9.596 +
   9.597 +    for (std::vector<tree_view_record>::const_iterator it =
   9.598 +        node_tree_view_records.begin(); it != node_tree_view_records.end();
   9.599 +        ++it)
   9.600 +    {
   9.601 +      if (it->visible)
   9.602 +      {
   9.603 +        if (it->numeric)
   9.604 +          p_data->numeric_node_map_names.push_back(it->name);
   9.605 +        if (it->string)
   9.606 +          p_data->string_node_map_names.push_back(it->name);
   9.607 +      }
   9.608 +    }
   9.609 +
   9.610 +    for (std::vector<tree_view_record>::const_iterator it =
   9.611 +        edge_tree_view_records.begin(); it != edge_tree_view_records.end();
   9.612 +        ++it)
   9.613 +    {
   9.614 +      if (it->visible)
   9.615 +      {
   9.616 +        if (it->numeric)
   9.617 +          p_data->numeric_edge_map_names.push_back(it->name);
   9.618 +        if (it->string)
   9.619 +          p_data->string_edge_map_names.push_back(it->name);
   9.620 +      }
   9.621 +    }
   9.622 +  }
   9.623 +}
   9.624 +
   9.625 +FileImportDialog::ImportData::ImportData(
   9.626 +    const std::vector<std::string>& _node_map_names,
   9.627 +    const std::vector<std::string>& _edge_map_names) :
   9.628 +  node_map_names(_node_map_names),
   9.629 +  edge_map_names(_edge_map_names)
   9.630 +{
   9.631 +  typedef std::vector<std::string> StrVec;
   9.632 +  {
   9.633 +    StrVec xMaps;
   9.634 +    StrVec yMaps;
   9.635 +    // collect map names ending with ":x" and ":y"
   9.636 +    for (StrVec::const_iterator it = node_map_names.begin();
   9.637 +        it != node_map_names.end(); ++it)
   9.638 +    {
   9.639 +      if ((it->length() >= 3) &&
   9.640 +          (it->substr(it->length()-2, it->length())  == ":x"))
   9.641 +      {
   9.642 +        xMaps.push_back(it->substr(0, it->length()-2));
   9.643 +      }
   9.644 +      if ((it->length() >= 3) &&
   9.645 +          (it->substr(it->length()-2, it->length())  == ":y"))
   9.646 +      {
   9.647 +        yMaps.push_back(it->substr(0, it->length()-2));
   9.648 +      }
   9.649 +    }
   9.650 +
   9.651 +    for (StrVec::const_iterator it1 = xMaps.begin();
   9.652 +        it1 != xMaps.end(); ++it1)
   9.653 +    {
   9.654 +      for (StrVec::const_iterator it2 = yMaps.begin();
   9.655 +          it2 != yMaps.end(); ++it2)
   9.656 +      {
   9.657 +        if (*it1 == *it2) xy_node_map_names.push_back(*it1);
   9.658 +      }
   9.659 +    }
   9.660 +  }
   9.661 +  {
   9.662 +    StrVec xMaps;
   9.663 +    StrVec yMaps;
   9.664 +    // collect map names ending with ":x" and ":y"
   9.665 +    for (StrVec::const_iterator it = edge_map_names.begin();
   9.666 +        it != edge_map_names.end(); ++it)
   9.667 +    {
   9.668 +      if ((it->length() >= 3) &&
   9.669 +          (it->substr(it->length()-2, it->length())  == ":x"))
   9.670 +      {
   9.671 +        xMaps.push_back(it->substr(0, it->length()-2));
   9.672 +      }
   9.673 +      if ((it->length() >= 3) &&
   9.674 +          (it->substr(it->length()-2, it->length())  == ":y"))
   9.675 +      {
   9.676 +        yMaps.push_back(it->substr(0, it->length()-2));
   9.677 +      }
   9.678 +    }
   9.679 +
   9.680 +    for (StrVec::const_iterator it1 = xMaps.begin();
   9.681 +        it1 != xMaps.end(); ++it1)
   9.682 +    {
   9.683 +      for (StrVec::const_iterator it2 = yMaps.begin();
   9.684 +          it2 != yMaps.end(); ++it2)
   9.685 +      {
   9.686 +        if (*it1 == *it2) xy_edge_map_names.push_back(*it1);
   9.687 +      }
   9.688 +    }
   9.689 +  }
   9.690 +}
   9.691 +
   9.692 +FileImportDialog::ImportData::~ImportData()
   9.693 +{
   9.694 +}
   9.695 +
   9.696 +bool FileImportDialog::ImportData::isXYNodeMap(const std::string& name)
   9.697 +{
   9.698 +  if (isNodeMap(name + ":x") && isNodeMap(name + ":y")) return true;
   9.699 +  return false;
   9.700 +}
   9.701 +
   9.702 +bool FileImportDialog::ImportData::isXYEdgeMap(const std::string& name)
   9.703 +{
   9.704 +  if (isEdgeMap(name + ":x") && isEdgeMap(name + ":y")) return true;
   9.705 +  return false;
   9.706 +}
   9.707 +
   9.708 +bool FileImportDialog::ImportData::isNodeMap(const std::string& name)
   9.709 +{
   9.710 +  if (contains(node_map_names, name)) return true;
   9.711 +  return false;
   9.712 +}
   9.713 +
   9.714 +bool FileImportDialog::ImportData::isEdgeMap(const std::string& name)
   9.715 +{
   9.716 +  if (contains(edge_map_names, name)) return true;
   9.717 +  return false;
   9.718 +}
   9.719 +
   9.720 +bool FileImportDialog::ImportData::contains(const std::vector<std::string>& vec,
   9.721 +    const std::string& str)
   9.722 +{
   9.723 +  for (std::vector<std::string>::const_iterator it = vec.begin();
   9.724 +      it != vec.end(); ++it)
   9.725 +  {
   9.726 +    if (*it == str) return true;
   9.727 +  }
   9.728 +  return false;
   9.729 +}
   9.730 +
   9.731 +void FileImportDialog::onNodeCoordOneMapChanged()
   9.732 +{
   9.733 +  p_data->node_coord_one_map_name = cbNodeCoordOneMap.get_active_text();
   9.734 +  update_node_tree_view();
   9.735 +}
   9.736 +
   9.737 +void FileImportDialog::onNodeCoordTwoMaps1Changed()
   9.738 +{
   9.739 +  p_data->node_coord_two_maps_1_name = cbNodeCoordTwoMaps1.get_active_text();
   9.740 +  update_node_tree_view();
   9.741 +}
   9.742 +
   9.743 +void FileImportDialog::onNodeCoordTwoMaps2Changed()
   9.744 +{
   9.745 +  p_data->node_coord_two_maps_2_name = cbNodeCoordTwoMaps2.get_active_text();
   9.746 +  update_node_tree_view();
   9.747 +}
   9.748 +
   9.749 +void FileImportDialog::onArrowCoordOneMapChanged()
   9.750 +{
   9.751 +  p_data->arrow_coord_one_map_name = cbArrowCoordOneMap.get_active_text();
   9.752 +  update_edge_tree_view();
   9.753 +}
   9.754 +
   9.755 +void FileImportDialog::onArrowCoordTwoMaps1Changed()
   9.756 +{
   9.757 +  p_data->arrow_coord_two_maps_1_name = cbArrowCoordTwoMaps1.get_active_text();
   9.758 +  update_edge_tree_view();
   9.759 +}
   9.760 +
   9.761 +void FileImportDialog::onArrowCoordTwoMaps2Changed()
   9.762 +{
   9.763 +  p_data->arrow_coord_two_maps_2_name = cbArrowCoordTwoMaps2.get_active_text();
   9.764 +  update_edge_tree_view();
   9.765 +}
   9.766 +
   9.767 +void FileImportDialog::onNodeMapNumericToggled(const Glib::ustring& path)
   9.768 +{
   9.769 +  Gtk::TreeModel::iterator iter = refNodeMapStore->get_iter(
   9.770 +      Gtk::TreeModel::Path(path));
   9.771 +  Gtk::TreeModel::Row row = *iter;
   9.772 +  std::vector<tree_view_record>::iterator it;
   9.773 +  for (it = node_tree_view_records.begin();
   9.774 +      it != node_tree_view_records.end(); ++it)
   9.775 +  {
   9.776 +    if (it->name == row[NodeMapColumns.colName]) break;
   9.777 +  }
   9.778 +  if (row[NodeMapColumns.colReadAsNumeric])
   9.779 +  {
   9.780 +    row[NodeMapColumns.colReadAsString] = false;
   9.781 +    it->string = false;
   9.782 +    it->numeric = true;
   9.783 +  }
   9.784 +}
   9.785 +
   9.786 +void FileImportDialog::onNodeMapStringToggled(const Glib::ustring& path)
   9.787 +{
   9.788 +  Gtk::TreeModel::iterator iter = refNodeMapStore->get_iter(
   9.789 +      Gtk::TreeModel::Path(path));
   9.790 +  Gtk::TreeModel::Row row = *iter;
   9.791 +  std::vector<tree_view_record>::iterator it;
   9.792 +  for (it = node_tree_view_records.begin();
   9.793 +      it != node_tree_view_records.end(); ++it)
   9.794 +  {
   9.795 +    if (it->name == row[NodeMapColumns.colName]) break;
   9.796 +  }
   9.797 +  if (row[NodeMapColumns.colReadAsString])
   9.798 +  {
   9.799 +    row[NodeMapColumns.colReadAsNumeric] = false;
   9.800 +    it->string = true;
   9.801 +    it->numeric = false;
   9.802 +  }
   9.803 +}
   9.804 +
   9.805 +void FileImportDialog::update_node_tree_view()
   9.806 +{
   9.807 +  for (std::vector<tree_view_record>::iterator it =
   9.808 +      node_tree_view_records.begin(); it != node_tree_view_records.end(); ++it)
   9.809 +  {
   9.810 +    it->visible = true;
   9.811 +  }
   9.812 +  switch (p_data->node_coord_load_from)
   9.813 +  {
   9.814 +    case ImportData::ONE_MAP:
   9.815 +      for (std::vector<tree_view_record>::iterator it =
   9.816 +          node_tree_view_records.begin(); it !=
   9.817 +          node_tree_view_records.end(); ++it)
   9.818 +      {
   9.819 +        if (it->name == p_data->node_coord_one_map_name)
   9.820 +          it->visible = false;
   9.821 +      }
   9.822 +      break;
   9.823 +    case ImportData::TWO_MAPS:
   9.824 +      for (std::vector<tree_view_record>::iterator it =
   9.825 +          node_tree_view_records.begin(); it !=
   9.826 +          node_tree_view_records.end(); ++it)
   9.827 +      {
   9.828 +        if ((it->name == p_data->node_coord_two_maps_1_name) ||
   9.829 +            (it->name == p_data->node_coord_two_maps_2_name))
   9.830 +          it->visible = false;
   9.831 +      }
   9.832 +      break;
   9.833 +    case ImportData::DONT_READ:
   9.834 +      break;
   9.835 +  }
   9.836 +  refNodeMapStore->clear();
   9.837 +  for (std::vector<tree_view_record>::iterator it =
   9.838 +      node_tree_view_records.begin(); it != node_tree_view_records.end(); ++it)
   9.839 +  {
   9.840 +    if (it->visible)
   9.841 +    {
   9.842 +      Gtk::TreeModel::Row row = *(refNodeMapStore->append());
   9.843 +      row[NodeMapColumns.colName] = it->name;
   9.844 +      row[NodeMapColumns.colReadAsNumeric] = it->numeric;
   9.845 +      row[NodeMapColumns.colReadAsString] = it->string;
   9.846 +    }
   9.847 +  }
   9.848 +}
   9.849 +
   9.850 +void FileImportDialog::onEdgeMapNumericToggled(const Glib::ustring& path)
   9.851 +{
   9.852 +  Gtk::TreeModel::iterator iter = refEdgeMapStore->get_iter(
   9.853 +      Gtk::TreeModel::Path(path));
   9.854 +  Gtk::TreeModel::Row row = *iter;
   9.855 +  std::vector<tree_view_record>::iterator it;
   9.856 +  for (it = edge_tree_view_records.begin();
   9.857 +      it != edge_tree_view_records.end(); ++it)
   9.858 +  {
   9.859 +    if (it->name == row[EdgeMapColumns.colName]) break;
   9.860 +  }
   9.861 +  if (row[EdgeMapColumns.colReadAsNumeric])
   9.862 +  {
   9.863 +    row[EdgeMapColumns.colReadAsString] = false;
   9.864 +    it->string = false;
   9.865 +    it->numeric = true;
   9.866 +  }
   9.867 +}
   9.868 +
   9.869 +void FileImportDialog::onEdgeMapStringToggled(const Glib::ustring& path)
   9.870 +{
   9.871 +  Gtk::TreeModel::iterator iter = refEdgeMapStore->get_iter(
   9.872 +      Gtk::TreeModel::Path(path));
   9.873 +  Gtk::TreeModel::Row row = *iter;
   9.874 +  std::vector<tree_view_record>::iterator it;
   9.875 +  for (it = edge_tree_view_records.begin();
   9.876 +      it != edge_tree_view_records.end(); ++it)
   9.877 +  {
   9.878 +    if (it->name == row[EdgeMapColumns.colName]) break;
   9.879 +  }
   9.880 +  if (row[EdgeMapColumns.colReadAsString])
   9.881 +  {
   9.882 +    row[EdgeMapColumns.colReadAsNumeric] = false;
   9.883 +    it->string = true;
   9.884 +    it->numeric = false;
   9.885 +  }
   9.886 +}
   9.887 +
   9.888 +void FileImportDialog::update_edge_tree_view()
   9.889 +{
   9.890 +  for (std::vector<tree_view_record>::iterator it =
   9.891 +      edge_tree_view_records.begin(); it != edge_tree_view_records.end(); ++it)
   9.892 +  {
   9.893 +    it->visible = true;
   9.894 +  }
   9.895 +  switch (p_data->arrow_coord_load_from)
   9.896 +  {
   9.897 +    case ImportData::ONE_MAP:
   9.898 +      for (std::vector<tree_view_record>::iterator it =
   9.899 +          edge_tree_view_records.begin(); it !=
   9.900 +          edge_tree_view_records.end(); ++it)
   9.901 +      {
   9.902 +        if (it->name == p_data->arrow_coord_one_map_name)
   9.903 +          it->visible = false;
   9.904 +      }
   9.905 +      break;
   9.906 +    case ImportData::TWO_MAPS:
   9.907 +      for (std::vector<tree_view_record>::iterator it =
   9.908 +          edge_tree_view_records.begin(); it !=
   9.909 +          edge_tree_view_records.end(); ++it)
   9.910 +      {
   9.911 +        if ((it->name == p_data->arrow_coord_two_maps_1_name) ||
   9.912 +            (it->name == p_data->arrow_coord_two_maps_2_name))
   9.913 +          it->visible = false;
   9.914 +      }
   9.915 +      break;
   9.916 +    case ImportData::DONT_READ:
   9.917 +      break;
   9.918 +  }
   9.919 +  refEdgeMapStore->clear();
   9.920 +  for (std::vector<tree_view_record>::iterator it =
   9.921 +      edge_tree_view_records.begin(); it != edge_tree_view_records.end(); ++it)
   9.922 +  {
   9.923 +    if (it->visible)
   9.924 +    {
   9.925 +      Gtk::TreeModel::Row row = *(refEdgeMapStore->append());
   9.926 +      row[EdgeMapColumns.colName] = it->name;
   9.927 +      row[EdgeMapColumns.colReadAsNumeric] = it->numeric;
   9.928 +      row[EdgeMapColumns.colReadAsString] = it->string;
   9.929 +    }
   9.930 +  }
   9.931 +}
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/file_import_dialog.h	Wed Jan 02 21:03:09 2008 +0000
    10.3 @@ -0,0 +1,137 @@
    10.4 +#ifndef FILE_IMPORT_DIALOG
    10.5 +#define FILE_IMPORT_DIALOG
    10.6 +
    10.7 +#include <gtkmm/dialog.h>
    10.8 +#include <gtkmm/radiobutton.h>
    10.9 +#include <gtkmm/comboboxtext.h>
   10.10 +#include <gtkmm/sizegroup.h>
   10.11 +#include <gtkmm/treemodel.h>
   10.12 +#include <gtkmm/liststore.h>
   10.13 +#include <gtkmm/treeview.h>
   10.14 +#include <gtkmm/scrolledwindow.h>
   10.15 +
   10.16 +class FileImportDialog : public Gtk::Dialog
   10.17 +{
   10.18 +  public:
   10.19 +    struct ImportData
   10.20 +    {
   10.21 +        ImportData(
   10.22 +            const std::vector<std::string>& _node_map_names,
   10.23 +            const std::vector<std::string>& _edge_map_names);
   10.24 +
   10.25 +        ~ImportData();
   10.26 +
   10.27 +        std::vector<std::string> node_map_names;
   10.28 +        std::vector<std::string> edge_map_names;
   10.29 +
   10.30 +        std::vector<std::string> xy_node_map_names;
   10.31 +        std::vector<std::string> xy_edge_map_names;
   10.32 +
   10.33 +        bool contains(
   10.34 +            const std::vector<std::string>& vec,
   10.35 +            const std::string& str);
   10.36 +
   10.37 +        std::string node_coord_one_map_name;
   10.38 +        std::string node_coord_two_maps_1_name;
   10.39 +        std::string node_coord_two_maps_2_name;
   10.40 +        std::string arrow_coord_one_map_name;
   10.41 +        std::string arrow_coord_two_maps_1_name;
   10.42 +        std::string arrow_coord_two_maps_2_name;
   10.43 +
   10.44 +        enum ReadOpts { ONE_MAP, TWO_MAPS, DONT_READ };
   10.45 +        ReadOpts node_coord_load_from;
   10.46 +        ReadOpts arrow_coord_load_from;
   10.47 +
   10.48 +        bool isXYNodeMap(const std::string& name);
   10.49 +        bool isXYEdgeMap(const std::string& name);
   10.50 +        bool isNodeMap(const std::string& name);
   10.51 +        bool isEdgeMap(const std::string& name);
   10.52 +
   10.53 +        std::vector<std::string> numeric_node_map_names;
   10.54 +        std::vector<std::string> string_node_map_names;
   10.55 +        std::vector<std::string> numeric_edge_map_names;
   10.56 +        std::vector<std::string> string_edge_map_names;
   10.57 +    };
   10.58 +
   10.59 +    ImportData* p_data;
   10.60 +
   10.61 +    Gtk::RadioButton rbNodeCoordNone;
   10.62 +    Gtk::RadioButton rbNodeCoordOneMap;
   10.63 +    Gtk::RadioButton rbNodeCoordTwoMaps;
   10.64 +
   10.65 +    Gtk::RadioButton rbArrowCoordNone;
   10.66 +    Gtk::RadioButton rbArrowCoordOneMap;
   10.67 +    Gtk::RadioButton rbArrowCoordTwoMaps;
   10.68 +
   10.69 +    Gtk::ComboBoxText cbNodeCoordOneMap;
   10.70 +    Gtk::ComboBoxText cbNodeCoordTwoMaps1;
   10.71 +    Gtk::ComboBoxText cbNodeCoordTwoMaps2;
   10.72 +
   10.73 +    Gtk::ComboBoxText cbArrowCoordOneMap;
   10.74 +    Gtk::ComboBoxText cbArrowCoordTwoMaps1;
   10.75 +    Gtk::ComboBoxText cbArrowCoordTwoMaps2;
   10.76 +
   10.77 +    void onNodeCoordMapNumToggled();
   10.78 +    void onArrowCoordMapNumToggled();
   10.79 +
   10.80 +    void onResponse(int id);
   10.81 +
   10.82 +    void onNodeCoordOneMapChanged();
   10.83 +    void onNodeCoordTwoMaps1Changed();
   10.84 +    void onNodeCoordTwoMaps2Changed();
   10.85 +
   10.86 +    void onArrowCoordOneMapChanged();
   10.87 +    void onArrowCoordTwoMaps1Changed();
   10.88 +    void onArrowCoordTwoMaps2Changed();
   10.89 +
   10.90 +    struct MapModelColumns : public Gtk::TreeModel::ColumnRecord
   10.91 +    {
   10.92 +      MapModelColumns()
   10.93 +      {
   10.94 +        add(colName);
   10.95 +        add(colReadAsNumeric);
   10.96 +        add(colReadAsString);
   10.97 +      }
   10.98 +      Gtk::TreeModelColumn<Glib::ustring> colName;
   10.99 +      Gtk::TreeModelColumn<bool> colReadAsNumeric;
  10.100 +      Gtk::TreeModelColumn<bool> colReadAsString;
  10.101 +    };
  10.102 +
  10.103 +    Gtk::TreeView twNodeMaps;
  10.104 +    MapModelColumns NodeMapColumns;
  10.105 +    Glib::RefPtr<Gtk::ListStore> refNodeMapStore;
  10.106 +    void onNodeMapNumericToggled(const Glib::ustring& path);
  10.107 +    void onNodeMapStringToggled(const Glib::ustring& path);
  10.108 +
  10.109 +    Gtk::TreeView twEdgeMaps;
  10.110 +    MapModelColumns EdgeMapColumns;
  10.111 +    Glib::RefPtr<Gtk::ListStore> refEdgeMapStore;
  10.112 +    void onEdgeMapNumericToggled(const Glib::ustring& path);
  10.113 +    void onEdgeMapStringToggled(const Glib::ustring& path);
  10.114 +
  10.115 +    struct tree_view_record
  10.116 +    {
  10.117 +      tree_view_record(const std::string& _name, bool _numeric, bool _string,
  10.118 +          bool _visible) :
  10.119 +        name(_name),
  10.120 +        numeric(_numeric),
  10.121 +        string(_string),
  10.122 +        visible(_visible) {}
  10.123 +      std::string name;
  10.124 +      bool numeric;
  10.125 +      bool string;
  10.126 +      bool visible;
  10.127 +    };
  10.128 +
  10.129 +    std::vector<tree_view_record> node_tree_view_records;
  10.130 +    void update_node_tree_view();
  10.131 +
  10.132 +    std::vector<tree_view_record> edge_tree_view_records;
  10.133 +    void update_edge_tree_view();
  10.134 +
  10.135 +  public:
  10.136 +    FileImportDialog(ImportData* d);
  10.137 +    ~FileImportDialog();
  10.138 +};
  10.139 +
  10.140 +#endif
    11.1 --- a/gdc-broken_edge.cc	Wed May 02 20:33:58 2007 +0000
    11.2 +++ b/gdc-broken_edge.cc	Wed Jan 02 21:03:09 2008 +0000
    11.3 @@ -36,7 +36,7 @@
    11.4  void GraphDisplayerCanvas::EdgeBase::drawArrow(XY unit_vector_in_dir)
    11.5  {
    11.6    MapStorage& ms = *canvas.mytab.mapstorage;
    11.7 -  XY center(ms.arrow_pos[edge]);
    11.8 +  XY center(ms.getArrowCoords(edge));
    11.9    XY unit_norm_vector(0-unit_vector_in_dir.y, unit_vector_in_dir.x);
   11.10  
   11.11    //       /\       // top
   11.12 @@ -89,8 +89,8 @@
   11.13    MapStorage& ms = *canvas.mytab.mapstorage;
   11.14  
   11.15    //calculating coordinates of the direction indicator arrow
   11.16 -  XY head(ms.coords[ms.graph.target(edge)]);
   11.17 -  XY center(ms.arrow_pos[edge]);
   11.18 +  XY head(ms.getNodeCoords(ms.graph.target(edge)));
   11.19 +  XY center(ms.getArrowCoords(edge));
   11.20  
   11.21    XY unit_vector_in_dir(head-center);
   11.22    double length=sqrt( unit_vector_in_dir.normSquare() );
   11.23 @@ -107,12 +107,12 @@
   11.24    Gnome::Canvas::Points points;
   11.25    Node source = ms.graph.source(edge);
   11.26    Node target = ms.graph.target(edge);
   11.27 -  points.push_back(Gnome::Art::Point(ms.coords[source].x,
   11.28 -        ms.coords[source].y));
   11.29 -  points.push_back(Gnome::Art::Point(ms.arrow_pos[edge].x,
   11.30 -        ms.arrow_pos[edge].y));
   11.31 -  points.push_back(Gnome::Art::Point(ms.coords[target].x,
   11.32 -        ms.coords[target].y));
   11.33 +  points.push_back(Gnome::Art::Point(ms.getNodeCoords(source).x,
   11.34 +        ms.getNodeCoords(source).y));
   11.35 +  points.push_back(Gnome::Art::Point(ms.getArrowCoords(edge).x,
   11.36 +        ms.getArrowCoords(edge).y));
   11.37 +  points.push_back(Gnome::Art::Point(ms.getNodeCoords(target).x,
   11.38 +        ms.getNodeCoords(target).y));
   11.39    line.property_points().set_value(points);
   11.40  }
   11.41  
   11.42 @@ -152,10 +152,10 @@
   11.43  
   11.44          Gnome::Canvas::Points points_new;
   11.45  
   11.46 -        canvas.mytab.mapstorage->arrow_pos.set(edge, canvas.mytab.mapstorage->arrow_pos[edge] + XY(dx, dy));
   11.47 +        canvas.mytab.mapstorage->setArrowCoords(edge, canvas.mytab.mapstorage->getArrowCoords(edge) + XY(dx, dy));
   11.48  
   11.49          draw();
   11.50 -        canvas.textReposition(canvas.mytab.mapstorage->arrow_pos[edge]);
   11.51 +        canvas.textReposition(canvas.mytab.mapstorage->getArrowCoords(edge));
   11.52  
   11.53          clicked_x=e->motion.x;
   11.54          clicked_y=e->motion.y;
   11.55 @@ -199,16 +199,16 @@
   11.56    MapStorage& ms = *canvas.mytab.mapstorage;
   11.57  
   11.58    Node node = ms.graph.source(edge);
   11.59 -  XY center = (ms.coords[node] + ms.arrow_pos[edge]) / 2.0;
   11.60 +  XY center = (ms.getNodeCoords(node) + ms.getArrowCoords(edge)) / 2.0;
   11.61  
   11.62 -  XY unit_vector_in_dir(rot90(center - ms.arrow_pos[edge]));
   11.63 +  XY unit_vector_in_dir(rot90(center - ms.getArrowCoords(edge)));
   11.64    double length = sqrt(unit_vector_in_dir.normSquare());
   11.65    unit_vector_in_dir /= length;
   11.66  
   11.67    drawArrow(unit_vector_in_dir);
   11.68  
   11.69    double radius =
   11.70 -    sqrt((ms.arrow_pos[edge] - ms.coords[node]).normSquare()) / 2.0;
   11.71 +    sqrt((ms.getArrowCoords(edge) - ms.getNodeCoords(node)).normSquare()) / 2.0;
   11.72  
   11.73    XY p1 = center + XY(-radius,  radius);
   11.74    XY p2 = center + XY( radius, -radius);
   11.75 @@ -249,10 +249,10 @@
   11.76      case GDK_MOTION_NOTIFY:
   11.77        if(isbutton)
   11.78        {
   11.79 -        canvas.mytab.mapstorage->arrow_pos.set(edge, XY(e->motion.x, e->motion.y));
   11.80 +        canvas.mytab.mapstorage->setArrowCoords(edge, XY(e->motion.x, e->motion.y));
   11.81  
   11.82          draw();
   11.83 -        canvas.textReposition(canvas.mytab.mapstorage->arrow_pos[edge]);
   11.84 +        canvas.textReposition(canvas.mytab.mapstorage->getArrowCoords(edge));
   11.85        }
   11.86      default: break;
   11.87    }
    12.1 --- a/graph-displayer.cc	Wed May 02 20:33:58 2007 +0000
    12.2 +++ b/graph-displayer.cc	Wed Jan 02 21:03:09 2008 +0000
    12.3 @@ -95,15 +95,15 @@
    12.4  //       mytab.readFile(argv[1]);
    12.5  //     }
    12.6    if(argc>=2)
    12.7 +  {
    12.8 +    for(int i=1;i<argc;i++)
    12.9      {
   12.10 -      for(int i=1;i<argc;i++)
   12.11 -	{
   12.12 -	  if(Glib::file_test(argv[i], Glib::FILE_TEST_IS_REGULAR))
   12.13 -	    {
   12.14 -	      mytab.readFile(argv[i]);
   12.15 -	    }
   12.16 -	}
   12.17 +      if(Glib::file_test(argv[i], Glib::FILE_TEST_IS_REGULAR))
   12.18 +      {
   12.19 +        mytab.readFile(argv[i]);
   12.20 +      }
   12.21      }
   12.22 +  }
   12.23    else
   12.24      {
   12.25        mytab.newTab();
    13.1 --- a/graph_displayer_canvas-edge.cc	Wed May 02 20:33:58 2007 +0000
    13.2 +++ b/graph_displayer_canvas-edge.cc	Wed Jan 02 21:03:09 2008 +0000
    13.3 @@ -25,126 +25,143 @@
    13.4  
    13.5  int GraphDisplayerCanvas::resetEdgeWidth (Edge edge)
    13.6  {
    13.7 +  MapStorage& ms = *mytab.mapstorage;
    13.8    double min, max;
    13.9  
   13.10    min=edge_property_defaults[E_WIDTH];
   13.11    max=edge_property_defaults[E_WIDTH];
   13.12 -  Graph::EdgeMap<double> actual_map((mytab.mapstorage)->graph,edge_property_defaults[E_WIDTH]);
   13.13 -  
   13.14 +  Graph::EdgeMap<double> actual_map(ms.graph,edge_property_defaults[E_WIDTH]);
   13.15 +
   13.16    if(edge==INVALID)
   13.17 +  {
   13.18 +    for (EdgeIt i(ms.graph); i!=INVALID; ++i)
   13.19      {
   13.20 -      for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
   13.21 -	{
   13.22 -	  double v=fabs(actual_map[i]);
   13.23 -	  int w;
   13.24 -	  if(min==max)
   13.25 -	    {
   13.26 -	      w=(int)(edge_property_defaults[E_WIDTH]);
   13.27 -	    }
   13.28 -	  else
   13.29 -	    {
   13.30 -	      w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH));
   13.31 -	    }
   13.32 -	  if(zoomtrack)
   13.33 -	    {
   13.34 -	      double actual_ppu=get_pixels_per_unit();
   13.35 -	      w=(int)(w/actual_ppu*fixed_zoom_factor);
   13.36 -	    }
   13.37 -	  edgesmap[i]->setLineWidth(w);
   13.38 -	}
   13.39 +      double v=fabs(actual_map[i]);
   13.40 +      int w;
   13.41 +      if(min==max)
   13.42 +      {
   13.43 +        w=(int)(edge_property_defaults[E_WIDTH]);
   13.44 +      }
   13.45 +      else
   13.46 +      {
   13.47 +        w=(int)(MIN_EDGE_WIDTH+(v-min)/(max-min)*(MAX_EDGE_WIDTH-MIN_EDGE_WIDTH));
   13.48 +      }
   13.49 +      if(zoomtrack)
   13.50 +      {
   13.51 +        double actual_ppu=get_pixels_per_unit();
   13.52 +        w=(int)(w/actual_ppu*fixed_zoom_factor);
   13.53 +      }
   13.54 +      edgesmap[i]->setLineWidth(w);
   13.55      }
   13.56 +  }
   13.57    else
   13.58 +  {
   13.59 +    int w=(int)actual_map[edge];
   13.60 +    if(w>=0)
   13.61      {
   13.62 -      int w=(int)actual_map[edge];
   13.63 -      if(w>=0)
   13.64 -	{
   13.65 -	  edgesmap[edge]->setLineWidth(w);
   13.66 -	}
   13.67 +      edgesmap[edge]->setLineWidth(w);
   13.68      }
   13.69 +  }
   13.70    return 0;
   13.71  }
   13.72  
   13.73  
   13.74  int GraphDisplayerCanvas::changeEdgeWidth (std::string mapname, Edge edge)
   13.75  {
   13.76 -  Graph::EdgeMap<double> * actual_map;
   13.77 +  MapStorage& ms = *mytab.mapstorage;
   13.78    double min, max;
   13.79  
   13.80 -  min=(mytab.mapstorage)->minOfEdgeMap(mapname);
   13.81 -  max=(mytab.mapstorage)->maxOfEdgeMap(mapname);
   13.82 -  actual_map=((mytab.mapstorage)->edgemap_storage)[mapname];
   13.83 +  {
   13.84 +    EdgeIt e(ms.graph);
   13.85 +    min = max = ms.get(mapname, e);
   13.86 +    for (; e != INVALID; ++e)
   13.87 +    {
   13.88 +      if (static_cast<double>(ms.get(mapname, e)) > max)
   13.89 +        max = ms.get(mapname, e);
   13.90 +      if (static_cast<double>(ms.get(mapname, e)) < min)
   13.91 +        min = ms.get(mapname, e);
   13.92 +    }
   13.93 +  }
   13.94  
   13.95    if(edge==INVALID)
   13.96 +  {
   13.97 +    for (EdgeIt i(ms.graph); i!=INVALID; ++i)
   13.98      {
   13.99 -      for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
  13.100 -	{
  13.101 -	  double v=(*actual_map)[i];
  13.102 -	  int w;
  13.103 -	  if(autoscale)
  13.104 -	    {
  13.105 -	      if(min==max)
  13.106 -		{
  13.107 -		  w=(int)(edge_property_defaults[E_WIDTH]);
  13.108 -		}
  13.109 -	      else
  13.110 -		{
  13.111 -		  w=(int)(minimum_edge_width+(v-min)/(max-min)*(edge_width-minimum_edge_width));
  13.112 -		}
  13.113 -	    }
  13.114 -	  else
  13.115 -	    {
  13.116 -	      w=(int)(v*edge_width);
  13.117 -	    }
  13.118 -	  if(w<0)
  13.119 -	    {
  13.120 -	      edgesmap[i]->hide();
  13.121 -	    }
  13.122 -	  else
  13.123 -	    {
  13.124 -	      edgesmap[i]->show();
  13.125 -	      if(w<minimum_edge_width)
  13.126 -		{
  13.127 -		  w=minimum_edge_width;
  13.128 -		}
  13.129 -	      if(zoomtrack)
  13.130 -		{
  13.131 -		  double actual_ppu=get_pixels_per_unit();
  13.132 -		  w=(int)(w/actual_ppu*fixed_zoom_factor);
  13.133 -		}
  13.134 -	      edgesmap[i]->setLineWidth(w);
  13.135 -	    }
  13.136 -	}
  13.137 +      double v=ms.get(mapname, i);
  13.138 +      int w;
  13.139 +      if(autoscale)
  13.140 +      {
  13.141 +        if(min==max)
  13.142 +        {
  13.143 +          w=(int)(edge_property_defaults[E_WIDTH]);
  13.144 +        }
  13.145 +        else
  13.146 +        {
  13.147 +          w=(int)(minimum_edge_width+(v-min)/(max-min)*(edge_width-minimum_edge_width));
  13.148 +        }
  13.149 +      }
  13.150 +      else
  13.151 +      {
  13.152 +        w=(int)(v*edge_width);
  13.153 +      }
  13.154 +      if(w<0)
  13.155 +      {
  13.156 +        edgesmap[i]->hide();
  13.157 +      }
  13.158 +      else
  13.159 +      {
  13.160 +        edgesmap[i]->show();
  13.161 +        if(w<minimum_edge_width)
  13.162 +        {
  13.163 +          w=minimum_edge_width;
  13.164 +        }
  13.165 +        if(zoomtrack)
  13.166 +        {
  13.167 +          double actual_ppu=get_pixels_per_unit();
  13.168 +          w=(int)(w/actual_ppu*fixed_zoom_factor);
  13.169 +        }
  13.170 +        edgesmap[i]->setLineWidth(w);
  13.171 +      }
  13.172      }
  13.173 +  }
  13.174    else
  13.175 +  {
  13.176 +    int w=(int)ms.get(mapname, edge);
  13.177 +    if(w>=0)
  13.178      {
  13.179 -      int w=(int)(*actual_map)[edge];
  13.180 -      if(w>=0)
  13.181 -	{
  13.182 -	  edgesmap[edge]->setLineWidth(w);
  13.183 -	}
  13.184 +      edgesmap[edge]->setLineWidth(w);
  13.185      }
  13.186 +  }
  13.187    return 0;
  13.188  };
  13.189  
  13.190  int GraphDisplayerCanvas::changeEdgeColor (std::string mapname, Edge edge)
  13.191  {  
  13.192 +  MapStorage& ms = *mytab.mapstorage;
  13.193  
  13.194    //function maps the range of the maximum and
  13.195    //the minimum of the nodemap to the range of
  13.196    //green in RGB
  13.197 -  Graph::EdgeMap<double> * actual_map;
  13.198 -  actual_map=((mytab.mapstorage)->edgemap_storage)[mapname];
  13.199  
  13.200    double max, min;
  13.201  
  13.202 -  max=(mytab.mapstorage)->maxOfEdgeMap(mapname);
  13.203 -  min=(mytab.mapstorage)->minOfEdgeMap(mapname);
  13.204 +  {
  13.205 +    EdgeIt e(ms.graph);
  13.206 +    min = max = ms.get(mapname, e);
  13.207 +    for (; e != INVALID; ++e)
  13.208 +    {
  13.209 +      if (static_cast<double>(ms.get(mapname, e)) > max)
  13.210 +        max = ms.get(mapname, e);
  13.211 +      if (static_cast<double>(ms.get(mapname, e)) < min)
  13.212 +        min = ms.get(mapname, e);
  13.213 +    }
  13.214 +  }
  13.215  
  13.216    if(edge==INVALID)
  13.217      {
  13.218 -      for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
  13.219 +      for (EdgeIt i(ms.graph); i!=INVALID; ++i)
  13.220  	{
  13.221 -	  double w=(*actual_map)[i];
  13.222 +	  double w=ms.get(mapname, i);
  13.223  
  13.224  	  Gdk::Color color;
  13.225  	  if(max!=min)
  13.226 @@ -162,7 +179,7 @@
  13.227      {
  13.228        Gdk::Color color;
  13.229  
  13.230 -      double w=(*actual_map)[edge];
  13.231 +      double w=ms.get(mapname, edge);
  13.232  
  13.233        if(max!=min)
  13.234  	{
  13.235 @@ -180,11 +197,12 @@
  13.236  
  13.237  int GraphDisplayerCanvas::resetEdgeColor (Edge edge)
  13.238  {  
  13.239 +  MapStorage& ms = *mytab.mapstorage;
  13.240  
  13.241    //function maps the range of the maximum and
  13.242    //the minimum of the nodemap to the range of
  13.243    //green in RGB
  13.244 -  Graph::EdgeMap<double> actual_map((mytab.mapstorage)->graph,edge_property_defaults[E_COLOR]);
  13.245 +  Graph::EdgeMap<double> actual_map(ms.graph,edge_property_defaults[E_COLOR]);
  13.246  
  13.247    double max, min;
  13.248  
  13.249 @@ -192,99 +210,93 @@
  13.250    min=edge_property_defaults[E_COLOR];
  13.251  
  13.252    if(edge==INVALID)
  13.253 +  {
  13.254 +    for (EdgeIt i(ms.graph); i!=INVALID; ++i)
  13.255      {
  13.256 -      for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
  13.257 -	{
  13.258 -	  double w=actual_map[i];
  13.259 +      double w=actual_map[i];
  13.260  
  13.261 -	  Gdk::Color color;
  13.262 -	  if(max!=min)
  13.263 -	    {
  13.264 -	      color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
  13.265 -	    }
  13.266 -	  else
  13.267 -	    {
  13.268 -	      color.set_rgb_p (0, 100, 0);
  13.269 -	    }
  13.270 -	  edgesmap[i]->setFillColor(color);
  13.271 -	}
  13.272 +      Gdk::Color color;
  13.273 +      if(max!=min)
  13.274 +      {
  13.275 +        color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
  13.276 +      }
  13.277 +      else
  13.278 +      {
  13.279 +        color.set_rgb_p (0, 100, 0);
  13.280 +      }
  13.281 +      edgesmap[i]->setFillColor(color);
  13.282      }
  13.283 +  }
  13.284    else
  13.285 +  {
  13.286 +    Gdk::Color color;
  13.287 +
  13.288 +    double w=actual_map[edge];
  13.289 +
  13.290 +    if(max!=min)
  13.291      {
  13.292 -      Gdk::Color color;
  13.293 +      color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
  13.294 +    }
  13.295 +    else
  13.296 +    {
  13.297 +      color.set_rgb_p (0, 100, 0);
  13.298 +    }
  13.299  
  13.300 -      double w=actual_map[edge];
  13.301 -
  13.302 -      if(max!=min)
  13.303 -	{
  13.304 -	  color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
  13.305 -	}
  13.306 -      else
  13.307 -	{
  13.308 -	  color.set_rgb_p (0, 100, 0);
  13.309 -	}
  13.310 -
  13.311 -      edgesmap[edge]->setFillColor(color);
  13.312 -    }
  13.313 +    edgesmap[edge]->setFillColor(color);
  13.314 +  }
  13.315    return 0;
  13.316  };
  13.317  
  13.318  int GraphDisplayerCanvas::changeEdgeText (std::string mapname, Edge edge)
  13.319  {
  13.320 +  MapStorage& ms = *mytab.mapstorage;
  13.321 +
  13.322    //the number in the map will be written on the edge
  13.323    //EXCEPT when the name of the map is Default, because
  13.324    //in that case empty string will be written, because
  13.325    //that is the deleter map
  13.326 -  
  13.327 +
  13.328    if(edge==INVALID)
  13.329 +  {
  13.330 +    for (EdgeIt i(ms.graph); i!=INVALID; ++i)
  13.331      {
  13.332 -      for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
  13.333 -	{
  13.334 -	  edgemap_to_edit=mapname;
  13.335 -	  double number=(*((mytab.mapstorage)->edgemap_storage)[mapname])[i];
  13.336 -	  
  13.337 -	  std::ostringstream ostr;
  13.338 -	  ostr << number;
  13.339 -	  
  13.340 -	  edgetextmap[i]->property_text().set_value(ostr.str());
  13.341 -	}
  13.342 +      edgemap_to_edit=mapname;
  13.343  
  13.344 -    }
  13.345 -  else
  13.346 -    {
  13.347 -	  double number=(*((mytab.mapstorage)->edgemap_storage)[mapname])[edge];
  13.348 -
  13.349 -	  std::ostringstream ostr;
  13.350 -	  ostr << number;
  13.351 -	  
  13.352 -	  edgetextmap[edge]->property_text().set_value(ostr.str());
  13.353 +      edgetextmap[i]->property_text().set_value(
  13.354 +          static_cast<std::string>(ms.get(mapname, i)));
  13.355      }
  13.356  
  13.357 +  }
  13.358 +  else
  13.359 +  {
  13.360 +    edgetextmap[edge]->property_text().set_value(
  13.361 +        static_cast<std::string>(ms.get(mapname, edge)));
  13.362 +  }
  13.363 +
  13.364    return 0;
  13.365 -
  13.366  };
  13.367  
  13.368  int GraphDisplayerCanvas::resetEdgeText (Edge edge)
  13.369  {
  13.370 +  MapStorage& ms = *mytab.mapstorage;
  13.371 +
  13.372    //the number in the map will be written on the edge
  13.373    //EXCEPT when the name of the map is Default, because
  13.374    //in that case empty string will be written, because
  13.375    //that is the deleter map
  13.376 -  
  13.377 +
  13.378    if(edge==INVALID)
  13.379 +  {
  13.380 +    for (EdgeIt i(ms.graph); i!=INVALID; ++i)
  13.381      {
  13.382 -      for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
  13.383 -	{
  13.384 -	  edgemap_to_edit="";
  13.385 -	  edgetextmap[i]->property_text().set_value("");
  13.386 -	}
  13.387 -
  13.388 +      edgemap_to_edit="";
  13.389 +      edgetextmap[i]->property_text().set_value("");
  13.390      }
  13.391 +  }
  13.392    else
  13.393 -    {
  13.394 -      edgetextmap[edge]->property_text().set_value("");
  13.395 -    }
  13.396 +  {
  13.397 +    edgetextmap[edge]->property_text().set_value("");
  13.398 +  }
  13.399  
  13.400    return 0;
  13.401 -
  13.402  };
    14.1 --- a/graph_displayer_canvas-event.cc	Wed May 02 20:33:58 2007 +0000
    14.2 +++ b/graph_displayer_canvas-event.cc	Wed Jan 02 21:03:09 2008 +0000
    14.3 @@ -33,63 +33,63 @@
    14.4  void GraphDisplayerCanvas::changeEditorialTool(int newtool)
    14.5  {
    14.6    if(actual_tool!=newtool)
    14.7 +  {
    14.8 +
    14.9 +    actual_handler.disconnect();
   14.10 +
   14.11 +    switch(actual_tool)
   14.12      {
   14.13 +      case CREATE_EDGE:
   14.14 +        {
   14.15 +          GdkEvent * generated=new GdkEvent();
   14.16 +          generated->type=GDK_BUTTON_RELEASE;
   14.17 +          generated->button.button=3;
   14.18 +          createEdgeEventHandler(generated);      
   14.19 +          break;
   14.20 +        }
   14.21 +      case MAP_EDIT:
   14.22 +        {
   14.23 +          break;
   14.24 +        }
   14.25 +      default:
   14.26 +        break;
   14.27 +    }
   14.28  
   14.29 -      actual_handler.disconnect();
   14.30 +    active_item=NULL; 
   14.31 +    target_item=NULL; 
   14.32 +    active_edge=INVALID;	
   14.33 +    active_node=INVALID;	
   14.34  
   14.35 -      switch(actual_tool)
   14.36 -	{
   14.37 -	case CREATE_EDGE:
   14.38 -	  {
   14.39 -	    GdkEvent * generated=new GdkEvent();
   14.40 -	    generated->type=GDK_BUTTON_RELEASE;
   14.41 -	    generated->button.button=3;
   14.42 -	    createEdgeEventHandler(generated);      
   14.43 -	    break;
   14.44 -	  }
   14.45 -	case MAP_EDIT:
   14.46 -	  {
   14.47 -	    break;
   14.48 -	  }
   14.49 -	default:
   14.50 -	  break;
   14.51 -	}
   14.52  
   14.53 -      active_item=NULL; 
   14.54 -      target_item=NULL; 
   14.55 -      active_edge=INVALID;	
   14.56 -      active_node=INVALID;	
   14.57 +    actual_tool=newtool;
   14.58  
   14.59 +    switch(newtool)
   14.60 +    {
   14.61 +      case MOVE:
   14.62 +        actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
   14.63 +        break;
   14.64  
   14.65 -      actual_tool=newtool;
   14.66 -  
   14.67 -      switch(newtool)
   14.68 -	{
   14.69 -	case MOVE:
   14.70 -	  actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::moveEventHandler), false);
   14.71 -	  break;
   14.72 +      case CREATE_NODE:
   14.73 +        actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::createNodeEventHandler), false);
   14.74 +        break;
   14.75  
   14.76 -	case CREATE_NODE:
   14.77 -	  actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::createNodeEventHandler), false);
   14.78 -	  break;
   14.79 +      case CREATE_EDGE:
   14.80 +        actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::createEdgeEventHandler), false);
   14.81 +        break;
   14.82  
   14.83 -	case CREATE_EDGE:
   14.84 -	  actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::createEdgeEventHandler), false);
   14.85 -	  break;
   14.86 +      case ERASER:
   14.87 +        actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::eraserEventHandler), false);
   14.88 +        break;
   14.89  
   14.90 -	case ERASER:
   14.91 -	  actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::eraserEventHandler), false);
   14.92 -	  break;
   14.93 +      case MAP_EDIT:
   14.94 +        grab_focus();
   14.95 +        actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::mapEditEventHandler), false);
   14.96 +        break;
   14.97  
   14.98 -	case MAP_EDIT:
   14.99 -	  grab_focus();
  14.100 -	  actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::mapEditEventHandler), false);
  14.101 -	  break;
  14.102 -
  14.103 -	default:
  14.104 -	  break;
  14.105 -	}
  14.106 +      default:
  14.107 +        break;
  14.108      }
  14.109 +  }
  14.110  }
  14.111  
  14.112  int GraphDisplayerCanvas::getActualTool()
  14.113 @@ -138,30 +138,32 @@
  14.114  
  14.115  bool GraphDisplayerCanvas::moveEventHandler(GdkEvent* e)
  14.116  {
  14.117 +  MapStorage& ms = *mytab.mapstorage;
  14.118 +
  14.119    static Gnome::Canvas::Text *coord_text = 0;
  14.120    switch(e->type)
  14.121 -    {
  14.122 +  {
  14.123      case GDK_BUTTON_PRESS:
  14.124        //we mark the location of the event to be able to calculate parameters of dragging
  14.125        window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
  14.126 -      
  14.127 +
  14.128        active_item=(get_item_at(clicked_x, clicked_y));
  14.129        active_node=INVALID;
  14.130 -      for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
  14.131 -	{
  14.132 -	  if(nodesmap[i]==active_item)
  14.133 -	    {
  14.134 -	      active_node=i;
  14.135 -	    }
  14.136 -	}
  14.137 +      for (NodeIt i(ms.graph); i!=INVALID; ++i)
  14.138 +      {
  14.139 +        if(nodesmap[i]==active_item)
  14.140 +        {
  14.141 +          active_node=i;
  14.142 +        }
  14.143 +      }
  14.144        isbutton=e->button.button;
  14.145        break;
  14.146      case GDK_BUTTON_RELEASE:
  14.147        if (coord_text)
  14.148 -	{
  14.149 -	  delete coord_text;
  14.150 -	  coord_text = 0;
  14.151 -	}
  14.152 +      {
  14.153 +        delete coord_text;
  14.154 +        coord_text = 0;
  14.155 +      }
  14.156        isbutton=0;
  14.157        active_item=NULL;
  14.158        active_node=INVALID;
  14.159 @@ -169,65 +171,65 @@
  14.160      case GDK_MOTION_NOTIFY:
  14.161        //we only have to do sg. if the mouse button is pressed AND the click was on a node that was found in the set of nodes
  14.162        if(active_node!=INVALID)
  14.163 -	{
  14.164 -	  (mytab.mapstorage)->modified = true;
  14.165 -	  
  14.166 -	  //new coordinates will be the old values,
  14.167 -	  //because the item will be moved to the
  14.168 -	  //new coordinate therefore the new movement
  14.169 -	  //has to be calculated from here
  14.170 -	  
  14.171 -	  double new_x, new_y;
  14.172 -	  
  14.173 -	  window_to_world (e->motion.x, e->motion.y, new_x, new_y);
  14.174 -	  
  14.175 -	  double dx=new_x-clicked_x;
  14.176 -	  double dy=new_y-clicked_y;
  14.177 -	  
  14.178 -	  moveNode(dx, dy);
  14.179 +      {
  14.180 +        ms.setModified();
  14.181  
  14.182 -	  clicked_x=new_x;
  14.183 -	  clicked_y=new_y;
  14.184 +        //new coordinates will be the old values,
  14.185 +        //because the item will be moved to the
  14.186 +        //new coordinate therefore the new movement
  14.187 +        //has to be calculated from here
  14.188  
  14.189 -	  // reposition the coordinates text
  14.190 -	  std::ostringstream ostr;
  14.191 -	  ostr << "(" <<
  14.192 -	    (mytab.mapstorage)->coords[active_node].x << ", " <<
  14.193 -	    (mytab.mapstorage)->coords[active_node].y << ")";
  14.194 -	  double radius =
  14.195 -	    (nodesmap[active_node]->property_x2().get_value() -
  14.196 -	     nodesmap[active_node]->property_x1().get_value()) / 2.0;
  14.197 -	  if (coord_text)
  14.198 -	    {
  14.199 -	      coord_text->property_text().set_value(ostr.str());
  14.200 -	      coord_text->property_x().set_value((mytab.mapstorage)->coords[active_node].x +
  14.201 -						 radius);
  14.202 -	      coord_text->property_y().set_value((mytab.mapstorage)->coords[active_node].y -
  14.203 -						 radius);
  14.204 -	    }
  14.205 -	  else
  14.206 -	    {
  14.207 -	      coord_text = new Gnome::Canvas::Text(
  14.208 -						   displayed_graph,
  14.209 -						   (mytab.mapstorage)->coords[active_node].x + radius,
  14.210 -						   (mytab.mapstorage)->coords[active_node].y - radius,
  14.211 -						   ostr.str());
  14.212 -	      coord_text->property_fill_color().set_value("black");
  14.213 -	      coord_text->property_anchor().set_value(Gtk::ANCHOR_SOUTH_WEST);
  14.214 -	    }
  14.215 +        double new_x, new_y;
  14.216  
  14.217 +        window_to_world (e->motion.x, e->motion.y, new_x, new_y);
  14.218  
  14.219 -	}
  14.220 +        double dx=new_x-clicked_x;
  14.221 +        double dy=new_y-clicked_y;
  14.222 +
  14.223 +        moveNode(dx, dy);
  14.224 +
  14.225 +        clicked_x=new_x;
  14.226 +        clicked_y=new_y;
  14.227 +
  14.228 +        // reposition the coordinates text
  14.229 +        std::ostringstream ostr;
  14.230 +        ostr << "(" <<
  14.231 +          ms.getNodeCoords(active_node).x << ", " <<
  14.232 +          ms.getNodeCoords(active_node).y << ")";
  14.233 +        double radius =
  14.234 +          (nodesmap[active_node]->property_x2().get_value() -
  14.235 +           nodesmap[active_node]->property_x1().get_value()) / 2.0;
  14.236 +        if (coord_text)
  14.237 +        {
  14.238 +          coord_text->property_text().set_value(ostr.str());
  14.239 +          coord_text->property_x().set_value(
  14.240 +              ms.getNodeCoords(active_node).x + radius);
  14.241 +          coord_text->property_y().set_value(
  14.242 +              ms.getNodeCoords(active_node).y - radius);
  14.243 +        }
  14.244 +        else
  14.245 +        {
  14.246 +          coord_text = new Gnome::Canvas::Text(
  14.247 +              displayed_graph,
  14.248 +              ms.getNodeCoords(active_node).x + radius,
  14.249 +              ms.getNodeCoords(active_node).y - radius,
  14.250 +              ostr.str());
  14.251 +          coord_text->property_fill_color().set_value("black");
  14.252 +          coord_text->property_anchor().set_value(Gtk::ANCHOR_SOUTH_WEST);
  14.253 +        }
  14.254 +
  14.255 +
  14.256 +      }
  14.257      default: break;
  14.258 -    }
  14.259 +  }
  14.260  
  14.261 -return false;
  14.262 +  return false;
  14.263  }
  14.264  
  14.265  XY GraphDisplayerCanvas::calcArrowPos(XY moved_node_1, XY moved_node_2, XY fix_node, XY old_arrow_pos, int move_code)
  14.266  {
  14.267    switch(move_code)
  14.268 -    {
  14.269 +  {
  14.270      case 1:
  14.271        return XY((moved_node_2.x + fix_node.x) / 2.0, (moved_node_2.y + fix_node.y) / 2.0);
  14.272        break;
  14.273 @@ -236,57 +238,59 @@
  14.274        break;
  14.275      case 3:
  14.276        {
  14.277 -	//////////////////////////////////////////////////////////////////////////////////////////////////////
  14.278 -	/////////// keeps shape-with scalar multiplication - version 2.
  14.279 -	//////////////////////////////////////////////////////////////////////////////////////////////////////
  14.280 +        //////////////////////////////////////////////////////////////////////////////////////////////////////
  14.281 +        /////////// keeps shape-with scalar multiplication - version 2.
  14.282 +        //////////////////////////////////////////////////////////////////////////////////////////////////////
  14.283  
  14.284 -	//old vector from one to the other node - a
  14.285 -	XY a_v(moved_node_1.x-fix_node.x,moved_node_1.y-fix_node.y);
  14.286 -	//new vector from one to the other node - b
  14.287 -	XY b_v(moved_node_2.x-fix_node.x,moved_node_2.y-fix_node.y);
  14.288 +        //old vector from one to the other node - a
  14.289 +        XY a_v(moved_node_1.x-fix_node.x,moved_node_1.y-fix_node.y);
  14.290 +        //new vector from one to the other node - b
  14.291 +        XY b_v(moved_node_2.x-fix_node.x,moved_node_2.y-fix_node.y);
  14.292  
  14.293 -	double absa=sqrt(a_v.normSquare());
  14.294 -	double absb=sqrt(b_v.normSquare());
  14.295 +        double absa=sqrt(a_v.normSquare());
  14.296 +        double absb=sqrt(b_v.normSquare());
  14.297  
  14.298 -	if ((absa == 0.0) || (absb == 0.0))
  14.299 -	  {
  14.300 -	    return old_arrow_pos;
  14.301 -	  }
  14.302 -	else
  14.303 -	  {
  14.304 -	    //old vector from one node to the breakpoint - c
  14.305 -	    XY c_v(old_arrow_pos.x-fix_node.x,old_arrow_pos.y-fix_node.y);
  14.306 +        if ((absa == 0.0) || (absb == 0.0))
  14.307 +        {
  14.308 +          return old_arrow_pos;
  14.309 +        }
  14.310 +        else
  14.311 +        {
  14.312 +          //old vector from one node to the breakpoint - c
  14.313 +          XY c_v(old_arrow_pos.x-fix_node.x,old_arrow_pos.y-fix_node.y);
  14.314  
  14.315 -	    //unit vector with the same direction to a_v
  14.316 -	    XY a_v_u(a_v.x/absa,a_v.y/absa);
  14.317 +          //unit vector with the same direction to a_v
  14.318 +          XY a_v_u(a_v.x/absa,a_v.y/absa);
  14.319  
  14.320 -	    //normal vector of unit vector with the same direction to a_v
  14.321 -	    XY a_v_u_n(((-1)*a_v_u.y),a_v_u.x);
  14.322 +          //normal vector of unit vector with the same direction to a_v
  14.323 +          XY a_v_u_n(((-1)*a_v_u.y),a_v_u.x);
  14.324  
  14.325 -	    //unit vector with the same direction to b_v
  14.326 -	    XY b_v_u(b_v.x/absb,b_v.y/absb);
  14.327 +          //unit vector with the same direction to b_v
  14.328 +          XY b_v_u(b_v.x/absb,b_v.y/absb);
  14.329  
  14.330 -	    //normal vector of unit vector with the same direction to b_v
  14.331 -	    XY b_v_u_n(((-1)*b_v_u.y),b_v_u.x);
  14.332 +          //normal vector of unit vector with the same direction to b_v
  14.333 +          XY b_v_u_n(((-1)*b_v_u.y),b_v_u.x);
  14.334  
  14.335 -	    //vector c in a_v_u and a_v_u_n co-ordinate system
  14.336 -	    XY c_a(c_v*a_v_u,c_v*a_v_u_n);
  14.337 +          //vector c in a_v_u and a_v_u_n co-ordinate system
  14.338 +          XY c_a(c_v*a_v_u,c_v*a_v_u_n);
  14.339  
  14.340 -	    //new vector from one node to the breakpoint - d - we have to calculate this one
  14.341 -	    XY d_v=absb/absa*(c_a.x*b_v_u+c_a.y*b_v_u_n);
  14.342 +          //new vector from one node to the breakpoint - d - we have to calculate this one
  14.343 +          XY d_v=absb/absa*(c_a.x*b_v_u+c_a.y*b_v_u_n);
  14.344  
  14.345 -	    return XY(d_v.x+fix_node.x,d_v.y+fix_node.y);
  14.346 -	  }
  14.347 -	break;
  14.348 +          return XY(d_v.x+fix_node.x,d_v.y+fix_node.y);
  14.349 +        }
  14.350 +        break;
  14.351        }
  14.352      default:
  14.353        break;
  14.354 -    }
  14.355 +  }
  14.356  }
  14.357  
  14.358  
  14.359  bool GraphDisplayerCanvas::createNodeEventHandler(GdkEvent* e)
  14.360  {
  14.361 +  MapStorage& ms = *mytab.mapstorage;
  14.362 +
  14.363    switch(e->type)
  14.364    {
  14.365      //move the new node
  14.366 @@ -301,35 +305,15 @@
  14.367        }
  14.368  
  14.369      case GDK_BUTTON_RELEASE:
  14.370 -      (mytab.mapstorage)->modified = true;
  14.371 +      ms.setModified();
  14.372  
  14.373        is_drawn=true;
  14.374  
  14.375        isbutton=1;
  14.376  
  14.377 -      active_node=(mytab.mapstorage)->graph.addNode();
  14.378 -
  14.379 -      //initiating values corresponding to new node in maps
  14.380 -
  14.381        window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
  14.382  
  14.383 -      // update coordinates
  14.384 -      (mytab.mapstorage)->coords.set(active_node, XY(clicked_x, clicked_y));
  14.385 -
  14.386 -      // update all other maps
  14.387 -      for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it =
  14.388 -          (mytab.mapstorage)->nodemap_storage.begin(); it !=
  14.389 -          (mytab.mapstorage)->nodemap_storage.end(); ++it)
  14.390 -      {
  14.391 -        if ((it->first != "coordinates_x") &&
  14.392 -            (it->first != "coordinates_y"))
  14.393 -        {
  14.394 -          (*(it->second))[active_node] =
  14.395 -            (mytab.mapstorage)->nodemap_default[it->first];
  14.396 -        }
  14.397 -      }
  14.398 -      // increment the id map's default value
  14.399 -      (mytab.mapstorage)->nodemap_default["label"] += 1.0;
  14.400 +      active_node = ms.addNode(XY(clicked_x, clicked_y));
  14.401  
  14.402        nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph,
  14.403            clicked_x-20, clicked_y-20, clicked_x+20, clicked_y+20);
  14.404 @@ -348,7 +332,7 @@
  14.405        nodetextmap[active_node]->property_fill_color().set_value("darkblue");
  14.406        nodetextmap[active_node]->raise_to_top();
  14.407  
  14.408 -//       mapwin.updateNode(active_node);
  14.409 +      //       mapwin.updateNode(active_node);
  14.410        propertyUpdate(active_node);
  14.411  
  14.412        isbutton=0;
  14.413 @@ -364,6 +348,8 @@
  14.414  
  14.415  bool GraphDisplayerCanvas::createEdgeEventHandler(GdkEvent* e)
  14.416  {
  14.417 +  MapStorage& ms = *mytab.mapstorage;
  14.418 +
  14.419    switch(e->type)
  14.420    {
  14.421      case GDK_BUTTON_PRESS:
  14.422 @@ -379,7 +365,7 @@
  14.423  
  14.424            active_item=(get_item_at(clicked_x, clicked_y));
  14.425            active_node=INVALID;
  14.426 -          for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
  14.427 +          for (NodeIt i(ms.graph); i!=INVALID; ++i)
  14.428            {
  14.429              if(nodesmap[i]==active_item)
  14.430              {
  14.431 @@ -408,7 +394,7 @@
  14.432            window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
  14.433            target_item=(get_item_at(clicked_x, clicked_y));
  14.434            Node target_node=INVALID;
  14.435 -          for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
  14.436 +          for (NodeIt i(ms.graph); i!=INVALID; ++i)
  14.437            {
  14.438              if(nodesmap[i]==target_item)
  14.439              {
  14.440 @@ -418,54 +404,24 @@
  14.441            //the clicked item is a node, the edge can be drawn
  14.442            if(target_node!=INVALID)
  14.443            {
  14.444 -            (mytab.mapstorage)->modified = true;
  14.445 +            ms.setModified();
  14.446  
  14.447              *(nodesmap[target_node]) <<
  14.448                Gnome::Canvas::Properties::fill_color("red");
  14.449  
  14.450 -            //creating new edge
  14.451 -            active_edge=(mytab.mapstorage)->graph.addEdge(active_node,
  14.452 -                target_node);
  14.453 -
  14.454 -            // update maps
  14.455 -            for (std::map<std::string,
  14.456 -                Graph::EdgeMap<double>*>::const_iterator it =
  14.457 -                (mytab.mapstorage)->edgemap_storage.begin(); it !=
  14.458 -                (mytab.mapstorage)->edgemap_storage.end(); ++it)
  14.459 -            {
  14.460 -              (*(it->second))[active_edge] =
  14.461 -                (mytab.mapstorage)->edgemap_default[it->first];
  14.462 -            }
  14.463 -            // increment the id map's default value
  14.464 -            (mytab.mapstorage)->edgemap_default["label"] += 1.0;
  14.465 +            active_edge = ms.addEdge(active_node, target_node);
  14.466  
  14.467              if(target_node!=active_node)		
  14.468              {
  14.469 -              // set the coordinates of the arrow on the new edge
  14.470 -              MapStorage& ms = *mytab.mapstorage;
  14.471 -              ms.arrow_pos.set(active_edge,
  14.472 -                  (ms.coords[ms.graph.source(active_edge)] +
  14.473 -                   ms.coords[ms.graph.target(active_edge)])/ 2.0);
  14.474 -
  14.475 -              //drawing new edge
  14.476 -              edgesmap[active_edge]=new BrokenEdge(displayed_graph, active_edge,
  14.477 -                  *this);
  14.478 +              edgesmap[active_edge]=new BrokenEdge(displayed_graph, active_edge, *this);
  14.479              }
  14.480              else
  14.481              {
  14.482 -              // set the coordinates of the arrow on the new edge
  14.483 -              MapStorage& ms = *mytab.mapstorage;
  14.484 -              ms.arrow_pos.set(active_edge,
  14.485 -                  (ms.coords[ms.graph.source(active_edge)] +
  14.486 -                   XY(0.0, 80.0)));
  14.487 -
  14.488 -              //drawing new edge
  14.489 -              edgesmap[active_edge]=new LoopEdge(displayed_graph, active_edge,
  14.490 -                  *this);
  14.491 +              edgesmap[active_edge]=new LoopEdge(displayed_graph, active_edge, *this);
  14.492              }
  14.493  
  14.494              //initializing edge-text as well, to empty string
  14.495 -            XY text_pos=mytab.mapstorage->arrow_pos[active_edge];
  14.496 +            XY text_pos=ms.getArrowCoords(active_edge);
  14.497              text_pos+=(XY(10,10));
  14.498  
  14.499              edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph,
  14.500 @@ -494,12 +450,12 @@
  14.501        {
  14.502          if(active_item)
  14.503          {
  14.504 -	  propertyUpdate(active_node,N_COLOR);
  14.505 +          propertyUpdate(active_node,N_COLOR);
  14.506            active_item=NULL;
  14.507          }
  14.508          if(target_item)
  14.509          {
  14.510 -	  propertyUpdate((mytab.mapstorage)->graph.target(active_edge),N_COLOR);
  14.511 +          propertyUpdate(ms.graph.target(active_edge),N_COLOR);
  14.512            target_item=NULL;
  14.513          }
  14.514          active_node=INVALID;
  14.515 @@ -514,8 +470,10 @@
  14.516  
  14.517  bool GraphDisplayerCanvas::eraserEventHandler(GdkEvent* e)
  14.518  {
  14.519 +  MapStorage& ms = *mytab.mapstorage;
  14.520 +
  14.521    switch(e->type)
  14.522 -    {
  14.523 +  {
  14.524      case GDK_BUTTON_PRESS:
  14.525        //finding the clicked items
  14.526        window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
  14.527 @@ -523,88 +481,88 @@
  14.528        active_node=INVALID;
  14.529        active_edge=INVALID;
  14.530        //was it a node?
  14.531 -      for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
  14.532 -	{
  14.533 -	  if(nodesmap[i]==active_item)
  14.534 -	    {
  14.535 -	      active_node=i;
  14.536 -	    }
  14.537 -	}
  14.538 +      for (NodeIt i(ms.graph); i!=INVALID; ++i)
  14.539 +      {
  14.540 +        if(nodesmap[i]==active_item)
  14.541 +        {
  14.542 +          active_node=i;
  14.543 +        }
  14.544 +      }
  14.545        //or was it an edge?
  14.546        if(active_node==INVALID)
  14.547 -	{
  14.548 -	  for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
  14.549 -	    {
  14.550 -	      if(edgesmap[i]->getLine()==active_item)
  14.551 -		{
  14.552 -		  active_edge=i;
  14.553 -		}
  14.554 -	    }
  14.555 -	}
  14.556 +      {
  14.557 +        for (EdgeIt i(ms.graph); i!=INVALID; ++i)
  14.558 +        {
  14.559 +          if(edgesmap[i]->getLine()==active_item)
  14.560 +          {
  14.561 +            active_edge=i;
  14.562 +          }
  14.563 +        }
  14.564 +      }
  14.565  
  14.566        // return if the clicked object is neither an edge nor a node
  14.567        if (active_edge == INVALID) return false;
  14.568 -      
  14.569 +
  14.570        //recolor activated item
  14.571        if(active_item)
  14.572 -	{
  14.573 -	  *active_item << Gnome::Canvas::Properties::fill_color("red");
  14.574 -	}
  14.575 +      {
  14.576 +        *active_item << Gnome::Canvas::Properties::fill_color("red");
  14.577 +      }
  14.578        break;
  14.579  
  14.580      case GDK_BUTTON_RELEASE:
  14.581        window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
  14.582        if(active_item)
  14.583 -	{
  14.584 -	  //the cursor was not moved since pressing it
  14.585 -	  if( active_item == ( get_item_at (clicked_x, clicked_y) ) )
  14.586 -	    {
  14.587 -	      //a node was found
  14.588 -	      if(active_node!=INVALID)
  14.589 -		{
  14.590 -                  (mytab.mapstorage)->modified = true;
  14.591 +      {
  14.592 +        //the cursor was not moved since pressing it
  14.593 +        if( active_item == ( get_item_at (clicked_x, clicked_y) ) )
  14.594 +        {
  14.595 +          //a node was found
  14.596 +          if(active_node!=INVALID)
  14.597 +          {
  14.598 +            ms.setModified();
  14.599  
  14.600 -		  std::set<Graph::Edge> edges_to_delete;
  14.601 +            std::set<Graph::Edge> edges_to_delete;
  14.602  
  14.603 -		  for(OutEdgeIt e((mytab.mapstorage)->graph,active_node);e!=INVALID;++e)
  14.604 -		    {
  14.605 -		      edges_to_delete.insert(e);
  14.606 -		    }
  14.607 -		  
  14.608 -		  for(InEdgeIt e((mytab.mapstorage)->graph,active_node);e!=INVALID;++e)
  14.609 -		    {
  14.610 -		      edges_to_delete.insert(e);
  14.611 -		    }
  14.612 -		  
  14.613 -		  //deleting collected edges
  14.614 -		  for(std::set<Graph::Edge>::iterator
  14.615 -			edge_set_it=edges_to_delete.begin();
  14.616 -		      edge_set_it!=edges_to_delete.end();
  14.617 -		      ++edge_set_it)
  14.618 -		    {
  14.619 -		      deleteItem(*edge_set_it);
  14.620 -		    }
  14.621 -		  deleteItem(active_node);
  14.622 -		}
  14.623 -	      //a simple edge was chosen
  14.624 -	      else if (active_edge != INVALID)
  14.625 -		{
  14.626 -		  deleteItem(active_edge);
  14.627 -		}
  14.628 -	    }
  14.629 -	  //pointer was moved, deletion is cancelled
  14.630 -	  else
  14.631 -	    {
  14.632 -	      if(active_node!=INVALID)
  14.633 -		{
  14.634 -		  *active_item << Gnome::Canvas::Properties::fill_color("blue");
  14.635 -		}
  14.636 -	      else if (active_edge != INVALID)
  14.637 -		{
  14.638 -		  *active_item << Gnome::Canvas::Properties::fill_color("green");
  14.639 -		}
  14.640 -	    }
  14.641 -	}
  14.642 +            for(OutEdgeIt e(ms.graph,active_node);e!=INVALID;++e)
  14.643 +            {
  14.644 +              edges_to_delete.insert(e);
  14.645 +            }
  14.646 +
  14.647 +            for(InEdgeIt e(ms.graph,active_node);e!=INVALID;++e)
  14.648 +            {
  14.649 +              edges_to_delete.insert(e);
  14.650 +            }
  14.651 +
  14.652 +            //deleting collected edges
  14.653 +            for(std::set<Graph::Edge>::iterator
  14.654 +                edge_set_it=edges_to_delete.begin();
  14.655 +                edge_set_it!=edges_to_delete.end();
  14.656 +                ++edge_set_it)
  14.657 +            {
  14.658 +              deleteItem(*edge_set_it);
  14.659 +            }
  14.660 +            deleteItem(active_node);
  14.661 +          }
  14.662 +          //a simple edge was chosen
  14.663 +          else if (active_edge != INVALID)
  14.664 +          {
  14.665 +            deleteItem(active_edge);
  14.666 +          }
  14.667 +        }
  14.668 +        //pointer was moved, deletion is cancelled
  14.669 +        else
  14.670 +        {
  14.671 +          if(active_node!=INVALID)
  14.672 +          {
  14.673 +            *active_item << Gnome::Canvas::Properties::fill_color("blue");
  14.674 +          }
  14.675 +          else if (active_edge != INVALID)
  14.676 +          {
  14.677 +            *active_item << Gnome::Canvas::Properties::fill_color("green");
  14.678 +          }
  14.679 +        }
  14.680 +      }
  14.681        //reseting datas
  14.682        active_item=NULL;
  14.683        active_edge=INVALID;
  14.684 @@ -616,167 +574,201 @@
  14.685  
  14.686      default:
  14.687        break;
  14.688 -    }
  14.689 +  }
  14.690    return false;
  14.691  }
  14.692  
  14.693  bool GraphDisplayerCanvas::mapEditEventHandler(GdkEvent* e)
  14.694  {
  14.695 +  MapStorage& ms = *mytab.mapstorage;
  14.696 +
  14.697    if(actual_tool==MAP_EDIT)
  14.698 +  {
  14.699 +    switch(e->type)
  14.700      {
  14.701 -      switch(e->type)
  14.702 -	{
  14.703 -	case GDK_BUTTON_PRESS:
  14.704 -	  {
  14.705 -	    //for determine, whether it was an edge
  14.706 -	    Edge clicked_edge=INVALID;
  14.707 -	    //for determine, whether it was a node
  14.708 -	    Node clicked_node=INVALID;
  14.709 +      case GDK_BUTTON_PRESS:
  14.710 +        {
  14.711 +          //for determine, whether it was an edge
  14.712 +          Edge clicked_edge=INVALID;
  14.713 +          //for determine, whether it was a node
  14.714 +          Node clicked_node=INVALID;
  14.715  
  14.716 -	    window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
  14.717 -	    active_item=(get_item_at(clicked_x, clicked_y));
  14.718 +          window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
  14.719 +          active_item=(get_item_at(clicked_x, clicked_y));
  14.720  
  14.721 -	    //find the activated item between text of nodes
  14.722 -	    for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
  14.723 -	      {
  14.724 -		//at the same time only one can be active
  14.725 -		if(nodetextmap[i]==active_item)
  14.726 -		  {
  14.727 -		    clicked_node=i;
  14.728 -		  }
  14.729 -	      }
  14.730 +          //find the activated item between text of nodes
  14.731 +          for (NodeIt i(ms.graph); i!=INVALID; ++i)
  14.732 +          {
  14.733 +            //at the same time only one can be active
  14.734 +            if(nodetextmap[i]==active_item)
  14.735 +            {
  14.736 +              clicked_node=i;
  14.737 +            }
  14.738 +          }
  14.739  
  14.740 -	    //if there was not, search for it between nodes
  14.741 -	    if(clicked_node==INVALID)
  14.742 -	      {
  14.743 -		for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
  14.744 -		  {
  14.745 -		    //at the same time only one can be active
  14.746 -		    if(nodesmap[i]==active_item)
  14.747 -		      {
  14.748 -			clicked_node=i;
  14.749 -		      }
  14.750 -		  }
  14.751 -	      }
  14.752 +          //if there was not, search for it between nodes
  14.753 +          if(clicked_node==INVALID)
  14.754 +          {
  14.755 +            for (NodeIt i(ms.graph); i!=INVALID; ++i)
  14.756 +            {
  14.757 +              //at the same time only one can be active
  14.758 +              if(nodesmap[i]==active_item)
  14.759 +              {
  14.760 +                clicked_node=i;
  14.761 +              }
  14.762 +            }
  14.763 +          }
  14.764  
  14.765 -	    if(clicked_node==INVALID)
  14.766 -	      {
  14.767 -		//find the activated item between texts
  14.768 -		for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
  14.769 -		  {
  14.770 -		    //at the same time only one can be active
  14.771 -		    if(edgetextmap[i]==active_item)
  14.772 -		      {
  14.773 -			clicked_edge=i;
  14.774 -		      }
  14.775 -		  }
  14.776 +          if(clicked_node==INVALID)
  14.777 +          {
  14.778 +            //find the activated item between texts
  14.779 +            for (EdgeIt i(ms.graph); i!=INVALID; ++i)
  14.780 +            {
  14.781 +              //at the same time only one can be active
  14.782 +              if(edgetextmap[i]==active_item)
  14.783 +              {
  14.784 +                clicked_edge=i;
  14.785 +              }
  14.786 +            }
  14.787  
  14.788 -		//if it was not between texts, search for it between edges
  14.789 -		if(clicked_edge==INVALID)
  14.790 -		  {
  14.791 -		    for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
  14.792 -		      {
  14.793 -			//at the same time only one can be active
  14.794 -			if((edgesmap[i]->getLine())==active_item)
  14.795 -			  {
  14.796 -			    clicked_edge=i;
  14.797 -			  }
  14.798 -		      }
  14.799 -		  }
  14.800 -	      }
  14.801 +            //if it was not between texts, search for it between edges
  14.802 +            if(clicked_edge==INVALID)
  14.803 +            {
  14.804 +              for (EdgeIt i(ms.graph); i!=INVALID; ++i)
  14.805 +              {
  14.806 +                //at the same time only one can be active
  14.807 +                if((edgesmap[i]->getLine())==active_item)
  14.808 +                {
  14.809 +                  clicked_edge=i;
  14.810 +                }
  14.811 +              }
  14.812 +            }
  14.813 +          }
  14.814  
  14.815 -	    //if it was really a node...
  14.816 -	    if(clicked_node!=INVALID)
  14.817 -	      {
  14.818 -		// the id map is not editable
  14.819 -		if (nodemap_to_edit == "label") return 0;
  14.820 +          //if it was really a node...
  14.821 +          if(clicked_node!=INVALID)
  14.822 +          {
  14.823 +            // the id map is not editable
  14.824 +            if (nodemap_to_edit == "label") return 0;
  14.825  
  14.826 -		//and there is activated map
  14.827 -		if(nodetextmap[clicked_node]->property_text().get_value()!="")
  14.828 -		  {
  14.829 -		    //activate the general variable for it
  14.830 -		    active_node=clicked_node;
  14.831 +            //and there is activated map
  14.832 +            if(nodetextmap[clicked_node]->property_text().get_value()!="")
  14.833 +            {
  14.834 +              //activate the general variable for it
  14.835 +              active_node=clicked_node;
  14.836  
  14.837 -		    //create a dialog
  14.838 -		    Gtk::Dialog dialog("Edit value", true);
  14.839 -		    dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
  14.840 -		    dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
  14.841 -		    Gtk::VBox* vbox = dialog.get_vbox();
  14.842 -		    Gtk::SpinButton spin(0.0, 4);
  14.843 -		    spin.set_increments(1.0, 10.0);
  14.844 -		    spin.set_range(-1000000.0, 1000000.0);
  14.845 -		    spin.set_numeric(true);
  14.846 -		    spin.set_value(atof(nodetextmap[active_node]->property_text().get_value().c_str()));
  14.847 -		    vbox->add(spin);
  14.848 -		    spin.show();
  14.849 -		    switch (dialog.run())
  14.850 -		      {
  14.851 -		      case Gtk::RESPONSE_NONE:
  14.852 -		      case Gtk::RESPONSE_CANCEL:
  14.853 -			break;
  14.854 -		      case Gtk::RESPONSE_ACCEPT:
  14.855 -			double new_value = spin.get_value();
  14.856 -			(*(mytab.mapstorage)->nodemap_storage[nodemap_to_edit])[active_node] =
  14.857 -			  new_value;
  14.858 -			std::ostringstream ostr;
  14.859 -			ostr << new_value;
  14.860 -			nodetextmap[active_node]->property_text().set_value(ostr.str());
  14.861 -			//mapwin.updateNode(active_node);
  14.862 -			//mapwin.updateNode(Node(INVALID));
  14.863 -			propertyUpdate(Node(INVALID));
  14.864 -		      }
  14.865 -		  }
  14.866 -	      }
  14.867 -	    else
  14.868 -	      //if it was really an edge...
  14.869 -	      if(clicked_edge!=INVALID)
  14.870 -		{
  14.871 -		  // the id map is not editable
  14.872 -		  if (edgemap_to_edit == "label") return 0;
  14.873 +              //create a dialog
  14.874 +              Gtk::Dialog dialog("Edit value", true);
  14.875 +              dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
  14.876 +              dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
  14.877 +              Gtk::VBox* vbox = dialog.get_vbox();
  14.878  
  14.879 -		  //and there is activated map
  14.880 -		  if(edgetextmap[clicked_edge]->property_text().get_value()!="")
  14.881 -		    {
  14.882 -		      //activate the general variable for it
  14.883 -		      active_edge=clicked_edge;
  14.884 +              /*
  14.885 +              Gtk::SpinButton spin(0.0, 4);
  14.886 +              spin.set_increments(1.0, 10.0);
  14.887 +              spin.set_range(-1000000.0, 1000000.0);
  14.888 +              spin.set_numeric(true);
  14.889 +              spin.set_value(atof(nodetextmap[active_node]->property_text().get_value().c_str()));
  14.890 +              vbox->add(spin);
  14.891 +              spin.show();
  14.892 +              */
  14.893 +              Gtk::Entry entry;
  14.894 +              entry.set_text(nodetextmap[active_node]->property_text().get_value());
  14.895 +              vbox->add(entry);
  14.896 +              entry.show();
  14.897  
  14.898 -		      //create a dialog
  14.899 -		      Gtk::Dialog dialog("Edit value", true);
  14.900 -		      dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
  14.901 -		      dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
  14.902 -		      Gtk::VBox* vbox = dialog.get_vbox();
  14.903 -		      Gtk::SpinButton spin(0.0, 4);
  14.904 -		      spin.set_increments(1.0, 10.0);
  14.905 -		      spin.set_range(-1000000.0, 1000000.0);
  14.906 -		      spin.set_numeric(true);
  14.907 -		      spin.set_value(atof(edgetextmap[active_edge]->property_text().get_value().c_str()));
  14.908 -		      vbox->add(spin);
  14.909 -		      spin.show();
  14.910 -		      switch (dialog.run())
  14.911 -			{
  14.912 -			case Gtk::RESPONSE_NONE:
  14.913 -			case Gtk::RESPONSE_CANCEL:
  14.914 -			  break;
  14.915 -			case Gtk::RESPONSE_ACCEPT:
  14.916 -			  double new_value = spin.get_value();
  14.917 -			  (*(mytab.mapstorage)->edgemap_storage[edgemap_to_edit])[active_edge] =
  14.918 -			    new_value;
  14.919 -			  std::ostringstream ostr;
  14.920 -			  ostr << new_value;
  14.921 -			  edgetextmap[active_edge]->property_text().set_value(
  14.922 -									      ostr.str());
  14.923 -			  //mapwin.updateEdge(active_edge);
  14.924 -			  //                   mapwin.updateEdge(Edge(INVALID));
  14.925 -			  propertyUpdate(Edge(INVALID));
  14.926 -			}
  14.927 -		    }
  14.928 -		}
  14.929 -	    break;
  14.930 -	  }
  14.931 -	default:
  14.932 -	  break;
  14.933 -	}
  14.934 +              switch (dialog.run())
  14.935 +              {
  14.936 +                case Gtk::RESPONSE_NONE:
  14.937 +                case Gtk::RESPONSE_CANCEL:
  14.938 +                  break;
  14.939 +                case Gtk::RESPONSE_ACCEPT:
  14.940 +                  switch (ms.getNodeMapElementType(nodemap_to_edit))
  14.941 +                  {
  14.942 +                    case MapValue::NUMERIC:
  14.943 +                      ms.set(nodemap_to_edit, active_node,
  14.944 +                          atof(entry.get_text().c_str()));
  14.945 +                      break;
  14.946 +                    case MapValue::STRING:
  14.947 +                      ms.set(nodemap_to_edit, active_node,
  14.948 +                          static_cast<std::string>(entry.get_text()));
  14.949 +                      break;
  14.950 +                  }
  14.951 +                  nodetextmap[active_node]->property_text().set_value(
  14.952 +                      static_cast<std::string>(ms.get(nodemap_to_edit, active_node)));
  14.953 +
  14.954 +                  //mapwin.updateNode(active_node);
  14.955 +                  //mapwin.updateNode(Node(INVALID));
  14.956 +                  propertyUpdate(Node(INVALID));
  14.957 +              }
  14.958 +            }
  14.959 +          }
  14.960 +          else
  14.961 +            //if it was really an edge...
  14.962 +            if(clicked_edge!=INVALID)
  14.963 +            {
  14.964 +              // the id map is not editable
  14.965 +              if (edgemap_to_edit == "label") return 0;
  14.966 +
  14.967 +              //and there is activated map
  14.968 +              if(edgetextmap[clicked_edge]->property_text().get_value()!="")
  14.969 +              {
  14.970 +                //activate the general variable for it
  14.971 +                active_edge=clicked_edge;
  14.972 +
  14.973 +                //create a dialog
  14.974 +                Gtk::Dialog dialog("Edit value", true);
  14.975 +                dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
  14.976 +                dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
  14.977 +                Gtk::VBox* vbox = dialog.get_vbox();
  14.978 +
  14.979 +                /*
  14.980 +                Gtk::SpinButton spin(0.0, 4);
  14.981 +                spin.set_increments(1.0, 10.0);
  14.982 +                spin.set_range(-1000000.0, 1000000.0);
  14.983 +                spin.set_numeric(true);
  14.984 +                spin.set_value(atof(edgetextmap[active_edge]->property_text().get_value().c_str()));
  14.985 +                vbox->add(spin);
  14.986 +                spin.show();
  14.987 +                */
  14.988 +                Gtk::Entry entry;
  14.989 +                entry.set_text(edgetextmap[active_edge]->property_text().get_value());
  14.990 +                vbox->add(entry);
  14.991 +                entry.show();
  14.992 +
  14.993 +                std::cout << edgemap_to_edit << std::endl;
  14.994 +                switch (dialog.run())
  14.995 +                {
  14.996 +                  case Gtk::RESPONSE_NONE:
  14.997 +                  case Gtk::RESPONSE_CANCEL:
  14.998 +                    break;
  14.999 +                  case Gtk::RESPONSE_ACCEPT:
 14.1000 +                    switch (ms.getEdgeMapElementType(edgemap_to_edit))
 14.1001 +                    {
 14.1002 +                      case MapValue::NUMERIC:
 14.1003 +                        ms.set(edgemap_to_edit, active_edge,
 14.1004 +                            atof(entry.get_text().c_str()));
 14.1005 +                        break;
 14.1006 +                      case MapValue::STRING:
 14.1007 +                        ms.set(edgemap_to_edit, active_edge,
 14.1008 +                            static_cast<std::string>(entry.get_text()));
 14.1009 +                        break;
 14.1010 +                    }
 14.1011 +                    edgetextmap[active_edge]->property_text().set_value(
 14.1012 +                        static_cast<std::string>(ms.get(edgemap_to_edit, active_edge)));
 14.1013 +
 14.1014 +                    //mapwin.updateEdge(active_edge);
 14.1015 +                    //                   mapwin.updateEdge(Edge(INVALID));
 14.1016 +                    propertyUpdate(Edge(INVALID));
 14.1017 +                }
 14.1018 +              }
 14.1019 +            }
 14.1020 +          break;
 14.1021 +        }
 14.1022 +      default:
 14.1023 +        break;
 14.1024      }
 14.1025 +  }
 14.1026    return false;  
 14.1027  }
 14.1028  
 14.1029 @@ -784,14 +776,14 @@
 14.1030  {
 14.1031    delete(nodetextmap[node_to_delete]);
 14.1032    delete(nodesmap[node_to_delete]);
 14.1033 -  (mytab.mapstorage)->graph.erase(node_to_delete);
 14.1034 +  mytab.mapstorage->graph.erase(node_to_delete);
 14.1035  }
 14.1036  
 14.1037  void GraphDisplayerCanvas::deleteItem(Edge edge_to_delete)
 14.1038  {
 14.1039    delete(edgetextmap[edge_to_delete]);
 14.1040    delete(edgesmap[edge_to_delete]);
 14.1041 -  (mytab.mapstorage)->graph.erase(edge_to_delete);
 14.1042 +  mytab.mapstorage->graph.erase(edge_to_delete);
 14.1043  }
 14.1044  
 14.1045  void GraphDisplayerCanvas::textReposition(XY new_place)
 14.1046 @@ -811,7 +803,7 @@
 14.1047      }
 14.1048      else
 14.1049      {
 14.1050 -      for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
 14.1051 +      for (EdgeIt i(mytab.mapstorage->graph); i!=INVALID; ++i)
 14.1052        {
 14.1053          if(edgesmap[i]==active_bre)
 14.1054          {
 14.1055 @@ -821,99 +813,99 @@
 14.1056      }
 14.1057    }
 14.1058    else
 14.1059 +  {
 14.1060 +    if(forming_edge!=INVALID)
 14.1061      {
 14.1062 -      if(forming_edge!=INVALID)
 14.1063 -	{
 14.1064 -	  forming_edge=INVALID;
 14.1065 -	}
 14.1066 -      else
 14.1067 -	{
 14.1068 -	  std::cerr << "ERROR!!!! Invalid edge found!" << std::endl;
 14.1069 -	}
 14.1070 +      forming_edge=INVALID;
 14.1071      }
 14.1072 +    else
 14.1073 +    {
 14.1074 +      std::cerr << "ERROR!!!! Invalid edge found!" << std::endl;
 14.1075 +    }
 14.1076 +  }
 14.1077  }
 14.1078  
 14.1079  void GraphDisplayerCanvas::moveNode(double dx, double dy, Gnome::Canvas::Item * item, Node node)
 14.1080  {
 14.1081 +  MapStorage& ms = *mytab.mapstorage;
 14.1082 +
 14.1083    Gnome::Canvas::Item * moved_item=item;
 14.1084    Node moved_node=node;
 14.1085  
 14.1086    if(item==NULL && node==INVALID)
 14.1087 -    {
 14.1088 -      moved_item=active_item;
 14.1089 -      moved_node=active_node;
 14.1090 -    }
 14.1091 +  {
 14.1092 +    moved_item=active_item;
 14.1093 +    moved_node=active_node;
 14.1094 +  }
 14.1095    else
 14.1096 -    {
 14.1097 -      isbutton=1;
 14.1098 -    }
 14.1099 +  {
 14.1100 +    isbutton=1;
 14.1101 +  }
 14.1102  
 14.1103    //repositioning node and its text
 14.1104    moved_item->move(dx, dy);
 14.1105    nodetextmap[moved_node]->move(dx, dy);
 14.1106  
 14.1107    // the new coordinates of the centre of the node 
 14.1108 -  double coord_x = dx + (mytab.mapstorage)->coords[moved_node].x;
 14.1109 -  double coord_y = dy + (mytab.mapstorage)->coords[moved_node].y;
 14.1110 +  double coord_x = dx + ms.getNodeCoords(moved_node).x;
 14.1111 +  double coord_y = dy + ms.getNodeCoords(moved_node).y;
 14.1112  
 14.1113    // write back the new coordinates to the coords map
 14.1114 -  (mytab.mapstorage)->coords.set(moved_node, XY(coord_x, coord_y));
 14.1115 +  ms.setNodeCoords(moved_node, XY(coord_x, coord_y));
 14.1116  
 14.1117    //all the edges connected to the moved point has to be redrawn
 14.1118 -  for(OutEdgeIt ei((mytab.mapstorage)->graph,moved_node);ei!=INVALID;++ei)
 14.1119 +  for(OutEdgeIt ei(ms.graph,moved_node);ei!=INVALID;++ei)
 14.1120 +  {
 14.1121 +    XY arrow_pos;
 14.1122 +
 14.1123 +    if (ms.graph.source(ei) == ms.graph.target(ei))
 14.1124      {
 14.1125 +      arrow_pos = ms.getArrowCoords(ei) + XY(dx, dy);
 14.1126 +    }
 14.1127 +    else
 14.1128 +    {
 14.1129 +      XY moved_node_1(coord_x - dx, coord_y - dy);
 14.1130 +      XY moved_node_2(coord_x, coord_y);
 14.1131 +      Node target = ms.graph.target(ei);
 14.1132 +      XY fix_node = ms.getNodeCoords(target);
 14.1133 +      XY old_arrow_pos(ms.getArrowCoords(ei));
 14.1134 +
 14.1135 +      arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
 14.1136 +    }
 14.1137 +
 14.1138 +    ms.setArrowCoords(ei, arrow_pos);
 14.1139 +    edgesmap[ei]->draw();
 14.1140 +
 14.1141 +    //reposition of edgetext
 14.1142 +    XY text_pos=ms.getArrowCoords(ei);
 14.1143 +    text_pos+=(XY(10,10));
 14.1144 +    edgetextmap[ei]->property_x().set_value(text_pos.x);
 14.1145 +    edgetextmap[ei]->property_y().set_value(text_pos.y);
 14.1146 +  }
 14.1147 +
 14.1148 +  for(InEdgeIt ei(ms.graph,moved_node);ei!=INVALID;++ei)
 14.1149 +  {
 14.1150 +    if (ms.graph.source(ei) != ms.graph.target(ei))
 14.1151 +    {
 14.1152 +      XY moved_node_1(coord_x - dx, coord_y - dy);
 14.1153 +      XY moved_node_2(coord_x, coord_y);
 14.1154 +      Node source = ms.graph.source(ei);
 14.1155 +      XY fix_node = ms.getNodeCoords(source);
 14.1156 +      XY old_arrow_pos(ms.getArrowCoords(ei));
 14.1157 +
 14.1158        XY arrow_pos;
 14.1159 +      arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
 14.1160  
 14.1161 -      if (mytab.mapstorage->graph.source(ei) == mytab.mapstorage->graph.target(ei))
 14.1162 -	{
 14.1163 -	  arrow_pos = mytab.mapstorage->arrow_pos[ei] + XY(dx, dy);
 14.1164 -	}
 14.1165 -      else
 14.1166 -	{
 14.1167 -	  XY moved_node_1(coord_x - dx, coord_y - dy);
 14.1168 -	  XY moved_node_2(coord_x, coord_y);
 14.1169 -	  Node target = mytab.mapstorage->graph.target(ei);
 14.1170 -	  XY fix_node(mytab.mapstorage->coords[target].x,
 14.1171 -		      mytab.mapstorage->coords[target].y);
 14.1172 -	  XY old_arrow_pos(mytab.mapstorage->arrow_pos[ei]);
 14.1173 -
 14.1174 -	  arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
 14.1175 -	}
 14.1176 -
 14.1177 -      mytab.mapstorage->arrow_pos.set(ei, arrow_pos);
 14.1178 +      ms.setArrowCoords(ei, arrow_pos);
 14.1179        edgesmap[ei]->draw();
 14.1180  
 14.1181        //reposition of edgetext
 14.1182 -      XY text_pos=mytab.mapstorage->arrow_pos[ei];
 14.1183 +      XY text_pos=ms.getArrowCoords(ei);
 14.1184        text_pos+=(XY(10,10));
 14.1185        edgetextmap[ei]->property_x().set_value(text_pos.x);
 14.1186        edgetextmap[ei]->property_y().set_value(text_pos.y);
 14.1187      }
 14.1188 -
 14.1189 -  for(InEdgeIt ei((mytab.mapstorage)->graph,moved_node);ei!=INVALID;++ei)
 14.1190 -    {
 14.1191 -      if (mytab.mapstorage->graph.source(ei) != mytab.mapstorage->graph.target(ei))
 14.1192 -	{
 14.1193 -	  XY moved_node_1(coord_x - dx, coord_y - dy);
 14.1194 -	  XY moved_node_2(coord_x, coord_y);
 14.1195 -	  Node source = mytab.mapstorage->graph.source(ei);
 14.1196 -	  XY fix_node(mytab.mapstorage->coords[source].x,
 14.1197 -		      mytab.mapstorage->coords[source].y);
 14.1198 -	  XY old_arrow_pos(mytab.mapstorage->arrow_pos[ei]);
 14.1199 -
 14.1200 -	  XY arrow_pos;
 14.1201 -	  arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
 14.1202 -
 14.1203 -	  mytab.mapstorage->arrow_pos.set(ei, arrow_pos);
 14.1204 -	  edgesmap[ei]->draw();
 14.1205 -
 14.1206 -	  //reposition of edgetext
 14.1207 -	  XY text_pos=mytab.mapstorage->arrow_pos[ei];
 14.1208 -	  text_pos+=(XY(10,10));
 14.1209 -	  edgetextmap[ei]->property_x().set_value(text_pos.x);
 14.1210 -	  edgetextmap[ei]->property_y().set_value(text_pos.y);
 14.1211 -	}
 14.1212 -    }
 14.1213 +  }
 14.1214  }
 14.1215  
 14.1216  Gdk::Color GraphDisplayerCanvas::rainbowColorCounter(double min, double max, double w)
 14.1217 @@ -928,48 +920,48 @@
 14.1218    //first we determine the phase, in which
 14.1219    //the actual value belongs to
 14.1220    for (int i=0;i<=5;i++)
 14.1221 +  {
 14.1222 +    if(((double)i/6<pos)&&(pos<=(double(i+1)/6)))
 14.1223      {
 14.1224 -      if(((double)i/6<pos)&&(pos<=(double(i+1)/6)))
 14.1225 -	{
 14.1226 -	  phase=i;
 14.1227 -	}
 14.1228 +      phase=i;
 14.1229      }
 14.1230 +  }
 14.1231    if(phase<6)
 14.1232 +  {
 14.1233 +    //within its 1/6 long phase the relativ position
 14.1234 +    //determines the power of the color changed in
 14.1235 +    //that phase
 14.1236 +    //we normalize that to one, to be able to give percentage
 14.1237 +    //value for the function
 14.1238 +    double rel_pos=(pos-(phase/6.0))*6.0;
 14.1239 +
 14.1240 +    switch(phase)
 14.1241      {
 14.1242 -      //within its 1/6 long phase the relativ position
 14.1243 -      //determines the power of the color changed in
 14.1244 -      //that phase
 14.1245 -      //we normalize that to one, to be able to give percentage
 14.1246 -      //value for the function
 14.1247 -      double rel_pos=(pos-(phase/6.0))*6.0;
 14.1248 -
 14.1249 -      switch(phase)
 14.1250 -	{
 14.1251 -	case 0:
 14.1252 -	  color.set_rgb_p (1, 0, 1-rel_pos);
 14.1253 -	  break;
 14.1254 -	case 1:
 14.1255 -	  color.set_rgb_p (1, rel_pos, 0);
 14.1256 -	  break;
 14.1257 -	case 2:
 14.1258 -	  color.set_rgb_p (1-rel_pos, 1, 0);
 14.1259 -	  break;
 14.1260 -	case 3:
 14.1261 -	  color.set_rgb_p (0, 1, rel_pos);
 14.1262 -	  break;
 14.1263 -	case 4:
 14.1264 -	  color.set_rgb_p (0, 1-rel_pos, 1);
 14.1265 -	  break;
 14.1266 -	case 5:
 14.1267 -	  color.set_rgb_p ((rel_pos/3.0), 0, 1);
 14.1268 -	  break;
 14.1269 -	default:
 14.1270 -	  std::cout << "Wrong phase: " << phase << " " << pos << std::endl;
 14.1271 -	}
 14.1272 +      case 0:
 14.1273 +        color.set_rgb_p (1, 0, 1-rel_pos);
 14.1274 +        break;
 14.1275 +      case 1:
 14.1276 +        color.set_rgb_p (1, rel_pos, 0);
 14.1277 +        break;
 14.1278 +      case 2:
 14.1279 +        color.set_rgb_p (1-rel_pos, 1, 0);
 14.1280 +        break;
 14.1281 +      case 3:
 14.1282 +        color.set_rgb_p (0, 1, rel_pos);
 14.1283 +        break;
 14.1284 +      case 4:
 14.1285 +        color.set_rgb_p (0, 1-rel_pos, 1);
 14.1286 +        break;
 14.1287 +      case 5:
 14.1288 +        color.set_rgb_p ((rel_pos/3.0), 0, 1);
 14.1289 +        break;
 14.1290 +      default:
 14.1291 +        std::cout << "Wrong phase: " << phase << " " << pos << std::endl;
 14.1292      }
 14.1293 +  }
 14.1294    else
 14.1295 -    {
 14.1296 -      std::cout << "Wrong phase: " << phase << " " << pos << std::endl;
 14.1297 -    }
 14.1298 +  {
 14.1299 +    std::cout << "Wrong phase: " << phase << " " << pos << std::endl;
 14.1300 +  }
 14.1301    return color;
 14.1302  }
    15.1 --- a/graph_displayer_canvas-node.cc	Wed May 02 20:33:58 2007 +0000
    15.2 +++ b/graph_displayer_canvas-node.cc	Wed Jan 02 21:03:09 2008 +0000
    15.3 @@ -25,17 +25,27 @@
    15.4  
    15.5  int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Node node)
    15.6  {
    15.7 -  Graph::NodeMap<double> * actual_map;
    15.8 +  MapStorage& ms = *mytab.mapstorage;
    15.9 +
   15.10    double min, max;
   15.11 -  min=(mytab.mapstorage)->minOfNodeMap(mapname);
   15.12 -  max=(mytab.mapstorage)->maxOfNodeMap(mapname);
   15.13 -  actual_map=((mytab.mapstorage)->nodemap_storage)[mapname];
   15.14 +
   15.15 +  {
   15.16 +    NodeIt n(ms.graph);
   15.17 +    min = max = ms.get(mapname, n);
   15.18 +    for (; n != INVALID; ++n)
   15.19 +    {
   15.20 +      if (static_cast<double>(ms.get(mapname, n)) > max)
   15.21 +        max = ms.get(mapname, n);
   15.22 +      if (static_cast<double>(ms.get(mapname, n)) < min)
   15.23 +        min = ms.get(mapname, n);
   15.24 +    }
   15.25 +  }
   15.26  
   15.27    if(node==INVALID)
   15.28      {
   15.29 -      for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
   15.30 +      for (NodeIt i(ms.graph); i!=INVALID; ++i)
   15.31  	{
   15.32 -	  double v=fabs((*actual_map)[i]);
   15.33 +	  double v=fabs(ms.get(mapname,i));
   15.34  	  int w;
   15.35  	  if(autoscale)
   15.36  	    {
   15.37 @@ -102,14 +112,16 @@
   15.38  
   15.39  int GraphDisplayerCanvas::resetNodeRadius (Node node)
   15.40  {
   15.41 +  MapStorage& ms = *mytab.mapstorage;
   15.42 +
   15.43    double min, max;
   15.44    min=node_property_defaults[N_RADIUS];
   15.45    max=node_property_defaults[N_RADIUS];
   15.46 -  Graph::NodeMap<double> actual_map((mytab.mapstorage)->graph,node_property_defaults[N_RADIUS]);
   15.47 +  Graph::NodeMap<double> actual_map(ms.graph,node_property_defaults[N_RADIUS]);
   15.48    
   15.49    if(node==INVALID)
   15.50      {
   15.51 -      for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
   15.52 +      for (NodeIt i(ms.graph); i!=INVALID; ++i)
   15.53  	{
   15.54  	  double v=fabs(actual_map[i]);
   15.55  	  int w;
   15.56 @@ -163,27 +175,34 @@
   15.57  
   15.58  int GraphDisplayerCanvas::changeNodeColor (std::string mapname, Node node)
   15.59  {  
   15.60 +  MapStorage& ms = *mytab.mapstorage;
   15.61  
   15.62    //function maps the range of the maximum and
   15.63    //the minimum of the nodemap to the range of
   15.64    //green in RGB
   15.65  
   15.66 -  Graph::NodeMap<double> * actual_map;
   15.67 -  actual_map=((mytab.mapstorage)->nodemap_storage)[mapname];
   15.68 -
   15.69    double max, min;
   15.70  
   15.71 -  max=(mytab.mapstorage)->maxOfNodeMap(mapname);
   15.72 -  min=(mytab.mapstorage)->minOfNodeMap(mapname);
   15.73 +  {
   15.74 +    NodeIt n(ms.graph);
   15.75 +    min = max = ms.get(mapname, n);
   15.76 +    for (; n != INVALID; ++n)
   15.77 +    {
   15.78 +      if (static_cast<double>(ms.get(mapname, n)) > max)
   15.79 +        max = ms.get(mapname, n);
   15.80 +      if (static_cast<double>(ms.get(mapname, n)) < min)
   15.81 +        min = ms.get(mapname, n);
   15.82 +    }
   15.83 +  }
   15.84  
   15.85    if(node==INVALID)
   15.86      {
   15.87  
   15.88 -      for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
   15.89 +      for (NodeIt i(ms.graph); i!=INVALID; ++i)
   15.90  	{
   15.91  	  Gdk::Color color;
   15.92  
   15.93 -	  double w=(*actual_map)[i];
   15.94 +	  double w=ms.get(mapname, i);
   15.95  
   15.96  	  if(max!=min)
   15.97  	    {
   15.98 @@ -201,7 +220,7 @@
   15.99      {
  15.100        Gdk::Color color;
  15.101  
  15.102 -      double w=(*actual_map)[node];
  15.103 +      double w=ms.get(mapname, node);
  15.104  
  15.105        if(max!=min)
  15.106  	{
  15.107 @@ -219,12 +238,13 @@
  15.108  
  15.109  int GraphDisplayerCanvas::resetNodeColor (Node node)
  15.110  {  
  15.111 +  MapStorage& ms = *mytab.mapstorage;
  15.112  
  15.113    //function maps the range of the maximum and
  15.114    //the minimum of the nodemap to the range of
  15.115    //green in RGB
  15.116  
  15.117 -  Graph::NodeMap<double> actual_map((mytab.mapstorage)->graph,node_property_defaults[N_COLOR]);
  15.118 +  Graph::NodeMap<double> actual_map(ms.graph,node_property_defaults[N_COLOR]);
  15.119  
  15.120    double max, min;
  15.121  
  15.122 @@ -234,7 +254,7 @@
  15.123    if(node==INVALID)
  15.124      {
  15.125  
  15.126 -      for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
  15.127 +      for (NodeIt i(ms.graph); i!=INVALID; ++i)
  15.128  	{
  15.129  	  Gdk::Color color;
  15.130  
  15.131 @@ -274,42 +294,7 @@
  15.132  
  15.133  int GraphDisplayerCanvas::changeNodeText (std::string mapname, Node node)
  15.134  {
  15.135 -
  15.136 -  //the number in the map will be written on the node
  15.137 -  //EXCEPT when the name of the map is Text, because
  15.138 -  //in that case empty string will be written, because
  15.139 -  //that is the deleter map
  15.140 -
  15.141 -  Graph::NodeMap<double> * actual_map=NULL;
  15.142 -  actual_map=((mytab.mapstorage)->nodemap_storage)[mapname];
  15.143 -
  15.144 -  if(node==INVALID)
  15.145 -    {
  15.146 -      for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
  15.147 -	{
  15.148 -	  nodemap_to_edit=mapname;
  15.149 -	  double number=(*actual_map)[i];
  15.150 -
  15.151 -	  std::ostringstream ostr;
  15.152 -	  ostr << number;
  15.153 -	      
  15.154 -	  nodetextmap[i]->property_text().set_value(ostr.str());
  15.155 -	}
  15.156 -    }
  15.157 -  else
  15.158 -    {
  15.159 -      double number=(*actual_map)[node];
  15.160 -
  15.161 -      std::ostringstream ostr;
  15.162 -      ostr << number;
  15.163 -	      
  15.164 -      nodetextmap[node]->property_text().set_value(ostr.str());
  15.165 -    }
  15.166 -  return 0;
  15.167 -};
  15.168 -
  15.169 -int GraphDisplayerCanvas::resetNodeText (Node node)
  15.170 -{
  15.171 +  MapStorage& ms = *mytab.mapstorage;
  15.172  
  15.173    //the number in the map will be written on the node
  15.174    //EXCEPT when the name of the map is Text, because
  15.175 @@ -318,7 +303,34 @@
  15.176  
  15.177    if(node==INVALID)
  15.178      {
  15.179 -      for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
  15.180 +      for (NodeIt i(ms.graph); i!=INVALID; ++i)
  15.181 +	{
  15.182 +	  nodemap_to_edit=mapname;
  15.183 +
  15.184 +	  nodetextmap[i]->property_text().set_value(
  15.185 +              static_cast<std::string>(ms.get(mapname, i)));
  15.186 +	}
  15.187 +    }
  15.188 +  else
  15.189 +    {
  15.190 +      nodetextmap[node]->property_text().set_value(
  15.191 +          static_cast<std::string>(ms.get(mapname, node)));
  15.192 +    }
  15.193 +  return 0;
  15.194 +};
  15.195 +
  15.196 +int GraphDisplayerCanvas::resetNodeText (Node node)
  15.197 +{
  15.198 +  MapStorage& ms = *mytab.mapstorage;
  15.199 +
  15.200 +  //the number in the map will be written on the node
  15.201 +  //EXCEPT when the name of the map is Text, because
  15.202 +  //in that case empty string will be written, because
  15.203 +  //that is the deleter map
  15.204 +
  15.205 +  if(node==INVALID)
  15.206 +    {
  15.207 +      for (NodeIt i(ms.graph); i!=INVALID; ++i)
  15.208  	{
  15.209  	  nodemap_to_edit="";
  15.210  	  nodetextmap[i]->property_text().set_value("");
    16.1 --- a/graph_displayer_canvas.cc	Wed May 02 20:33:58 2007 +0000
    16.2 +++ b/graph_displayer_canvas.cc	Wed Jan 02 21:03:09 2008 +0000
    16.3 @@ -117,46 +117,57 @@
    16.4    std::string mapname=mytab.getActiveNodeMap(prop);
    16.5  
    16.6    if(is_drawn)
    16.7 +  {
    16.8 +    if(mapname!="")
    16.9      {
   16.10 -      if(mapname!="")
   16.11 -	{
   16.12 -	  if( ( ((mytab.mapstorage)->nodemap_storage).find(mapname) != ((mytab.mapstorage)->nodemap_storage).end() ) )
   16.13 -	    {
   16.14 -	      switch(prop)
   16.15 -		{
   16.16 -		case N_RADIUS:
   16.17 -		  changeNodeRadius(mapname, node);
   16.18 -		  break;
   16.19 -		case N_COLOR:
   16.20 -		  changeNodeColor(mapname, node);
   16.21 -		  break;
   16.22 -		case N_TEXT:
   16.23 -		  changeNodeText(mapname, node);
   16.24 -		  break;
   16.25 -		default:
   16.26 -		  std::cerr<<"Error\n";
   16.27 -		}
   16.28 -	    }
   16.29 -	}
   16.30 -      else //mapname==""
   16.31 -	{
   16.32 -	  Node node=INVALID;	
   16.33 -	  switch(prop)
   16.34 -	    {
   16.35 -	    case N_RADIUS:
   16.36 -	      resetNodeRadius(node);
   16.37 -	      break;
   16.38 -	    case N_COLOR:
   16.39 -	      resetNodeColor(node);
   16.40 -	      break;
   16.41 -	    case N_TEXT:
   16.42 -	      resetNodeText(node);
   16.43 -	      break;
   16.44 -	    default:
   16.45 -	      std::cerr<<"Error\n";
   16.46 -	    }
   16.47 -	}
   16.48 +      std::vector<std::string> nodemaps = mytab.mapstorage->getNodeMapList();
   16.49 +      bool found = false;
   16.50 +      for (std::vector<std::string>::const_iterator it = nodemaps.begin();
   16.51 +          it != nodemaps.end(); ++it)
   16.52 +      {
   16.53 +        if (*it == mapname)
   16.54 +        {
   16.55 +          found = true;
   16.56 +          break;
   16.57 +        }
   16.58 +      }
   16.59 +      if (found)
   16.60 +      {
   16.61 +        switch(prop)
   16.62 +        {
   16.63 +          case N_RADIUS:
   16.64 +            changeNodeRadius(mapname, node);
   16.65 +            break;
   16.66 +          case N_COLOR:
   16.67 +            changeNodeColor(mapname, node);
   16.68 +            break;
   16.69 +          case N_TEXT:
   16.70 +            changeNodeText(mapname, node);
   16.71 +            break;
   16.72 +          default:
   16.73 +            std::cerr<<"Error\n";
   16.74 +        }
   16.75 +      }
   16.76      }
   16.77 +    else //mapname==""
   16.78 +    {
   16.79 +      Node node=INVALID;
   16.80 +      switch(prop)
   16.81 +      {
   16.82 +        case N_RADIUS:
   16.83 +          resetNodeRadius(node);
   16.84 +          break;
   16.85 +        case N_COLOR:
   16.86 +          resetNodeColor(node);
   16.87 +          break;
   16.88 +        case N_TEXT:
   16.89 +          resetNodeText(node);
   16.90 +          break;
   16.91 +        default:
   16.92 +          std::cerr<<"Error\n";
   16.93 +      }
   16.94 +    }
   16.95 +  }
   16.96  }
   16.97  
   16.98  void GraphDisplayerCanvas::propertyUpdate(Edge edge, int prop)
   16.99 @@ -164,45 +175,56 @@
  16.100    std::string mapname=mytab.getActiveEdgeMap(prop);
  16.101  
  16.102    if(is_drawn)
  16.103 +  {
  16.104 +    if(mapname!="")
  16.105      {
  16.106 -      if(mapname!="")
  16.107 -	{
  16.108 -	  if( ( ((mytab.mapstorage)->edgemap_storage).find(mapname) != ((mytab.mapstorage)->edgemap_storage).end() ) )
  16.109 -	    {
  16.110 -	      switch(prop)
  16.111 -		{
  16.112 -		case E_WIDTH:
  16.113 -		  changeEdgeWidth(mapname, edge);
  16.114 -		  break;
  16.115 -		case E_COLOR:
  16.116 -		  changeEdgeColor(mapname, edge);
  16.117 -		  break;
  16.118 -		case E_TEXT:
  16.119 -		  changeEdgeText(mapname, edge);
  16.120 -		  break;
  16.121 -		default:
  16.122 -		  std::cerr<<"Error\n";
  16.123 -		}
  16.124 -	    }
  16.125 -	}
  16.126 -      else //mapname==""
  16.127 -	{
  16.128 -	  switch(prop)
  16.129 -	    {
  16.130 -	    case E_WIDTH:
  16.131 -	      resetEdgeWidth(edge);
  16.132 -	      break;
  16.133 -	    case E_COLOR:
  16.134 -	      resetEdgeColor(edge);
  16.135 -	      break;
  16.136 -	    case E_TEXT:
  16.137 -	      resetEdgeText(edge);
  16.138 -	      break;
  16.139 -	    default:
  16.140 -	      std::cerr<<"Error\n";
  16.141 -	    }
  16.142 -	}
  16.143 +      std::vector<std::string> edgemaps = mytab.mapstorage->getEdgeMapList();
  16.144 +      bool found = false;
  16.145 +      for (std::vector<std::string>::const_iterator it = edgemaps.begin();
  16.146 +          it != edgemaps.end(); ++it)
  16.147 +      {
  16.148 +        if (*it == mapname)
  16.149 +        {
  16.150 +          found = true;
  16.151 +          break;
  16.152 +        }
  16.153 +      }
  16.154 +      if (found)
  16.155 +      {
  16.156 +        switch(prop)
  16.157 +        {
  16.158 +          case E_WIDTH:
  16.159 +            changeEdgeWidth(mapname, edge);
  16.160 +            break;
  16.161 +          case E_COLOR:
  16.162 +            changeEdgeColor(mapname, edge);
  16.163 +            break;
  16.164 +          case E_TEXT:
  16.165 +            changeEdgeText(mapname, edge);
  16.166 +            break;
  16.167 +          default:
  16.168 +            std::cerr<<"Error\n";
  16.169 +        }
  16.170 +      }
  16.171      }
  16.172 +    else //mapname==""
  16.173 +    {
  16.174 +      switch(prop)
  16.175 +      {
  16.176 +        case E_WIDTH:
  16.177 +          resetEdgeWidth(edge);
  16.178 +          break;
  16.179 +        case E_COLOR:
  16.180 +          resetEdgeColor(edge);
  16.181 +          break;
  16.182 +        case E_TEXT:
  16.183 +          resetEdgeText(edge);
  16.184 +          break;
  16.185 +        default:
  16.186 +          std::cerr<<"Error\n";
  16.187 +      }
  16.188 +    }
  16.189 +  }
  16.190  }
  16.191  
  16.192  void GraphDisplayerCanvas::drawGraph()
  16.193 @@ -221,7 +243,7 @@
  16.194      }
  16.195      //initializing edge-text as well, to empty string
  16.196  
  16.197 -    XY text_pos=mytab.mapstorage->arrow_pos[i];
  16.198 +    XY text_pos=mytab.mapstorage->getArrowCoords(i);
  16.199      text_pos+=(XY(10,10));
  16.200  
  16.201      edgetextmap[i]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, "");
  16.202 @@ -238,10 +260,10 @@
  16.203  
  16.204      nodesmap[i]=new Gnome::Canvas::Ellipse(
  16.205          displayed_graph,
  16.206 -        (mytab.mapstorage)->coords[i].x-20,
  16.207 -        (mytab.mapstorage)->coords[i].y-20,
  16.208 -        (mytab.mapstorage)->coords[i].x+20,
  16.209 -        (mytab.mapstorage)->coords[i].y+20);
  16.210 +        mytab.mapstorage->getNodeCoords(i).x-20,
  16.211 +        mytab.mapstorage->getNodeCoords(i).y-20,
  16.212 +        mytab.mapstorage->getNodeCoords(i).x+20,
  16.213 +        mytab.mapstorage->getNodeCoords(i).y+20);
  16.214      *(nodesmap[i]) << Gnome::Canvas::Properties::fill_color("blue");
  16.215      *(nodesmap[i]) << Gnome::Canvas::Properties::outline_color("black");
  16.216      nodesmap[i]->raise_to_top();
  16.217 @@ -249,8 +271,8 @@
  16.218      //initializing edge-text as well, to empty string
  16.219  
  16.220      XY text_pos(
  16.221 -        ((mytab.mapstorage)->coords[i].x+node_property_defaults[N_RADIUS]+5),
  16.222 -        ((mytab.mapstorage)->coords[i].y+node_property_defaults[N_RADIUS]+5));
  16.223 +        (mytab.mapstorage->getNodeCoords(i).x+node_property_defaults[N_RADIUS]+5),
  16.224 +        (mytab.mapstorage->getNodeCoords(i).y+node_property_defaults[N_RADIUS]+5));
  16.225  
  16.226      nodetextmap[i]=new Gnome::Canvas::Text(displayed_graph,
  16.227          text_pos.x, text_pos.y, "");
  16.228 @@ -325,7 +347,8 @@
  16.229  
  16.230  void GraphDisplayerCanvas::reDesignGraph()
  16.231  {
  16.232 -  NodeIt firstnode((mytab.mapstorage)->graph);
  16.233 +  MapStorage& ms = *mytab.mapstorage;
  16.234 +  NodeIt firstnode(ms.graph);
  16.235    //is it not an empty graph?
  16.236    if(firstnode!=INVALID)
  16.237      {
  16.238 @@ -335,7 +358,7 @@
  16.239  
  16.240        if(!was_redesigned)
  16.241  	{
  16.242 -	  NodeIt i((mytab.mapstorage)->graph);
  16.243 +	  NodeIt i(ms.graph);
  16.244  
  16.245  	  dim2::Point<double> init(init_vector_length*rnd(),
  16.246  				   init_vector_length*rnd());
  16.247 @@ -347,28 +370,28 @@
  16.248        double propulsation;
  16.249        int iterations;
  16.250  
  16.251 -      (mytab.mapstorage)->get_design_data(attraction, propulsation, iterations);
  16.252 +      ms.get_design_data(attraction, propulsation, iterations);
  16.253  
  16.254        //iteration counter
  16.255        for(int l=0;l<iterations;l++)
  16.256  	{
  16.257 -	  Graph::NodeMap<double> x(mytab.mapstorage->graph);
  16.258 -	  Graph::NodeMap<double> y(mytab.mapstorage->graph);
  16.259 +	  Graph::NodeMap<double> x(ms.graph);
  16.260 +	  Graph::NodeMap<double> y(ms.graph);
  16.261  	  XYMap<Graph::NodeMap<double> > actual_forces;
  16.262  	  actual_forces.setXMap(x);
  16.263  	  actual_forces.setYMap(y);
  16.264  
  16.265  	  //count actual force for each nodes
  16.266 -	  for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
  16.267 +	  for (NodeIt i(ms.graph); i!=INVALID; ++i)
  16.268  	    {
  16.269  	      //propulsation of nodes
  16.270 -	      for (NodeIt j((mytab.mapstorage)->graph); j!=INVALID; ++j)
  16.271 +	      for (NodeIt j(ms.graph); j!=INVALID; ++j)
  16.272  		{
  16.273  		  if(i!=j)
  16.274  		    {
  16.275  		      lemon::dim2::Point<double> delta =
  16.276 -			((mytab.mapstorage)->coords[i]-
  16.277 -			 (mytab.mapstorage)->coords[j]);
  16.278 +			(ms.getNodeCoords(i)-
  16.279 +			 ms.getNodeCoords(j));
  16.280  
  16.281  		      const double length_sqr=std::max(delta.normSquare(),min_dist);
  16.282  
  16.283 @@ -382,55 +405,53 @@
  16.284  		      actual_forces.set(i,(actual_forces[i]+delta));
  16.285  		    }
  16.286  		}
  16.287 -	      //attraction of nodes, to which actual node is bound
  16.288 -	      for(OutEdgeIt ei((mytab.mapstorage)->graph,i);ei!=INVALID;++ei)
  16.289 +            //attraction of nodes, to which actual node is bound
  16.290 +            for(OutEdgeIt ei(ms.graph,i);ei!=INVALID;++ei)
  16.291 +              {
  16.292 +                lemon::dim2::Point<double> delta =
  16.293 +                  (ms.getNodeCoords(i)-
  16.294 +                   ms.getNodeCoords(ms.graph.target(ei)));
  16.295 +
  16.296 +                //calculating attraction strength
  16.297 +                //greater distance means greater strength
  16.298 +                delta*=attraction;
  16.299 +
  16.300 +                actual_forces.set(i,actual_forces[i]-delta);
  16.301 +              }
  16.302 +                    for(InEdgeIt ei(ms.graph,i);ei!=INVALID;++ei)
  16.303 +              {
  16.304 +                lemon::dim2::Point<double> delta =
  16.305 +                  (ms.getNodeCoords(i)-
  16.306 +                   ms.getNodeCoords(ms.graph.source(ei)));
  16.307 +
  16.308 +                //calculating attraction strength
  16.309 +                //greater distance means greater strength
  16.310 +                delta*=attraction;
  16.311 +
  16.312 +                actual_forces.set(i,actual_forces[i]-delta);
  16.313 +              }
  16.314 +	    }
  16.315 +	  for (NodeIt i(ms.graph); i!=INVALID; ++i)
  16.316 +	    {
  16.317 +	      if((ms.getNodeCoords(i).x)+actual_forces[i].x>max_coord)
  16.318  		{
  16.319 -		  lemon::dim2::Point<double> delta =
  16.320 -		    ((mytab.mapstorage)->coords[i]-
  16.321 -		     (mytab.mapstorage)->coords[mytab.mapstorage->
  16.322 -					       graph.target(ei)]);
  16.323 -		
  16.324 -		  //calculating attraction strength
  16.325 -		  //greater distance means greater strength
  16.326 -		  delta*=attraction;
  16.327 -		
  16.328 -		  actual_forces.set(i,actual_forces[i]-delta);
  16.329 +		  actual_forces[i].x=max_coord-(ms.getNodeCoords(i).x);
  16.330 +		  std::cout << "Correction! " << ((ms.getNodeCoords(i).x)+actual_forces[i].x) << std::endl;
  16.331  		}
  16.332 -	      for(InEdgeIt ei((mytab.mapstorage)->graph,i);ei!=INVALID;++ei)
  16.333 +	      else if((ms.getNodeCoords(i).x)+actual_forces[i].x<(0-max_coord))
  16.334  		{
  16.335 -		  lemon::dim2::Point<double> delta =
  16.336 -		    ((mytab.mapstorage)->coords[i]-
  16.337 -		     (mytab.mapstorage)->coords[mytab.mapstorage->
  16.338 -					       graph.source(ei)]);
  16.339 -		
  16.340 -		  //calculating attraction strength
  16.341 -		  //greater distance means greater strength
  16.342 -		  delta*=attraction;
  16.343 -		
  16.344 -		  actual_forces.set(i,actual_forces[i]-delta);
  16.345 +		  actual_forces[i].x=0-max_coord-(ms.getNodeCoords(i).x);
  16.346 +		  std::cout << "Correction! " << ((ms.getNodeCoords(i).x)+actual_forces[i].x) << std::endl;
  16.347  		}
  16.348 -	    }
  16.349 -	  for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
  16.350 -	    {
  16.351 -	      if(((mytab.mapstorage)->coords[i].x)+actual_forces[i].x>max_coord)
  16.352 +	      if((ms.getNodeCoords(i).y)+actual_forces[i].y>max_coord)
  16.353  		{
  16.354 -		  actual_forces[i].x=max_coord-((mytab.mapstorage)->coords[i].x);
  16.355 -		  std::cout << "Correction! " << (((mytab.mapstorage)->coords[i].x)+actual_forces[i].x) << std::endl;
  16.356 +		  actual_forces[i].y=max_coord-(ms.getNodeCoords(i).y);
  16.357 +		  std::cout << "Correction! " << ((ms.getNodeCoords(i).y)+actual_forces[i].y) << std::endl;
  16.358  		}
  16.359 -	      else if(((mytab.mapstorage)->coords[i].x)+actual_forces[i].x<(0-max_coord))
  16.360 +	      else if((ms.getNodeCoords(i).y)+actual_forces[i].y<(0-max_coord))
  16.361  		{
  16.362 -		  actual_forces[i].x=0-max_coord-((mytab.mapstorage)->coords[i].x);
  16.363 -		  std::cout << "Correction! " << (((mytab.mapstorage)->coords[i].x)+actual_forces[i].x) << std::endl;
  16.364 -		}
  16.365 -	      if(((mytab.mapstorage)->coords[i].y)+actual_forces[i].y>max_coord)
  16.366 -		{
  16.367 -		  actual_forces[i].y=max_coord-((mytab.mapstorage)->coords[i].y);
  16.368 -		  std::cout << "Correction! " << (((mytab.mapstorage)->coords[i].y)+actual_forces[i].y) << std::endl;
  16.369 -		}
  16.370 -	      else if(((mytab.mapstorage)->coords[i].y)+actual_forces[i].y<(0-max_coord))
  16.371 -		{
  16.372 -		  actual_forces[i].y=0-max_coord-((mytab.mapstorage)->coords[i].y);
  16.373 -		  std::cout << "Correction! " << (((mytab.mapstorage)->coords[i].y)+actual_forces[i].y) << std::endl;
  16.374 +		  actual_forces[i].y=0-max_coord-(ms.getNodeCoords(i).y);
  16.375 +		  std::cout << "Correction! " << ((ms.getNodeCoords(i).y)+actual_forces[i].y) << std::endl;
  16.376  		}
  16.377  	      moveNode(actual_forces[i].x, actual_forces[i].y, nodesmap[i], i);
  16.378  	    }
    17.1 --- a/gui_reader.cc	Wed May 02 20:33:58 2007 +0000
    17.2 +++ b/gui_reader.cc	Wed Jan 02 21:03:09 2008 +0000
    17.3 @@ -20,6 +20,7 @@
    17.4  #include <mapstorage.h>
    17.5  
    17.6  #include <xml.h>
    17.7 +#include "io_helper.h"
    17.8  #include <lemon/dim2.h>
    17.9  #include <vector>
   17.10  
   17.11 @@ -33,34 +34,139 @@
   17.12  
   17.13  void GuiReader::read(std::istream& is)
   17.14  {
   17.15 +  using std::vector;
   17.16 +  using std::string;
   17.17 +  using std::pair;
   17.18 +  using std::make_pair;
   17.19 +  using std::string;
   17.20 +  using std::map;
   17.21 +
   17.22    XmlIo x(is);
   17.23 -  std::map<int, XY > m;
   17.24 -  x("arrow_pos", m);
   17.25  
   17.26 -  if ((int)m.size() == countEdges(mapstorage->graph))
   17.27 +  { x("main_node_map_names", gui_data.main_node_map_names); }
   17.28 +  { x("gui_node_map_names", gui_data.gui_node_map_names); }
   17.29 +
   17.30 +  { x("node_map_types", gui_data.node_map_types); }
   17.31 +
   17.32 +  { x("main_edge_map_names", gui_data.main_edge_map_names); }
   17.33 +  { x("gui_edge_map_names", gui_data.gui_edge_map_names); }
   17.34 +
   17.35 +  { x("edge_map_types", gui_data.edge_map_types); }
   17.36 +
   17.37 +  for (vector<string>::const_iterator it = gui_data.gui_node_map_names.begin();
   17.38 +      it != gui_data.gui_node_map_names.end(); ++it)
   17.39 +  {
   17.40 +    MapValue::Type type = gui_data.node_map_types[*it];
   17.41 +    switch (type)
   17.42      {
   17.43 -      for (EdgeIt e(mapstorage->graph); e != INVALID; ++e)
   17.44 -	{
   17.45 -	  int edgeid = (int)(*mapstorage->edgemap_storage["label"])[e];
   17.46 -	  mapstorage->arrow_pos.set(e, m[edgeid]);
   17.47 -	}
   17.48 -      mapstorage->ArrowPosReadOK();
   17.49 +      case MapValue::NUMERIC:
   17.50 +        {
   17.51 +          map<int, double>* p_map_data =
   17.52 +            new map<int, double>;
   17.53 +          gui_data.numeric_node_maps[*it] = p_map_data;
   17.54 +          { x(*it, *p_map_data); }
   17.55 +        }
   17.56 +        break;
   17.57 +      case MapValue::STRING:
   17.58 +        {
   17.59 +          map<int, string>* p_map_data =
   17.60 +            new map<int, string>;
   17.61 +          gui_data.string_node_maps[*it] = p_map_data;
   17.62 +          { x(*it, *p_map_data); }
   17.63 +        }
   17.64 +        break;
   17.65      }
   17.66 -  
   17.67 +  }
   17.68 +
   17.69 +  for (vector<string>::const_iterator it = gui_data.gui_edge_map_names.begin();
   17.70 +      it != gui_data.gui_edge_map_names.end(); ++it)
   17.71 +  {
   17.72 +    MapValue::Type type = gui_data.edge_map_types[*it];
   17.73 +    switch (type)
   17.74 +    {
   17.75 +      case MapValue::NUMERIC:
   17.76 +        {
   17.77 +          map<int, double>* p_map_data =
   17.78 +            new map<int, double>;
   17.79 +          gui_data.numeric_edge_maps[*it] = p_map_data;
   17.80 +          { x(*it, *p_map_data); }
   17.81 +        }
   17.82 +        break;
   17.83 +      case MapValue::STRING:
   17.84 +        {
   17.85 +          map<int, string>* p_map_data =
   17.86 +            new map<int, string>;
   17.87 +          gui_data.string_edge_maps[*it] = p_map_data;
   17.88 +          { x(*it, *p_map_data); }
   17.89 +        }
   17.90 +        break;
   17.91 +    }
   17.92 +  }
   17.93 +
   17.94 +  {
   17.95 +    std::string node_coords_save_dest;
   17.96 +    { x("node_coords_save_dest", node_coords_save_dest); }
   17.97 +    if (node_coords_save_dest == "gui_sect")
   17.98 +    {
   17.99 +      // read the node coorinates
  17.100 +      gui_data.node_coords_save_dest = MapStorage::SpecMapSaveOpts::GUI_SECT;
  17.101 +      { x("node_coord_map", gui_data.node_coord_map); }
  17.102 +    }
  17.103 +    else if (node_coords_save_dest == "nodeset_sect_1_map")
  17.104 +    {
  17.105 +      gui_data.node_coords_save_dest = MapStorage::SpecMapSaveOpts::NESET_SECT;
  17.106 +      gui_data.node_coords_save_map_num = MapStorage::SpecMapSaveOpts::ONE_MAP;
  17.107 +      { x("map_name", gui_data.node_coords_one_map_name); }
  17.108 +    }
  17.109 +    else if (node_coords_save_dest == "nodeset_sect_2_maps")
  17.110 +    {
  17.111 +      gui_data.node_coords_save_dest = MapStorage::SpecMapSaveOpts::NESET_SECT;
  17.112 +      gui_data.node_coords_save_map_num = MapStorage::SpecMapSaveOpts::TWO_MAPS;
  17.113 +      { x("map1_name", gui_data.node_coords_two_maps_1_name); }
  17.114 +      { x("map2_name", gui_data.node_coords_two_maps_2_name); }
  17.115 +    }
  17.116 +  }
  17.117 +
  17.118 +  {
  17.119 +    std::string arrow_coords_save_dest;
  17.120 +    { x("arrow_coords_save_dest", arrow_coords_save_dest); }
  17.121 +    if (arrow_coords_save_dest == "gui_sect")
  17.122 +    {
  17.123 +      // read the arrow coorinates
  17.124 +      gui_data.arrow_coords_save_dest = MapStorage::SpecMapSaveOpts::GUI_SECT;
  17.125 +      { x("arrow_coord_map", gui_data.arrow_coord_map); }
  17.126 +    }
  17.127 +    else if (arrow_coords_save_dest == "edgeset_sect_1_map")
  17.128 +    {
  17.129 +      gui_data.arrow_coords_save_dest = MapStorage::SpecMapSaveOpts::NESET_SECT;
  17.130 +      gui_data.arrow_coords_save_map_num = MapStorage::SpecMapSaveOpts::ONE_MAP;
  17.131 +      { x("map_name", gui_data.arrow_coords_one_map_name); }
  17.132 +    }
  17.133 +    else if (arrow_coords_save_dest == "edgeset_sect_2_maps")
  17.134 +    {
  17.135 +      gui_data.arrow_coords_save_dest = MapStorage::SpecMapSaveOpts::NESET_SECT;
  17.136 +      gui_data.arrow_coords_save_map_num = MapStorage::SpecMapSaveOpts::TWO_MAPS;
  17.137 +      { x("map1_name", gui_data.arrow_coords_two_maps_1_name); }
  17.138 +      { x("map2_name", gui_data.arrow_coords_two_maps_2_name); }
  17.139 +    }
  17.140 +  }
  17.141 +
  17.142 +
  17.143 +
  17.144    std::map<int, std::string> nm;
  17.145    x("active_nodemaps", nm);
  17.146  
  17.147    for(int i=0;i<NODE_PROPERTY_NUM;i++)
  17.148 -    {
  17.149 -      mapstorage->changeActiveMap(false, i, nm[i]);
  17.150 -    }
  17.151 +  {
  17.152 +    mapstorage->changeActiveMap(false, i, nm[i]);
  17.153 +  }
  17.154  
  17.155    std::map<int, std::string> em;
  17.156    x("active_edgemaps", em);
  17.157    for(int i=0;i<EDGE_PROPERTY_NUM;i++)
  17.158 -    {
  17.159 -      mapstorage->changeActiveMap(true, i, em[i]);
  17.160 -    }
  17.161 +  {
  17.162 +    mapstorage->changeActiveMap(true, i, em[i]);
  17.163 +  }
  17.164  
  17.165    double attraction;
  17.166    double propulsation;
  17.167 @@ -77,6 +183,10 @@
  17.168    mapstorage->redesign_data_changed();
  17.169  }
  17.170  
  17.171 -GuiReader::GuiReader(LemonReader& reader, MapStorage* ms) : Parent(reader), mapstorage(ms)
  17.172 +GuiReader::GuiReader(LemonReader& reader, MapStorage* _mapstorage,
  17.173 +    MapStorage::GUISectData& _gui_data) :
  17.174 +  Parent(reader),
  17.175 +  mapstorage(_mapstorage),
  17.176 +  gui_data(_gui_data)
  17.177  {
  17.178  }
    18.1 --- a/gui_reader.h	Wed May 02 20:33:58 2007 +0000
    18.2 +++ b/gui_reader.h	Wed Jan 02 21:03:09 2008 +0000
    18.3 @@ -20,7 +20,7 @@
    18.4  #define GUI_READER_H
    18.5  #include <lemon/lemon_reader.h>
    18.6  
    18.7 -class MapStorage;
    18.8 +#include "mapstorage.h"
    18.9  
   18.10  using lemon::LemonReader;
   18.11  
   18.12 @@ -28,12 +28,13 @@
   18.13  {
   18.14    private:
   18.15      MapStorage* mapstorage;
   18.16 +    MapStorage::GUISectData& gui_data;
   18.17    protected:
   18.18      virtual bool header(const std::string&);
   18.19      virtual void read(std::istream&);
   18.20    public:
   18.21      typedef LemonReader::SectionReader Parent;
   18.22 -    GuiReader(LemonReader&, MapStorage*);
   18.23 +    GuiReader(LemonReader&, MapStorage*, MapStorage::GUISectData&);
   18.24  };
   18.25  
   18.26  #endif
    19.1 --- a/gui_writer.cc	Wed May 02 20:33:58 2007 +0000
    19.2 +++ b/gui_writer.cc	Wed Jan 02 21:03:09 2008 +0000
    19.3 @@ -16,7 +16,10 @@
    19.4   *
    19.5   */
    19.6  
    19.7 -#include <xml.h>
    19.8 +#include "gui_writer.h"
    19.9 +#include "io_helper.h"
   19.10 +#include "mapstorage.h"
   19.11 +#include "xml.h"
   19.12  #include <lemon/dim2.h>
   19.13  #include <vector>
   19.14  
   19.15 @@ -30,28 +33,232 @@
   19.16  
   19.17  void GuiWriter::write(std::ostream& os)
   19.18  {
   19.19 +  using std::vector;
   19.20 +  using std::string;
   19.21 +  using std::map;
   19.22 +  using std::string;
   19.23 +
   19.24    XmlIo x(os);
   19.25 -  std::map<int, XY > m;
   19.26 -  for (EdgeIt e(mapstorage->graph); e != INVALID; ++e)
   19.27 +
   19.28 +  vector<string> all_node_map_names = mapstorage->getNodeMapList();
   19.29 +  // name of the maps saved to the nodeset section
   19.30 +  vector<string> main_node_map_names;
   19.31 +  // name of the maps saved to the gui section
   19.32 +  vector<string> gui_node_map_names;
   19.33 +
   19.34 +  for (vector<string>::const_iterator it = all_node_map_names.begin();
   19.35 +      it != all_node_map_names.end(); ++it)
   19.36    {
   19.37 -    int edgeid = (int)(*(mapstorage->edgemap_storage["label"]))[e];
   19.38 -    m[edgeid] = mapstorage->arrow_pos[e];
   19.39 +    if (mapstorage->getNodeMapSaveDest(*it) == MapStorage::NESET_SECT)
   19.40 +      main_node_map_names.push_back(*it);
   19.41 +    else if (mapstorage->getNodeMapSaveDest(*it) == MapStorage::GUI_SECT)
   19.42 +      gui_node_map_names.push_back(*it);
   19.43    }
   19.44 -  x("arrow_pos", m);
   19.45 +
   19.46 +  { x("main_node_map_names", main_node_map_names); }
   19.47 +  { x("gui_node_map_names", gui_node_map_names); }
   19.48 +
   19.49 +  map<string, MapValue::Type> node_map_types;
   19.50 +  for (vector<string>::const_iterator it = main_node_map_names.begin();
   19.51 +      it != main_node_map_names.end(); ++it)
   19.52 +  {
   19.53 +    node_map_types[*it] = mapstorage->getNodeMapElementType(*it);
   19.54 +  }
   19.55 +  for (vector<string>::const_iterator it = gui_node_map_names.begin();
   19.56 +      it != gui_node_map_names.end(); ++it)
   19.57 +  {
   19.58 +    node_map_types[*it] = mapstorage->getNodeMapElementType(*it);
   19.59 +  }
   19.60 +
   19.61 +  { x("node_map_types", node_map_types); }
   19.62 +
   19.63 +
   19.64 +  vector<string> all_edge_map_names = mapstorage->getEdgeMapList();
   19.65 +  // name of the maps saved to the edgeset section
   19.66 +  vector<string> main_edge_map_names;
   19.67 +  // name of the maps saved to the gui section
   19.68 +  vector<string> gui_edge_map_names;
   19.69 +
   19.70 +  for (vector<string>::const_iterator it = all_edge_map_names.begin();
   19.71 +      it != all_edge_map_names.end(); ++it)
   19.72 +  {
   19.73 +    if (mapstorage->getEdgeMapSaveDest(*it) == MapStorage::NESET_SECT)
   19.74 +      main_edge_map_names.push_back(*it);
   19.75 +    if (mapstorage->getEdgeMapSaveDest(*it) == MapStorage::GUI_SECT)
   19.76 +      gui_edge_map_names.push_back(*it);
   19.77 +  }
   19.78 +
   19.79 +  { x("main_edge_map_names", main_edge_map_names); }
   19.80 +  { x("gui_edge_map_names", gui_edge_map_names); }
   19.81 +
   19.82 +  map<string, MapValue::Type> edge_map_types;
   19.83 +  for (vector<string>::const_iterator it = main_edge_map_names.begin();
   19.84 +      it != main_edge_map_names.end(); ++it)
   19.85 +  {
   19.86 +    edge_map_types[*it] = mapstorage->getEdgeMapElementType(*it);
   19.87 +  }
   19.88 +  for (vector<string>::const_iterator it = gui_edge_map_names.begin();
   19.89 +      it != gui_edge_map_names.end(); ++it)
   19.90 +  {
   19.91 +    edge_map_types[*it] = mapstorage->getEdgeMapElementType(*it);
   19.92 +  }
   19.93 +
   19.94 +  { x("edge_map_types", edge_map_types); }
   19.95 +
   19.96 +  // write the gui node maps
   19.97 +  for (vector<string>::const_iterator it = gui_node_map_names.begin();
   19.98 +      it != gui_node_map_names.end(); ++it)
   19.99 +  {
  19.100 +    MapValue::Type type = mapstorage->getNodeMapElementType(*it);
  19.101 +    const MapStorage::NodeLabelMap& labels = mapstorage->getNodeLabelMap();
  19.102 +    switch (type)
  19.103 +    {
  19.104 +      case MapValue::NUMERIC:
  19.105 +        {
  19.106 +          std::map<int, double> map_data;
  19.107 +          MapStorage::NumericNodeMap& map =
  19.108 +            mapstorage->getNumericNodeMap(*it);
  19.109 +          for (NodeIt n(mapstorage->getGraph()); n != INVALID; ++n)
  19.110 +          {
  19.111 +            map_data[labels[n]] = map[n];
  19.112 +          }
  19.113 +          { x(*it, map_data); }
  19.114 +        }
  19.115 +        break;
  19.116 +      case MapValue::STRING:
  19.117 +        {
  19.118 +          std::map<int, std::string> map_data;
  19.119 +          MapStorage::StringNodeMap& map =
  19.120 +            mapstorage->getStringNodeMap(*it);
  19.121 +          for (NodeIt n(mapstorage->getGraph()); n != INVALID; ++n)
  19.122 +          {
  19.123 +            map_data[labels[n]] = map[n];
  19.124 +          }
  19.125 +          { x(*it, map_data); }
  19.126 +        }
  19.127 +        break;
  19.128 +    }
  19.129 +  }
  19.130 +
  19.131 +  // write the gui edge maps
  19.132 +  for (vector<string>::const_iterator it = gui_edge_map_names.begin();
  19.133 +      it != gui_edge_map_names.end(); ++it)
  19.134 +  {
  19.135 +    MapValue::Type type = mapstorage->getEdgeMapElementType(*it);
  19.136 +    const MapStorage::EdgeLabelMap& labels = mapstorage->getEdgeLabelMap();
  19.137 +    switch (type)
  19.138 +    {
  19.139 +      case MapValue::NUMERIC:
  19.140 +        {
  19.141 +          std::map<int, double> map_data;
  19.142 +          MapStorage::NumericEdgeMap& map =
  19.143 +            mapstorage->getNumericEdgeMap(*it);
  19.144 +          for (EdgeIt e(mapstorage->getGraph()); e != INVALID; ++e)
  19.145 +          {
  19.146 +            map_data[labels[e]] = map[e];
  19.147 +          }
  19.148 +          { x(*it, map_data); }
  19.149 +        }
  19.150 +        break;
  19.151 +      case MapValue::STRING:
  19.152 +        {
  19.153 +          std::map<int, std::string> map_data;
  19.154 +          MapStorage::StringEdgeMap& map =
  19.155 +            mapstorage->getStringEdgeMap(*it);
  19.156 +          for (EdgeIt e(mapstorage->getGraph()); e != INVALID; ++e)
  19.157 +          {
  19.158 +            map_data[labels[e]] = map[e];
  19.159 +          }
  19.160 +          { x(*it, map_data); }
  19.161 +        }
  19.162 +        break;
  19.163 +    }
  19.164 +  }
  19.165 +
  19.166 +  {
  19.167 +    switch (mapstorage->getNodeCoordsSaveDest())
  19.168 +    {
  19.169 +      case MapStorage::SpecMapSaveOpts::GUI_SECT:
  19.170 +        { x("node_coords_save_dest", string("gui_sect")); }
  19.171 +        // write the node coorinates
  19.172 +        {
  19.173 +          const MapStorage::NodeLabelMap& labels =
  19.174 +            mapstorage->getNodeLabelMap();
  19.175 +          std::map<int, XY> node_coord_map;
  19.176 +          MapStorage::NodeCoordMap& map = mapstorage->getNodeCoordMap();
  19.177 +          for (NodeIt n(mapstorage->getGraph()); n != INVALID; ++n)
  19.178 +          {
  19.179 +            node_coord_map[labels[n]] = map[n];
  19.180 +          }
  19.181 +          { x("node_coord_map", node_coord_map); }
  19.182 +        }
  19.183 +        break;
  19.184 +      case MapStorage::SpecMapSaveOpts::NESET_SECT:
  19.185 +        switch (mapstorage->getNodeCoordsSaveMapNum())
  19.186 +        {
  19.187 +          case MapStorage::SpecMapSaveOpts::ONE_MAP:
  19.188 +            { x("node_coords_save_dest", string("nodeset_sect_1_map")); }
  19.189 +            { x("map_name", mapstorage->getNodeCoordsOneMapName()); }
  19.190 +            break;
  19.191 +          case MapStorage::SpecMapSaveOpts::TWO_MAPS:
  19.192 +            { x("node_coords_save_dest", string("nodeset_sect_2_maps")); }
  19.193 +            { x("map1_name", mapstorage->getNodeCoordsTwoMaps1Name()); }
  19.194 +            { x("map2_name", mapstorage->getNodeCoordsTwoMaps2Name()); }
  19.195 +            break;
  19.196 +        }
  19.197 +        break;
  19.198 +    }
  19.199 +  }
  19.200 +
  19.201 +  {
  19.202 +    switch (mapstorage->getArrowCoordsSaveDest())
  19.203 +    {
  19.204 +      case MapStorage::SpecMapSaveOpts::GUI_SECT:
  19.205 +        { x("arrow_coords_save_dest", string("gui_sect")); }
  19.206 +        // write the arrow coorinates
  19.207 +        {
  19.208 +          const MapStorage::EdgeLabelMap& labels =
  19.209 +            mapstorage->getEdgeLabelMap();
  19.210 +          std::map<int, XY> arrow_coord_map;
  19.211 +          MapStorage::ArrowCoordMap& map = mapstorage->getArrowCoordMap();
  19.212 +          for (EdgeIt e(mapstorage->getGraph()); e != INVALID; ++e)
  19.213 +          {
  19.214 +            arrow_coord_map[labels[e]] = map[e];
  19.215 +          }
  19.216 +          { x("arrow_coord_map", arrow_coord_map); }
  19.217 +        }
  19.218 +        break;
  19.219 +      case MapStorage::SpecMapSaveOpts::NESET_SECT:
  19.220 +        switch (mapstorage->getArrowCoordsSaveMapNum())
  19.221 +        {
  19.222 +          case MapStorage::SpecMapSaveOpts::ONE_MAP:
  19.223 +            { x("arrow_coords_save_dest", string("edgeset_sect_1_map")); }
  19.224 +            { x("map_name", mapstorage->getArrowCoordsOneMapName()); }
  19.225 +            break;
  19.226 +          case MapStorage::SpecMapSaveOpts::TWO_MAPS:
  19.227 +            { x("arrow_coords_save_dest", string("edgeset_sect_2_maps")); }
  19.228 +            { x("map1_name", mapstorage->getArrowCoordsTwoMaps1Name()); }
  19.229 +            { x("map2_name", mapstorage->getArrowCoordsTwoMaps2Name()); }
  19.230 +            break;
  19.231 +        }
  19.232 +        break;
  19.233 +    }
  19.234 +  }
  19.235 +
  19.236  
  19.237    std::map<int, std::string> nm;
  19.238    for(int i=0;i<NODE_PROPERTY_NUM;i++)
  19.239      {
  19.240        nm[i]=mapstorage->active_nodemaps[i];
  19.241      }
  19.242 -  x("active_nodemaps", nm);
  19.243 +  { x("active_nodemaps", nm); }
  19.244  
  19.245    std::map<int, std::string> em;
  19.246    for(int i=0;i<EDGE_PROPERTY_NUM;i++)
  19.247      {
  19.248        em[i]=mapstorage->active_edgemaps[i];
  19.249      }
  19.250 -  x("active_edgemaps", em);
  19.251 +  { x("active_edgemaps", em); }
  19.252  
  19.253    double attraction;
  19.254    double propulsation;
  19.255 @@ -59,11 +266,13 @@
  19.256  
  19.257    mapstorage->get_design_data(attraction, propulsation, iteration);
  19.258  
  19.259 -  x("redesign-attraction", attraction);
  19.260 -  x("redesign-propulsation", propulsation);
  19.261 -  x("redesign-iteration", iteration);
  19.262 +  { x("redesign-attraction", attraction); }
  19.263 +  { x("redesign-propulsation", propulsation); }
  19.264 +  { x("redesign-iteration", iteration); }
  19.265  }
  19.266  
  19.267 -GuiWriter::GuiWriter(LemonWriter& writer, MapStorage* ms) : Parent(writer), mapstorage(ms)
  19.268 +GuiWriter::GuiWriter(LemonWriter& writer, MapStorage* ms) :
  19.269 +  Parent(writer),
  19.270 +  mapstorage(ms)
  19.271  {
  19.272  }
    20.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    20.2 +++ b/io_helper.cc	Wed Jan 02 21:03:09 2008 +0000
    20.3 @@ -0,0 +1,34 @@
    20.4 +#include "io_helper.h"
    20.5 +
    20.6 +namespace lemon {
    20.7 +  void xml(XmlIo &x, MapValue::Type& v)
    20.8 +  {
    20.9 +    if(x.write()) {
   20.10 +      switch (v)
   20.11 +      {
   20.12 +        case MapValue::NUMERIC:
   20.13 +          { x("type", std::string("numeric")); }
   20.14 +          break;
   20.15 +        case MapValue::STRING:
   20.16 +          { x("type", std::string("string")); }
   20.17 +          break;
   20.18 +      }
   20.19 +    }
   20.20 +    else {
   20.21 +      std::string type;
   20.22 +      { x("type", type); }
   20.23 +      if (type == "numeric")
   20.24 +      {
   20.25 +        v = MapValue::NUMERIC;
   20.26 +      }
   20.27 +      else if (type == "string")
   20.28 +      {
   20.29 +        v = MapValue::STRING;
   20.30 +      }
   20.31 +      else
   20.32 +      {
   20.33 +        throw DataFormatError("Bad format");
   20.34 +      }
   20.35 +    }
   20.36 +  }
   20.37 +};
    21.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    21.2 +++ b/io_helper.h	Wed Jan 02 21:03:09 2008 +0000
    21.3 @@ -0,0 +1,11 @@
    21.4 +#ifndef IO_HELPER
    21.5 +#define IO_HELPER
    21.6 +
    21.7 +#include "xml.h"
    21.8 +#include "map_value.h"
    21.9 +
   21.10 +namespace lemon {
   21.11 +  void xml(XmlIo &x, MapValue::Type& v);
   21.12 +};
   21.13 +
   21.14 +#endif
    22.1 --- a/kruskalbox.cc	Wed May 02 20:33:58 2007 +0000
    22.2 +++ b/kruskalbox.cc	Wed Jan 02 21:03:09 2008 +0000
    22.3 @@ -33,51 +33,50 @@
    22.4  void KruskalBox::run()
    22.5  {
    22.6    if(
    22.7 -     tabcbt.get_active_text()!="" &&
    22.8 -     (edgemapcbts[INPUT])->get_active_text()!="" &&
    22.9 -     (edgemapcbts[OUTPUT])->get_active_text()!=""
   22.10 -     )
   22.11 +      tabcbt.get_active_text()!="" &&
   22.12 +      (edgemapcbts[INPUT])->get_active_text()!="" &&
   22.13 +      (edgemapcbts[OUTPUT])->get_active_text()!=""
   22.14 +    )
   22.15 +  {
   22.16 +
   22.17 +    const Graph &g=mapstorage->getGraph();
   22.18 +    std::string input_map_name = edgemapcbts[INPUT]->get_active_text();
   22.19 +    Graph::EdgeMap<bool> outputmap(g);
   22.20 +    const MapStorage::NumericEdgeMap& inputmap=
   22.21 +      mapstorage->getNumericEdgeMap(input_map_name);
   22.22 +    double res=kruskal(g, inputmap, outputmap);
   22.23 +
   22.24 +    for (EdgeIt i(g); i!=INVALID; ++i)
   22.25      {
   22.26 +      if(outputmap[i])
   22.27 +      {
   22.28 +        mapstorage->set(edgemapcbts[OUTPUT]->get_active_text(), i, 1.0);
   22.29 +      }
   22.30 +      else
   22.31 +      {
   22.32 +        mapstorage->set(edgemapcbts[OUTPUT]->get_active_text(), i, 0.0);
   22.33 +      }
   22.34 +    }
   22.35  
   22.36 -      const Graph &g=mapstorage->graph;
   22.37 -      Graph::EdgeMap<double> * inputmap=
   22.38 -	((mapstorage->edgemap_storage)[(edgemapcbts[INPUT])->get_active_text()]);
   22.39 -      Graph::EdgeMap<bool> outputmap(g);
   22.40 -      double res=kruskal(g, *inputmap, outputmap);
   22.41 +    std::ostringstream o;
   22.42 +    o << "Result: " << res;
   22.43 +    resultlabel.set_text(o.str());
   22.44  
   22.45 -      for (EdgeIt i(g); i!=INVALID; ++i)
   22.46 -	{
   22.47 -	  if(outputmap[i])
   22.48 -	    {
   22.49 -	      (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->
   22.50 -					       get_active_text()]))[i]=1;
   22.51 -	    }
   22.52 -	  else
   22.53 -	    {
   22.54 -	      (*((mapstorage->edgemap_storage)[(edgemapcbts[OUTPUT])->
   22.55 -					       get_active_text()]))[i]=0;
   22.56 -	    }
   22.57 -	}
   22.58 +    mapstorage->mapChanged(true, (edgemapcbts[OUTPUT])->get_active_text());
   22.59 +    //   mapstorage->changeActiveMap(true, E_COLOR,
   22.60 +    // 			      (edgemapcbts[OUTPUT])->get_active_text());
   22.61 +    //   mapstorage->changeActiveMap(true, E_TEXT,
   22.62 +    // 			      (edgemapcbts[INPUT])->get_active_text());
   22.63  
   22.64 -      std::ostringstream o;
   22.65 -      o << "Result: " << res;
   22.66 -      resultlabel.set_text(o.str());
   22.67 -
   22.68 -      mapstorage->mapChanged(true, (edgemapcbts[OUTPUT])->get_active_text());
   22.69 -      //   mapstorage->changeActiveMap(true, E_COLOR,
   22.70 -      // 			      (edgemapcbts[OUTPUT])->get_active_text());
   22.71 -      //   mapstorage->changeActiveMap(true, E_TEXT,
   22.72 -      // 			      (edgemapcbts[INPUT])->get_active_text());
   22.73 -  
   22.74 -    }
   22.75 +  }
   22.76  }
   22.77      
   22.78  void KruskalBox::build_box()
   22.79  {
   22.80    std::vector<std::string> empty_vector;
   22.81  
   22.82 -  addMapSelector("Edgecosts: ", true);
   22.83 -  addMapSelector("Edges of tree here: ", true);
   22.84 +  addMapSelector("Edgecosts: ", true, NUM);
   22.85 +  addMapSelector("Edges of tree here: ", true, NUM);
   22.86  
   22.87    resultlabel.set_text("Result: algorithm is not run yet.");
   22.88    pack_start(resultlabel);
    23.1 --- a/main_win.cc	Wed May 02 20:33:58 2007 +0000
    23.2 +++ b/main_win.cc	Wed Jan 02 21:03:09 2008 +0000
    23.3 @@ -20,9 +20,10 @@
    23.4  #include <config.h>
    23.5  #endif
    23.6  
    23.7 -#include <main_win.h>
    23.8 -#include <guipixbufs.h>
    23.9 -#include <background_chooser_dialog.h>
   23.10 +#include "main_win.h"
   23.11 +#include "guipixbufs.h"
   23.12 +#include "save_details_dialog.h"
   23.13 +#include "background_chooser_dialog.h"
   23.14  
   23.15  #include <mapstorage.h>
   23.16  #include <graph_displayer_canvas.h>
   23.17 @@ -114,6 +115,8 @@
   23.18        sigc::mem_fun(*this, &MainWin::saveFile));
   23.19    ag->add( Gtk::Action::create("FileSaveAs", Gtk::Stock::SAVE_AS),
   23.20        sigc::mem_fun(*this, &MainWin::saveFileAs));
   23.21 +  ag->add( Gtk::Action::create("SaveDetails", _("Save _Details...")),
   23.22 +	   sigc::mem_fun(*this, &MainWin::createSaveDetailsDialog));
   23.23    ag->add( Gtk::Action::create("Close", Gtk::Stock::CLOSE),
   23.24        sigc::mem_fun(*this, &MainWin::closeTab));
   23.25    ag->add( Gtk::Action::create("Quit", Gtk::Stock::QUIT),
   23.26 @@ -160,13 +163,13 @@
   23.27    ag->add( Gtk::RadioAction::create(tool_group, "EditEdgeMap", Gtk::StockID("gd-editlink"), _("Edit edge map")),
   23.28        sigc::bind( sigc::mem_fun ( *this, &MainWin::changeEditorialTool ), 4) );
   23.29  
   23.30 -  ag->add( Gtk::Action::create("AddMap", Gtk::StockID("gd-newmap")),
   23.31 +  ag->add( Gtk::Action::create("AddMap", Gtk::StockID("gd-newmap"), "New map"),
   23.32        sigc::mem_fun ( *this , &MainWin::createNewMapWin ) );
   23.33  
   23.34    ag->add( Gtk::Action::create("DesignGraph", Gtk::Stock::REFRESH),
   23.35        sigc::mem_fun ( *this , &MainWin::reDesignGraph ) );
   23.36  
   23.37 -  ag->add( Gtk::Action::create("Eps", Gtk::StockID("gd-eps")),
   23.38 +  ag->add( Gtk::Action::create("Eps", Gtk::StockID("gd-eps"), "Export to EPS"),
   23.39        sigc::mem_fun ( *this , &MainWin::exportToEPS ) );
   23.40  
   23.41    uim=Gtk::UIManager::create();
   23.42 @@ -185,6 +188,7 @@
   23.43        "      <menuitem action='FileClearTab'/>"
   23.44        "      <menuitem action='FileSave'/>"
   23.45        "      <menuitem action='FileSaveAs'/>"
   23.46 +      "      <menuitem action='SaveDetails'/>"
   23.47        "      <menuitem action='Close'/>"
   23.48        "      <menuitem action='Quit'/>"
   23.49        "    </menu>"
   23.50 @@ -370,7 +374,7 @@
   23.51  {
   23.52    if(active_tab!=-1)
   23.53      {
   23.54 -      if (tabs[active_tab]->mapstorage->modified)
   23.55 +      if (tabs[active_tab]->mapstorage->getModified())
   23.56  	{
   23.57  	  Gtk::MessageDialog mdialog(_("<b>Save changes before closing?</b>"), true, 
   23.58  				     Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
   23.59 @@ -628,6 +632,12 @@
   23.60    tabs[active_tab]->reDesignGraph();
   23.61  }
   23.62  
   23.63 +void MainWin::createSaveDetailsDialog()
   23.64 +{
   23.65 +  SaveDetailsDialog dialog(tabs[active_tab]->mapstorage);
   23.66 +  dialog.run();
   23.67 +}
   23.68 +
   23.69  void MainWin::exportToEPS()
   23.70  {
   23.71    if(active_tab!=-1)
    24.1 --- a/main_win.h	Wed May 02 20:33:58 2007 +0000
    24.2 +++ b/main_win.h	Wed Jan 02 21:03:09 2008 +0000
    24.3 @@ -260,6 +260,9 @@
    24.4  
    24.5    virtual void reDesignGraph();
    24.6  
    24.7 +  /// Pops up a SaveDetailsDialog.
    24.8 +  void createSaveDetailsDialog();
    24.9 +
   24.10    virtual void exportToEPS();
   24.11  
   24.12    void createBackgroundChooser();
    25.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    25.2 +++ b/map_value.cc	Wed Jan 02 21:03:09 2008 +0000
    25.3 @@ -0,0 +1,153 @@
    25.4 +#include "map_value.h"
    25.5 +#include <sstream>
    25.6 +#include <iostream>
    25.7 +
    25.8 +MapValue::MapValue()
    25.9 +{
   25.10 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
   25.11 +  has_value = false;
   25.12 +}
   25.13 +
   25.14 +MapValue::MapValue(double d)
   25.15 +{
   25.16 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
   25.17 +  p_value = new double(d);
   25.18 +  type = NUMERIC;
   25.19 +  has_value = true;
   25.20 +}
   25.21 +
   25.22 +MapValue::MapValue(std::string str)
   25.23 +{
   25.24 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
   25.25 +  p_value = new std::string(str);
   25.26 +  type = STRING;
   25.27 +  has_value = true;
   25.28 +}
   25.29 +
   25.30 +MapValue::MapValue(const char* str)
   25.31 +{
   25.32 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
   25.33 +  p_value = new std::string(str);
   25.34 +  type = STRING;
   25.35 +  has_value = true;
   25.36 +}
   25.37 +
   25.38 +MapValue::operator double() const
   25.39 +{
   25.40 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
   25.41 +  if (!has_value) throw IllegalOperation();
   25.42 +  if (type == NUMERIC)
   25.43 +    return *(static_cast<double*>(p_value));
   25.44 +  else
   25.45 +    throw IllegalOperation();
   25.46 +}
   25.47 +
   25.48 +MapValue::operator std::string() const
   25.49 +{
   25.50 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
   25.51 +  if (!has_value) throw IllegalOperation();
   25.52 +  std::string ret;
   25.53 +  switch (type)
   25.54 +  {
   25.55 +    case NUMERIC:
   25.56 +      {
   25.57 +        double d = *(static_cast<double*>(p_value));
   25.58 +        std::ostringstream ostr;
   25.59 +        ostr << d;
   25.60 +        ret = ostr.str();
   25.61 +      }
   25.62 +      break;
   25.63 +    case STRING:
   25.64 +      ret = *(static_cast<std::string*>(p_value));
   25.65 +      break;
   25.66 +  }
   25.67 +  return ret;
   25.68 +}
   25.69 +
   25.70 +MapValue::MapValue(const MapValue& v)
   25.71 +{
   25.72 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
   25.73 +  if (!v.has_value) throw IllegalOperation();
   25.74 +  has_value = true;
   25.75 +  type = v.type;
   25.76 +  switch (v.type)
   25.77 +  {
   25.78 +    case NUMERIC:
   25.79 +      p_value = new double(*(static_cast<double*>(v.p_value)));
   25.80 +      break;
   25.81 +    case STRING:
   25.82 +      p_value = new std::string(*(static_cast<std::string*>(v.p_value)));
   25.83 +      break;
   25.84 +  }
   25.85 +}
   25.86 +
   25.87 +MapValue& MapValue::operator=(const MapValue& v)
   25.88 +{
   25.89 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
   25.90 +  if (&v != this)
   25.91 +  {
   25.92 +    if (!v.has_value) throw IllegalOperation();
   25.93 +    clear();
   25.94 +    has_value = true;
   25.95 +    type = v.type;
   25.96 +    switch (v.type)
   25.97 +    {
   25.98 +      case NUMERIC:
   25.99 +        p_value = new double(*(static_cast<double*>(v.p_value)));
  25.100 +        break;
  25.101 +      case STRING:
  25.102 +        p_value = new std::string(*(static_cast<std::string*>(v.p_value)));
  25.103 +        break;
  25.104 +    }
  25.105 +  }
  25.106 +  return *this;
  25.107 +}
  25.108 +
  25.109 +MapValue::~MapValue()
  25.110 +{
  25.111 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
  25.112 +  clear();
  25.113 +}
  25.114 +
  25.115 +void MapValue::clear()
  25.116 +{
  25.117 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
  25.118 +  if (!has_value) return;
  25.119 +  switch (type)
  25.120 +  {
  25.121 +    case NUMERIC:
  25.122 +      delete static_cast<double*>(p_value);
  25.123 +      break;
  25.124 +    case STRING:
  25.125 +      delete static_cast<std::string*>(p_value);
  25.126 +      break;
  25.127 +  }
  25.128 +}
  25.129 +
  25.130 +MapValue::Type MapValue::getType() const
  25.131 +{
  25.132 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
  25.133 +  return type;
  25.134 +}
  25.135 +
  25.136 +bool MapValue::hasValue() const
  25.137 +{
  25.138 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
  25.139 +  return has_value;
  25.140 +}
  25.141 +
  25.142 +std::ostream& operator<<(std::ostream &os, const MapValue& v)
  25.143 +{
  25.144 +  //std::cout << __PRETTY_FUNCTION__ << std::endl;
  25.145 +  if (!v.has_value) return os;
  25.146 +  switch (v.type)
  25.147 +  {
  25.148 +    case MapValue::NUMERIC:
  25.149 +      os << *(static_cast<double*>(v.p_value));
  25.150 +      break;
  25.151 +    case MapValue::STRING:
  25.152 +      os << *(static_cast<std::string*>(v.p_value));
  25.153 +      break;
  25.154 +  }
  25.155 +  return os;
  25.156 +}
    26.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    26.2 +++ b/map_value.h	Wed Jan 02 21:03:09 2008 +0000
    26.3 @@ -0,0 +1,43 @@
    26.4 +#ifndef MAP_VALUE_H
    26.5 +#define MAP_VALUE_H
    26.6 +
    26.7 +#include <exception>
    26.8 +#include <functional>
    26.9 +#include <iosfwd>
   26.10 +
   26.11 +class MapValue
   26.12 +{
   26.13 +  public:
   26.14 +    friend std::ostream& operator<<(std::ostream &os, const MapValue& v);
   26.15 +    class IllegalOperation : public std::exception
   26.16 +    {
   26.17 +      virtual const char* what() const throw()
   26.18 +      {
   26.19 +        return "Illegal operation.";
   26.20 +      }
   26.21 +    };
   26.22 +    typedef enum
   26.23 +    {
   26.24 +      NUMERIC = 1 << 0,
   26.25 +      STRING  = 1 << 1
   26.26 +    } Type;
   26.27 +  private:
   26.28 +    bool has_value;
   26.29 +    void* p_value;
   26.30 +    MapValue::Type type;
   26.31 +    void clear();
   26.32 +  public:
   26.33 +    MapValue();
   26.34 +    MapValue(double);
   26.35 +    MapValue(std::string);
   26.36 +    MapValue(const char* str);
   26.37 +    MapValue(const MapValue& v);
   26.38 +    MapValue& operator=(const MapValue& v);
   26.39 +    ~MapValue();
   26.40 +    operator std::string() const;
   26.41 +    operator double() const;
   26.42 +    Type getType() const;
   26.43 +    bool hasValue() const;
   26.44 +};
   26.45 +
   26.46 +#endif
    27.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    27.2 +++ b/map_value_map.cc	Wed Jan 02 21:03:09 2008 +0000
    27.3 @@ -0,0 +1,32 @@
    27.4 +#include "map_value_map.h"
    27.5 +#include "mapstorage.h"
    27.6 +
    27.7 +MapValueEdgeMap::MapValueEdgeMap(const std::string& _mapName, MapStorage* _pMapStorage) :
    27.8 +  mapName(_mapName),
    27.9 +  pMapStorage(_pMapStorage)
   27.10 +{
   27.11 +}
   27.12 +
   27.13 +MapValueEdgeMap::Value MapValueEdgeMap::operator[](Key k) const {
   27.14 +  return pMapStorage->get(mapName, k);
   27.15 +}
   27.16 +
   27.17 +void MapValueEdgeMap::set(Key k, Value v)
   27.18 +{
   27.19 +  pMapStorage->set(mapName, k, v);
   27.20 +}
   27.21 +
   27.22 +MapValueNodeMap::MapValueNodeMap(const std::string& _mapName, MapStorage* _pMapStorage) :
   27.23 +  mapName(_mapName),
   27.24 +  pMapStorage(_pMapStorage)
   27.25 +{
   27.26 +}
   27.27 +
   27.28 +MapValueNodeMap::Value MapValueNodeMap::operator[](Key k) const {
   27.29 +  return pMapStorage->get(mapName, k);
   27.30 +}
   27.31 +
   27.32 +void MapValueNodeMap::set(Key k, Value v)
   27.33 +{
   27.34 +  pMapStorage->set(mapName, k, v);
   27.35 +}
    28.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    28.2 +++ b/map_value_map.h	Wed Jan 02 21:03:09 2008 +0000
    28.3 @@ -0,0 +1,36 @@
    28.4 +#ifndef MAP_VALUE_MAP_H
    28.5 +#define MAP_VALUE_MAP_H
    28.6 +
    28.7 +#include "map_value.h"
    28.8 +#include <string>
    28.9 +#include "all_include.h"
   28.10 +
   28.11 +class MapStorage;
   28.12 +
   28.13 +class MapValueEdgeMap
   28.14 +{
   28.15 +  private:
   28.16 +    std::string mapName;
   28.17 +    MapStorage* pMapStorage;
   28.18 +  public:
   28.19 +    typedef MapValue Value;
   28.20 +    typedef Graph::Edge Key;
   28.21 +    MapValueEdgeMap(const std::string&, MapStorage*);
   28.22 +    Value operator[](Key k) const;
   28.23 +    void set(Key k, Value v);
   28.24 +};
   28.25 +
   28.26 +class MapValueNodeMap
   28.27 +{
   28.28 +  private:
   28.29 +    std::string mapName;
   28.30 +    MapStorage* pMapStorage;
   28.31 +  public:
   28.32 +    typedef MapValue Value;
   28.33 +    typedef Graph::Node Key;
   28.34 +    MapValueNodeMap(const std::string&, MapStorage*);
   28.35 +    Value operator[](Key k) const;
   28.36 +    void set(Key k, Value v);
   28.37 +};
   28.38 +
   28.39 +#endif
    29.1 --- a/map_win.cc	Wed May 02 20:33:58 2007 +0000
    29.2 +++ b/map_win.cc	Wed Jan 02 21:03:09 2008 +0000
    29.3 @@ -31,7 +31,12 @@
    29.4    return true;
    29.5  }
    29.6  
    29.7 -MapWin::MapWin(const std::string& title, std::vector<std::string> eml, std::vector<std::string> nml, NoteBookTab & mw):mytab(mw)
    29.8 +MapWin::MapWin(const std::string& title,
    29.9 +    std::vector<std::string> n_eml,
   29.10 +    std::vector<std::string> s_eml,
   29.11 +    std::vector<std::string> n_nml,
   29.12 +    std::vector<std::string> s_nml,
   29.13 +    NoteBookTab & mw):mytab(mw)
   29.14  {
   29.15    set_title(title);
   29.16    set_default_size(200, 50);
   29.17 @@ -48,7 +53,24 @@
   29.18  
   29.19    for(int i=0;i<EDGE_PROPERTY_NUM;i++)
   29.20    {
   29.21 -    e_combo_array[i]=new MapSelector(eml, mytab.getActiveEdgeMap(i), edge_property_strings[i], true);
   29.22 +    switch (i)
   29.23 +    {
   29.24 +      case E_WIDTH:
   29.25 +        e_combo_array[i]=new MapSelector(n_eml, s_eml,
   29.26 +            mytab.getActiveEdgeMap(i), edge_property_strings[i],
   29.27 +            true, true, NUM);
   29.28 +        break;
   29.29 +      case E_COLOR:
   29.30 +        e_combo_array[i]=new MapSelector(n_eml, s_eml,
   29.31 +            mytab.getActiveEdgeMap(i), edge_property_strings[i],
   29.32 +            true, true, NUM);
   29.33 +        break;
   29.34 +      case E_TEXT:
   29.35 +        e_combo_array[i]=new MapSelector(n_eml, s_eml,
   29.36 +            mytab.getActiveEdgeMap(i), edge_property_strings[i],
   29.37 +            true, true, ALL);
   29.38 +        break;
   29.39 +    }
   29.40  
   29.41      (*table).attach((*(e_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
   29.42  
   29.43 @@ -68,7 +90,24 @@
   29.44  
   29.45    for(int i=0;i<NODE_PROPERTY_NUM;i++)
   29.46    {
   29.47 -    n_combo_array[i]=new MapSelector(nml, mytab.getActiveNodeMap(i), node_property_strings[i], false);
   29.48 +    switch (i)
   29.49 +    {
   29.50 +      case N_RADIUS:
   29.51 +        n_combo_array[i]=new MapSelector(n_nml, s_nml,
   29.52 +            mytab.getActiveNodeMap(i), node_property_strings[i],
   29.53 +            false, true, NUM);
   29.54 +        break;
   29.55 +      case N_COLOR:
   29.56 +        n_combo_array[i]=new MapSelector(n_nml, s_nml,
   29.57 +            mytab.getActiveNodeMap(i), node_property_strings[i],
   29.58 +            false, true, NUM);
   29.59 +        break;
   29.60 +      case N_TEXT:
   29.61 +        n_combo_array[i]=new MapSelector(n_nml, s_nml,
   29.62 +            mytab.getActiveNodeMap(i), node_property_strings[i],
   29.63 +            false, true, ALL);
   29.64 +        break;
   29.65 +    }
   29.66  
   29.67      (*table).attach((*(n_combo_array[i])),0,1,i,i+1,Gtk::SHRINK,Gtk::SHRINK,10,3);
   29.68  
   29.69 @@ -82,6 +121,8 @@
   29.70  
   29.71    vbox.pack_start(*table);
   29.72  
   29.73 +  update(n_eml, s_eml, n_nml, s_nml);
   29.74 +
   29.75    show_all_children();
   29.76  
   29.77  }
   29.78 @@ -101,36 +142,40 @@
   29.79    mytab.popupNewMapWin(itisedge);
   29.80  }
   29.81  
   29.82 -void MapWin::update(std::vector<std::string> eml, std::vector<std::string> nml)
   29.83 +void MapWin::update(
   29.84 +    std::vector<std::string> n_eml,
   29.85 +    std::vector<std::string> s_eml,
   29.86 +    std::vector<std::string> n_nml,
   29.87 +    std::vector<std::string> s_nml)
   29.88  {
   29.89    for(int i=0;i<EDGE_PROPERTY_NUM;i++)
   29.90    {
   29.91 -    e_combo_array[i]->update_list(eml);
   29.92 +    e_combo_array[i]->update_list(n_eml, s_eml);
   29.93    }
   29.94  
   29.95    for(int i=0;i<NODE_PROPERTY_NUM;i++)
   29.96    {
   29.97 -    n_combo_array[i]->update_list(nml);
   29.98 +    n_combo_array[i]->update_list(n_nml, s_nml);
   29.99    }
  29.100  
  29.101    mytab.active_maps_needed();
  29.102  }
  29.103  
  29.104 -void MapWin::registerNewEdgeMap(std::string newmapname)
  29.105 +void MapWin::registerNewEdgeMap(std::string newmapname, MapValue::Type type)
  29.106  {
  29.107    for(int i=0;i<EDGE_PROPERTY_NUM;i++)
  29.108    {
  29.109      //filling in combo box with choices
  29.110 -    e_combo_array[i]->append_text((Glib::ustring)newmapname);
  29.111 +    e_combo_array[i]->append_text((Glib::ustring)newmapname, type);
  29.112    }
  29.113  }
  29.114  
  29.115 -void MapWin::registerNewNodeMap(std::string newmapname)
  29.116 +void MapWin::registerNewNodeMap(std::string newmapname, MapValue::Type type)
  29.117  {
  29.118    for(int i=0;i<NODE_PROPERTY_NUM;i++)
  29.119    {
  29.120      //filling in combo box with choices
  29.121 -    n_combo_array[i]->append_text((Glib::ustring)newmapname);
  29.122 +    n_combo_array[i]->append_text((Glib::ustring)newmapname, type);
  29.123    }
  29.124  }
  29.125  
    30.1 --- a/map_win.h	Wed May 02 20:33:58 2007 +0000
    30.2 +++ b/map_win.h	Wed Jan 02 21:03:09 2008 +0000
    30.3 @@ -25,6 +25,7 @@
    30.4  #include <all_include.h>
    30.5  #include <libgnomecanvasmm.h>
    30.6  #include <libgnomecanvasmm/polygon.h>
    30.7 +#include "map_value.h"
    30.8  
    30.9  ///Graph visualization setup window.
   30.10  
   30.11 @@ -64,10 +65,13 @@
   30.12    ///It creates the widgets shown in \ref MapWin and
   30.13    ///binds the needed signal to the correct place.
   30.14    ///\param title title of window
   30.15 -  ///\param eml edgemap list
   30.16 -  ///\param nml nodemap list
   30.17    ///\param mw the owner \ref NoteBookTab (\ref mytab)
   30.18 -  MapWin(const std::string& title, std::vector<std::string> eml, std::vector<std::string> nml, NoteBookTab & mw);
   30.19 +  MapWin(const std::string& title, 
   30.20 +      std::vector<std::string> n_eml,
   30.21 +      std::vector<std::string> s_eml,
   30.22 +      std::vector<std::string> n_nml,
   30.23 +      std::vector<std::string> s_nml,
   30.24 +      NoteBookTab & mw);
   30.25  
   30.26    ///Deregistrates \ref MapWin in its \ref NoteBookTab (\ref mytab)
   30.27    virtual bool on_delete_event(GdkEventAny *);
   30.28 @@ -106,13 +110,13 @@
   30.29  
   30.30    ///\param new_name
   30.31    ///name of new map
   30.32 -  void registerNewEdgeMap(std::string new_name);
   30.33 +  void registerNewEdgeMap(std::string new_name, MapValue::Type type);
   30.34  
   30.35    ///This function inserts name of the new nodemap in the name list in \ref MapSelector s
   30.36  
   30.37    ///\param new_name
   30.38    ///name of new map
   30.39 -  void registerNewNodeMap(std::string new_name);
   30.40 +  void registerNewNodeMap(std::string new_name, MapValue::Type type);
   30.41  
   30.42    ///Close window if Esc key pressed.
   30.43    virtual bool closeIfEscapeIsPressed(GdkEventKey*);
   30.44 @@ -124,9 +128,11 @@
   30.45    ///have changed as well. \ref NoteBookTab knows, whether it
   30.46    ///has to call this function or not from the \ref NoteBookTab::mapwinexists
   30.47    ///variable.
   30.48 -  ///\param eml edge map list
   30.49 -  ///\param nml node map list
   30.50 -  void update(std::vector<std::string> eml, std::vector<std::string> nml);
   30.51 +  void update(
   30.52 +    std::vector<std::string> n_eml,
   30.53 +    std::vector<std::string> s_eml,
   30.54 +    std::vector<std::string> n_nml,
   30.55 +    std::vector<std::string> s_nml);
   30.56  
   30.57    void changeEntry(bool, int, std::string);
   30.58  
    31.1 --- a/mapselector.cc	Wed May 02 20:33:58 2007 +0000
    31.2 +++ b/mapselector.cc	Wed Jan 02 21:03:09 2008 +0000
    31.3 @@ -18,61 +18,63 @@
    31.4  
    31.5  #include <mapselector.h>
    31.6  
    31.7 -MapSelector::MapSelector(std::vector<std::string> ml, std::string act, std::string labeltext, bool edge, bool d):def(d),itisedge(edge),set_new_map(false)
    31.8 +MapSelector::MapSelector(std::vector<std::string> n_ml,
    31.9 +    std::vector<std::string> s_ml, std::string act,
   31.10 +    std::string labeltext, bool edge, bool d, MapType type) :
   31.11 +  def(d),
   31.12 +  itisedge(edge),
   31.13 +  set_new_map(false),
   31.14 +  label(labeltext),
   31.15 +  map_type(type),
   31.16 +  newbut(Gtk::Stock::NEW)
   31.17  {
   31.18 -  update_list(ml);
   31.19 +  update_list(n_ml, s_ml);
   31.20  
   31.21    if(act=="")
   31.22 -    {
   31.23 -      cbt.set_active(0);
   31.24 -      default_state=true;
   31.25 -    }
   31.26 +  {
   31.27 +    cbt.set_active(0);
   31.28 +    default_state=true;
   31.29 +  }
   31.30    else
   31.31 -    {
   31.32 -      cbt.set_active_text((Glib::ustring)act);
   31.33 -      default_state=false;
   31.34 -    }
   31.35 +  {
   31.36 +    cbt.set_active_text((Glib::ustring)act);
   31.37 +    default_state=false;
   31.38 +  }
   31.39  
   31.40    //binding signal to the actual entry
   31.41    cbt.signal_changed().connect
   31.42      (
   31.43       sigc::mem_fun((*this), &MapSelector::comboChanged),
   31.44       false
   31.45 -     );
   31.46 -  
   31.47 -  label=new Gtk::Label(labeltext);
   31.48 +    );
   31.49  
   31.50 -  label->set_width_chars(longest_property_string_length);
   31.51 +  label.set_width_chars(longest_property_string_length);
   31.52  
   31.53 -  defbut=NULL;
   31.54    if(def)
   31.55 -    {
   31.56 -      defbut=new Gtk::Button();
   31.57 -      defbut->set_label("Reset");
   31.58 -      
   31.59 -      defbut->signal_pressed().connect
   31.60 -	(
   31.61 -	 sigc::mem_fun(*this, &MapSelector::reset)
   31.62 -	 );
   31.63 -    }
   31.64 +  {
   31.65 +    defbut.set_label("Reset");
   31.66 +    defbut.signal_pressed().connect
   31.67 +      (
   31.68 +       sigc::mem_fun(*this, &MapSelector::reset)
   31.69 +      );
   31.70 +  }
   31.71  
   31.72 -  newbut=new Gtk::Button(Gtk::Stock::NEW);
   31.73  
   31.74 -  newbut->signal_pressed().connect
   31.75 +  newbut.signal_pressed().connect
   31.76      (
   31.77       sigc::mem_fun(*this, &MapSelector::new_but_pressed)
   31.78 -     );
   31.79 +    );
   31.80  
   31.81 -  add(*label);
   31.82 +  add(label);
   31.83  
   31.84    add(cbt);
   31.85  
   31.86    if(def)
   31.87 -    {
   31.88 -      add(*defbut);
   31.89 -    }
   31.90 +  {
   31.91 +    add(defbut);
   31.92 +  }
   31.93  
   31.94 -  add(*newbut);
   31.95 +  add(newbut);
   31.96  }
   31.97  
   31.98  void MapSelector::new_but_pressed()
   31.99 @@ -81,17 +83,31 @@
  31.100    signal_newmapwin.emit(itisedge);
  31.101  }
  31.102  
  31.103 -void MapSelector::update_list( std::vector< std::string > ml )
  31.104 +void MapSelector::update_list(std::vector<std::string> n_ml,
  31.105 +    std::vector<std::string> s_ml)
  31.106  {
  31.107    int prev_act=cbt.get_active_row_number();
  31.108    cbt.clear();
  31.109    cbt_content.clear();
  31.110 -  std::vector< std::string >::iterator emsi=ml.begin();
  31.111 -  for(;emsi!=ml.end();emsi++)
  31.112 +
  31.113 +  if (map_type & NUM)
  31.114 +  {
  31.115 +    std::vector< std::string >::iterator emsi=n_ml.begin();
  31.116 +    for(;emsi!=n_ml.end();emsi++)
  31.117      {
  31.118        cbt.append_text(*emsi);
  31.119        cbt_content.push_back(*emsi);
  31.120      }
  31.121 +  }
  31.122 +  if (map_type & STR)
  31.123 +  {
  31.124 +    std::vector< std::string >::iterator emsi=s_ml.begin();
  31.125 +    for(;emsi!=s_ml.end();emsi++)
  31.126 +    {
  31.127 +      cbt.append_text(*emsi);
  31.128 +      cbt_content.push_back(*emsi);
  31.129 +    }
  31.130 +  }
  31.131    if(def)
  31.132      {
  31.133        cbt.prepend_text("Default values");
  31.134 @@ -147,16 +163,19 @@
  31.135      }
  31.136  }
  31.137  
  31.138 -void MapSelector::append_text(Glib::ustring text)
  31.139 +void MapSelector::append_text(Glib::ustring text, MapValue::Type type)
  31.140  {
  31.141 -  cbt.append_text(text);
  31.142 -  cbt_content.push_back(text);
  31.143 +  if (type & map_type)
  31.144 +  {
  31.145 +    cbt.append_text(text);
  31.146 +    cbt_content.push_back(text);
  31.147  
  31.148 -  if(set_new_map)
  31.149 +    if(set_new_map)
  31.150      {
  31.151        set_active_text(text);
  31.152        set_new_map=false;
  31.153      }
  31.154 +  }
  31.155  }
  31.156  
  31.157  sigc::signal<void, std::string> MapSelector::signal_cbt_ch()
    32.1 --- a/mapselector.h	Wed May 02 20:33:58 2007 +0000
    32.2 +++ b/mapselector.h	Wed Jan 02 21:03:09 2008 +0000
    32.3 @@ -22,6 +22,7 @@
    32.4  #include <all_include.h>
    32.5  #include <libgnomecanvasmm.h>
    32.6  #include <libgnomecanvasmm/polygon.h>
    32.7 +#include "map_value.h"
    32.8  
    32.9  ///A widget by which node and edgemaps can be selected, deselected and created.
   32.10  
   32.11 @@ -80,7 +81,7 @@
   32.12  
   32.13    ///By pressing it
   32.14    ///\ref NewMapWin wilol pop-up
   32.15 -  Gtk::Button * newbut;
   32.16 +  Gtk::Button newbut;
   32.17  
   32.18    ///Reset button.
   32.19  
   32.20 @@ -88,25 +89,28 @@
   32.21    ///set to 'Default' option.
   32.22    ///
   32.23    ///It is visible only if \ref def is true.
   32.24 -  Gtk::Button * defbut;
   32.25 -
   32.26 -  ///Container in which GUI elements are packed.
   32.27 -  Gtk::HBox hbox;
   32.28 +  Gtk::Button defbut;
   32.29  
   32.30    ///Shows purpose of \ref MapSelector piece.
   32.31 -  Gtk::Label * label;
   32.32 +  Gtk::Label label;
   32.33 +
   32.34 +  /// Which types of maps (integer, string, ...) to display.
   32.35 +  MapType map_type;
   32.36  
   32.37   public:
   32.38  
   32.39    ///Constructor of \ref MapSelector
   32.40  
   32.41    ///Creates the layout and binds signal to the correct place.
   32.42 -  ///\param optionlist list of names to place in \ref cbt
   32.43 +  ///\param mapstorage Pointer to the \ref MapStorage to get the map list from.
   32.44    ///\param act preselected option
   32.45    ///\param purpose text of label indicating purpose of \ref MapStorage
   32.46    ///\param itisedge do \ref MapSelector contains edgemap names or nodemapnames.
   32.47    ///\param def do we need 'Default' option. See \ref def.
   32.48 -  MapSelector(std::vector<std::string> optionlist, std::string act, std::string purpose, bool itisedge, bool def=true);
   32.49 +  ///\param type Specifies which types of maps to display.
   32.50 +  MapSelector(std::vector<std::string> n_ml,
   32.51 +      std::vector<std::string> s_ml, std::string act, std::string labeltext,
   32.52 +      bool edge, bool d = true, MapType type = ALL);
   32.53  
   32.54    ///Returns signal emitted if the user has changed the selection. (\ref signal_cbt)
   32.55    sigc::signal<void, std::string> signal_cbt_ch();
   32.56 @@ -119,7 +123,8 @@
   32.57    ///Fills in \ref cbt with names, taking
   32.58    ///into account that the previously selected option
   32.59    ///has to be set back after the operation.
   32.60 -  void update_list( std::vector<std::string> );
   32.61 +  void update_list(std::vector<std::string> n_ml,
   32.62 +      std::vector<std::string> s_ml);
   32.63  
   32.64    ///Handles changement in \ref cbt.
   32.65  
   32.66 @@ -168,6 +173,6 @@
   32.67    ///from that the option to append is coming. In this case
   32.68    ///this function  will set \ref cbt to the new option.
   32.69    ///\param new_option new option to append
   32.70 -  void append_text(Glib::ustring new_option);
   32.71 +  void append_text(Glib::ustring new_option, MapValue::Type);
   32.72  };
   32.73  #endif //MAPSELECTOR_H
    33.1 --- a/mapstorage.cc	Wed May 02 20:33:58 2007 +0000
    33.2 +++ b/mapstorage.cc	Wed Jan 02 21:03:09 2008 +0000
    33.3 @@ -7,7 +7,7 @@
    33.4   * (Egervary Research Group on Combinatorial Optimization, EGRES).
    33.5   *
    33.6   * Permission to use, modify and distribute this software is granted
    33.7 - * provided that this copyright notice appears in all copies. For
    33.8 + * provided that this copyright notice appears in all cop	ies. For
    33.9   * precise terms see the accompanying LICENSE file.
   33.10   *
   33.11   * This software is provided "AS IS" with no warranty of any kind,
   33.12 @@ -16,10 +16,15 @@
   33.13   *
   33.14   */
   33.15  
   33.16 +#include "i18n.h"
   33.17  #include <limits>
   33.18  #include <cmath>
   33.19 +#include <iostream>
   33.20 +#include <fstream>
   33.21 +#include <string>
   33.22 +#include <algorithm>
   33.23  #include <gtkmm.h>
   33.24 -
   33.25 +#include "file_import_dialog.h"
   33.26  #include <mapstorage.h>
   33.27  #include <gui_writer.h>
   33.28  #include <gui_reader.h>
   33.29 @@ -29,23 +34,35 @@
   33.30  const double a_d=0.05;
   33.31  const double p_d=40000;
   33.32  
   33.33 -MapStorage::MapStorage() : modified(false), file_name(""), arrow_pos_read_ok(false), iterations(i_d), attraction(a_d), propulsation(p_d), background_set(false)
   33.34 +MapStorage::MapStorage() :
   33.35 +  gui_sect_save_dest(LGF_FILE),
   33.36 +  node_coords_save_dest(SpecMapSaveOpts::GUI_SECT),
   33.37 +  arrow_coords_save_dest(SpecMapSaveOpts::GUI_SECT),
   33.38 +  modified(false),
   33.39 +  file_name(""),
   33.40 +  max_node_label(0),
   33.41 +  max_edge_label(0),
   33.42 +  node_coords_one_map_name("coord"),
   33.43 +  node_coords_two_maps_1_name("coord_x"),
   33.44 +  node_coords_two_maps_2_name("coord_y"),
   33.45 +  arrow_coords_one_map_name("arrow"),
   33.46 +  arrow_coords_two_maps_1_name("arrow_x"),
   33.47 +  arrow_coords_two_maps_2_name("arrow_y"),
   33.48 +  iterations(i_d),
   33.49 +  attraction(a_d),
   33.50 +  propulsation(p_d),
   33.51 +  node_coords_x(graph),
   33.52 +  node_coords_y(graph),
   33.53 +  arrow_coords_x(graph),
   33.54 +  arrow_coords_y(graph),
   33.55 +  node_label(graph),
   33.56 +  edge_label(graph),
   33.57 +  background_set(false)
   33.58  {
   33.59 -  nodemap_storage["coordinates_x"] = new Graph::NodeMap<double>(graph);
   33.60 -  coords.setXMap(*nodemap_storage["coordinates_x"]);
   33.61 -  nodemap_storage["coordinates_y"] = new Graph::NodeMap<double>(graph);
   33.62 -  coords.setYMap(*nodemap_storage["coordinates_y"]);
   33.63 -
   33.64 -  edgemap_storage["arrow_pos_x"] = new Graph::EdgeMap<double>(graph);
   33.65 -  arrow_pos.setXMap(*edgemap_storage["arrow_pos_x"]);
   33.66 -  edgemap_storage["arrow_pos_y"] = new Graph::EdgeMap<double>(graph);
   33.67 -  arrow_pos.setYMap(*edgemap_storage["arrow_pos_y"]);
   33.68 -
   33.69 -  nodemap_storage["label"] = new Graph::NodeMap<double>(graph);
   33.70 -  edgemap_storage["label"] = new Graph::EdgeMap<double>(graph);
   33.71 -
   33.72 -  nodemap_default["label"] = 1.0;
   33.73 -  edgemap_default["label"] = 1.0;
   33.74 +  node_coords.setXMap(node_coords_x);
   33.75 +  node_coords.setYMap(node_coords_y);
   33.76 +  arrow_coords.setXMap(arrow_coords_x);
   33.77 +  arrow_coords.setYMap(arrow_coords_y);
   33.78  
   33.79    active_nodemaps.resize(NODE_PROPERTY_NUM);
   33.80    for(int i=0;i<NODE_PROPERTY_NUM;i++)
   33.81 @@ -62,31 +79,51 @@
   33.82  
   33.83  MapStorage::~MapStorage()
   33.84  {
   33.85 -  for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it =
   33.86 -      nodemap_storage.begin(); it != nodemap_storage.end(); ++it)
   33.87 -  {
   33.88 -    delete it->second;
   33.89 -  }
   33.90 -  for (std::map<std::string, Graph::EdgeMap<double>*>::const_iterator it =
   33.91 -      edgemap_storage.begin(); it != edgemap_storage.end(); ++it)
   33.92 -  {
   33.93 -    delete it->second;
   33.94 -  }
   33.95 +  clear();
   33.96  }
   33.97  
   33.98 -int MapStorage::addNodeMap(const std::string & name, Graph::NodeMap<double> *nodemap, double default_value)
   33.99 +void MapStorage::createNodeMap(const std::string& name, MapValue::Type type,
  33.100 +    MapValue def_val)
  33.101  {
  33.102 -  if( nodemap_storage.find(name) == nodemap_storage.end() )
  33.103 -    {
  33.104 -      nodemap_storage[name]=nodemap;
  33.105 -      // set the maps default value
  33.106 -      nodemap_default[name] = default_value;
  33.107 +  NodeMapStore::const_iterator it = nodemaps.find(name);
  33.108 +  if (it != nodemaps.end())
  33.109 +    throw Error("Node map " + name + " already exists.");
  33.110  
  33.111 -      //announce changement in maps
  33.112 -      signal_node_map.emit(name);
  33.113 -      return 0;
  33.114 -    }
  33.115 -  return 1;
  33.116 +  switch (type)
  33.117 +  {
  33.118 +    case MapValue::NUMERIC:
  33.119 +      nodemaps[name] = new NumericNodeMapData(graph, def_val);
  33.120 +      break;
  33.121 +    case MapValue::STRING:
  33.122 +      nodemaps[name] = new StringNodeMapData(graph, def_val);
  33.123 +      break;
  33.124 +  }
  33.125 +
  33.126 +  nodemaps[name]->default_value = def_val;
  33.127 +
  33.128 +  signal_node_map.emit(name, type);
  33.129 +}
  33.130 +
  33.131 +void MapStorage::createEdgeMap(const std::string& name, MapValue::Type type,
  33.132 +    MapValue def_val)
  33.133 +{
  33.134 +  EdgeMapStore::const_iterator it = edgemaps.find(name);
  33.135 +  if (it != edgemaps.end())
  33.136 +    throw Error("Edge map " + name + " already exists.");
  33.137 +
  33.138 +  switch (type)
  33.139 +  {
  33.140 +    case MapValue::NUMERIC:
  33.141 +      edgemaps[name] = new NumericEdgeMapData(graph, def_val);
  33.142 +      break;
  33.143 +    case MapValue::STRING:
  33.144 +      edgemaps[name] = new StringEdgeMapData(graph, def_val);
  33.145 +      break;
  33.146 +  }
  33.147 +
  33.148 +  edgemaps[name]->default_value = def_val;
  33.149 +
  33.150 +  signal_edge_map.emit(name, type);
  33.151  }
  33.152  
  33.153  void MapStorage::changeActiveMap(bool itisedge, int prop, std::string mapname)
  33.154 @@ -115,7 +152,6 @@
  33.155      }
  33.156  }
  33.157  
  33.158 -
  33.159  std::string MapStorage::getActiveEdgeMap(int prop)
  33.160  {
  33.161    return active_edgemaps[prop];
  33.162 @@ -126,32 +162,64 @@
  33.163    return active_nodemaps[prop];
  33.164  }
  33.165  
  33.166 -std::vector<std::string> MapStorage::getEdgeMapList()
  33.167 +std::vector<std::string> MapStorage::getEdgeMapList(MapType type)
  33.168  {
  33.169 -  std::vector<std::string> eml;
  33.170 -  eml.resize(edgemap_storage.size());
  33.171 -  int i=0;
  33.172 -  std::map< std::string,Graph::EdgeMap<double> * >::iterator emsi=beginOfEdgeMaps();
  33.173 -  for(;emsi!=endOfEdgeMaps();emsi++)
  33.174 +  if (type == ALL)
  33.175 +  {
  33.176 +    std::vector<std::string> ret;
  33.177 +    for (EdgeMapStore::const_iterator it = edgemaps.begin();
  33.178 +        it != edgemaps.end(); ++it)
  33.179      {
  33.180 -      eml[i]=(emsi->first);
  33.181 -      i++;
  33.182 +      ret.push_back(it->first);
  33.183      }
  33.184 -  return eml;
  33.185 +    return ret;
  33.186 +  }
  33.187 +  else
  33.188 +  {
  33.189 +    std::vector<std::string> ret;
  33.190 +    for (EdgeMapStore::const_iterator it = edgemaps.begin();
  33.191 +        it != edgemaps.end(); ++it)
  33.192 +    {
  33.193 +      EdgeMapData* data = getEdgeMapData(it->first);
  33.194 +      MapValue::Type t = data->type();
  33.195 +      if ((t == MapValue::NUMERIC && (type & NUM)) ||
  33.196 +          (t == MapValue::STRING && (type & STR)))
  33.197 +      {
  33.198 +        ret.push_back(it->first);
  33.199 +      }
  33.200 +    }
  33.201 +    return ret;
  33.202 +  }
  33.203  }
  33.204  
  33.205 -std::vector<std::string> MapStorage::getNodeMapList()
  33.206 +std::vector<std::string> MapStorage::getNodeMapList(MapType type)
  33.207  {
  33.208 -  std::vector<std::string> nml;
  33.209 -  nml.resize(nodemap_storage.size());
  33.210 -  int i=0;
  33.211 -  std::map< std::string,Graph::NodeMap<double> * >::iterator nmsi=beginOfNodeMaps();
  33.212 -  for(;nmsi!=endOfNodeMaps();nmsi++)
  33.213 +  if (type == ALL)
  33.214 +  {
  33.215 +    std::vector<std::string> ret;
  33.216 +    for (NodeMapStore::const_iterator it = nodemaps.begin();
  33.217 +        it != nodemaps.end(); ++it)
  33.218      {
  33.219 -      nml[i]=(nmsi->first);
  33.220 -      i++;
  33.221 +      ret.push_back(it->first);
  33.222      }
  33.223 -  return nml;
  33.224 +    return ret;
  33.225 +  }
  33.226 +  else
  33.227 +  {
  33.228 +    std::vector<std::string> ret;
  33.229 +    for (NodeMapStore::const_iterator it = nodemaps.begin();
  33.230 +        it != nodemaps.end(); ++it)
  33.231 +    {
  33.232 +      NodeMapData* data = getNodeMapData(it->first);
  33.233 +      MapValue::Type t = data->type();
  33.234 +      if ((t == MapValue::NUMERIC && (type & NUM)) ||
  33.235 +          (t == MapValue::STRING && (type & STR)))
  33.236 +      {
  33.237 +        ret.push_back(it->first);
  33.238 +      }
  33.239 +    }
  33.240 +    return ret;
  33.241 +  }
  33.242  }
  33.243  
  33.244  sigc::signal<void, bool, int> MapStorage::signal_prop_ch()
  33.245 @@ -159,255 +227,491 @@
  33.246    return signal_prop;
  33.247  }
  33.248  
  33.249 -int MapStorage::addEdgeMap(const std::string & name, Graph::EdgeMap<double> *edgemap, double default_value)
  33.250 +int MapStorage::readFromFile(const std::string &filename)
  33.251  {
  33.252 -  if( edgemap_storage.find(name) == edgemap_storage.end() )
  33.253 +  using std::vector;
  33.254 +  using std::map;
  33.255 +  using std::string;
  33.256 +
  33.257 +  // check whether the .conf file exists
  33.258 +  bool gui_data_in_conf = g_file_test((filename + ".conf").c_str(),
  33.259 +      (GFileTest)(G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR));
  33.260 +
  33.261 +  // check whether the .lgf file contains a gui section
  33.262 +  bool gui_data_in_lgf = false;
  33.263 +  {
  33.264 +    std::ifstream ifs(filename.c_str());
  33.265 +    std::string line;
  33.266 +    while (getline(ifs, line))
  33.267      {
  33.268 -      edgemap_storage[name]=edgemap;
  33.269 -      // set the maps default value
  33.270 -      edgemap_default[name] = default_value;
  33.271 -
  33.272 -      //announce changement in maps
  33.273 -      signal_edge_map.emit(name);
  33.274 -      return 0;
  33.275 -    }
  33.276 -  return 1;
  33.277 -}
  33.278 -
  33.279 -double MapStorage::maxOfNodeMap(const std::string & name)
  33.280 -{
  33.281 -  double max=0;
  33.282 -  for (NodeIt j(graph); j!=INVALID; ++j)
  33.283 -  {
  33.284 -    if( (*nodemap_storage[name])[j]>max )
  33.285 -    {
  33.286 -      max=(*nodemap_storage[name])[j];
  33.287 +      int pos = line.find("@gui");
  33.288 +      if (pos != std::string::npos)
  33.289 +      {
  33.290 +        bool only_whitespace_before = true;
  33.291 +        for (int i = 0; i < pos; ++i)
  33.292 +        {
  33.293 +          if (!std::isspace(line[i]))
  33.294 +          {
  33.295 +            only_whitespace_before = false;
  33.296 +            break;
  33.297 +          }
  33.298 +        }
  33.299 +        if (only_whitespace_before) gui_data_in_lgf = true;
  33.300 +      }
  33.301      }
  33.302    }
  33.303 -  return max;
  33.304 -}
  33.305  
  33.306 -double MapStorage::maxOfEdgeMap(const std::string & name)
  33.307 -{
  33.308 -  double max=0;
  33.309 -  for (EdgeIt j(graph); j!=INVALID; ++j)
  33.310 +  bool gui_data_found = gui_data_in_lgf || gui_data_in_conf;
  33.311 +
  33.312 +  // ask for user input if both exist
  33.313 +  bool use_gui_data_in_lgf = false;
  33.314 +  if (gui_data_in_conf && gui_data_in_lgf)
  33.315    {
  33.316 -    if( (*edgemap_storage[name])[j]>max )
  33.317 +    Gtk::MessageDialog mdialog(_("<b>Found both ") + filename +
  33.318 +        _(".conf and a gui section in ") + filename + _(".</b>"), true,
  33.319 +        Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_NONE);
  33.320 +	  mdialog.add_button(_("Use the ._conf file"), 1);
  33.321 +	  mdialog.add_button(_("Use the _gui section"), 2);
  33.322 +    switch (mdialog.run())
  33.323      {
  33.324 -      max=(*edgemap_storage[name])[j];
  33.325 +      case 1:
  33.326 +        use_gui_data_in_lgf = false;
  33.327 +        break;
  33.328 +      case 2:
  33.329 +        use_gui_data_in_lgf = true;
  33.330 +        break;
  33.331 +      case Gtk::RESPONSE_NONE:
  33.332 +        return 1;
  33.333      }
  33.334    }
  33.335 -  return max;
  33.336 -}
  33.337 +  else
  33.338 +  {
  33.339 +    use_gui_data_in_lgf = gui_data_in_lgf;
  33.340 +  }
  33.341  
  33.342 -double MapStorage::minOfNodeMap(const std::string & name)
  33.343 -{
  33.344 -  NodeIt j(graph);
  33.345 -  double min;
  33.346 -  if(j!=INVALID)
  33.347 +  if (gui_data_found)
  33.348 +  {
  33.349 +    GUISectData gui_data;
  33.350 +    if (use_gui_data_in_lgf)
  33.351      {
  33.352 -      min=(*nodemap_storage[name])[j];
  33.353 +      // read the gui section from the .lgf file
  33.354 +      try
  33.355 +      {
  33.356 +        LemonReader lreader(filename);
  33.357 +        GuiReader gui_reader(lreader, this, gui_data);
  33.358 +        lreader.run();
  33.359 +        gui_sect_save_dest = LGF_FILE;
  33.360 +      }
  33.361 +      catch (Exception& error)
  33.362 +      {
  33.363 +        clear();
  33.364 +        return 1;
  33.365 +      }
  33.366      }
  33.367 -  else
  33.368 +    else
  33.369      {
  33.370 -      min=0;
  33.371 +      // read the gui section from the .conf file
  33.372 +      try
  33.373 +      {
  33.374 +        LemonReader lreader(filename + ".conf");
  33.375 +        GuiReader gui_reader(lreader, this, gui_data);
  33.376 +        lreader.run();
  33.377 +        gui_sect_save_dest = CONF_FILE;
  33.378 +      }
  33.379 +      catch (Exception& error)
  33.380 +      {
  33.381 +        clear();
  33.382 +        return 1;
  33.383 +      }
  33.384      }
  33.385 -  for (; j!=INVALID; ++j)
  33.386 -  {
  33.387 -    if( (*nodemap_storage[name])[j]<min )
  33.388 +
  33.389 +    // read the graph and maps form the .lgf file
  33.390 +    try
  33.391      {
  33.392 -      min=(*nodemap_storage[name])[j];
  33.393 +      std::string node_coord_xmap_name, node_coord_ymap_name;
  33.394 +      std::string arrow_coord_xmap_name, arrow_coord_ymap_name;
  33.395 +
  33.396 +      if (gui_data.node_coords_save_dest ==
  33.397 +          MapStorage::SpecMapSaveOpts::NESET_SECT)
  33.398 +      {
  33.399 +        switch (gui_data.node_coords_save_map_num)
  33.400 +        {
  33.401 +          case SpecMapSaveOpts::ONE_MAP:
  33.402 +            node_coord_xmap_name = gui_data.node_coords_one_map_name + ":x";
  33.403 +            node_coord_ymap_name = gui_data.node_coords_one_map_name + ":y";
  33.404 +            node_coords_one_map_name = gui_data.node_coords_one_map_name;
  33.405 +            break;
  33.406 +          case SpecMapSaveOpts::TWO_MAPS:
  33.407 +            node_coord_xmap_name = gui_data.node_coords_two_maps_1_name;
  33.408 +            node_coord_ymap_name = gui_data.node_coords_two_maps_2_name;
  33.409 +            node_coords_two_maps_1_name = gui_data.node_coords_two_maps_1_name;
  33.410 +            node_coords_two_maps_2_name = gui_data.node_coords_two_maps_2_name;
  33.411 +            break;
  33.412 +        }
  33.413 +        node_coords_save_dest = gui_data.node_coords_save_dest;
  33.414 +        node_coords_save_map_num = gui_data.node_coords_save_map_num;
  33.415 +      }
  33.416 +
  33.417 +      if (gui_data.arrow_coords_save_dest ==
  33.418 +          MapStorage::SpecMapSaveOpts::NESET_SECT)
  33.419 +      {
  33.420 +        switch (gui_data.arrow_coords_save_map_num)
  33.421 +        {
  33.422 +          case SpecMapSaveOpts::ONE_MAP:
  33.423 +            arrow_coord_xmap_name = gui_data.arrow_coords_one_map_name + ":x";
  33.424 +            arrow_coord_ymap_name = gui_data.arrow_coords_one_map_name + ":y";
  33.425 +            arrow_coords_one_map_name = gui_data.arrow_coords_one_map_name;
  33.426 +            break;
  33.427 +          case SpecMapSaveOpts::TWO_MAPS:
  33.428 +            arrow_coord_xmap_name = gui_data.arrow_coords_two_maps_1_name;
  33.429 +            arrow_coord_ymap_name = gui_data.arrow_coords_two_maps_2_name;
  33.430 +            arrow_coords_two_maps_1_name =
  33.431 +              gui_data.arrow_coords_two_maps_1_name;
  33.432 +            arrow_coords_two_maps_2_name =
  33.433 +              gui_data.arrow_coords_two_maps_2_name;
  33.434 +            break;
  33.435 +        }
  33.436 +        arrow_coords_save_dest = gui_data.arrow_coords_save_dest;
  33.437 +        arrow_coords_save_map_num = gui_data.arrow_coords_save_map_num;
  33.438 +      }
  33.439 +      readLGF(filename, true,
  33.440 +          gui_data.main_node_map_names, gui_data.main_edge_map_names,
  33.441 +          gui_data.node_map_types, gui_data.edge_map_types,
  33.442 +          node_coord_xmap_name, node_coord_ymap_name,
  33.443 +          arrow_coord_xmap_name, arrow_coord_ymap_name);
  33.444      }
  33.445 -  }
  33.446 -  return min;
  33.447 -}
  33.448 -
  33.449 -double MapStorage::minOfEdgeMap(const std::string & name)
  33.450 -{
  33.451 -  EdgeIt j(graph);
  33.452 -  double min;
  33.453 -  if(j!=INVALID)
  33.454 +    catch (Exception& error)
  33.455      {
  33.456 -      min=(*edgemap_storage[name])[j];
  33.457 -    }
  33.458 -  else
  33.459 -    {
  33.460 -      min=0;
  33.461 -    }
  33.462 -  for (EdgeIt j(graph); j!=INVALID; ++j)
  33.463 -  {
  33.464 -    if( (*edgemap_storage[name])[j]<min )
  33.465 -    {
  33.466 -      min=(*edgemap_storage[name])[j];
  33.467 -    }
  33.468 -  }
  33.469 -  return min;
  33.470 -}
  33.471 -
  33.472 -int MapStorage::readFromFile(const std::string &filename)
  33.473 -{
  33.474 -  bool read_x = false;
  33.475 -  bool read_y = false;
  33.476 -  bool read_edge_id = false;
  33.477 -
  33.478 -  try {
  33.479 -    LemonReader lreader(filename);
  33.480 -    ContentReader content(lreader);
  33.481 -    lreader.run();
  33.482 -
  33.483 -    if (content.nodeSetNum() < 1)
  33.484 -    {
  33.485 -      Gtk::MessageDialog mdialog("No nodeset found in file.");
  33.486 -      mdialog.run();
  33.487        clear();
  33.488        return 1;
  33.489      }
  33.490  
  33.491 -    if (content.edgeSetNum() < 1)
  33.492 +    // add the maps from the gui section
  33.493 +    for (vector<string>::const_iterator
  33.494 +        it = gui_data.gui_node_map_names.begin();
  33.495 +        it != gui_data.gui_node_map_names.end(); ++it)
  33.496      {
  33.497 -      Gtk::MessageDialog mdialog("No edgeset found in file.");
  33.498 -      mdialog.run();
  33.499 -      clear();
  33.500 -      return 1;
  33.501 +      string map_name = *it;
  33.502 +      switch (gui_data.node_map_types[map_name])
  33.503 +      {
  33.504 +        case MapValue::NUMERIC:
  33.505 +          {
  33.506 +            createNodeMap(map_name, MapValue::NUMERIC, double());
  33.507 +            NumericNodeMap& dmap = getNumericNodeMap(map_name);
  33.508 +            map<int, double>& smap = *gui_data.numeric_node_maps[map_name];
  33.509 +            for (NodeIt n(graph); n != INVALID; ++n)
  33.510 +            {
  33.511 +              dmap[n] = smap[node_label[n]];
  33.512 +            }
  33.513 +            break;
  33.514 +          }
  33.515 +        case MapValue::STRING:
  33.516 +          {
  33.517 +            createNodeMap(map_name, MapValue::STRING, string());
  33.518 +            StringNodeMap& dmap = getStringNodeMap(map_name);
  33.519 +            map<int, string>& smap = *gui_data.string_node_maps[map_name];
  33.520 +            for (NodeIt n(graph); n != INVALID; ++n)
  33.521 +            {
  33.522 +              dmap[n] = smap[node_label[n]];
  33.523 +            }
  33.524 +            break;
  33.525 +          }
  33.526 +      }
  33.527 +      getNodeMapData(map_name)->save_dest = GUI_SECT;
  33.528 +    }
  33.529 +    for (vector<string>::const_iterator
  33.530 +        it = gui_data.gui_edge_map_names.begin();
  33.531 +        it != gui_data.gui_edge_map_names.end(); ++it)
  33.532 +    {
  33.533 +      string map_name = *it;
  33.534 +      switch (gui_data.edge_map_types[map_name])
  33.535 +      {
  33.536 +        case MapValue::NUMERIC:
  33.537 +          {
  33.538 +            createEdgeMap(map_name, MapValue::NUMERIC, double());
  33.539 +            NumericEdgeMap& dmap = getNumericEdgeMap(map_name);
  33.540 +            map<int, double>& smap = *gui_data.numeric_edge_maps[map_name];
  33.541 +            for (EdgeIt e(graph); e != INVALID; ++e)
  33.542 +            {
  33.543 +              dmap[e] = smap[edge_label[e]];
  33.544 +            }
  33.545 +            break;
  33.546 +          }
  33.547 +        case MapValue::STRING:
  33.548 +          {
  33.549 +            createEdgeMap(map_name, MapValue::STRING, string());
  33.550 +            StringEdgeMap& dmap = getStringEdgeMap(map_name);
  33.551 +            map<int, string>& smap = *gui_data.string_edge_maps[map_name];
  33.552 +            for (EdgeIt e(graph); e != INVALID; ++e)
  33.553 +            {
  33.554 +              dmap[e] = smap[edge_label[e]];
  33.555 +            }
  33.556 +            break;
  33.557 +          }
  33.558 +      }
  33.559 +      getEdgeMapData(map_name)->save_dest = GUI_SECT;
  33.560      }
  33.561  
  33.562 -    const std::vector<std::string>& nodeMapNames = content.nodeSetMaps(0);
  33.563 -    const std::vector<std::string>& edgeMapNames = content.edgeSetMaps(0);
  33.564 +    // restore the node coordinate maps
  33.565 +    if (gui_data.node_coords_save_dest ==
  33.566 +        MapStorage::SpecMapSaveOpts::GUI_SECT)
  33.567 +    {
  33.568 +      for (NodeIt n(graph); n != INVALID; ++n)
  33.569 +      {
  33.570 +        node_coords.set(n, gui_data.node_coord_map[node_label[n]]);
  33.571 +      }
  33.572 +      node_coords_save_dest = gui_data.node_coords_save_dest;
  33.573 +    }
  33.574 +    // restore the arrow coordinate maps
  33.575 +    if (gui_data.arrow_coords_save_dest ==
  33.576 +        MapStorage::SpecMapSaveOpts::GUI_SECT)
  33.577 +    {
  33.578 +      for (EdgeIt e(graph); e != INVALID; ++e)
  33.579 +      {
  33.580 +        arrow_coords.set(e, gui_data.arrow_coord_map[edge_label[e]]);
  33.581 +      }
  33.582 +      arrow_coords_save_dest = gui_data.arrow_coords_save_dest;
  33.583 +    }
  33.584 +  }
  33.585 +  else
  33.586 +  {
  33.587 +    // there is no gui section neither in the .lgf file nor in the .conf file
  33.588 +    {
  33.589 +      LemonReader lreader(filename);
  33.590 +      ContentReader content(lreader);
  33.591 +      try
  33.592 +      {
  33.593 +        lreader.run();
  33.594 +      }
  33.595 +      catch (Exception& error)
  33.596 +      {
  33.597 +        Gtk::MessageDialog mdialog(error.what());
  33.598 +        mdialog.run();
  33.599 +        clear();
  33.600 +        return 1;
  33.601 +      }
  33.602  
  33.603 -    GraphReader<Graph> greader(filename, graph);
  33.604 -    for (std::vector<std::string>::const_iterator it = nodeMapNames.begin();
  33.605 -        it != nodeMapNames.end(); ++it)
  33.606 -    {
  33.607 -      if (*it == "coordinates_x")
  33.608 +      if (content.nodeSetNum() < 1)
  33.609        {
  33.610 -        read_x = true;
  33.611 -        //std::cout << "read X nodemap" << std::endl;
  33.612 +        Gtk::MessageDialog mdialog("No nodeset found in file.");
  33.613 +        mdialog.run();
  33.614 +        clear();
  33.615 +        return 1;
  33.616        }
  33.617 -      else if (*it == "coordinates_y")
  33.618 +
  33.619 +      if (content.edgeSetNum() < 1)
  33.620        {
  33.621 -        read_y = true;
  33.622 -        //std::cout << "read Y nodemap" << std::endl;
  33.623 +        Gtk::MessageDialog mdialog("No edgeset found in file.");
  33.624 +        mdialog.run();
  33.625 +        clear();
  33.626 +        return 1;
  33.627        }
  33.628 -      else if (*it == "label")
  33.629 +
  33.630 +      std::vector<std::string> nodeMapNames = content.nodeSetMaps(0);
  33.631 +      std::vector<std::string> edgeMapNames = content.edgeSetMaps(0);
  33.632 +      
  33.633 +      bool read_edge_label = true;
  33.634 +      if (std::find(edgeMapNames.begin(), edgeMapNames.end(), "label") ==
  33.635 +          edgeMapNames.end())
  33.636        {
  33.637 -        //std::cout << "read id nodemap" << std::endl;
  33.638 +        read_edge_label = false;
  33.639 +      }
  33.640 +
  33.641 +      nodeMapNames.erase(
  33.642 +          std::remove(nodeMapNames.begin(), nodeMapNames.end(), "label"),
  33.643 +          nodeMapNames.end());
  33.644 +
  33.645 +      edgeMapNames.erase(
  33.646 +          std::remove(edgeMapNames.begin(), edgeMapNames.end(), "label"),
  33.647 +          edgeMapNames.end());
  33.648 +
  33.649 +      FileImportDialog::ImportData data(nodeMapNames, edgeMapNames);
  33.650 +      FileImportDialog fidialog(&data);
  33.651 +      int response = fidialog.run();
  33.652 +      if (response == Gtk::RESPONSE_OK)
  33.653 +      {
  33.654 +        try
  33.655 +        {
  33.656 +          std::string node_coord_xmap_name, node_coord_ymap_name;
  33.657 +          std::string arrow_coord_xmap_name, arrow_coord_ymap_name;
  33.658 +          bool gen_node_coords = false;
  33.659 +          bool gen_arrow_coords = false;
  33.660 +
  33.661 +          switch (data.node_coord_load_from)
  33.662 +          {
  33.663 +            case FileImportDialog::ImportData::ONE_MAP:
  33.664 +              node_coord_xmap_name = data.node_coord_one_map_name + ":x";
  33.665 +              node_coord_ymap_name = data.node_coord_one_map_name + ":y";
  33.666 +              node_coords_one_map_name = data.node_coord_one_map_name;
  33.667 +
  33.668 +              node_coords_save_dest = SpecMapSaveOpts::NESET_SECT;
  33.669 +              node_coords_save_map_num = SpecMapSaveOpts::ONE_MAP;
  33.670 +              break;
  33.671 +            case FileImportDialog::ImportData::TWO_MAPS:
  33.672 +              node_coord_xmap_name = data.node_coord_two_maps_1_name;
  33.673 +              node_coord_ymap_name = data.node_coord_two_maps_2_name;
  33.674 +              node_coords_two_maps_1_name = data.node_coord_two_maps_1_name;
  33.675 +              node_coords_two_maps_2_name = data.node_coord_two_maps_2_name;
  33.676 +
  33.677 +              node_coords_save_dest = SpecMapSaveOpts::NESET_SECT;
  33.678 +              node_coords_save_map_num = SpecMapSaveOpts::TWO_MAPS;
  33.679 +              break;
  33.680 +            case FileImportDialog::ImportData::DONT_READ:
  33.681 +              node_coord_xmap_name = "";
  33.682 +              node_coord_ymap_name = "";
  33.683 +
  33.684 +              node_coords_save_dest = SpecMapSaveOpts::GUI_SECT;
  33.685 +              gen_node_coords = true;
  33.686 +              break;
  33.687 +          }
  33.688 +
  33.689 +          switch (data.arrow_coord_load_from)
  33.690 +          {
  33.691 +            case FileImportDialog::ImportData::ONE_MAP:
  33.692 +              arrow_coord_xmap_name = data.arrow_coord_one_map_name + ":x";
  33.693 +              arrow_coord_ymap_name = data.arrow_coord_one_map_name + ":y";
  33.694 +              arrow_coords_one_map_name = data.arrow_coord_one_map_name;
  33.695 +
  33.696 +              arrow_coords_save_dest = SpecMapSaveOpts::NESET_SECT;
  33.697 +              arrow_coords_save_map_num = SpecMapSaveOpts::ONE_MAP;
  33.698 +              break;
  33.699 +            case FileImportDialog::ImportData::TWO_MAPS:
  33.700 +              arrow_coord_xmap_name = data.arrow_coord_two_maps_1_name;
  33.701 +              arrow_coord_ymap_name = data.arrow_coord_two_maps_2_name;
  33.702 +              arrow_coords_two_maps_1_name = data.arrow_coord_two_maps_1_name;
  33.703 +              arrow_coords_two_maps_2_name = data.arrow_coord_two_maps_2_name;
  33.704 +
  33.705 +              arrow_coords_save_dest = SpecMapSaveOpts::NESET_SECT;
  33.706 +              arrow_coords_save_map_num = SpecMapSaveOpts::TWO_MAPS;
  33.707 +              break;
  33.708 +            case FileImportDialog::ImportData::DONT_READ:
  33.709 +              arrow_coord_xmap_name = "";
  33.710 +              arrow_coord_ymap_name = "";
  33.711 +
  33.712 +              arrow_coords_save_dest = SpecMapSaveOpts::GUI_SECT;
  33.713 +              gen_arrow_coords = true;
  33.714 +              break;
  33.715 +          }
  33.716 +
  33.717 +          // read edge and node maps
  33.718 +          std::vector<std::string> node_map_names;
  33.719 +          std::vector<std::string> edge_map_names;
  33.720 +          std::map<std::string, MapValue::Type> node_map_types;
  33.721 +          std::map<std::string, MapValue::Type> edge_map_types;
  33.722 +          for (std::vector<std::string>::const_iterator it =
  33.723 +              data.numeric_node_map_names.begin();
  33.724 +              it != data.numeric_node_map_names.end(); ++it)
  33.725 +          {
  33.726 +            node_map_names.push_back(*it);
  33.727 +            node_map_types[*it] = MapValue::NUMERIC;
  33.728 +          }
  33.729 +          for (std::vector<std::string>::const_iterator it =
  33.730 +              data.string_node_map_names.begin();
  33.731 +              it != data.string_node_map_names.end(); ++it)
  33.732 +          {
  33.733 +            node_map_names.push_back(*it);
  33.734 +            node_map_types[*it] = MapValue::STRING;
  33.735 +          }
  33.736 +          for (std::vector<std::string>::const_iterator it =
  33.737 +              data.numeric_edge_map_names.begin();
  33.738 +              it != data.numeric_edge_map_names.end(); ++it)
  33.739 +          {
  33.740 +            edge_map_names.push_back(*it);
  33.741 +            edge_map_types[*it] = MapValue::NUMERIC;
  33.742 +          }
  33.743 +          for (std::vector<std::string>::const_iterator it =
  33.744 +              data.string_edge_map_names.begin();
  33.745 +              it != data.string_edge_map_names.end(); ++it)
  33.746 +          {
  33.747 +            edge_map_names.push_back(*it);
  33.748 +            edge_map_types[*it] = MapValue::STRING;
  33.749 +          }
  33.750 +
  33.751 +          readLGF(filename, read_edge_label,
  33.752 +              node_map_names, edge_map_names,
  33.753 +              node_map_types, edge_map_types,
  33.754 +              node_coord_xmap_name, node_coord_ymap_name,
  33.755 +              arrow_coord_xmap_name, arrow_coord_ymap_name);
  33.756 +
  33.757 +          // generate edge labels
  33.758 +          if (!read_edge_label)
  33.759 +          {
  33.760 +            int l = 0;
  33.761 +            for (EdgeIt e(graph); e != INVALID; ++e)
  33.762 +            {
  33.763 +              edge_label[e] = l++;
  33.764 +            }
  33.765 +          }
  33.766 +
  33.767 +          if (gen_node_coords)
  33.768 +          {
  33.769 +            // generate node coordinates
  33.770 +            int node_num = 0;
  33.771 +            for (NodeIt n(graph); n != INVALID; ++n) { node_num++; }
  33.772 +            const double pi = 3.142;
  33.773 +            double step = 2 * pi / (double) node_num;
  33.774 +            int i = 0;
  33.775 +            for (NodeIt n(graph); n != INVALID; ++n)
  33.776 +            {
  33.777 +              setNodeCoords(n,
  33.778 +                  XY(250.0 * std::cos(i * step),
  33.779 +                    250.0 * std::sin(i * step)));
  33.780 +              i++;
  33.781 +            }
  33.782 +          }
  33.783 +          if (gen_arrow_coords)
  33.784 +          {
  33.785 +            // generate arrow coordinates
  33.786 +            for (EdgeIt e(graph); e != INVALID; ++e)
  33.787 +            {
  33.788 +              if (graph.source(e) == graph.target(e))
  33.789 +              {
  33.790 +                setArrowCoords(e,
  33.791 +                    getNodeCoords(graph.source(e)) + XY(0.0, 80.0));
  33.792 +              }
  33.793 +              else
  33.794 +              {
  33.795 +                setArrowCoords(e,
  33.796 +                    (getNodeCoords(graph.source(e)) +
  33.797 +                     getNodeCoords(graph.target(e))) / 2.0);
  33.798 +              }
  33.799 +            }
  33.800 +          }
  33.801 +        }
  33.802 +        catch (Exception& error)
  33.803 +        {
  33.804 +          clear();
  33.805 +          return 1;
  33.806 +        }
  33.807        }
  33.808        else
  33.809        {
  33.810 -        nodemap_storage[*it] = new Graph::NodeMap<double>(graph);
  33.811 -        //std::cout << "read " << *it << " nodemap" << std::endl;
  33.812 -      }
  33.813 -      greader.readNodeMap(*it, *nodemap_storage[*it]);
  33.814 -    }
  33.815 -    for (std::vector<std::string>::const_iterator it = edgeMapNames.begin();
  33.816 -        it != edgeMapNames.end(); ++it)
  33.817 -    {
  33.818 -      if (*it == "label")
  33.819 -      {
  33.820 -        //std::cout << "read id edgemap" << std::endl;
  33.821 -        read_edge_id = true;
  33.822 -      }
  33.823 -      else
  33.824 -      {
  33.825 -        edgemap_storage[*it] = new Graph::EdgeMap<double>(graph);
  33.826 -        //std::cout << "read " << *it << " edgemap" << std::endl;
  33.827 -      }
  33.828 -      greader.readEdgeMap(*it, *edgemap_storage[*it]);
  33.829 -    }
  33.830 -    GuiReader gui_reader(greader, this);
  33.831 -    greader.run();
  33.832 -  } catch (Exception& error) {
  33.833 -    Gtk::MessageDialog mdialog(error.what());
  33.834 -    mdialog.run();
  33.835 -    clear();
  33.836 -    return 1;
  33.837 -  }
  33.838 -
  33.839 -  if (!read_edge_id)
  33.840 -  {
  33.841 -    edgemap_storage["label"] = new Graph::EdgeMap<double>(graph);
  33.842 -    int i = 1;
  33.843 -    for (EdgeIt e(graph); e != INVALID; ++e)
  33.844 -    {
  33.845 -      (*edgemap_storage["label"])[e] = i++;
  33.846 -    }
  33.847 -  }
  33.848 -
  33.849 -  if (!read_x || !read_y)
  33.850 -  {
  33.851 -    int node_num = 0;
  33.852 -    for (NodeIt n(graph); n != INVALID; ++n)
  33.853 -    {
  33.854 -      node_num++;
  33.855 -    }
  33.856 -    const double pi = 3.142;
  33.857 -    double step = 2 * pi / (double) node_num;
  33.858 -    int i = 0;
  33.859 -    for (NodeIt n(graph); n != INVALID; ++n)
  33.860 -    {
  33.861 -      nodemap_storage["coordinates_x"]->set(n, 250.0 * std::cos(i * step));
  33.862 -      nodemap_storage["coordinates_y"]->set(n, 250.0 * std::sin(i * step));
  33.863 -      i++;
  33.864 -    }
  33.865 -  }
  33.866 -
  33.867 -  if (!arrow_pos_read_ok)
  33.868 -  {
  33.869 -    arrow_pos_read_ok = false;
  33.870 -    for (EdgeIt e(graph); e != INVALID; ++e)
  33.871 -    {
  33.872 -      if (graph.source(e) == graph.target(e))
  33.873 -      {
  33.874 -        arrow_pos.set(e, coords[graph.source(e)] + XY(0.0, 80.0));
  33.875 -      }
  33.876 -      else
  33.877 -      {
  33.878 -        arrow_pos.set(e, (coords[graph.source(e)] + coords[graph.target(e)]) / 2.0);
  33.879 +        clear();
  33.880 +        return 1;
  33.881        }
  33.882      }
  33.883    }
  33.884  
  33.885 -  // fill in the default values for the maps
  33.886 -  for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it =
  33.887 -      nodemap_storage.begin(); it != nodemap_storage.end(); ++it)
  33.888 +  // set max_node_label
  33.889    {
  33.890 -    if ((it->first != "label") &&
  33.891 -        (it->first != "coordiantes_x") &&
  33.892 -        (it->first != "coordinates_y"))
  33.893 +    max_node_label = std::numeric_limits<int>::min();
  33.894 +    for (NodeIt n(graph); n != INVALID; ++n)
  33.895      {
  33.896 -      nodemap_default[it->first] = 0.0;
  33.897 -    }
  33.898 -    else if (it->first == "label")
  33.899 -    {
  33.900 -      NodeIt n(graph);
  33.901 -      double max = (*nodemap_storage["label"])[n];
  33.902 -      for (; n != INVALID; ++n)
  33.903 +      if (node_label[n] > max_node_label)
  33.904        {
  33.905 -        if ((*nodemap_storage["label"])[n] > max)
  33.906 -          max = (*nodemap_storage["label"])[n];
  33.907 +        max_node_label = node_label[n];
  33.908        }
  33.909 -      nodemap_default["label"] = max + 1.0;
  33.910      }
  33.911    }
  33.912 -  for (std::map<std::string, Graph::EdgeMap<double>*>::const_iterator it =
  33.913 -      edgemap_storage.begin(); it != edgemap_storage.end(); ++it)
  33.914 +  // set max_edge_label
  33.915    {
  33.916 -    if (it->first != "label")
  33.917 +    max_edge_label = std::numeric_limits<int>::min();
  33.918 +    for (EdgeIt e(graph); e != INVALID; ++e)
  33.919      {
  33.920 -      edgemap_default[it->first] = 0.0;
  33.921 -    }
  33.922 -    else
  33.923 -    {
  33.924 -      double max = std::numeric_limits<double>::min();
  33.925 -      for (EdgeIt e(graph); e != INVALID; ++e)
  33.926 +      if (edge_label[e] > max_edge_label)
  33.927        {
  33.928 -        if ((*edgemap_storage["label"])[e] > max)
  33.929 -          max = (*edgemap_storage["label"])[e];
  33.930 +        max_edge_label = edge_label[e];
  33.931        }
  33.932 -      if (max > std::numeric_limits<double>::min())
  33.933 -        edgemap_default["label"] = max + 1.0;
  33.934 -      else
  33.935 -        edgemap_default["label"] = 1.0;
  33.936      }
  33.937    }
  33.938  
  33.939 @@ -416,70 +720,160 @@
  33.940  
  33.941  void MapStorage::writeToFile(const std::string &filename)
  33.942  {
  33.943 -  GraphWriter<Graph> gwriter(filename, graph);
  33.944 +  // relabel nodes and edges
  33.945 +  int i = 0;
  33.946 +  for (NodeIt n(graph); n != INVALID; ++n)
  33.947 +  {
  33.948 +    node_label[n] = i++;
  33.949 +  }
  33.950 +  max_node_label = i-1;
  33.951 +  i = 0;
  33.952 +  for (EdgeIt e(graph); e != INVALID; ++e)
  33.953 +  {
  33.954 +    edge_label[e] = i++;
  33.955 +  }
  33.956 +  max_edge_label = i-1;
  33.957  
  33.958 -  for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it =
  33.959 -      nodemap_storage.begin(); it != nodemap_storage.end(); ++it)
  33.960 +  // write .lgf file
  33.961    {
  33.962 -    gwriter.writeNodeMap(it->first, *(it->second));
  33.963 -  }
  33.964 -  for (std::map<std::string, Graph::EdgeMap<double>*>::const_iterator it =
  33.965 -      edgemap_storage.begin(); it != edgemap_storage.end(); ++it)
  33.966 -  {
  33.967 -    if ((it->first != "arrow_pos_x") &&
  33.968 -        (it->first != "arrow_pos_y"))
  33.969 +    GraphWriter<Graph> gwriter(filename, graph);
  33.970 +
  33.971 +    gwriter.writeNodeMap("label", node_label);
  33.972 +    gwriter.writeEdgeMap("label", edge_label);
  33.973 +
  33.974 +    // write node maps
  33.975 +    for (NodeMapStore::const_iterator it = nodemaps.begin();
  33.976 +        it != nodemaps.end(); ++it)
  33.977      {
  33.978 -      gwriter.writeEdgeMap(it->first, *(it->second));
  33.979 +      if (it->second->save_dest == NESET_SECT)
  33.980 +      {
  33.981 +        switch (it->second->type())
  33.982 +        {
  33.983 +          case MapValue::NUMERIC:
  33.984 +            gwriter.writeNodeMap(it->first, getNumericNodeMap(it->first));
  33.985 +            break;
  33.986 +          case MapValue::STRING:
  33.987 +            gwriter.writeNodeMap(it->first, getStringNodeMap(it->first));
  33.988 +            break;
  33.989 +        }
  33.990 +      }
  33.991 +    }
  33.992 +
  33.993 +    // write edge maps
  33.994 +    for (EdgeMapStore::const_iterator it = edgemaps.begin();
  33.995 +        it != edgemaps.end(); ++it)
  33.996 +    {
  33.997 +      if (it->second->save_dest == NESET_SECT)
  33.998 +      {
  33.999 +        switch (it->second->type())
 33.1000 +        {
 33.1001 +          case MapValue::NUMERIC:
 33.1002 +            gwriter.writeEdgeMap(it->first, getNumericEdgeMap(it->first));
 33.1003 +            break;
 33.1004 +          case MapValue::STRING:
 33.1005 +            gwriter.writeEdgeMap(it->first, getStringEdgeMap(it->first));
 33.1006 +            break;
 33.1007 +        }
 33.1008 +      }
 33.1009 +    }
 33.1010 +
 33.1011 +    // write node coordinates
 33.1012 +    switch (getNodeCoordsSaveDest())
 33.1013 +    {
 33.1014 +      case MapStorage::SpecMapSaveOpts::GUI_SECT:
 33.1015 +        break;
 33.1016 +      case MapStorage::SpecMapSaveOpts::NESET_SECT:
 33.1017 +        switch (getNodeCoordsSaveMapNum())
 33.1018 +        {
 33.1019 +          case MapStorage::SpecMapSaveOpts::ONE_MAP:
 33.1020 +            gwriter.writeNodeMap(node_coords_one_map_name + ":x",
 33.1021 +                node_coords_x);
 33.1022 +            gwriter.writeNodeMap(node_coords_one_map_name + ":y",
 33.1023 +                node_coords_y);
 33.1024 +            break;
 33.1025 +          case MapStorage::SpecMapSaveOpts::TWO_MAPS:
 33.1026 +            gwriter.writeNodeMap(node_coords_two_maps_1_name,
 33.1027 +                node_coords_x);
 33.1028 +            gwriter.writeNodeMap(node_coords_two_maps_2_name,
 33.1029 +                node_coords_y);
 33.1030 +            break;
 33.1031 +        }
 33.1032 +        break;
 33.1033 +    }
 33.1034 +
 33.1035 +    // write arrow coordinates
 33.1036 +    switch (getArrowCoordsSaveDest())
 33.1037 +    {
 33.1038 +      case MapStorage::SpecMapSaveOpts::GUI_SECT:
 33.1039 +        break;
 33.1040 +      case MapStorage::SpecMapSaveOpts::NESET_SECT:
 33.1041 +        switch (getArrowCoordsSaveMapNum())
 33.1042 +        {
 33.1043 +          case MapStorage::SpecMapSaveOpts::ONE_MAP:
 33.1044 +            gwriter.writeEdgeMap(arrow_coords_one_map_name + ":x",
 33.1045 +                arrow_coords_x);
 33.1046 +            gwriter.writeEdgeMap(arrow_coords_one_map_name + ":y",
 33.1047 +                arrow_coords_y);
 33.1048 +            break;
 33.1049 +          case MapStorage::SpecMapSaveOpts::TWO_MAPS:
 33.1050 +            gwriter.writeEdgeMap(arrow_coords_two_maps_1_name,
 33.1051 +                arrow_coords_x);
 33.1052 +            gwriter.writeEdgeMap(arrow_coords_two_maps_2_name,
 33.1053 +                arrow_coords_y);
 33.1054 +            break;
 33.1055 +        }
 33.1056 +        break;
 33.1057 +    }
 33.1058 +
 33.1059 +    if (gui_sect_save_dest == LGF_FILE)
 33.1060 +    {
 33.1061 +      GuiWriter gui_writer(gwriter, this);
 33.1062 +      gwriter.run();
 33.1063 +    }
 33.1064 +    else
 33.1065 +    {
 33.1066 +      gwriter.run();
 33.1067      }
 33.1068    }
 33.1069  
 33.1070 -  GuiWriter gui_writer(gwriter, this);
 33.1071 -
 33.1072 -  gwriter.run();
 33.1073 +  // write .conf file
 33.1074 +  if (gui_sect_save_dest == CONF_FILE)
 33.1075 +  {
 33.1076 +    LemonWriter lwriter(filename + ".conf");
 33.1077 +    GuiWriter gui_writer(lwriter, this);
 33.1078 +    lwriter.run();
 33.1079 +  }
 33.1080  }
 33.1081  
 33.1082  void MapStorage::clear()
 33.1083  {
 33.1084 -  for (std::map<std::string, Graph::NodeMap<double>*>::iterator it =
 33.1085 -      nodemap_storage.begin(); it != nodemap_storage.end(); ++it)
 33.1086 +  for (NodeMapStore::iterator it = nodemaps.begin(); it != nodemaps.end(); ++it)
 33.1087    {
 33.1088 -    if ((it->first != "coordinates_x") &&
 33.1089 -        (it->first != "coordinates_y") &&
 33.1090 -        (it->first != "label"))
 33.1091 -    {
 33.1092 -      delete it->second;
 33.1093 -      nodemap_storage.erase(it);
 33.1094 -    }
 33.1095 +    delete it->second;
 33.1096 +    nodemaps.erase(it);
 33.1097    }
 33.1098 -  for (std::map<std::string, Graph::EdgeMap<double>*>::iterator it =
 33.1099 -      edgemap_storage.begin(); it != edgemap_storage.end(); ++it)
 33.1100 +  for (EdgeMapStore::iterator it = edgemaps.begin(); it != edgemaps.end(); ++it)
 33.1101    {
 33.1102 -    if ((it->first != "label") &&
 33.1103 -        (it->first != "arrow_pos_x") &&
 33.1104 -        (it->first != "arrow_pos_y"))
 33.1105 -    {
 33.1106 -      delete it->second;
 33.1107 -      edgemap_storage.erase(it);
 33.1108 -    }
 33.1109 -  }
 33.1110 -  for (std::map<std::string, double>::iterator it =
 33.1111 -      nodemap_default.begin(); it != nodemap_default.end(); ++it)
 33.1112 -  {
 33.1113 -    if (it->first != "label")
 33.1114 -      nodemap_default.erase(it);
 33.1115 -  }
 33.1116 -  for (std::map<std::string, double>::iterator it =
 33.1117 -      edgemap_default.begin(); it != edgemap_default.end(); ++it)
 33.1118 -  {
 33.1119 -    if (it->first != "label")
 33.1120 -      edgemap_default.erase(it);
 33.1121 +    delete it->second;
 33.1122 +    edgemaps.erase(it);
 33.1123    }
 33.1124    graph.clear();
 33.1125    file_name = "";
 33.1126    modified = false;
 33.1127 +  max_node_label = 0;
 33.1128 +  max_edge_label = 0;
 33.1129 +  background_set = false;
 33.1130  
 33.1131 -  arrow_pos_read_ok = false;
 33.1132 -  
 33.1133 +  gui_sect_save_dest = LGF_FILE;
 33.1134 +  node_coords_save_dest = SpecMapSaveOpts::GUI_SECT;
 33.1135 +  arrow_coords_save_dest = SpecMapSaveOpts::GUI_SECT;
 33.1136 +  node_coords_one_map_name = "coord";
 33.1137 +  node_coords_two_maps_1_name = "coord_x";
 33.1138 +  node_coords_two_maps_2_name = "coord_y";
 33.1139 +  arrow_coords_one_map_name = "arrow";
 33.1140 +  arrow_coords_two_maps_1_name = "arrow_x";
 33.1141 +  arrow_coords_two_maps_2_name = "arrow_y";
 33.1142 +
 33.1143    for(int i=0;i<NODE_PROPERTY_NUM;i++)
 33.1144      {
 33.1145        changeActiveMap(false, i, "");
 33.1146 @@ -499,33 +893,28 @@
 33.1147    signal_design_win.emit(attraction, propulsation, iterations);
 33.1148  }
 33.1149  
 33.1150 -void MapStorage::ArrowPosReadOK()
 33.1151 -{
 33.1152 -  arrow_pos_read_ok = true;
 33.1153 -}
 33.1154 -
 33.1155  void MapStorage::mapChanged(bool itisedge, std::string mapname)
 33.1156  {
 33.1157    if(itisedge)
 33.1158 +  {
 33.1159 +    for(int i=0;i<EDGE_PROPERTY_NUM;i++)
 33.1160      {
 33.1161 -      for(int i=0;i<EDGE_PROPERTY_NUM;i++)
 33.1162 -	{
 33.1163 -	  if(active_edgemaps[i]==mapname)
 33.1164 -	    {
 33.1165 -	      signal_prop.emit(itisedge, i);
 33.1166 -	    }
 33.1167 -	}
 33.1168 +      if(active_edgemaps[i]==mapname)
 33.1169 +      {
 33.1170 +        signal_prop.emit(itisedge, i);
 33.1171 +      }
 33.1172      }
 33.1173 +  }
 33.1174    else
 33.1175 +  {
 33.1176 +    for(int i=0;i<NODE_PROPERTY_NUM;i++)
 33.1177      {
 33.1178 -      for(int i=0;i<NODE_PROPERTY_NUM;i++)
 33.1179 -	{
 33.1180 -	  if(active_nodemaps[i]==mapname)
 33.1181 -	    {
 33.1182 -	      signal_prop.emit(itisedge, i);
 33.1183 -	    }
 33.1184 -	}
 33.1185 +      if(active_nodemaps[i]==mapname)
 33.1186 +      {
 33.1187 +        signal_prop.emit(itisedge, i);
 33.1188 +      }
 33.1189      }
 33.1190 +  }
 33.1191  }
 33.1192  
 33.1193  void MapStorage::get_design_data(double & attraction_p, double & propulsation_p, int & iterations_p)
 33.1194 @@ -555,6 +944,479 @@
 33.1195    signal_design_win.emit(attraction, propulsation, iterations);
 33.1196  }
 33.1197  
 33.1198 +XY MapStorage::getNodeCoords(Node n) const
 33.1199 +{
 33.1200 +  return node_coords[n];
 33.1201 +}
 33.1202 +
 33.1203 +void MapStorage::setNodeCoords(Node n, XY c)
 33.1204 +{
 33.1205 +  node_coords.set(n, c);
 33.1206 +}
 33.1207 +
 33.1208 +XY MapStorage::getArrowCoords(Edge e) const
 33.1209 +{
 33.1210 +  return arrow_coords[e];
 33.1211 +}
 33.1212 +
 33.1213 +void MapStorage::setArrowCoords(Edge e, XY c)
 33.1214 +{
 33.1215 +  arrow_coords.set(e, c);
 33.1216 +}
 33.1217 +
 33.1218 +MapValue MapStorage::get(const std::string& name, Node node) const
 33.1219 +{
 33.1220 +  NodeMapData* data = getNodeMapData(name);
 33.1221 +  return data->get(node);
 33.1222 +}
 33.1223 +
 33.1224 +void MapStorage::set(const std::string& name, Node node, MapValue val)
 33.1225 +{
 33.1226 +  NodeMapData* data = getNodeMapData(name);
 33.1227 +  data->set(node, val);
 33.1228 +}
 33.1229 +
 33.1230 +MapValue MapStorage::get(const std::string& name, Edge edge) const
 33.1231 +{
 33.1232 +  EdgeMapData* data = getEdgeMapData(name);
 33.1233 +  return data->get(edge);
 33.1234 +}
 33.1235 +
 33.1236 +void MapStorage::set(const std::string& name, Edge edge, MapValue val)
 33.1237 +{
 33.1238 +  EdgeMapData* data = getEdgeMapData(name);
 33.1239 +  data->set(edge, val);
 33.1240 +}
 33.1241 +
 33.1242 +const std::string& MapStorage::getFileName() const
 33.1243 +{
 33.1244 +  return file_name;
 33.1245 +}
 33.1246 +
 33.1247 +void MapStorage::setFileName(const std::string& fn)
 33.1248 +{
 33.1249 +  file_name = fn;
 33.1250 +}
 33.1251 +
 33.1252 +bool MapStorage::getModified() const
 33.1253 +{
 33.1254 +  return modified;
 33.1255 +}
 33.1256 +
 33.1257 +void MapStorage::setModified(bool m)
 33.1258 +{
 33.1259 +  modified = m;
 33.1260 +}
 33.1261 +
 33.1262 +Node MapStorage::addNode(XY coords)
 33.1263 +{
 33.1264 +  Node node = graph.addNode();
 33.1265 +
 33.1266 +  setNodeCoords(node, coords);
 33.1267 +
 33.1268 +  max_node_label++;
 33.1269 +
 33.1270 +  node_label[node] = max_node_label;
 33.1271 +
 33.1272 +  std::vector<std::string> node_maps = getNodeMapList();
 33.1273 +  for (std::vector<std::string>::const_iterator it = node_maps.begin();
 33.1274 +      it != node_maps.end(); ++it)
 33.1275 +  {
 33.1276 +    NodeMapData* data = getNodeMapData(*it);
 33.1277 +    set(*it, node, data->default_value);
 33.1278 +  }
 33.1279 +
 33.1280 +  return node;
 33.1281 +}
 33.1282 +
 33.1283 +Edge MapStorage::addEdge(Node from, Node to)
 33.1284 +{
 33.1285 +  Edge edge = graph.addEdge(from, to);
 33.1286 +
 33.1287 +  if (from == to)
 33.1288 +  {
 33.1289 +    setArrowCoords(edge, getNodeCoords(from) + XY(0.0, 80.0));
 33.1290 +  }
 33.1291 +  else
 33.1292 +  {
 33.1293 +    setArrowCoords(edge, (getNodeCoords(from) + getNodeCoords(to)) / 2.0);
 33.1294 +  }
 33.1295 +
 33.1296 +  max_edge_label++;
 33.1297 +
 33.1298 +  edge_label[edge] = max_edge_label;
 33.1299 +
 33.1300 +  std::vector<std::string> edge_maps = getEdgeMapList();
 33.1301 +  for (std::vector<std::string>::const_iterator it = edge_maps.begin();
 33.1302 +      it != edge_maps.end(); ++it)
 33.1303 +  {
 33.1304 +    EdgeMapData* data = getEdgeMapData(*it);
 33.1305 +    set(*it, edge, data->default_value);
 33.1306 +  }
 33.1307 +  return edge;
 33.1308 +}
 33.1309 +
 33.1310 +MapStorage::NumericNodeMap& MapStorage::getNumericNodeMap(const std::string& name)
 33.1311 +{
 33.1312 +  NodeMapData* data = getNodeMapData(name);
 33.1313 +  if (data->type() != MapValue::NUMERIC)
 33.1314 +    throw Error("Numeric node map " + name + " does not exists.");
 33.1315 +  return static_cast<NumericNodeMapData*>(data)->map;
 33.1316 +}
 33.1317 +
 33.1318 +MapStorage::StringNodeMap& MapStorage::getStringNodeMap(const std::string& name)
 33.1319 +{
 33.1320 +  NodeMapData* data = getNodeMapData(name);
 33.1321 +  if (data->type() != MapValue::STRING)
 33.1322 +    throw Error("String node map " + name + " does not exists.");
 33.1323 +  return static_cast<StringNodeMapData*>(data)->map;
 33.1324 +}
 33.1325 +
 33.1326 +MapStorage::NumericEdgeMap& MapStorage::getNumericEdgeMap(const std::string& name)
 33.1327 +{
 33.1328 +  EdgeMapData* data = getEdgeMapData(name);
 33.1329 +  if (data->type() != MapValue::NUMERIC)
 33.1330 +    throw Error("Numeric edge map " + name + " does not exists.");
 33.1331 +  return static_cast<NumericEdgeMapData*>(data)->map;
 33.1332 +}
 33.1333 +
 33.1334 +MapStorage::StringEdgeMap& MapStorage::getStringEdgeMap(const std::string& name)
 33.1335 +{
 33.1336 +  EdgeMapData* data = getEdgeMapData(name);
 33.1337 +  if (data->type() != MapValue::STRING)
 33.1338 +    throw Error("String edge map " + name + " does not exists.");
 33.1339 +  return static_cast<StringEdgeMapData*>(data)->map;
 33.1340 +}
 33.1341 +
 33.1342 +MapValueEdgeMap MapStorage::getEdgeMap(const std::string& name)
 33.1343 +{
 33.1344 +  return MapValueEdgeMap(name, this);
 33.1345 +}
 33.1346 +
 33.1347 +MapValueNodeMap MapStorage::getNodeMap(const std::string& name)
 33.1348 +{
 33.1349 +  return MapValueNodeMap(name, this);
 33.1350 +}
 33.1351 +
 33.1352 +int MapStorage::getLabel(Node n) const
 33.1353 +{
 33.1354 +  return node_label[n];
 33.1355 +}
 33.1356 +
 33.1357 +int MapStorage::getLabel(Edge e) const
 33.1358 +{
 33.1359 +  return edge_label[e];
 33.1360 +}
 33.1361 +
 33.1362 +MapStorage::GuiSectSaveDest MapStorage::getGUIDataSaveLocation()
 33.1363 +{
 33.1364 +  return gui_sect_save_dest;
 33.1365 +}
 33.1366 +
 33.1367 +void MapStorage::setGUIDataSaveLocation(MapStorage::GuiSectSaveDest dest)
 33.1368 +{
 33.1369 +  gui_sect_save_dest = dest;
 33.1370 +}
 33.1371 +
 33.1372 +MapStorage::MapSaveDest MapStorage::getNodeMapSaveDest(std::string name) const
 33.1373 +{
 33.1374 +  NodeMapData *data = getNodeMapData(name);
 33.1375 +  return data->save_dest;
 33.1376 +}
 33.1377 +
 33.1378 +MapStorage::MapSaveDest MapStorage::getEdgeMapSaveDest(std::string name) const
 33.1379 +{
 33.1380 +  EdgeMapData *data = getEdgeMapData(name);
 33.1381 +  return data->save_dest;
 33.1382 +}
 33.1383 +
 33.1384 +void MapStorage::setNodeMapSaveDest(std::string name, MapStorage::MapSaveDest dest)
 33.1385 +{
 33.1386 +  NodeMapData *data = getNodeMapData(name);
 33.1387 +  data->save_dest = dest;
 33.1388 +}
 33.1389 +
 33.1390 +void MapStorage::setEdgeMapSaveDest(std::string name, MapStorage::MapSaveDest dest)
 33.1391 +{
 33.1392 +  EdgeMapData *data = getEdgeMapData(name);
 33.1393 +  data->save_dest = dest;
 33.1394 +}
 33.1395 +
 33.1396 +MapStorage::EdgeMapData* MapStorage::getEdgeMapData(std::string name) const
 33.1397 +{
 33.1398 +  EdgeMapStore::const_iterator it = edgemaps.find(name);
 33.1399 +  if (it != edgemaps.end())
 33.1400 +    return it->second;
 33.1401 +  else
 33.1402 +    throw Error("Edge map " + name + " does not exists.");
 33.1403 +}
 33.1404 +
 33.1405 +MapStorage::NodeMapData* MapStorage::getNodeMapData(std::string name) const
 33.1406 +{
 33.1407 +  NodeMapStore::const_iterator it = nodemaps.find(name);
 33.1408 +  if (it != nodemaps.end())
 33.1409 +    return it->second;
 33.1410 +  else
 33.1411 +    throw Error("Node map " + name + " does not exists.");
 33.1412 +}
 33.1413 +
 33.1414 +MapValue::Type MapStorage::getNodeMapElementType(std::string name) const
 33.1415 +{
 33.1416 +  NodeMapData *data = getNodeMapData(name);
 33.1417 +  return data->type();
 33.1418 +}
 33.1419 +
 33.1420 +MapValue::Type MapStorage::getEdgeMapElementType(std::string name) const
 33.1421 +{
 33.1422 +  EdgeMapData *data = getEdgeMapData(name);
 33.1423 +  return data->type();
 33.1424 +}
 33.1425 +
 33.1426 +const MapStorage::NodeLabelMap& MapStorage::getNodeLabelMap()
 33.1427 +{
 33.1428 +  return node_label;
 33.1429 +}
 33.1430 +
 33.1431 +const MapStorage::EdgeLabelMap& MapStorage::getEdgeLabelMap()
 33.1432 +{
 33.1433 +  return edge_label;
 33.1434 +}
 33.1435 +
 33.1436 +const Graph& MapStorage::getGraph()
 33.1437 +{
 33.1438 +  return graph;
 33.1439 +}
 33.1440 +
 33.1441 +bool MapStorage::nodeMapExists(std::string name)
 33.1442 +{
 33.1443 +  NodeMapStore::const_iterator it = nodemaps.find(name);
 33.1444 +  if (it == nodemaps.end())
 33.1445 +    return false;
 33.1446 +  else
 33.1447 +    return true;
 33.1448 +}
 33.1449 +
 33.1450 +bool MapStorage::edgeMapExists(std::string name)
 33.1451 +{
 33.1452 +  EdgeMapStore::const_iterator it = edgemaps.find(name);
 33.1453 +  if (it == edgemaps.end())
 33.1454 +    return false;
 33.1455 +  else
 33.1456 +    return true;
 33.1457 +}
 33.1458 +
 33.1459 +std::vector<std::string> MapStorage::getEdgeMaps(MapType type)
 33.1460 +{
 33.1461 +  std::vector<std::string> maps;
 33.1462 +  for (EdgeMapStore::const_iterator it = edgemaps.begin(); it != edgemaps.end(); ++it)
 33.1463 +  {
 33.1464 +    if (it->second->type() & type)
 33.1465 +    {
 33.1466 +      maps.push_back(it->first);
 33.1467 +    }
 33.1468 +  }
 33.1469 +  return maps;
 33.1470 +}
 33.1471 +
 33.1472 +std::vector<std::string> MapStorage::getNodeMaps(MapType type)
 33.1473 +{
 33.1474 +  std::vector<std::string> maps;
 33.1475 +  for (NodeMapStore::const_iterator it = nodemaps.begin(); it != nodemaps.end(); ++it)
 33.1476 +  {
 33.1477 +    if (it->second->type() & type)
 33.1478 +    {
 33.1479 +      maps.push_back(it->first);
 33.1480 +    }
 33.1481 +  }
 33.1482 +  return maps;
 33.1483 +}
 33.1484 +
 33.1485 +MapStorage::NodeCoordMap& MapStorage::getNodeCoordMap()
 33.1486 +{
 33.1487 +  return node_coords;
 33.1488 +}
 33.1489 +
 33.1490 +MapStorage::ArrowCoordMap& MapStorage::getArrowCoordMap()
 33.1491 +{
 33.1492 +  return arrow_coords;
 33.1493 +}
 33.1494 +
 33.1495 +MapStorage::SpecMapSaveOpts::Dest MapStorage::getNodeCoordsSaveDest()
 33.1496 +{
 33.1497 +  return node_coords_save_dest;
 33.1498 +}
 33.1499 +
 33.1500 +MapStorage::SpecMapSaveOpts::Dest MapStorage::getArrowCoordsSaveDest()
 33.1501 +{
 33.1502 +  return arrow_coords_save_dest;
 33.1503 +}
 33.1504 +
 33.1505 +void MapStorage::setNodeCoordsSaveDest(MapStorage::SpecMapSaveOpts::Dest dest)
 33.1506 +{
 33.1507 +  node_coords_save_dest = dest;
 33.1508 +}
 33.1509 +
 33.1510 +void MapStorage::setArrowCoordsSaveDest(MapStorage::SpecMapSaveOpts::Dest dest)
 33.1511 +{
 33.1512 +  arrow_coords_save_dest = dest;
 33.1513 +}
 33.1514 +
 33.1515 +MapStorage::SpecMapSaveOpts::MapNum MapStorage::getNodeCoordsSaveMapNum()
 33.1516 +{
 33.1517 +  return node_coords_save_map_num;
 33.1518 +}
 33.1519 +
 33.1520 +MapStorage::SpecMapSaveOpts::MapNum MapStorage::getArrowCoordsSaveMapNum()
 33.1521 +{
 33.1522 +  return arrow_coords_save_map_num;
 33.1523 +}
 33.1524 +
 33.1525 +void MapStorage::setNodeCoordsSaveMapNum(MapStorage::SpecMapSaveOpts::MapNum num)
 33.1526 +{
 33.1527 +  node_coords_save_map_num = num;
 33.1528 +}
 33.1529 +
 33.1530 +void MapStorage::setArrowCoordsSaveMapNum(MapStorage::SpecMapSaveOpts::MapNum num)
 33.1531 +{
 33.1532 +  arrow_coords_save_map_num = num;
 33.1533 +}
 33.1534 +
 33.1535 +const std::string& MapStorage::getNodeCoordsOneMapName()
 33.1536 +{
 33.1537 +  return node_coords_one_map_name;
 33.1538 +}
 33.1539 +const std::string& MapStorage::getNodeCoordsTwoMaps1Name()
 33.1540 +{
 33.1541 +  return node_coords_two_maps_1_name;
 33.1542 +}
 33.1543 +const std::string& MapStorage::getNodeCoordsTwoMaps2Name()
 33.1544 +{
 33.1545 +  return node_coords_two_maps_2_name;
 33.1546 +}
 33.1547 +
 33.1548 +void MapStorage::setNodeCoordsOneMapName(const std::string& name)
 33.1549 +{
 33.1550 +  node_coords_one_map_name = name;
 33.1551 +}
 33.1552 +void MapStorage::setNodeCoordsTwoMaps1Name(const std::string& name)
 33.1553 +{
 33.1554 +  node_coords_two_maps_1_name = name;
 33.1555 +}
 33.1556 +void MapStorage::setNodeCoordsTwoMaps2Name(const std::string& name)
 33.1557 +{
 33.1558 +  node_coords_two_maps_2_name = name;
 33.1559 +}
 33.1560 +
 33.1561 +const std::string& MapStorage::getArrowCoordsOneMapName()
 33.1562 +{
 33.1563 +  return arrow_coords_one_map_name;
 33.1564 +}
 33.1565 +const std::string& MapStorage::getArrowCoordsTwoMaps1Name()
 33.1566 +{
 33.1567 +  return arrow_coords_two_maps_1_name;
 33.1568 +}
 33.1569 +const std::string& MapStorage::getArrowCoordsTwoMaps2Name()
 33.1570 +{
 33.1571 +  return arrow_coords_two_maps_2_name;
 33.1572 +}
 33.1573 +
 33.1574 +void MapStorage::setArrowCoordsOneMapName(const std::string& name)
 33.1575 +{
 33.1576 +  arrow_coords_one_map_name = name;
 33.1577 +}
 33.1578 +void MapStorage::setArrowCoordsTwoMaps1Name(const std::string& name)
 33.1579 +{
 33.1580 +  arrow_coords_two_maps_1_name = name;
 33.1581 +}
 33.1582 +void MapStorage::setArrowCoordsTwoMaps2Name(const std::string& name)
 33.1583 +{
 33.1584 +  arrow_coords_two_maps_2_name = name;
 33.1585 +}
 33.1586 +
 33.1587 +void MapStorage::readLGF(
 33.1588 +    const std::string& filename,
 33.1589 +    bool read_edge_label,
 33.1590 +    const std::vector<std::string>& node_map_names,
 33.1591 +    const std::vector<std::string>& edge_map_names,
 33.1592 +    const std::map<std::string, MapValue::Type>& node_map_types,
 33.1593 +    const std::map<std::string, MapValue::Type>& edge_map_types,
 33.1594 +    const std::string& node_coord_xmap_name,
 33.1595 +    const std::string& node_coord_ymap_name,
 33.1596 +    const std::string& arrow_coord_xmap_name,
 33.1597 +    const std::string& arrow_coord_ymap_name)
 33.1598 +{
 33.1599 +  using std::vector;
 33.1600 +  using std::map;
 33.1601 +  using std::string;
 33.1602 +
 33.1603 +  GraphReader<Graph> greader(filename, graph);
 33.1604 +
 33.1605 +  // read the label maps
 33.1606 +  greader.readNodeMap("label", node_label);
 33.1607 +  if (read_edge_label)
 33.1608 +    greader.readEdgeMap("label", edge_label);
 33.1609 +
 33.1610 +  // read the node maps
 33.1611 +  for (vector<string>::const_iterator
 33.1612 +      it = node_map_names.begin();
 33.1613 +      it != node_map_names.end(); ++it)
 33.1614 +  {
 33.1615 +    switch (node_map_types.find(*it)->second)
 33.1616 +    {
 33.1617 +      case MapValue::NUMERIC:
 33.1618 +        {
 33.1619 +          createNodeMap(*it, MapValue::NUMERIC, double());
 33.1620 +          greader.readNodeMap(*it, getNumericNodeMap(*it));
 33.1621 +          break;
 33.1622 +        }
 33.1623 +      case MapValue::STRING:
 33.1624 +        {
 33.1625 +          createNodeMap(*it, MapValue::STRING, string());
 33.1626 +          greader.readNodeMap(*it, getStringNodeMap(*it));
 33.1627 +          break;
 33.1628 +        }
 33.1629 +    }
 33.1630 +    getNodeMapData(*it)->save_dest = NESET_SECT;
 33.1631 +  }
 33.1632 +
 33.1633 +  // read the edge maps
 33.1634 +  for (vector<string>::const_iterator
 33.1635 +      it = edge_map_names.begin();
 33.1636 +      it != edge_map_names.end(); ++it)
 33.1637 +  {
 33.1638 +    switch (edge_map_types.find(*it)->second)
 33.1639 +    {
 33.1640 +      case MapValue::NUMERIC:
 33.1641 +        {
 33.1642 +          createEdgeMap(*it, MapValue::NUMERIC, double());
 33.1643 +          greader.readEdgeMap(*it, getNumericEdgeMap(*it));
 33.1644 +          break;
 33.1645 +        }
 33.1646 +      case MapValue::STRING:
 33.1647 +        {
 33.1648 +          createEdgeMap(*it, MapValue::STRING, string());
 33.1649 +          greader.readEdgeMap(*it, getStringEdgeMap(*it));
 33.1650 +          break;
 33.1651 +        }
 33.1652 +    }
 33.1653 +    getEdgeMapData(*it)->save_dest = NESET_SECT;
 33.1654 +  }
 33.1655 +
 33.1656 +  // read the node coordinate maps
 33.1657 +  if (node_coord_xmap_name != "")
 33.1658 +    greader.readNodeMap(node_coord_xmap_name, node_coords_x);
 33.1659 +  if (node_coord_ymap_name != "")
 33.1660 +    greader.readNodeMap(node_coord_ymap_name, node_coords_y);
 33.1661 +
 33.1662 +  // read the arrow coordinate maps
 33.1663 +  if (arrow_coord_xmap_name != "")
 33.1664 +    greader.readEdgeMap(arrow_coord_xmap_name, arrow_coords_x);
 33.1665 +  if (arrow_coord_ymap_name != "")
 33.1666 +    greader.readEdgeMap(arrow_coord_ymap_name, arrow_coords_y);
 33.1667 +
 33.1668 +  greader.run();
 33.1669 +}
 33.1670 +
 33.1671  void MapStorage::setBackground(const std::string& file_name)
 33.1672  {
 33.1673    if (file_name == background_file_name) return;
 33.1674 @@ -610,13 +1472,13 @@
 33.1675      {
 33.1676        if(active_nodemaps[N_RADIUS]!="")
 33.1677  	{
 33.1678 -	  _nodeSizes=*(nodemap_storage[active_nodemaps[N_RADIUS]]);
 33.1679 +	  _nodeSizes=getNumericNodeMap(active_nodemaps[N_RADIUS]);
 33.1680  	}
 33.1681        if(active_nodemaps[N_COLOR]!="")
 33.1682  	{
 33.1683  	  for(NodeIt ni(graph);ni!=INVALID;++ni)
 33.1684  	    {
 33.1685 -	      _nodeColors[ni]=(int)((*(nodemap_storage[active_nodemaps[N_COLOR]]))[ni]);
 33.1686 +	      _nodeColors[ni]=(int)get(active_nodemaps[N_COLOR], ni);
 33.1687  	    }
 33.1688  	}
 33.1689        if(active_nodemaps[N_TEXT]!="")
 33.1690 @@ -624,7 +1486,7 @@
 33.1691  	  for(NodeIt ni(graph);ni!=INVALID;++ni)
 33.1692  	    {
 33.1693  	      std::ostringstream o;
 33.1694 -	      o << ((*(nodemap_storage[active_nodemaps[N_TEXT]]))[ni]);
 33.1695 +	      o << get(active_nodemaps[N_TEXT], ni);
 33.1696  	      _nodeTextMap[ni]=o.str();	      
 33.1697  	    }
 33.1698  	}
 33.1699 @@ -633,21 +1495,33 @@
 33.1700      {
 33.1701        if(active_edgemaps[E_WIDTH]!="")
 33.1702  	{
 33.1703 -	  _edgeWidths=*(edgemap_storage[active_edgemaps[E_WIDTH]]);
 33.1704 +	  _edgeWidths=getNumericEdgeMap(active_edgemaps[E_WIDTH]);
 33.1705  	}
 33.1706        if(active_edgemaps[E_COLOR]!="")
 33.1707  	{
 33.1708  	  for(EdgeIt ei(graph);ei!=INVALID;++ei)
 33.1709  	    {
 33.1710 -	      _edgeColors[ei]=(int)((*(edgemap_storage[active_edgemaps[E_COLOR]]))[ei]);
 33.1711 +	      _edgeColors[ei]=(int)get(active_edgemaps[E_COLOR], ei);
 33.1712  	    }
 33.1713  	}
 33.1714      }
 33.1715    if(shapemap!="Default values")
 33.1716      {
 33.1717 -      if((minOfNodeMap(shapemap)>=0)&&(maxOfNodeMap(shapemap)<=4))
 33.1718 +      double min = std::numeric_limits<double>::max();
 33.1719 +      double max = std::numeric_limits<double>::min();
 33.1720 +      for (NodeIt n(graph); n != INVALID; ++n)
 33.1721 +      {
 33.1722 +        double v = static_cast<double>(get(shapemap, n));
 33.1723 +        if (v < min) min = v;
 33.1724 +        if (v > max) max = v;
 33.1725 +      }
 33.1726 +      if((min>=0)&&(max<=4))
 33.1727  	{
 33.1728 -	  _shapes=*(nodemap_storage[shapemap]);
 33.1729 +          NumericNodeMap& map = static_cast<NumericNodeMapData*>(getNodeMapData(shapemap))->map;
 33.1730 +          for (NodeIt n(graph); n != INVALID; ++n)
 33.1731 +          {
 33.1732 +            _shapes[n] = static_cast<int>(map[n]);
 33.1733 +          }
 33.1734  	}
 33.1735      }
 33.1736  
 33.1737 @@ -659,7 +1533,7 @@
 33.1738      copyright("(C) 2006 LEMON Project").
 33.1739      absoluteNodeSizes().absoluteEdgeWidths().
 33.1740      nodeScale(2).nodeSizes(_nodeSizes).
 33.1741 -    coords(coords).
 33.1742 +    coords(node_coords).
 33.1743      nodeShapes(_shapes).
 33.1744      nodeColors(composeMap(paletteW,_nodeColors)).
 33.1745      edgeColors(composeMap(palette,_edgeColors)).
    34.1 --- a/mapstorage.h	Wed May 02 20:33:58 2007 +0000
    34.2 +++ b/mapstorage.h	Wed Jan 02 21:03:09 2008 +0000
    34.3 @@ -19,9 +19,16 @@
    34.4  #ifndef MAPSTORAGE_H
    34.5  #define MAPSTORAGE_H
    34.6  
    34.7 -#include <all_include.h>
    34.8 -#include <xymap.h>
    34.9 +class Mapstorage;
   34.10 +
   34.11 +#include <vector>
   34.12 +#include <map>
   34.13 +#include <string>
   34.14 +#include "all_include.h"
   34.15 +#include "xymap.h"
   34.16  #include <libgnomecanvasmm.h>
   34.17 +#include "map_value.h"
   34.18 +#include "map_value_map.h"
   34.19  
   34.20  ///class MapStorage handles NodeMaps and EdgeMaps.
   34.21  
   34.22 @@ -41,17 +48,218 @@
   34.23    bool background_set;
   34.24    double background_scaling;
   34.25  public:
   34.26 +  class Error : public std::exception
   34.27 +  {
   34.28 +    private:
   34.29 +      std::string message;
   34.30 +    public:
   34.31 +      Error(const std::string& msg) : message(msg) {}
   34.32 +      virtual const char* what() const throw()
   34.33 +      {
   34.34 +        return message.c_str();
   34.35 +      }
   34.36 +      ~Error() throw() {}
   34.37 +  };
   34.38 +
   34.39    void setBackground(const std::string& file_name);
   34.40    const std::string& getBackgroundFilename();
   34.41    bool isBackgroundSet();
   34.42    double getBackgroundScaling();
   34.43    void setBackgroundScaling(double scaling);
   34.44 +
   34.45 +  enum MapSaveDest { GUI_SECT, NESET_SECT, DONT_SAVE };
   34.46 +  enum GuiSectSaveDest { LGF_FILE, CONF_FILE };
   34.47 +  struct SpecMapSaveOpts
   34.48 +  {
   34.49 +    enum Dest { GUI_SECT, NESET_SECT };
   34.50 +    enum MapNum { ONE_MAP, TWO_MAPS };
   34.51 +  };
   34.52 +
   34.53 +  typedef Graph::NodeMap<double> NumericNodeMap;
   34.54 +  typedef Graph::NodeMap<std::string> StringNodeMap;
   34.55 +  typedef Graph::EdgeMap<double> NumericEdgeMap;
   34.56 +  typedef Graph::EdgeMap<std::string> StringEdgeMap;
   34.57 +  typedef Graph::NodeMap<int> NodeLabelMap;
   34.58 +  typedef Graph::EdgeMap<int> EdgeLabelMap;
   34.59 +  typedef XYMap<Graph::NodeMap<double> > NodeCoordMap;
   34.60 +  typedef XYMap<Graph::EdgeMap<double> > ArrowCoordMap;
   34.61 +
   34.62 +  struct EdgeMapData
   34.63 +  {
   34.64 +    /// where to save the map
   34.65 +    MapSaveDest save_dest;
   34.66 +    /// read-only or read-write
   34.67 +    bool writeable;
   34.68 +    /// default value
   34.69 +    MapValue default_value;
   34.70 +    virtual MapValue::Type type() = 0;
   34.71 +    virtual MapValue get(Edge e) = 0;
   34.72 +    virtual void set(Edge e, MapValue v) = 0;
   34.73 +    EdgeMapData(MapValue def_val) :
   34.74 +      save_dest(GUI_SECT),
   34.75 +      writeable(true),
   34.76 +      default_value(def_val)
   34.77 +    {}
   34.78 +  };
   34.79 +
   34.80 +  struct NumericEdgeMapData : public EdgeMapData
   34.81 +  {
   34.82 +    NumericEdgeMap map;
   34.83 +    MapValue::Type type() { return MapValue::NUMERIC; }
   34.84 +    MapValue get(Edge e) { return MapValue(map[e]); }
   34.85 +    void set(Edge e, MapValue v) { map.set(e, static_cast<double>(v)); }
   34.86 +    NumericEdgeMapData(Graph& g, double def_val) :
   34.87 +      EdgeMapData(MapValue(def_val)),
   34.88 +      map(g, def_val)
   34.89 +    {}
   34.90 +  };
   34.91 +
   34.92 +  struct StringEdgeMapData : public EdgeMapData
   34.93 +  {
   34.94 +    StringEdgeMap map;
   34.95 +    MapValue::Type type() { return MapValue::STRING; }
   34.96 +    MapValue get(Edge e) { return MapValue(map[e]); }
   34.97 +    void set(Edge e, MapValue v) { map.set(e, static_cast<std::string>(v)); }
   34.98 +    StringEdgeMapData(Graph& g, std::string def_val) :
   34.99 +      EdgeMapData(MapValue(def_val)),
  34.100 +      map(g, def_val)
  34.101 +    {}
  34.102 +  };
  34.103 +
  34.104 +  struct NodeMapData
  34.105 +  {
  34.106 +    /// where to save the map
  34.107 +    MapSaveDest save_dest;
  34.108 +    /// read-only or read-write
  34.109 +    bool writeable;
  34.110 +    /// default value
  34.111 +    MapValue default_value;
  34.112 +    virtual MapValue::Type type() = 0;
  34.113 +    virtual MapValue get(Node e) = 0;
  34.114 +    virtual void set(Node e, MapValue v) = 0;
  34.115 +    NodeMapData(MapValue def_val) :
  34.116 +      save_dest(GUI_SECT),
  34.117 +      writeable(true),
  34.118 +      default_value(def_val)
  34.119 +    {}
  34.120 +  };
  34.121 +
  34.122 +  struct NumericNodeMapData : public NodeMapData
  34.123 +  {
  34.124 +    NumericNodeMap map;
  34.125 +    MapValue::Type type() { return MapValue::NUMERIC; }
  34.126 +    MapValue get(Node e) { return MapValue(map[e]); }
  34.127 +    void set(Node e, MapValue v) { map.set(e, static_cast<double>(v)); }
  34.128 +    NumericNodeMapData(Graph& g, double def_val) :
  34.129 +      NodeMapData(MapValue(def_val)),
  34.130 +      map(g, def_val)
  34.131 +    {}
  34.132 +  };
  34.133 +
  34.134 +  struct StringNodeMapData : public NodeMapData
  34.135 +  {
  34.136 +    StringNodeMap map;
  34.137 +    MapValue::Type type() { return MapValue::STRING; }
  34.138 +    MapValue get(Node e) { return MapValue(map[e]); }
  34.139 +    void set(Node e, MapValue v) { map.set(e, static_cast<std::string>(v)); }
  34.140 +    StringNodeMapData(Graph& g, std::string def_val) :
  34.141 +      NodeMapData(MapValue(def_val)),
  34.142 +      map(g, def_val)
  34.143 +    {}
  34.144 +  };
  34.145 +
  34.146 +  typedef std::map<std::string, NodeMapData*> NodeMapStore;
  34.147 +  typedef std::map<std::string, EdgeMapData*> EdgeMapStore;
  34.148 +
  34.149 +  struct GUISectData
  34.150 +  {
  34.151 +    std::vector<std::string> main_node_map_names;
  34.152 +    std::vector<std::string> main_edge_map_names;
  34.153 +
  34.154 +    std::vector<std::string> gui_node_map_names;
  34.155 +    std::vector<std::string> gui_edge_map_names;
  34.156 +
  34.157 +    std::map<std::string, MapValue::Type> node_map_types;
  34.158 +    std::map<std::string, MapValue::Type> edge_map_types;
  34.159 +
  34.160 +    std::map<std::string, std::map<int, double>* > numeric_node_maps;
  34.161 +    std::map<std::string, std::map<int, std::string>* > string_node_maps;
  34.162 +
  34.163 +    std::map<std::string, std::map<int, double>* > numeric_edge_maps;
  34.164 +    std::map<std::string, std::map<int, std::string>* > string_edge_maps;
  34.165 +
  34.166 +    std::map<int, XY> node_coord_map;
  34.167 +    std::map<int, XY> arrow_coord_map;
  34.168 +
  34.169 +    SpecMapSaveOpts::Dest node_coords_save_dest;
  34.170 +    SpecMapSaveOpts::MapNum node_coords_save_map_num;
  34.171 +    std::string node_coords_one_map_name;
  34.172 +    std::string node_coords_two_maps_1_name;
  34.173 +    std::string node_coords_two_maps_2_name;
  34.174 +
  34.175 +    SpecMapSaveOpts::Dest arrow_coords_save_dest;
  34.176 +    SpecMapSaveOpts::MapNum arrow_coords_save_map_num;
  34.177 +    std::string arrow_coords_one_map_name;
  34.178 +    std::string arrow_coords_two_maps_1_name;
  34.179 +    std::string arrow_coords_two_maps_2_name;
  34.180 +
  34.181 +    ~GUISectData()
  34.182 +    {
  34.183 +      using std::map;
  34.184 +      using std::vector;
  34.185 +      using std::pair;
  34.186 +      using std::string;
  34.187 +
  34.188 +      for (map<string, map<int, double>* >::iterator it =
  34.189 +          numeric_node_maps.begin(); it != numeric_node_maps.end(); ++it)
  34.190 +      {
  34.191 +        delete it->second;
  34.192 +      }
  34.193 +      for (map<string, map<int, string>* >::iterator it =
  34.194 +          string_node_maps.begin(); it != string_node_maps.end(); ++it)
  34.195 +      {
  34.196 +        delete it->second;
  34.197 +      }
  34.198 +      for (map<string, map<int, double>* >::iterator it =
  34.199 +          numeric_edge_maps.begin(); it != numeric_edge_maps.end(); ++it)
  34.200 +      {
  34.201 +        delete it->second;
  34.202 +      }
  34.203 +      for (map<string, map<int, string>* >::iterator it =
  34.204 +          string_edge_maps.begin(); it != string_edge_maps.end(); ++it)
  34.205 +      {
  34.206 +        delete it->second;
  34.207 +      }
  34.208 +    }
  34.209 +  };
  34.210 +public:
  34.211    ///The graph for which the datas are stored.
  34.212    Graph graph;
  34.213 +  const Graph& getGraph();
  34.214 +
  34.215 +private:
  34.216 +  GuiSectSaveDest gui_sect_save_dest;
  34.217 +
  34.218 +  SpecMapSaveOpts::Dest node_coords_save_dest;
  34.219 +  SpecMapSaveOpts::MapNum node_coords_save_map_num;
  34.220 +  SpecMapSaveOpts::Dest arrow_coords_save_dest;
  34.221 +  SpecMapSaveOpts::MapNum arrow_coords_save_map_num;
  34.222 +
  34.223 +  NodeMapStore nodemaps;
  34.224 +  EdgeMapStore edgemaps;
  34.225 +
  34.226 +  NodeLabelMap node_label;
  34.227 +  EdgeLabelMap edge_label;
  34.228 +
  34.229    /// the coordinates of the nodes
  34.230 -  XYMap<Graph::NodeMap<double> > coords;
  34.231 +  NodeCoordMap node_coords;
  34.232 +  Graph::NodeMap<double> node_coords_x;
  34.233 +  Graph::NodeMap<double> node_coords_y;
  34.234 +
  34.235    /// the coordinates of the arrows on the edges
  34.236 -  XYMap<Graph::EdgeMap<double> > arrow_pos;
  34.237 +  ArrowCoordMap arrow_coords;
  34.238 +  Graph::EdgeMap<double> arrow_coords_x;
  34.239 +  Graph::EdgeMap<double> arrow_coords_y;
  34.240  
  34.241    ///The content of the object has changed, update is needed.
  34.242    bool modified;
  34.243 @@ -59,12 +267,21 @@
  34.244    ///Name of file loaded in object.
  34.245    std::string file_name;
  34.246  
  34.247 -  ///Stores double type NodeMaps
  34.248 -  std::map< std::string,Graph::NodeMap<double> * > nodemap_storage;
  34.249 +  // the largest node label
  34.250 +  int max_node_label;
  34.251  
  34.252 -  ///Stores double type EdgeMaps
  34.253 -  std::map< std::string,Graph::EdgeMap<double> * > edgemap_storage;
  34.254 +  // the largest edge label
  34.255 +  int max_edge_label;
  34.256  
  34.257 +  std::string node_coords_one_map_name;
  34.258 +  std::string node_coords_two_maps_1_name;
  34.259 +  std::string node_coords_two_maps_2_name;
  34.260 +
  34.261 +  std::string arrow_coords_one_map_name;
  34.262 +  std::string arrow_coords_two_maps_1_name;
  34.263 +  std::string arrow_coords_two_maps_2_name;
  34.264 +
  34.265 +public:
  34.266    ///Stores the default values for the different visualization node attributes
  34.267    std::vector<Graph::NodeMap<double> > default_nodemaps;
  34.268  
  34.269 @@ -77,14 +294,6 @@
  34.270    /// Stores the active maps for the different visualization edge attributes
  34.271    std::vector< std::string > active_edgemaps;
  34.272  
  34.273 -  /// Default values for the maps
  34.274 -  std::map< std::string, double > nodemap_default;
  34.275 -
  34.276 -  /// Default values for the maps
  34.277 -  std::map< std::string, double > edgemap_default;
  34.278 -
  34.279 -  bool arrow_pos_read_ok;
  34.280 -
  34.281  protected:
  34.282  
  34.283    /// Signal emitted on any change made on map values
  34.284 @@ -98,13 +307,13 @@
  34.285  
  34.286    /// std::string is the
  34.287    ///name of the new map
  34.288 -  sigc::signal<void, std::string> signal_node_map;
  34.289 +  sigc::signal<void, std::string, MapValue::Type> signal_node_map;
  34.290  
  34.291    /// Signal emitted in the case of edgemap addition
  34.292  
  34.293    /// std::string is the
  34.294    ///name of the new map
  34.295 -  sigc::signal<void, std::string> signal_edge_map;
  34.296 +  sigc::signal<void, std::string, MapValue::Type> signal_edge_map;
  34.297  
  34.298    /// Signal emitted, when entry in \ref MapWin should be changed.
  34.299    sigc::signal<void, bool, int, std::string> signal_map_win;
  34.300 @@ -164,19 +373,19 @@
  34.301    std::string getActiveNodeMap(int prop);
  34.302  
  34.303    /// Returns the names of the edgemaps stored here.
  34.304 -  std::vector<std::string> getEdgeMapList();
  34.305 +  std::vector<std::string> getEdgeMapList(MapType type = ALL);
  34.306  
  34.307    /// Returns the names of the nodemaps stored here.
  34.308 -  std::vector<std::string> getNodeMapList();
  34.309 +  std::vector<std::string> getNodeMapList(MapType type = ALL);
  34.310  
  34.311    ///returns \ref signal_prop to be able to connect functions to it
  34.312    sigc::signal<void, bool, int> signal_prop_ch();
  34.313  
  34.314    ///returns \ref signal_node_map to be able to connect functions to it
  34.315 -  sigc::signal<void, std::string> signal_node_map_ch(){return signal_node_map;};
  34.316 +  sigc::signal<void, std::string, MapValue::Type> signal_node_map_ch(){return signal_node_map;};
  34.317  
  34.318    ///returns \ref signal_edge_map to be able to connect functions to it
  34.319 -  sigc::signal<void, std::string> signal_edge_map_ch(){return signal_edge_map;};
  34.320 +  sigc::signal<void, std::string, MapValue::Type> signal_edge_map_ch(){return signal_edge_map;};
  34.321  
  34.322    ///returns \ref signal_map_win to be able to connect functions to it
  34.323    sigc::signal<void, bool, int, std::string> signal_map_win_ch(){return signal_map_win;};
  34.324 @@ -184,87 +393,17 @@
  34.325    ///returns \ref signal_design_win to be able to connect functions to it
  34.326    sigc::signal<void, double, double, int> signal_design_win_ch(){return signal_design_win;};
  34.327  
  34.328 +  void createNodeMap(const std::string& name, MapValue::Type type,
  34.329 +    MapValue def_val);
  34.330 +  void createEdgeMap(const std::string& name, MapValue::Type type,
  34.331 +    MapValue def_val);
  34.332 +
  34.333    ///returns \ref signal_background to be able to connect functions to it
  34.334    sigc::signal<void> signal_background_ch(){return signal_background;};
  34.335  
  34.336  
  34.337    ///Adds given map to storage.
  34.338  
  34.339 -  ///A name and the map itself has to be provided.
  34.340 -  ///\param mapname is the name of map
  34.341 -  ///\param nodemap is the pointer of the given nodemap
  34.342 -  ///\param def the default value of the map. If not given, it will be 0.
  34.343 -  ///If new edge is added to graph the value of it in the map will be this.
  34.344 -  ///\todo map should be given by reference!
  34.345 -  ///\todo why is default value stored?
  34.346 -  int addNodeMap(const std::string & mapname,Graph::NodeMap<double> * nodemap, double def=0.0);
  34.347 -
  34.348 -  ///Adds given map to storage. A name and the map itself has to be provided.
  34.349 -
  34.350 -  ///A name and the map itself has to be provided.
  34.351 -  ///\param mapname is the name of map
  34.352 -  ///\param edgemap is the pointer of the given edgemap
  34.353 -  ///\param def the default value of the map. If not given, it will be 0.
  34.354 -  ///If new edge is added to graph the value of it in the map will be this.
  34.355 -  ///\todo map should be given by reference!
  34.356 -  int addEdgeMap(const std::string & mapname,Graph::EdgeMap<double> * edgemap, double def=0.0);
  34.357 -
  34.358 -  ///Returns how much nodemaps is stored in \ref MapStorage
  34.359 -  int numOfNodeMaps() {return nodemap_storage.size();};
  34.360 -
  34.361 -  ///Returns how much edgemaps is stored in \ref MapStorage
  34.362 -  int numOfEdgeMaps() {return edgemap_storage.size();};
  34.363 -
  34.364 -  ///Returns the maximum value of the given NodeMap.
  34.365 -
  34.366 -  ///NodeMap has to be given by its name.
  34.367 -  ///\param name the name of map of which maximum is searched
  34.368 -  double maxOfNodeMap(const std::string & name);
  34.369 -
  34.370 -  ///Returns the maximum value of the given EdgeMap.
  34.371 -
  34.372 -  ///EdgeMap has to be given by its name.
  34.373 -  ///\param name the name of map of which maximum is searched
  34.374 -  double maxOfEdgeMap(const std::string & name);
  34.375 -
  34.376 -  ///Returns the minimum value of the given NodeMap.
  34.377 -
  34.378 -  ///NodeMap has to be given by its name.
  34.379 -  ///\param name the name of map of which minimum is searched
  34.380 -  double minOfNodeMap(const std::string & name);
  34.381 -
  34.382 -  ///Returns the minimum value of the given EdgeMap.
  34.383 -
  34.384 -  ///EdgeMap has to be given by its name.
  34.385 -  ///\param name the name of map of which minimum is searched
  34.386 -  double minOfEdgeMap(const std::string & name);
  34.387 -
  34.388 -  ///Returns iterator pointing to the first NodeMap in storage.
  34.389 -
  34.390 -  ///To be able to iterate through each maps this function
  34.391 -  ///returns an iterator pointing to the first nodemap in
  34.392 -  ///the storage.
  34.393 -  std::map< std::string,Graph::NodeMap<double> * >::iterator beginOfNodeMaps(){return nodemap_storage.begin();};
  34.394 -
  34.395 -  ///Returns iterator pointing to the first EdgeMap in storage.
  34.396 -
  34.397 -  ///To be able to iterate through each maps this function
  34.398 -  ///returns an iterator pointing to the first edgemap in
  34.399 -  ///the storage.
  34.400 -  std::map< std::string,Graph::EdgeMap<double> * >::iterator beginOfEdgeMaps(){return edgemap_storage.begin();};
  34.401 -
  34.402 -  ///Returns iterator pointing after the last NodeMap in storage.
  34.403 -
  34.404 -  ///To be able to iterate through each maps this function
  34.405 -  ///returns an iterator pointing to the last nodemap in the storage.
  34.406 -  std::map< std::string,Graph::NodeMap<double> * >::iterator endOfNodeMaps(){return nodemap_storage.end();};
  34.407 -
  34.408 -  ///Returns iterator pointing after the last EdgeMap in storage.
  34.409 -
  34.410 -  ///To be able to iterate through each maps this function
  34.411 -  ///returns an iterator pointing to the last edgemap in the storage.
  34.412 -  std::map< std::string,Graph::EdgeMap<double> * >::iterator endOfEdgeMaps(){return edgemap_storage.end();};
  34.413 -
  34.414    ///Emits \ref signal_prop if mapvalues have changed, and MapStorage gets to know it.
  34.415  
  34.416    ///If values in a map have changed, this function checks, whether it is displayed.
  34.417 @@ -285,8 +424,6 @@
  34.418    ///Deletes all datastructures stored here.
  34.419    void clear();
  34.420  
  34.421 -  void ArrowPosReadOK();
  34.422 -
  34.423    void get_design_data(double &, double &, int &);
  34.424    void set_attraction(double);
  34.425    void set_propulsation(double);
  34.426 @@ -294,6 +431,99 @@
  34.427  
  34.428    void redesign_data_changed();
  34.429  
  34.430 +  XY getNodeCoords(Node n) const;
  34.431 +  void setNodeCoords(Node n, XY c);
  34.432 +  XY getArrowCoords(Edge e) const;
  34.433 +  void setArrowCoords(Edge e, XY c);
  34.434 +
  34.435 +  MapValue get(const std::string& name, Node node) const;
  34.436 +  void set(const std::string& name, Node node, MapValue val);
  34.437 +  MapValue get(const std::string& name, Edge edge) const;
  34.438 +  void set(const std::string& name, Edge edge, MapValue val);
  34.439 +
  34.440 +  const std::string& getFileName() const;
  34.441 +  void setFileName(const std::string& fn);
  34.442 +
  34.443 +  bool getModified() const;
  34.444 +  void setModified(bool m = true);
  34.445 +
  34.446 +  Node addNode(XY);
  34.447 +  Edge addEdge(Node, Node);
  34.448 +
  34.449 +  NumericNodeMap& getNumericNodeMap(const std::string& name);
  34.450 +  StringNodeMap& getStringNodeMap(const std::string& name);
  34.451 +  NumericEdgeMap& getNumericEdgeMap(const std::string& name);
  34.452 +  StringEdgeMap& getStringEdgeMap(const std::string& name);
  34.453 +
  34.454 +  MapValueEdgeMap getEdgeMap(const std::string& name);
  34.455 +  MapValueNodeMap getNodeMap(const std::string& name);
  34.456 +
  34.457 +  int getLabel(Node) const;
  34.458 +  int getLabel(Edge) const;
  34.459 +
  34.460 +  GuiSectSaveDest getGUIDataSaveLocation();
  34.461 +  void setGUIDataSaveLocation(GuiSectSaveDest dest);
  34.462 +
  34.463 +  MapSaveDest getNodeMapSaveDest(std::string name) const;
  34.464 +  MapSaveDest getEdgeMapSaveDest(std::string name) const;
  34.465 +  void setNodeMapSaveDest(std::string name, MapSaveDest dest);
  34.466 +  void setEdgeMapSaveDest(std::string name, MapSaveDest dest);
  34.467 +
  34.468 +  SpecMapSaveOpts::Dest getNodeCoordsSaveDest();
  34.469 +  SpecMapSaveOpts::Dest getArrowCoordsSaveDest();
  34.470 +  void setNodeCoordsSaveDest(SpecMapSaveOpts::Dest dest);
  34.471 +  void setArrowCoordsSaveDest(SpecMapSaveOpts::Dest dest);
  34.472 +
  34.473 +  SpecMapSaveOpts::MapNum getNodeCoordsSaveMapNum();
  34.474 +  SpecMapSaveOpts::MapNum getArrowCoordsSaveMapNum();
  34.475 +  void setNodeCoordsSaveMapNum(SpecMapSaveOpts::MapNum num);
  34.476 +  void setArrowCoordsSaveMapNum(SpecMapSaveOpts::MapNum num);
  34.477 +
  34.478 +  MapValue::Type getNodeMapElementType(std::string name) const;
  34.479 +  MapValue::Type getEdgeMapElementType(std::string name) const;
  34.480 +
  34.481 +  const NodeLabelMap& getNodeLabelMap();
  34.482 +  const EdgeLabelMap& getEdgeLabelMap();
  34.483 +
  34.484 +  bool nodeMapExists(std::string name);
  34.485 +  bool edgeMapExists(std::string name);
  34.486 +
  34.487 +  std::vector<std::string> getEdgeMaps(MapType type = ALL);
  34.488 +  std::vector<std::string> getNodeMaps(MapType type = ALL);
  34.489 +
  34.490 +  NodeCoordMap& getNodeCoordMap();
  34.491 +  ArrowCoordMap& getArrowCoordMap();
  34.492 +
  34.493 +  const std::string& getNodeCoordsOneMapName();
  34.494 +  const std::string& getNodeCoordsTwoMaps1Name();
  34.495 +  const std::string& getNodeCoordsTwoMaps2Name();
  34.496 +  void setNodeCoordsOneMapName(const std::string& name);
  34.497 +  void setNodeCoordsTwoMaps1Name(const std::string& name);
  34.498 +  void setNodeCoordsTwoMaps2Name(const std::string& name);
  34.499 +
  34.500 +  const std::string& getArrowCoordsOneMapName();
  34.501 +  const std::string& getArrowCoordsTwoMaps1Name();
  34.502 +  const std::string& getArrowCoordsTwoMaps2Name();
  34.503 +  void setArrowCoordsOneMapName(const std::string& name);
  34.504 +  void setArrowCoordsTwoMaps1Name(const std::string& name);
  34.505 +  void setArrowCoordsTwoMaps2Name(const std::string& name);
  34.506 +
  34.507 +private:
  34.508 +  EdgeMapData* getEdgeMapData(std::string name) const;
  34.509 +  NodeMapData* getNodeMapData(std::string name) const;
  34.510 +  void readLGF(
  34.511 +      const std::string& filename,
  34.512 +      bool read_edge_label,
  34.513 +      const std::vector<std::string>& node_map_names,
  34.514 +      const std::vector<std::string>& edge_map_names,
  34.515 +      const std::map<std::string, MapValue::Type>& node_map_types,
  34.516 +      const std::map<std::string, MapValue::Type>& edge_map_types,
  34.517 +      const std::string& node_coord_xmap_name,
  34.518 +      const std::string& node_coord_ymap_name,
  34.519 +      const std::string& arrow_coord_xmap_name,
  34.520 +      const std::string& arrow_coord_ymap_name);
  34.521 +
  34.522 +public:
  34.523    void exportGraphToEPS(std::vector<bool>, std::string, std::string);
  34.524  };
  34.525  
    35.1 --- a/nbtab.cc	Wed May 02 20:33:58 2007 +0000
    35.2 +++ b/nbtab.cc	Wed Jan 02 21:03:09 2008 +0000
    35.3 @@ -30,6 +30,7 @@
    35.4    mapstorage=new MapStorage();
    35.5  
    35.6    Gtk::ScrolledWindow *pScrolledWindow = manage(new Gtk::ScrolledWindow);
    35.7 +  pScrolledWindow->set_shadow_type(Gtk::SHADOW_ETCHED_IN);
    35.8    gd_canvas=new GraphDisplayerCanvas(*this);
    35.9    pScrolledWindow->add(*gd_canvas);
   35.10    add(*pScrolledWindow);
   35.11 @@ -46,19 +47,23 @@
   35.12  void NoteBookTab::readFile(const std::string &file)
   35.13  {
   35.14    mapstorage->readFromFile(file);
   35.15 -  mapstorage->file_name = file;
   35.16 -  mapstorage->modified = false;
   35.17 +  mapstorage->setFileName(file);
   35.18 +  mapstorage->setModified(false);
   35.19    gd_canvas->drawGraph();
   35.20    if(mapwinexists)
   35.21      {
   35.22 -      mapwin->update(mapstorage->getEdgeMapList(), mapstorage->getNodeMapList());
   35.23 +      mapwin->update(
   35.24 +          mapstorage->getEdgeMapList(NUM),
   35.25 +          mapstorage->getEdgeMapList(STR),
   35.26 +          mapstorage->getNodeMapList(NUM),
   35.27 +          mapstorage->getNodeMapList(STR));
   35.28      }
   35.29    title_changed(Glib::filename_display_basename(file));
   35.30  }
   35.31  
   35.32  void NoteBookTab::newFile()
   35.33  {
   35.34 -  if (mapstorage->modified)
   35.35 +  if (mapstorage->getModified())
   35.36    {
   35.37      Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true,
   35.38          Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
   35.39 @@ -80,14 +85,18 @@
   35.40    mapstorage->clear();
   35.41    if(mapwinexists)
   35.42      {
   35.43 -      mapwin->update(mapstorage->getEdgeMapList(), mapstorage->getNodeMapList());
   35.44 +      mapwin->update(
   35.45 +          mapstorage->getEdgeMapList(NUM),
   35.46 +          mapstorage->getEdgeMapList(STR),
   35.47 +          mapstorage->getNodeMapList(NUM),
   35.48 +          mapstorage->getNodeMapList(STR));
   35.49      }
   35.50    title_changed("unsaved file");
   35.51  }
   35.52  
   35.53  void NoteBookTab::openFile()
   35.54  {
   35.55 -  if (mapstorage->modified)
   35.56 +  if (mapstorage->getModified())
   35.57    {
   35.58      Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true, 
   35.59          Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
   35.60 @@ -115,12 +124,16 @@
   35.61      Glib::ustring filename = fcdialog.get_filename();
   35.62      if (!mapstorage->readFromFile(filename))
   35.63      {
   35.64 -      mapstorage->file_name = filename;
   35.65 -      mapstorage->modified = false;
   35.66 +      mapstorage->setFileName(filename);
   35.67 +      mapstorage->setModified(false);
   35.68        gd_canvas->drawGraph();
   35.69        if(mapwinexists)
   35.70  	{
   35.71 -	  mapwin->update(mapstorage->getEdgeMapList(), mapstorage->getNodeMapList());
   35.72 +          mapwin->update(
   35.73 +              mapstorage->getEdgeMapList(NUM),
   35.74 +              mapstorage->getEdgeMapList(STR),
   35.75 +              mapstorage->getNodeMapList(NUM),
   35.76 +              mapstorage->getNodeMapList(STR));
   35.77  	}
   35.78        title_changed(Glib::filename_display_basename(filename));
   35.79      }
   35.80 @@ -129,14 +142,14 @@
   35.81  
   35.82  void NoteBookTab::saveFile()
   35.83  {
   35.84 -  if (mapstorage->file_name == "") {
   35.85 +  if (mapstorage->getFileName() == "") {
   35.86      saveFileAs();
   35.87    }
   35.88    else
   35.89    {
   35.90 -    mapstorage->writeToFile(mapstorage->file_name);
   35.91 -    mapstorage->modified = false;
   35.92 -    title_changed(Glib::filename_display_basename(mapstorage->file_name));
   35.93 +    mapstorage->writeToFile(mapstorage->getFileName());
   35.94 +    mapstorage->setModified(false);
   35.95 +    title_changed(Glib::filename_display_basename(mapstorage->getFileName()));
   35.96    }
   35.97  }
   35.98  
   35.99 @@ -148,16 +161,16 @@
  35.100    if (fcdialog.run() == Gtk::RESPONSE_ACCEPT)
  35.101    {
  35.102      Glib::ustring filename = fcdialog.get_filename();
  35.103 -    mapstorage->file_name = filename;
  35.104 +    mapstorage->setFileName(filename);
  35.105      mapstorage->writeToFile(filename);
  35.106 -    mapstorage->modified = false;
  35.107 +    mapstorage->setModified(false);
  35.108      title_changed(Glib::filename_display_basename(filename));
  35.109    }
  35.110  }
  35.111  
  35.112  void NoteBookTab::close()
  35.113  {
  35.114 -  if (mapstorage->modified)
  35.115 +  if (mapstorage->getModified())
  35.116    {
  35.117      Gtk::MessageDialog mdialog("<b>Save changes before closing?</b>", true,
  35.118          Gtk::MESSAGE_WARNING, Gtk::BUTTONS_NONE);
  35.119 @@ -179,7 +192,11 @@
  35.120    mapstorage->clear();
  35.121    if(mapwinexists)
  35.122      {
  35.123 -      mapwin->update(mapstorage->getEdgeMapList(), mapstorage->getNodeMapList());
  35.124 +      mapwin->update(
  35.125 +          mapstorage->getEdgeMapList(NUM),
  35.126 +          mapstorage->getEdgeMapList(STR),
  35.127 +          mapstorage->getNodeMapList(NUM),
  35.128 +          mapstorage->getNodeMapList(STR));
  35.129      }
  35.130    title_changed("unsaved file");
  35.131  }
  35.132 @@ -209,23 +226,23 @@
  35.133    return mapstorage->getActiveNodeMap(prop);
  35.134  }
  35.135  
  35.136 -void NoteBookTab::registerNewEdgeMap(std::string mapname)
  35.137 +void NoteBookTab::registerNewEdgeMap(std::string mapname, MapValue::Type type)
  35.138  {
  35.139    if(mapwinexists)
  35.140      {
  35.141 -      mapwin->registerNewEdgeMap(mapname);
  35.142 +      mapwin->registerNewEdgeMap(mapname, type);
  35.143      }
  35.144  }
  35.145  
  35.146 -void NoteBookTab::registerNewNodeMap(std::string mapname)
  35.147 +void NoteBookTab::registerNewNodeMap(std::string mapname, MapValue::Type type)
  35.148  {
  35.149    if(mapwinexists)
  35.150      {
  35.151 -      mapwin->registerNewNodeMap(mapname);
  35.152 +      mapwin->registerNewNodeMap(mapname, type);
  35.153      }
  35.154    if(epswinexists)
  35.155      {
  35.156 -      epswin->registerNewNodeMap(mapname);
  35.157 +      epswin->registerNewNodeMap(mapname, type);
  35.158      }
  35.159  }
  35.160  
  35.161 @@ -233,7 +250,12 @@
  35.162  {
  35.163    if(!mapwinexists)
  35.164      {
  35.165 -      mapwin=new MapWin("Map Setup - "+name, mapstorage->getEdgeMapList(), mapstorage->getNodeMapList(), *this);
  35.166 +      mapwin=new MapWin("Map Setup - "+name,
  35.167 +          mapstorage->getEdgeMapList(NUM),
  35.168 +          mapstorage->getEdgeMapList(STR),
  35.169 +          mapstorage->getNodeMapList(NUM),
  35.170 +          mapstorage->getNodeMapList(STR),
  35.171 +          *this);
  35.172        mapst2mapwin=mapstorage->signal_map_win_ch().connect(sigc::mem_fun(*mapwin, &MapWin::changeEntry));
  35.173        mapwin->show();
  35.174        mapwinexists=true;
  35.175 @@ -244,7 +266,7 @@
  35.176  {
  35.177    if(!epswinexists)
  35.178      {
  35.179 -      epswin=new EpsWin("Export to EPS - "+name, mapstorage->getNodeMapList());
  35.180 +      epswin=new EpsWin("Export to EPS - "+name, mapstorage->getNodeMapList(NUM), mapstorage->getNodeMapList(STR));
  35.181        epswin->show();
  35.182        epswinexists=true;
  35.183        epswin->signal_eps_details_ch().connect(sigc::mem_fun(*this, &NoteBookTab::exportGraphToEPS));
  35.184 @@ -263,9 +285,9 @@
  35.185        mapstorage->get_design_data(attraction, propulsation, iterations);
  35.186        designwin=new DesignWin("Design Setup - "+name, attraction, propulsation, iterations);
  35.187  
  35.188 -      designwin->signal_attraction().connect(sigc::mem_fun(mapstorage, &MapStorage::set_attraction));
  35.189 -      designwin->signal_propulsation().connect(sigc::mem_fun(mapstorage, &MapStorage::set_propulsation));
  35.190 -      designwin->signal_iteration().connect(sigc::mem_fun(mapstorage, &MapStorage::set_iteration));
  35.191 +      designwin->signal_attraction().connect(sigc::mem_fun(*mapstorage, &MapStorage::set_attraction));
  35.192 +      designwin->signal_propulsation().connect(sigc::mem_fun(*mapstorage, &MapStorage::set_propulsation));
  35.193 +      designwin->signal_iteration().connect(sigc::mem_fun(*mapstorage, &MapStorage::set_iteration));
  35.194        designwin->close_run().connect(sigc::mem_fun(*gd_canvas, &GraphDisplayerCanvas::reDesignGraph));
  35.195  
  35.196        designwin->signal_delete_event().connect(sigc::mem_fun(*this, &NoteBookTab::closeDesignWin));
    36.1 --- a/nbtab.h	Wed May 02 20:33:58 2007 +0000
    36.2 +++ b/nbtab.h	Wed Jan 02 21:03:09 2008 +0000
    36.3 @@ -27,6 +27,7 @@
    36.4  
    36.5  #include <libgnomecanvasmm.h>
    36.6  #include <libgnomecanvasmm/polygon.h>
    36.7 +#include "map_value.h"
    36.8  
    36.9  ///One tab in the Notebook that is placed in the main window (\ref MainWin).
   36.10  
   36.11 @@ -172,7 +173,7 @@
   36.12    ///a function with the same name and same parameterin \ref MapWin.
   36.13    ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
   36.14    ///\param mapname name of new map
   36.15 -  void registerNewEdgeMap(std::string mapname);
   36.16 +  void registerNewEdgeMap(std::string mapname, MapValue::Type type);
   36.17  
   36.18    ///Registers recently created nodemap in \ref MapWin.
   36.19  
   36.20 @@ -181,7 +182,7 @@
   36.21    ///a function with the same name and same parameter in \ref MapWin.
   36.22    ///This call-forwarder function is needed, because \ref Mapstorage does not know \ref MapWin
   36.23    ///\param mapname name of new map
   36.24 -  void registerNewNodeMap(std::string mapname);
   36.25 +  void registerNewNodeMap(std::string mapname, MapValue::Type type);
   36.26  
   36.27    ///Pops up and registrates the \ref MapWin of \ref NoteBookTab.
   36.28    
    37.1 --- a/new_map_win.cc	Wed May 02 20:33:58 2007 +0000
    37.2 +++ b/new_map_win.cc	Wed Jan 02 21:03:09 2008 +0000
    37.3 @@ -29,7 +29,7 @@
    37.4    return true;
    37.5  }
    37.6  
    37.7 -NewMapWin::NewMapWin(const std::string& title, NoteBookTab & mw, bool itisedge, bool edgenode):Gtk::Dialog(title, true, true),mytab(mw),node("Create NodeMap"),edge("Create EdgeMap")
    37.8 +NewMapWin::NewMapWin(const std::string& title, NoteBookTab & mw, bool itisedge, bool edgenode, MapType type):Gtk::Dialog(title, true, true),mytab(mw),node("Create NodeMap"),edge("Create EdgeMap"),map_type(type)
    37.9  {
   37.10    set_default_size(200, 50);
   37.11  
   37.12 @@ -38,7 +38,7 @@
   37.13    Gtk::VBox * vbox=get_vbox();
   37.14  
   37.15    //entries
   37.16 -  table=new Gtk::Table(3, 2, false);
   37.17 +  table=new Gtk::Table(5, 2, false);
   37.18  
   37.19    label=new Gtk::Label;
   37.20    label->set_text("Name of new map:");
   37.21 @@ -47,33 +47,45 @@
   37.22    (*table).attach(*label,0,1,0,1,Gtk::SHRINK,Gtk::SHRINK,10,3);
   37.23    (*table).attach(name,1,2,0,1,Gtk::SHRINK,Gtk::SHRINK,10,3);
   37.24  
   37.25 +  lblType.set_label("Element type:");
   37.26 +  if (map_type & NUM)
   37.27 +    cbType.append_text("Numeric");
   37.28 +  if (map_type & STR)
   37.29 +    cbType.append_text("String");
   37.30 +  cbType.set_active(0);
   37.31 +
   37.32 +  (*table).attach(lblType,0,1,1,2,Gtk::SHRINK,Gtk::SHRINK,10,3);
   37.33 +  (*table).attach(cbType, 1,2,1,2,Gtk::SHRINK,Gtk::SHRINK,10,3);
   37.34 +
   37.35    label=new Gtk::Label;
   37.36    label->set_text("Default value in the map:");
   37.37    default_value.set_text("0");
   37.38  
   37.39 -  (*table).attach(*label,0,1,1,2,Gtk::SHRINK,Gtk::SHRINK,10,3);
   37.40 -  (*table).attach(default_value,1,2,1,2,Gtk::SHRINK,Gtk::SHRINK,10,3);
   37.41 +  (*table).attach(*label,0,1,2,3,Gtk::SHRINK,Gtk::SHRINK,10,3);
   37.42 +  (*table).attach(default_value,1,2,2,3,Gtk::SHRINK,Gtk::SHRINK,10,3);
   37.43  
   37.44    //node vs. edge map selector
   37.45    Gtk::RadioButton::Group group = node.get_group();
   37.46    edge.set_group(group);
   37.47 -  
   37.48 +
   37.49    if(edgenode)
   37.50 +  {
   37.51 +    (*table).attach(node,0,1,3,4,Gtk::SHRINK,Gtk::SHRINK,10,3);
   37.52 +    (*table).attach(edge,1,2,3,4,Gtk::SHRINK,Gtk::SHRINK,10,3);
   37.53 +  }
   37.54 +  else
   37.55 +  {
   37.56 +    if(itisedge)
   37.57      {
   37.58 -      (*table).attach(node,0,1,2,3,Gtk::SHRINK,Gtk::SHRINK,10,3);
   37.59 -      (*table).attach(edge,1,2,2,3,Gtk::SHRINK,Gtk::SHRINK,10,3);
   37.60 +      edge.set_active();
   37.61      }
   37.62 -  else
   37.63 +    else
   37.64      {
   37.65 -      if(itisedge)
   37.66 -	{
   37.67 -	  edge.set_active();
   37.68 -	}
   37.69 -      else
   37.70 -	{
   37.71 -	  node.set_active();
   37.72 -	}
   37.73 +      node.set_active();
   37.74      }
   37.75 +  }
   37.76 +
   37.77 +  (*table).attach(lblErrorMsg,0,2,4,5,Gtk::SHRINK,Gtk::SHRINK,10,3);
   37.78  
   37.79    vbox->pack_start(*table);
   37.80  
   37.81 @@ -84,214 +96,242 @@
   37.82  
   37.83  }
   37.84  
   37.85 +void NewMapWin::setErrorMsg(const Glib::ustring& msg)
   37.86 +{
   37.87 +  lblErrorMsg.set_markup("<i><small>" + msg + "</small></i>");
   37.88 +}
   37.89 +
   37.90 +std::vector<double>* NewMapWin::evaluate_expr(const std::string polishform, bool itisedge)
   37.91 +{
   37.92 +  MapStorage& ms = *mytab.mapstorage;
   37.93 +
   37.94 +  std::vector<double>* ret = new std::vector<double>;
   37.95 +  std::stack<double> polishstack;
   37.96 +
   37.97 +  if (itisedge)
   37.98 +  {
   37.99 +    for(EdgeIt k(ms.graph); k!=INVALID; ++k)
  37.100 +    {
  37.101 +      for(int i=0;i<(int)polishform.size();i++)
  37.102 +      {
  37.103 +        double op1=0, op2=0;
  37.104 +        bool operation=true;
  37.105 +        switch(polishform[i])
  37.106 +        {
  37.107 +          case '+':
  37.108 +          case '-':
  37.109 +          case '/':
  37.110 +          case '*':
  37.111 +            op1=polishstack.top();
  37.112 +            polishstack.pop();
  37.113 +            op2=polishstack.top();
  37.114 +            polishstack.pop();
  37.115 +            break;
  37.116 +          default:
  37.117 +            //substitute variable
  37.118 +            std::vector<std::string> maps = ms.getEdgeMapList(NUM);
  37.119 +            bool itisvar=(std::find(maps.begin(), maps.end(), ch2var[ polishform[i] ]) != maps.end());
  37.120 +            if(itisvar)
  37.121 +            {
  37.122 +              polishstack.push(ms.get(ch2var[ polishform[i] ], k));
  37.123 +            }
  37.124 +            else
  37.125 +            {
  37.126 +              polishstack.push(atof(ch2var[ polishform[i] ].c_str()));
  37.127 +            }
  37.128 +            operation=false;
  37.129 +            break;
  37.130 +        }
  37.131 +        if(operation)
  37.132 +        {
  37.133 +          double res;
  37.134 +          switch(polishform[i])
  37.135 +          {
  37.136 +            case '+':
  37.137 +              res=op1+op2;
  37.138 +              break;
  37.139 +            case '-':
  37.140 +              res=op2-op1;
  37.141 +              break;
  37.142 +            case '/':
  37.143 +              res=op2/op1;
  37.144 +              break;
  37.145 +            case '*':
  37.146 +              res=op1*op2;
  37.147 +              break;
  37.148 +            default:
  37.149 +              std::cout << "How could we get here?" << std::endl;
  37.150 +              break;
  37.151 +          }
  37.152 +          polishstack.push(res);
  37.153 +        }
  37.154 +      }//foreach letter in polishform
  37.155 +      ret->push_back(polishstack.top());
  37.156 +    }//foreach edge
  37.157 +  }
  37.158 +  else
  37.159 +  {
  37.160 +    for(NodeIt k(ms.graph); k!=INVALID; ++k)
  37.161 +    {
  37.162 +      for(int i=0;i<(int)polishform.size();i++)
  37.163 +      {
  37.164 +        double op1=0, op2=0;
  37.165 +        bool operation=true;
  37.166 +        switch(polishform[i])
  37.167 +        {
  37.168 +          case '+':
  37.169 +          case '-':
  37.170 +          case '/':
  37.171 +          case '*':
  37.172 +            op1=polishstack.top();
  37.173 +            polishstack.pop();
  37.174 +            op2=polishstack.top();
  37.175 +            polishstack.pop();
  37.176 +            break;
  37.177 +          default:
  37.178 +            //substitute variable
  37.179 +            std::vector<std::string> maps = ms.getNodeMapList(NUM);
  37.180 +            bool itisvar=(std::find(maps.begin(), maps.end(), ch2var[ polishform[i] ]) != maps.end());
  37.181 +            if(itisvar)
  37.182 +            {
  37.183 +              polishstack.push(ms.get(ch2var[ polishform[i] ], k));
  37.184 +            }
  37.185 +            else
  37.186 +            {
  37.187 +              polishstack.push(atof(ch2var[ polishform[i] ].c_str()));
  37.188 +            }
  37.189 +            operation=false;
  37.190 +            break;
  37.191 +        }
  37.192 +        if(operation)
  37.193 +        {
  37.194 +          double res;
  37.195 +          switch(polishform[i])
  37.196 +          {
  37.197 +            case '+':
  37.198 +              res=op1+op2;
  37.199 +              break;
  37.200 +            case '-':
  37.201 +              res=op2-op1;
  37.202 +              break;
  37.203 +            case '/':
  37.204 +              res=op2/op1;
  37.205 +              break;
  37.206 +            case '*':
  37.207 +              res=op1*op2;
  37.208 +              break;
  37.209 +            default:
  37.210 +              std::cout << "How could we get here?" << std::endl;
  37.211 +              break;
  37.212 +          }
  37.213 +          polishstack.push(res);
  37.214 +        }
  37.215 +      }//foreach letter in polishform
  37.216 +      ret->push_back(polishstack.top());
  37.217 +    }//foreach edge
  37.218 +  }
  37.219 +  return ret;
  37.220 +}
  37.221 +
  37.222  void NewMapWin::on_response(int response_id)
  37.223  {
  37.224 +  MapStorage& ms = *mytab.mapstorage;
  37.225 +
  37.226    if(response_id==Gtk::RESPONSE_OK)
  37.227 +  {
  37.228 +    std::string map_name = name.get_text();
  37.229 +    std::string def_val = default_value.get_text();
  37.230 +
  37.231 +    if (map_name.empty())
  37.232      {
  37.233 -      double def_val=0;
  37.234 +      setErrorMsg("No map name given.");
  37.235 +      return;
  37.236 +    }
  37.237  
  37.238 -      //get and formulate text
  37.239 -      std::string def_val_str=default_value.get_text();
  37.240 +    // check whether the map already exists
  37.241 +    if (edge.get_active())
  37.242 +    {
  37.243 +      if (ms.edgeMapExists(map_name))
  37.244 +      {
  37.245 +        setErrorMsg("Map '" + map_name + "' already exists.");
  37.246 +        return;
  37.247 +      }
  37.248 +    }
  37.249 +    else
  37.250 +    {
  37.251 +      if (ms.nodeMapExists(map_name))
  37.252 +      {
  37.253 +        setErrorMsg("Map '" + map_name + "' already exists.");
  37.254 +        return;
  37.255 +      }
  37.256 +    }
  37.257  
  37.258 -      bool only_nums=true;
  37.259 -      for(int i=0;i<(int)def_val_str.size() && only_nums;i++)
  37.260 -	{
  37.261 -	  if( def_val_str[i]<'0' || def_val_str[i]>'9' )
  37.262 -	    {
  37.263 -	      only_nums=false;
  37.264 -	    }
  37.265 -	}
  37.266 -      std::string polishform;
  37.267 +    Glib::ustring text = cbType.get_active_text();
  37.268 +    if (text == "Numeric")
  37.269 +    {
  37.270 +      double d;
  37.271 +      char *endptr;
  37.272 +      d = strtod(def_val.c_str(), &endptr);
  37.273 +      if (def_val.c_str() + def_val.length() == endptr)
  37.274 +      {
  37.275 +        // the full string was a number
  37.276 +        if (edge.get_active())
  37.277 +          ms.createEdgeMap(map_name, MapValue::NUMERIC,
  37.278 +              MapValue(d));
  37.279 +        else
  37.280 +          ms.createNodeMap(map_name, MapValue::NUMERIC,
  37.281 +              MapValue(d));
  37.282 +      }
  37.283 +      else
  37.284 +      {
  37.285 +        // let't try to evaluate the string as an arithmetic expression
  37.286 +        std::string polishform =
  37.287 +          string2Polishform(def_val, edge.get_active());
  37.288 +        if (polishform.empty())
  37.289 +          return;
  37.290 +        std::vector<double>* values =
  37.291 +          evaluate_expr(polishform, edge.get_active());
  37.292 +        if (edge.get_active())
  37.293 +        {
  37.294 +          ms.createEdgeMap(map_name, MapValue::NUMERIC,
  37.295 +              MapValue(0.0));
  37.296 +          std::vector<double>::const_iterator vit = values->begin();
  37.297 +          for (EdgeIt it(ms.graph); it != INVALID; ++it)
  37.298 +          {
  37.299 +            ms.set(map_name, it, MapValue(*vit));
  37.300 +            ++vit;
  37.301 +          }
  37.302 +        }
  37.303 +        else
  37.304 +        {
  37.305 +          ms.createNodeMap(map_name, MapValue::NUMERIC,
  37.306 +              MapValue(0.0));
  37.307 +          std::vector<double>::const_iterator vit = values->begin();
  37.308 +          for (NodeIt it(ms.graph); it != INVALID; ++it)
  37.309 +          {
  37.310 +            ms.set(map_name, it, MapValue(*vit));
  37.311 +            ++vit;
  37.312 +          }
  37.313 +        }
  37.314 +        delete values;
  37.315 +      }
  37.316 +    }
  37.317 +    else if (text == "String")
  37.318 +    {
  37.319 +      if (edge.get_active())
  37.320 +        ms.createEdgeMap(map_name, MapValue::STRING,
  37.321 +            MapValue(def_val));
  37.322 +      else
  37.323 +        ms.createNodeMap(map_name, MapValue::STRING,
  37.324 +            MapValue(def_val));
  37.325 +    }
  37.326  
  37.327 -      if(only_nums)
  37.328 -	{
  37.329 -	  def_val=atof(def_val_str.c_str());
  37.330 -	}
  37.331 -      else
  37.332 -	{
  37.333 -	  polishform=string2Polishform(def_val_str,edge.get_active());
  37.334 -	}
  37.335 -
  37.336 -      //get name of text
  37.337 -      std::string mapname=name.get_text();
  37.338 -      
  37.339 -      if(!mapname.empty()&&(!polishform.empty()||only_nums))
  37.340 -	{
  37.341 -	  int abortion=0;
  37.342 -	  if(edge.get_active())
  37.343 -	    {
  37.344 -	      //create the new map
  37.345 -	      Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (mytab.mapstorage->graph, def_val);
  37.346 -	      
  37.347 -	      if(!only_nums)
  37.348 -		{
  37.349 -		  std::stack<double> polishstack;
  37.350 -		  
  37.351 -		  for(EdgeIt k(mytab.mapstorage->graph); k!=INVALID; ++k)
  37.352 -		    {
  37.353 -		      for(int i=0;i<(int)polishform.size();i++)
  37.354 -			{
  37.355 -			  double op1=0, op2=0;
  37.356 -			  bool operation=true;
  37.357 -			  switch(polishform[i])
  37.358 -			    {
  37.359 -			    case '+':
  37.360 -			    case '-':
  37.361 -			    case '/':
  37.362 -			    case '*':
  37.363 -			      op1=polishstack.top();
  37.364 -			      polishstack.pop();
  37.365 -			      op2=polishstack.top();
  37.366 -			      polishstack.pop();
  37.367 -			      break;
  37.368 -			    default:
  37.369 -			      //substitute variable
  37.370 -			      std::map< std::string,Graph::EdgeMap<double> * > ems=mytab.mapstorage->edgemap_storage;
  37.371 -			      bool itisvar=(ems.find(ch2var[ polishform[i] ])!=ems.end());
  37.372 -			      if(itisvar)
  37.373 -				{
  37.374 -				  polishstack.push( (*(mytab.mapstorage->edgemap_storage[ ch2var[ polishform[i] ] ]))[k]);
  37.375 -				}
  37.376 -			      else
  37.377 -				{
  37.378 -				  polishstack.push(atof(ch2var[ polishform[i] ].c_str()));
  37.379 -				}
  37.380 -			      operation=false;
  37.381 -			      break;
  37.382 -			    }
  37.383 -			  if(operation)
  37.384 -			    {
  37.385 -			      double res;
  37.386 -			      switch(polishform[i])
  37.387 -				{
  37.388 -				case '+':
  37.389 -				  res=op1+op2;
  37.390 -				  break;
  37.391 -				case '-':
  37.392 -				  res=op2-op1;
  37.393 -				  break;
  37.394 -				case '/':
  37.395 -				  res=op2/op1;
  37.396 -				  break;
  37.397 -				case '*':
  37.398 -				  res=op1*op2;
  37.399 -				  break;
  37.400 -				default:
  37.401 -				  std::cout << "How could we get here?" << std::endl;
  37.402 -				  break;
  37.403 -				}
  37.404 -			      polishstack.push(res);
  37.405 -			    }
  37.406 -			}//foreach letter in polishform
  37.407 -		      (*emptr)[k]=polishstack.top(); 
  37.408 -		    }//foreach edge
  37.409 -		}//!only_nums
  37.410 -
  37.411 -	      //if addition was not successful addEdgeMap returns one.
  37.412 -	      //cause can be that there is already a map named like the new one
  37.413 -	      if(mytab.mapstorage->addEdgeMap(mapname, emptr, def_val))
  37.414 -		{
  37.415 -		  abortion=1;
  37.416 -		}
  37.417 -
  37.418 -	      //add it to the list of the displayable maps
  37.419 -	      //furthermore it is done by signals
  37.420 -	      //mytab.registerNewEdgeMap(mapname);
  37.421 -
  37.422 -	      //display it
  37.423 -	      //gdc.changeEdgeText(mapname);
  37.424 -	    }
  37.425 -	  else //!edge.get_active()
  37.426 -	    {
  37.427 -	      //create the new map
  37.428 -	      Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (mytab.mapstorage->graph, def_val);
  37.429 -
  37.430 -	      if(!only_nums)
  37.431 -		{
  37.432 -		  std::stack<double> polishstack;
  37.433 -  
  37.434 -		  for(NodeIt k(mytab.mapstorage->graph); k!=INVALID; ++k)
  37.435 -		    {
  37.436 -		      for(int i=0;i<(int)polishform.size();i++)
  37.437 -			{
  37.438 -			  double op1=0, op2=0;
  37.439 -			  bool operation=true;
  37.440 -			  switch(polishform[i])
  37.441 -			    {
  37.442 -			    case '+':
  37.443 -			    case '-':
  37.444 -			    case '/':
  37.445 -			    case '*':
  37.446 -			      op1=polishstack.top();
  37.447 -			      polishstack.pop();
  37.448 -			      op2=polishstack.top();
  37.449 -			      polishstack.pop();
  37.450 -			      break;
  37.451 -			    default:
  37.452 -			      std::map< std::string,Graph::NodeMap<double> * > nms=mytab.mapstorage->nodemap_storage;
  37.453 -			      bool itisvar=(nms.find(ch2var[ polishform[i] ])!=nms.end());
  37.454 -			      if(itisvar)
  37.455 -				{
  37.456 -				  polishstack.push( (*(mytab.mapstorage->nodemap_storage[ ch2var[ polishform[i] ] ]))[k]);
  37.457 -				}
  37.458 -			      else
  37.459 -				{
  37.460 -				  polishstack.push(atof(ch2var[ polishform[i] ].c_str()));
  37.461 -				}
  37.462 -			      operation=false;
  37.463 -			      break;
  37.464 -			    }
  37.465 -			  if(operation)
  37.466 -			    {
  37.467 -			      double res;
  37.468 -			      switch(polishform[i])
  37.469 -				{
  37.470 -				case '+':
  37.471 -				  res=op1+op2;
  37.472 -				  break;
  37.473 -				case '-':
  37.474 -				  res=op2-op1;
  37.475 -				  break;
  37.476 -				case '/':
  37.477 -				  res=op2/op1;
  37.478 -				  break;
  37.479 -				case '*':
  37.480 -				  res=op1*op2;
  37.481 -				  break;
  37.482 -				default:
  37.483 -				  std::cout << "How could we get here?" << std::endl;
  37.484 -				  break;
  37.485 -				}
  37.486 -			      polishstack.push(res);
  37.487 -			    }
  37.488 -			}
  37.489 -		      (*emptr)[k]=polishstack.top(); 
  37.490 -		    }
  37.491 -		}
  37.492 -	      //if addition was not successful addNodeMap returns one.
  37.493 -	      //cause can be that there is already a map named like the new one
  37.494 -	      if(mytab.mapstorage->addNodeMap(mapname,emptr, def_val))
  37.495 -		{
  37.496 -		  abortion=1;
  37.497 -		}
  37.498 -
  37.499 -	      //add it to the list of the displayable maps
  37.500 -	      //furthermore it is done by signals
  37.501 -	      //mytab.registerNewNodeMap(mapname);
  37.502 -
  37.503 -	      //display it
  37.504 -	      //gdc.changeNodeText(mapname);
  37.505 -	    }
  37.506 -	  if(!abortion)
  37.507 -	    {
  37.508 -	      name.set_text("");
  37.509 -	      default_value.set_text("0");
  37.510 -	      edge.show();
  37.511 -	      node.show();
  37.512 -	      hide();
  37.513 -	    }
  37.514 -	}
  37.515 -    }
  37.516 +    name.set_text("");
  37.517 +    default_value.set_text("0");
  37.518 +    edge.show();
  37.519 +    node.show();
  37.520 +    hide();
  37.521 +  }
  37.522  }
  37.523  
  37.524  
  37.525 @@ -308,128 +348,128 @@
  37.526    char index='a';
  37.527  
  37.528    for(int i=0;(valid_entry&&(i<(int)rawcommand.size()));i++)
  37.529 +  {
  37.530 +    switch(rawcommand[i])
  37.531      {
  37.532 -      switch(rawcommand[i])
  37.533 -	{
  37.534 -	case '+':
  37.535 -	case '-':
  37.536 -	case '*':
  37.537 -	case '/':
  37.538 -	case ')':
  37.539 -	case '(':
  37.540 - 	  if(!variable.empty())
  37.541 -	    {
  37.542 -	      valid_entry=validVariable(variable, itisedge);
  37.543 -	      ch2var[index]=variable;
  37.544 -	      command+=index;
  37.545 -	      index++;
  37.546 -	      variable.erase(0,variable.size());	  
  37.547 -	    }
  37.548 -	  command+=rawcommand[i];
  37.549 -	  break;
  37.550 -	default:
  37.551 -	  variable+=rawcommand[i];
  37.552 -	  break;
  37.553 -	}
  37.554 +      case '+':
  37.555 +      case '-':
  37.556 +      case '*':
  37.557 +      case '/':
  37.558 +      case ')':
  37.559 +      case '(':
  37.560 +        if(!variable.empty())
  37.561 +        {
  37.562 +          valid_entry=validVariable(variable, itisedge);
  37.563 +          ch2var[index]=variable;
  37.564 +          command+=index;
  37.565 +          index++;
  37.566 +          variable.erase(0,variable.size());	  
  37.567 +        }
  37.568 +        command+=rawcommand[i];
  37.569 +        break;
  37.570 +      default:
  37.571 +        variable+=rawcommand[i];
  37.572 +        break;
  37.573 +    }
  37.574 +  }
  37.575 +
  37.576 +  if(!variable.empty()&&valid_entry)
  37.577 +  {
  37.578 +    valid_entry=validVariable(variable, itisedge);
  37.579 +    ch2var[index]=variable;
  37.580 +    command+=index;
  37.581 +    index++;
  37.582 +    variable.erase(0,variable.size());	  
  37.583 +  }
  37.584 +
  37.585 +  if(valid_entry)
  37.586 +  {
  37.587 +    unsigned int pr=10000;
  37.588 +    bool prevmult=false;
  37.589 +    unsigned int prev_change=pr;
  37.590 +    unsigned int prev_br=pr;
  37.591 +    int counter=0;
  37.592 +    std::string comm_nobr="";
  37.593 +    std::vector<unsigned int> p;
  37.594 +    p.resize(counter+1);
  37.595 +
  37.596 +    //limits
  37.597 +    //6 brackets embedded
  37.598 +    //100 operation in a row from the same priority
  37.599 +
  37.600 +    for(int i=0;i<(int)command.size();i++)
  37.601 +    {
  37.602 +      bool put_in_string=true;
  37.603 +      switch(command[i])
  37.604 +      {
  37.605 +        case '(':
  37.606 +          pr=prev_br+10000;
  37.607 +          prev_br=pr;
  37.608 +          prevmult=false;
  37.609 +          put_in_string=false;
  37.610 +          break;
  37.611 +        case ')':
  37.612 +          pr=prev_br-10000;
  37.613 +          prev_br=pr;
  37.614 +          prevmult=false;
  37.615 +          put_in_string=false;
  37.616 +          break;
  37.617 +        case '+':
  37.618 +        case '-':
  37.619 +          if(prevmult)
  37.620 +          {
  37.621 +            pr=prev_change;
  37.622 +          }
  37.623 +          p[counter]=pr;
  37.624 +          pr-=100;
  37.625 +
  37.626 +          prevmult=false;
  37.627 +          break;
  37.628 +        case '/':
  37.629 +        case '*':
  37.630 +          if(!prevmult)
  37.631 +          {
  37.632 +            prev_change=pr;
  37.633 +            pr+=200;
  37.634 +            pr-=1;
  37.635 +          }
  37.636 +          p[counter]=pr;
  37.637 +          pr-=1;
  37.638 +          prevmult=true;
  37.639 +          break;
  37.640 +        default:
  37.641 +          p[counter]=65000;
  37.642 +          break;
  37.643 +      }
  37.644 +      if(put_in_string)
  37.645 +      {
  37.646 +        counter++;
  37.647 +        p.resize(counter+1);
  37.648 +        comm_nobr=comm_nobr+command[i];
  37.649 +      }
  37.650      }
  37.651  
  37.652 -  if(!variable.empty()&&valid_entry)
  37.653 -    {
  37.654 -      valid_entry=validVariable(variable, itisedge);
  37.655 -      ch2var[index]=variable;
  37.656 -      command+=index;
  37.657 -      index++;
  37.658 -      variable.erase(0,variable.size());	  
  37.659 -    }
  37.660 +    tree_node * root=weightedString2Tree(comm_nobr, p, 0);
  37.661  
  37.662 -  if(valid_entry)
  37.663 -    {
  37.664 -      unsigned int pr=10000;
  37.665 -      bool prevmult=false;
  37.666 -      unsigned int prev_change=pr;
  37.667 -      unsigned int prev_br=pr;
  37.668 -      int counter=0;
  37.669 -      std::string comm_nobr="";
  37.670 -      std::vector<unsigned int> p;
  37.671 -      p.resize(counter+1);
  37.672 -      
  37.673 -      //limits
  37.674 -      //6 brackets embedded
  37.675 -      //100 operation in a row from the same priority
  37.676 -      
  37.677 -      for(int i=0;i<(int)command.size();i++)
  37.678 -	{
  37.679 -	  bool put_in_string=true;
  37.680 -	  switch(command[i])
  37.681 -	    {
  37.682 -	    case '(':
  37.683 -	      pr=prev_br+10000;
  37.684 -	      prev_br=pr;
  37.685 -	      prevmult=false;
  37.686 -	      put_in_string=false;
  37.687 -	      break;
  37.688 -	    case ')':
  37.689 -	      pr=prev_br-10000;
  37.690 -	      prev_br=pr;
  37.691 -	      prevmult=false;
  37.692 -	      put_in_string=false;
  37.693 -	      break;
  37.694 -	    case '+':
  37.695 -	    case '-':
  37.696 -	      if(prevmult)
  37.697 -		{
  37.698 -		  pr=prev_change;
  37.699 -		}
  37.700 -	      p[counter]=pr;
  37.701 -	      pr-=100;
  37.702 +    std::string polishform=postOrder(root);
  37.703  
  37.704 -	      prevmult=false;
  37.705 -	      break;
  37.706 -	    case '/':
  37.707 -	    case '*':
  37.708 -	      if(!prevmult)
  37.709 -		{
  37.710 -		  prev_change=pr;
  37.711 -		  pr+=200;
  37.712 -		  pr-=1;
  37.713 -		}
  37.714 -	      p[counter]=pr;
  37.715 -	      pr-=1;
  37.716 -	      prevmult=true;
  37.717 -	      break;
  37.718 -	    default:
  37.719 -	      p[counter]=65000;
  37.720 -	      break;
  37.721 -	    }
  37.722 -	  if(put_in_string)
  37.723 -	    {
  37.724 -	      counter++;
  37.725 -	      p.resize(counter+1);
  37.726 -	      comm_nobr=comm_nobr+command[i];
  37.727 -	    }
  37.728 -	}
  37.729 +    deleteTree(root);
  37.730  
  37.731 -      tree_node * root=weightedString2Tree(comm_nobr, p, 0);
  37.732 -
  37.733 -      std::string polishform=postOrder(root);
  37.734 -
  37.735 -      deleteTree(root);
  37.736 -
  37.737 -      return polishform;
  37.738 -    }
  37.739 +    return polishform;
  37.740 +  }
  37.741    return "";
  37.742  }
  37.743  
  37.744  void NewMapWin::deleteTree(NewMapWin::tree_node * node)
  37.745  {
  37.746    if(node->left_child!=NULL)
  37.747 -    {
  37.748 -      deleteTree(node->left_child);
  37.749 -    }
  37.750 +  {
  37.751 +    deleteTree(node->left_child);
  37.752 +  }
  37.753    if(node->right_child!=NULL)
  37.754 -    {
  37.755 -      deleteTree(node->right_child);
  37.756 -    }
  37.757 +  {
  37.758 +    deleteTree(node->right_child);
  37.759 +  }
  37.760    delete node;
  37.761  }
  37.762  
  37.763 @@ -438,25 +478,25 @@
  37.764    unsigned int min=p[offset];
  37.765    int minplace=0;
  37.766    for(int i=0;i<(int)to_tree.size();i++)
  37.767 +  {
  37.768 +    if(min>p[offset+i])
  37.769      {
  37.770 -      if(min>p[offset+i])
  37.771 -	{
  37.772 -	  min=p[offset+i];
  37.773 -	  minplace=i;
  37.774 -	}
  37.775 +      min=p[offset+i];
  37.776 +      minplace=i;
  37.777      }
  37.778 +  }
  37.779    tree_node * act_node=new tree_node;
  37.780    act_node->ch=to_tree[minplace];
  37.781    if(to_tree.size()>=3)
  37.782 -    {
  37.783 -      act_node->left_child=weightedString2Tree(to_tree.substr(0,minplace), p, offset);
  37.784 -      act_node->right_child=weightedString2Tree(to_tree.substr(minplace+1,to_tree.size()-minplace-1), p, offset+minplace+1);
  37.785 -    }
  37.786 +  {
  37.787 +    act_node->left_child=weightedString2Tree(to_tree.substr(0,minplace), p, offset);
  37.788 +    act_node->right_child=weightedString2Tree(to_tree.substr(minplace+1,to_tree.size()-minplace-1), p, offset+minplace+1);
  37.789 +  }
  37.790    else
  37.791 -    {
  37.792 -      act_node->left_child=NULL;
  37.793 -      act_node->right_child=NULL;
  37.794 -    }
  37.795 +  {
  37.796 +    act_node->left_child=NULL;
  37.797 +    act_node->right_child=NULL;
  37.798 +  }
  37.799    return act_node;
  37.800  }
  37.801  
  37.802 @@ -464,56 +504,62 @@
  37.803  {
  37.804    std::string subtree_to_string;
  37.805    if(subtree->left_child)
  37.806 -    {
  37.807 -      subtree_to_string=postOrder(subtree->left_child);
  37.808 -    }
  37.809 +  {
  37.810 +    subtree_to_string=postOrder(subtree->left_child);
  37.811 +  }
  37.812    if(subtree->right_child)
  37.813 -    {
  37.814 -      subtree_to_string=subtree_to_string+postOrder(subtree->right_child);
  37.815 -    }
  37.816 +  {
  37.817 +    subtree_to_string=subtree_to_string+postOrder(subtree->right_child);
  37.818 +  }
  37.819    subtree_to_string=subtree_to_string+subtree->ch;
  37.820    return subtree_to_string;
  37.821  }
  37.822  
  37.823  bool NewMapWin::validVariable(std::string variable, bool itisedge)
  37.824  {
  37.825 +  MapStorage& ms = *mytab.mapstorage;
  37.826 +
  37.827    bool cancel;
  37.828    //is it mapname?
  37.829    if(itisedge)
  37.830 -    {
  37.831 -      cancel=(mytab.mapstorage->edgemap_storage.find(variable)==mytab.mapstorage->edgemap_storage.end());
  37.832 -    }
  37.833 +  {
  37.834 +    std::vector<std::string> edge_maps =
  37.835 +      ms.getEdgeMapList(NUM);
  37.836 +    cancel=(std::find(edge_maps.begin(), edge_maps.end(), variable)==edge_maps.end());
  37.837 +  }
  37.838    else
  37.839 -    {
  37.840 -      cancel=(mytab.mapstorage->nodemap_storage.find(variable)==mytab.mapstorage->nodemap_storage.end());
  37.841 -    }
  37.842 +  {
  37.843 +    std::vector<std::string> node_maps =
  37.844 +      ms.getNodeMapList(NUM);
  37.845 +    cancel=(std::find(node_maps.begin(), node_maps.end(), variable)==node_maps.end());
  37.846 +  }
  37.847    //maybe it is number
  37.848    int point_num=0;
  37.849    if(cancel)
  37.850 +  {
  37.851 +    cancel=false;
  37.852 +    for(int j=0;(!cancel)&&(j<(int)variable.size());j++)
  37.853      {
  37.854 -      cancel=false;
  37.855 -      for(int j=0;(!cancel)&&(j<(int)variable.size());j++)
  37.856 -	{
  37.857 -	  if(((variable[j]<'0')||(variable[j]>'9'))&&(variable[j]!='.'))
  37.858 -	    {
  37.859 -	      cancel=true;
  37.860 -	    }
  37.861 -	  else
  37.862 -	    {
  37.863 -	      if(variable[j]=='.')
  37.864 -		{
  37.865 -		  point_num++;
  37.866 -		  if(point_num>1)
  37.867 -		    {
  37.868 -		      cancel=true;
  37.869 -		    }
  37.870 -		}
  37.871 -	    }
  37.872 -	}
  37.873 +      if(((variable[j]<'0')||(variable[j]>'9'))&&(variable[j]!='.'))
  37.874 +      {
  37.875 +        cancel=true;
  37.876 +      }
  37.877 +      else
  37.878 +      {
  37.879 +        if(variable[j]=='.')
  37.880 +        {
  37.881 +          point_num++;
  37.882 +          if(point_num>1)
  37.883 +          {
  37.884 +            cancel=true;
  37.885 +          }
  37.886 +        }
  37.887 +      }
  37.888      }
  37.889 +  }
  37.890    if(cancel)
  37.891 -    {
  37.892 -      return false;
  37.893 -    }
  37.894 +  {
  37.895 +    return false;
  37.896 +  }
  37.897    return true;
  37.898  }
    38.1 --- a/new_map_win.h	Wed May 02 20:33:58 2007 +0000
    38.2 +++ b/new_map_win.h	Wed Jan 02 21:03:09 2008 +0000
    38.3 @@ -35,6 +35,15 @@
    38.4    ///The \ref NoteBookTab in which the new map has to be placed.
    38.5    NoteBookTab & mytab;
    38.6  
    38.7 +  MapType map_type;
    38.8 +  Gtk::Label lblType;
    38.9 +  Gtk::ComboBoxText cbType;
   38.10 +
   38.11 +  Gtk::Label lblErrorMsg;
   38.12 +  void setErrorMsg(const Glib::ustring& msg);
   38.13 +
   38.14 +  std::vector<double>* evaluate_expr(const std::string polishform, bool itisedge);
   38.15 +
   38.16  public:
   38.17  
   38.18    ///Struct to be able to evaluate expressions.
   38.19 @@ -59,7 +68,7 @@
   38.20  
   38.21    ///It creates the widgets shown in
   38.22    ///NewMapWin.
   38.23 -  NewMapWin(const std::string& title, NoteBookTab &, bool itisedge=true, bool edgenode=true);
   38.24 +  NewMapWin(const std::string& title, NoteBookTab &, bool itisedge=true, bool edgenode=true, MapType type = ALL);
   38.25  
   38.26    ///Callback function for OK button. It creates the map.
   38.27    
    39.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    39.2 +++ b/save_details_dialog.cc	Wed Jan 02 21:03:09 2008 +0000
    39.3 @@ -0,0 +1,16 @@
    39.4 +#include "save_details_dialog.h"
    39.5 +#include <gtkmm/stock.h>
    39.6 +
    39.7 +SaveDetailsDialog::SaveDetailsDialog(MapStorage *ms) :
    39.8 +  Gtk::Dialog("Save Details", true),
    39.9 +  SaveDetails(ms)
   39.10 +{
   39.11 +  set_size_request(400, -1);
   39.12 +
   39.13 +  Gtk::VBox* pVBox = get_vbox();
   39.14 +  pVBox->pack_start(SaveDetails, Gtk::PACK_SHRINK);
   39.15 +
   39.16 +  add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
   39.17 +
   39.18 +  show_all_children();
   39.19 +}
    40.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    40.2 +++ b/save_details_dialog.h	Wed Jan 02 21:03:09 2008 +0000
    40.3 @@ -0,0 +1,15 @@
    40.4 +#ifndef SAVE_DETAILS_DIALOG
    40.5 +#define SAVE_DETAILS_DIALOG
    40.6 +
    40.7 +#include <gtkmm/dialog.h>
    40.8 +#include "save_details_widget.h"
    40.9 +
   40.10 +class SaveDetailsDialog : public Gtk::Dialog
   40.11 +{
   40.12 +  private:
   40.13 +    SaveDetailsWidget SaveDetails;
   40.14 +  public:
   40.15 +    SaveDetailsDialog(MapStorage*);
   40.16 +};
   40.17 +
   40.18 +#endif
    41.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    41.2 +++ b/save_details_widget.cc	Wed Jan 02 21:03:09 2008 +0000
    41.3 @@ -0,0 +1,616 @@
    41.4 +#include "save_details_widget.h"
    41.5 +#include "mapstorage.h"
    41.6 +
    41.7 +SaveDetailsWidget::SaveDetailsWidget(MapStorage* ms) :
    41.8 +  pMapStorage(ms)
    41.9 +{
   41.10 +  Gtk::Notebook* nb = Gtk::manage(new Gtk::Notebook);
   41.11 +  pack_start(*nb, Gtk::PACK_EXPAND_WIDGET);
   41.12 +
   41.13 +  nb->set_tab_pos(Gtk::POS_TOP);
   41.14 +
   41.15 +  Gtk::VBox* vbNodeMaps = Gtk::manage(new Gtk::VBox(false, 18));
   41.16 +  vbNodeMaps->set_border_width(12);
   41.17 +
   41.18 +  Gtk::VBox* vbEdgeMaps = Gtk::manage(new Gtk::VBox(false, 18));
   41.19 +  vbEdgeMaps->set_border_width(12);
   41.20 +
   41.21 +  Gtk::VBox* vbSpecMaps = Gtk::manage(new Gtk::VBox(false, 18));
   41.22 +  vbSpecMaps->set_border_width(12);
   41.23 +
   41.24 +  Gtk::VBox* vbGuiSect = Gtk::manage(new Gtk::VBox(false, 18));
   41.25 +  vbGuiSect->set_border_width(12);
   41.26 +
   41.27 +  nb->append_page(*vbSpecMaps, "Special Maps");
   41.28 +  nb->append_page(*vbNodeMaps, "Node Maps");
   41.29 +  nb->append_page(*vbEdgeMaps, "Edge Maps");
   41.30 +  nb->append_page(*vbGuiSect, "GUI Section");
   41.31 +
   41.32 +  // child widgets of vbSpecMaps
   41.33 +
   41.34 +  {
   41.35 +    Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6));
   41.36 +    vbSpecMaps->pack_start(*box1, Gtk::PACK_SHRINK);
   41.37 +
   41.38 +    Gtk::Label* lblNodeCoordMap =
   41.39 +      Gtk::manage(new Gtk::Label("<b>Node Coordinates</b>"));
   41.40 +    lblNodeCoordMap->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
   41.41 +    lblNodeCoordMap->set_use_markup();
   41.42 +    box1->pack_start(*lblNodeCoordMap, Gtk::PACK_SHRINK);
   41.43 +
   41.44 +    Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
   41.45 +    box1->pack_start(*box2, Gtk::PACK_SHRINK);
   41.46 +
   41.47 +    Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
   41.48 +    box2->pack_start(*fill1, Gtk::PACK_SHRINK);
   41.49 +
   41.50 +    Gtk::VBox* box3 = Gtk::manage(new Gtk::VBox);
   41.51 +    box2->pack_start(*box3, Gtk::PACK_SHRINK);
   41.52 +
   41.53 +    rbNodeCoordGuiSection.set_label("Save to GUI section");
   41.54 +    rbNodeCoordNodesetSection.set_label("Save to Nodeset section");
   41.55 +    Gtk::RadioButtonGroup group = rbNodeCoordGuiSection.get_group();
   41.56 +    rbNodeCoordNodesetSection.set_group(group);
   41.57 +
   41.58 +    box3->pack_start(rbNodeCoordGuiSection, Gtk::PACK_SHRINK);
   41.59 +    box3->pack_start(rbNodeCoordNodesetSection, Gtk::PACK_SHRINK);
   41.60 +
   41.61 +    Gtk::HBox* box4 = Gtk::manage(new Gtk::HBox);
   41.62 +    box3->pack_start(*box4, Gtk::PACK_SHRINK);
   41.63 +
   41.64 +    Gtk::Label* fill2 = Gtk::manage(new Gtk::Label("    "));
   41.65 +    box4->pack_start(*fill2, Gtk::PACK_SHRINK);
   41.66 +
   41.67 +    Gtk::Table* table1 = Gtk::manage(new Gtk::Table(3, 2));
   41.68 +    box4->pack_start(*table1, Gtk::PACK_SHRINK);
   41.69 +
   41.70 +    rbNodeCoordOneMap.set_label("As one map");
   41.71 +    rbNodeCoordTwoMaps.set_label("As two maps");
   41.72 +    group = rbNodeCoordOneMap.get_group();
   41.73 +    rbNodeCoordTwoMaps.set_group(group);
   41.74 +
   41.75 +    table1->attach(rbNodeCoordOneMap, 0, 1, 0, 1);
   41.76 +    table1->attach(rbNodeCoordTwoMaps, 0, 1, 1, 2);
   41.77 +    table1->attach(entNodeCoordsOneMap, 1, 2, 0, 1);
   41.78 +    table1->attach(entNodeCoordsTwoMaps1, 1, 2, 1, 2);
   41.79 +    table1->attach(entNodeCoordsTwoMaps2, 1, 2, 2, 3);
   41.80 +
   41.81 +    switch (pMapStorage->getNodeCoordsSaveDest())
   41.82 +    {
   41.83 +      case MapStorage::SpecMapSaveOpts::GUI_SECT:
   41.84 +        rbNodeCoordGuiSection.set_active();
   41.85 +        rbNodeCoordOneMap.set_sensitive(false);
   41.86 +        rbNodeCoordTwoMaps.set_sensitive(false);
   41.87 +        entNodeCoordsOneMap.set_sensitive(false);
   41.88 +        entNodeCoordsTwoMaps1.set_sensitive(false);
   41.89 +        entNodeCoordsTwoMaps2.set_sensitive(false);
   41.90 +        break;
   41.91 +      case MapStorage::SpecMapSaveOpts::NESET_SECT:
   41.92 +        rbNodeCoordNodesetSection.set_active();
   41.93 +        rbNodeCoordOneMap.set_sensitive(true);
   41.94 +        rbNodeCoordTwoMaps.set_sensitive(true);
   41.95 +        switch (pMapStorage->getNodeCoordsSaveMapNum())
   41.96 +        {
   41.97 +          case MapStorage::SpecMapSaveOpts::ONE_MAP:
   41.98 +            rbNodeCoordOneMap.set_active();
   41.99 +            entNodeCoordsOneMap.set_sensitive(true);
  41.100 +            entNodeCoordsTwoMaps1.set_sensitive(false);
  41.101 +            entNodeCoordsTwoMaps2.set_sensitive(false);
  41.102 +            break;
  41.103 +          case MapStorage::SpecMapSaveOpts::TWO_MAPS:
  41.104 +            rbNodeCoordTwoMaps.set_active();
  41.105 +            entNodeCoordsOneMap.set_sensitive(false);
  41.106 +            entNodeCoordsTwoMaps1.set_sensitive(true);
  41.107 +            entNodeCoordsTwoMaps2.set_sensitive(true);
  41.108 +            break;
  41.109 +        }
  41.110 +        break;
  41.111 +    }
  41.112 +
  41.113 +    entNodeCoordsOneMap.set_text(pMapStorage->getNodeCoordsOneMapName());
  41.114 +    entNodeCoordsTwoMaps1.set_text(pMapStorage->getNodeCoordsTwoMaps1Name());
  41.115 +    entNodeCoordsTwoMaps2.set_text(pMapStorage->getNodeCoordsTwoMaps2Name());
  41.116 +
  41.117 +    entNodeCoordsOneMap.signal_changed().connect(
  41.118 +        sigc::mem_fun(*this, &SaveDetailsWidget::onNodeCoordsOneMapName));
  41.119 +    entNodeCoordsTwoMaps1.signal_changed().connect(
  41.120 +        sigc::mem_fun(*this, &SaveDetailsWidget::onNodeCoordsTwoMaps1Name));
  41.121 +    entNodeCoordsTwoMaps2.signal_changed().connect(
  41.122 +        sigc::mem_fun(*this, &SaveDetailsWidget::onNodeCoordsTwoMaps2Name));
  41.123 +
  41.124 +    rbNodeCoordGuiSection.signal_toggled().connect(
  41.125 +        sigc::mem_fun(*this, &SaveDetailsWidget::onNodeCoordSaveDestChanged));
  41.126 +    rbNodeCoordNodesetSection.signal_toggled().connect(
  41.127 +        sigc::mem_fun(*this, &SaveDetailsWidget::onNodeCoordSaveDestChanged));
  41.128 +    rbNodeCoordOneMap.signal_toggled().connect(
  41.129 +        sigc::mem_fun(*this, &SaveDetailsWidget::onNodeCoordMapNumChanged));
  41.130 +    rbNodeCoordTwoMaps.signal_toggled().connect(
  41.131 +        sigc::mem_fun(*this, &SaveDetailsWidget::onNodeCoordMapNumChanged));
  41.132 +  }
  41.133 +
  41.134 +  {
  41.135 +    Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6));
  41.136 +    vbSpecMaps->pack_start(*box1, Gtk::PACK_SHRINK);
  41.137 +
  41.138 +    Gtk::Label* lblArrowCoordMap =
  41.139 +      Gtk::manage(new Gtk::Label("<b>Arrow Coordinates</b>"));
  41.140 +    lblArrowCoordMap->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
  41.141 +    lblArrowCoordMap->set_use_markup();
  41.142 +    box1->pack_start(*lblArrowCoordMap, Gtk::PACK_SHRINK);
  41.143 +
  41.144 +    Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
  41.145 +    box1->pack_start(*box2, Gtk::PACK_SHRINK);
  41.146 +
  41.147 +    Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
  41.148 +    box2->pack_start(*fill1, Gtk::PACK_SHRINK);
  41.149 +
  41.150 +    Gtk::VBox* box3 = Gtk::manage(new Gtk::VBox);
  41.151 +    box2->pack_start(*box3, Gtk::PACK_SHRINK);
  41.152 +
  41.153 +    rbArrowCoordGuiSection.set_label("Save to GUI section");
  41.154 +    rbArrowCoordEdgesetSection.set_label("Save to Edgeset section");
  41.155 +    Gtk::RadioButtonGroup group = rbArrowCoordGuiSection.get_group();
  41.156 +    rbArrowCoordEdgesetSection.set_group(group);
  41.157 +
  41.158 +    box3->pack_start(rbArrowCoordGuiSection, Gtk::PACK_SHRINK);
  41.159 +    box3->pack_start(rbArrowCoordEdgesetSection, Gtk::PACK_SHRINK);
  41.160 +
  41.161 +    Gtk::HBox* box4 = Gtk::manage(new Gtk::HBox);
  41.162 +    box3->pack_start(*box4, Gtk::PACK_SHRINK);
  41.163 +
  41.164 +    Gtk::Label* fill2 = Gtk::manage(new Gtk::Label("    "));
  41.165 +    box4->pack_start(*fill2, Gtk::PACK_SHRINK);
  41.166 +
  41.167 +    Gtk::Table* table1 = Gtk::manage(new Gtk::Table(3, 2));
  41.168 +    box4->pack_start(*table1, Gtk::PACK_SHRINK);
  41.169 +
  41.170 +    rbArrowCoordOneMap.set_label("As one map");
  41.171 +    rbArrowCoordTwoMaps.set_label("As two maps");
  41.172 +    group = rbArrowCoordOneMap.get_group();
  41.173 +    rbArrowCoordTwoMaps.set_group(group);
  41.174 +
  41.175 +    table1->attach(rbArrowCoordOneMap, 0, 1, 0, 1);
  41.176 +    table1->attach(rbArrowCoordTwoMaps, 0, 1, 1, 2);
  41.177 +    table1->attach(entArrowCoordsOneMap, 1, 2, 0, 1);
  41.178 +    table1->attach(entArrowCoordsTwoMaps1, 1, 2, 1, 2);
  41.179 +    table1->attach(entArrowCoordsTwoMaps2, 1, 2, 2, 3);
  41.180 +
  41.181 +    switch (pMapStorage->getArrowCoordsSaveDest())
  41.182 +    {
  41.183 +      case MapStorage::SpecMapSaveOpts::GUI_SECT:
  41.184 +        rbArrowCoordGuiSection.set_active();
  41.185 +        rbArrowCoordOneMap.set_sensitive(false);
  41.186 +        rbArrowCoordTwoMaps.set_sensitive(false);
  41.187 +        entArrowCoordsOneMap.set_sensitive(false);
  41.188 +        entArrowCoordsTwoMaps1.set_sensitive(false);
  41.189 +        entArrowCoordsTwoMaps2.set_sensitive(false);
  41.190 +        break;
  41.191 +      case MapStorage::SpecMapSaveOpts::NESET_SECT:
  41.192 +        rbArrowCoordEdgesetSection.set_active();
  41.193 +        rbArrowCoordOneMap.set_sensitive(true);
  41.194 +        rbArrowCoordTwoMaps.set_sensitive(true);
  41.195 +        switch (pMapStorage->getArrowCoordsSaveMapNum())
  41.196 +        {
  41.197 +          case MapStorage::SpecMapSaveOpts::ONE_MAP:
  41.198 +            rbArrowCoordOneMap.set_active();
  41.199 +            entArrowCoordsOneMap.set_sensitive(true);
  41.200 +            entArrowCoordsTwoMaps1.set_sensitive(false);
  41.201 +            entArrowCoordsTwoMaps2.set_sensitive(false);
  41.202 +            break;
  41.203 +          case MapStorage::SpecMapSaveOpts::TWO_MAPS:
  41.204 +            rbArrowCoordTwoMaps.set_active();
  41.205 +            entArrowCoordsOneMap.set_sensitive(false);
  41.206 +            entArrowCoordsTwoMaps1.set_sensitive(true);
  41.207 +            entArrowCoordsTwoMaps2.set_sensitive(true);
  41.208 +            break;
  41.209 +        }
  41.210 +        break;
  41.211 +    }
  41.212 +
  41.213 +    entArrowCoordsOneMap.set_text(pMapStorage->getArrowCoordsOneMapName());
  41.214 +    entArrowCoordsTwoMaps1.set_text(pMapStorage->getArrowCoordsTwoMaps1Name());
  41.215 +    entArrowCoordsTwoMaps2.set_text(pMapStorage->getArrowCoordsTwoMaps2Name());
  41.216 +
  41.217 +    entArrowCoordsOneMap.signal_changed().connect(
  41.218 +        sigc::mem_fun(*this, &SaveDetailsWidget::onArrowCoordsOneMapName));
  41.219 +    entArrowCoordsTwoMaps1.signal_changed().connect(
  41.220 +        sigc::mem_fun(*this, &SaveDetailsWidget::onArrowCoordsTwoMaps1Name));
  41.221 +    entArrowCoordsTwoMaps2.signal_changed().connect(
  41.222 +        sigc::mem_fun(*this, &SaveDetailsWidget::onArrowCoordsTwoMaps2Name));
  41.223 +
  41.224 +    rbArrowCoordGuiSection.signal_toggled().connect(
  41.225 +        sigc::mem_fun(*this, &SaveDetailsWidget::onArrowCoordSaveDestChanged));
  41.226 +    rbArrowCoordEdgesetSection.signal_toggled().connect(
  41.227 +        sigc::mem_fun(*this, &SaveDetailsWidget::onArrowCoordSaveDestChanged));
  41.228 +    rbArrowCoordOneMap.signal_toggled().connect(
  41.229 +        sigc::mem_fun(*this, &SaveDetailsWidget::onArrowCoordMapNumChanged));
  41.230 +    rbArrowCoordTwoMaps.signal_toggled().connect(
  41.231 +        sigc::mem_fun(*this, &SaveDetailsWidget::onArrowCoordMapNumChanged));
  41.232 +  }
  41.233 +
  41.234 +  // child widgets of vbGuiSect
  41.235 +
  41.236 +  {
  41.237 +    Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6));
  41.238 +    vbGuiSect->pack_start(*box1, Gtk::PACK_SHRINK);
  41.239 +
  41.240 +    Gtk::Label* lblGuiSectionSave =
  41.241 +      Gtk::manage(new Gtk::Label("<b>Save Destination</b>"));
  41.242 +    lblGuiSectionSave->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
  41.243 +    lblGuiSectionSave->set_use_markup();
  41.244 +    box1->pack_start(*lblGuiSectionSave, Gtk::PACK_SHRINK);
  41.245 +
  41.246 +    rbLgfFile.set_label("Lgf file");
  41.247 +    rbConfFile.set_label("Conf file");
  41.248 +
  41.249 +    Gtk::RadioButtonGroup group = rbLgfFile.get_group();
  41.250 +    rbConfFile.set_group(group);
  41.251 +
  41.252 +    switch (pMapStorage->getGUIDataSaveLocation())
  41.253 +    {
  41.254 +      case MapStorage::LGF_FILE:
  41.255 +        rbLgfFile.set_active();
  41.256 +        break;
  41.257 +      case MapStorage::CONF_FILE:
  41.258 +        rbConfFile.set_active();
  41.259 +        break;
  41.260 +    }
  41.261 +
  41.262 +    Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
  41.263 +    box1->pack_start(*box2, Gtk::PACK_SHRINK);
  41.264 +
  41.265 +    Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
  41.266 +    box2->pack_start(*fill1, Gtk::PACK_SHRINK);
  41.267 +
  41.268 +    Gtk::VBox* box3 = Gtk::manage(new Gtk::VBox);
  41.269 +    box2->pack_start(*box3, Gtk::PACK_SHRINK);
  41.270 +
  41.271 +    box3->pack_start(rbLgfFile, Gtk::PACK_SHRINK);
  41.272 +    box3->pack_start(rbConfFile, Gtk::PACK_SHRINK);
  41.273 +
  41.274 +    rbLgfFile.signal_toggled().connect(
  41.275 +        sigc::mem_fun(*this, &SaveDetailsWidget::onGuiSectSaveDestChanged));
  41.276 +    rbConfFile.signal_toggled().connect(
  41.277 +        sigc::mem_fun(*this, &SaveDetailsWidget::onGuiSectSaveDestChanged));
  41.278 +  }
  41.279 +
  41.280 +  // child widgets of vbNodeMaps
  41.281 +
  41.282 +  {
  41.283 +    Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6));
  41.284 +    vbNodeMaps->pack_start(*box1, Gtk::PACK_SHRINK);
  41.285 +
  41.286 +    Gtk::Label* label1 =
  41.287 +      Gtk::manage(new Gtk::Label("<b>Save Destination</b>"));
  41.288 +    label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
  41.289 +    label1->set_use_markup();
  41.290 +    box1->pack_start(*label1, Gtk::PACK_SHRINK);
  41.291 +
  41.292 +    Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
  41.293 +    box1->pack_start(*box2, Gtk::PACK_SHRINK);
  41.294 +
  41.295 +    Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
  41.296 +    box2->pack_start(*fill1, Gtk::PACK_SHRINK);
  41.297 +
  41.298 +    Gtk::Frame* frame = Gtk::manage(new Gtk::Frame);
  41.299 +    box2->pack_start(*frame, Gtk::PACK_EXPAND_WIDGET);
  41.300 +
  41.301 +    Gtk::ScrolledWindow* swNodeMaps = Gtk::manage(new Gtk::ScrolledWindow);
  41.302 +    frame->add(*swNodeMaps);
  41.303 +
  41.304 +    swNodeMaps->add(twNodeMaps);
  41.305 +
  41.306 +    refNodeMapStore = Gtk::ListStore::create(NodeMapColumns);
  41.307 +
  41.308 +    std::vector<std::string> node_maps = pMapStorage->getNodeMapList();
  41.309 +    for (std::vector<std::string>::const_iterator it = node_maps.begin();
  41.310 +        it != node_maps.end(); ++it)
  41.311 +    {
  41.312 +      Gtk::TreeModel::Row row = *(refNodeMapStore->append());
  41.313 +      row[NodeMapColumns.colName] = *it;
  41.314 +      switch (pMapStorage->getNodeMapSaveDest(*it))
  41.315 +      {
  41.316 +        case MapStorage::GUI_SECT:
  41.317 +          row[NodeMapColumns.colSaveToMainSect] = false;
  41.318 +          row[NodeMapColumns.colSaveToGuiSect] = true;
  41.319 +          break;
  41.320 +        case MapStorage::NESET_SECT:
  41.321 +          row[NodeMapColumns.colSaveToMainSect] = true;
  41.322 +          row[NodeMapColumns.colSaveToGuiSect] = false;
  41.323 +          break;
  41.324 +        case MapStorage::DONT_SAVE:
  41.325 +          row[NodeMapColumns.colSaveToMainSect] = false;
  41.326 +          row[NodeMapColumns.colSaveToGuiSect] = false;
  41.327 +          break;
  41.328 +      }
  41.329 +    }
  41.330 +
  41.331 +    twNodeMaps.set_model(refNodeMapStore);
  41.332 +    twNodeMaps.append_column("Name", NodeMapColumns.colName);
  41.333 +    twNodeMaps.append_column_editable("Nodeset section",
  41.334 +        NodeMapColumns.colSaveToMainSect);
  41.335 +    twNodeMaps.append_column_editable("GUI section",
  41.336 +        NodeMapColumns.colSaveToGuiSect);
  41.337 +
  41.338 +    swNodeMaps->set_size_request(-1, 200);
  41.339 +    swNodeMaps->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
  41.340 +
  41.341 +    refNodeMapStore->signal_row_changed().connect(
  41.342 +        sigc::mem_fun(*this, &SaveDetailsWidget::onNodeMapRowChanged));
  41.343 +  }
  41.344 +
  41.345 +  // child widgets of vbEdgeMaps
  41.346 +
  41.347 +  {
  41.348 +    Gtk::VBox* box1 = Gtk::manage(new Gtk::VBox(false, 6));
  41.349 +    vbEdgeMaps->pack_start(*box1, Gtk::PACK_SHRINK);
  41.350 +
  41.351 +    Gtk::Label* label1 =
  41.352 +      Gtk::manage(new Gtk::Label("<b>Save Destination</b>"));
  41.353 +    label1->set_alignment(Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER);
  41.354 +    label1->set_use_markup();
  41.355 +    box1->pack_start(*label1, Gtk::PACK_SHRINK);
  41.356 +
  41.357 +    Gtk::HBox* box2 = Gtk::manage(new Gtk::HBox);
  41.358 +    box1->pack_start(*box2, Gtk::PACK_SHRINK);
  41.359 +
  41.360 +    Gtk::Label* fill1 = Gtk::manage(new Gtk::Label("    "));
  41.361 +    box2->pack_start(*fill1, Gtk::PACK_SHRINK);
  41.362 +
  41.363 +    Gtk::Frame* frame = Gtk::manage(new Gtk::Frame);
  41.364 +    box2->pack_start(*frame, Gtk::PACK_EXPAND_WIDGET);
  41.365 +
  41.366 +    Gtk::ScrolledWindow* swEdgeMaps = Gtk::manage(new Gtk::ScrolledWindow);
  41.367 +    frame->add(*swEdgeMaps);
  41.368 +
  41.369 +    swEdgeMaps->add(twEdgeMaps);
  41.370 +
  41.371 +    refEdgeMapStore = Gtk::ListStore::create(EdgeMapColumns);
  41.372 +
  41.373 +    std::vector<std::string> edge_maps = pMapStorage->getEdgeMapList();
  41.374 +    for (std::vector<std::string>::const_iterator it = edge_maps.begin();
  41.375 +        it != edge_maps.end(); ++it)
  41.376 +    {
  41.377 +      Gtk::TreeModel::Row row = *(refEdgeMapStore->append());
  41.378 +      row[EdgeMapColumns.colName] = *it;
  41.379 +      switch (pMapStorage->getEdgeMapSaveDest(*it))
  41.380 +      {
  41.381 +        case MapStorage::GUI_SECT:
  41.382 +          row[EdgeMapColumns.colSaveToMainSect] = false;
  41.383 +          row[EdgeMapColumns.colSaveToGuiSect] = true;
  41.384 +          break;
  41.385 +        case MapStorage::NESET_SECT:
  41.386 +          row[EdgeMapColumns.colSaveToMainSect] = true;
  41.387 +          row[EdgeMapColumns.colSaveToGuiSect] = false;
  41.388 +          break;
  41.389 +        case MapStorage::DONT_SAVE:
  41.390 +          row[EdgeMapColumns.colSaveToMainSect] = false;
  41.391 +          row[EdgeMapColumns.colSaveToGuiSect] = false;
  41.392 +          break;
  41.393 +      }
  41.394 +    }
  41.395 +
  41.396 +    twEdgeMaps.set_model(refEdgeMapStore);
  41.397 +    twEdgeMaps.append_column("Name", EdgeMapColumns.colName);
  41.398 +    twEdgeMaps.append_column_editable("Edgeset section",
  41.399 +        EdgeMapColumns.colSaveToMainSect);
  41.400 +    twEdgeMaps.append_column_editable("GUI section",
  41.401 +        EdgeMapColumns.colSaveToGuiSect);
  41.402 +
  41.403 +    swEdgeMaps->set_size_request(-1, 200);
  41.404 +    swEdgeMaps->set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
  41.405 +
  41.406 +    refEdgeMapStore->signal_row_changed().connect(
  41.407 +        sigc::mem_fun(*this, &SaveDetailsWidget::onEdgeMapRowChanged));
  41.408 +  }
  41.409 +
  41.410 +  show_all_children();
  41.411 +}
  41.412 +
  41.413 +void SaveDetailsWidget::onGuiSectSaveDestChanged()
  41.414 +{
  41.415 +  if (rbLgfFile.get_active())
  41.416 +  {
  41.417 +    pMapStorage->setGUIDataSaveLocation(MapStorage::LGF_FILE);
  41.418 +  }
  41.419 +  else if (rbConfFile.get_active())
  41.420 +  {
  41.421 +    pMapStorage->setGUIDataSaveLocation(MapStorage::CONF_FILE);
  41.422 +  }
  41.423 +}
  41.424 +
  41.425 +void SaveDetailsWidget::onEdgeMapRowChanged(const Gtk::TreeModel::Path& path,
  41.426 +    const Gtk::TreeModel::iterator& iter)
  41.427 +{
  41.428 +  Gtk::TreeModel::Row row = *iter;
  41.429 +  Glib::ustring map_name = row[EdgeMapColumns.colName];
  41.430 +  if (row[EdgeMapColumns.colSaveToMainSect] &&
  41.431 +      row[EdgeMapColumns.colSaveToGuiSect])
  41.432 +  {
  41.433 +    if (pMapStorage->getEdgeMapSaveDest(map_name) == MapStorage::NESET_SECT)
  41.434 +    {
  41.435 +      pMapStorage->setEdgeMapSaveDest(map_name, MapStorage::GUI_SECT);
  41.436 +      row[EdgeMapColumns.colSaveToMainSect] = false;
  41.437 +    }
  41.438 +    else
  41.439 +    {
  41.440 +      pMapStorage->setEdgeMapSaveDest(map_name, MapStorage::NESET_SECT);
  41.441 +      row[EdgeMapColumns.colSaveToGuiSect] = false;
  41.442 +    }
  41.443 +  }
  41.444 +  else if (row[EdgeMapColumns.colSaveToMainSect])
  41.445 +  {
  41.446 +    pMapStorage->setEdgeMapSaveDest(map_name, MapStorage::NESET_SECT);
  41.447 +  }
  41.448 +  else if (row[EdgeMapColumns.colSaveToGuiSect])
  41.449 +  {
  41.450 +    pMapStorage->setEdgeMapSaveDest(map_name, MapStorage::GUI_SECT);
  41.451 +  }
  41.452 +  else
  41.453 +  {
  41.454 +    pMapStorage->setEdgeMapSaveDest(map_name, MapStorage::DONT_SAVE);
  41.455 +  }
  41.456 +}
  41.457 +
  41.458 +void SaveDetailsWidget::onNodeMapRowChanged(const Gtk::TreeModel::Path& path,
  41.459 +    const Gtk::TreeModel::iterator& iter)
  41.460 +{
  41.461 +  Gtk::TreeModel::Row row = *iter;
  41.462 +  Glib::ustring map_name = row[NodeMapColumns.colName];
  41.463 +  if (row[NodeMapColumns.colSaveToMainSect] &&
  41.464 +      row[NodeMapColumns.colSaveToGuiSect])
  41.465 +  {
  41.466 +    if (pMapStorage->getNodeMapSaveDest(map_name) == MapStorage::NESET_SECT)
  41.467 +    {
  41.468 +      pMapStorage->setNodeMapSaveDest(map_name, MapStorage::GUI_SECT);
  41.469 +      row[NodeMapColumns.colSaveToMainSect] = false;
  41.470 +    }
  41.471 +    else
  41.472 +    {
  41.473 +      pMapStorage->setNodeMapSaveDest(map_name, MapStorage::NESET_SECT);
  41.474 +      row[NodeMapColumns.colSaveToGuiSect] = false;
  41.475 +    }
  41.476 +  }
  41.477 +  else if (row[NodeMapColumns.colSaveToMainSect])
  41.478 +  {
  41.479 +    pMapStorage->setNodeMapSaveDest(map_name, MapStorage::NESET_SECT);
  41.480 +  }
  41.481 +  else if (row[NodeMapColumns.colSaveToGuiSect])
  41.482 +  {
  41.483 +    pMapStorage->setNodeMapSaveDest(map_name, MapStorage::GUI_SECT);
  41.484 +  }
  41.485 +  else
  41.486 +  {
  41.487 +    pMapStorage->setNodeMapSaveDest(map_name, MapStorage::DONT_SAVE);
  41.488 +  }
  41.489 +}
  41.490 +
  41.491 +void SaveDetailsWidget::onNodeCoordSaveDestChanged()
  41.492 +{
  41.493 +  if (rbNodeCoordGuiSection.get_active())
  41.494 +  {
  41.495 +    pMapStorage->setNodeCoordsSaveDest(MapStorage::SpecMapSaveOpts::GUI_SECT);
  41.496 +    rbNodeCoordOneMap.set_sensitive(false);
  41.497 +    rbNodeCoordTwoMaps.set_sensitive(false);
  41.498 +    entNodeCoordsOneMap.set_sensitive(false);
  41.499 +    entNodeCoordsTwoMaps1.set_sensitive(false);
  41.500 +    entNodeCoordsTwoMaps2.set_sensitive(false);
  41.501 +  }
  41.502 +  else if (rbNodeCoordNodesetSection.get_active())
  41.503 +  {
  41.504 +    pMapStorage->setNodeCoordsSaveDest(MapStorage::SpecMapSaveOpts::NESET_SECT);
  41.505 +    rbNodeCoordOneMap.set_sensitive(true);
  41.506 +    rbNodeCoordTwoMaps.set_sensitive(true);
  41.507 +    switch (pMapStorage->getNodeCoordsSaveMapNum())
  41.508 +    {
  41.509 +      case MapStorage::SpecMapSaveOpts::ONE_MAP:
  41.510 +        entNodeCoordsOneMap.set_sensitive(true);
  41.511 +        entNodeCoordsTwoMaps1.set_sensitive(false);
  41.512 +        entNodeCoordsTwoMaps2.set_sensitive(false);
  41.513 +        break;
  41.514 +      case MapStorage::SpecMapSaveOpts::TWO_MAPS:
  41.515 +        entNodeCoordsOneMap.set_sensitive(false);
  41.516 +        entNodeCoordsTwoMaps1.set_sensitive(true);
  41.517 +        entNodeCoordsTwoMaps2.set_sensitive(true);
  41.518 +        break;
  41.519 +    }
  41.520 +  }
  41.521 +}
  41.522 +
  41.523 +void SaveDetailsWidget::onNodeCoordMapNumChanged()
  41.524 +{
  41.525 +  if (rbNodeCoordOneMap.get_active())
  41.526 +  {
  41.527 +    pMapStorage->setNodeCoordsSaveMapNum(MapStorage::SpecMapSaveOpts::ONE_MAP);
  41.528 +    entNodeCoordsOneMap.set_sensitive(true);
  41.529 +    entNodeCoordsTwoMaps1.set_sensitive(false);
  41.530 +    entNodeCoordsTwoMaps2.set_sensitive(false);
  41.531 +  }
  41.532 +  else if (rbNodeCoordTwoMaps.get_active())
  41.533 +  {
  41.534 +    pMapStorage->setNodeCoordsSaveMapNum(MapStorage::SpecMapSaveOpts::TWO_MAPS);
  41.535 +    entNodeCoordsOneMap.set_sensitive(false);
  41.536 +    entNodeCoordsTwoMaps1.set_sensitive(true);
  41.537 +    entNodeCoordsTwoMaps2.set_sensitive(true);
  41.538 +  }
  41.539 +}
  41.540 +
  41.541 +void SaveDetailsWidget::onNodeCoordsOneMapName()
  41.542 +{
  41.543 +  pMapStorage->setNodeCoordsOneMapName(entNodeCoordsOneMap.get_text());
  41.544 +}
  41.545 +void SaveDetailsWidget::onNodeCoordsTwoMaps1Name()
  41.546 +{
  41.547 +  pMapStorage->setNodeCoordsTwoMaps1Name(entNodeCoordsTwoMaps1.get_text());
  41.548 +}
  41.549 +void SaveDetailsWidget::onNodeCoordsTwoMaps2Name()
  41.550 +{
  41.551 +  pMapStorage->setNodeCoordsTwoMaps2Name(entNodeCoordsTwoMaps2.get_text());
  41.552 +}
  41.553 +
  41.554 +void SaveDetailsWidget::onArrowCoordSaveDestChanged()
  41.555 +{
  41.556 +  if (rbArrowCoordGuiSection.get_active())
  41.557 +  {
  41.558 +    pMapStorage->setArrowCoordsSaveDest(MapStorage::SpecMapSaveOpts::GUI_SECT);
  41.559 +    rbArrowCoordOneMap.set_sensitive(false);
  41.560 +    rbArrowCoordTwoMaps.set_sensitive(false);
  41.561 +    entArrowCoordsOneMap.set_sensitive(false);
  41.562 +    entArrowCoordsTwoMaps1.set_sensitive(false);
  41.563 +    entArrowCoordsTwoMaps2.set_sensitive(false);
  41.564 +  }
  41.565 +  else if (rbArrowCoordEdgesetSection.get_active())
  41.566 +  {
  41.567 +    pMapStorage->setArrowCoordsSaveDest(MapStorage::SpecMapSaveOpts::NESET_SECT);
  41.568 +    rbArrowCoordOneMap.set_sensitive(true);
  41.569 +    rbArrowCoordTwoMaps.set_sensitive(true);
  41.570 +    switch (pMapStorage->getArrowCoordsSaveMapNum())
  41.571 +    {
  41.572 +      case MapStorage::SpecMapSaveOpts::ONE_MAP:
  41.573 +        entArrowCoordsOneMap.set_sensitive(true);
  41.574 +        entArrowCoordsTwoMaps1.set_sensitive(false);
  41.575 +        entArrowCoordsTwoMaps2.set_sensitive(false);
  41.576 +        break;
  41.577 +      case MapStorage::SpecMapSaveOpts::TWO_MAPS:
  41.578 +        entArrowCoordsOneMap.set_sensitive(false);
  41.579 +        entArrowCoordsTwoMaps1.set_sensitive(true);
  41.580 +        entArrowCoordsTwoMaps2.set_sensitive(true);
  41.581 +        break;
  41.582 +    }
  41.583 +  }
  41.584 +}
  41.585 +
  41.586 +void SaveDetailsWidget::onArrowCoordMapNumChanged()
  41.587 +{
  41.588 +  if (rbArrowCoordOneMap.get_active())
  41.589 +  {
  41.590 +    pMapStorage->setArrowCoordsSaveMapNum(MapStorage::SpecMapSaveOpts::ONE_MAP);
  41.591 +    entArrowCoordsOneMap.set_sensitive(true);
  41.592 +    entArrowCoordsTwoMaps1.set_sensitive(false);
  41.593 +    entArrowCoordsTwoMaps2.set_sensitive(false);
  41.594 +  }
  41.595 +  else if (rbArrowCoordTwoMaps.get_active())
  41.596 +  {
  41.597 +    pMapStorage->setArrowCoordsSaveMapNum(MapStorage::SpecMapSaveOpts::TWO_MAPS);
  41.598 +    entArrowCoordsOneMap.set_sensitive(false);
  41.599 +    entArrowCoordsTwoMaps1.set_sensitive(true);
  41.600 +    entArrowCoordsTwoMaps2.set_sensitive(true);
  41.601 +  }
  41.602 +}
  41.603 +
  41.604 +void SaveDetailsWidget::onArrowCoordsOneMapName()
  41.605 +{
  41.606 +  pMapStorage->setArrowCoordsOneMapName(entArrowCoordsOneMap.get_text());
  41.607 +}
  41.608 +void SaveDetailsWidget::onArrowCoordsTwoMaps1Name()
  41.609 +{
  41.610 +  pMapStorage->setArrowCoordsTwoMaps1Name(entArrowCoordsTwoMaps1.get_text());
  41.611 +}
  41.612 +void SaveDetailsWidget::onArrowCoordsTwoMaps2Name()
  41.613 +{
  41.614 +  pMapStorage->setArrowCoordsTwoMaps2Name(entArrowCoordsTwoMaps2.get_text());
  41.615 +}
  41.616 +
  41.617 +SaveDetailsWidget::~SaveDetailsWidget()
  41.618 +{
  41.619 +}
    42.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    42.2 +++ b/save_details_widget.h	Wed Jan 02 21:03:09 2008 +0000
    42.3 @@ -0,0 +1,86 @@
    42.4 +#ifndef SAVE_DETAILS_WIDGET
    42.5 +#define SAVE_DETAILS_WIDGET
    42.6 +
    42.7 +#include <gtkmm/box.h>
    42.8 +#include <gtkmm/radiobutton.h>
    42.9 +#include <gtkmm/label.h>
   42.10 +#include <gtkmm/notebook.h>
   42.11 +#include <gtkmm/treemodel.h>
   42.12 +#include <gtkmm/liststore.h>
   42.13 +#include <gtkmm/treeview.h>
   42.14 +#include <gtkmm/scrolledwindow.h>
   42.15 +
   42.16 +class MapStorage;
   42.17 +
   42.18 +class SaveDetailsWidget : public Gtk::VBox
   42.19 +{
   42.20 +  public:
   42.21 +    struct MapModelColumns : public Gtk::TreeModel::ColumnRecord
   42.22 +    {
   42.23 +      MapModelColumns()
   42.24 +      {
   42.25 +        add(colName);
   42.26 +        add(colSaveToMainSect);
   42.27 +        add(colSaveToGuiSect);
   42.28 +      }
   42.29 +      Gtk::TreeModelColumn<Glib::ustring> colName;
   42.30 +      Gtk::TreeModelColumn<bool> colSaveToMainSect;
   42.31 +      Gtk::TreeModelColumn<bool> colSaveToGuiSect;
   42.32 +    };
   42.33 +  private:
   42.34 +    Gtk::RadioButton rbLgfFile;
   42.35 +    Gtk::RadioButton rbConfFile;
   42.36 +
   42.37 +    Gtk::TreeView twNodeMaps;
   42.38 +    Gtk::TreeView twEdgeMaps;
   42.39 +
   42.40 +    MapModelColumns NodeMapColumns;
   42.41 +    MapModelColumns EdgeMapColumns;
   42.42 +
   42.43 +    Glib::RefPtr<Gtk::ListStore> refNodeMapStore;
   42.44 +    Glib::RefPtr<Gtk::ListStore> refEdgeMapStore;
   42.45 +
   42.46 +    Gtk::RadioButton rbNodeCoordGuiSection;
   42.47 +    Gtk::RadioButton rbNodeCoordNodesetSection;
   42.48 +    Gtk::RadioButton rbNodeCoordOneMap;
   42.49 +    Gtk::RadioButton rbNodeCoordTwoMaps;
   42.50 +    Gtk::Entry entNodeCoordsOneMap;
   42.51 +    Gtk::Entry entNodeCoordsTwoMaps1;
   42.52 +    Gtk::Entry entNodeCoordsTwoMaps2;
   42.53 +
   42.54 +    Gtk::RadioButton rbArrowCoordGuiSection;
   42.55 +    Gtk::RadioButton rbArrowCoordEdgesetSection;
   42.56 +    Gtk::RadioButton rbArrowCoordOneMap;
   42.57 +    Gtk::RadioButton rbArrowCoordTwoMaps;
   42.58 +    Gtk::Entry entArrowCoordsOneMap;
   42.59 +    Gtk::Entry entArrowCoordsTwoMaps1;
   42.60 +    Gtk::Entry entArrowCoordsTwoMaps2;
   42.61 +
   42.62 +    MapStorage* pMapStorage;
   42.63 +
   42.64 +    void onGuiSectSaveDestChanged();
   42.65 +
   42.66 +    void onNodeCoordSaveDestChanged();
   42.67 +    void onNodeCoordMapNumChanged();
   42.68 +
   42.69 +    void onNodeCoordsOneMapName();
   42.70 +    void onNodeCoordsTwoMaps1Name();
   42.71 +    void onNodeCoordsTwoMaps2Name();
   42.72 +
   42.73 +    void onArrowCoordSaveDestChanged();
   42.74 +    void onArrowCoordMapNumChanged();
   42.75 +
   42.76 +    void onArrowCoordsOneMapName();
   42.77 +    void onArrowCoordsTwoMaps1Name();
   42.78 +    void onArrowCoordsTwoMaps2Name();
   42.79 +
   42.80 +    void onEdgeMapRowChanged(const Gtk::TreeModel::Path& path,
   42.81 +        const Gtk::TreeModel::iterator& iter);
   42.82 +    void onNodeMapRowChanged(const Gtk::TreeModel::Path& path,
   42.83 +        const Gtk::TreeModel::iterator& iter);
   42.84 +  public:
   42.85 +    SaveDetailsWidget(MapStorage* ms);
   42.86 +    ~SaveDetailsWidget();
   42.87 +};
   42.88 +
   42.89 +#endif
    43.1 --- a/xml.h	Wed May 02 20:33:58 2007 +0000
    43.2 +++ b/xml.h	Wed Jan 02 21:03:09 2008 +0000
    43.3 @@ -16,6 +16,9 @@
    43.4   *
    43.5   */
    43.6  
    43.7 +#ifndef GLEMON_XML_H
    43.8 +#define GLEMON_XML_H
    43.9 +
   43.10  #include <iostream>
   43.11  #include <string>
   43.12  #include <vector>
   43.13 @@ -442,3 +445,4 @@
   43.14    
   43.15  }
   43.16  
   43.17 +#endif