gui/graph_displayer_canvas-event.cc
changeset 1843 1e386f4047c9
parent 1826 e07a7a8acd77
child 1849 a4d1362397fe
equal deleted inserted replaced
30:6619e8d691cb 31:a94d1af9eb48
    92       //we mark the location of the event to be able to calculate parameters of dragging
    92       //we mark the location of the event to be able to calculate parameters of dragging
    93       window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
    93       window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
    94 
    94 
    95       active_item=(get_item_at(clicked_x, clicked_y));
    95       active_item=(get_item_at(clicked_x, clicked_y));
    96       active_node=INVALID;
    96       active_node=INVALID;
    97       for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
    97       for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
    98 	{
    98 	{
    99 	  if(nodesmap[i]==active_item)
    99 	  if(nodesmap[i]==active_item)
   100 	    {
   100 	    {
   101 	      active_node=i;
   101 	      active_node=i;
   102 	    }
   102 	    }
   123       break;
   123       break;
   124     case GDK_MOTION_NOTIFY:
   124     case GDK_MOTION_NOTIFY:
   125       //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
   125       //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
   126       if(active_node!=INVALID)
   126       if(active_node!=INVALID)
   127       {
   127       {
   128         mapstorage.modified = true;
   128         (mainwin.mapstorage).modified = true;
   129 
   129 
   130 	//new coordinates will be the old values,
   130 	//new coordinates will be the old values,
   131 	//because the item will be moved to the
   131 	//because the item will be moved to the
   132 	//new coordinate therefore the new movement
   132 	//new coordinate therefore the new movement
   133 	//has to be calculated from here
   133 	//has to be calculated from here
   142 	//repositioning node and its text
   142 	//repositioning node and its text
   143         active_item->move(dx, dy);
   143         active_item->move(dx, dy);
   144 	nodetextmap[active_node]->move(dx, dy);
   144 	nodetextmap[active_node]->move(dx, dy);
   145 
   145 
   146         // the new coordinates of the centre of the node 
   146         // the new coordinates of the centre of the node 
   147         double coord_x = new_x - (clicked_x - mapstorage.coords[active_node].x);
   147         double coord_x = new_x - (clicked_x - (mainwin.mapstorage).coords[active_node].x);
   148         double coord_y = new_y - (clicked_y - mapstorage.coords[active_node].y);
   148         double coord_y = new_y - (clicked_y - (mainwin.mapstorage).coords[active_node].y);
   149 
   149 
   150         clicked_x=new_x;
   150         clicked_x=new_x;
   151         clicked_y=new_y;
   151         clicked_y=new_y;
   152 
   152 
   153         // write back the new coordinates to the coords map
   153         // write back the new coordinates to the coords map
   154         mapstorage.coords.set(active_node, xy<double>(coord_x, coord_y));
   154         (mainwin.mapstorage).coords.set(active_node, xy<double>(coord_x, coord_y));
   155 
   155 
   156         // reposition the coordinates text
   156         // reposition the coordinates text
   157         std::ostringstream ostr;
   157         std::ostringstream ostr;
   158         ostr << "(" <<
   158         ostr << "(" <<
   159           mapstorage.coords[active_node].x << ", " <<
   159           (mainwin.mapstorage).coords[active_node].x << ", " <<
   160           mapstorage.coords[active_node].y << ")";
   160           (mainwin.mapstorage).coords[active_node].y << ")";
   161         double radius =
   161         double radius =
   162           (nodesmap[active_node]->property_x2().get_value() -
   162           (nodesmap[active_node]->property_x2().get_value() -
   163           nodesmap[active_node]->property_x1().get_value()) / 2.0;
   163           nodesmap[active_node]->property_x1().get_value()) / 2.0;
   164         if (coord_text)
   164         if (coord_text)
   165         {
   165         {
   166           coord_text->property_text().set_value(ostr.str());
   166           coord_text->property_text().set_value(ostr.str());
   167           coord_text->property_x().set_value(mapstorage.coords[active_node].x +
   167           coord_text->property_x().set_value((mainwin.mapstorage).coords[active_node].x +
   168               radius);
   168               radius);
   169           coord_text->property_y().set_value(mapstorage.coords[active_node].y -
   169           coord_text->property_y().set_value((mainwin.mapstorage).coords[active_node].y -
   170               radius);
   170               radius);
   171         }
   171         }
   172         else
   172         else
   173         {
   173         {
   174           coord_text = new Gnome::Canvas::Text(
   174           coord_text = new Gnome::Canvas::Text(
   175               displayed_graph,
   175               displayed_graph,
   176               mapstorage.coords[active_node].x + radius,
   176               (mainwin.mapstorage).coords[active_node].x + radius,
   177               mapstorage.coords[active_node].y - radius,
   177               (mainwin.mapstorage).coords[active_node].y - radius,
   178               ostr.str());
   178               ostr.str());
   179           coord_text->property_fill_color().set_value("black");
   179           coord_text->property_fill_color().set_value("black");
   180           coord_text->property_anchor().set_value(Gtk::ANCHOR_SOUTH_WEST);
   180           coord_text->property_anchor().set_value(Gtk::ANCHOR_SOUTH_WEST);
   181         }
   181         }
   182 
   182 
   183 	//all the edges connected to the moved point has to be redrawn
   183 	//all the edges connected to the moved point has to be redrawn
   184         for(OutEdgeIt ei(mapstorage.graph,active_node);ei!=INVALID;++ei)
   184         for(OutEdgeIt ei((mainwin.mapstorage).graph,active_node);ei!=INVALID;++ei)
   185         {
   185         {
   186             Gnome::Canvas::Points coos;
   186             Gnome::Canvas::Points coos;
   187             double x1, x2, y1, y2;
   187             double x1, x2, y1, y2;
   188 
   188 
   189             nodesmap[mapstorage.graph.source(ei)]->get_bounds(x1, y1, x2, y2);
   189             nodesmap[(mainwin.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2);
   190             coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   190             coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   191 
   191 
   192             nodesmap[mapstorage.graph.target(ei)]->get_bounds(x1, y1, x2, y2);
   192             nodesmap[(mainwin.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2);
   193             coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   193             coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   194 
   194 
   195 	    if(isbutton==3)
   195 	    if(isbutton==3)
   196 	      {
   196 	      {
   197 		edgesmap[ei]->setPoints(coos);
   197 		edgesmap[ei]->setPoints(coos);
   206 	    text_pos+=(xy<double>(10,10));
   206 	    text_pos+=(xy<double>(10,10));
   207 	    edgetextmap[ei]->property_x().set_value(text_pos.x);
   207 	    edgetextmap[ei]->property_x().set_value(text_pos.x);
   208 	    edgetextmap[ei]->property_y().set_value(text_pos.y);
   208 	    edgetextmap[ei]->property_y().set_value(text_pos.y);
   209         }
   209         }
   210 
   210 
   211         for(InEdgeIt ei(mapstorage.graph,active_node);ei!=INVALID;++ei)
   211         for(InEdgeIt ei((mainwin.mapstorage).graph,active_node);ei!=INVALID;++ei)
   212         {
   212         {
   213             Gnome::Canvas::Points coos;
   213             Gnome::Canvas::Points coos;
   214             double x1, x2, y1, y2;
   214             double x1, x2, y1, y2;
   215 
   215 
   216             nodesmap[mapstorage.graph.source(ei)]->get_bounds(x1, y1, x2, y2);
   216             nodesmap[(mainwin.mapstorage).graph.source(ei)]->get_bounds(x1, y1, x2, y2);
   217             coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   217             coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   218 
   218 
   219             nodesmap[mapstorage.graph.target(ei)]->get_bounds(x1, y1, x2, y2);
   219             nodesmap[(mainwin.mapstorage).graph.target(ei)]->get_bounds(x1, y1, x2, y2);
   220             coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   220             coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   221 
   221 
   222 	    if(isbutton==3)
   222 	    if(isbutton==3)
   223 	      {
   223 	      {
   224 		edgesmap[ei]->setPoints(coos);
   224 		edgesmap[ei]->setPoints(coos);
   254         moveEventHandler(generated);      
   254         moveEventHandler(generated);      
   255         break;
   255         break;
   256       }
   256       }
   257 
   257 
   258     case GDK_BUTTON_RELEASE:
   258     case GDK_BUTTON_RELEASE:
   259       mapstorage.modified = true;
   259       (mainwin.mapstorage).modified = true;
   260 
   260 
   261       isbutton=1;
   261       isbutton=1;
   262 
   262 
   263       active_node=mapstorage.graph.addNode();
   263       active_node=(mainwin.mapstorage).graph.addNode();
   264 
   264 
   265       //initiating values corresponding to new node in maps
   265       //initiating values corresponding to new node in maps
   266 
   266 
   267       window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   267       window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   268 
   268 
   269       // update coordinates
   269       // update coordinates
   270       mapstorage.coords.set(active_node, xy<double>(clicked_x, clicked_y));
   270       (mainwin.mapstorage).coords.set(active_node, xy<double>(clicked_x, clicked_y));
   271 
   271 
   272       // update all other maps
   272       // update all other maps
   273       for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it =
   273       for (std::map<std::string, Graph::NodeMap<double>*>::const_iterator it =
   274           mapstorage.nodemap_storage.begin(); it !=
   274           (mainwin.mapstorage).nodemap_storage.begin(); it !=
   275           mapstorage.nodemap_storage.end(); ++it)
   275           (mainwin.mapstorage).nodemap_storage.end(); ++it)
   276       {
   276       {
   277         if ((it->first != "coordinates_x") &&
   277         if ((it->first != "coordinates_x") &&
   278             (it->first != "coordinates_y"))
   278             (it->first != "coordinates_y"))
   279         {
   279         {
   280           (*(it->second))[active_node] =
   280           (*(it->second))[active_node] =
   281             mapstorage.nodemap_default[it->first];
   281             (mainwin.mapstorage).nodemap_default[it->first];
   282         }
   282         }
   283       }
   283       }
   284       // increment the id map's default value
   284       // increment the id map's default value
   285       mapstorage.nodemap_default["id"] += 1.0;
   285       (mainwin.mapstorage).nodemap_default["id"] += 1.0;
   286 
   286 
   287       nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph,
   287       nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph,
   288           clicked_x-20, clicked_y-20, clicked_x+20, clicked_y+20);
   288           clicked_x-20, clicked_y-20, clicked_x+20, clicked_y+20);
   289       active_item=(Gnome::Canvas::Item *)(nodesmap[active_node]);
   289       active_item=(Gnome::Canvas::Item *)(nodesmap[active_node]);
   290       *(nodesmap[active_node]) <<
   290       *(nodesmap[active_node]) <<
   299           clicked_x+node_property_defaults[N_RADIUS]+5,
   299           clicked_x+node_property_defaults[N_RADIUS]+5,
   300           clicked_y+node_property_defaults[N_RADIUS]+5, "");
   300           clicked_y+node_property_defaults[N_RADIUS]+5, "");
   301       nodetextmap[active_node]->property_fill_color().set_value("darkblue");
   301       nodetextmap[active_node]->property_fill_color().set_value("darkblue");
   302       nodetextmap[active_node]->raise_to_top();
   302       nodetextmap[active_node]->raise_to_top();
   303 
   303 
   304       mapwin.updateNode(active_node);
   304 //       mapwin.updateNode(active_node);
       
   305       propertyUpdate(active_node);
   305 
   306 
   306       isbutton=0;
   307       isbutton=0;
   307       target_item=NULL;
   308       target_item=NULL;
   308       active_item=NULL;
   309       active_item=NULL;
   309       active_node=INVALID;
   310       active_node=INVALID;
   329 
   330 
   330           window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   331           window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   331 
   332 
   332           active_item=(get_item_at(clicked_x, clicked_y));
   333           active_item=(get_item_at(clicked_x, clicked_y));
   333           active_node=INVALID;
   334           active_node=INVALID;
   334           for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
   335           for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
   335           {
   336           {
   336             if(nodesmap[i]==active_item)
   337             if(nodesmap[i]==active_item)
   337             {
   338             {
   338               active_node=i;
   339               active_node=i;
   339             }
   340             }
   358         else
   359         else
   359         {
   360         {
   360           window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   361           window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   361           target_item=(get_item_at(clicked_x, clicked_y));
   362           target_item=(get_item_at(clicked_x, clicked_y));
   362           Node target_node=INVALID;
   363           Node target_node=INVALID;
   363           for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
   364           for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
   364           {
   365           {
   365             if(nodesmap[i]==target_item)
   366             if(nodesmap[i]==target_item)
   366             {
   367             {
   367               target_node=i;
   368               target_node=i;
   368             }
   369             }
   370           //the clicked item is a node, the edge can be drawn
   371           //the clicked item is a node, the edge can be drawn
   371           if(target_node!=INVALID)
   372           if(target_node!=INVALID)
   372           {
   373           {
   373             if(target_node!=active_node)		
   374             if(target_node!=active_node)		
   374             {
   375             {
   375               mapstorage.modified = true;
   376               (mainwin.mapstorage).modified = true;
   376 
   377 
   377               *(nodesmap[target_node]) <<
   378               *(nodesmap[target_node]) <<
   378                 Gnome::Canvas::Properties::fill_color("red");
   379                 Gnome::Canvas::Properties::fill_color("red");
   379 
   380 
   380               //creating new edge
   381               //creating new edge
   381               active_edge=mapstorage.graph.addEdge(active_node,
   382               active_edge=(mainwin.mapstorage).graph.addEdge(active_node,
   382                   target_node);
   383                   target_node);
   383 
   384 
   384               // update maps
   385               // update maps
   385               for (std::map<std::string,
   386               for (std::map<std::string,
   386                   Graph::EdgeMap<double>*>::const_iterator it =
   387                   Graph::EdgeMap<double>*>::const_iterator it =
   387                   mapstorage.edgemap_storage.begin(); it !=
   388                   (mainwin.mapstorage).edgemap_storage.begin(); it !=
   388                   mapstorage.edgemap_storage.end(); ++it)
   389                   (mainwin.mapstorage).edgemap_storage.end(); ++it)
   389               {
   390               {
   390                 (*(it->second))[active_edge] =
   391                 (*(it->second))[active_edge] =
   391                   mapstorage.edgemap_default[it->first];
   392                   (mainwin.mapstorage).edgemap_default[it->first];
   392               }
   393               }
   393               // increment the id map's default value
   394               // increment the id map's default value
   394               mapstorage.edgemap_default["id"] += 1.0;
   395               (mainwin.mapstorage).edgemap_default["id"] += 1.0;
   395 
   396 
   396               //calculating coordinates of new edge
   397               //calculating coordinates of new edge
   397               Gnome::Canvas::Points coos;
   398               Gnome::Canvas::Points coos;
   398               double x1, x2, y1, y2;
   399               double x1, x2, y1, y2;
   399 
   400 
   421               edgetextmap[active_edge]->property_fill_color().set_value(
   422               edgetextmap[active_edge]->property_fill_color().set_value(
   422                   "darkgreen");
   423                   "darkgreen");
   423               edgetextmap[active_edge]->raise_to_top();
   424               edgetextmap[active_edge]->raise_to_top();
   424 
   425 
   425               //updating its properties
   426               //updating its properties
   426               mapwin.updateEdge(active_edge);
   427 //               mapwin.updateEdge(active_edge);
       
   428               propertyUpdate(active_edge);
   427             }
   429             }
   428             else
   430             else
   429             {
   431             {
   430               target_node=INVALID;
   432               target_node=INVALID;
   431               std::cerr << "Loop edge is not yet implemented!" << std::endl;
   433               std::cerr << "Loop edge is not yet implemented!" << std::endl;
   476       window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   478       window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   477       active_item=(get_item_at(clicked_x, clicked_y));
   479       active_item=(get_item_at(clicked_x, clicked_y));
   478       active_node=INVALID;
   480       active_node=INVALID;
   479       active_edge=INVALID;
   481       active_edge=INVALID;
   480       //was it a node?
   482       //was it a node?
   481       for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
   483       for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
   482 	{
   484 	{
   483 	  if(nodesmap[i]==active_item)
   485 	  if(nodesmap[i]==active_item)
   484 	    {
   486 	    {
   485 	      active_node=i;
   487 	      active_node=i;
   486 	    }
   488 	    }
   487 	}
   489 	}
   488       //or was it an edge?
   490       //or was it an edge?
   489       if(active_node==INVALID)
   491       if(active_node==INVALID)
   490 	{
   492 	{
   491 	  for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
   493 	  for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
   492 	    {
   494 	    {
   493 	      if(edgesmap[i]==active_item)
   495 	      if(edgesmap[i]==active_item)
   494 		{
   496 		{
   495 		  active_edge=i;
   497 		  active_edge=i;
   496 		}
   498 		}
   512 	  if( active_item == ( get_item_at (clicked_x, clicked_y) ) )
   514 	  if( active_item == ( get_item_at (clicked_x, clicked_y) ) )
   513 	    {
   515 	    {
   514 	      //a node was found
   516 	      //a node was found
   515 	      if(active_node!=INVALID)
   517 	      if(active_node!=INVALID)
   516 		{
   518 		{
   517                   mapstorage.modified = true;
   519                   (mainwin.mapstorage).modified = true;
   518 
   520 
   519 		  std::set<Graph::Edge> edges_to_delete;
   521 		  std::set<Graph::Edge> edges_to_delete;
   520 
   522 
   521 		  for(OutEdgeIt e(mapstorage.graph,active_node);e!=INVALID;++e)
   523 		  for(OutEdgeIt e((mainwin.mapstorage).graph,active_node);e!=INVALID;++e)
   522 		    {
   524 		    {
   523 		      edges_to_delete.insert(e);
   525 		      edges_to_delete.insert(e);
   524 		    }
   526 		    }
   525 		  
   527 		  
   526 		  for(InEdgeIt e(mapstorage.graph,active_node);e!=INVALID;++e)
   528 		  for(InEdgeIt e((mainwin.mapstorage).graph,active_node);e!=INVALID;++e)
   527 		    {
   529 		    {
   528 		      edges_to_delete.insert(e);
   530 		      edges_to_delete.insert(e);
   529 		    }
   531 		    }
   530 		  
   532 		  
   531 		  //deleting collected edges
   533 		  //deleting collected edges
   585 
   587 
   586           window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   588           window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   587           active_item=(get_item_at(clicked_x, clicked_y));
   589           active_item=(get_item_at(clicked_x, clicked_y));
   588 
   590 
   589           //find the activated item between texts
   591           //find the activated item between texts
   590           for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
   592           for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
   591           {
   593           {
   592             //at the same time only one can be active
   594             //at the same time only one can be active
   593             if(edgetextmap[i]==active_item)
   595             if(edgetextmap[i]==active_item)
   594             {
   596             {
   595               clicked_edge=i;
   597               clicked_edge=i;
   597           }
   599           }
   598 
   600 
   599           //if it was not between texts, search for it between edges
   601           //if it was not between texts, search for it between edges
   600           if(clicked_edge==INVALID)
   602           if(clicked_edge==INVALID)
   601           {
   603           {
   602             for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
   604             for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
   603             {
   605             {
   604               //at the same time only one can be active
   606               //at the same time only one can be active
   605               if((edgesmap[i]==active_item)||(edgetextmap[i]==active_item))
   607               if((edgesmap[i]==active_item)||(edgetextmap[i]==active_item))
   606               {
   608               {
   607                 clicked_edge=i;
   609                 clicked_edge=i;
   620             {
   622             {
   621               //activate the general variable for it
   623               //activate the general variable for it
   622               active_edge=clicked_edge;
   624               active_edge=clicked_edge;
   623 
   625 
   624               //create a dialog
   626               //create a dialog
   625               Gtk::Dialog dialog("Edit value", *parentwin, true);
   627               Gtk::Dialog dialog("Edit value", mainwin, true);
   626               dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
   628               dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
   627               dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
   629               dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
   628               Gtk::VBox* vbox = dialog.get_vbox();
   630               Gtk::VBox* vbox = dialog.get_vbox();
   629               Gtk::SpinButton spin(0.0, 4);
   631               Gtk::SpinButton spin(0.0, 4);
   630               spin.set_increments(1.0, 10.0);
   632               spin.set_increments(1.0, 10.0);
   637                 case Gtk::RESPONSE_NONE:
   639                 case Gtk::RESPONSE_NONE:
   638                 case Gtk::RESPONSE_CANCEL:
   640                 case Gtk::RESPONSE_CANCEL:
   639                   break;
   641                   break;
   640                 case Gtk::RESPONSE_ACCEPT:
   642                 case Gtk::RESPONSE_ACCEPT:
   641                   double new_value = spin.get_value();
   643                   double new_value = spin.get_value();
   642                   (*mapstorage.edgemap_storage[edgemap_to_edit])[active_edge] =
   644                   (*(mainwin.mapstorage).edgemap_storage[edgemap_to_edit])[active_edge] =
   643                     new_value;
   645                     new_value;
   644                   std::ostringstream ostr;
   646                   std::ostringstream ostr;
   645                   ostr << new_value;
   647                   ostr << new_value;
   646                   edgetextmap[active_edge]->property_text().set_value(
   648                   edgetextmap[active_edge]->property_text().set_value(
   647                       ostr.str());
   649                       ostr.str());
   648                   //mapwin.updateEdge(active_edge);
   650                   //mapwin.updateEdge(active_edge);
   649                   mapwin.updateEdge(Edge(INVALID));
   651 //                   mapwin.updateEdge(Edge(INVALID));
       
   652                   propertyUpdate(Edge(INVALID));
   650               }
   653               }
   651             }
   654             }
   652           }
   655           }
   653           break;
   656           break;
   654         }
   657         }
   672 
   675 
   673           window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   676           window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   674           active_item=(get_item_at(clicked_x, clicked_y));
   677           active_item=(get_item_at(clicked_x, clicked_y));
   675 
   678 
   676           //find the activated item between texts
   679           //find the activated item between texts
   677           for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
   680           for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
   678           {
   681           {
   679             //at the same time only one can be active
   682             //at the same time only one can be active
   680             if(nodetextmap[i]==active_item)
   683             if(nodetextmap[i]==active_item)
   681             {
   684             {
   682               clicked_node=i;
   685               clicked_node=i;
   684           }
   687           }
   685 
   688 
   686           //if there was not, search for it between nodes
   689           //if there was not, search for it between nodes
   687           if(clicked_node==INVALID)
   690           if(clicked_node==INVALID)
   688           {
   691           {
   689             for (NodeIt i(mapstorage.graph); i!=INVALID; ++i)
   692             for (NodeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
   690             {
   693             {
   691               //at the same time only one can be active
   694               //at the same time only one can be active
   692               if(nodesmap[i]==active_item)
   695               if(nodesmap[i]==active_item)
   693               {
   696               {
   694                 clicked_node=i;
   697                 clicked_node=i;
   707             {
   710             {
   708               //activate the general variable for it
   711               //activate the general variable for it
   709               active_node=clicked_node;
   712               active_node=clicked_node;
   710 
   713 
   711               //create a dialog
   714               //create a dialog
   712               Gtk::Dialog dialog("Edit value", *parentwin, true);
   715               Gtk::Dialog dialog("Edit value", mainwin, true);
   713               dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
   716               dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
   714               dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
   717               dialog.add_button(Gtk::Stock::OK, Gtk::RESPONSE_ACCEPT);
   715               Gtk::VBox* vbox = dialog.get_vbox();
   718               Gtk::VBox* vbox = dialog.get_vbox();
   716               Gtk::SpinButton spin(0.0, 4);
   719               Gtk::SpinButton spin(0.0, 4);
   717               spin.set_increments(1.0, 10.0);
   720               spin.set_increments(1.0, 10.0);
   724                 case Gtk::RESPONSE_NONE:
   727                 case Gtk::RESPONSE_NONE:
   725                 case Gtk::RESPONSE_CANCEL:
   728                 case Gtk::RESPONSE_CANCEL:
   726                   break;
   729                   break;
   727                 case Gtk::RESPONSE_ACCEPT:
   730                 case Gtk::RESPONSE_ACCEPT:
   728                   double new_value = spin.get_value();
   731                   double new_value = spin.get_value();
   729                   (*mapstorage.nodemap_storage[nodemap_to_edit])[active_node] =
   732                   (*(mainwin.mapstorage).nodemap_storage[nodemap_to_edit])[active_node] =
   730                     new_value;
   733                     new_value;
   731                   std::ostringstream ostr;
   734                   std::ostringstream ostr;
   732                   ostr << new_value;
   735                   ostr << new_value;
   733                   nodetextmap[active_node]->property_text().set_value(
   736                   nodetextmap[active_node]->property_text().set_value(
   734                       ostr.str());
   737                       ostr.str());
   735                   //mapwin.updateNode(active_node);
   738                   //mapwin.updateNode(active_node);
   736                   mapwin.updateNode(Node(INVALID));
   739 //                   mapwin.updateNode(Node(INVALID));
       
   740                   propertyUpdate(Node(INVALID));
   737               }
   741               }
   738             }
   742             }
   739           }
   743           }
   740           break;
   744           break;
   741         }
   745         }
   748 
   752 
   749 void GraphDisplayerCanvas::deleteItem(Node node_to_delete)
   753 void GraphDisplayerCanvas::deleteItem(Node node_to_delete)
   750 {
   754 {
   751   delete(nodetextmap[node_to_delete]);
   755   delete(nodetextmap[node_to_delete]);
   752   delete(nodesmap[node_to_delete]);
   756   delete(nodesmap[node_to_delete]);
   753   mapstorage.graph.erase(node_to_delete);
   757   (mainwin.mapstorage).graph.erase(node_to_delete);
   754 }
   758 }
   755 
   759 
   756 void GraphDisplayerCanvas::deleteItem(Edge edge_to_delete)
   760 void GraphDisplayerCanvas::deleteItem(Edge edge_to_delete)
   757 {
   761 {
   758   delete(edgetextmap[edge_to_delete]);
   762   delete(edgetextmap[edge_to_delete]);
   759   delete(edgesmap[edge_to_delete]);
   763   delete(edgesmap[edge_to_delete]);
   760   mapstorage.graph.erase(edge_to_delete);
   764   (mainwin.mapstorage).graph.erase(edge_to_delete);
   761 }
   765 }
   762 
   766 
   763 void GraphDisplayerCanvas::textReposition(xy<double> new_place)
   767 void GraphDisplayerCanvas::textReposition(xy<double> new_place)
   764 {
   768 {
   765   new_place+=(xy<double>(10,10));
   769   new_place+=(xy<double>(10,10));
   775 	{
   779 	{
   776 	  std::cerr << "ERROR!!!! Valid edge found!" << std::endl;
   780 	  std::cerr << "ERROR!!!! Valid edge found!" << std::endl;
   777 	}
   781 	}
   778       else
   782       else
   779 	{
   783 	{
   780 	  for (EdgeIt i(mapstorage.graph); i!=INVALID; ++i)
   784 	  for (EdgeIt i((mainwin.mapstorage).graph); i!=INVALID; ++i)
   781 	    {
   785 	    {
   782 	      if(edgesmap[i]==active_bre)
   786 	      if(edgesmap[i]==active_bre)
   783 		{
   787 		{
   784 		  forming_edge=i;
   788 		  forming_edge=i;
   785 		}
   789 		}
   801 }
   805 }
   802 
   806 
   803 int GraphDisplayerCanvas::addNewEdgeMap(double default_value, std::string mapname)
   807 int GraphDisplayerCanvas::addNewEdgeMap(double default_value, std::string mapname)
   804 {
   808 {
   805   //create the new map
   809   //create the new map
   806   Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> (mapstorage.graph, default_value);
   810   Graph::EdgeMap<double> * emptr=new Graph::EdgeMap<double> ((mainwin.mapstorage).graph, default_value);
   807 
   811 
   808   //if addition was not successful addEdgeMap returns one.
   812   //if addition was not successful addEdgeMap returns one.
   809   //cause can be that there is already a map named like the new one
   813   //cause can be that there is already a map named like the new one
   810   if(mapstorage.addEdgeMap(mapname,emptr, default_value))
   814   if((mainwin.mapstorage).addEdgeMap(mapname,emptr, default_value))
   811     {
   815     {
   812       return 1;
   816       return 1;
   813     }
   817     }
   814 
   818 
   815 
   819 
   816   //add it to the list of the displayable maps
   820   //add it to the list of the displayable maps
   817   mapwin.registerNewEdgeMap(mapname);
   821   mainwin.registerNewEdgeMap(mapname);
   818 
   822 
   819   //display it
   823   //display it
   820   changeEdgeText(mapname);
   824   changeEdgeText(mapname);
   821 
   825 
   822   return 0;
   826   return 0;
   823 }
   827 }
   824 
   828 
   825 int GraphDisplayerCanvas::addNewNodeMap(double default_value, std::string mapname)
   829 int GraphDisplayerCanvas::addNewNodeMap(double default_value, std::string mapname)
   826 {
   830 {
   827   //create the new map
   831   //create the new map
   828   Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> (mapstorage.graph,default_value);
   832   Graph::NodeMap<double> * emptr=new Graph::NodeMap<double> ((mainwin.mapstorage).graph,default_value);
   829 
   833 
   830   //if addition was not successful addNodeMap returns one.
   834   //if addition was not successful addNodeMap returns one.
   831   //cause can be that there is already a map named like the new one
   835   //cause can be that there is already a map named like the new one
   832   if(mapstorage.addNodeMap(mapname,emptr, default_value))
   836   if((mainwin.mapstorage).addNodeMap(mapname,emptr, default_value))
   833     {
   837     {
   834       return 1;
   838       return 1;
   835     }
   839     }
   836 
   840 
   837   //add it to the list of the displayable maps
   841   //add it to the list of the displayable maps
   838   mapwin.registerNewNodeMap(mapname);
   842   mainwin.registerNewNodeMap(mapname);
   839 
   843 
   840   //display it
   844   //display it
   841   changeNodeText(mapname);
   845   changeNodeText(mapname);
   842 
   846 
   843   return 0;
   847   return 0;