From: <aur...@wa...> - 2003-04-09 16:12:01
|
En principe, to connect some Line-ish object to an Element-ish object, you pick one line's handle, drag it onto the Element's bounding box and just drop ! it's connected. which translates to : - a lot of calc_glue_point on the Element side (in fact, any Element already on the canvas**), - at drop time, the Line handle is connected to the closest glue point of the bounding box of the Element, - one add_line_constraint is issued (to ensure the line handle remains glued to its landing place) as shown on this trace (with NODE & EDGE playing for Element & Line) : note that there are 2 nodes here, but obiously only one shall be connected, NODE glue NODE calc_glue_point, dist = 166.087326 NODE glue NODE calc_glue_point, dist = 1.414214 NODE glue NODE calc_glue_point, dist = 166.379085 NODE glue NODE calc_glue_point, dist = 1.000000 NODE glue NODE calc_glue_point, dist = 166.676333 NODE glue NODE calc_glue_point, dist = 0.000000 NODE glue NODE calc_glue_point, dist = 165.722660 then... NODE connect NODE calc_glue_point, dist = 0.000000 handle add_point_constraint The problem is : what is going on under the hood that makes things actually work ? When I try to programatically replicate this, typing in a pythonesque way : class VcEdge (dia.CanvasEdge, dia.CanvasAbstractGroup): def __init__(self): self.__gobject_init__() def attach (self, from_node, to_node): self.from_node = from_node self.to_node = to_node #two point constraints will be added : from_node.connect_handle (self.handles[0]) to_node.connect_handle (self.handles[1]) self.request_update() from_node.request_update() to_node.request_update() any call to attach won't really connect the edge to the nodes. HINT : the edge is not yet on the canvas. What's missing here ...? Aurélien. ** this is not a good thing. It won't work with huge graphs (or drawings). This O(n) calculus could be done just at drop-time (or MOUSE_RELEASE time) instead of being incessantly recomputed. |