jan: thuban/Thuban/UI viewport.py,1.18,1.19
cvs@intevation.de
cvs at intevation.de
Thu Nov 18 21:17:46 CET 2004
Author: jan
Update of /thubanrepository/thuban/Thuban/UI
In directory doto:/tmp/cvs-serv2214
Modified Files:
viewport.py
Log Message:
(ViewPort._hit_point): Added optional parameter
size' defaulting to the previously fixed value 5.
Extended doc-string.
(Viewport._find_shape_in_layer): Resolved FIXME regarding flexibility
for symbols.
Now the size of the largest point symbol is determined to find out
about whether the point has been hit.
This fixes the problem that only clicks inside a fixed distance of
5 where found.
Index: viewport.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/UI/viewport.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- viewport.py 22 Jul 2004 13:07:52 -0000 1.18
+++ viewport.py 18 Nov 2004 20:17:43 -0000 1.19
@@ -1,7 +1,8 @@
-# Copyright (c) 2001, 2002, 2003, 2004 by Intevation GmbH
+# Copyright (c) 2003-2004 by Intevation GmbH
# Authors:
-# Bernhard Herzog <bh at intevation.de>
-# Frank Koormann <frank at intevation.de>
+# Bernhard Herzog <bh at intevation.de> (2003, 2004)
+# Jonathan Coles <jonathan at intevation.de> (2003)
+# Jan-Oliver Wagner <jan at intevation.de> (2004)
#
# This program is free software under the GPL (>=v2)
# Read the file COPYING coming with Thuban for details.
@@ -11,6 +12,8 @@
"""
__version__ = "$Revision$"
+# $Source$
+# $Id$
from math import hypot
@@ -734,14 +737,19 @@
# around the point. For layers containing points we have to
# choose a larger size of the box we're testing against so
# that we take the size of the markers into account
- # FIXME: Once the markers are more flexible this part has to
- # become more flexible too, of course
+ # The size of the box is determined by the largest symbol
+ # of the corresponding layer.
+ maxsize = 1
if layer.ShapeType() == SHAPETYPE_POINT:
- box = self.unprojected_rect_around_point(px, py, 5)
- else:
- box = self.unprojected_rect_around_point(px, py, 1)
+ for group in layer.GetClassification():
+ props = group.GetProperties()
+ if props.GetSize() > maxsize:
+ maxsize = props.GetSize()
+ box = self.unprojected_rect_around_point(px, py, maxsize)
+ # determine the function that does the hit test based on the layer
hittester = self._get_hit_tester(layer)
+
for shape in layer.ShapesInRegion(box):
if field:
record = table.ReadRowAsDict(shape.ShapeID())
@@ -749,7 +757,13 @@
props = group.GetProperties()
filled = props.GetFill() is not Transparent
stroked = props.GetLineColor() is not Transparent
- hit = hittester(layer, shape, filled, stroked, px, py)
+
+ if layer.ShapeType() == SHAPETYPE_POINT:
+ hit = hittester(layer, shape, filled, stroked,
+ px, py, size = props.GetSize())
+ else:
+ hit = hittester(layer, shape, filled, stroked, px, py)
+
if hit:
return shape.ShapeID()
return None
@@ -813,14 +827,18 @@
-y * scale + offy))
return result
- def _hit_point(self, layer, shape, filled, stroked, px, py):
+ def _hit_point(self, layer, shape, filled, stroked, px, py, size = 5):
"""Internal: return whether a click at (px,py) hits the point shape
The filled and stroked parameters determine whether the shape is
assumed to be filled or stroked respectively.
+
+ size -- defines the size of the point symbol. For the hitting
+ test it is assumed the symbol is a circle of this size
+ (radius).
"""
x, y = self.projected_points(layer, shape.Points())[0][0]
- return hypot(px - x, py - y) < 5 and (filled or stroked)
+ return hypot(px - x, py - y) < size and (filled or stroked)
def _hit_arc(self, layer, shape, filled, stroked, px, py):
"""Internal: return whether a click at (px,py) hits the arc shape
More information about the Thuban-devel
mailing list
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)