gui/graph_displayer_canvas.cc
changeset 1510 cde847387b5a
parent 1509 f9113440b667
child 1512 e54392395480
     1.1 --- a/gui/graph_displayer_canvas.cc	Thu Jun 23 17:56:24 2005 +0000
     1.2 +++ b/gui/graph_displayer_canvas.cc	Fri Jun 24 07:58:18 2005 +0000
     1.3 @@ -91,706 +91,3 @@
     1.4    writer.writeNodeMap("coordinates_y", yc);
     1.5    writer.run();
     1.6  }
     1.7 -
     1.8 -int GraphDisplayerCanvas::changeLineWidth (std::string mapname)
     1.9 -{
    1.10 -  for (EdgeIt i(g); i!=INVALID; ++i)
    1.11 -    {
    1.12 -      int w=(int)(*(mapstorage.edgemap_storage)[mapname])[i];
    1.13 -      if(w>=0)
    1.14 -	{
    1.15 -	  edgesmap[i]->property_width_pixels().set_value(w);
    1.16 -	}
    1.17 -    }
    1.18 -  return 0;
    1.19 -};
    1.20 -
    1.21 -int GraphDisplayerCanvas::changeColor (std::string mapname)
    1.22 -{  
    1.23 -
    1.24 -  //function maps the range of the maximum and
    1.25 -  //the minimum of the nodemap to the range of
    1.26 -  //green in RGB
    1.27 -
    1.28 -  for (EdgeIt i(g); i!=INVALID; ++i)
    1.29 -  {
    1.30 -    double w=(*(mapstorage.edgemap_storage)[mapname])[i];
    1.31 -    double max=mapstorage.maxOfEdgeMap(mapname);
    1.32 -    double min=mapstorage.minOfEdgeMap(mapname);
    1.33 -      
    1.34 -    //std::cout<<w<<" "<<max<<" "<<min<<" "<<100*(w-min)/(max-min)<<std::endl;
    1.35 -    Gdk::Color color;
    1.36 -    if(max!=min)
    1.37 -    {
    1.38 -      color.set_rgb_p (0, 100*(w-min)/(max-min), 0);
    1.39 -    }
    1.40 -    else
    1.41 -    {
    1.42 -      color.set_rgb_p (0, 100, 0);
    1.43 -    }
    1.44 -
    1.45 -    edgesmap[i]->property_fill_color_gdk().set_value(color);
    1.46 -  }
    1.47 -  return 0;
    1.48 -};
    1.49 -
    1.50 -int GraphDisplayerCanvas::changeText (std::string mapname)
    1.51 -{
    1.52 -
    1.53 -  //the number in the map will be written on the edge
    1.54 -  //EXCEPT when the name of the map is Text, because
    1.55 -  //in that case empty string will be written, because
    1.56 -  //that is the deleter map
    1.57 -  //\todo isn't it a bit woodcutter?
    1.58 -
    1.59 -  for (EdgeIt i(g); i!=INVALID; ++i)
    1.60 -    {
    1.61 -      if(mapname!="Text")
    1.62 -	{
    1.63 -	  double number=(*(mapstorage.edgemap_storage)[mapname])[i];
    1.64 -	  int length=1;
    1.65 -	  //if number is smaller than one, length would be negative, or invalid
    1.66 -	  if(number>=1)
    1.67 -	    {
    1.68 -	      length=(int)(floor(log(number)/log(10)))+1;
    1.69 -	    }
    1.70 -	  int maxpos=(int)(pow(10,length-1));
    1.71 -	  int strl=length+1+RANGE;
    1.72 -	  char * str=new char[strl];
    1.73 -	  str[length]='.';
    1.74 -	  str[strl]='\0';
    1.75 -      
    1.76 -	  for(int j=0;j<strl;j++)
    1.77 -	    {
    1.78 -	      if(j!=length)
    1.79 -		{
    1.80 -		  int digit=(int)(number/maxpos);
    1.81 -		  str[j]=(digit+'0');
    1.82 -		  number-=digit*maxpos;
    1.83 -		  number*=10;
    1.84 -		}
    1.85 -	    }
    1.86 -      
    1.87 -	  edgetextmap[i]->property_text().set_value(str);
    1.88 -	}
    1.89 -      else
    1.90 -	{
    1.91 -	  edgetextmap[i]->property_text().set_value("");
    1.92 -	}
    1.93 -    }
    1.94 -  return 0;
    1.95 -};
    1.96 -
    1.97 -//Deprecated
    1.98 -bool GraphDisplayerCanvas::event_handler(GdkEvent* e, Node n)
    1.99 -{
   1.100 -  switch(e->type)
   1.101 -  {
   1.102 -    case GDK_BUTTON_PRESS:
   1.103 -      //we mark the location of the event to be able to calculate parameters of dragging
   1.104 -      clicked_x=e->button.x;
   1.105 -      clicked_y=e->button.y;
   1.106 -      active_item=(get_item_at(e->button.x, e->button.y));
   1.107 -      isbutton=1;
   1.108 -      break;
   1.109 -    case GDK_BUTTON_RELEASE:
   1.110 -      isbutton=0;
   1.111 -      active_item=NULL;
   1.112 -      updateScrollRegion();
   1.113 -      break;
   1.114 -    case GDK_MOTION_NOTIFY:
   1.115 -      //we only have to do sg. if the mouse button is pressed
   1.116 -      if(isbutton)
   1.117 -      {
   1.118 -	//new coordinates will be the old values,
   1.119 -	//because the item will be moved to the
   1.120 -	//new coordinate therefore the new movement
   1.121 -	//has to be calculated from here
   1.122 -
   1.123 -        double dx=e->motion.x-clicked_x;
   1.124 -        double dy=e->motion.y-clicked_y;
   1.125 -        active_item->move(dx, dy);
   1.126 -        clicked_x=e->motion.x;
   1.127 -        clicked_y=e->motion.y;
   1.128 -
   1.129 -	//all the edges connected to the moved point has to be redrawn
   1.130 -
   1.131 -        EdgeIt e;
   1.132 -        g.firstOut(e,n);
   1.133 -        for(;e!=INVALID;g.nextOut(e))
   1.134 -        {
   1.135 -            Gnome::Canvas::Points coos;
   1.136 -            double x1, x2, y1, y2;
   1.137 -
   1.138 -            nodesmap[g.source(e)]->get_bounds(x1, y1, x2, y2);
   1.139 -            coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   1.140 -
   1.141 -            nodesmap[g.target(e)]->get_bounds(x1, y1, x2, y2);
   1.142 -            coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   1.143 -
   1.144 -            edgesmap[e]->property_points().set_value(coos);
   1.145 -
   1.146 -	    edgesmap[e]->get_bounds(x1, y1, x2, y2);
   1.147 -
   1.148 -	    edgetextmap[e]->property_x().set_value((x1+x2)/2);
   1.149 -	    edgetextmap[e]->property_y().set_value((y1+y2)/2);
   1.150 -        }
   1.151 -
   1.152 -        g.firstIn(e,n);
   1.153 -        for(;e!=INVALID;g.nextIn(e))
   1.154 -        {
   1.155 -            Gnome::Canvas::Points coos;
   1.156 -            double x1, x2, y1, y2;
   1.157 -
   1.158 -            nodesmap[g.source(e)]->get_bounds(x1, y1, x2, y2);
   1.159 -            coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   1.160 -
   1.161 -            nodesmap[g.target(e)]->get_bounds(x1, y1, x2, y2);
   1.162 -            coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   1.163 -
   1.164 -            edgesmap[e]->property_points().set_value(coos);
   1.165 -
   1.166 -	    edgesmap[e]->get_bounds(x1, y1, x2, y2);
   1.167 -
   1.168 -	    edgetextmap[e]->property_x().set_value((x1+x2)/2);
   1.169 -	    edgetextmap[e]->property_y().set_value((y1+y2)/2);
   1.170 -        }
   1.171 -      }
   1.172 -    default: break;
   1.173 -  }
   1.174 -  return true;
   1.175 -}
   1.176 -
   1.177 -bool GraphDisplayerCanvas::on_expose_event(GdkEventExpose *event)
   1.178 -{
   1.179 -  Gnome::Canvas::CanvasAA::on_expose_event(event);
   1.180 -  //usleep(10000);
   1.181 -  //rezoom();
   1.182 -  return true;
   1.183 -}
   1.184 -
   1.185 -void GraphDisplayerCanvas::zoomIn()
   1.186 -{
   1.187 -  set_pixels_per_unit(
   1.188 -      (1.0 + (double) zoom_step / 100.0) * get_pixels_per_unit());
   1.189 -}
   1.190 -
   1.191 -void GraphDisplayerCanvas::zoomOut()
   1.192 -{
   1.193 -  set_pixels_per_unit(
   1.194 -      (1.0 - (double) zoom_step / 100.0) * get_pixels_per_unit());
   1.195 -}
   1.196 -
   1.197 -void GraphDisplayerCanvas::zoomFit()
   1.198 -{
   1.199 -  // get the height and width of the canvas
   1.200 -  Gtk::Allocation a = get_allocation();
   1.201 -  int aw = a.get_width();
   1.202 -  int ah = a.get_height();
   1.203 -  // add some space
   1.204 -  aw -= 5; if (aw < 0) aw = 0;
   1.205 -  ah -= 5; if (ah < 0) ah = 0;
   1.206 -
   1.207 -  // get the bounding box of the graph
   1.208 -  double wx1, wy1, wx2, wy2;
   1.209 -  Gnome::Canvas::Item* pCanvasItem = root();
   1.210 -  pCanvasItem->get_bounds(wx1, wy1, wx2, wy2);
   1.211 -
   1.212 -  // fit the graph to the window
   1.213 -  double ppu1 = (double) aw / fabs(wx2 - wx1);
   1.214 -  double ppu2 = (double) ah / fabs(wy2 - wy1);
   1.215 -  set_pixels_per_unit((ppu1 < ppu2) ? ppu1 : ppu2);
   1.216 -}
   1.217 -
   1.218 -void GraphDisplayerCanvas::zoom100()
   1.219 -{
   1.220 -  set_pixels_per_unit(1.0);
   1.221 -}
   1.222 -
   1.223 -void GraphDisplayerCanvas::updateScrollRegion()
   1.224 -{
   1.225 -  double wx1, wy1, wx2, wy2;
   1.226 -  Gnome::Canvas::Item* pCanvasItem = root();
   1.227 -  pCanvasItem->get_bounds(wx1, wy1, wx2, wy2);
   1.228 -  set_scroll_region(wx1, wy1, wx2, wy2);
   1.229 -}
   1.230 -
   1.231 -void GraphDisplayerCanvas::changeEditorialTool(int newtool)
   1.232 -{
   1.233 -  actual_handler.disconnect();
   1.234 -
   1.235 -  if(actual_tool==CREATE_EDGE)
   1.236 -    {
   1.237 -	GdkEvent * generated=new GdkEvent();
   1.238 -	generated->type=GDK_BUTTON_RELEASE;
   1.239 -	generated->button.button=3;
   1.240 -	create_edge_event_handler(generated);      
   1.241 -    }
   1.242 -
   1.243 -  actual_tool=newtool;
   1.244 -
   1.245 -  switch(newtool)
   1.246 -    {
   1.247 -    case MOVE:
   1.248 -      actual_handler=displayed_graph.signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::move_event_handler), false);
   1.249 -      break;
   1.250 -
   1.251 -      //it has to assigned to canvas, because all the canvas has to be monitored, not only the elements of the already drawn group
   1.252 -    case CREATE_NODE:
   1.253 -      actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::create_node_event_handler), false);
   1.254 -      break;
   1.255 -
   1.256 -    case CREATE_EDGE:
   1.257 -      actual_handler=displayed_graph.signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::create_edge_event_handler), false);
   1.258 -      break;
   1.259 -
   1.260 -    case ERASER:
   1.261 -      actual_handler=displayed_graph.signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::eraser_event_handler), false);
   1.262 -      break;
   1.263 -
   1.264 -    default:
   1.265 -      break;
   1.266 -    }
   1.267 -}
   1.268 -
   1.269 -int GraphDisplayerCanvas::get_actual_tool()
   1.270 -{
   1.271 -  return actual_tool;
   1.272 -}
   1.273 -
   1.274 -bool GraphDisplayerCanvas::move_event_handler(GdkEvent* e)
   1.275 -{
   1.276 -  switch(e->type)
   1.277 -  {
   1.278 -    case GDK_BUTTON_PRESS:
   1.279 -      //we mark the location of the event to be able to calculate parameters of dragging
   1.280 -      clicked_x=e->button.x;
   1.281 -      clicked_y=e->button.y;
   1.282 -      active_item=(get_item_at(e->button.x, e->button.y));
   1.283 -      active_node=INVALID;
   1.284 -      for (NodeIt i(g); i!=INVALID; ++i)
   1.285 -	{
   1.286 -	  if(nodesmap[i]==active_item)
   1.287 -	    {
   1.288 -	      active_node=i;
   1.289 -	    }
   1.290 -	}
   1.291 -      switch(e->button.button)
   1.292 -	{
   1.293 -	case 3:      
   1.294 -	  isbutton=3;
   1.295 -	  break;
   1.296 -	default:
   1.297 -	  isbutton=1;
   1.298 -	  break;
   1.299 -	}
   1.300 -      break;
   1.301 -    case GDK_BUTTON_RELEASE:
   1.302 -      isbutton=0;
   1.303 -      active_item=NULL;
   1.304 -      active_node=INVALID;
   1.305 -      updateScrollRegion();
   1.306 -      break;
   1.307 -    case GDK_MOTION_NOTIFY:
   1.308 -      //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
   1.309 -      if(active_node!=INVALID)
   1.310 -      {
   1.311 -	//new coordinates will be the old values,
   1.312 -	//because the item will be moved to the
   1.313 -	//new coordinate therefore the new movement
   1.314 -	//has to be calculated from here
   1.315 -
   1.316 -        double dx=e->motion.x-clicked_x;
   1.317 -        double dy=e->motion.y-clicked_y;
   1.318 -
   1.319 -        active_item->move(dx, dy);
   1.320 -
   1.321 -        clicked_x=e->motion.x;
   1.322 -        clicked_y=e->motion.y;
   1.323 -
   1.324 -	//all the edges connected to the moved point has to be redrawn
   1.325 -        EdgeIt ei;
   1.326 -
   1.327 -        g.firstOut(ei,active_node);
   1.328 -
   1.329 -        for(;ei!=INVALID;g.nextOut(ei))
   1.330 -        {
   1.331 -            Gnome::Canvas::Points coos;
   1.332 -            double x1, x2, y1, y2;
   1.333 -
   1.334 -            nodesmap[g.source(ei)]->get_bounds(x1, y1, x2, y2);
   1.335 -            coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   1.336 -
   1.337 -            nodesmap[g.target(ei)]->get_bounds(x1, y1, x2, y2);
   1.338 -            coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   1.339 -
   1.340 -	    if(isbutton==3)
   1.341 -	      {
   1.342 -		edgesmap[ei]->set_points(coos);
   1.343 -	      }
   1.344 -	    else
   1.345 -	      {
   1.346 -		edgesmap[ei]->set_points(coos,true);
   1.347 -	      }
   1.348 -
   1.349 -	    xy<double> text_pos=edgesmap[ei]->get_arrow_pos();
   1.350 -	    text_pos+=(xy<double>(10,10));
   1.351 -	    edgetextmap[ei]->property_x().set_value(text_pos.x);
   1.352 -	    edgetextmap[ei]->property_y().set_value(text_pos.y);
   1.353 -        }
   1.354 -
   1.355 -        g.firstIn(ei,active_node);
   1.356 -        for(;ei!=INVALID;g.nextIn(ei))
   1.357 -        {
   1.358 -            Gnome::Canvas::Points coos;
   1.359 -            double x1, x2, y1, y2;
   1.360 -
   1.361 -            nodesmap[g.source(ei)]->get_bounds(x1, y1, x2, y2);
   1.362 -            coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   1.363 -
   1.364 -            nodesmap[g.target(ei)]->get_bounds(x1, y1, x2, y2);
   1.365 -            coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   1.366 -
   1.367 -	    if(isbutton==3)
   1.368 -	      {
   1.369 -		edgesmap[ei]->set_points(coos);
   1.370 -	      }
   1.371 -	    else
   1.372 -	      {
   1.373 -		edgesmap[ei]->set_points(coos,true);
   1.374 -	      }
   1.375 -
   1.376 -	    xy<double> text_pos=edgesmap[ei]->get_arrow_pos();
   1.377 -	    text_pos+=(xy<double>(10,10));
   1.378 -	    edgetextmap[ei]->property_x().set_value(text_pos.x);
   1.379 -	    edgetextmap[ei]->property_y().set_value(text_pos.y);
   1.380 -        }
   1.381 -      }
   1.382 -    default: break;
   1.383 -  }
   1.384 -
   1.385 -  return true;
   1.386 -}
   1.387 -
   1.388 -bool GraphDisplayerCanvas::create_node_event_handler(GdkEvent* e)
   1.389 -{
   1.390 -  switch(e->type)
   1.391 -    {
   1.392 -
   1.393 -      //draw the new node in red at the clicked place
   1.394 -    case GDK_BUTTON_PRESS:
   1.395 -      isbutton=1;
   1.396 -
   1.397 -      active_node=NodeIt(g,g.addNode());
   1.398 -
   1.399 -      //initiating values corresponding to new node in maps
   1.400 -      
   1.401 -
   1.402 -      window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
   1.403 -
   1.404 -      nodesmap[active_node]=new Gnome::Canvas::Ellipse(displayed_graph, clicked_x-20, clicked_y-20, clicked_x+20, clicked_y+20);
   1.405 -      active_item=(Gnome::Canvas::Item *)(nodesmap[active_node]);
   1.406 -      *(nodesmap[active_node]) << Gnome::Canvas::Properties::fill_color("red");
   1.407 -      *(nodesmap[active_node]) << Gnome::Canvas::Properties::outline_color("black");
   1.408 -      (nodesmap[active_node])->show();
   1.409 -      break;
   1.410 -
   1.411 -      //move the new node
   1.412 -    case GDK_MOTION_NOTIFY:
   1.413 -      {
   1.414 -	double world_motion_x, world_motion_y;
   1.415 -	GdkEvent * generated=new GdkEvent();
   1.416 -	window_to_world (e->motion.x, e->motion.y, world_motion_x, world_motion_y);
   1.417 -	generated->motion.x=world_motion_x;
   1.418 -	generated->motion.y=world_motion_y;
   1.419 -	generated->type=GDK_MOTION_NOTIFY;
   1.420 -	move_event_handler(generated);      
   1.421 -	break;
   1.422 -      }
   1.423 -
   1.424 -      //finalize the new node
   1.425 -    case GDK_BUTTON_RELEASE:
   1.426 -      isbutton=0;
   1.427 -      *active_item << Gnome::Canvas::Properties::fill_color("blue");
   1.428 -      active_item=NULL;
   1.429 -      active_node=INVALID;
   1.430 -      updateScrollRegion();
   1.431 -      break;
   1.432 -    default:
   1.433 -      break;
   1.434 -    }
   1.435 -  return false;
   1.436 -}
   1.437 -
   1.438 -bool GraphDisplayerCanvas::create_edge_event_handler(GdkEvent* e)
   1.439 -{
   1.440 -  switch(e->type)
   1.441 -    {
   1.442 -    case GDK_BUTTON_PRESS:
   1.443 -      //in edge creation right button has special meaning
   1.444 -      if(e->button.button!=3)
   1.445 -	{
   1.446 -	  //there is not yet selected node
   1.447 -	  if(active_node==INVALID)
   1.448 -	    {
   1.449 -	      //we mark the location of the event to be able to calculate parameters of dragging
   1.450 -	      clicked_x=e->button.x;
   1.451 -	      clicked_y=e->button.y;
   1.452 -	      active_item=(get_item_at(e->button.x, e->button.y));
   1.453 -	      active_node=INVALID;
   1.454 -	      for (NodeIt i(g); i!=INVALID; ++i)
   1.455 -		{
   1.456 -		  if(nodesmap[i]==active_item)
   1.457 -		    {
   1.458 -		      active_node=i;
   1.459 -		    }
   1.460 -		}
   1.461 -	      //the clicked item is really a node
   1.462 -	      if(active_node!=INVALID)
   1.463 -		{
   1.464 -		  *(nodesmap[active_node]) << Gnome::Canvas::Properties::fill_color("red");
   1.465 -		  isbutton=1;
   1.466 -		}
   1.467 -	      //clicked item was not a node. It could be e.g. edge.
   1.468 -	      else
   1.469 -		{
   1.470 -		  active_item=NULL;
   1.471 -		}
   1.472 -	    }
   1.473 -	  //we only have to do sg. if the mouse button
   1.474 -	  // is pressed already once AND the click was
   1.475 -	  // on a node that was found in the set of 
   1.476 -	  //nodes, and now we only search for the second 
   1.477 -	  //node
   1.478 -	  else
   1.479 -	    {
   1.480 -	      target_item=(get_item_at(e->button.x, e->button.y));
   1.481 -	      Graph::NodeIt target_node=INVALID;
   1.482 -	      for (NodeIt i(g); i!=INVALID; ++i)
   1.483 -		{
   1.484 -		  if(nodesmap[i]==target_item)
   1.485 -		    {
   1.486 -		      target_node=i;
   1.487 -		    }
   1.488 -		}
   1.489 -	      //the clicked item is a node, the edge can be drawn
   1.490 -	      if(target_node!=INVALID)
   1.491 -		{
   1.492 -		  *(nodesmap[target_node]) << Gnome::Canvas::Properties::fill_color("red");
   1.493 -
   1.494 -		  //creating new edge
   1.495 -		  active_edge=EdgeIt(g,g.addEdge(active_node, target_node));
   1.496 -
   1.497 -		  //initiating values corresponding to new edge in maps
   1.498 -		  mapstorage.init_maps_for_edge(active_edge);
   1.499 -	  
   1.500 -		  //calculating coordinates of new edge
   1.501 -		  Gnome::Canvas::Points coos;
   1.502 -		  double x1, x2, y1, y2;
   1.503 -	  
   1.504 -		  active_item->get_bounds(x1, y1, x2, y2);
   1.505 -		  coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   1.506 -
   1.507 -		  target_item->get_bounds(x1, y1, x2, y2);
   1.508 -		  coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
   1.509 -
   1.510 -		  //drawing new edge
   1.511 -		  edgesmap[active_edge]=new BrokenEdge(displayed_graph, coos, *this);
   1.512 -		  *(edgesmap[active_edge]) << Gnome::Canvas::Properties::fill_color("green");
   1.513 -		  edgesmap[active_edge]->property_width_pixels().set_value(10);
   1.514 -
   1.515 -		  //redraw nodes to blank terminations of the new edge
   1.516 -		  target_item->raise_to_top();
   1.517 -		  active_item->raise_to_top();
   1.518 -
   1.519 -		  //initializing edge-text as well, to empty string
   1.520 -		  xy<double> text_pos=edgesmap[active_edge]->get_arrow_pos();
   1.521 -		  text_pos+=(xy<double>(10,10));
   1.522 -
   1.523 -		  edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, "");
   1.524 -		  edgetextmap[active_edge]->property_fill_color().set_value("black");
   1.525 -		}
   1.526 -	      //clicked item was not a node. it could be an e.g. edge. we do not deal with it furthermore.
   1.527 -	      else
   1.528 -		{
   1.529 -		  target_item=NULL;
   1.530 -		}
   1.531 -	    }
   1.532 -	}
   1.533 -      break;
   1.534 -    case GDK_BUTTON_RELEASE:
   1.535 -      isbutton=0;
   1.536 -      //we clear settings in two cases
   1.537 -      //1: the edge is ready (target_item has valid value)
   1.538 -      //2: the edge creation is cancelled with right button
   1.539 -      if((target_item)||(e->button.button==3))
   1.540 -	{
   1.541 -	  if(active_item)
   1.542 -	    {
   1.543 -	      *active_item << Gnome::Canvas::Properties::fill_color("blue");
   1.544 -	      active_item=NULL;
   1.545 -	    }
   1.546 -	  if(target_item)
   1.547 -	    {
   1.548 -	      *target_item << Gnome::Canvas::Properties::fill_color("blue");
   1.549 -	      target_item=NULL;
   1.550 -	    }
   1.551 -	  active_node=INVALID;
   1.552 -	  active_edge=INVALID;
   1.553 -	}
   1.554 -      break;
   1.555 -    default:
   1.556 -      break;
   1.557 -    }
   1.558 -  return false;
   1.559 -}
   1.560 -
   1.561 -bool GraphDisplayerCanvas::eraser_event_handler(GdkEvent* e)
   1.562 -{
   1.563 -  switch(e->type)
   1.564 -    {
   1.565 -    case GDK_BUTTON_PRESS:
   1.566 -      active_item=(get_item_at(e->button.x, e->button.y));
   1.567 -      active_node=INVALID;
   1.568 -      active_edge=INVALID;
   1.569 -      for (NodeIt i(g); i!=INVALID; ++i)
   1.570 -	{
   1.571 -	  if(nodesmap[i]==active_item)
   1.572 -	    {
   1.573 -	      active_node=i;
   1.574 -	    }
   1.575 -	}
   1.576 -      if(active_node==INVALID)
   1.577 -	{
   1.578 -	  for (EdgeIt i(g); i!=INVALID; ++i)
   1.579 -	    {
   1.580 -	      if(edgesmap[i]==active_item)
   1.581 -		{
   1.582 -		  active_edge=i;
   1.583 -		}
   1.584 -	    }
   1.585 -	}
   1.586 -    *active_item << Gnome::Canvas::Properties::fill_color("red");
   1.587 -      break;
   1.588 -
   1.589 -    case GDK_BUTTON_RELEASE:
   1.590 -      if(active_item==(get_item_at(e->button.x, e->button.y)))
   1.591 -	{
   1.592 -	  if(active_node!=INVALID)
   1.593 -	    {
   1.594 -
   1.595 -	      //collecting edges to delete
   1.596 -	      EdgeIt e;
   1.597 -	      std::set<Graph::Edge> edges_to_delete;
   1.598 -
   1.599 -	      g.firstOut(e,active_node);
   1.600 -	      for(;e!=INVALID;g.nextOut(e))
   1.601 -		{
   1.602 -		      edges_to_delete.insert(e);
   1.603 -		}
   1.604 -
   1.605 -	      g.firstIn(e,active_node);
   1.606 -	      for(;e!=INVALID;g.nextIn(e))
   1.607 -		{
   1.608 -		      edges_to_delete.insert(e);
   1.609 -		}
   1.610 -
   1.611 -	      //deleting collected edges
   1.612 -	      for(std::set<Graph::Edge>::iterator edge_set_it=edges_to_delete.begin();edge_set_it!=edges_to_delete.end();edge_set_it++)
   1.613 -		{
   1.614 -		  delete_item(*edge_set_it);
   1.615 -		}
   1.616 -	      delete_item(active_node);
   1.617 -	    }
   1.618 -	  //a simple edge was chosen
   1.619 -	  else
   1.620 -	    {
   1.621 -	      delete_item(active_edge);
   1.622 -	    }
   1.623 -
   1.624 -	  
   1.625 -	}
   1.626 -      //pointer was moved, deletion is cancelled
   1.627 -      else
   1.628 -	{
   1.629 -	  if(active_node!=INVALID)
   1.630 -	    {
   1.631 -	      *active_item << Gnome::Canvas::Properties::fill_color("blue");
   1.632 -	    }
   1.633 -	  else
   1.634 -	    {
   1.635 -	      *active_item << Gnome::Canvas::Properties::fill_color("green");
   1.636 -	    }
   1.637 -	}
   1.638 -      //reseting datas
   1.639 -      active_item=NULL;
   1.640 -      active_edge=INVALID;
   1.641 -      active_node=INVALID;
   1.642 -      break;
   1.643 -
   1.644 -    case GDK_MOTION_NOTIFY:
   1.645 -      break;
   1.646 -
   1.647 -    default:
   1.648 -      break;
   1.649 -    }
   1.650 -  return true;
   1.651 -}
   1.652 -
   1.653 -void GraphDisplayerCanvas::delete_item(NodeIt node_to_delete)
   1.654 -{
   1.655 -  delete(nodesmap[node_to_delete]);
   1.656 -  g.erase(node_to_delete);
   1.657 -}
   1.658 -
   1.659 -void GraphDisplayerCanvas::delete_item(EdgeIt edge_to_delete)
   1.660 -{
   1.661 -  delete(edgesmap[edge_to_delete]);
   1.662 -  g.erase(edge_to_delete);
   1.663 -}
   1.664 -
   1.665 -void GraphDisplayerCanvas::delete_item(Graph::Edge edge_to_delete)
   1.666 -{
   1.667 -  delete(edgesmap[edge_to_delete]);
   1.668 -  g.erase(edge_to_delete);
   1.669 -}
   1.670 -
   1.671 -void GraphDisplayerCanvas::text_reposition(xy<double> new_place)
   1.672 -{
   1.673 -  new_place+=(xy<double>(10,10));
   1.674 -  edgetextmap[active_edge]->property_x().set_value(new_place.x);
   1.675 -  edgetextmap[active_edge]->property_y().set_value(new_place.y);
   1.676 -}
   1.677 -
   1.678 -void GraphDisplayerCanvas::toggle_edge_activity(BrokenEdge* active_bre, bool on)
   1.679 -{
   1.680 -  if(on)
   1.681 -    {
   1.682 -      if(active_edge!=INVALID)
   1.683 -	{
   1.684 -	  std::cout << "ERROR!!!! Valid edge found!" << std::endl;
   1.685 -	}
   1.686 -      else
   1.687 -	{
   1.688 -	  for (EdgeIt i(g); i!=INVALID; ++i)
   1.689 -	    {
   1.690 -	      if(edgesmap[i]==active_bre)
   1.691 -		{
   1.692 -		  active_edge=i;
   1.693 -		}
   1.694 -	    }
   1.695 -	}
   1.696 -    }
   1.697 -  else
   1.698 -    {
   1.699 -      if(active_edge!=INVALID)
   1.700 -	{
   1.701 -	  active_edge=INVALID;
   1.702 -	}
   1.703 -      else
   1.704 -	{
   1.705 -	  std::cout << "ERROR!!!! Invalid edge found!" << std::endl;
   1.706 -	}
   1.707 -    }
   1.708 -
   1.709 -}