Helper function to return the new points after a pan. This helper function returns the points on the axis after a pan has occurred. This is a convenience method to abstract the pan logic out of the base setter.
(self, button, key, x, y)
| 4529 | del self._pan_start |
| 4530 | |
| 4531 | def _get_pan_points(self, button, key, x, y): |
| 4532 | """ |
| 4533 | Helper function to return the new points after a pan. |
| 4534 | |
| 4535 | This helper function returns the points on the axis after a pan has |
| 4536 | occurred. This is a convenience method to abstract the pan logic |
| 4537 | out of the base setter. |
| 4538 | """ |
| 4539 | def format_deltas(key, dx, dy): |
| 4540 | if key == 'control': |
| 4541 | if abs(dx) > abs(dy): |
| 4542 | dy = dx |
| 4543 | else: |
| 4544 | dx = dy |
| 4545 | elif key == 'x': |
| 4546 | dy = 0 |
| 4547 | elif key == 'y': |
| 4548 | dx = 0 |
| 4549 | elif key == 'shift': |
| 4550 | if 2 * abs(dx) < abs(dy): |
| 4551 | dx = 0 |
| 4552 | elif 2 * abs(dy) < abs(dx): |
| 4553 | dy = 0 |
| 4554 | elif abs(dx) > abs(dy): |
| 4555 | dy = dy / abs(dy) * abs(dx) |
| 4556 | else: |
| 4557 | dx = dx / abs(dx) * abs(dy) |
| 4558 | return dx, dy |
| 4559 | |
| 4560 | p = self._pan_start |
| 4561 | dx = x - p.x |
| 4562 | dy = y - p.y |
| 4563 | if dx == dy == 0: |
| 4564 | return |
| 4565 | if button == 1: |
| 4566 | dx, dy = format_deltas(key, dx, dy) |
| 4567 | result = p.bbox.translated(-dx, -dy).transformed(p.trans_inverse) |
| 4568 | elif button == 3: |
| 4569 | try: |
| 4570 | dx = -dx / self.bbox.width |
| 4571 | dy = -dy / self.bbox.height |
| 4572 | dx, dy = format_deltas(key, dx, dy) |
| 4573 | if self.get_aspect() != 'auto': |
| 4574 | dx = dy = 0.5 * (dx + dy) |
| 4575 | alpha = np.power(10.0, (dx, dy)) |
| 4576 | start = np.array([p.x, p.y]) |
| 4577 | oldpoints = p.lim.transformed(p.trans) |
| 4578 | newpoints = start + alpha * (oldpoints - start) |
| 4579 | result = (mtransforms.Bbox(newpoints) |
| 4580 | .transformed(p.trans_inverse)) |
| 4581 | except OverflowError: |
| 4582 | _api.warn_external('Overflow while panning') |
| 4583 | return |
| 4584 | else: |
| 4585 | return |
| 4586 | |
| 4587 | valid = np.isfinite(result.transformed(p.trans)) |
| 4588 | points = result.get_points().astype(object) |