Index: graph_displayer_canvas.cc
===================================================================
--- graph_displayer_canvas.cc	(revision 201)
+++ graph_displayer_canvas.cc	(revision 204)
@@ -17,13 +17,11 @@
  */
 
-#include <mapstorage.h>
-#include <nbtab.h>
-#include <graph_displayer_canvas.h>
+#include "graph_displayer_canvas.h"
 #include <lemon/random.h>
 #include <cmath>
 
 GraphDisplayerCanvas::GraphDisplayerCanvas(NoteBookTab & mainw) :
-  nodesmap(mainw.mapstorage->graph), edgesmap(mainw.mapstorage->graph), edgetextmap(mainw.mapstorage->graph),
-  nodetextmap(mainw.mapstorage->graph), displayed_graph(*(root()), 0, 0),
+  nodesmap(mainw.mapstorage.graph), edgesmap(mainw.mapstorage.graph), edgetextmap(mainw.mapstorage.graph),
+  nodetextmap(mainw.mapstorage.graph), displayed_graph(*(root()), 0, 0),
   isbutton(0), active_item(NULL), target_item(NULL), nodemap_to_edit(""),
   edgemap_to_edit(""), autoscale(true), zoomtrack(false), radius_size(20), edge_width(10),
@@ -52,9 +50,9 @@
     delete background;
   }
-  if (mytab.mapstorage->isBackgroundSet())
+  if (mytab.mapstorage.isBackgroundSet())
   {
     background_set = true;
     refBackground = Gdk::Pixbuf::create_from_file(
-      mytab.mapstorage->getBackgroundFilename());
+      mytab.mapstorage.getBackgroundFilename());
     background = new Gnome::Canvas::Pixbuf(
         *(root()),
@@ -72,14 +70,14 @@
 GraphDisplayerCanvas::~GraphDisplayerCanvas()
 {
-  for (NodeIt n((mytab.mapstorage)->graph); n != INVALID; ++n)
+  for (NodeIt n((mytab.mapstorage).graph); n != INVALID; ++n)
     {
       delete nodesmap[n];
-      delete nodetextmap[n];
+      //      delete nodetextmap[n];
     }
   
-  for (EdgeIt e((mytab.mapstorage)->graph); e != INVALID; ++e)
+  for (EdgeIt e((mytab.mapstorage).graph); e != INVALID; ++e)
     {
       delete edgesmap[e];
-      delete edgetextmap[e];
+      //      delete edgetextmap[e];
     }
 }
@@ -118,55 +116,44 @@
 
   if(is_drawn)
-  {
-    if(mapname!="")
-    {
-      std::vector<std::string> nodemaps = mytab.mapstorage->getNodeMapList();
-      bool found = false;
-      for (std::vector<std::string>::const_iterator it = nodemaps.begin();
-          it != nodemaps.end(); ++it)
-      {
-        if (*it == mapname)
-        {
-          found = true;
-          break;
-        }
-      }
-      if (found)
-      {
-        switch(prop)
-        {
-          case N_RADIUS:
-            changeNodeRadius(mapname, node);
-            break;
-          case N_COLOR:
-            changeNodeColor(mapname, node);
-            break;
-          case N_TEXT:
-            changeNodeText(mapname, node);
-            break;
-          default:
-            std::cerr<<"Error\n";
-        }
-      }
-    }
-    else //mapname==""
-    {
-      Node node=INVALID;
-      switch(prop)
-      {
-        case N_RADIUS:
-          resetNodeRadius(node);
-          break;
-        case N_COLOR:
-          resetNodeColor(node);
-          break;
-        case N_TEXT:
-          resetNodeText(node);
-          break;
-        default:
-          std::cerr<<"Error\n";
-      }
-    }
-  }
+    {
+      if(mapname!="")
+	{
+	  if( ( ((mytab.mapstorage).nodemap_storage).find(mapname) != ((mytab.mapstorage).nodemap_storage).end() ) )
+	    {
+	      switch(prop)
+		{
+		case N_RADIUS:
+		  changeNodeRadius(mapname, node);
+		  break;
+		case N_COLOR:
+		  changeNodeColor(mapname, node);
+		  break;
+		case N_TEXT:
+		  changeNodeText(mapname, node);
+		  break;
+		default:
+		  std::cerr<<"Error\n";
+		}
+	    }
+	}
+      else //mapname==""
+	{
+	  Node node=INVALID;	
+	  switch(prop)
+	    {
+	    case N_RADIUS:
+	      resetNodeRadius(node);
+	      break;
+	    case N_COLOR:
+	      resetNodeColor(node);
+	      break;
+	    case N_TEXT:
+	      resetNodeText(node);
+	      break;
+	    default:
+	      std::cerr<<"Error\n";
+	    }
+	}
+    }
 }
 
