[Lemon-commits] [lemon_svn] hegyi: r1966 - hugo/trunk/gui

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:49:08 CET 2006


Author: hegyi
Date: Tue Jun 14 17:58:12 2005
New Revision: 1966

Modified:
   hugo/trunk/gui/all_include.h
   hugo/trunk/gui/edit_win.cc
   hugo/trunk/gui/graph_displayer_canvas.cc
   hugo/trunk/gui/graph_displayer_canvas.h

Log:
Erasing from graph would be possible, if erasing from graph would be possible... (Afternoon has become timewasting...)

Modified: hugo/trunk/gui/all_include.h
==============================================================================
--- hugo/trunk/gui/all_include.h	(original)
+++ hugo/trunk/gui/all_include.h	Tue Jun 14 17:58:12 2005
@@ -17,7 +17,7 @@
 #include <lemon/xy.h>
 
 enum {WIDTH, COLOR, TEXT, PROPERTY_NUM}; // edge properties;
-enum {MOVE, CREATE_NODE, CREATE_EDGE, TOOL_NUM}; // tools;
+enum {MOVE, CREATE_NODE, CREATE_EDGE, ERASER, TOOL_NUM}; // tools;
 #define RANGE 3
 #define WIN_WIDTH 900
 #define WIN_HEIGHT 600

Modified: hugo/trunk/gui/edit_win.cc
==============================================================================
--- hugo/trunk/gui/edit_win.cc	(original)
+++ hugo/trunk/gui/edit_win.cc	Tue Jun 14 17:58:12 2005
@@ -68,6 +68,20 @@
      );
   table.attach(*buttons[MOVE],0,1,1,2);
       
+  //New edge button
+  buttons[ERASER]=new Gtk::RadioButton("Erase Item");
+  buttons[ERASER]->set_mode(false);
+  buttons[ERASER]->set_group(group);
+  buttons[ERASER]->signal_clicked().connect
+    (
+     sigc::bind
+     (
+      sigc::mem_fun(*this, &EditWin::makeEditorialToolChanged),
+      3
+      )
+     );
+  table.attach(*buttons[ERASER],1,2,1,2);
+    
   add(table);
 
   show_all_children();

Modified: hugo/trunk/gui/graph_displayer_canvas.cc
==============================================================================
--- hugo/trunk/gui/graph_displayer_canvas.cc	(original)
+++ hugo/trunk/gui/graph_displayer_canvas.cc	Tue Jun 14 17:58:12 2005
@@ -322,6 +322,11 @@
     case CREATE_EDGE:
       actual_handler=displayed_graph.signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::create_edge_event_handler), false);
       break;
+
+    case ERASER:
+      actual_handler=displayed_graph.signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::eraser_event_handler), false);
+      break;
+
     default:
       break;
     }
@@ -584,3 +589,87 @@
   return false;
 }
 
+bool GraphDisplayerCanvas::eraser_event_handler(GdkEvent* e)
+{
+  switch(e->type)
+    {
+    case GDK_BUTTON_PRESS:
+      active_item=(get_item_at(e->button.x, e->button.y));
+      active_node=INVALID;
+      active_edge=INVALID;
+      for (NodeIt i(g); i!=INVALID; ++i)
+	{
+	  if(nodesmap[i]==active_item)
+	    {
+	      active_node=i;
+	    }
+	}
+      if(active_node==INVALID)
+	{
+	  for (EdgeIt i(g); i!=INVALID; ++i)
+	    {
+	      if(edgesmap[i]==active_item)
+		{
+		  active_edge=i;
+		}
+	    }
+	}
+    *active_item << Gnome::Canvas::Properties::fill_color("red");
+      break;
+
+    case GDK_BUTTON_RELEASE:
+      if(active_item==(get_item_at(e->button.x, e->button.y)))
+	{
+	  if(active_node!=INVALID)
+	    {
+	      EdgeIt e;
+	      g.firstOut(e,active_node);
+	      for(;e!=INVALID;g.nextOut(e))
+		{
+		  delete_item(edgesmap[e]);
+		  //edgesmap[e]->property_points().set_value(coos);
+		  //edgetextmap[e]->property_y().set_value((y1+y2)/2);
+		}
+
+	      g.firstIn(e,active_node);
+	      for(;e!=INVALID;g.nextIn(e))
+		{
+		  delete_item(edgesmap[e]);
+		  //edgesmap[e]->get_bounds(x1, y1, x2, y2);
+		  //edgetextmap[e]->property_y().set_value((y1+y2)/2);
+		}
+	    }
+	  delete_item(active_item);
+	  
+	}
+      else
+	{
+	  if(active_node!=INVALID)
+	    {
+	      *active_item << Gnome::Canvas::Properties::fill_color("blue");
+	    }
+	  else
+	    {
+	      *active_item << Gnome::Canvas::Properties::fill_color("green");
+	    }
+	}
+      active_item=NULL;
+      active_edge=INVALID;
+      active_node=INVALID;
+      break;
+
+    case GDK_MOTION_NOTIFY:
+      break;
+
+    default:
+      break;
+    }
+  return true;
+}
+
+void GraphDisplayerCanvas::delete_item(Gnome::Canvas::Item * item_to_delete)
+{
+  //item_to_delete->hide();
+  delete(item_to_delete);
+}
+

Modified: hugo/trunk/gui/graph_displayer_canvas.h
==============================================================================
--- hugo/trunk/gui/graph_displayer_canvas.h	(original)
+++ hugo/trunk/gui/graph_displayer_canvas.h	Tue Jun 14 17:58:12 2005
@@ -66,6 +66,11 @@
   bool create_node_event_handler(GdkEvent*);
   ///event handler for the case when create_edge-tool is active
   bool create_edge_event_handler(GdkEvent*);
+  ///event handler for the case when eraser-tool is active
+  bool eraser_event_handler(GdkEvent*);
+
+  ///Deletes the given item.
+  void delete_item(Gnome::Canvas::Item *);
 
   ///The graph, on which we work
   Graph g;



More information about the Lemon-commits mailing list