def _zoom_fit(self): data_info = self._controller.get_data() config = self._controller.get_config() def add_padding(bounding_box, max_x, max_y): bounding_box[0].x = max(bounding_box[0].x - 1, 0) bounding_box[0].y = max(bounding_box[0].y - 1, 0) bounding_box[1].y = min(bounding_box[1].y + 2, max_y) bounding_box[1].x = min(bounding_box[1].x + 2, max_x) return bounding_box if config.maps_to_show or len(data_info.maps): bounding_box = data_info.get_bounding_box(config.dimension, config.slice_index, config.volume_index, config.rotate, config.maps_to_show) max_y = data_info.get_max_y_index(config.dimension, rotate=config.rotate, map_names=config.maps_to_show) max_x = data_info.get_max_x_index(config.dimension, rotate=config.rotate, map_names=config.maps_to_show) if not config.flipud: # Since the renderer plots with a left top coordinate system, # we need to flip the y coordinates upside down by default. tmp = max_y - bounding_box[0].y bounding_box[0].y = max_y - bounding_box[1].y bounding_box[1].y = tmp bounding_box = add_padding(bounding_box, max_x, max_y) self._controller.apply_action(SetZoom(Zoom(*bounding_box)))
def _extra_actions(self, data_info, configuration): if self.new_value != self._previous_config.flipud: max_y = data_info.get_max_y_index(configuration.dimension, configuration.rotate, configuration.maps_to_show) + 1 new_zoom = Zoom( Point(configuration.zoom.p0.x, max_y - configuration.zoom.p1.y), Point(configuration.zoom.p1.x, max_y - configuration.zoom.p0.y)) return SetZoom(new_zoom).apply(data_info, configuration)
def _extra_actions(self, configuration): if self.new_value != self._previous_config.flipud: data = self._previous_model.get_data() max_y = data.get_max_y_index(configuration.dimension, configuration.rotate, configuration.maps_to_show) + 1 new_p0_y = max_y - configuration.zoom.p1.y if new_p0_y >= max_y - 1: new_p0_y = 0 new_p1_y = max_y - configuration.zoom.p0.y if new_p1_y >= max_y - 1: new_p1_y = max_y - 1 new_zoom = Zoom(Point2d(configuration.zoom.p0.x, new_p0_y), Point2d(configuration.zoom.p1.x, new_p1_y)) return SetZoom(new_zoom).apply(SimpleDataConfigModel(data, configuration)).get_config()