@@ -176,54 +163,43 @@
 
   if(is_drawn)
-  {
-    if(mapname!="")
-    {
-      std::vector<std::string> edgemaps = mytab.mapstorage->getEdgeMapList();
-      bool found = false;
-      for (std::vector<std::string>::const_iterator it = edgemaps.begin();
-          it != edgemaps.end(); ++it)
-      {
-        if (*it == mapname)
-        {
-          found = true;
-          break;
-        }
-      }
-      if (found)
-      {
-        switch(prop)
-        {
-          case E_WIDTH:
-            changeEdgeWidth(mapname, edge);
-            break;
-          case E_COLOR:
-            changeEdgeColor(mapname, edge);
-            break;
-          case E_TEXT:
-            changeEdgeText(mapname, edge);
-            break;
-          default:
-            std::cerr<<"Error\n";
-        }
-      }
-    }
-    else //mapname==""
-    {
-      switch(prop)
-      {
-        case E_WIDTH:
-          resetEdgeWidth(edge);
-          break;
-        case E_COLOR:
-          resetEdgeColor(edge);
-          break;
-        case E_TEXT:
-          resetEdgeText(edge);
-          break;
-        default:
-          std::cerr<<"Error\n";
-      }
-    }
-  }
+    {
+      if(mapname!="")
+	{
+	  if( ( ((mytab.mapstorage).edgemap_storage).find(mapname) != ((mytab.mapstorage).edgemap_storage).end() ) )
+	    {
+	      switch(prop)
+		{
+		case E_WIDTH:
+		  changeEdgeWidth(mapname, edge);
+		  break;
+		case E_COLOR:
+		  changeEdgeColor(mapname, edge);
+		  break;
+		case E_TEXT:
+		  changeEdgeText(mapname, edge);
+		  break;
+		default:
+		  std::cerr<<"Error\n";
+		}
+	    }
+	}
+      else //mapname==""
+	{
+	  switch(prop)
+	    {
+	    case E_WIDTH:
+	      resetEdgeWidth(edge);
+	      break;
+	    case E_COLOR:
+	      resetEdgeColor(edge);
+	      break;
+	    case E_TEXT:
+	      resetEdgeText(edge);
+	      break;
+	    default:
+	      std::cerr<<"Error\n";
+	    }
+	}
+    }
 }
 
@@ -232,7 +208,7 @@
   //first edges are drawn, to hide joining with nodes later
 
-  for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
-  {
-    if (mytab.mapstorage->graph.source(i) == mytab.mapstorage->graph.target(i))
+  for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
+  {
+    if (mytab.mapstorage.graph.source(i) == mytab.mapstorage.graph.target(i))
     {
       edgesmap[i]=new LoopEdge(displayed_graph, i, *this);
@@ -244,16 +220,16 @@
     //initializing edge-text as well, to empty string
 
-    XY text_pos=mytab.mapstorage->getArrowCoords(i);
+    XY text_pos=mytab.mapstorage.arrow_pos[i];
     text_pos+=(XY(10,10));
 
-    edgetextmap[i]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, "");
-    edgetextmap[i]->property_fill_color().set_value("darkgreen");
-    edgetextmap[i]->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::mapEditEventHandler), false);
-    edgetextmap[i]->raise_to_top();
+//     edgetextmap[i]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, "");
+//     edgetextmap[i]->property_fill_color().set_value("darkgreen");
+//     edgetextmap[i]->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::mapEditEventHandler), false);
+//     edgetextmap[i]->raise_to_top();
   }
 
   //afterwards nodes come to be drawn
 
