Changeset 25:c45a34eaa118 in glemon-0.x
- Timestamp:
- 06/17/05 19:08:45 (19 years ago)
- Branch:
- gui
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk/gui@1986
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
broken_edge.cc
r24 r25 1 1 #include <broken_edge.h> 2 #include <lemon/xy.h>3 2 #include <math.h> 4 3 … … 113 112 if(gdc.get_actual_tool()!=CREATE_NODE) 114 113 { 114 gdc.toggle_edge_activity(this, true); 115 115 clicked_x=e->button.x; 116 116 clicked_y=e->button.y; … … 119 119 break; 120 120 case GDK_BUTTON_RELEASE: 121 isbutton=false; 121 if(gdc.get_actual_tool()!=CREATE_NODE) 122 { 123 gdc.toggle_edge_activity(this, false); 124 isbutton=false; 125 } 122 126 break; 123 127 case GDK_MOTION_NOTIFY: … … 140 144 141 145 set_points(points_new); 146 gdc.text_reposition(xy<double>(my_points[1].get_x(),my_points[1].get_y())); 142 147 143 148 clicked_x=e->motion.x; … … 150 155 return true; 151 156 } 157 158 xy<double> BrokenEdge::get_arrow_pos() 159 { 160 xy<double> ret_val(my_points[1].get_x(),my_points[1].get_y()); 161 return ret_val; 162 } -
broken_edge.h
r21 r25 10 10 #include <libgnomecanvasmm/polygon.h> 11 11 #include <graph_displayer_canvas.h> 12 #include <lemon/xy.h> 12 13 13 14 class BrokenEdge : public Gnome::Canvas::Line … … 31 32 ~BrokenEdge(); 32 33 void set_points(Gnome::Canvas::Points, bool move=false); 34 xy<double> get_arrow_pos(); 33 35 }; 34 36 -
graph_displayer_canvas.cc
r21 r25 31 31 //initializing edge-text as well, to empty string 32 32 33 double x1, x2, y1, y2;34 edgesmap[i]->get_bounds(x1, y1, x2, y2);35 36 edgetextmap[i]=new Gnome::Canvas::Text(displayed_graph, (x1+x2)/2, (y1+y2)/2, "");33 xy<double> text_pos=edgesmap[i]->get_arrow_pos(); 34 text_pos+=(xy<double>(10,10)); 35 36 edgetextmap[i]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, ""); 37 37 edgetextmap[i]->property_fill_color().set_value("black"); 38 38 } … … 174 174 }; 175 175 176 //Deprecated 176 177 bool GraphDisplayerCanvas::event_handler(GdkEvent* e, Node n) 177 178 { … … 425 426 } 426 427 427 edgesmap[ei]->get_bounds(x1, y1, x2, y2);428 429 edgetextmap[ei]->property_x().set_value( (x1+x2)/2);430 edgetextmap[ei]->property_y().set_value( (y1+y2)/2);428 xy<double> text_pos=edgesmap[ei]->get_arrow_pos(); 429 text_pos+=(xy<double>(10,10)); 430 edgetextmap[ei]->property_x().set_value(text_pos.x); 431 edgetextmap[ei]->property_y().set_value(text_pos.y); 431 432 } 432 433 … … 452 453 } 453 454 454 edgesmap[ei]->get_bounds(x1, y1, x2, y2);455 456 edgetextmap[ei]->property_x().set_value( (x1+x2)/2);457 edgetextmap[ei]->property_y().set_value( (y1+y2)/2);455 xy<double> text_pos=edgesmap[ei]->get_arrow_pos(); 456 text_pos+=(xy<double>(10,10)); 457 edgetextmap[ei]->property_x().set_value(text_pos.x); 458 edgetextmap[ei]->property_y().set_value(text_pos.y); 458 459 } 459 460 } … … 590 591 591 592 //initializing edge-text as well, to empty string 592 edgesmap[active_edge]->get_bounds(x1, y1, x2, y2); 593 edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph,(x1+x2)/2, (y1+y2)/2, ""); 593 xy<double> text_pos=edgesmap[active_edge]->get_arrow_pos(); 594 text_pos+=(xy<double>(10,10)); 595 596 edgetextmap[active_edge]=new Gnome::Canvas::Text(displayed_graph, text_pos.x, text_pos.y, ""); 594 597 edgetextmap[active_edge]->property_fill_color().set_value("black"); 595 598 } … … 739 742 } 740 743 744 void GraphDisplayerCanvas::text_reposition(xy<double> new_place) 745 { 746 new_place+=(xy<double>(10,10)); 747 edgetextmap[active_edge]->property_x().set_value(new_place.x); 748 edgetextmap[active_edge]->property_y().set_value(new_place.y); 749 } 750 751 void GraphDisplayerCanvas::toggle_edge_activity(BrokenEdge* active_bre, bool on) 752 { 753 if(on) 754 { 755 if(active_edge!=INVALID) 756 { 757 std::cout << "ERROR!!!! Valid edge found!" << std::endl; 758 } 759 else 760 { 761 for (EdgeIt i(g); i!=INVALID; ++i) 762 { 763 if(edgesmap[i]==active_bre) 764 { 765 active_edge=i; 766 } 767 } 768 } 769 } 770 else 771 { 772 if(active_edge!=INVALID) 773 { 774 active_edge=INVALID; 775 } 776 else 777 { 778 std::cout << "ERROR!!!! Invalid edge found!" << std::endl; 779 } 780 } 781 782 } -
graph_displayer_canvas.h
r21 r25 57 57 ///reaction of any action happened in the territory 58 58 ///of the canvas 59 ///DEPRECATED!!!! 59 60 bool event_handler(GdkEvent* e, Node n); 60 61 … … 74 75 ///event handler for the case when eraser-tool is active 75 76 bool edge_map_edit_event_handler(GdkEvent*); 77 78 public: 79 ///Moves the text to new place 80 void text_reposition(xy<double>); 81 ///Activates an edge belonging to a BrokenEdge 82 void toggle_edge_activity(BrokenEdge*, bool); 76 83 77 84 public:
Note: See TracChangeset
for help on using the changeset viewer.