Like pa_zoom(), but pans the image as well to keep the
        coordinate under the cursor in that same position relative
        to the window.
778556
def pa_zoom_origin(self, viewer, event, msg=True):
        
        event = self._pa_synth_scroll_event(event)
        if event.state != 'move':
            return False
        origin = (event.data_x, event.data_y)
        self._sc_zoom(viewer, event, msg=msg, origin=origin)
        return True
867928
function getCanvasPointClicked(e, canvas) {
  var rect = canvas.getBoundingClientRect();
  return {x: e.clientX - rect.left, y: e.clientY - rect.top};
}
159193
def zoom_in(self):
        """"""
        if self._scalefactor <= self._sfmax:
            self._scalefactor += 1
            self.scale_image()
            self._adjust_scrollbar(self._scalestep)
            self.sig_zoom_changed.emit(self.get_scaling())
18137
def pan_cb(self, setting, value):
        """"""
        pan_x, pan_y = value[:2]

        self.logger.debug("pan set to %.2f,%.2f" % (pan_x, pan_y))
        self.redraw(whence=0)
160256
def _constrain_zoom(self):
        """"""
        if self.xmin is not None:
            self._zoom[0] = max(self._zoom[0],
                                1. / (self._pan[0] - self.xmin))
        if self.xmax is not None:
            self._zoom[0] = max(self._zoom[0],
                                1. / (self.xmax - self._pan[0]))

        if self.ymin is not None:
            self._zoom[1] = max(self._zoom[1],
                                1. / (self._pan[1] - self.ymin))
        if self.ymax is not None:
            self._zoom[1] = max(self._zoom[1],
                                1. / (self.ymax - self._pan[1]))
791581
def panset_xy(self, data_x, data_y, no_reset=False):
        
        pan_coord = self.t_['pan_coord']
        # To center on the pixel
        if pan_coord == 'wcs':
            image = self.get_image()
            if image is None:
                return
            pan_x, pan_y = image.pixtoradec(data_x, data_y)
        else:
            pan_x, pan_y = data_x, data_y

        self.set_pan(pan_x, pan_y, coord=pan_coord, no_reset=no_reset)
423714
function (){
    var scale = Math.min(
      (_svg.width() - PADDING * 2) / _width,
      (_svg.height() - PADDING * 2) / _height
    ),
    panZoomValues = _panZoom();

    if(
      panZoomValues.panX !== PADDING ||
      panZoomValues.panY !== PADDING ||
      panZoomValues.scale !== scale
    ) {
      _panZoomValues = _panZoom(PADDING, PADDING, scale);
    }
    else {
      _panZoomValues = _panZoom(
        _panZoomValues.panX,
        _panZoomValues.panY,
        _panZoomValues.scale);
    }
  }
975207
def snapPointToCanvas(self, x, y):
        
        if x < 0 or x > self.pixmap.width() or y < 0 or y > self.pixmap.height():
            x = max(x, 0)
            y = max(y, 0)
            x = min(x, self.pixmap.width())
            y = min(y, self.pixmap.height())
            return x, y, True

        return x, y, False
615221
def mouse_zoom(self, inc):
        '''

        '''
        # Square Distance from pivot
        dsq = np.linalg.norm(self.position - self.pivot)
        minsq = 1.0**2  # How near can we be to the pivot
        maxsq = 7.0**2 # How far can we go 

        scalefac = 0.25

        if dsq > maxsq and inc < 0: 
            # We're going too far
            pass
        elif dsq < minsq and inc > 0:
            # We're going too close
            pass
        else:
            # We're golden
            self.position += self.c*inc*scalefac
569242
def zoom_delta(self, d, p=(0., 0.), c=1.):
        """"""
        dx, dy = d
        x0, y0 = p

        pan_x, pan_y = self._pan
        zoom_x, zoom_y = self._zoom
        zoom_x_new, zoom_y_new = (zoom_x * math.exp(c * self._zoom_coeff * dx),
                                  zoom_y * math.exp(c * self._zoom_coeff * dy))

        zoom_x_new = max(min(zoom_x_new, self._zmax), self._zmin)
        zoom_y_new = max(min(zoom_y_new, self._zmax), self._zmin)

        self.zoom = zoom_x_new, zoom_y_new

        if self._zoom_to_pointer:
            zoom_x, zoom_y = self._zoom_aspect((zoom_x,
                                                zoom_y))
            zoom_x_new, zoom_y_new = self._zoom_aspect((zoom_x_new,
                                                        zoom_y_new))

            self.pan = (pan_x - x0 * (1. / zoom_x - 1. / zoom_x_new),
                        pan_y - y0 * (1. / zoom_y - 1. / zoom_y_new))

        self.update()
1169261
def mouse_event_callback(self, window, xpos, ypos):
        
        # screen coordinates relative to the top-left corner
        self.example.mouse_position_event(xpos, ypos)
469387
def unzoom(self,event=None):
        
        if self.panel is not None: self.panel.unzoom(event=event)
731893
def on_key_press(self, event):
        """"""
        # Zooming with the keyboard.
        key = event.key
        if event.modifiers:
            return

        # Pan.
        if self.enable_keyboard_pan and key in self._arrows:
            self._pan_keyboard(key)

        # Zoom.
        if key in self._pm:
            self._zoom_keyboard(key)

        # Reset with 'R'.
        if key == 'R':
            self.reset()
921637
def scroll_x(self, pixels, relative=True):
        '''
        
        '''
        if relative:
            self.offset.x += int(pixels)
        else:
            self.offset.x = int(pixels)
        self._update()
304959
def ms_zoom(self, viewer, event, data_x, data_y, msg=True):
        
        if not self.canzoom:
            return True
        msg = self.settings.get('msg_zoom', msg)

        x, y = self.get_win_xy(viewer)

        if event.state == 'move':
            self._zoom_xy(viewer, x, y)

        elif event.state == 'down':
            if msg:
                viewer.onscreen_message("Zoom (drag mouse L-R)",
                                        delay=1.0)
            self._start_x, self._start_y = x, y

        else:
            viewer.onscreen_message(None)
        return True
1021754
def zoom_leftdown(self, event=None):
        """"""
        self.x_lastmove, self.y_lastmove = None, None
        self.zoom_ini = (event.x, event.y, event.xdata, event.ydata)
        self.report_leftdown(event=event)
857077
def on_mouse_wheel(self, event):
        
        self.zoom(np.exp(event.delta * (0.01, -0.01)), event.pos)