Revision: 5891
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5891&view=rev
Author: pkienzle
Date: 2008-07-26 19:24:28 +0000 (Sat, 26 Jul 2008)
Log Message:
-----------
Fix contains() for collections, moving common code from draw() into a function
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/collections.py
Modified: trunk/matplotlib/lib/matplotlib/collections.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/collections.py 2008-07-26 19:22:44 UTC
(rev 5890)
+++ trunk/matplotlib/lib/matplotlib/collections.py 2008-07-26 19:24:28 UTC
(rev 5891)
@@ -148,9 +148,9 @@
result = result.inverse_transformed(transData)
return result
- def draw(self, renderer):
- if not self.get_visible(): return
- renderer.open_group(self.__class__.__name__)
+ def _prepare_points(self):
+ """Point prep for drawing and hit testing"""
+
transform = self.get_transform()
transOffset = self._transOffset
offsets = self._offsets
@@ -171,12 +171,6 @@
offsets = np.asarray(offsets, np.float_)
- self.update_scalarmappable()
-
- clippath, clippath_trans = self.get_transformed_clip_path_and_affine()
- if clippath_trans is not None:
- clippath_trans = clippath_trans.frozen()
-
if not transform.is_affine:
paths = [transform.transform_path_non_affine(path) for path in
paths]
transform = transform.get_affine()
@@ -184,7 +178,20 @@
offsets = transOffset.transform_non_affine(offsets)
transOffset = transOffset.get_affine()
+ return transform, transOffset, offsets, paths
+ def draw(self, renderer):
+ if not self.get_visible(): return
+ renderer.open_group(self.__class__.__name__)
+
+ self.update_scalarmappable()
+
+ clippath, clippath_trans = self.get_transformed_clip_path_and_affine()
+ if clippath_trans is not None:
+ clippath_trans = clippath_trans.frozen()
+
+ transform, transOffset, offsets, paths = self._prepare_points()
+
renderer.draw_path_collection(
transform.frozen(), self.clipbox, clippath, clippath_trans,
paths, self.get_transforms(),
@@ -201,18 +208,14 @@
item in itemlist contains the event.
"""
if callable(self._contains): return self._contains(self,mouseevent)
+ if not self.get_visible(): return False,{}
- transform = self.get_transform()
- paths = self.get_paths()
- if not transform.is_affine:
- paths = [transform.transform_path_non_affine(path) for path in
paths]
- transform = transform.get_affine()
+ transform, transOffset, offsets, paths = self._prepare_points()
ind = mpath.point_in_path_collection(
mouseevent.x, mouseevent.y, self._pickradius,
transform.frozen(), paths, self.get_transforms(),
- np.asarray(self._offsets, np.float_),
- self._transOffset.frozen(), len(self._facecolors))
+ offsets, transOffset, len(self._facecolors)>0)
return len(ind)>0,dict(ind=ind)
def set_pickradius(self,pickradius): self.pickradius = 5
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins