graph_displayer_canvas-event.cc
changeset 199 128195bbab73
parent 187 b465e2c34f23
child 200 c7ae8642a8d8
equal deleted inserted replaced
48:1063ed893a03 49:103f6d9b0860
    14  * express or implied, and with no claim as to its suitability for any
    14  * express or implied, and with no claim as to its suitability for any
    15  * purpose.
    15  * purpose.
    16  *
    16  *
    17  */
    17  */
    18 
    18 
    19 #include "graph_displayer_canvas.h"
    19 #include <graph_displayer_canvas.h>
       
    20 #include <mapstorage.h>
       
    21 #include <nbtab.h>
    20 #include <cmath>
    22 #include <cmath>
    21 
    23 
    22 
    24 
    23 bool GraphDisplayerCanvas::on_expose_event(GdkEventExpose *event)
    25 bool GraphDisplayerCanvas::on_expose_event(GdkEventExpose *event)
    24 {
    26 {
   143       //we mark the location of the event to be able to calculate parameters of dragging
   145       //we mark the location of the event to be able to calculate parameters of dragging
   144       window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   146       window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   145       
   147       
   146       active_item=(get_item_at(clicked_x, clicked_y));
   148       active_item=(get_item_at(clicked_x, clicked_y));
   147       active_node=INVALID;
   149       active_node=INVALID;
   148       for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
   150       for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
   149 	{
   151 	{
   150 	  if(nodesmap[i]==active_item)
   152 	  if(nodesmap[i]==active_item)
   151 	    {
   153 	    {
   152 	      active_node=i;
   154 	      active_node=i;
   153 	    }
   155 	    }
   166       break;
   168       break;
   167     case GDK_MOTION_NOTIFY:
   169     case GDK_MOTION_NOTIFY:
   168       //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
   170       //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
   169       if(active_node!=INVALID)
   171       if(active_node!=INVALID)
   170 	{
   172 	{
   171 	  (mytab.mapstorage).modified = true;
   173 	  (mytab.mapstorage)->modified = true;
   172 	  
   174 	  
   173 	  //new coordinates will be the old values,
   175 	  //new coordinates will be the old values,
   174 	  //because the item will be moved to the
   176 	  //because the item will be moved to the
   175 	  //new coordinate therefore the new movement
   177 	  //new coordinate therefore the new movement
   176 	  //has to be calculated from here
   178 	  //has to be calculated from here
   188 	  clicked_y=new_y;
   190 	  clicked_y=new_y;
   189 
   191 
   190 	  // reposition the coordinates text
   192 	  // reposition the coordinates text
   191 	  std::ostringstream ostr;
   193 	  std::ostringstream ostr;
   192 	  ostr << "(" <<
   194 	  ostr << "(" <<
   193 	    (mytab.mapstorage).coords[active_node].x << ", " <<
   195 	    (mytab.mapstorage)->coords[active_node].x << ", " <<
   194 	    (mytab.mapstorage).coords[active_node].y << ")";
   196 	    (mytab.mapstorage)->coords[active_node].y << ")";
   195 	  double radius =
   197 	  double radius =
   196 	    (nodesmap[active_node]->property_x2().get_value() -
   198 	    (nodesmap[active_node]->property_x2().get_value() -
   197 	     nodesmap[active_node]->property_x1().get_value()) / 2.0;
   199 	     nodesmap[active_node]->property_x1().get_value()) / 2.0;
   198 	  if (coord_text)
   200 	  if (coord_text)
   199 	    {
   201 	    {
   200 	      coord_text->property_text().set_value(ostr.str());
   202 	      coord_text->property_text().set_value(ostr.str());
   201 	      coord_text->property_x().set_value((mytab.mapstorage).coords[active_node].x +
   203 	      coord_text->property_x().set_value((mytab.mapstorage)->coords[active_node].x +
   202 						 radius);
   204 						 radius);
   203 	      coord_text->property_y().set_value((mytab.mapstorage).coords[active_node].y -
   205 	      coord_text->property_y().set_value((mytab.mapstorage)->coords[active_node].y -
   204 						 radius);
   206 						 radius);
   205 	    }
   207 	    }
   206 	  else
   208 	  else
   207 	    {
   209 	    {
   208 	      coord_text = new Gnome::Canvas::Text(
   210 	      coord_text = new Gnome::Canvas::Text(
   209 						   displayed_graph,
   211 						   displayed_graph,
   210 						   (mytab.mapstorage).coords[active_node].x + radius,
   212 						   (mytab.mapstorage)->coords[active_node].x + radius,
   211 						   (mytab.mapstorage).coords[active_node].y - radius,
   213 						   (mytab.mapstorage)->coords[active_node].y - radius,
   212 						   ostr.str());
   214 						   ostr.str());
   213 	      coord_text->property_fill_color().set_value("black");
   215 	      coord_text->property_fill_color().set_value("black");
   214 	      coord_text->property_anchor().set_value(Gtk::ANCHOR_SOUTH_WEST);
   216 	      coord_text->property_anchor().set_value(Gtk::ANCHOR_SOUTH_WEST);
   215 	    }
   217 	    }
   216 
   218 
   297         moveEventHandler(generated);      
   299         moveEventHandler(generated);      
   298         break;
   300         break;
   299       }
   301       }
   300 
   302 
   301     case GDK_BUTTON_RELEASE:
   303     case GDK_BUTTON_RELEASE:
   302       (mytab.mapstorage).modified = true;
   304       (mytab.mapstorage)->modified = true;
   303 
   305 
   304       is_drawn=true;
   306       is_drawn=true;
   305 
   307 
   306       isbutton=1;
   308       isbutton=1;
   307 
   309 
   308       active_node=(mytab.mapstorage).graph.addNode();
   310       active_node=(mytab.mapstorage)->graph.addNode();
   309 
   311 
   310       //initiating values corresponding to new node in maps
   312       //initiating values corresponding to new node in maps
   311 
   313 
   312       window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   314       window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   313 
   315 
   314       // update coordinates
   316       // update coordinates
   315       (mytab.mapstorage).coords.set(active_node, XY(clicked_x, clicked_y));
   317       (mytab.mapstorage)->coords.set(active_node, XY(clicked_x, clicked_y));
   316 
   318 
   317       // update all other maps
   319       // update all other maps
   318       for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it =
   320       for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it =
   319           (mytab.mapstorage).nodemap_storage.begin(); it !=
   321           (mytab.mapstorage)->nodemap_storage.begin(); it !=
   320           (mytab.mapstorage).nodemap_storage.end(); ++it)
   322           (mytab.mapstorage)->nodemap_storage.end(); ++it)
   321       {
   323       {
   322         if ((it->first != "coordinates_x") &&
   324         if ((it->first != "coordinates_x") &&
   323             (it->first != "coordinates_y"))
   325             (it->first != "coordinates_y"))
   324         {
   326         {
   325           (*(it->second))[active_node] =
   327           (*(it->second))[active_node] =
   326             (mytab.mapstorage).nodemap_default[it->first];
   328             (mytab.mapstorage)->nodemap_default[it->first];
   327         }
   329         }
   328       }
   330       }
   329       // increment the id map's default value
   331       // increment the id map's default value
   330       (mytab.mapstorage).nodemap_default["label"] += 1.0;
   332       (mytab.mapstorage)->nodemap_default["label"] += 1.0;
   331 
   333 
   332       nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph,
   334       nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph,
   333           clicked_x-20, clicked_y-20, clicked_x+20, clicked_y+20);
   335           clicked_x-20, clicked_y-20, clicked_x+20, clicked_y+20);
   334       active_item=(Gnome::Canvas::Item *)(nodesmap[active_node]);
   336       active_item=(Gnome::Canvas::Item *)(nodesmap[active_node]);
   335       *(nodesmap[active_node]) <<
   337       *(nodesmap[active_node]) <<
   375 
   377 
   376           window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   378           window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   377 
   379 
   378           active_item=(get_item_at(clicked_x, clicked_y));
   380           active_item=(get_item_at(clicked_x, clicked_y));
   379           active_node=INVALID;
   381           active_node=INVALID;
   380           for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
   382           for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
   381           {
   383           {
   382             if(nodesmap[i]==active_item)
   384             if(nodesmap[i]==active_item)
   383             {
   385             {
   384               active_node=i;
   386               active_node=i;
   385             }
   387             }
   404         else
   406         else
   405         {
   407         {
   406           window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   408           window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   407           target_item=(get_item_at(clicked_x, clicked_y));
   409           target_item=(get_item_at(clicked_x, clicked_y));
   408           Node target_node=INVALID;
   410           Node target_node=INVALID;
   409           for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
   411           for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
   410           {
   412           {
   411             if(nodesmap[i]==target_item)
   413             if(nodesmap[i]==target_item)
   412             {
   414             {
   413               target_node=i;
   415               target_node=i;
   414             }
   416             }
   415           }
   417           }
   416           //the clicked item is a node, the edge can be drawn
   418           //the clicked item is a node, the edge can be drawn
   417           if(target_node!=INVALID)
   419           if(target_node!=INVALID)
   418           {
   420           {
   419             (mytab.mapstorage).modified = true;
   421             (mytab.mapstorage)->modified = true;
   420 
   422 
   421             *(nodesmap[target_node]) <<
   423             *(nodesmap[target_node]) <<
   422               Gnome::Canvas::Properties::fill_color("red");
   424               Gnome::Canvas::Properties::fill_color("red");
   423 
   425 
   424             //creating new edge
   426             //creating new edge
   425             active_edge=(mytab.mapstorage).graph.addEdge(active_node,
   427             active_edge=(mytab.mapstorage)->graph.addEdge(active_node,
   426                 target_node);
   428                 target_node);
   427 
   429 
   428             // update maps
   430             // update maps
   429             for (std::map<std::string,
   431             for (std::map<std::string,
   430                 Graph::EdgeMap<double>*>::const_iterator it =
   432                 Graph::EdgeMap<double>*>::const_iterator it =
   431                 (mytab.mapstorage).edgemap_storage.begin(); it !=
   433                 (mytab.mapstorage)->edgemap_storage.begin(); it !=
   432                 (mytab.mapstorage).edgemap_storage.end(); ++it)
   434                 (mytab.mapstorage)->edgemap_storage.end(); ++it)
   433             {
   435             {
   434               (*(it->second))[active_edge] =
   436               (*(it->second))[active_edge] =
   435                 (mytab.mapstorage).edgemap_default[it->first];
   437                 (mytab.mapstorage)->edgemap_default[it->first];
   436             }
   438             }
   437             // increment the id map's default value
   439             // increment the id map's default value
   438             (mytab.mapstorage).edgemap_default["label"] += 1.0;
   440             (mytab.mapstorage)->edgemap_default["label"] += 1.0;
   439 
   441 
   440             if(target_node!=active_node)		
   442             if(target_node!=active_node)		
   441             {
   443             {
   442               // set the coordinates of the arrow on the new edge
   444               // set the coordinates of the arrow on the new edge
   443               MapStorage& ms = mytab.mapstorage;
   445               MapStorage& ms = *mytab.mapstorage;
   444               ms.arrow_pos.set(active_edge,
   446               ms.arrow_pos.set(active_edge,
   445                   (ms.coords[ms.graph.source(active_edge)] +
   447                   (ms.coords[ms.graph.source(active_edge)] +
   446                    ms.coords[ms.graph.target(active_edge)])/ 2.0);
   448                    ms.coords[ms.graph.target(active_edge)])/ 2.0);
   447 
   449 
   448               //drawing new edge
   450               //drawing new edge
   450                   *this);
   452                   *this);
   451             }
   453             }
   452             else
   454             else
   453             {
   455             {
   454               // set the coordinates of the arrow on the new edge
   456               // set the coordinates of the arrow on the new edge
   455               MapStorage& ms = mytab.mapstorage;
   457               MapStorage& ms = *mytab.mapstorage;
   456               ms.arrow_pos.set(active_edge,
   458               ms.arrow_pos.set(active_edge,
   457                   (ms.coords[ms.graph.source(active_edge)] +
   459                   (ms.coords[ms.graph.source(active_edge)] +
   458                    XY(0.0, 80.0)));
   460                    XY(0.0, 80.0)));
   459 
   461 
   460               //drawing new edge
   462               //drawing new edge
   461               edgesmap[active_edge]=new LoopEdge(displayed_graph, active_edge,
   463               edgesmap[active_edge]=new LoopEdge(displayed_graph, active_edge,
   462                   *this);
   464                   *this);
   463             }
   465             }
   464 
   466 
   465             //initializing edge-text as well, to empty string
   467             //initializing edge-text as well, to empty string
   466             XY text_pos=mytab.mapstorage.arrow_pos[active_edge];
   468             XY text_pos=mytab.mapstorage->arrow_pos[active_edge];
   467             text_pos+=(XY(10,10));
   469             text_pos+=(XY(10,10));
   468 
   470 
   469             edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph,
   471             edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph,
   470                 text_pos.x, text_pos.y, "");
   472                 text_pos.x, text_pos.y, "");
   471             edgetextmap[active_edge]->property_fill_color().set_value(
   473             edgetextmap[active_edge]->property_fill_color().set_value(
   495 	  propertyUpdate(active_node,N_COLOR);
   497 	  propertyUpdate(active_node,N_COLOR);
   496           active_item=NULL;
   498           active_item=NULL;
   497         }
   499         }
   498         if(target_item)
   500         if(target_item)
   499         {
   501         {
   500 	  propertyUpdate((mytab.mapstorage).graph.target(active_edge),N_COLOR);
   502 	  propertyUpdate((mytab.mapstorage)->graph.target(active_edge),N_COLOR);
   501           target_item=NULL;
   503           target_item=NULL;
   502         }
   504         }
   503         active_node=INVALID;
   505         active_node=INVALID;
   504         active_edge=INVALID;
   506         active_edge=INVALID;
   505       }
   507       }
   519       window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   521       window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   520       active_item=(get_item_at(clicked_x, clicked_y));
   522       active_item=(get_item_at(clicked_x, clicked_y));
   521       active_node=INVALID;
   523       active_node=INVALID;
   522       active_edge=INVALID;
   524       active_edge=INVALID;
   523       //was it a node?
   525       //was it a node?
   524       for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
   526       for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
   525 	{
   527 	{
   526 	  if(nodesmap[i]==active_item)
   528 	  if(nodesmap[i]==active_item)
   527 	    {
   529 	    {
   528 	      active_node=i;
   530 	      active_node=i;
   529 	    }
   531 	    }
   530 	}
   532 	}
   531       //or was it an edge?
   533       //or was it an edge?
   532       if(active_node==INVALID)
   534       if(active_node==INVALID)
   533 	{
   535 	{
   534 	  for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
   536 	  for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
   535 	    {
   537 	    {
   536 	      if(edgesmap[i]->getLine()==active_item)
   538 	      if(edgesmap[i]->getLine()==active_item)
   537 		{
   539 		{
   538 		  active_edge=i;
   540 		  active_edge=i;
   539 		}
   541 		}
   558 	  if( active_item == ( get_item_at (clicked_x, clicked_y) ) )
   560 	  if( active_item == ( get_item_at (clicked_x, clicked_y) ) )
   559 	    {
   561 	    {
   560 	      //a node was found
   562 	      //a node was found
   561 	      if(active_node!=INVALID)
   563 	      if(active_node!=INVALID)
   562 		{
   564 		{
   563                   (mytab.mapstorage).modified = true;
   565                   (mytab.mapstorage)->modified = true;
   564 
   566 
   565 		  std::set<Graph::Edge> edges_to_delete;
   567 		  std::set<Graph::Edge> edges_to_delete;
   566 
   568 
   567 		  for(OutEdgeIt e((mytab.mapstorage).graph,active_node);e!=INVALID;++e)
   569 		  for(OutEdgeIt e((mytab.mapstorage)->graph,active_node);e!=INVALID;++e)
   568 		    {
   570 		    {
   569 		      edges_to_delete.insert(e);
   571 		      edges_to_delete.insert(e);
   570 		    }
   572 		    }
   571 		  
   573 		  
   572 		  for(InEdgeIt e((mytab.mapstorage).graph,active_node);e!=INVALID;++e)
   574 		  for(InEdgeIt e((mytab.mapstorage)->graph,active_node);e!=INVALID;++e)
   573 		    {
   575 		    {
   574 		      edges_to_delete.insert(e);
   576 		      edges_to_delete.insert(e);
   575 		    }
   577 		    }
   576 		  
   578 		  
   577 		  //deleting collected edges
   579 		  //deleting collected edges
   633 
   635 
   634 	    window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   636 	    window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   635 	    active_item=(get_item_at(clicked_x, clicked_y));
   637 	    active_item=(get_item_at(clicked_x, clicked_y));
   636 
   638 
   637 	    //find the activated item between text of nodes
   639 	    //find the activated item between text of nodes
   638 	    for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
   640 	    for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
   639 	      {
   641 	      {
   640 		//at the same time only one can be active
   642 		//at the same time only one can be active
   641 		if(nodetextmap[i]==active_item)
   643 		if(nodetextmap[i]==active_item)
   642 		  {
   644 		  {
   643 		    clicked_node=i;
   645 		    clicked_node=i;
   645 	      }
   647 	      }
   646 
   648 
   647 	    //if there was not, search for it between nodes
   649 	    //if there was not, search for it between nodes
   648 	    if(clicked_node==INVALID)
   650 	    if(clicked_node==INVALID)
   649 	      {
   651 	      {
   650 		for (NodeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
   652 		for (NodeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
   651 		  {
   653 		  {
   652 		    //at the same time only one can be active
   654 		    //at the same time only one can be active
   653 		    if(nodesmap[i]==active_item)
   655 		    if(nodesmap[i]==active_item)
   654 		      {
   656 		      {
   655 			clicked_node=i;
   657 			clicked_node=i;
   658 	      }
   660 	      }
   659 
   661 
   660 	    if(clicked_node==INVALID)
   662 	    if(clicked_node==INVALID)
   661 	      {
   663 	      {
   662 		//find the activated item between texts
   664 		//find the activated item between texts
   663 		for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
   665 		for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
   664 		  {
   666 		  {
   665 		    //at the same time only one can be active
   667 		    //at the same time only one can be active
   666 		    if(edgetextmap[i]==active_item)
   668 		    if(edgetextmap[i]==active_item)
   667 		      {
   669 		      {
   668 			clicked_edge=i;
   670 			clicked_edge=i;
   670 		  }
   672 		  }
   671 
   673 
   672 		//if it was not between texts, search for it between edges
   674 		//if it was not between texts, search for it between edges
   673 		if(clicked_edge==INVALID)
   675 		if(clicked_edge==INVALID)
   674 		  {
   676 		  {
   675 		    for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
   677 		    for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
   676 		      {
   678 		      {
   677 			//at the same time only one can be active
   679 			//at the same time only one can be active
   678 			if((edgesmap[i]->getLine())==active_item)
   680 			if((edgesmap[i]->getLine())==active_item)
   679 			  {
   681 			  {
   680 			    clicked_edge=i;
   682 			    clicked_edge=i;
   712 		      case Gtk::RESPONSE_NONE:
   714 		      case Gtk::RESPONSE_NONE:
   713 		      case Gtk::RESPONSE_CANCEL:
   715 		      case Gtk::RESPONSE_CANCEL:
   714 			break;
   716 			break;
   715 		      case Gtk::RESPONSE_ACCEPT:
   717 		      case Gtk::RESPONSE_ACCEPT:
   716 			double new_value = spin.get_value();
   718 			double new_value = spin.get_value();
   717 			(*(mytab.mapstorage).nodemap_storage[nodemap_to_edit])[active_node] =
   719 			(*(mytab.mapstorage)->nodemap_storage[nodemap_to_edit])[active_node] =
   718 			  new_value;
   720 			  new_value;
   719 			std::ostringstream ostr;
   721 			std::ostringstream ostr;
   720 			ostr << new_value;
   722 			ostr << new_value;
   721 			nodetextmap[active_node]->property_text().set_value(ostr.str());
   723 			nodetextmap[active_node]->property_text().set_value(ostr.str());
   722 			//mapwin.updateNode(active_node);
   724 			//mapwin.updateNode(active_node);
   755 			case Gtk::RESPONSE_NONE:
   757 			case Gtk::RESPONSE_NONE:
   756 			case Gtk::RESPONSE_CANCEL:
   758 			case Gtk::RESPONSE_CANCEL:
   757 			  break;
   759 			  break;
   758 			case Gtk::RESPONSE_ACCEPT:
   760 			case Gtk::RESPONSE_ACCEPT:
   759 			  double new_value = spin.get_value();
   761 			  double new_value = spin.get_value();
   760 			  (*(mytab.mapstorage).edgemap_storage[edgemap_to_edit])[active_edge] =
   762 			  (*(mytab.mapstorage)->edgemap_storage[edgemap_to_edit])[active_edge] =
   761 			    new_value;
   763 			    new_value;
   762 			  std::ostringstream ostr;
   764 			  std::ostringstream ostr;
   763 			  ostr << new_value;
   765 			  ostr << new_value;
   764 			  edgetextmap[active_edge]->property_text().set_value(
   766 			  edgetextmap[active_edge]->property_text().set_value(
   765 									      ostr.str());
   767 									      ostr.str());
   780 
   782 
   781 void GraphDisplayerCanvas::deleteItem(Node node_to_delete)
   783 void GraphDisplayerCanvas::deleteItem(Node node_to_delete)
   782 {
   784 {
   783   delete(nodetextmap[node_to_delete]);
   785   delete(nodetextmap[node_to_delete]);
   784   delete(nodesmap[node_to_delete]);
   786   delete(nodesmap[node_to_delete]);
   785   (mytab.mapstorage).graph.erase(node_to_delete);
   787   (mytab.mapstorage)->graph.erase(node_to_delete);
   786 }
   788 }
   787 
   789 
   788 void GraphDisplayerCanvas::deleteItem(Edge edge_to_delete)
   790 void GraphDisplayerCanvas::deleteItem(Edge edge_to_delete)
   789 {
   791 {
   790   delete(edgetextmap[edge_to_delete]);
   792   delete(edgetextmap[edge_to_delete]);
   791   delete(edgesmap[edge_to_delete]);
   793   delete(edgesmap[edge_to_delete]);
   792   (mytab.mapstorage).graph.erase(edge_to_delete);
   794   (mytab.mapstorage)->graph.erase(edge_to_delete);
   793 }
   795 }
   794 
   796 
   795 void GraphDisplayerCanvas::textReposition(XY new_place)
   797 void GraphDisplayerCanvas::textReposition(XY new_place)
   796 {
   798 {
   797   new_place+=(XY(10,10));
   799   new_place+=(XY(10,10));
   807     {
   809     {
   808       std::cerr << "ERROR!!!! Valid edge found!" << std::endl;
   810       std::cerr << "ERROR!!!! Valid edge found!" << std::endl;
   809     }
   811     }
   810     else
   812     else
   811     {
   813     {
   812       for (EdgeIt i((mytab.mapstorage).graph); i!=INVALID; ++i)
   814       for (EdgeIt i((mytab.mapstorage)->graph); i!=INVALID; ++i)
   813       {
   815       {
   814         if(edgesmap[i]==active_bre)
   816         if(edgesmap[i]==active_bre)
   815         {
   817         {
   816           forming_edge=i;
   818           forming_edge=i;
   817         }
   819         }
   849   //repositioning node and its text
   851   //repositioning node and its text
   850   moved_item->move(dx, dy);
   852   moved_item->move(dx, dy);
   851   nodetextmap[moved_node]->move(dx, dy);
   853   nodetextmap[moved_node]->move(dx, dy);
   852 
   854 
   853   // the new coordinates of the centre of the node 
   855   // the new coordinates of the centre of the node 
   854   double coord_x = dx + (mytab.mapstorage).coords[moved_node].x;
   856   double coord_x = dx + (mytab.mapstorage)->coords[moved_node].x;
   855   double coord_y = dy + (mytab.mapstorage).coords[moved_node].y;
   857   double coord_y = dy + (mytab.mapstorage)->coords[moved_node].y;
   856 
   858 
   857   // write back the new coordinates to the coords map
   859   // write back the new coordinates to the coords map
   858   (mytab.mapstorage).coords.set(moved_node, XY(coord_x, coord_y));
   860   (mytab.mapstorage)->coords.set(moved_node, XY(coord_x, coord_y));
   859 
   861 
   860   //all the edges connected to the moved point has to be redrawn
   862   //all the edges connected to the moved point has to be redrawn
   861   for(OutEdgeIt ei((mytab.mapstorage).graph,moved_node);ei!=INVALID;++ei)
   863   for(OutEdgeIt ei((mytab.mapstorage)->graph,moved_node);ei!=INVALID;++ei)
   862     {
   864     {
   863       XY arrow_pos;
   865       XY arrow_pos;
   864 
   866 
   865       if (mytab.mapstorage.graph.source(ei) == mytab.mapstorage.graph.target(ei))
   867       if (mytab.mapstorage->graph.source(ei) == mytab.mapstorage->graph.target(ei))
   866 	{
   868 	{
   867 	  arrow_pos = mytab.mapstorage.arrow_pos[ei] + XY(dx, dy);
   869 	  arrow_pos = mytab.mapstorage->arrow_pos[ei] + XY(dx, dy);
   868 	}
   870 	}
   869       else
   871       else
   870 	{
   872 	{
   871 	  XY moved_node_1(coord_x - dx, coord_y - dy);
   873 	  XY moved_node_1(coord_x - dx, coord_y - dy);
   872 	  XY moved_node_2(coord_x, coord_y);
   874 	  XY moved_node_2(coord_x, coord_y);
   873 	  Node target = mytab.mapstorage.graph.target(ei);
   875 	  Node target = mytab.mapstorage->graph.target(ei);
   874 	  XY fix_node(mytab.mapstorage.coords[target].x,
   876 	  XY fix_node(mytab.mapstorage->coords[target].x,
   875 		      mytab.mapstorage.coords[target].y);
   877 		      mytab.mapstorage->coords[target].y);
   876 	  XY old_arrow_pos(mytab.mapstorage.arrow_pos[ei]);
   878 	  XY old_arrow_pos(mytab.mapstorage->arrow_pos[ei]);
   877 
   879 
   878 	  arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
   880 	  arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
   879 	}
   881 	}
   880 
   882 
   881       mytab.mapstorage.arrow_pos.set(ei, arrow_pos);
   883       mytab.mapstorage->arrow_pos.set(ei, arrow_pos);
   882       edgesmap[ei]->draw();
   884       edgesmap[ei]->draw();
   883 
   885 
   884       //reposition of edgetext
   886       //reposition of edgetext
   885       XY text_pos=mytab.mapstorage.arrow_pos[ei];
   887       XY text_pos=mytab.mapstorage->arrow_pos[ei];
   886       text_pos+=(XY(10,10));
   888       text_pos+=(XY(10,10));
   887       edgetextmap[ei]->property_x().set_value(text_pos.x);
   889       edgetextmap[ei]->property_x().set_value(text_pos.x);
   888       edgetextmap[ei]->property_y().set_value(text_pos.y);
   890       edgetextmap[ei]->property_y().set_value(text_pos.y);
   889     }
   891     }
   890 
   892 
   891   for(InEdgeIt ei((mytab.mapstorage).graph,moved_node);ei!=INVALID;++ei)
   893   for(InEdgeIt ei((mytab.mapstorage)->graph,moved_node);ei!=INVALID;++ei)
   892     {
   894     {
   893       if (mytab.mapstorage.graph.source(ei) != mytab.mapstorage.graph.target(ei))
   895       if (mytab.mapstorage->graph.source(ei) != mytab.mapstorage->graph.target(ei))
   894 	{
   896 	{
   895 	  XY moved_node_1(coord_x - dx, coord_y - dy);
   897 	  XY moved_node_1(coord_x - dx, coord_y - dy);
   896 	  XY moved_node_2(coord_x, coord_y);
   898 	  XY moved_node_2(coord_x, coord_y);
   897 	  Node source = mytab.mapstorage.graph.source(ei);
   899 	  Node source = mytab.mapstorage->graph.source(ei);
   898 	  XY fix_node(mytab.mapstorage.coords[source].x,
   900 	  XY fix_node(mytab.mapstorage->coords[source].x,
   899 		      mytab.mapstorage.coords[source].y);
   901 		      mytab.mapstorage->coords[source].y);
   900 	  XY old_arrow_pos(mytab.mapstorage.arrow_pos[ei]);
   902 	  XY old_arrow_pos(mytab.mapstorage->arrow_pos[ei]);
   901 
   903 
   902 	  XY arrow_pos;
   904 	  XY arrow_pos;
   903 	  arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
   905 	  arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
   904 
   906 
   905 	  mytab.mapstorage.arrow_pos.set(ei, arrow_pos);
   907 	  mytab.mapstorage->arrow_pos.set(ei, arrow_pos);
   906 	  edgesmap[ei]->draw();
   908 	  edgesmap[ei]->draw();
   907 
   909 
   908 	  //reposition of edgetext
   910 	  //reposition of edgetext
   909 	  XY text_pos=mytab.mapstorage.arrow_pos[ei];
   911 	  XY text_pos=mytab.mapstorage->arrow_pos[ei];
   910 	  text_pos+=(XY(10,10));
   912 	  text_pos+=(XY(10,10));
   911 	  edgetextmap[ei]->property_x().set_value(text_pos.x);
   913 	  edgetextmap[ei]->property_x().set_value(text_pos.x);
   912 	  edgetextmap[ei]->property_y().set_value(text_pos.y);
   914 	  edgetextmap[ei]->property_y().set_value(text_pos.y);
   913 	}
   915 	}
   914     }
   916     }