Changeset 1884
- Timestamp:
- 08/09/07 01:41:19 (1 year ago)
- Files:
-
- gaphor/trunk/gaphor/diagram/interfaces.py (modified) (5 diffs)
- gaphor/trunk/gaphor/ui/diagramtools.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gaphor/trunk/gaphor/diagram/interfaces.py
r1519 r1884 58 58 """ 59 59 60 def connect(self, handle , x, y):60 def connect(self, handle): 61 61 """ 62 62 Connect a line's handle to element. 63 x and y are translated to the element the handle is connecting to.64 63 65 64 Note that at the moment of the connect, handle.connected_to may point … … 75 74 """ 76 75 77 def connect_constraint(self, handle , x, y):76 def connect_constraint(self, handle): 78 77 """ 79 78 Connect a handle to the element. … … 86 85 """ 87 86 88 def glue(self, handle , x, y):87 def glue(self, handle): 89 88 """ 90 89 Determine if a handle can glue to a specific element. … … 100 99 interactions contain lifelines and components contain classes objects. 101 100 """ 101 102 102 def pre_can_contain(self): 103 103 """ … … 105 105 class. Method called before item creation. 106 106 """ 107 108 107 109 108 def can_contain(self): gaphor/trunk/gaphor/ui/diagramtools.py
r1880 r1884 147 147 item = view.hovered_item 148 148 if item and item is view.focused_item and isinstance(item, Line): 149 h = item.handles()149 handles = item.handles() 150 150 x, y = context.view.get_matrix_v2i(item).transform_point(event.x, event.y) 151 for h1, h2 in zip(h [:-1], h[1:]):151 for h1, h2 in zip(handles[:-1], handles[1:]): 152 152 xp = (h1.x + h2.x) / 2 153 153 yp = (h1.y + h2.y) / 2 154 154 if distance_point_point_fast((x,y), (xp, yp)) <= 4: 155 segment = h .index(h1)155 segment = handles.index(h1) 156 156 item.split_segment(segment) 157 157 self.grab_handle(item, item.handles()[segment + 1]) … … 165 165 if super(ConnectHandleTool, self).on_button_release(context, event): 166 166 if grabbed_handle and grabbed_item: 167 h = grabbed_item.handles()168 if h [0] is grabbed_handle or h[-1] is grabbed_handle:167 handles = grabbed_item.handles() 168 if handles[0] is grabbed_handle or handles[-1] is grabbed_handle: 169 169 return True 170 segment = h .index(grabbed_handle)171 before = h [segment - 1]172 after = h [segment + 1]170 segment = handles.index(grabbed_handle) 171 before = handles[segment - 1] 172 after = handles[segment + 1] 173 173 d, p = distance_line_point(before.pos, after.pos, grabbed_handle.pos) 174 174 if d < 2: 175 175 grabbed_item.merge_segment(segment) 176 # TODO: ensure constraints are updated 176 177 return True 177 178
