# HG changeset patch # User hegyi # Date 1119028125 0 # Node ID c45a34eaa118c4235f56ff9ff6df4da734200603 # Parent 094ac2326a2aba06c9f1b78a5b78e583b989426e 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. diff -r 094ac2326a2a -r c45a34eaa118 broken_edge.cc --- a/broken_edge.cc Fri Jun 17 15:41:48 2005 +0000 +++ b/broken_edge.cc Fri Jun 17 17:08:45 2005 +0000 @@ -1,5 +1,4 @@ #include -#include #include BrokenEdge::BrokenEdge(Gnome::Canvas::Group & g, Gnome::Canvas::Points p, GraphDisplayerCanvas & gc) : Line(g), gdc(gc), isbutton(false) @@ -112,13 +111,18 @@ //we mark the location of the event to be able to calculate parameters of dragging if(gdc.get_actual_tool()!=CREATE_NODE) { + gdc.toggle_edge_activity(this, true); clicked_x=e->button.x; clicked_y=e->button.y; isbutton=true; } break; case GDK_BUTTON_RELEASE: - isbutton=false; + if(gdc.get_actual_tool()!=CREATE_NODE) + { + gdc.toggle_edge_activity(this, false); + isbutton=false; + } break; case GDK_MOTION_NOTIFY: //we only have to do sg. if the mouse button is pressed @@ -139,6 +143,7 @@ points_new.push_back(my_points[2]); set_points(points_new); + gdc.text_reposition(xy(my_points[1].get_x(),my_points[1].get_y())); clicked_x=e->motion.x; clicked_y=e->motion.y; @@ -149,3 +154,9 @@ return true; } + +xy BrokenEdge::get_arrow_pos() +{ + xy ret_val(my_points[1].get_x(),my_points[1].get_y()); + return ret_val; +} diff -r 094ac2326a2a -r c45a34eaa118 broken_edge.h --- a/broken_edge.h Fri Jun 17 15:41:48 2005 +0000 +++ b/broken_edge.h Fri Jun 17 17:08:45 2005 +0000 @@ -9,6 +9,7 @@ #include #include #include +#include class BrokenEdge : public Gnome::Canvas::Line { @@ -30,6 +31,7 @@ BrokenEdge(Gnome::Canvas::Group &, Gnome::Canvas::Points, GraphDisplayerCanvas &); ~BrokenEdge(); void set_points(Gnome::Canvas::Points, bool move=false); + xy get_arrow_pos(); }; diff -r 094ac2326a2a -r c45a34eaa118 graph_displayer_canvas.cc --- a/graph_displayer_canvas.cc Fri Jun 17 15:41:48 2005 +0000 +++ b/graph_displayer_canvas.cc Fri Jun 17 17:08:45 2005 +0000 @@ -30,10 +30,10 @@ //initializing edge-text as well, to empty string - double x1, x2, y1, y2; - edgesmap[i]->get_bounds(x1, y1, x2, y2); - - edgetextmap[i]=new Gnome::Canvas::Text(displayed_graph,(x1+x2)/2, (y1+y2)/2, ""); + xy text_pos=edgesmap[i]->get_arrow_pos(); + text_pos+=(xy(10,10)); + + edgetextmap[i]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, ""); edgetextmap[i]->property_fill_color().set_value("black"); } @@ -173,6 +173,7 @@ return 0; }; +//Deprecated bool GraphDisplayerCanvas::event_handler(GdkEvent* e, Node n) { switch(e->type) @@ -424,10 +425,10 @@ edgesmap[ei]->set_points(coos,true); } - edgesmap[ei]->get_bounds(x1, y1, x2, y2); - - edgetextmap[ei]->property_x().set_value((x1+x2)/2); - edgetextmap[ei]->property_y().set_value((y1+y2)/2); + xy text_pos=edgesmap[ei]->get_arrow_pos(); + text_pos+=(xy(10,10)); + edgetextmap[ei]->property_x().set_value(text_pos.x); + edgetextmap[ei]->property_y().set_value(text_pos.y); } g.firstIn(ei,active_node); @@ -451,10 +452,10 @@ edgesmap[ei]->set_points(coos,true); } - edgesmap[ei]->get_bounds(x1, y1, x2, y2); - - edgetextmap[ei]->property_x().set_value((x1+x2)/2); - edgetextmap[ei]->property_y().set_value((y1+y2)/2); + xy text_pos=edgesmap[ei]->get_arrow_pos(); + text_pos+=(xy(10,10)); + edgetextmap[ei]->property_x().set_value(text_pos.x); + edgetextmap[ei]->property_y().set_value(text_pos.y); } } default: break; @@ -589,8 +590,10 @@ active_item->raise_to_top(); //initializing edge-text as well, to empty string - edgesmap[active_edge]->get_bounds(x1, y1, x2, y2); - edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph,(x1+x2)/2, (y1+y2)/2, ""); + xy text_pos=edgesmap[active_edge]->get_arrow_pos(); + text_pos+=(xy(10,10)); + + edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, ""); edgetextmap[active_edge]->property_fill_color().set_value("black"); } //clicked item was not a node. it could be an e.g. edge. we do not deal with it furthermore. @@ -738,3 +741,42 @@ g.erase(edge_to_delete); } +void GraphDisplayerCanvas::text_reposition(xy new_place) +{ + new_place+=(xy(10,10)); + edgetextmap[active_edge]->property_x().set_value(new_place.x); + edgetextmap[active_edge]->property_y().set_value(new_place.y); +} + +void GraphDisplayerCanvas::toggle_edge_activity(BrokenEdge* active_bre, bool on) +{ + if(on) + { + if(active_edge!=INVALID) + { + std::cout << "ERROR!!!! Valid edge found!" << std::endl; + } + else + { + for (EdgeIt i(g); i!=INVALID; ++i) + { + if(edgesmap[i]==active_bre) + { + active_edge=i; + } + } + } + } + else + { + if(active_edge!=INVALID) + { + active_edge=INVALID; + } + else + { + std::cout << "ERROR!!!! Invalid edge found!" << std::endl; + } + } + +} diff -r 094ac2326a2a -r c45a34eaa118 graph_displayer_canvas.h --- a/graph_displayer_canvas.h Fri Jun 17 15:41:48 2005 +0000 +++ b/graph_displayer_canvas.h Fri Jun 17 17:08:45 2005 +0000 @@ -56,6 +56,7 @@ ///This function is responsible for the correct ///reaction of any action happened in the territory ///of the canvas + ///DEPRECATED!!!! bool event_handler(GdkEvent* e, Node n); ///actual event handler @@ -75,6 +76,12 @@ bool edge_map_edit_event_handler(GdkEvent*); public: + ///Moves the text to new place + void text_reposition(xy); + ///Activates an edge belonging to a BrokenEdge + void toggle_edge_activity(BrokenEdge*, bool); + +public: ///\return the actual tool in hand int get_actual_tool();