Previous commit was also mine, but I forgot to say, that it was my younger brother's birthyear. From this commit texts of activated maps move together with red arrows.
1.1 --- a/gui/broken_edge.cc Fri Jun 17 15:41:48 2005 +0000
1.2 +++ b/gui/broken_edge.cc Fri Jun 17 17:08:45 2005 +0000
1.3 @@ -1,5 +1,4 @@
1.4 #include <broken_edge.h>
1.5 -#include <lemon/xy.h>
1.6 #include <math.h>
1.7
1.8 BrokenEdge::BrokenEdge(Gnome::Canvas::Group & g, Gnome::Canvas::Points p, GraphDisplayerCanvas & gc) : Line(g), gdc(gc), isbutton(false)
1.9 @@ -112,13 +111,18 @@
1.10 //we mark the location of the event to be able to calculate parameters of dragging
1.11 if(gdc.get_actual_tool()!=CREATE_NODE)
1.12 {
1.13 + gdc.toggle_edge_activity(this, true);
1.14 clicked_x=e->button.x;
1.15 clicked_y=e->button.y;
1.16 isbutton=true;
1.17 }
1.18 break;
1.19 case GDK_BUTTON_RELEASE:
1.20 - isbutton=false;
1.21 + if(gdc.get_actual_tool()!=CREATE_NODE)
1.22 + {
1.23 + gdc.toggle_edge_activity(this, false);
1.24 + isbutton=false;
1.25 + }
1.26 break;
1.27 case GDK_MOTION_NOTIFY:
1.28 //we only have to do sg. if the mouse button is pressed
1.29 @@ -139,6 +143,7 @@
1.30 points_new.push_back(my_points[2]);
1.31
1.32 set_points(points_new);
1.33 + gdc.text_reposition(xy<double>(my_points[1].get_x(),my_points[1].get_y()));
1.34
1.35 clicked_x=e->motion.x;
1.36 clicked_y=e->motion.y;
1.37 @@ -149,3 +154,9 @@
1.38
1.39 return true;
1.40 }
1.41 +
1.42 +xy<double> BrokenEdge::get_arrow_pos()
1.43 +{
1.44 + xy<double> ret_val(my_points[1].get_x(),my_points[1].get_y());
1.45 + return ret_val;
1.46 +}
2.1 --- a/gui/broken_edge.h Fri Jun 17 15:41:48 2005 +0000
2.2 +++ b/gui/broken_edge.h Fri Jun 17 17:08:45 2005 +0000
2.3 @@ -9,6 +9,7 @@
2.4 #include <libgnomecanvasmm.h>
2.5 #include <libgnomecanvasmm/polygon.h>
2.6 #include <graph_displayer_canvas.h>
2.7 +#include <lemon/xy.h>
2.8
2.9 class BrokenEdge : public Gnome::Canvas::Line
2.10 {
2.11 @@ -30,6 +31,7 @@
2.12 BrokenEdge(Gnome::Canvas::Group &, Gnome::Canvas::Points, GraphDisplayerCanvas &);
2.13 ~BrokenEdge();
2.14 void set_points(Gnome::Canvas::Points, bool move=false);
2.15 + xy<double> get_arrow_pos();
2.16 };
2.17
2.18
3.1 --- a/gui/graph_displayer_canvas.cc Fri Jun 17 15:41:48 2005 +0000
3.2 +++ b/gui/graph_displayer_canvas.cc Fri Jun 17 17:08:45 2005 +0000
3.3 @@ -30,10 +30,10 @@
3.4
3.5 //initializing edge-text as well, to empty string
3.6
3.7 - double x1, x2, y1, y2;
3.8 - edgesmap[i]->get_bounds(x1, y1, x2, y2);
3.9 -
3.10 - edgetextmap[i]=new Gnome::Canvas::Text(displayed_graph,(x1+x2)/2, (y1+y2)/2, "");
3.11 + xy<double> text_pos=edgesmap[i]->get_arrow_pos();
3.12 + text_pos+=(xy<double>(10,10));
3.13 +
3.14 + edgetextmap[i]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, "");
3.15 edgetextmap[i]->property_fill_color().set_value("black");
3.16 }
3.17
3.18 @@ -173,6 +173,7 @@
3.19 return 0;
3.20 };
3.21
3.22 +//Deprecated
3.23 bool GraphDisplayerCanvas::event_handler(GdkEvent* e, Node n)
3.24 {
3.25 switch(e->type)
3.26 @@ -424,10 +425,10 @@
3.27 edgesmap[ei]->set_points(coos,true);
3.28 }
3.29
3.30 - edgesmap[ei]->get_bounds(x1, y1, x2, y2);
3.31 -
3.32 - edgetextmap[ei]->property_x().set_value((x1+x2)/2);
3.33 - edgetextmap[ei]->property_y().set_value((y1+y2)/2);
3.34 + xy<double> text_pos=edgesmap[ei]->get_arrow_pos();
3.35 + text_pos+=(xy<double>(10,10));
3.36 + edgetextmap[ei]->property_x().set_value(text_pos.x);
3.37 + edgetextmap[ei]->property_y().set_value(text_pos.y);
3.38 }
3.39
3.40 g.firstIn(ei,active_node);
3.41 @@ -451,10 +452,10 @@
3.42 edgesmap[ei]->set_points(coos,true);
3.43 }
3.44
3.45 - edgesmap[ei]->get_bounds(x1, y1, x2, y2);
3.46 -
3.47 - edgetextmap[ei]->property_x().set_value((x1+x2)/2);
3.48 - edgetextmap[ei]->property_y().set_value((y1+y2)/2);
3.49 + xy<double> text_pos=edgesmap[ei]->get_arrow_pos();
3.50 + text_pos+=(xy<double>(10,10));
3.51 + edgetextmap[ei]->property_x().set_value(text_pos.x);
3.52 + edgetextmap[ei]->property_y().set_value(text_pos.y);
3.53 }
3.54 }
3.55 default: break;
3.56 @@ -589,8 +590,10 @@
3.57 active_item->raise_to_top();
3.58
3.59 //initializing edge-text as well, to empty string
3.60 - edgesmap[active_edge]->get_bounds(x1, y1, x2, y2);
3.61 - edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph,(x1+x2)/2, (y1+y2)/2, "");
3.62 + xy<double> text_pos=edgesmap[active_edge]->get_arrow_pos();
3.63 + text_pos+=(xy<double>(10,10));
3.64 +
3.65 + edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, "");
3.66 edgetextmap[active_edge]->property_fill_color().set_value("black");
3.67 }
3.68 //clicked item was not a node. it could be an e.g. edge. we do not deal with it furthermore.
3.69 @@ -738,3 +741,42 @@
3.70 g.erase(edge_to_delete);
3.71 }
3.72
3.73 +void GraphDisplayerCanvas::text_reposition(xy<double> new_place)
3.74 +{
3.75 + new_place+=(xy<double>(10,10));
3.76 + edgetextmap[active_edge]->property_x().set_value(new_place.x);
3.77 + edgetextmap[active_edge]->property_y().set_value(new_place.y);
3.78 +}
3.79 +
3.80 +void GraphDisplayerCanvas::toggle_edge_activity(BrokenEdge* active_bre, bool on)
3.81 +{
3.82 + if(on)
3.83 + {
3.84 + if(active_edge!=INVALID)
3.85 + {
3.86 + std::cout << "ERROR!!!! Valid edge found!" << std::endl;
3.87 + }
3.88 + else
3.89 + {
3.90 + for (EdgeIt i(g); i!=INVALID; ++i)
3.91 + {
3.92 + if(edgesmap[i]==active_bre)
3.93 + {
3.94 + active_edge=i;
3.95 + }
3.96 + }
3.97 + }
3.98 + }
3.99 + else
3.100 + {
3.101 + if(active_edge!=INVALID)
3.102 + {
3.103 + active_edge=INVALID;
3.104 + }
3.105 + else
3.106 + {
3.107 + std::cout << "ERROR!!!! Invalid edge found!" << std::endl;
3.108 + }
3.109 + }
3.110 +
3.111 +}
4.1 --- a/gui/graph_displayer_canvas.h Fri Jun 17 15:41:48 2005 +0000
4.2 +++ b/gui/graph_displayer_canvas.h Fri Jun 17 17:08:45 2005 +0000
4.3 @@ -56,6 +56,7 @@
4.4 ///This function is responsible for the correct
4.5 ///reaction of any action happened in the territory
4.6 ///of the canvas
4.7 + ///DEPRECATED!!!!
4.8 bool event_handler(GdkEvent* e, Node n);
4.9
4.10 ///actual event handler
4.11 @@ -75,6 +76,12 @@
4.12 bool edge_map_edit_event_handler(GdkEvent*);
4.13
4.14 public:
4.15 + ///Moves the text to new place
4.16 + void text_reposition(xy<double>);
4.17 + ///Activates an edge belonging to a BrokenEdge
4.18 + void toggle_edge_activity(BrokenEdge*, bool);
4.19 +
4.20 +public:
4.21 ///\return the actual tool in hand
4.22 int get_actual_tool();
4.23