-  for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
+  for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
   {
     //drawing bule nodes, with black line around them
@@ -261,8 +237,8 @@
     nodesmap[i]=new Gnome::Canvas::Ellipse(
         displayed_graph,
-        mytab.mapstorage->getNodeCoords(i).x-20,
-        mytab.mapstorage->getNodeCoords(i).y-20,
-        mytab.mapstorage->getNodeCoords(i).x+20,
-        mytab.mapstorage->getNodeCoords(i).y+20);
+        (mytab.mapstorage).coords[i].x-20,
+        (mytab.mapstorage).coords[i].y-20,
+        (mytab.mapstorage).coords[i].x+20,
+        (mytab.mapstorage).coords[i].y+20);
     *(nodesmap[i]) << Gnome::Canvas::Properties::fill_color("blue");
     *(nodesmap[i]) << Gnome::Canvas::Properties::outline_color("black");
@@ -272,12 +248,12 @@
 
     XY text_pos(
-        (mytab.mapstorage->getNodeCoords(i).x+node_property_defaults[N_RADIUS]+5),
-        (mytab.mapstorage->getNodeCoords(i).y+node_property_defaults[N_RADIUS]+5));
-
-    nodetextmap[i]=new Gnome::Canvas::Text(displayed_graph,
-        text_pos.x, text_pos.y, "");
-    nodetextmap[i]->property_fill_color().set_value("darkblue");
-    nodetextmap[i]->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::mapEditEventHandler), false);
-    nodetextmap[i]->raise_to_top();
+        ((mytab.mapstorage).coords[i].x+node_property_defaults[N_RADIUS]+5),
+        ((mytab.mapstorage).coords[i].y+node_property_defaults[N_RADIUS]+5));
+
+//     nodetextmap[i]=new Gnome::Canvas::Text(displayed_graph,
+//         text_pos.x, text_pos.y, "");
+//     nodetextmap[i]->property_fill_color().set_value("darkblue");
+//     nodetextmap[i]->signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::mapEditEventHandler), false);
+//     nodetextmap[i]->raise_to_top();
   }
 
@@ -306,14 +282,14 @@
   forming_edge=INVALID;
 
-  for (NodeIt n((mytab.mapstorage)->graph); n != INVALID; ++n)
+  for (NodeIt n((mytab.mapstorage).graph); n != INVALID; ++n)
   {
     delete nodesmap[n];
-    delete nodetextmap[n];
-  }
-
-  for (EdgeIt e((mytab.mapstorage)->graph); e != INVALID; ++e)
+    //    delete nodetextmap[n];
+  }
+
+  for (EdgeIt e((mytab.mapstorage).graph); e != INVALID; ++e)
   {
     delete edgesmap[e];
-    delete edgetextmap[e];
+    //    delete edgetextmap[e];
   }
 
