vispy.scene.cameras.base_camera module#

class vispy.scene.cameras.base_camera.BaseCamera(interactive=True, flip=None, up='+z', parent=None, name=None)#

Bases: Node

Base camera class.

The Camera describes the perspective from which a ViewBox views its subscene, and the way that user interaction affects that perspective.

Most functionality is implemented in subclasses. This base class has no user interaction and causes the subscene to use the same coordinate system as the ViewBox.

Parameters:
interactivebool

Whether the camera processes mouse and keyboard events.

fliptuple of bools

For each dimension, specify whether it is flipped.

up{‘+z’, ‘-z’, ‘+y’, ‘-y’, ‘+x’, ‘-x’}

The direction that is considered up. Default ‘+z’. Not all camera’s may support this (yet).

parentNode

The parent of the camera.

namestr

Name used to identify the camera in the scene.

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.

property depth_value#

The depth value to use in orthographic and perspective projection

For orthographic projections, depth_value is the distance between the near and far clipping planes. For perspective projections, it is the ratio between the near and far clipping plane distances.

GL has a fixed amount of precision in the depth buffer, and a fixed constant will not work for both a very large range and very high precision. This property provides the user a way to override the default value if necessary.

property flip#
property fov#

Field-of-view angle of the camera. If 0, the camera is in orthographic mode.

get_state(props=None)#

Get the current view state of the camera

Returns a dict of key-value pairs. The exact keys depend on the camera. Can be passed to set_state() (of this or another camera of the same type) to reproduce the state.

Parameters:
propslist of strings | None

List of properties to include in the returned dict. If None, all of camera state is returned.

property interactive#

Boolean describing whether the camera should enable or disable user interaction.

Link this camera with another camera of the same type

Linked camera’s keep each-others’ state in sync.

Parameters:
camerainstance of Camera

The other camera to link.

propslist of strings | tuple of strings | None

List of camera state properties to keep in sync between the two cameras. If None, all of camera state is kept in sync.

axis“x” | “y” | None

An axis to link between two PanZoomCamera instances. If not None, view limits in the selected axis only will be kept in sync between the cameras.

on_canvas_change(event)#

Canvas change event handler

Parameters:
eventinstance of Event

The event.

property pre_transform#

A transform to apply to the beginning of the scene transform, in addition to anything else provided by this Camera.

reset()#

Reset the view to the default state.

set_default_state()#

Set the current state to be the default state to be applied when calling reset().

set_range(x=None, y=None, z=None, margin=0.05)#

Set the range of the view region for the camera

Parameters:
xtuple | None

X range.

ytuple | None

Y range.

ztuple | None

Z range.

marginfloat

Margin to use.

Notes

The view is set to the given range or to the scene boundaries if ranges are not specified. The ranges should be 2-element tuples specifying the min and max for each dimension.

For the PanZoomCamera the view is fully defined by the range. For e.g. the TurntableCamera the elevation and azimuth are not set. One should use reset() for that.

set_state(state=None, **kwargs)#

Set the view state of the camera

Should be a dict (or kwargs) as returned by get_state. It can be an incomlete dict, in which case only the specified properties are set.

Parameters:
statedict

The camera state.

**kwargsdict

Unused keyword arguments.

property up#

The dimension that is considered up.

view_changed()#

Called when this camera is changes its view. Also called when its associated with a viewbox.

property viewbox#

The viewbox that this camera applies to.

viewbox_key_event(event)#

The ViewBox key event handler

Parameters:
eventinstance of Event

The event.

viewbox_mouse_event(event)#

Viewbox mouse event handler

Parameters:
eventinstance of Event

The event.

viewbox_resize_event(event)#

The ViewBox resize handler to update the transform

Parameters:
eventinstance of Event

The event.

zoom_factor = 0.007#
vispy.scene.cameras.base_camera.nested_getattr(obj, names)#
vispy.scene.cameras.base_camera.nested_setattr(obj, names, val)#