vispy.scene.cameras.panzoom module#
- class vispy.scene.cameras.panzoom.PanZoomCamera(rect=(0, 0, 1, 1), aspect=None, **kwargs)#
Bases:
BaseCamera
Camera implementing 2D pan/zoom mouse interaction.
For this camera, the
scale_factor
indicates the zoom level, and thecenter
indicates the center position of the view.By default, this camera inverts the y axis of the scene. This usually results in the scene +y axis pointing upward because widgets (including ViewBox) have their +y axis pointing downward.
- Parameters:
- rectRect
A Rect object or 4-element tuple that specifies the rectangular area to show.
- aspectfloat | None
The aspect ratio (i.e. scaling) between x and y dimension of the scene. E.g. to show a square image as square, the aspect should be 1. If None (default) the x and y dimensions are scaled independently.
- **kwargsdict
Keyword arguments to pass to BaseCamera.
Notes
Interaction:
LMB: pan the view
RMB or scroll: zooms the view
- property aspect#
The ratio between the x and y dimension. E.g. to show a square image as square, the aspect should be 1. If None, the dimensions are scaled automatically, dependening on the available space. Otherwise the ratio between the dimensions is fixed.
- property center#
The center location for this camera
The exact meaning of this value differs per type of camera, but generally means the point of interest or the rotation point.
- pan(*pan)#
Pan the view.
- Parameters:
- *panlength-2 sequence
The distance to pan the view, in the coordinate system of the scene.
- property rect#
The rectangular border of the ViewBox visible area.
This is expressed in the coordinate system of the scene. See
Rect
for different ways this can be specified.Note that the rectangle can have negative width or height, in which case the corresponding dimension is flipped (this flipping is independent from the camera’s
flip
property).
- viewbox_mouse_event(event)#
The SubScene received a mouse event; update transform accordingly.
- Parameters:
- eventinstance of Event
The event.
- viewbox_resize_event(event)#
Modify the data aspect and scale factor, to adjust to the new window size.
- Parameters:
- eventinstance of Event
The event.
- zoom(factor, center=None)#
Zoom in (or out) at the given center
- Parameters:
- factorfloat or tuple
Fraction by which the scene should be zoomed (e.g. a factor of 2 causes the scene to appear twice as large).
- centertuple of 2-4 elements
The center of the view. If not given or None, use the current center.