Skip to content

renderer

Plot

Bases: RendererWindowInteractor

Class with single renderer on a window.

Used for fast setting-up the 3D scene. Objects (actors) can be added to the renderer with self.renderer.add_actor method.

interactor_style = PickableInteractorStyle(self.renderer, self) instance-attribute

__init__(width=800, height=600, background_color=(26, 51, 102))

add_actors(actors=())

Add list of actors to the renderer.

Parameters:

Name Type Description Default
actors list

List of actors to add to the renderer

()

add_renderer(background_color)

add_time_operation(time_operation, dt=20)

Add time dependend operation to the scene.

Parameters:

Name Type Description Default
time_operation _type_

function for updating the scene

required
dt int

time interval operation. Defaults to 20 ms.

20

export_html(filename)

Use PyVista's Plotter with the existing vtkRenderWindow.

Note

LATs need to be in transposed and rescaled to 0-255 range.

reset_camera(pad=1)

Reset the camera position to the original position with a vertical padding.

Parameters:

Name Type Description Default
pad float

vertical padding for the camera. Defaults to 1.0.

1

set_camera_vector(vector, angle=0)

Set the camera vector and roll angle.

Parameters:

Name Type Description Default
vector list

camera vector

required
angle float

roll angle in degrees. Defaults to 0.

0

Renderer

Bases: vtkRenderer

Class for creating a single renderer object.

Renderer - is an object responsible for rendering actors on 3D scene.

background_color property writable

scene_objects = [] instance-attribute

__init__(background_color=(26, 51, 102))

add_object(scene_object)

Add scene object to the renderer. Checks if object is already in the list of objects.

Parameters:

Name Type Description Default
scene_object SceneObject

class containing vtkActor.

required

add_objects(objects)

Add objects to the renderer.

Parameters:

Name Type Description Default
objects list

list of SceneObject objects.

required

remove_all_objects()

remove_object(scene_object)

remove_objects(objects)

Remove objects to the renderer.

Parameters:

Name Type Description Default
objects list

list of SceneObject objects.

required

set_camera_position(coords, zoom=0.5)

Set camera position and zoom to reflect the data.

set_camera_vertical_angle(factor=1)

write(filenames=None)

Write vtk objects of this renderer to a file.

Subplots

Bases: RendererWindowInteractor

Class for creating multiple renderers.

shared_camera = shared_camera instance-attribute

__init__(width=800, height=600, ncols=1, nrows=1, shared_camera=True, background_color=(26, 51, 102))

add_actors(renderer, actors=())

Add list of actors to a renderer.

Parameters:

Name Type Description Default
renderer (int, list or tuple)

Indices of the renderer

required
actors list

List of actors to add to the renderer

()

add_renderers(nrows=1, ncols=1, background_color=(26, 51, 102))

Create and return an array of renderers.

Parameters:

Name Type Description Default
ncols int

Number of columns. Defaults to 1.

1
nrows int

Number of rows. Defaults to 1.

1
background_color str or list

Name of color or RGB list. Defaults to blue.

(26, 51, 102)

Returns:

Name Type Description
ndarray ndarray

Array of renderers

add_time_operation(time_operation, dt=20)

Add time dependend operation to the scene.

Parameters:

Name Type Description Default
time_operation _type_

function for updating the scene

required
dt int

time interval operation. Defaults to 20 ms.

20

export_html(filename)

Export render to html file.

Parameters:

Name Type Description Default
filename str

Filename of the resulting html file.

required

make_screenshot(screenshot_name='screenshot.png', transparent=False)

reset_cameras(pad=0.8)

set_camera_vector(vector, angle=0)

Set camera position for all renderers in the subplot.

Parameters:

Name Type Description Default
vector tuple

Camera position.

required
angle int

Defaults to 0.

0

start()

Start every renderer window in the array of renderers.