Test whether the mouse event occurred within the image.
(self, mouseevent)
| 638 | self.stale = False |
| 639 | |
| 640 | def contains(self, mouseevent): |
| 641 | """Test whether the mouse event occurred within the image.""" |
| 642 | if (self._different_canvas(mouseevent) |
| 643 | # This doesn't work for figimage. |
| 644 | or not self.axes.contains(mouseevent)[0]): |
| 645 | return False, {} |
| 646 | # TODO: make sure this is consistent with patch and patch |
| 647 | # collection on nonlinear transformed coordinates. |
| 648 | # TODO: consider returning image coordinates (shouldn't |
| 649 | # be too difficult given that the image is rectilinear |
| 650 | trans = self.get_transform().inverted() |
| 651 | x, y = trans.transform([mouseevent.x, mouseevent.y]) |
| 652 | xmin, xmax, ymin, ymax = self.get_extent() |
| 653 | # This checks xmin <= x <= xmax *or* xmax <= x <= xmin. |
| 654 | inside = (x is not None and (x - xmin) * (x - xmax) <= 0 |
| 655 | and y is not None and (y - ymin) * (y - ymax) <= 0) |
| 656 | return inside, {} |
| 657 | |
| 658 | def write_png(self, fname): |
| 659 | """Write the image to png file *fname*.""" |
nothing calls this directly
no test coverage detected