Skip to content

scene

Scene management and mesh rendering helpers.

RenderResult dataclass

RenderResult(
    legend_items=list(),
    mesh_stats=None,
    scalar_bar_info=None,
    fiber_actor=None,
)

Result of one render pass.

Scene dataclass

Scene(
    plotter,
    active_actor=None,
    xdmf_mesh=None,
    xdmf_actor=None,
    xdmf_surface=None,
    xdmf_point_ids=None,
    xdmf_cell_ids=None,
)

One plotter and the actors its in-place updates act on.

forget_actors

forget_actors()

Drop every tracked actor and mesh.

TrameCtrl

Bases: Protocol

Trame controller hooks the scene pushes through.

view_push_camera

view_push_camera()

Push the server camera to the client.

view_update

view_update()

Send a delta view update to the client.

view_push_scene

view_push_scene()

Send the full scene state to the client.

field_label

field_label(name)

Return the display label for the scalar field name.

set_background

set_background(scene, dark_mode)

Set the gradient background of scene for dark_mode.

clear_scene

clear_scene(scene, dark_mode)

Remove every actor from scene, drop its tracked actors and set the background for dark_mode.

apply_opacity

apply_opacity(scene, opacity)

Set opacity on every vtkActor in the renderer.

push_scene

push_scene(scene, ctrl, reset_camera=True)

Render scene, reset the camera when reset_camera and push the scene to the client.

update_actor_palette

update_actor_palette(scene, ctrl, colors, n)

Swap the active actor's categorical LUT to the first n of colors in place and push the scene.

update_scalar_field_view

update_scalar_field_view(
    scene,
    ctrl,
    ddir,
    mesh_file,
    field,
    categorical_fields,
    zone_labels,
    palette,
    cmap,
    percentile=_PERCENTILE_CLAMP,
)

Switch the active actor's mapper to field in place and return (legend, scalar bar).

update_scalar_range

update_scalar_range(scene, ctrl, field, clim, cmap)

Set the active actor's scalar range to clim in place and return the scalar bar dict.

redraw_xdmf

redraw_xdmf(
    scene,
    ctrl,
    path,
    xdmf_meta,
    dark_mode,
    opacity,
    field=None,
    step=0,
    reset_camera=True,
    cmap="viridis",
    mesh_meta=None,
)

Render step step of the time series at path and return the RenderResult.

update_xdmf_step

update_xdmf_step(
    scene, ctrl, path, xdmf_meta, step, field, cmap
)

Copy step step onto the live frame and its skin in place and return (updated, stats, scalar bar).

redraw_ircadb

redraw_ircadb(
    scene,
    ctrl,
    patient_dir,
    dark_mode,
    opacity,
    palette=None,
    reset_camera=True,
)

Render every organ mesh in patient_dir as one merged actor and return the RenderResult.

redraw_stl_surface

redraw_stl_surface(
    scene,
    ctrl,
    dataset_dir,
    dark_mode,
    opacity,
    filename,
    palette=None,
    reset_camera=True,
)

Render the closed, geometry-only STL/OBJ surface filename in one solid colour and return the RenderResult.

redraw_region_surface_step

redraw_region_surface_step(
    scene,
    ctrl,
    pvd_path,
    dark_mode,
    opacity,
    step,
    palette=None,
    reset_camera=True,
    solid=True,
)

Render phase step of the region-coloured PVD surface series at pvd_path (GRASP MRI) and return the RenderResult.

redraw_scalar_field

redraw_scalar_field(
    scene,
    ctrl,
    dataset_dir,
    dark_mode,
    opacity,
    mesh_file,
    field,
    categorical_fields,
    zone_labels,
    palette=None,
    cmap="viridis",
    percentile=_PERCENTILE_CLAMP,
    reset_camera=True,
)

Render mesh_file coloured by field, as zones with a legend when categorical or a ramp clamped at percentile, and return the RenderResult.