diff options
author | wrobell@pld-linux.org <wrobell@pld-linux.org@a8418922-720d-0410-834f-a69b97ada669> | 2009-01-03 17:06:09 (GMT) |
---|---|---|
committer | wrobell@pld-linux.org <wrobell@pld-linux.org@a8418922-720d-0410-834f-a69b97ada669> | 2009-01-03 17:06:09 (GMT) |
commit | 55c1be98c284edf037113677576d9668e27f1bdd (patch) | |
tree | bc4bcd7b92d1d76fa56ecf8226f4b9a4dd2fb229 | |
parent | 6725277fbbe3bcad8b0afc3bcb0fe6629e38fe6a (diff) |
- s/ConnectHandleTool.find_connectable_port/ConnectHandleTool.find_item_at_point/
(we have View.find_item_at_point method)
git-svn-id: http://svn.devjavu.com/gaphor/gaphas/trunk@2552 a8418922-720d-0410-834f-a69b97ada669
-rw-r--r-- | gaphas/tool.py | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/gaphas/tool.py b/gaphas/tool.py index 09ac09c..db7820b 100644 --- a/gaphas/tool.py +++ b/gaphas/tool.py @@ -850,7 +850,7 @@ class ConnectHandleTool(HandleTool): return None item, port, glue_pos = \ - self.find_connectable_port(view, vpos, exclude_item=line) + self.find_item_at_point(view, vpos, exclude=(line,)) # check if line and found item can be connected on closest port if port is not None and \ @@ -864,10 +864,30 @@ class ConnectHandleTool(HandleTool): handle.pos = v2i(*glue_pos) # else item and port will be set to None - return item, port + - def find_connectable_port(self, view, vpos, exclude_item=None): + def find_item_at_point(self, view, vpos, exclude=None): + """ + Find item with closest, connectable port to specified position. + + List of items to be ignored can be specified with `exclude` + parameter. + + Tuple is returned + + - found item + - closest port + - closest point on found port + + :Parameters: + view + View used by user. + vpos + Position specified in view coordinates. + exclude + Set of items to ignore. + """ dist = self.GLUE_DISTANCE v2i = view.get_matrix_v2i vx, vy = vpos @@ -880,7 +900,7 @@ class ConnectHandleTool(HandleTool): rect = (vx - dist, vy - dist, dist * 2, dist * 2) items = view.get_items_in_rectangle(rect, reverse=True) for i in items: - if i is exclude_item: + if i in exclude: continue for p in i.ports(): if not p.connectable: |