pynaviz.controller.GetController#
- class pynaviz.controller.GetController(camera: Camera | None = None, *, enabled=True, auto_update: bool = True, renderer: Viewport | Renderer | None = None, controller_id: int | None = None, data: Any | None = None, buffer: Buffer = None, callback: Callable | None = None)[source]#
Bases:
CustomController
The class for grabbing a single time point
- __init__(camera: Camera | None = None, *, enabled=True, auto_update: bool = True, renderer: Viewport | Renderer | None = None, controller_id: int | None = None, data: Any | None = None, buffer: Buffer = None, callback: Callable | None = None)[source]#
Methods
__init__
([camera, enabled, auto_update, ...])add_camera
(camera, *[, include_state, ...])Add a camera to control.
add_default_event_handlers
(*args)get_xlim
()Return the current x boundaries
handle_event
(event, viewport)pan
(delta, rect, *[, animate])Pan the camera (move relative to its local coordinate frame).
pause
()Context manager to temporarily disable the controller.
quickzoom
(delta, *[, animate])Zoom the view using the camera's zoom property.
register_events
(viewport_or_renderer)Apply the default interaction mechanism to a render canvas.
remove_camera
(camera)Remove a camera from the list of cameras to control.
set_frame
(target_time)Set the frame to target time.
set_view
(xmin, xmax, ymin, ymax)Set the visible X and Y ranges for an OrthographicCamera.
set_xlim
(xmin, xmax)Set the visible X range for an OrthographicCamera.
set_ylim
(ymin, ymax)Set the visible Y range for an OrthographicCamera.
sync
(event)Get a new data point and update the texture
tick
()Should be called periodically to keep the camera up to date.
update_camera
(*args)update_fov
(delta, *, animate)Adjust the field of view with the given delta value (Limited to [1, 179]).
zoom
(delta, rect, *[, animate])Zoom the view with the given amount.
zoom_to_point
(delta, pos, rect, *[, animate])Zoom the view while panning to keep the position under the cursor fixed.
Attributes
Whether the controller automatically requests a new draw at the canvas.
A tuple with the cameras under control, in the order that they were added.
A dictionary that maps buttons/keys to actions.
The amount of motion damping (i.e. smoothing).
Whether the controller responds to events.
- add_camera(camera, *, include_state=None, exclude_state=None)#
Add a camera to control.
If the camera is already registered, it only updates the include_state and exclude_state (without changing the order of the cameras).
The
include_state
andexclude_state
arguments represent the camera state fields to include/exclude, when updating this camera. This can be used to “partially link” a camera. These args are None by default (i.e. no filtering).See
camera.get_state()
for available fields. Useful state names for the perspective and orthographhic camera are: ‘x’, ‘y’, ‘z’ (or ‘position’ for all three), ‘width’, ‘height’, ‘rotation’, ‘zoom’, and ‘depth_range’.
- add_default_event_handlers(*args)#
- property auto_update#
Whether the controller automatically requests a new draw at the canvas.
- property cameras#
A tuple with the cameras under control, in the order that they were added.
- property controller_id#
- property controls#
A dictionary that maps buttons/keys to actions.
Can be modified to configure how the controller reacts to events. Possible keys include ‘mouse1’ to ‘mouse5’, single characters for the corresponding key presses, and ‘arrowleft’, ‘arrowright’, ‘arrowup’, ‘arrowdown’, ‘tab’, ‘enter’, ‘escape’, ‘backspace’, and ‘delete’.
Each action value is a tuple with 3 fields:
The action name, e.g. ‘pan’, see
controller.controls.action_names
for the possible names.The mode: ‘drag’, ‘push’, ‘peek’, ‘repeat’. Drag represents mouse drag, push means the action is performed as the key is pushed, peek means that the action is undone once the key is released, and repeat means that while the key is held down, the value updates with the given amount per second.
The multiplier is the value that the set value from the event is multiplied with.
- property damping#
The amount of motion damping (i.e. smoothing). Lower values dampen less. Typical values would be below 10.
- property enabled#
Whether the controller responds to events.
- property frame_index#
- get_xlim()#
Return the current x boundaries
- handle_event(event, viewport)#
- pan(delta: Tuple, rect: Tuple, *, animate=False)#
Pan the camera (move relative to its local coordinate frame).
If animate is True, the motion is damped. This requires the controller to receive events from the renderer/viewport.
- pause()#
Context manager to temporarily disable the controller. Controller is set back to the original enabled/disabled state when leaving the context.
Usage#
- with controller.pause():
# do things while controller.enabled is False
# outside context manager, controller.enabled is set back to the original value
- quickzoom(delta: float, *, animate=False)#
Zoom the view using the camera’s zoom property. This is intended for temporary zoom operations.
If animate is True, the motion is damped. This requires the controller to receive events from the renderer/viewport.
- register_events(viewport_or_renderer: Viewport | Renderer)#
Apply the default interaction mechanism to a render canvas. Needs either a viewport or renderer.
- remove_camera(camera)#
Remove a camera from the list of cameras to control.
If the camera is not registered, this does nothing.
- set_frame(target_time: float)[source]#
Set the frame to target time.
- Parameters:
target_time – A time point.
- set_view(xmin: float, xmax: float, ymin: float, ymax: float)#
Set the visible X and Y ranges for an OrthographicCamera.
- set_xlim(xmin: float, xmax: float)#
Set the visible X range for an OrthographicCamera. #TODO THIS SHOULD DEPEND ON THE CURRENT SYNC STATUS
- set_ylim(ymin: float, ymax: float)#
Set the visible Y range for an OrthographicCamera.
- tick()#
Should be called periodically to keep the camera up to date.
If
auto_update
is True, this is done automatically. Returns a dict with the new camera state, or None if there are no running actions.
- update_camera(*args)#
- update_fov(delta, *, animate)#
Adjust the field of view with the given delta value (Limited to [1, 179]).
If animate is True, the motion is damped. This requires the controller to receive events from the renderer/viewport.
- zoom(delta: Tuple, rect: Tuple, *, animate=False)#
Zoom the view with the given amount.
The delta can be either a scalar or 2-element tuple. The zoom multiplier is calculated using
2**delta
. If the camera has maintain_aspect set to True, only the second value is used.Note that the camera’s distance, width, and height are adjusted, not its zoom property.
If animate is True, the motion is damped. This requires the controller to receive events from the renderer/viewport.
- zoom_to_point(delta: float, pos: Tuple, rect: Tuple, *, animate=False)#
Zoom the view while panning to keep the position under the cursor fixed.
If animate is True, the motion is damped. This requires the controller to receive events from the renderer/viewport.