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 :-)
authorhegyi
Fri, 17 Jun 2005 12:25:53 +0000
changeset 150139d59aee2a1a
parent 1500 a222eb109e52
child 1502 371aba7d61ca
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 :-)
gui/all_include.h
gui/broken_edge.cc
gui/broken_edge.h
gui/graph_displayer_canvas.cc
gui/graph_displayer_canvas.h
     1.1 --- a/gui/all_include.h	Thu Jun 16 18:58:15 2005 +0000
     1.2 +++ b/gui/all_include.h	Fri Jun 17 12:25:53 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, ERASER, TOOL_NUM}; // tools;
     1.8 +enum {MOVE, CREATE_NODE, CREATE_EDGE, ERASER, EDGE_MAP_EDIT, TOOL_NUM}; // tools;
     1.9  #define RANGE 3
    1.10  #define WIN_WIDTH 900
    1.11  #define WIN_HEIGHT 600
     2.1 --- a/gui/broken_edge.cc	Thu Jun 16 18:58:15 2005 +0000
     2.2 +++ b/gui/broken_edge.cc	Fri Jun 17 12:25:53 2005 +0000
     2.3 @@ -2,7 +2,7 @@
     2.4  #include <lemon/xy.h>
     2.5  #include <math.h>
     2.6  
     2.7 -BrokenEdge::BrokenEdge(Gnome::Canvas::Group & g, Gnome::Canvas::Points p) : Line(g), isbutton(false)
     2.8 +BrokenEdge::BrokenEdge(Gnome::Canvas::Group & g, Gnome::Canvas::Points p, GraphDisplayerCanvas & gc) : Line(g), gdc(gc), isbutton(false)
     2.9  {
    2.10    my_points=new Gnome::Art::Point[3];
    2.11  
    2.12 @@ -110,9 +110,12 @@
    2.13      {
    2.14      case GDK_BUTTON_PRESS:
    2.15        //we mark the location of the event to be able to calculate parameters of dragging
    2.16 -      clicked_x=e->button.x;
    2.17 -      clicked_y=e->button.y;
    2.18 -      isbutton=true;
    2.19 +      if(gdc.get_actual_tool()!=CREATE_NODE)
    2.20 +	{
    2.21 +	  clicked_x=e->button.x;
    2.22 +	  clicked_y=e->button.y;
    2.23 +	  isbutton=true;
    2.24 +	}
    2.25        break;
    2.26      case GDK_BUTTON_RELEASE:
    2.27        isbutton=false;
     3.1 --- a/gui/broken_edge.h	Thu Jun 16 18:58:15 2005 +0000
     3.2 +++ b/gui/broken_edge.h	Fri Jun 17 12:25:53 2005 +0000
     3.3 @@ -3,15 +3,20 @@
     3.4  #ifndef BROKEN_EDGE_H
     3.5  #define BROKEN_EDGE_H
     3.6  
     3.7 +class BrokenEdge;
     3.8 +
     3.9  #include <all_include.h>
    3.10  #include <libgnomecanvasmm.h>
    3.11  #include <libgnomecanvasmm/polygon.h>
    3.12 +#include <graph_displayer_canvas.h>
    3.13  
    3.14  class BrokenEdge : public Gnome::Canvas::Line
    3.15  {
    3.16 +  GraphDisplayerCanvas & gdc;
    3.17    Gnome::Canvas::Polygon * arrow;
    3.18    Gnome::Art::Point * my_points;
    3.19  
    3.20 +
    3.21    ///Indicates whether the button of mouse is pressed or not
    3.22    bool isbutton;
    3.23  
    3.24 @@ -22,7 +27,7 @@
    3.25    ///event handler for forming edges
    3.26    bool edge_former_event_handler(GdkEvent*);
    3.27   public:
    3.28 -  BrokenEdge(Gnome::Canvas::Group &, Gnome::Canvas::Points);
    3.29 +  BrokenEdge(Gnome::Canvas::Group &, Gnome::Canvas::Points, GraphDisplayerCanvas &);
    3.30    ~BrokenEdge();
    3.31    void set_points(Gnome::Canvas::Points, bool move=false);
    3.32  };
     4.1 --- a/gui/graph_displayer_canvas.cc	Thu Jun 16 18:58:15 2005 +0000
     4.2 +++ b/gui/graph_displayer_canvas.cc	Fri Jun 17 12:25:53 2005 +0000
     4.3 @@ -5,7 +5,8 @@
     4.4  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)
     4.5  {
     4.6    
     4.7 -  actual_handler=displayed_graph.signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::create_edge_event_handler), false);
     4.8 +  actual_handler=signal_event().connect(sigc::mem_fun(*this, &GraphDisplayerCanvas::create_node_event_handler), false);
     4.9 +  actual_tool=CREATE_NODE;
    4.10  
    4.11    active_node=INVALID;
    4.12    active_edge=INVALID;
    4.13 @@ -23,7 +24,7 @@
    4.14      coos.push_back(Gnome::Art::Point(cm[g.source(i)].x,cm[g.source(i)].y));
    4.15      coos.push_back(Gnome::Art::Point(cm[g.target(i)].x,cm[g.target(i)].y));
    4.16      
    4.17 -    edgesmap[i]=new BrokenEdge(displayed_graph, coos);
    4.18 +    edgesmap[i]=new BrokenEdge(displayed_graph, coos, *this);
    4.19      *(edgesmap[i]) << Gnome::Canvas::Properties::fill_color("green");
    4.20      edgesmap[i]->property_width_pixels().set_value(10);    
    4.21      
    4.22 @@ -309,6 +310,16 @@
    4.23  {
    4.24    actual_handler.disconnect();
    4.25  
    4.26 +  if(actual_tool==CREATE_EDGE)
    4.27 +    {
    4.28 +	GdkEvent * generated=new GdkEvent();
    4.29 +	generated->type=GDK_BUTTON_RELEASE;
    4.30 +	generated->button.button=3;
    4.31 +	create_edge_event_handler(generated);      
    4.32 +    }
    4.33 +
    4.34 +  actual_tool=newtool;
    4.35 +
    4.36    switch(newtool)
    4.37      {
    4.38      case MOVE:
    4.39 @@ -333,6 +344,11 @@
    4.40      }
    4.41  }
    4.42  
    4.43 +int GraphDisplayerCanvas::get_actual_tool()
    4.44 +{
    4.45 +  return actual_tool;
    4.46 +}
    4.47 +
    4.48  bool GraphDisplayerCanvas::move_event_handler(GdkEvent* e)
    4.49  {
    4.50    switch(e->type)
    4.51 @@ -564,7 +580,7 @@
    4.52  		  coos.push_back(Gnome::Art::Point((x1+x2)/2,(y1+y2)/2));
    4.53  
    4.54  		  //drawing new edge
    4.55 -		  edgesmap[active_edge]=new BrokenEdge(displayed_graph, coos);
    4.56 +		  edgesmap[active_edge]=new BrokenEdge(displayed_graph, coos, *this);
    4.57  		  *(edgesmap[active_edge]) << Gnome::Canvas::Properties::fill_color("green");
    4.58  		  edgesmap[active_edge]->property_width_pixels().set_value(10);
    4.59  
     5.1 --- a/gui/graph_displayer_canvas.h	Thu Jun 16 18:58:15 2005 +0000
     5.2 +++ b/gui/graph_displayer_canvas.h	Fri Jun 17 12:25:53 2005 +0000
     5.3 @@ -3,6 +3,8 @@
     5.4  #ifndef GRAPH_DISPLAYER_CANVAS_H
     5.5  #define GRAPH_DISPLAYER_CANVAS_H
     5.6  
     5.7 +class GraphDisplayerCanvas;
     5.8 +
     5.9  #include <all_include.h>
    5.10  #include <mapstorage.h>
    5.11  #include <broken_edge.h>
    5.12 @@ -69,7 +71,14 @@
    5.13    bool create_edge_event_handler(GdkEvent*);
    5.14    ///event handler for the case when eraser-tool is active
    5.15    bool eraser_event_handler(GdkEvent*);
    5.16 +  ///event handler for the case when eraser-tool is active
    5.17 +  bool edge_map_edit_event_handler(GdkEvent*);
    5.18  
    5.19 +public:
    5.20 +  ///\return the actual tool in hand
    5.21 +  int get_actual_tool();
    5.22 +
    5.23 +private:
    5.24    ///Deletes the given element.
    5.25    void delete_item(NodeIt);
    5.26    ///Deletes the given element.
    5.27 @@ -77,6 +86,8 @@
    5.28    ///Deletes the given element.
    5.29    void delete_item(Graph::Edge);
    5.30  
    5.31 +private:
    5.32 +
    5.33    ///The graph, on which we work
    5.34    Graph g;
    5.35  
    5.36 @@ -98,6 +109,9 @@
    5.37    ///Indicates whether the button of mouse is pressed or not
    5.38    int isbutton;
    5.39  
    5.40 +  ///Stores the actual tool in hand
    5.41 +  int actual_tool;
    5.42 +
    5.43    ///At this location was the mousebutton pressed.
    5.44    ///It helps to calculate the distance of dragging.
    5.45    double clicked_x, clicked_y;