Ejemplo n.º 1
0
    def _do_zoom(self, new_index_factor, new_value_factor):
        if self.zoom_to_mouse:
            location = self.position
            x_map = self._get_x_mapper()
            y_map = self._get_y_mapper()

            cx = (x_map.range.high + x_map.range.low)/2
            if self._index_factor == new_index_factor:
                nextx = cx
            else:
                x = x_map.map_data(location[0])
                nextx = x + (cx - x)*(self._index_factor/new_index_factor)

            cy = (y_map.range.high + y_map.range.low)/2
            if self._value_factor == new_value_factor:
                nexty = cy
            else:
                y = y_map.map_data(location[1])
                nexty = y + (cy - y)*(self._value_factor/new_value_factor)

            pan_state = PanState((cx, cy), (nextx, nexty))
            zoom_state = ZoomState((self._index_factor, self._value_factor),
                                   (new_index_factor, new_value_factor))

            states = GroupedToolState([pan_state, zoom_state])
            states.apply(self)
            self._append_state(states)

        else:

            zoom_state = ZoomState((self._index_factor, self._value_factor),
                                   (new_index_factor, new_value_factor))

            zoom_state.apply(self)
            self._append_state(zoom_state)
Ejemplo n.º 2
0
    def _do_zoom(self, new_index_factor, new_value_factor):
        if self.zoom_to_mouse:
            location = self.position
            x_map = self._get_x_mapper()
            y_map = self._get_y_mapper()

            cx = (x_map.range.high + x_map.range.low) / 2
            if self._index_factor == new_index_factor:
                nextx = cx
            else:
                x = x_map.map_data(location[0])
                nextx = x + (cx - x) * (self._index_factor / new_index_factor)

            cy = (y_map.range.high + y_map.range.low) / 2
            if self._value_factor == new_value_factor:
                nexty = cy
            else:
                y = y_map.map_data(location[1])
                nexty = y + (cy - y) * (self._value_factor / new_value_factor)

            pan_state = PanState((cx, cy), (nextx, nexty))
            zoom_state = ZoomState((self._index_factor, self._value_factor),
                                   (new_index_factor, new_value_factor))

            states = GroupedToolState([pan_state, zoom_state])
            states.apply(self)
            self._append_state(states)

        else:

            zoom_state = ZoomState((self._index_factor, self._value_factor),
                                   (new_index_factor, new_value_factor))

            zoom_state.apply(self)
            self._append_state(zoom_state)
Ejemplo n.º 3
0
    def zoom_in(self, factor=0):
        if factor == 0:
            factor = self.zoom_factor

        new_index_factor = self._index_factor * factor
        new_value_factor = self._value_factor * factor

        if self.axis == 'value':
            new_index_factor = self._index_factor
        elif self.axis == 'index':
            new_value_factor = self._value_factor

        if self.component.orientation == 'h':
            if self._zoom_limit_reached(new_index_factor, 'x'):
                return
            if self._zoom_limit_reached(new_value_factor, 'y'):
                return
        else:
            if self._zoom_limit_reached(new_index_factor, 'y'):
                return
            if self._zoom_limit_reached(new_value_factor, 'x'):
                return

        if self.zoom_to_mouse:
            location = self.position

            x_map = self._get_x_mapper()
            y_map = self._get_y_mapper()

            next = (x_map.map_data(location[0]),
                    y_map.map_data(location[1]))
            prev = (x_map.map_data(self.component.bounds[0]/2),
                    y_map.map_data(self.component.bounds[1]/2))

            pan_state = PanState(prev, next)
            zoom_state = ZoomState((self._index_factor, self._value_factor),
                                   (new_index_factor, new_value_factor))

            states = GroupedToolState([pan_state, zoom_state])
            states.apply(self)
            self._append_state(states)

        else:

            zoom_state = ZoomState((self._index_factor, self._value_factor),
                                   (new_index_factor, new_value_factor))

            zoom_state.apply(self)
            self._append_state(zoom_state)
Ejemplo n.º 4
0
    def zoom_in(self, factor=0):
        if factor == 0:
            factor = self.zoom_factor

        new_index_factor = self._index_factor * factor
        new_value_factor = self._value_factor * factor

        if self.axis == 'value':
            new_index_factor = self._index_factor
        elif self.axis == 'index':
            new_value_factor = self._value_factor

        if self.component.orientation == 'h':
            if self._zoom_limit_reached(new_index_factor, 'x'):
                return
            if self._zoom_limit_reached(new_value_factor, 'y'):
                return
        else:
            if self._zoom_limit_reached(new_index_factor, 'y'):
                return
            if self._zoom_limit_reached(new_value_factor, 'x'):
                return

        if self.zoom_to_mouse:
            location = self.position

            x_map = self._get_x_mapper()
            y_map = self._get_y_mapper()

            next = (x_map.map_data(location[0]), y_map.map_data(location[1]))
            prev = (x_map.map_data(self.component.bounds[0] / 2),
                    y_map.map_data(self.component.bounds[1] / 2))

            pan_state = PanState(prev, next)
            zoom_state = ZoomState((self._index_factor, self._value_factor),
                                   (new_index_factor, new_value_factor))

            states = GroupedToolState([pan_state, zoom_state])
            states.apply(self)
            self._append_state(states)

        else:

            zoom_state = ZoomState((self._index_factor, self._value_factor),
                                   (new_index_factor, new_value_factor))

            zoom_state.apply(self)
            self._append_state(zoom_state)