def contains(self, mouseevent):
        """
        Test whether the mouse event occurred in the collection.

        Returns True | False, ``dict(ind=itemlist)``, where every
        item in itemlist contains the event.
        """
        if isinstance(self._contains, collections.Callable):
            return self._contains(self,mouseevent)

        if not self.get_visible():
            return False, {}

        if self._picker is True:  # the Boolean constant, not just nonzero or 1
            pickradius = self._pickradius
        else:
            try:
                pickradius = float(self._picker)
            except TypeError:
                # This should not happen if "contains" is called via
                # pick, the normal route; the check is here in case
                # it is called through some unanticipated route.
                warnings.warn(
                    "Collection picker %s could not be converted to float"
                                        % self._picker)
                pickradius = self._pickradius

        transform, transOffset, offsets, paths = self._prepare_points()

        ind = mpath.point_in_path_collection(
            mouseevent.x, mouseevent.y, pickradius,
            transform.frozen(), paths, self.get_transforms(),
            offsets, transOffset, pickradius <= 0)

        return len(ind)>0, dict(ind=ind)
Exemplo n.º 2
0
    def contains(self, mouseevent):
        """
        Test whether the mouse event occurred in the collection.

        Returns True | False, ``dict(ind=itemlist)``, where every
        item in itemlist contains the event.
        """
        if callable(self._contains):
            return self._contains(self, mouseevent)

        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()

        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),
        )
        return len(ind) > 0, dict(ind=ind)
Exemplo n.º 3
0
 def contains(self, mouseevent):
     """
     Test whether the mouse event occurred in the collection.
     Returns True | False, ``dict(ind=itemlist)``, where every
     item in itemlist contains the event.
     """
     if callable(self._contains): return self._contains(self,mouseevent)
     if not self.get_visible(): return False,{}
     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(),
         offsets, transOffset, len(self._facecolors)>0)
     return len(ind)>0,dict(ind=ind)
Exemplo n.º 4
0
    def contains(self, mouseevent):
        """
        Test whether the mouse event occurred in the collection.

        Returns True | False, ``dict(ind=itemlist)``, where every
        item in itemlist contains the event.
        """
        if callable(self._contains): return self._contains(self,mouseevent)
        if not self.get_visible(): return False,{}

        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(),
            offsets, transOffset, len(self._facecolors)>0)
        return len(ind)>0,dict(ind=ind)
Exemplo n.º 5
0
    def contains(self, mouseevent):
        """
        Test whether the mouse event occurred in the collection.

        Returns True | False, ``dict(ind=itemlist)``, where every
        item in itemlist contains the event.
        """
        if callable(self._contains): return self._contains(self, mouseevent)

        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()

        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))
        return len(ind) > 0, dict(ind=ind)
Exemplo n.º 6
0
    def contains(self, mouseevent):
        """
        Test whether the mouse event occurred in the collection.

        Returns True | False, ``dict(ind=itemlist)``, where every
        item in itemlist contains the event.
        """
        if callable(self._contains):
            return self._contains(self, mouseevent)

        if not self.get_visible():
            return False, {}

        if self._picker is True:  # the Boolean constant, not just nonzero or 1
            pickradius = self._pickradius
        else:
            try:
                pickradius = float(self._picker)
            except TypeError:
                # This should not happen if "contains" is called via
                # pick, the normal route; the check is here in case
                # it is called through some unanticipated route.
                warnings.warn(
                    "Collection picker %s could not be converted to float" %
                    self._picker)
                pickradius = self._pickradius

        transform, transOffset, offsets, paths = self._prepare_points()

        ind = mpath.point_in_path_collection(mouseevent.x,
                                             mouseevent.y, pickradius,
                                             transform.frozen(), paths,
                                             self.get_transforms(), offsets,
                                             transOffset, pickradius <= 0)

        return len(ind) > 0, dict(ind=ind)