# HG changeset patch # User hegyi # Date 1119011153 0 # Node ID 39d59aee2a1acd1b1645a2d0805ac57acec6b985 # Parent a222eb109e528bfcc0416605e5da50f9231df34e Very small bug is corrected: if node creator tool is active, the small red arrows won't move, if you click on them and if you drag the newly created node... 'was hard to notice it :-) diff -r a222eb109e52 -r 39d59aee2a1a gui/all_include.h --- a/gui/all_include.h Thu Jun 16 18:58:15 2005 +0000 +++ b/gui/all_include.h Fri Jun 17 12:25:53 2005 +0000 @@ -17,7 +17,7 @@ #include enum {WIDTH, COLOR, TEXT, PROPERTY_NUM}; // edge properties; -enum {MOVE, CREATE_NODE, CREATE_EDGE, ERASER, TOOL_NUM}; // tools; +enum {MOVE, CREATE_NODE, CREATE_EDGE, ERASER, EDGE_MAP_EDIT, TOOL_NUM}; // tools; #define RANGE 3 #define WIN_WIDTH 900 #define WIN_HEIGHT 600 diff -r a222eb109e52 -r 39d59aee2a1a gui/broken_edge.cc --- a/gui/broken_edge.cc Thu Jun 16 18:58:15 2005 +0000 +++ b/gui/broken_edge.cc Fri Jun 17 12:25:53 2005 +0000 @@ -2,7 +2,7 @@ #include #include -BrokenEdge::BrokenEdge(Gnome::Canvas::Group & g, Gnome::Canvas::Points p) : Line(g), isbutton(false) +BrokenEdge::BrokenEdge(Gnome::Canvas::Group & g, Gnome::Canvas::Points p, GraphDisplayerCanvas & gc) : Line(g), gdc(gc), isbutton(false) { my_points=new Gnome::Art::Point[3]; @@ -110,9 +110,12 @@ { case GDK_BUTTON_PRESS: //we mark the location of the event to be able to calculate parameters of dragging - clicked_x=e->button.x; - clicked_y=e->button.y; - isbutton=true; + if(gdc.get_actual_tool()!=CREATE_NODE) + { + clicked_x=e->button.x; + clicked_y=e->button.y; + isbutton=true; + } break; case GDK_BUTTON_RELEASE: isbutton=false; diff -r a222eb109e52 -r 39d59aee2a1a gui/broken_edge.h --- a/gui/broken_edge.h Thu Jun 16 18:58:15 2005 +0000 +++ b/gui/broken_edge.h Fri Jun 17 12:25:53 2005 +0000 @@ -3,15 +3,20 @@ #ifndef BROKEN_EDGE_H #define BROKEN_EDGE_H +class BrokenEdge; + #include #include #include +#include class BrokenEdge : public Gnome::Canvas::Line { + GraphDisplayerCanvas & gdc; Gnome::Canvas::Polygon * arrow; Gnome::Art::Point * my_points; + ///Indicates whether the button of mouse is pressed or not bool isbutton; @@ -22,7 +27,7 @@ ///event handler for forming edges bool edge_former_event_handler(GdkEvent*); public: - BrokenEdge(Gnome::Canvas::Group &, Gnome::Canvas::Points); + BrokenEdge(Gnome::Canvas::Group &, Gnome::Canvas::Points, GraphDisplayerCanvas &); ~BrokenEdge(); void set_points(Gnome::Canvas::Points, bool move=false); }; diff -r a222eb109e52 -r 39d59aee2a1a gui/graph_displayer_canvas.cc --- a/gui/graph_displayer_canvas.cc Thu Jun 16 18:58:15 2005 +0000 +++ b/gui/graph_displayer_canvas.cc Fri Jun 17 12:25:53 2005 +0000 @@ -5,7 +5,8 @@ GraphDisplayerCanvas::GraphDisplayerCanvas(Graph & gr, CoordinatesMap & cm, MapStorage & ms):g(gr),nodesmap(g),edgesmap(g),edgetextmap(g),displayed_graph(*(root()), 0, 0),mapstorage(ms),isbutton(0),active_item(NULL),target_item(NULL) { - actual_handler=displayed_graph.signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::create_edge_event_handler), false); + actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::create_node_event_handler), false); + actual_tool=CREATE_NODE; active_node=INVALID; active_edge=INVALID; @@ -23,7 +24,7 @@ coos.push_back(Gnome::Art::Point(cm[g.source(i)].x,cm[g.source(i)].y)); coos.push_back(Gnome::Art::Point(cm[g.target(i)].x,cm[g.target(i)].y)); - edgesmap[i]=new BrokenEdge(displayed_graph, coos); + edgesmap[i]=new BrokenEdge(displayed_graph, coos, *this); *(edgesmap[i]) << Gnome::Canvas::Properties::fill_color("green"); edgesmap[i]->property_width_pixels().set_value(10); @@ -309,6 +310,16 @@ { actual_handler.disconnect(); + if(actual_tool==CREATE_EDGE) + { + GdkEvent * generated=new GdkEvent(); + generated->type=GDK_BUTTON_RELEASE; + generated->button.button=3; + create_edge_event_handler(generated); + } + + actual_tool=newtool; + switch(newtool) { case MOVE: @@ -333,6 +344,11 @@ } } +int GraphDisplayerCanvas::get_actual_tool() +{ + return actual_tool; +} + bool GraphDisplayerCanvas::move_event_handler(GdkEvent* e) { switch(e->type) @@ -564,7 +580,7 @@ coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2)); //drawing new edge - edgesmap[active_edge]=new BrokenEdge(displayed_graph, coos); + edgesmap[active_edge]=new BrokenEdge(displayed_graph, coos, *this); *(edgesmap[active_edge]) << Gnome::Canvas::Properties::fill_color("green"); edgesmap[active_edge]->property_width_pixels().set_value(10); diff -r a222eb109e52 -r 39d59aee2a1a gui/graph_displayer_canvas.h --- a/gui/graph_displayer_canvas.h Thu Jun 16 18:58:15 2005 +0000 +++ b/gui/graph_displayer_canvas.h Fri Jun 17 12:25:53 2005 +0000 @@ -3,6 +3,8 @@ #ifndef GRAPH_DISPLAYER_CANVAS_H #define GRAPH_DISPLAYER_CANVAS_H +class GraphDisplayerCanvas; + #include #include #include @@ -69,7 +71,14 @@ bool create_edge_event_handler(GdkEvent*); ///event handler for the case when eraser-tool is active bool eraser_event_handler(GdkEvent*); + ///event handler for the case when eraser-tool is active + bool edge_map_edit_event_handler(GdkEvent*); +public: + ///\return the actual tool in hand + int get_actual_tool(); + +private: ///Deletes the given element. void delete_item(NodeIt); ///Deletes the given element. @@ -77,6 +86,8 @@ ///Deletes the given element. void delete_item(Graph::Edge); +private: + ///The graph, on which we work Graph g; @@ -98,6 +109,9 @@ ///Indicates whether the button of mouse is pressed or not int isbutton; + ///Stores the actual tool in hand + int actual_tool; + ///At this location was the mousebutton pressed. ///It helps to calculate the distance of dragging. double clicked_x, clicked_y;