[Lemon-commits] [lemon_svn] hegyi: r1986 - hugo/trunk/gui

Lemon SVN svn at lemon.cs.elte.hu
Mon Nov 6 20:49:17 CET 2006


Author: hegyi
Date: Fri Jun 17 19:08:45 2005
New Revision: 1986

Modified:
   hugo/trunk/gui/broken_edge.cc
   hugo/trunk/gui/broken_edge.h
   hugo/trunk/gui/graph_displayer_canvas.cc
   hugo/trunk/gui/graph_displayer_canvas.h

Log:
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.

Modified: hugo/trunk/gui/broken_edge.cc
==============================================================================
--- hugo/trunk/gui/broken_edge.cc	(original)
+++ hugo/trunk/gui/broken_edge.cc	Fri Jun 17 19:08:45 2005
@@ -1,5 +1,4 @@
 #include <broken_edge.h>
-#include <lemon/xy.h>
 #include <math.h>
 
 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<double>(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<double> BrokenEdge::get_arrow_pos()
+{
+  xy<double> ret_val(my_points[1].get_x(),my_points[1].get_y());
+  return ret_val;
+}

Modified: hugo/trunk/gui/broken_edge.h
==============================================================================
--- hugo/trunk/gui/broken_edge.h	(original)
+++ hugo/trunk/gui/broken_edge.h	Fri Jun 17 19:08:45 2005
@@ -9,6 +9,7 @@
 #include <libgnomecanvasmm.h>
 #include <libgnomecanvasmm/polygon.h>
 #include <graph_displayer_canvas.h>
+#include <lemon/xy.h>
 
 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<double> get_arrow_pos();
 };
 
 

Modified: hugo/trunk/gui/graph_displayer_canvas.cc
==============================================================================
--- hugo/trunk/gui/graph_displayer_canvas.cc	(original)
+++ hugo/trunk/gui/graph_displayer_canvas.cc	Fri Jun 17 19:08:45 2005
@@ -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<double> text_pos=edgesmap[i]->get_arrow_pos();
+    text_pos+=(xy<double>(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<double> text_pos=edgesmap[ei]->get_arrow_pos();
+	    text_pos+=(xy<double>(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<double> text_pos=edgesmap[ei]->get_arrow_pos();
+	    text_pos+=(xy<double>(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<double> text_pos=edgesmap[active_edge]->get_arrow_pos();
+		  text_pos+=(xy<double>(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<double> new_place)
+{
+  new_place+=(xy<double>(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;
+	}
+    }
+
+}

Modified: hugo/trunk/gui/graph_displayer_canvas.h
==============================================================================
--- hugo/trunk/gui/graph_displayer_canvas.h	(original)
+++ hugo/trunk/gui/graph_displayer_canvas.h	Fri Jun 17 19:08:45 2005
@@ -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<double>);
+  ///Activates an edge belonging to a BrokenEdge
+  void toggle_edge_activity(BrokenEdge*, bool);
+
+public:
   ///\return the actual tool in hand
   int get_actual_tool();
 



More information about the Lemon-commits mailing list