@@ -348,114 +324,110 @@
 void GraphDisplayerCanvas::reDesignGraph()
 {
-  MapStorage& ms = *mytab.mapstorage;
-  NodeIt firstnode(ms.graph);
-  //is it not an empty graph?
-  if(firstnode!=INVALID)
-    {
-      double max_coord=50000;
-      double min_dist=20;
-      double init_vector_length=25;
-
-      if(!was_redesigned)
-	{
-	  NodeIt i(ms.graph);
-
-	  dim2::Point<double> init(init_vector_length*rnd(),
-				   init_vector_length*rnd());
-	  moveNode(init.x, init.y, nodesmap[i], i);
-	  was_redesigned=true;
-	}
-
-      double attraction;
-      double propulsation;
-      int iterations;
-
-      ms.get_design_data(attraction, propulsation, iterations);
-
-      //iteration counter
-      for(int l=0;l<iterations;l++)
-	{
-	  Graph::NodeMap<double> x(ms.graph);
-	  Graph::NodeMap<double> y(ms.graph);
-	  XYMap<Graph::NodeMap<double> > actual_forces;
-	  actual_forces.setXMap(x);
-	  actual_forces.setYMap(y);
-
-	  //count actual force for each nodes
-	  for (NodeIt i(ms.graph); i!=INVALID; ++i)
-	    {
-	      //propulsation of nodes
-	      for (NodeIt j(ms.graph); j!=INVALID; ++j)
+  double max_coord=50000;
+  double min_dist=20;
+  double init_vector_length=25;
+
+  if(!was_redesigned)
+    {
+      NodeIt i((mytab.mapstorage).graph);
+
+      dim2::Point<double> init(init_vector_length*rnd(),
+			       init_vector_length*rnd());
+      moveNode(init.x, init.y, nodesmap[i], i);
+      was_redesigned=true;
+    }
+
+  double attraction;
+  double propulsation;
+  int iterations;
+
+  (mytab.mapstorage).get_design_data(attraction, propulsation, iterations);
+
+  //iteration counter
+  for(int l=0;l<iterations;l++)
+    {
+      Graph::NodeMap<double> x(mytab.mapstorage.graph);
+      Graph::NodeMap<double> y(mytab.mapstorage.graph);
+      XYMap<Graph::NodeMap<double> > actual_forces;
+      actual_forces.setXMap(x);
+      actual_forces.setYMap(y);
+
+      //count actual force for each nodes
+      for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
+	{
+	  //propulsation of nodes
+	  for (NodeIt j((mytab.mapstorage).graph); j!=INVALID; ++j)
+	    {
+	      if(i!=j)
 		{
-		  if(i!=j)
-		    {
-		      lemon::dim2::Point<double> delta =
-			(ms.getNodeCoords(i)-
-			 ms.getNodeCoords(j));
-
-		      const double length_sqr=std::max(delta.normSquare(),min_dist);
-
-		      //normalize vector
-		      delta/=sqrt(length_sqr);
-
-		      //calculating propulsation strength
-		      //greater distance menas smaller propulsation strength
-		      delta*=propulsation/length_sqr;
+		  lemon::dim2::Point<double> delta =
+		    ((mytab.mapstorage).coords[i]-
+		     (mytab.mapstorage).coords[j]);
+
+		  const double length_sqr=std::max(delta.normSquare(),min_dist);
+
+		  //normalize vector
+		  delta/=sqrt(length_sqr);
+
+		  //calculating propulsation strength
+		  //greater distance menas smaller propulsation strength
+		  delta*=propulsation/length_sqr;
 		    
-		      actual_forces.set(i,(actual_forces[i]+delta));
-		    }
+		  actual_forces.set(i,(actual_forces[i]+delta));
 		}
-            //attraction of nodes, to which actual node is bound
-            for(OutEdgeIt ei(ms.graph,i);ei!=INVALID;++ei)
-              {
-                lemon::dim2::Point<double> delta =
-                  (ms.getNodeCoords(i)-
-                   ms.getNodeCoords(ms.graph.target(ei)));
-
-                //calculating attraction strength
-                //greater distance means greater strength
-                delta*=attraction;
-
-                actual_forces.set(i,actual_forces[i]-delta);
-              }
-                    for(InEdgeIt ei(ms.graph,i);ei!=INVALID;++ei)
-              {
-                lemon::dim2::Point<double> delta =
-                  (ms.getNodeCoords(i)-
-                   ms.getNodeCoords(ms.graph.source(ei)));
-
-                //calculating attraction strength
-                //greater distance means greater strength
-                delta*=attraction;
-
-                actual_forces.set(i,actual_forces[i]-delta);
-              }
-	    }
-	  for (NodeIt i(ms.graph); i!=INVALID; ++i)
-	    {
-	      if((ms.getNodeCoords(i).x)+actual_forces[i].x>max_coord)
-		{
-		  actual_forces[i].x=max_coord-(ms.getNodeCoords(i).x);
-		  std::cout << "Correction! " << ((ms.getNodeCoords(i).x)+actual_forces[i].x) << std::endl;
-		}
-	      else if((ms.getNodeCoords(i).x)+actual_forces[i].x<(0-max_coord))
-		{
-		  actual_forces[i].x=0-max_coord-(ms.getNodeCoords(i).x);
-		  std::cout << "Correction! " << ((ms.getNodeCoords(i).x)+actual_forces[i].x) << std::endl;
-		}
-	      if((ms.getNodeCoords(i).y)+actual_forces[i].y>max_coord)
-		{
-		  actual_forces[i].y=max_coord-(ms.getNodeCoords(i).y);
-		  std::cout << "Correction! " << ((ms.getNodeCoords(i).y)+actual_forces[i].y) << std::endl;
-		}
-	      else if((ms.getNodeCoords(i).y)+actual_forces[i].y<(0-max_coord))
-		{
-		  actual_forces[i].y=0-max_coord-(ms.getNodeCoords(i).y);
-		  std::cout << "Correction! " << ((ms.getNodeCoords(i).y)+actual_forces[i].y) << std::endl;
-		}
-	      moveNode(actual_forces[i].x, actual_forces[i].y, nodesmap[i], i);
-	    }
-	}
-    }
-}
-
+	    }
+	  //attraction of nodes, to which actual node is bound
+	  for(OutEdgeIt ei((mytab.mapstorage).graph,i);ei!=INVALID;++ei)
+	    {
+	      lemon::dim2::Point<double> delta =
+		((mytab.mapstorage).coords[i]-
+		 (mytab.mapstorage).coords[mytab.mapstorage.
+					   graph.target(ei)]);
+		
+		//calculating attraction strength
+		//greater distance means greater strength
+		delta*=attraction;
+		
+		actual_forces.set(i,actual_forces[i]-delta);
+	    }
+	  for(InEdgeIt ei((mytab.mapstorage).graph,i);ei!=INVALID;++ei)
+	    {
+	      lemon::dim2::Point<double> delta =
+		((mytab.mapstorage).coords[i]-
+		 (mytab.mapstorage).coords[mytab.mapstorage.
+					   graph.source(ei)]);
+		
+		//calculating attraction strength
+		//greater distance means greater strength
+		delta*=attraction;
+		
+		actual_forces.set(i,actual_forces[i]-delta);
+	    }
+	}
+      for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
+	{
+	  if(((mytab.mapstorage).coords[i].x)+actual_forces[i].x>max_coord)
+	    {
+	      actual_forces[i].x=max_coord-((mytab.mapstorage).coords[i].x);
+	      std::cout << "Correction! " << (((mytab.mapstorage).coords[i].x)+actual_forces[i].x) << std::endl;
+	    }
+	  else if(((mytab.mapstorage).coords[i].x)+actual_forces[i].x<(0-max_coord))
+	    {
+	      actual_forces[i].x=0-max_coord-((mytab.mapstorage).coords[i].x);
+	      std::cout << "Correction! " << (((mytab.mapstorage).coords[i].x)+actual_forces[i].x) << std::endl;
+	    }
+	  if(((mytab.mapstorage).coords[i].y)+actual_forces[i].y>max_coord)
+	    {
+	      actual_forces[i].y=max_coord-((mytab.mapstorage).coords[i].y);
+	      std::cout << "Correction! " << (((mytab.mapstorage).coords[i].y)+actual_forces[i].y) << std::endl;
+	    }
+	  else if(((mytab.mapstorage).coords[i].y)+actual_forces[i].y<(0-max_coord))
+	    {
+	      actual_forces[i].y=0-max_coord-((mytab.mapstorage).coords[i].y);
+	      std::cout << "Correction! " << (((mytab.mapstorage).coords[i].y)+actual_forces[i].y) << std::endl;
+	    }
+	  moveNode(actual_forces[i].x, actual_forces[i].y, nodesmap[i], i);
+	}
+    }
+}
+
