Zoom in or out of the bounding box. Will center the view in the center of the bounding box, and zoom by the ratio of the size of the bounding box to the size of the Axes3D.
(self, bbox, direction='in',
mode=None, twinx=False, twiny=False)
| 1909 | return u, v, w |
| 1910 | |
| 1911 | def _set_view_from_bbox(self, bbox, direction='in', |
| 1912 | mode=None, twinx=False, twiny=False): |
| 1913 | """ |
| 1914 | Zoom in or out of the bounding box. |
| 1915 | |
| 1916 | Will center the view in the center of the bounding box, and zoom by |
| 1917 | the ratio of the size of the bounding box to the size of the Axes3D. |
| 1918 | """ |
| 1919 | (start_x, start_y, stop_x, stop_y) = bbox |
| 1920 | if mode == 'x': |
| 1921 | start_y = self.bbox.min[1] |
| 1922 | stop_y = self.bbox.max[1] |
| 1923 | elif mode == 'y': |
| 1924 | start_x = self.bbox.min[0] |
| 1925 | stop_x = self.bbox.max[0] |
| 1926 | |
| 1927 | # Clip to bounding box limits |
| 1928 | start_x, stop_x = np.clip(sorted([start_x, stop_x]), |
| 1929 | self.bbox.min[0], self.bbox.max[0]) |
| 1930 | start_y, stop_y = np.clip(sorted([start_y, stop_y]), |
| 1931 | self.bbox.min[1], self.bbox.max[1]) |
| 1932 | |
| 1933 | # Move the center of the view to the center of the bbox |
| 1934 | zoom_center_x = (start_x + stop_x)/2 |
| 1935 | zoom_center_y = (start_y + stop_y)/2 |
| 1936 | |
| 1937 | ax_center_x = (self.bbox.max[0] + self.bbox.min[0])/2 |
| 1938 | ax_center_y = (self.bbox.max[1] + self.bbox.min[1])/2 |
| 1939 | |
| 1940 | self.start_pan(zoom_center_x, zoom_center_y, 2) |
| 1941 | self.drag_pan(2, None, ax_center_x, ax_center_y) |
| 1942 | self.end_pan() |
| 1943 | |
| 1944 | # Calculate zoom level |
| 1945 | dx = abs(start_x - stop_x) |
| 1946 | dy = abs(start_y - stop_y) |
| 1947 | scale_u = dx / (self.bbox.max[0] - self.bbox.min[0]) |
| 1948 | scale_v = dy / (self.bbox.max[1] - self.bbox.min[1]) |
| 1949 | |
| 1950 | # Keep aspect ratios equal |
| 1951 | scale = max(scale_u, scale_v) |
| 1952 | |
| 1953 | # Zoom out |
| 1954 | if direction == 'out': |
| 1955 | scale = 1 / scale |
| 1956 | |
| 1957 | self._zoom_data_limits(scale, scale, scale) |
| 1958 | |
| 1959 | def _zoom_data_limits(self, scale_u, scale_v, scale_w): |
| 1960 | """ |
nothing calls this directly
no test coverage detected