Erasing from graph would be possible, if erasing from graph would be possible... (Afternoon has become timewasting...)
1.1 --- a/gui/all_include.h Tue Jun 14 13:55:28 2005 +0000
1.2 +++ b/gui/all_include.h Tue Jun 14 15:58:12 2005 +0000
1.3 @@ -17,7 +17,7 @@
1.4 #include <lemon/xy.h>
1.5
1.6 enum {WIDTH, COLOR, TEXT, PROPERTY_NUM}; // edge properties;
1.7 -enum {MOVE, CREATE_NODE, CREATE_EDGE, TOOL_NUM}; // tools;
1.8 +enum {MOVE, CREATE_NODE, CREATE_EDGE, ERASER, TOOL_NUM}; // tools;
1.9 #define RANGE 3
1.10 #define WIN_WIDTH 900
1.11 #define WIN_HEIGHT 600
2.1 --- a/gui/edit_win.cc Tue Jun 14 13:55:28 2005 +0000
2.2 +++ b/gui/edit_win.cc Tue Jun 14 15:58:12 2005 +0000
2.3 @@ -68,6 +68,20 @@
2.4 );
2.5 table.attach(*buttons[MOVE],0,1,1,2);
2.6
2.7 + //New edge button
2.8 + buttons[ERASER]=new Gtk::RadioButton("Erase Item");
2.9 + buttons[ERASER]->set_mode(false);
2.10 + buttons[ERASER]->set_group(group);
2.11 + buttons[ERASER]->signal_clicked().connect
2.12 + (
2.13 + sigc::bind
2.14 + (
2.15 + sigc::mem_fun(*this, &EditWin::makeEditorialToolChanged),
2.16 + 3
2.17 + )
2.18 + );
2.19 + table.attach(*buttons[ERASER],1,2,1,2);
2.20 +
2.21 add(table);
2.22
2.23 show_all_children();
3.1 --- a/gui/graph_displayer_canvas.cc Tue Jun 14 13:55:28 2005 +0000
3.2 +++ b/gui/graph_displayer_canvas.cc Tue Jun 14 15:58:12 2005 +0000
3.3 @@ -322,6 +322,11 @@
3.4 case CREATE_EDGE:
3.5 actual_handler=displayed_graph.signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::create_edge_event_handler), false);
3.6 break;
3.7 +
3.8 + case ERASER:
3.9 + actual_handler=displayed_graph.signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::eraser_event_handler), false);
3.10 + break;
3.11 +
3.12 default:
3.13 break;
3.14 }
3.15 @@ -584,3 +589,87 @@
3.16 return false;
3.17 }
3.18
3.19 +bool GraphDisplayerCanvas::eraser_event_handler(GdkEvent* e)
3.20 +{
3.21 + switch(e->type)
3.22 + {
3.23 + case GDK_BUTTON_PRESS:
3.24 + active_item=(get_item_at(e->button.x, e->button.y));
3.25 + active_node=INVALID;
3.26 + active_edge=INVALID;
3.27 + for (NodeIt i(g); i!=INVALID; ++i)
3.28 + {
3.29 + if(nodesmap[i]==active_item)
3.30 + {
3.31 + active_node=i;
3.32 + }
3.33 + }
3.34 + if(active_node==INVALID)
3.35 + {
3.36 + for (EdgeIt i(g); i!=INVALID; ++i)
3.37 + {
3.38 + if(edgesmap[i]==active_item)
3.39 + {
3.40 + active_edge=i;
3.41 + }
3.42 + }
3.43 + }
3.44 + *active_item << Gnome::Canvas::Properties::fill_color("red");
3.45 + break;
3.46 +
3.47 + case GDK_BUTTON_RELEASE:
3.48 + if(active_item==(get_item_at(e->button.x, e->button.y)))
3.49 + {
3.50 + if(active_node!=INVALID)
3.51 + {
3.52 + EdgeIt e;
3.53 + g.firstOut(e,active_node);
3.54 + for(;e!=INVALID;g.nextOut(e))
3.55 + {
3.56 + delete_item(edgesmap[e]);
3.57 + //edgesmap[e]->property_points().set_value(coos);
3.58 + //edgetextmap[e]->property_y().set_value((y1+y2)/2);
3.59 + }
3.60 +
3.61 + g.firstIn(e,active_node);
3.62 + for(;e!=INVALID;g.nextIn(e))
3.63 + {
3.64 + delete_item(edgesmap[e]);
3.65 + //edgesmap[e]->get_bounds(x1, y1, x2, y2);
3.66 + //edgetextmap[e]->property_y().set_value((y1+y2)/2);
3.67 + }
3.68 + }
3.69 + delete_item(active_item);
3.70 +
3.71 + }
3.72 + else
3.73 + {
3.74 + if(active_node!=INVALID)
3.75 + {
3.76 + *active_item << Gnome::Canvas::Properties::fill_color("blue");
3.77 + }
3.78 + else
3.79 + {
3.80 + *active_item << Gnome::Canvas::Properties::fill_color("green");
3.81 + }
3.82 + }
3.83 + active_item=NULL;
3.84 + active_edge=INVALID;
3.85 + active_node=INVALID;
3.86 + break;
3.87 +
3.88 + case GDK_MOTION_NOTIFY:
3.89 + break;
3.90 +
3.91 + default:
3.92 + break;
3.93 + }
3.94 + return true;
3.95 +}
3.96 +
3.97 +void GraphDisplayerCanvas::delete_item(Gnome::Canvas::Item * item_to_delete)
3.98 +{
3.99 + //item_to_delete->hide();
3.100 + delete(item_to_delete);
3.101 +}
3.102 +
4.1 --- a/gui/graph_displayer_canvas.h Tue Jun 14 13:55:28 2005 +0000
4.2 +++ b/gui/graph_displayer_canvas.h Tue Jun 14 15:58:12 2005 +0000
4.3 @@ -66,6 +66,11 @@
4.4 bool create_node_event_handler(GdkEvent*);
4.5 ///event handler for the case when create_edge-tool is active
4.6 bool create_edge_event_handler(GdkEvent*);
4.7 + ///event handler for the case when eraser-tool is active
4.8 + bool eraser_event_handler(GdkEvent*);
4.9 +
4.10 + ///Deletes the given item.
4.11 + void delete_item(Gnome::Canvas::Item *);
4.12
4.13 ///The graph, on which we work
4.14 Graph g;