Convenience¶
The convenience API builds a viewer with little code. It is designed to provide a single way to declare a viewer configuration and launch it on any of the GUI backends (Qt and Anywidget).
Viewers¶
A Viewer holds one scene; an OrthoViewer holds four that share one world coordinate system (three orthogonal 2D slices and a 3D view).
cellier.convenience.Viewer ¶
Bases: ControlsRegistryMixin, RenderSettingsMixin
Single-scene viewer wrapping a CellierController.
Creates a controller and a single scene pre-wired and ready to receive
data and visuals. No Qt objects are constructed here; call
add_canvas when you are ready to attach a render surface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axes
|
WorldAxesLike
|
The world axes in order: a |
required |
displayed_axes
|
tuple of str or UUID
|
The axes the scene displays first, in display order. Required. Two entries start the viewer in 2D and three start it in 3D: Each entry is an axis name or an axis id ( |
required |
render_modes
|
set[str] or None
|
Which rendering modes the scene (and its visuals) should support.
Defaults to |
None
|
render_config
|
RenderManagerConfig or None
|
Render pipeline configuration passed through to the controller.
Uses controller defaults when |
None
|
gui
|
"qt", "anywidget", or "offscreen"
|
Which GUI toolkit the canvas should target. |
'qt'
|
lighting
|
'none' or 'default'
|
Lights in the scene. |
'none'
|
draw_status_overlay
|
bool
|
Whether every canvas names, in its top-left corner, the visuals its
view does not draw and why in one word -- a 2D view whose slice cuts
a rotated image at an angle, say. Default |
True
|
render_config
property
¶
render_config: RenderManagerConfig
Live rendering configuration.
Mutating a field here changes the model but not the GPU state, and notifies no widget. The named properties below do all three; reach for this to read the whole configuration or to serialise it.
outline_enabled
property
writable
¶
outline_enabled: bool
Whether the screen-space outline pass is active.
outline_boundaries_enabled
property
writable
¶
outline_boundaries_enabled: bool
Whether the boundaries layer (every outlined region) draws.
outline_selection_enabled
property
writable
¶
outline_selection_enabled: bool
Whether the selection layer (regions with a palette slot) draws.
ambient_occlusion_enabled
property
writable
¶
ambient_occlusion_enabled: bool
Whether the ambient occlusion pass is active. 3D only.
ambient_occlusion_radius
property
writable
¶
ambient_occlusion_radius: float | None
Occlusion hemisphere radius in scene units, or None for auto.
None derives it from the scene bounding box diagonal, which is
the only default that means anything across cellier's coordinate
systems. ambient_occlusion_effective_radius reports what that came to.
ambient_occlusion_auto_radius_fraction
property
writable
¶
ambient_occlusion_auto_radius_fraction: float
Fraction of the scene bounding box diagonal used when radius is auto.
ambient_occlusion_effective_radius
property
¶
ambient_occlusion_effective_radius: float | None
The occlusion radius actually in use, in scene units. Read-only.
ambient_occlusion_strength
property
writable
¶
ambient_occlusion_strength: float
How far the occlusion is applied, 0 (off) to 1 (full).
ambient_occlusion_power
property
writable
¶
ambient_occlusion_power: float
Contrast exponent applied to the occlusion before the multiply.
ambient_occlusion_bias
property
writable
¶
ambient_occlusion_bias: float
Depth-comparison bias, as a fraction of the effective radius.
ambient_occlusion_n_samples
property
writable
¶
ambient_occlusion_n_samples: int
Hemisphere samples per pixel. Changing this recompiles the shader.
ambient_occlusion_blur_radius
property
writable
¶
ambient_occlusion_blur_radius: int
Occlusion box-blur half-width in internal pixels. Recompiles.
temporal_enabled
property
writable
¶
temporal_enabled: bool
Whether the temporal accumulation pass is active. 3D only.
temporal_blend_weight
property
writable
¶
temporal_blend_weight: float
Minimum EMA blend weight for the current frame, in (0, 1].
Lower values give a smoother settled image and take longer to get there after a camera move.
gui
property
¶
gui: str
The GUI toolkit this viewer renders into.
"qt", "anywidget" or "offscreen" (no window: for
scripted screenshots and tests).
background
property
writable
¶
background: BackgroundAppearance
Appearance of the background drawn behind the scene's visuals.
Uniform black by default (a scene built directly with add_scene
keeps the gray gradient of BackgroundAppearance). Mutate its
fields to update the canvas at runtime:
viewer.background.color = (1.0, 1.0, 1.0, 1.0)
viewer.background.mode = "vertical_gradient"
Assigning a whole new BackgroundAppearance works too.
draw_status_overlay
property
¶
draw_status_overlay: DrawStatusOverlay | None
The text overlay naming visuals a canvas's view does not draw.
On by default (Viewer(..., draw_status_overlay=True)); every
canvas of this viewer shows it. Its fields are live: set visible
to hide it, or change its colour and size. It lists the visuals
whose CellierController.draw_status is not drawable -- a 2D
view that cuts a rotated image at an angle, say. None when the
viewer was built without it. It is not one of overlays.
overlays
property
¶
overlays: tuple[CanvasOverlay | SceneOverlay, ...]
Every overlay on this viewer, scene overlays first.
Scene overlays in add order, then the canvas overlays of each canvas in creation order, then any canvas overlay still waiting for a canvas.
startup_state
property
¶
startup_state: StartupState
How far this viewer has got through starting up.
Readable at any moment, with no callback, no event loop and no front end -- which is the point. A blank viewer used to be undiagnosable from Python; now it can say whether it is waiting for the canvas to reach the browser, waiting for a first frame, loading data, or done.
StartupState.IDLE until display/launch/show runs.
scene_startup_states
property
¶
scene_startup_states: dict[str, StartupState]
Each scene's startup state, keyed as this viewer keys its scenes.
An aggregate hides which panel is stuck; this does not.
canvases
property
¶
IDs of the canvases attached to this viewer's scene, in creation order.
Empty until add_canvas (or a layout builder) has run. A viewer
with no canvas is still capturable -- see screenshot.
reset_temporal_accumulation ¶
Discard the accumulated history on every canvas.
add_scene_overlay ¶
add_scene_overlay(overlay: SceneOverlay) -> SceneOverlay
Add a world-space overlay to this viewer's scene.
A scene overlay is drawn in the scene's world by the scene camera and
follows the scene's contents -- see
add_scene_overlay.
Its fields are live afterwards:
box = viewer.add_scene_overlay(SceneBoundingBox(name="box"))
box.appearance.color = (1.0, 0.0, 0.0, 1.0)
box.visible = False
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
overlay
|
SceneOverlay
|
The overlay model, e.g. a |
required |
Returns:
| Type | Description |
|---|---|
SceneOverlay
|
The same model. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If overlay is not a scene overlay. |
add_canvas_overlay ¶
add_canvas_overlay(overlay: CanvasOverlay) -> CanvasOverlay
Add a screen-space overlay to this viewer's canvas.
Attached to the viewer's first canvas. Before any canvas exists --
the usual case, since launch / show / display build it --
the overlay is held and attached as soon as the canvas is created.
Its fields are live once attached.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
overlay
|
CanvasOverlay
|
The overlay model, e.g. a |
required |
Returns:
| Type | Description |
|---|---|
CanvasOverlay
|
The same model. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If overlay is not a canvas overlay. |
remove_overlay ¶
remove_overlay(overlay: CanvasOverlay | SceneOverlay | UUID) -> None
Remove an overlay of either category.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
overlay
|
(CanvasOverlay, SceneOverlay or UUID)
|
The overlay model, or its id. |
required |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the overlay is not on this viewer. |
on_ready ¶
on_ready(callback: Callable[[], None]) -> SubscriptionHandle
Register a callback fired once the scene's startup data is on the GPU.
The callback runs after the initial reslice triggered by
launch / show
has committed all visuals (in-memory, multiscale, multichannel, and
geometry) to the GPU. Use it to hide a loading indicator, capture a
screenshot, or enable controls once the first view is fully loaded.
Fires once, on the first startup. Register it before or after
display/launch/show: before startup has finished it
waits, and after that it runs at once. For one scene, use
on_scene_ready.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
Callable[[], None]
|
Zero-argument callback. |
required |
Returns:
| Type | Description |
|---|---|
SubscriptionHandle
|
Active until callback fires; its |
startup_report ¶
startup_report() -> str
A one-line summary of startup progress, for a cell or a log line.
on_scene_ready ¶
on_scene_ready(key: str, callback: Callable[[], None]) -> SubscriptionHandle
Fire callback when one scene's data is on the GPU.
The per-scene counterpart of on_ready, which waits for all
of them. Fires once; immediately if that scene is already ready.
Must be called after display/launch, which is when the
startup tracker exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The scene key -- |
required |
callback
|
Callable[[], None]
|
Zero-argument callback. |
required |
Returns:
| Type | Description |
|---|---|
SubscriptionHandle
|
Active until callback fires; its |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the viewer has not been started yet. |
on_startup_progress ¶
on_startup_progress(callback: Callable[[int, int], None]) -> SubscriptionHandle
Fire callback(scenes_ready, scenes_total) as scenes load.
For a progress bar over a slow or remote dataset, where the gap between "shown" and "loaded" is long enough to need reporting.
Must be called after display/show/launch, which is when
the startup tracker exists. launch blocks until the window
closes, so with it register from code that runs in the event loop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
Callable[[int, int], None]
|
Called with the number of scenes ready and the total. |
required |
Returns:
| Type | Description |
|---|---|
SubscriptionHandle
|
Active until its |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the viewer has not been started yet. |
on_startup_stalled ¶
on_startup_stalled(callback: Callable[[dict], None]) -> SubscriptionHandle
Fire callback({scene key: state}) if startup does not finish.
The signal that was missing entirely: startup could only ever report success, so a viewer that never finished looked exactly like one still working. The payload names each unfinished scene and the state it stopped in, so the report can say what it was waiting for.
Stalling is not an error -- slow remote data legitimately takes a
while -- it is the cue that something is worth looking at. The
window is 30 s by default. display(..., stall_timeout=) tunes it
(None turns the check off); run, launch and show take
no stall_timeout and always use the default.
Must be called after display/show/launch, which is when
the startup tracker exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
Callable[[dict], None]
|
Called with |
required |
Returns:
| Type | Description |
|---|---|
SubscriptionHandle
|
Active until its |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the viewer has not been started yet. |
on_pick ¶
on_pick(canvas_id: UUID, event_type: type, callback: Callable[[Any], None], *, owner_id: UUID | None = None, weak: bool = False) -> SubscriptionHandle
Register a callback fired when a visual of one kind is picked.
Mirrors CellierController.on_pick; see it for the events,
their timing and gating.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
canvas_id
|
UUID
|
The canvas to watch, e.g. one of |
required |
event_type
|
type
|
One of |
required |
callback
|
Callable
|
Called with each pick event. |
required |
owner_id
|
UUID or None
|
Owner for bulk removal. Defaults to canvas_id, so removing the canvas removes the subscription. |
None
|
weak
|
bool
|
If True, hold only a weak reference to callback. |
False
|
Returns:
| Type | Description |
|---|---|
SubscriptionHandle
|
Call its |
unsubscribe ¶
unsubscribe(handle: SubscriptionHandle) -> None
Remove one subscription made by an on_* method.
The same as handle.unsubscribe(). Does nothing when the
subscription was already removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
SubscriptionHandle
|
The handle an |
required |
loading_progress ¶
loading_progress(visual: object) -> LoadingProgress | None
How far a multiscale visual's data has loaded.
Mirrors CellierController.loading_progress.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
visual
|
visual model or UUID
|
A multiscale image or labels visual. |
required |
Returns:
| Type | Description |
|---|---|
LoadingProgress or None
|
|
on_reslice_progress ¶
on_reslice_progress(visual: object, callback: Callable[[ResliceProgressEvent], None], *, owner_id: UUID | None = None, weak: bool = False) -> SubscriptionHandle
Register a callback fired as a multiscale visual's data loads.
Mirrors CellierController.on_reslice_progress.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
visual
|
visual model or UUID
|
A multiscale image or labels visual. |
required |
callback
|
Callable
|
Called with each |
required |
owner_id
|
UUID or None
|
Owner for |
None
|
weak
|
bool
|
If True, hold only a weak reference to callback. |
False
|
Returns:
| Type | Description |
|---|---|
SubscriptionHandle
|
Call its |
on_backstop_complete ¶
on_backstop_complete(visual: object, callback: Callable[[BackstopCompleteEvent], None], *, owner_id: UUID | None = None, weak: bool = False) -> SubscriptionHandle
Register a callback fired when a multiscale visual's backstop is in.
Mirrors CellierController.on_backstop_complete.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
visual
|
visual model or UUID
|
A multiscale image or labels visual. |
required |
callback
|
Callable
|
Called with each |
required |
owner_id
|
UUID or None
|
Owner for |
None
|
weak
|
bool
|
If True, hold only a weak reference to callback. |
False
|
Returns:
| Type | Description |
|---|---|
SubscriptionHandle
|
Call its |
set_loading ¶
set_loading(visual: object, **fields: Any) -> ProgressiveLoadingConfig
Change how a multiscale visual loads, while it is shown.
Mirrors CellierController.set_loading_config: fields are
merged into the visual's render_config.loading and applied at
once. An invalid combination raises and changes nothing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
visual
|
visual model or UUID
|
A multiscale image or labels visual. |
required |
**fields
|
Any
|
|
{}
|
Returns:
| Type | Description |
|---|---|
ProgressiveLoadingConfig
|
The visual's config after the call. |
set_lod_config ¶
set_lod_config(visual: object, **fields: Any) -> GeometryLodConfig
Change the level-of-detail settings of a multiscale mesh.
Mirrors CellierController.set_lod_config. dims_drag_draw
and camera_motion choose among the levels already loaded and
apply in the next frame; dims_drag decides what the next dims
scrub loads.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
visual
|
visual model or UUID
|
A multiscale mesh visual. |
required |
**fields
|
Any
|
|
{}
|
Returns:
| Type | Description |
|---|---|
GeometryLodConfig
|
The visual's config after the call. |
add_clipping_plane_gizmo ¶
add_clipping_plane_gizmo(visual: object, plane: ClippingPlane | UUID, *, canvas: UUID | None = None) -> ClippingPlaneGizmoController
Put a gizmo on one clipping plane of a visual, in the 3D view.
Dragging the gizmo moves and tilts the plane. Mirrors
CellierController.add_clipping_plane_gizmo: a canvas has
one gizmo at a time, and the gizmo closes itself when its plane or
its visual is removed or the view leaves 3D.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
visual
|
visual model or UUID
|
The visual the plane belongs to. |
required |
plane
|
ClippingPlane or UUID
|
One of |
required |
canvas
|
UUID or None
|
One of |
None
|
Returns:
| Type | Description |
|---|---|
ClippingPlaneGizmoController
|
The session. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the visual has no plane with that id. |
ValueError
|
If the view is in 2D, the plane has a component on an axis the view does not show, or canvas is omitted while the viewer does not have exactly one canvas. |
add_render_plane_gizmo ¶
add_render_plane_gizmo(visual: object, plane: RenderPlane | UUID, *, canvas: UUID | None = None) -> RenderPlaneGizmoController
Put a gizmo on one render plane of a visual, in the 3D view.
Dragging the gizmo moves and turns the plane, and its two in-plane
scale handles resize it (an axis with an unbounded side has none).
Mirrors CellierController.add_render_plane_gizmo: a canvas
has one gizmo at a time, clipping planes included, and the gizmo
closes itself when its plane or its visual is removed, the visual
leaves the "plane" render mode or the view leaves 3D.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
visual
|
visual model or UUID
|
The visual the plane belongs to, in the |
required |
plane
|
RenderPlane or UUID
|
One of |
required |
canvas
|
UUID or None
|
One of |
None
|
Returns:
| Type | Description |
|---|---|
RenderPlaneGizmoController
|
The session. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the visual has no render plane with that id. |
ValueError
|
If the view is in 2D, the visual is not in plane mode, the plane's axes are not the displayed ones, or canvas is omitted while the viewer does not have exactly one canvas. |
remove_plane_gizmo ¶
remove_plane_gizmo(*, canvas: UUID | None = None) -> None
Close a canvas's plane gizmo, of either kind; nothing if it has none.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
canvas
|
UUID or None
|
One of |
None
|
screenshot ¶
screenshot(*, canvas: UUID | None = None, size: tuple[int, int] | None = None, scale: float = 1.0, frames: int | Literal['converged'] = 1, save: str | Path | None = None, **capture_kwargs) -> ndarray
Capture a reproducible screenshot as an RGBA uint8 array.
The frame is rendered offscreen, so two captures of the same viewer state produce byte-identical arrays and the result does not depend on a window being open, on the display's pixel ratio, or on which GUI toolkit the viewer targets.
The capture shows the data currently resident on the GPU -- it does
not reslice. Capture from on_ready (or after launch /
show / display have fired it) when a load may still be running.
A viewer with no canvas still renders, fitting the camera to the
scene, but it will have no data to show: slice requests are planned
per canvas, so a viewer that never called add_canvas has never
loaded anything. Add a canvas and let the reslice finish first --
cellier.convenience.capture does this for you.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
canvas
|
UUID or None
|
Which canvas's viewpoint to reproduce, from |
None
|
size
|
tuple[int, int] or None
|
|
None
|
scale
|
float
|
Multiplier applied to size. |
1.0
|
frames
|
int or 'converged'
|
|
1
|
save
|
str, Path, or None
|
When given, also write the frame to this path as a PNG. |
None
|
**capture_kwargs
|
Forwarded to the capture helper ( |
{}
|
Returns:
| Type | Description |
|---|---|
ndarray
|
RGBA uint8 array of shape |
Raises:
| Type | Description |
|---|---|
ValueError
|
If canvas is not one of this viewer's canvases, or if it is omitted while the viewer has more than one canvas. |
to_file ¶
Serialize the viewer model state to a JSON file.
The file captures scenes, visuals, data stores, canvases with their
camera models, and the render pipeline configuration. Pass the
path to from_file to restore an equivalent Viewer.
The cameras are saved with their pose, which from_file
restores. The gui toolkit is not saved; pass it to
from_file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Destination file path. |
required |
from_file
classmethod
¶
Restore a Viewer from a previously serialized file.
The render pipeline configuration, scenes, visuals, data stores and
canvases are restored from the file, and each camera starts at its
saved pose. launch / show / display keep that view
(their default fit=None does not fit placed cameras); pass
fit="ready" to fit to the data instead. A camera that was never
shown before saving (the 3D camera of a viewer saved in 2D) has no
pose and is fitted the first time it is shown.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Path to a JSON file written by |
required |
gui
|
('qt', 'anywidget', 'offscreen')
|
Toolkit to build the canvases with; the file does not record
one. The canvases are built during this call, so |
"qt"
|
Returns:
| Type | Description |
|---|---|
Viewer
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the file contains zero or more than one scene. |
add_canvas ¶
add_canvas(*, render_modes: set[str] | None = None, initial_dim: str | None = None, fov: float = 70.0, depth_range_3d: tuple[float, float] = (1.0, 8000.0), depth_range_2d: tuple[float, float] = (-500.0, 500.0), canvas_size: tuple[int, int] | None = None, fit_view_direction_3d: Mapping[AxisRef, float] | None = None, fit_up_3d: Mapping[AxisRef, float] | None = None) -> QWidget
Create a canvas attached to this viewer's scene.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
render_modes
|
set[str] or None
|
Which camera modes to prepare. Defaults to the scene's own
|
None
|
initial_dim
|
str or None
|
Which mode is active first. Inferred from the scene's current
|
None
|
fov
|
float
|
Vertical field of view in degrees for the 3D camera. Default 70. |
70.0
|
depth_range_3d
|
tuple[float, float]
|
|
(1.0, 8000.0)
|
depth_range_2d
|
tuple[float, float]
|
|
(-500.0, 500.0)
|
canvas_size
|
tuple[int, int] or None
|
Initial CSS pixel size for the anywidget canvas. Ignored for the
Qt gui. Defaults to |
None
|
fit_view_direction_3d
|
Mapping[AxisRef, float] or None
|
The view direction and up vector the 3D camera is fitted with, each
as the component along named world axes, e.g. |
None
|
fit_up_3d
|
Mapping[AxisRef, float] or None
|
The view direction and up vector the 3D camera is fitted with, each
as the component along named world axes, e.g. |
None
|
Returns:
| Type | Description |
|---|---|
QWidget or AnywidgetRenderCanvas or OffscreenRenderCanvas
|
The canvas for this viewer's |
set_displayed_dimensions ¶
Set which axes are displayed, by name or by id.
Switches the scene between 2D and 3D rendering by resolving axis_names to axis indices and calling the controller's dims API. Every axis keeps its slice position whether or not it is displayed, so an axis that goes from displayed back to sliced slices where it last was.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axis_names
|
sequence of str or UUID
|
The axes to display, e.g. |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If an entry is neither a name nor an id. |
ValueError
|
If axis_names does not have 2 or 3 entries, an entry names no axis or an ambiguous one, or an axis is given twice. |
set_slice_positions ¶
Move the slice position of one or more world axes.
By default a jump: every visual loads in full at once. With
interactive=True, or inside dims_interaction, it is a
tick of a scrub: visuals with coarsest_while_moving on for the
view load their coarse backstop only, and load in full when the scrub ends.
See CellierController.update_slice_indices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
Mapping[int, float]
|
World axis index -> world position. Other axes keep theirs. |
required |
interactive
|
bool
|
Whether the move is a tick of a scrub. |
False
|
dims_interaction ¶
dims_interaction() -> Generator[None, None, None]
Scrub the dims for the length of a with block.
Every slice-position move inside the block is a scrub tick, so a player or a scripted sweep loads coarse while it runs and in full when the block exits:
with viewer.dims_interaction():
for t in range(n_frames):
viewer.set_slice_positions({0: t})
A sweep that wants every position at full resolution does not open one.
transform_interaction ¶
Drag a visual's transform for the length of a with block.
Every assignment of the visual's transform inside the block is a
tick of one drag (CellierController.transform_interaction):
with viewer.transform_interaction(visual):
for angle in angles:
visual.transform = rotated(angle)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
visual
|
UUID or visual
|
The visual, or its id. |
required |
get_camera_state ¶
get_camera_state(*, canvas: UUID | None = None) -> CameraState
Return a snapshot of a canvas's camera.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
canvas
|
UUID or None
|
One of |
None
|
Returns:
| Type | Description |
|---|---|
CameraState
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If canvas is not this viewer's, or is omitted while the viewer does not have exactly one canvas. |
set_camera_state ¶
set_camera_state(state: CameraState, *, canvas: UUID | None = None, interactive: bool = False) -> None
Move a canvas's camera to state.
By default a jump: multiscale image and labels reslice at once
for the new view. With interactive=True, or inside
camera_interaction, it is a tick of a motion: nothing is
resliced until the motion ends. See
CellierController.set_camera_state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
CameraState
|
The state to apply; |
required |
canvas
|
UUID or None
|
One of |
None
|
interactive
|
bool
|
Whether the move is a tick of a motion. |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the canvas cannot be resolved (see |
fit_camera ¶
fit_camera(*, canvas: UUID | None = None, interactive: bool = False, only_visible_visuals: bool = False) -> None
Fit the camera to the box the scene's data occupies.
A jump, like set_camera_state. See
CellierController.fit_camera for how the box and the far plane are
worked out.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
canvas
|
UUID or None
|
One of |
None
|
interactive
|
bool
|
Whether the move is a tick of a camera motion instead of a jump. |
False
|
only_visible_visuals
|
bool
|
Fit to the visuals that are shown only. The far plane still keeps
every visual in view. Default |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If canvas is not one of this viewer's canvases. |
camera_interaction ¶
Move a camera as one motion for the length of a with block.
Every camera move inside the block is a tick of a motion, so a fly-through reslices once, when the block exits, instead of at every pose:
with viewer.camera_interaction():
for pose in path:
viewer.set_camera_state(pose)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
canvas
|
UUID or None
|
One of |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the canvas cannot be resolved; see |
add_image ¶
add_image(data: ImageMemoryStore | UUID, appearance: InMemoryImageAppearance | None = None, name: str = 'image', controls: list[Control] | None = None, *, single: InMemoryImageSingleAppearance | None = None, channel_axis: int | None = None, composite: bool = False, channels: dict[int, InMemoryImageChannelAppearance] | None = None, max_channels: int = 4, transform: BaseTransform | None = None, outline: VisualOutline | None = None, ambient_occlusion: bool | None = None, pick_write: bool = True, clipping_planes: Sequence[ClippingPlane] = (), render_planes: Sequence[RenderPlane] = (), render_config: InMemoryImageRenderConfig | None = None) -> ImageVisual
Add an in-memory image visual.
One visual draws the image single-channel or composited; see
cellier.controller.CellierController.add_image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ImageMemoryStore or UUID
|
Backing data store or the UUID of an already-registered store. |
required |
appearance
|
InMemoryImageAppearance or None
|
Shared by both modes. |
None
|
name
|
str
|
Human-readable label. Default |
'image'
|
controls
|
list[Control] or None
|
The controls to show for this visual in the layout's docks: a
list of control models, drawn in the order of the list. The
image's fields are chosen with |
None
|
single
|
single appearance or None
|
Single mode's appearance. |
None
|
channel_axis
|
int or None
|
The data axis a composite draws channels along; it must map to a
world axis. |
None
|
composite
|
bool
|
Start in composite mode. Requires channel_axis. |
False
|
channels
|
dict[int, channel appearance] or None
|
Composite mode's per-channel appearances. |
None
|
max_channels
|
int
|
The most channels the visual may hold. Default 4. |
4
|
transform
|
BaseTransform or None
|
Data-to-world transform. Identity when |
None
|
outline
|
VisualOutline or None
|
Screen-space outline assignment. |
None
|
ambient_occlusion
|
bool or None
|
Whether this visual receives ambient occlusion. |
None
|
pick_write
|
bool
|
Whether the visual writes to the pick buffer. Default |
True
|
clipping_planes
|
Sequence[ClippingPlane]
|
Clipping planes, in the store's level-0 data coordinates: the
visual is drawn only on the kept side of every enabled plane.
Build them from |
()
|
render_planes
|
Sequence[RenderPlane]
|
The planes the |
()
|
render_config
|
InMemoryImageRenderConfig or None
|
The GPU configuration of the brick route, which draws a tilted
2D view of the image. |
None
|
Returns:
| Type | Description |
|---|---|
ImageVisual
|
|
add_labels ¶
add_labels(data: LabelMemoryStore | UUID, appearance: BaseLabelsAppearance | None = None, name: str = 'labels', transform: BaseTransform | None = None, controls: list[Control] | None = None, outline: VisualOutline | None = None, ambient_occlusion: bool | None = None, pick_write: bool = True, outline_selected_labels: dict[int, int] | None = None, outline_mode: OutlineMode = 'per_label', outline_depth_range: tuple[float, float] | None = None, clipping_planes: Sequence[ClippingPlane] = (), render_planes: Sequence[RenderPlane] = (), render_config: InMemoryLabelRenderConfig | None = None) -> LabelMemoryVisual
Add an in-memory label visual.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
LabelMemoryStore or UUID
|
Backing data store or the UUID of an already-registered store. |
required |
appearance
|
BaseLabelsAppearance or None
|
Appearance parameters. Defaults to |
None
|
name
|
str
|
Human-readable label. Default |
'labels'
|
transform
|
BaseTransform or None
|
Data-to-world transform. Defaults to identity when |
None
|
controls
|
list[Control] or None
|
The controls to show for this visual in the layout's docks: a
list of control models, drawn in the order of the list. The
visual's fields are chosen with |
None
|
outline
|
VisualOutline or None
|
Screen-space outline assignment. |
None
|
ambient_occlusion
|
bool or None
|
Whether this visual receives ambient occlusion. |
None
|
pick_write
|
bool
|
Whether the visual writes to the pick buffer. |
True
|
outline_selected_labels
|
dict[int, int] or None
|
Maps a label value to the palette slot the selection layer draws
it in. |
None
|
outline_mode
|
str
|
How the labels are outlined: |
'per_label'
|
outline_depth_range
|
tuple[float, float] or None
|
|
None
|
clipping_planes
|
Sequence[ClippingPlane]
|
Clipping planes, in the store's level-0 data coordinates: the
visual is drawn only on the kept side of every enabled plane.
Build them from |
()
|
render_planes
|
Sequence[RenderPlane]
|
The planes the |
()
|
render_config
|
InMemoryLabelRenderConfig or None
|
The GPU configuration of the brick route, which draws a tilted
2D view of the labels. |
None
|
Returns:
| Type | Description |
|---|---|
LabelMemoryVisual
|
|
add_mesh ¶
add_mesh(data: MeshMemoryStore | UUID, appearance: MeshAppearance, name: str = 'mesh', transform: BaseTransform | None = None, controls: list[Control] | None = None, outline: VisualOutline | None = None, ambient_occlusion: bool | None = None, pick_write: bool = True, section: MeshSectionConfig | None = None, clipping_planes: Sequence[ClippingPlane] = ()) -> MeshVisual
Add a mesh visual.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
MeshMemoryStore or UUID
|
Backing data store or the UUID of an already-registered store. |
required |
appearance
|
MeshFlatAppearance or MeshPhongAppearance
|
Appearance parameters. |
required |
name
|
str
|
Human-readable label. Default |
'mesh'
|
transform
|
BaseTransform or None
|
Data-to-world transform. Defaults to identity when |
None
|
controls
|
list[Control] or None
|
The controls to show for this visual in the layout's docks: a
list of control models, drawn in the order of the list. The
visual's fields are chosen with |
None
|
outline
|
VisualOutline or None
|
Screen-space outline assignment. |
None
|
ambient_occlusion
|
bool or None
|
Whether this visual receives ambient occlusion. |
None
|
pick_write
|
bool
|
Whether the visual writes to the pick buffer. |
True
|
section
|
MeshSectionConfig or None
|
How the mesh is drawn in a 2D view: the outline and fill of its
cross-section, and whether the cut is the slice plane
( |
None
|
clipping_planes
|
Sequence[ClippingPlane]
|
Clipping planes, in the store's level-0 data coordinates: the
visual is drawn only on the kept side of every enabled plane.
Build them from |
()
|
Returns:
| Type | Description |
|---|---|
MeshVisual
|
|
add_multiscale_mesh ¶
add_multiscale_mesh(data: MultiscaleMeshStore | UUID, appearance: MeshAppearance, name: str = 'mesh', transform: BaseTransform | None = None, controls: list[Control] | None = None, outline: VisualOutline | None = None, ambient_occlusion: bool | None = None, pick_write: bool = True, section: MeshSectionConfig | None = None, lod: GeometryLodConfig | None = None, clipping_planes: Sequence[ClippingPlane] = ()) -> MultiscaleMeshVisual
Add a mesh with levels of detail.
Two levels are kept loaded, the finest and one coarse level. A new position shows the coarse level first and the finest when it has loaded; a dims scrub loads the coarse level only until it ends.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
MultiscaleMeshStore or UUID
|
The mesh's levels, finest first, or the UUID of an already-registered store. |
required |
appearance
|
MeshFlatAppearance or MeshPhongAppearance
|
Appearance parameters, shared by both levels. |
required |
name
|
str
|
Human-readable label. Default |
'mesh'
|
transform
|
BaseTransform or None
|
Data-to-world transform. Defaults to identity when |
None
|
controls
|
list[Control] or None
|
The controls to show for this visual in the layout's docks: a
list of control models, drawn in the order of the list. The
visual's fields are chosen with |
None
|
outline
|
VisualOutline or None
|
Screen-space outline assignment; see |
None
|
ambient_occlusion
|
bool or None
|
Whether this visual receives ambient occlusion; see
|
None
|
pick_write
|
bool
|
Whether the visual writes to the pick buffer; see
|
True
|
section
|
MeshSectionConfig or None
|
How the mesh is drawn in a 2D view; see |
None
|
lod
|
GeometryLodConfig or None
|
Which coarse level is kept (the coarsest by default), and what a dims scrub loads and draws. |
None
|
clipping_planes
|
Sequence[ClippingPlane]
|
Clipping planes, in the store's level-0 data coordinates: the
visual is drawn only on the kept side of every enabled plane.
Build them from |
()
|
Returns:
| Type | Description |
|---|---|
MultiscaleMeshVisual
|
|
add_points ¶
add_points(data: PointsMemoryStore | UUID, appearance: PointsMarkerAppearance | None = None, name: str = 'points', transform: BaseTransform | None = None, controls: list[Control] | None = None, outline: VisualOutline | None = None, ambient_occlusion: bool | None = None, pick_write: bool = True, clipping_planes: Sequence[ClippingPlane] = ()) -> PointsVisual
Add a points visual.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
PointsMemoryStore or UUID
|
Backing data store or the UUID of an already-registered store. |
required |
appearance
|
PointsMarkerAppearance or None
|
Appearance parameters. Defaults to |
None
|
name
|
str
|
Human-readable label. Default |
'points'
|
transform
|
BaseTransform or None
|
Data-to-world transform. Defaults to identity when |
None
|
controls
|
list[Control] or None
|
The controls to show for this visual in the layout's docks: a
list of control models, drawn in the order of the list. The
visual's fields are chosen with |
None
|
outline
|
VisualOutline or None
|
Screen-space outline assignment. |
None
|
ambient_occlusion
|
bool or None
|
Whether this visual receives ambient occlusion. |
None
|
pick_write
|
bool
|
Whether the visual writes to the pick buffer. |
True
|
clipping_planes
|
Sequence[ClippingPlane]
|
Clipping planes, in the store's level-0 data coordinates: the
visual is drawn only on the kept side of every enabled plane.
Build them from |
()
|
Returns:
| Type | Description |
|---|---|
PointsVisual
|
|
add_graph ¶
add_graph(data: GraphMemoryStore | UUID, appearance: GraphAppearance | None = None, name: str = 'graph', transform: BaseTransform | None = None, trail: dict[int, TrailConfig] | None = None, controls: list[Control] | None = None, outline: VisualOutline | None = None, ambient_occlusion: bool | None = None, pick_write: bool = True, clipping_planes: Sequence[ClippingPlane] = ()) -> GraphVisual
Add a spatial-graph visual.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
GraphMemoryStore or UUID
|
Backing data store or the UUID of an already-registered store. |
required |
appearance
|
GraphAppearance or None
|
Appearance parameters. Defaults to |
None
|
name
|
str
|
Human-readable label. Default |
'graph'
|
trail
|
dict[int, TrailConfig] or None
|
Axis index -> window configuration. Extends the slab on that
axis and optionally fades elements by distance from the current
slice index. An out-of-range axis raises |
None
|
transform
|
BaseTransform or None
|
Data-to-world transform. When |
None
|
controls
|
list[Control] or None
|
The controls to show for this visual in the layout's docks: a
list of control models, drawn in the order of the list. The
visual's fields are chosen with |
None
|
outline
|
VisualOutline or None
|
Screen-space outline assignment. |
None
|
ambient_occlusion
|
bool or None
|
Whether this visual receives ambient occlusion. |
None
|
pick_write
|
bool
|
Whether the visual writes to the pick buffer. |
True
|
clipping_planes
|
Sequence[ClippingPlane]
|
Clipping planes, in the store's level-0 data coordinates: the
visual is drawn only on the kept side of every enabled plane.
Build them from |
()
|
Returns:
| Type | Description |
|---|---|
GraphVisual
|
|
add_lines ¶
add_lines(data: LinesMemoryStore | UUID, appearance: LinesMemoryAppearance | None = None, name: str = 'lines', transform: BaseTransform | None = None, controls: list[Control] | None = None, outline: VisualOutline | None = None, ambient_occlusion: bool | None = None, pick_write: bool = True, clipping_planes: Sequence[ClippingPlane] = ()) -> LinesVisual
Add a lines visual.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
LinesMemoryStore or UUID
|
Backing data store or the UUID of an already-registered store. |
required |
appearance
|
LinesMemoryAppearance or None
|
Appearance parameters. Defaults to |
None
|
name
|
str
|
Human-readable label. Default |
'lines'
|
transform
|
BaseTransform or None
|
Data-to-world transform. Defaults to identity when |
None
|
controls
|
list[Control] or None
|
The controls to show for this visual in the layout's docks: a
list of control models, drawn in the order of the list. The
visual's fields are chosen with |
None
|
outline
|
VisualOutline or None
|
Screen-space outline assignment. |
None
|
ambient_occlusion
|
bool or None
|
Whether this visual receives ambient occlusion. |
None
|
pick_write
|
bool
|
Whether the visual writes to the pick buffer. |
True
|
clipping_planes
|
Sequence[ClippingPlane]
|
Clipping planes, in the store's level-0 data coordinates: the
visual is drawn only on the kept side of every enabled plane.
Build them from |
()
|
Returns:
| Type | Description |
|---|---|
LinesVisual
|
|
add_image_multiscale ¶
add_image_multiscale(data: BaseDataStore | UUID, appearance: MultiscaleImageAppearance | None = None, name: str = 'image', render_config: MultiscaleImageRenderConfig | None = None, transform: BaseTransform | None = None, controls: list[Control] | None = None, *, single: MultiscaleImageSingleAppearance | None = None, channel_axis: int | None = None, composite: bool = False, channels: dict[int, MultiscaleImageChannelAppearance] | None = None, max_channels: int = 4, outline: VisualOutline | None = None, ambient_occlusion: bool | None = None, pick_write: bool = True, clipping_planes: Sequence[ClippingPlane] = (), render_planes: Sequence[RenderPlane] = ()) -> MultiscaleImageVisual
Add a multiscale image visual.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
BaseDataStore or UUID
|
Backing multiscale data store or UUID of an already-registered store. |
required |
appearance
|
MultiscaleImageAppearance or None
|
Shared by both modes, including the LOD settings. |
None
|
name
|
str
|
Human-readable label. Default |
'image'
|
render_config
|
MultiscaleImageRenderConfig or None
|
GPU cache configuration. Uses defaults when |
None
|
transform
|
BaseTransform or None
|
Data-to-world transform. Defaults to identity when |
None
|
controls
|
list[Control] or None
|
The controls to show for this visual in the layout's docks: a
list of control models, drawn in the order of the list. The
image's fields are chosen with |
None
|
single
|
single appearance or None
|
Single mode's appearance. |
None
|
channel_axis
|
int or None
|
The data axis a composite draws channels along; it must map to a
world axis. |
None
|
composite
|
bool
|
Start in composite mode. Requires channel_axis. |
False
|
channels
|
dict[int, channel appearance] or None
|
Composite mode's per-channel appearances. |
None
|
max_channels
|
int
|
The most channels the visual may hold. Default 4. |
4
|
outline
|
VisualOutline or None
|
Screen-space outline assignment. |
None
|
ambient_occlusion
|
bool or None
|
Whether this visual receives ambient occlusion. |
None
|
pick_write
|
bool
|
Whether the visual writes to the pick buffer. Default |
True
|
clipping_planes
|
Sequence[ClippingPlane]
|
Clipping planes, in the store's level-0 data coordinates: the
visual is drawn only on the kept side of every enabled plane.
Build them from |
()
|
render_planes
|
Sequence[RenderPlane]
|
The planes the |
()
|
Returns:
| Type | Description |
|---|---|
MultiscaleImageVisual
|
|
add_masked_image ¶
add_masked_image(mask: BaseDataStore | UUID, value: BaseDataStore | UUID, value_to_mask: AffineTransform | ndarray | None = None, transform: AffineTransform | None = None, appearance: MaskedImageAppearance | None = None, single: MaskedImageSingleAppearance | None = None, render_config: MaskedImageRenderConfig | None = None, name: str = 'masked image', controls: list[Control] | None = None, *, outline: VisualOutline | None = None, ambient_occlusion: bool | None = None, pick_write: bool = True, clipping_planes: Sequence[ClippingPlane] = ()) -> MaskedImageVisual
Add a MaskedImage: a mask's isosurface coloured by a value image.
The surface is found and lit in mask at single.iso_threshold
and coloured from value. In 3D the colour is the max, mean or min
of the value along the surface normal over single.surface_thickness;
in 2D the thickness is the width of a contour band, each pixel
showing its own value. See
cellier.controller.CellierController.add_masked_image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
BaseDataStore or UUID
|
The image whose isosurface is drawn, in memory or multiscale, or the UUID of a registered store. |
required |
value
|
BaseDataStore or UUID
|
The image the surface is coloured from, in memory or multiscale, on its own grid, or the UUID of a registered store. |
required |
value_to_mask
|
(AffineTransform, array - like or None)
|
Value level-0 data coordinates to mask level-0 data coordinates.
|
None
|
transform
|
AffineTransform or None
|
The mask's data-to-world transform; the value follows it. Defaults to the identity. |
None
|
appearance
|
MaskedImageAppearance or None
|
Shared appearance, including each image's level of detail. |
None
|
single
|
MaskedImageSingleAppearance or None
|
The surface's appearance: the value's colour map, |
None
|
render_config
|
MaskedImageRenderConfig or None
|
Block size and each image's GPU budget (1,100 MiB each by default, allocated whatever the image's size). |
None
|
name
|
str
|
Human-readable label. Default |
'masked image'
|
controls
|
list[Control] or None
|
The controls to show for this visual in the layout's docks, in
the order of the list. |
None
|
outline
|
VisualOutline | None
|
As |
None
|
ambient_occlusion
|
VisualOutline | None
|
As |
None
|
pick_write
|
VisualOutline | None
|
As |
None
|
clipping_planes
|
VisualOutline | None
|
As |
None
|
Returns:
| Type | Description |
|---|---|
MaskedImageVisual
|
|
add_labels_multiscale ¶
add_labels_multiscale(data: BaseDataStore | UUID, appearance: MultiscaleLabelsAppearance | None = None, name: str = 'labels', render_config: MultiscaleLabelRenderConfig | None = None, transform: BaseTransform | None = None, controls: list[Control] | None = None, outline: VisualOutline | None = None, ambient_occlusion: bool | None = None, pick_write: bool = True, outline_selected_labels: dict[int, int] | None = None, outline_mode: OutlineMode = 'per_label', outline_depth_range: tuple[float, float] | None = None, clipping_planes: Sequence[ClippingPlane] = (), render_planes: Sequence[RenderPlane] = ()) -> MultiscaleLabelVisual
Add a multiscale label visual.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
BaseDataStore or UUID
|
Backing multiscale label store or UUID of an already-registered store. |
required |
appearance
|
MultiscaleLabelsAppearance or None
|
Visual appearance parameters. Defaults to
|
None
|
name
|
str
|
Human-readable label. Default |
'labels'
|
render_config
|
MultiscaleLabelRenderConfig or None
|
LOD and rendering configuration. Uses
defaults when |
None
|
transform
|
BaseTransform or None
|
Data-to-world transform. Defaults to identity when |
None
|
controls
|
list[Control] or None
|
The controls to show for this visual in the layout's docks: a
list of control models, drawn in the order of the list. The
visual's fields are chosen with |
None
|
outline
|
VisualOutline or None
|
Screen-space outline assignment. |
None
|
ambient_occlusion
|
bool or None
|
Whether this visual receives ambient occlusion. |
None
|
pick_write
|
bool
|
Whether the visual writes to the pick buffer. |
True
|
outline_selected_labels
|
dict[int, int] or None
|
Maps a label value to the palette slot the selection layer draws
it in. |
None
|
outline_mode
|
str
|
How the labels are outlined: |
'per_label'
|
outline_depth_range
|
tuple[float, float] or None
|
|
None
|
clipping_planes
|
Sequence[ClippingPlane]
|
Clipping planes, in the store's level-0 data coordinates: the
visual is drawn only on the kept side of every enabled plane.
Build them from |
()
|
render_planes
|
Sequence[RenderPlane]
|
The planes the |
()
|
Returns:
| Type | Description |
|---|---|
MultiscaleLabelVisual
|
|
cellier.convenience.OrthoViewer ¶
Bases: ControlsRegistryMixin, RenderSettingsMixin
Four-panel orthoviewer wrapping a single CellierController.
Creates a controller and four pre-wired scenes that share one world
coordinate system: three orthogonal 2D slice panels (xy, xz,
yz) and one 3D volume panel (vol). No Qt objects are constructed
here; build canvases with
cellier.convenience.gui.build_ortho_grid_widget when ready.
The three spatial axes (default: the last three axis labels, treated as
z, y, x) define the slice planes. Any remaining axes are "extra" axes
(e.g. channel or time). By default every axis's slice position, thickness
and slider override is mirrored across the four panels, so the
panels share one world point.
Every panel starts with a uniform black background; see
set_background.
Appearance controls come in two groups per added visual: one drives the
three 2D panels together, the other the 3D panel. An
AppearanceControls() dock offers both, labelled "{name} (2D
views)" and "{name} (3D view)".
Clipping planes controls are not in the appearance docks. A visual
whose controls= list holds ClippingPlanesControl() is shown in the
OrthoClippingControls() dock, which holds the link mode selector
(see link_clipping_planes) and one clipping planes control per group
of linked panels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axes
|
WorldAxesLike
|
The world axes in order: a |
required |
spatial_axes
|
tuple[str, ...], tuple[int, ...], or None
|
The three axes (names or indices, in |
None
|
link_axes
|
bool
|
When |
True
|
link_clipping_planes
|
('all', '2d')
|
Which panels of one |
"all"
|
render_config
|
RenderManagerConfig or None
|
Render pipeline configuration passed through to the controller. |
None
|
gui
|
"qt", "anywidget", or "offscreen"
|
Which GUI toolkit the canvases should target. |
'qt'
|
draw_status_overlay
|
bool
|
Whether every panel names, in its top-left corner, the visuals its
view does not draw. Default |
True
|
render_config
property
¶
render_config: RenderManagerConfig
Live rendering configuration.
Mutating a field here changes the model but not the GPU state, and notifies no widget. The named properties below do all three; reach for this to read the whole configuration or to serialise it.
outline_enabled
property
writable
¶
outline_enabled: bool
Whether the screen-space outline pass is active.
outline_boundaries_enabled
property
writable
¶
outline_boundaries_enabled: bool
Whether the boundaries layer (every outlined region) draws.
outline_selection_enabled
property
writable
¶
outline_selection_enabled: bool
Whether the selection layer (regions with a palette slot) draws.
ambient_occlusion_enabled
property
writable
¶
ambient_occlusion_enabled: bool
Whether the ambient occlusion pass is active. 3D only.
ambient_occlusion_radius
property
writable
¶
ambient_occlusion_radius: float | None
Occlusion hemisphere radius in scene units, or None for auto.
None derives it from the scene bounding box diagonal, which is
the only default that means anything across cellier's coordinate
systems. ambient_occlusion_effective_radius reports what that came to.
ambient_occlusion_auto_radius_fraction
property
writable
¶
ambient_occlusion_auto_radius_fraction: float
Fraction of the scene bounding box diagonal used when radius is auto.
ambient_occlusion_effective_radius
property
¶
ambient_occlusion_effective_radius: float | None
The occlusion radius actually in use, in scene units. Read-only.
ambient_occlusion_strength
property
writable
¶
ambient_occlusion_strength: float
How far the occlusion is applied, 0 (off) to 1 (full).
ambient_occlusion_power
property
writable
¶
ambient_occlusion_power: float
Contrast exponent applied to the occlusion before the multiply.
ambient_occlusion_bias
property
writable
¶
ambient_occlusion_bias: float
Depth-comparison bias, as a fraction of the effective radius.
ambient_occlusion_n_samples
property
writable
¶
ambient_occlusion_n_samples: int
Hemisphere samples per pixel. Changing this recompiles the shader.
ambient_occlusion_blur_radius
property
writable
¶
ambient_occlusion_blur_radius: int
Occlusion box-blur half-width in internal pixels. Recompiles.
temporal_enabled
property
writable
¶
temporal_enabled: bool
Whether the temporal accumulation pass is active. 3D only.
temporal_blend_weight
property
writable
¶
temporal_blend_weight: float
Minimum EMA blend weight for the current frame, in (0, 1].
Lower values give a smoother settled image and take longer to get there after a camera move.
draw_status_overlay
property
¶
draw_status_overlay: DrawStatusOverlay | None
The text overlay naming visuals a panel's view does not draw.
On by default (OrthoViewer(..., draw_status_overlay=True)); every
panel canvas shows it. Under a rotation not about one view axis, a
2D panel whose slice cuts an image at an angle draws nothing of it
and lists it here. Its fields are live. None when the viewer
was built without it.
gui
property
¶
gui: str
The GUI toolkit this viewer renders into.
"qt", "anywidget" or "offscreen" (no window: for
scripted screenshots and tests).
startup_state
property
¶
startup_state: StartupState
How far this viewer has got through starting up.
Readable at any moment, with no callback, no event loop and no front end -- which is the point. A blank viewer used to be undiagnosable from Python; now it can say whether it is waiting for the canvas to reach the browser, waiting for a first frame, loading data, or done.
StartupState.IDLE until display/launch/show runs.
scene_startup_states
property
¶
scene_startup_states: dict[str, StartupState]
Each scene's startup state, keyed as this viewer keys its scenes.
An aggregate hides which panel is stuck; this does not.
spatial_axes
property
¶
The three spatial axis indices in (z, y, x) order.
dims_controller
property
¶
The controller mirroring dims across the panels, if linked.
clipping_controller
property
¶
The controller linking clipping planes across the panels.
Its mode ("all", "2d" or None) says which panels of
one add_* call carry one tuple of planes, and can be set at any
time:
ortho.clipping_controller.mode = "2d"
plane_controller
property
¶
The controller tying the 3D panel's render planes to the 2D panels.
Its mode is None (the default: no link) or "slices":
every image and labels visual of the 3D panel then carries three
render planes, one per 2D panel, at that panel's slice position, and
a 2D slider moves its plane:
ortho.add_image_multiscale(
store, single=MultiscaleImageSingleAppearance(render_mode="plane")
)
ortho.plane_controller.mode = "slices"
The planes are drawn by the visuals that are in the "plane"
render mode.
axis_sync_enabled
property
writable
¶
axis_sync_enabled: bool
Whether dims edits are mirrored across the panels.
reset_temporal_accumulation ¶
Discard the accumulated history on every canvas.
set_background ¶
set_background(background: BackgroundAppearance) -> None
Apply one background appearance to all four panels.
Each panel is its own Scene and so owns its own background; use
viewer.scenes["xy"].background to change just one. A copy is
given to each panel so that later edits to one panel's background do
not leak into the others.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
background
|
BackgroundAppearance
|
The background appearance to apply to every panel. |
required |
startup_report ¶
startup_report() -> str
A one-line summary of startup progress, for a cell or a log line.
on_pick ¶
on_pick(canvas_id: UUID, event_type: type, callback: Callable[[Any], None], *, owner_id: UUID | None = None, weak: bool = False) -> SubscriptionHandle
Register a callback fired when a visual of one kind is picked.
Mirrors CellierController.on_pick; see it for the events,
their timing and gating.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
canvas_id
|
UUID
|
The canvas to watch, e.g. one of a panel scene's canvases. |
required |
event_type
|
type
|
One of |
required |
callback
|
Callable
|
Called with each pick event. |
required |
owner_id
|
UUID or None
|
Owner for bulk removal. Defaults to canvas_id, so removing the canvas removes the subscription. |
None
|
weak
|
bool
|
If True, hold only a weak reference to callback. |
False
|
Returns:
| Type | Description |
|---|---|
SubscriptionHandle
|
Call its |
unsubscribe ¶
unsubscribe(handle: SubscriptionHandle) -> None
Remove one subscription made by an on_* method.
The same as handle.unsubscribe(). Does nothing when the
subscription was already removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
handle
|
SubscriptionHandle
|
The handle an |
required |
on_scene_ready ¶
on_scene_ready(key: str, callback: Callable[[], None]) -> SubscriptionHandle
Fire callback when one scene's data is on the GPU.
The per-scene counterpart of on_ready, which waits for all
of them. Fires once; immediately if that scene is already ready.
Must be called after display/launch, which is when the
startup tracker exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The scene key -- |
required |
callback
|
Callable[[], None]
|
Zero-argument callback. |
required |
Returns:
| Type | Description |
|---|---|
SubscriptionHandle
|
Active until callback fires; its |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the viewer has not been started yet. |
on_startup_progress ¶
on_startup_progress(callback: Callable[[int, int], None]) -> SubscriptionHandle
Fire callback(scenes_ready, scenes_total) as scenes load.
For a progress bar over a slow or remote dataset, where the gap between "shown" and "loaded" is long enough to need reporting.
Must be called after display/show/launch, which is when
the startup tracker exists. launch blocks until the window
closes, so with it register from code that runs in the event loop.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
Callable[[int, int], None]
|
Called with the number of scenes ready and the total. |
required |
Returns:
| Type | Description |
|---|---|
SubscriptionHandle
|
Active until its |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the viewer has not been started yet. |
on_startup_stalled ¶
on_startup_stalled(callback: Callable[[dict], None]) -> SubscriptionHandle
Fire callback({scene key: state}) if startup does not finish.
The signal that was missing entirely: startup could only ever report success, so a viewer that never finished looked exactly like one still working. The payload names each unfinished scene and the state it stopped in, so the report can say what it was waiting for.
Stalling is not an error -- slow remote data legitimately takes a
while -- it is the cue that something is worth looking at. The
window is 30 s by default. display(..., stall_timeout=) tunes it
(None turns the check off); run, launch and show take
no stall_timeout and always use the default.
Must be called after display/show/launch, which is when
the startup tracker exists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
Callable[[dict], None]
|
Called with |
required |
Returns:
| Type | Description |
|---|---|
SubscriptionHandle
|
Active until its |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the viewer has not been started yet. |
screenshot ¶
screenshot(*, panel: str | None = None, size: tuple[int, int] | None = None, scale: float = 1.0, frames: int | Literal['converged'] = 1, save: str | Path | None = None, **capture_kwargs) -> ndarray
Capture one panel, or all four as a 2x2 grid, as RGBA uint8.
Each panel is rendered offscreen, so the result is reproducible and does not need a window.
The capture shows the data currently resident on the GPU -- it does
not reslice. Capture from on_ready when a load may still be
running. A panel with no canvas renders empty, because slice
requests are planned per canvas: give every panel a canvas (the grid
builder does, and so does cellier.convenience.capture) and let the reslice
finish before capturing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
panel
|
str or None
|
Which panel to capture: |
None
|
size
|
tuple[int, int] or None
|
|
None
|
scale
|
float
|
Multiplier applied to size. |
1.0
|
frames
|
int or 'converged'
|
|
1
|
save
|
str, Path, or None
|
When given, also write the frame to this path as a PNG. |
None
|
**capture_kwargs
|
Forwarded to the capture helper. |
{}
|
Returns:
| Type | Description |
|---|---|
ndarray
|
RGBA uint8 array: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If panel is not one of the four panel keys. |
Notes
The grid composite is canvases only. The Qt grid carries XY /
XZ / YZ / 3D labels above the panels; those are chrome and
do not appear here. Use
screenshot_window for a picture with the
labels and docks in it.
on_ready ¶
on_ready(callback: Callable[[], None]) -> SubscriptionHandle
Register a callback fired once all panels' startup data is on the GPU.
The callback runs after the initial reslice triggered by
launch / show
has committed every visual across all four panel scenes. Use it to
hide a loading indicator, capture a screenshot, or enable controls once
the first view is fully loaded.
Fires once, on the first startup. Register it before or after
display/launch/show: before startup has finished it
waits, and after that it runs at once. For one panel, use
on_scene_ready.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
callback
|
Callable[[], None]
|
Zero-argument callback. |
required |
Returns:
| Type | Description |
|---|---|
SubscriptionHandle
|
Active until callback fires; its |
to_file ¶
Serialize the orthoviewer model state to a JSON file.
Captures the four scenes (dims, slice positions), visuals, data stores,
canvases with their camera models, and the render pipeline
configuration. The live dims mirroring is not serialized -- the
panels are saved in agreement -- and from_file re-establishes
it. The cameras are saved with their poses, which from_file
restores; the gui toolkit is not saved.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Destination file path. |
required |
from_file
classmethod
¶
from_file(path: str | Path, *, link_axes: bool = True, link_clipping_planes: ClippingLinkMode = 'all', render_config: RenderManagerConfig | None = None, gui: Literal['qt', 'anywidget', 'offscreen'] = 'qt') -> OrthoViewer
Restore an OrthoViewer from a previously serialized file.
The four panels are rebound by scene name (xy, xz, yz,
vol) and the spatial axes are recovered from the vol panel's
displayed axes -- no extra metadata is stored. Dims mirroring is
re-established when link_axes is True.
The clipping plane links are rebuilt too. The panel visuals of
each dataset are found by name and type (f"{name}_{key}", as
image_group does; datasets of one name and type are paired
in the order they were added) and linked as link_clipping_planes
says. The mode is not in the file. A load does not rewrite what
was saved: a file whose panels differ where the mode would link
them (saved in "2d" with the 3D panel's planes moved, loaded
with "all") is refused.
Each panel camera starts at its saved pose, which launch /
show / display keep with their default fit=None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Path to a JSON file written by |
required |
link_axes
|
bool
|
Re-establish the cross-panel dims mirroring. Default |
True
|
link_clipping_planes
|
('all', '2d')
|
The clipping link mode; see |
"all"
|
render_config
|
RenderManagerConfig or None
|
Override the serialized render pipeline configuration. |
None
|
gui
|
('qt', 'anywidget', 'offscreen')
|
Toolkit to build the canvases with; the file does not record
one. The canvases are built during this call, so |
"qt"
|
Returns:
| Type | Description |
|---|---|
OrthoViewer
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the file does not contain exactly the four expected panels, or the panels of a dataset carry different clipping planes where link_clipping_planes links them. |
center_slices ¶
Move the three spatial slice positions to the middle of the data.
Reads the world-space extent of the loaded visuals and sets every panel's position on each spatial axis to its midpoint -- once, through the dims controller when the panels are linked. Extra-axis positions are left unchanged. Call after adding data.
Raises:
| Type | Description |
|---|---|
ValueError
|
If no visuals with known shapes have been added yet. |
set_slice_positions ¶
Move the slice position of one or more world axes on every panel.
Once, through the dims controller, when the panels are linked. By
default a jump: every visual loads in full at once. With
interactive=True, or inside dims_interaction, it is a
tick of a scrub; see CellierController.update_slice_indices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positions
|
Mapping[int, float]
|
World axis index -> world position. Other axes keep theirs. |
required |
interactive
|
bool
|
Whether the move is a tick of a scrub. |
False
|
dims_interaction ¶
dims_interaction() -> Generator[None, None, None]
Scrub the dims of all four panels for the length of a with block.
Every slice-position move inside the block is a scrub tick on every panel it changes, so a player loads coarse while it runs and in full when the block exits:
with viewer.dims_interaction():
for t in range(n_frames):
viewer.set_slice_positions({0: t})
transform_interaction ¶
Drag one visual's transform in every panel for a with block.
Opens CellierController.transform_interaction on every panel's
copy of the visual, so each panel plans coarse while the transform
changes (when its view's moving setting is on) and in full when the
block exits, and a tilted 2D panel switches onto the brick route with
about a one-frame gap:
with viewer.transform_interaction(visuals):
for angle in angles:
for copy in visuals.values():
copy.transform = rotated(copy, angle)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
visual
|
(UUID, visual or dict[str, visual])
|
Any panel's copy (or its id), or the dict a fanned-out |
required |
get_camera_state ¶
get_camera_state(panel: str) -> CameraState
Return a snapshot of one panel's camera.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
panel
|
('xy', 'xz', 'yz', 'vol')
|
The panel. |
"xy"
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If panel is not a panel key, or the panel has no canvas yet. |
set_camera_state ¶
set_camera_state(panel: str, state: CameraState, *, interactive: bool = False) -> None
Move one panel's camera to state.
The four cameras are independent. By default a jump; with
interactive=True, or inside camera_interaction, a tick of
a motion. See CellierController.set_camera_state.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
panel
|
('xy', 'xz', 'yz', 'vol')
|
The panel. |
"xy"
|
state
|
CameraState
|
The state to apply; |
required |
interactive
|
bool
|
Whether the move is a tick of a motion. |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If panel is not a panel key, the panel has no canvas yet,
state is for the other kind of camera, or its
|
fit_camera ¶
fit_camera(panel: str | None = None, *, interactive: bool = False, only_visible_visuals: bool = False) -> None
Fit a panel's camera, or every panel's, to its scene.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
panel
|
('xy', 'xz', 'yz', 'vol')
|
The panel to fit. |
"xy"
|
interactive
|
bool
|
Whether the move is a tick of a camera motion instead of a jump. |
False
|
only_visible_visuals
|
bool
|
Fit to the visuals that are shown only. The far plane still keeps
every visual in view. Default |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If panel is not a panel key. |
camera_interaction ¶
Move one panel's camera as one motion for a with block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
panel
|
('xy', 'xz', 'yz', 'vol')
|
The panel whose camera moves. |
"xy"
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If panel is not a panel key, or the panel has no canvas yet. |
add_image ¶
add_image(data: ImageMemoryStore | UUID, appearance: InMemoryImageAppearance | None = None, name: str = 'image', controls: list[Control] | None = None, *, single: InMemoryImageSingleAppearance | None = None, channel_axis: int | None = None, composite: bool = False, channels: dict[int, InMemoryImageChannelAppearance] | None = None, max_channels: int = 4, outline: VisualOutline | None = None, ambient_occlusion: bool | None = None, clipping_planes: Sequence[ClippingPlane] = (), render_planes: Sequence[RenderPlane] = (), transform: BaseTransform | None = None, render_config: InMemoryImageRenderConfig | None = None) -> dict[str, ImageVisual]
Add an in-memory image to every panel from a single data store.
Each panel gets its own visual model with its own copy of the
appearances. set_image_composite,
update_image_single_field and
update_image_channel_field set all four panels at once. The
image controls instead drive the 2D panels and the 3D panel
separately, so the two can differ. A composited axis cannot be one
of the spatial axes, since some panel always displays it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
ImageMemoryStore or UUID
|
Backing data store or the UUID of an already-registered store. |
required |
appearance
|
InMemoryImageAppearance or None
|
Shared by both modes. |
None
|
name
|
str
|
Base label; each panel's visual is named |
'image'
|
controls
|
list[Control] or None
|
The controls to show for this visual: a list of control models,
drawn in the order of the list. The image's fields are chosen
with |
None
|
single
|
single appearance or None
|
Single mode's appearance. |
None
|
channel_axis
|
int or None
|
The data axis a composite draws channels along; it must map to a
world axis. |
None
|
composite
|
bool
|
Start in composite mode. Requires channel_axis. |
False
|
channels
|
dict[int, channel appearance] or None
|
Composite mode's per-channel appearances. |
None
|
max_channels
|
int
|
The most channels the visual may hold. Default 4. |
4
|
outline
|
VisualOutline or None
|
Screen-space outline assignment. |
None
|
ambient_occlusion
|
bool or None
|
Whether this visual receives ambient occlusion. |
None
|
clipping_planes
|
Sequence[ClippingPlane]
|
Clipping planes, in the store's level-0 data coordinates: the
visual is drawn only on the kept side of every enabled plane.
Build them from |
()
|
render_planes
|
Sequence[RenderPlane]
|
The planes the |
()
|
transform
|
BaseTransform or None
|
The |
None
|
render_config
|
InMemoryImageRenderConfig or None
|
The GPU configuration of the brick route, which draws a tilted
2D view of the image. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, ImageVisual]
|
The per-panel visuals keyed |
add_labels ¶
add_labels(data: LabelMemoryStore | UUID, appearance: BaseLabelsAppearance | None = None, name: str = 'labels', transform: BaseTransform | None = None, controls: list[Control] | None = None, outline: VisualOutline | None = None, ambient_occlusion: bool | None = None, outline_selected_labels: dict[int, int] | None = None, clipping_planes: Sequence[ClippingPlane] = (), render_planes: Sequence[RenderPlane] = (), render_config: InMemoryLabelRenderConfig | None = None) -> dict[str, LabelMemoryVisual]
Add an in-memory label image to every panel from one data store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
LabelMemoryStore or UUID
|
Backing data store or the UUID of an already-registered store. |
required |
appearance
|
BaseLabelsAppearance or None
|
Appearance parameters.
Defaults to |
None
|
name
|
str
|
Base label; each panel's visual is named |
'labels'
|
transform
|
BaseTransform or None
|
Data-to-world transform. Defaults to identity when |
None
|
controls
|
list[Control] or None
|
The controls to show for this visual: a list of control models,
drawn in the order of the list. The visual's fields are chosen
with |
None
|
outline
|
VisualOutline or None
|
Screen-space outline assignment. |
None
|
ambient_occlusion
|
bool or None
|
Whether this visual receives ambient occlusion. |
None
|
outline_selected_labels
|
dict[int, int] or None
|
Maps a label value to the palette slot the selection layer draws
it in. |
None
|
clipping_planes
|
Sequence[ClippingPlane]
|
Clipping planes, in the store's level-0 data coordinates: the
visual is drawn only on the kept side of every enabled plane.
Build them from |
()
|
render_planes
|
Sequence[RenderPlane]
|
The planes the |
()
|
render_config
|
InMemoryLabelRenderConfig or None
|
The GPU configuration of the brick route, which draws a tilted
2D view of the labels. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, LabelMemoryVisual]
|
|
add_mesh ¶
add_mesh(data: MeshMemoryStore | UUID, appearance: MeshAppearance, name: str = 'mesh', transform: BaseTransform | None = None, controls: list[Control] | None = None, outline: VisualOutline | None = None, ambient_occlusion: bool | None = None, section: MeshSectionConfig | None = None, clipping_planes: Sequence[ClippingPlane] = ()) -> dict[str, MeshVisual]
Add a mesh to every panel from a single data store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
MeshMemoryStore or UUID
|
Backing data store or the UUID of an already-registered store. |
required |
appearance
|
MeshFlatAppearance or MeshPhongAppearance
|
Appearance parameters. When passing a dict, include the
|
required |
name
|
str
|
Base label; each panel's visual is named |
'mesh'
|
transform
|
BaseTransform or None
|
Data-to-world transform. Defaults to identity when |
None
|
controls
|
list[Control] or None
|
The controls to show for this visual: a list of control models,
drawn in the order of the list. The visual's fields are chosen
with |
None
|
outline
|
VisualOutline or None
|
Screen-space outline assignment. |
None
|
ambient_occlusion
|
bool or None
|
Whether this visual receives ambient occlusion. |
None
|
section
|
MeshSectionConfig or None
|
How the mesh is drawn in a 2D view: the outline and fill of its
cross-section, and whether the cut is the slice plane
( |
None
|
clipping_planes
|
Sequence[ClippingPlane]
|
Clipping planes, in the store's level-0 data coordinates: the
visual is drawn only on the kept side of every enabled plane.
Build them from |
()
|
Returns:
| Type | Description |
|---|---|
dict[str, MeshVisual]
|
|
add_multiscale_mesh ¶
add_multiscale_mesh(data: MultiscaleMeshStore | UUID, appearance: MeshAppearance, name: str = 'mesh', transform: BaseTransform | None = None, controls: list[Control] | None = None, outline: VisualOutline | None = None, ambient_occlusion: bool | None = None, section: MeshSectionConfig | None = None, lod: GeometryLodConfig | None = None, clipping_planes: Sequence[ClippingPlane] = ()) -> dict[str, MultiscaleMeshVisual]
Add a mesh with levels of detail to every panel, from one store.
Each panel keeps two levels loaded, the finest and one coarse level. The three 2D panels draw the cross-section of the level; the 3D panel draws the surface. A dims scrub loads the coarse level only until it ends, and the 3D panel draws the coarse level while its camera moves.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
MultiscaleMeshStore or UUID
|
The mesh's levels, finest first, or the UUID of an already-registered store. |
required |
appearance
|
MeshFlatAppearance or MeshPhongAppearance
|
Appearance parameters, shared by both levels. |
required |
name
|
str
|
Base label; each panel's visual is named |
'mesh'
|
transform
|
BaseTransform or None
|
Data-to-world transform. Defaults to identity when |
None
|
controls
|
list[Control] or None
|
The controls to show for this visual: a list of control models,
drawn in the order of the list. The visual's fields are chosen
with |
None
|
outline
|
VisualOutline or None
|
Screen-space outline assignment; see |
None
|
ambient_occlusion
|
bool or None
|
Whether this visual receives ambient occlusion; see
|
None
|
section
|
MeshSectionConfig or None
|
How the mesh is drawn in a 2D view; see |
None
|
lod
|
GeometryLodConfig or None
|
Which coarse level is kept (the coarsest by default), what a
dims scrub loads and draws, and what a moving camera draws. The
same for every panel; change it later with
|
None
|
clipping_planes
|
Sequence[ClippingPlane]
|
Clipping planes, in the store's level-0 data coordinates: the
visual is drawn only on the kept side of every enabled plane.
Build them from |
()
|
Returns:
| Type | Description |
|---|---|
dict[str, MultiscaleMeshVisual]
|
|
add_points ¶
add_points(data: PointsMemoryStore | UUID, appearance: PointsMarkerAppearance | None = None, name: str = 'points', transform: BaseTransform | None = None, controls: list[Control] | None = None, outline: VisualOutline | None = None, ambient_occlusion: bool | None = None, clipping_planes: Sequence[ClippingPlane] = ()) -> dict[str, PointsVisual]
Add a points visual to every panel from a single data store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
PointsMemoryStore or UUID
|
Backing data store or the UUID of an already-registered store. |
required |
appearance
|
PointsMarkerAppearance or None
|
Appearance parameters.
Defaults to |
None
|
name
|
str
|
Base label; each panel's visual is named |
'points'
|
transform
|
BaseTransform or None
|
Data-to-world transform. Defaults to identity when |
None
|
controls
|
list[Control] or None
|
The controls to show for this visual: a list of control models,
drawn in the order of the list. The visual's fields are chosen
with |
None
|
outline
|
VisualOutline or None
|
Screen-space outline assignment. |
None
|
ambient_occlusion
|
bool or None
|
Whether this visual receives ambient occlusion. |
None
|
clipping_planes
|
Sequence[ClippingPlane]
|
Clipping planes, in the store's level-0 data coordinates: the
visual is drawn only on the kept side of every enabled plane.
Build them from |
()
|
Returns:
| Type | Description |
|---|---|
dict[str, PointsVisual]
|
|
add_graph ¶
add_graph(data: GraphMemoryStore | UUID, appearance: GraphAppearance | None = None, name: str = 'graph', transform: BaseTransform | None = None, trail: dict[int, TrailConfig] | None = None, controls: list[Control] | None = None, outline: VisualOutline | None = None, ambient_occlusion: bool | None = None, clipping_planes: Sequence[ClippingPlane] = ()) -> dict[str, GraphVisual]
Add a spatial-graph visual to every panel from a single data store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
GraphMemoryStore or UUID
|
Backing data store or the UUID of an already-registered store. |
required |
appearance
|
GraphAppearance or None
|
Appearance parameters. Defaults
to |
None
|
name
|
str
|
Base label; each panel's visual is named |
'graph'
|
transform
|
BaseTransform or None
|
Data-to-world transform. Falls back to the store's own transform, then to identity. |
None
|
trail
|
dict[int, TrailConfig] or None
|
Axis index -> window configuration, applied to every panel. |
None
|
controls
|
list[Control] or None
|
The controls to show for this visual: a list of control models,
drawn in the order of the list. The visual's fields are chosen
with |
None
|
outline
|
VisualOutline or None
|
Screen-space outline assignment. |
None
|
ambient_occlusion
|
bool or None
|
Whether this visual receives ambient occlusion. |
None
|
clipping_planes
|
Sequence[ClippingPlane]
|
Clipping planes, in the store's level-0 data coordinates: the
visual is drawn only on the kept side of every enabled plane.
Build them from |
()
|
Returns:
| Type | Description |
|---|---|
dict[str, GraphVisual]
|
|
add_lines ¶
add_lines(data: LinesMemoryStore | UUID, appearance: LinesMemoryAppearance | None = None, name: str = 'lines', transform: BaseTransform | None = None, controls: list[Control] | None = None, outline: VisualOutline | None = None, ambient_occlusion: bool | None = None, clipping_planes: Sequence[ClippingPlane] = ()) -> dict[str, LinesVisual]
Add a lines visual to every panel from a single data store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
LinesMemoryStore or UUID
|
Backing data store or the UUID of an already-registered store. |
required |
appearance
|
LinesMemoryAppearance or None
|
Appearance parameters.
Defaults to |
None
|
name
|
str
|
Base label; each panel's visual is named |
'lines'
|
transform
|
BaseTransform or None
|
Data-to-world transform. Defaults to identity when |
None
|
controls
|
list[Control] or None
|
The controls to show for this visual: a list of control models,
drawn in the order of the list. The visual's fields are chosen
with |
None
|
outline
|
VisualOutline or None
|
Screen-space outline assignment. |
None
|
ambient_occlusion
|
bool or None
|
Whether this visual receives ambient occlusion. |
None
|
clipping_planes
|
Sequence[ClippingPlane]
|
Clipping planes, in the store's level-0 data coordinates: the
visual is drawn only on the kept side of every enabled plane.
Build them from |
()
|
Returns:
| Type | Description |
|---|---|
dict[str, LinesVisual]
|
|
add_image_multiscale ¶
add_image_multiscale(data: BaseDataStore | UUID, appearance: MultiscaleImageAppearance | None = None, name: str = 'image', render_config: MultiscaleImageRenderConfig | None = None, transform: BaseTransform | None = None, controls: list[Control] | None = None, *, single: MultiscaleImageSingleAppearance | None = None, channel_axis: int | None = None, composite: bool = False, channels: dict[int, MultiscaleImageChannelAppearance] | None = None, max_channels: int = 4, outline: VisualOutline | None = None, ambient_occlusion: bool | None = None, clipping_planes: Sequence[ClippingPlane] = (), render_planes: Sequence[RenderPlane] = ()) -> dict[str, MultiscaleImageVisual]
Add a multiscale image to every panel from a single data store.
See add_image for the modes and the group methods.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
BaseDataStore or UUID
|
Backing multiscale store or UUID of an already-registered store. |
required |
appearance
|
MultiscaleImageAppearance or None
|
Shared by both modes. |
None
|
name
|
str
|
Base label; each panel's visual is named |
'image'
|
render_config
|
MultiscaleImageRenderConfig or None
|
GPU cache configuration. Uses defaults when |
None
|
transform
|
BaseTransform or None
|
Data-to-world transform. Defaults to identity when |
None
|
controls
|
list[Control] or None
|
The controls to show for this visual: a list of control models,
drawn in the order of the list. The image's fields are chosen
with |
None
|
single
|
single appearance or None
|
Single mode's appearance. |
None
|
channel_axis
|
int or None
|
The data axis a composite draws channels along; it must map to a
world axis. |
None
|
composite
|
bool
|
Start in composite mode. Requires channel_axis. |
False
|
channels
|
dict[int, channel appearance] or None
|
Composite mode's per-channel appearances. |
None
|
max_channels
|
int
|
The most channels the visual may hold. Default 4. |
4
|
outline
|
VisualOutline or None
|
Screen-space outline assignment. |
None
|
ambient_occlusion
|
bool or None
|
Whether this visual receives ambient occlusion. |
None
|
clipping_planes
|
Sequence[ClippingPlane]
|
Clipping planes, in the store's level-0 data coordinates: the
visual is drawn only on the kept side of every enabled plane.
Build them from |
()
|
render_planes
|
Sequence[RenderPlane]
|
The planes the |
()
|
Returns:
| Type | Description |
|---|---|
dict[str, MultiscaleImageVisual]
|
|
add_labels_multiscale ¶
add_labels_multiscale(data: BaseDataStore | UUID, appearance: MultiscaleLabelsAppearance | None = None, name: str = 'labels', render_config: MultiscaleLabelRenderConfig | None = None, transform: BaseTransform | None = None, controls: list[Control] | None = None, outline: VisualOutline | None = None, ambient_occlusion: bool | None = None, outline_selected_labels: dict[int, int] | None = None, clipping_planes: Sequence[ClippingPlane] = (), render_planes: Sequence[RenderPlane] = ()) -> dict[str, MultiscaleLabelVisual]
Add a multiscale label image to every panel from one data store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
BaseDataStore or UUID
|
Backing multiscale label store or UUID of an already-registered store. |
required |
appearance
|
MultiscaleLabelsAppearance or None
|
Appearance parameters. Defaults to |
None
|
name
|
str
|
Base label; each panel's visual is named |
'labels'
|
render_config
|
MultiscaleLabelRenderConfig or None
|
LOD and rendering configuration. Uses defaults when |
None
|
transform
|
BaseTransform or None
|
Data-to-world transform. Defaults to identity when |
None
|
controls
|
list[Control] or None
|
The controls to show for this visual: a list of control models,
drawn in the order of the list. The visual's fields are chosen
with |
None
|
outline
|
VisualOutline or None
|
Screen-space outline assignment. |
None
|
ambient_occlusion
|
bool or None
|
Whether this visual receives ambient occlusion. |
None
|
outline_selected_labels
|
dict[int, int] or None
|
Maps a label value to the palette slot the selection layer draws
it in. |
None
|
clipping_planes
|
Sequence[ClippingPlane]
|
Clipping planes, in the store's level-0 data coordinates: the
visual is drawn only on the kept side of every enabled plane.
Build them from |
()
|
render_planes
|
Sequence[RenderPlane]
|
The planes the |
()
|
Returns:
| Type | Description |
|---|---|
dict[str, MultiscaleLabelVisual]
|
|
image_group ¶
The four panel siblings of an image added with add_image*.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
visual
|
UUID, visual model, or dict
|
Any panel's visual (or its id), or the dict |
required |
Returns:
| Type | Description |
|---|---|
list[UUID]
|
The sibling visual ids, in panel order. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If visual is not a panel image of this viewer. |
loading_progress ¶
loading_progress(visual: object) -> LoadingProgress | None
How far a multiscale visual's four panels have loaded, summed.
Mirrors CellierController.loading_progress over the panel
group: counts are added and the completion flags hold only when they
hold for every panel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
visual
|
UUID, visual model, or dict
|
Any panel's multiscale visual; see |
required |
Returns:
| Type | Description |
|---|---|
LoadingProgress or None
|
|
on_reslice_progress ¶
on_reslice_progress(visual: object, callback: Callable[[ResliceProgressEvent], None], *, owner_id: UUID | None = None, weak: bool = False) -> SubscriptionHandle
Register a callback fired as a multiscale visual's panels load.
Mirrors CellierController.on_reslice_progress over the panel
group. The callback gets each panel's event with progress
replaced by the group sum (loading_progress); visual_id
and scene_id name the panel whose change triggered it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
visual
|
UUID, visual model, or dict
|
Any panel's multiscale visual; see |
required |
callback
|
Callable
|
Called with a |
required |
owner_id
|
UUID or None
|
Owner for |
None
|
weak
|
bool
|
If True, hold only a weak reference to callback. |
False
|
Returns:
| Type | Description |
|---|---|
SubscriptionHandle
|
One handle for the subscriptions on every panel: its
|
on_backstop_complete ¶
on_backstop_complete(visual: object, callback: Callable[[BackstopCompleteEvent], None], *, owner_id: UUID | None = None, weak: bool = False) -> SubscriptionHandle
Register a callback fired when every panel's backstop is in.
Mirrors CellierController.on_backstop_complete over the
panel group: fires on the panel event that completes the group, with
that panel's event.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
visual
|
UUID, visual model, or dict
|
Any panel's multiscale visual; see |
required |
callback
|
Callable
|
Called with a |
required |
owner_id
|
UUID or None
|
Owner for |
None
|
weak
|
bool
|
If True, hold only a weak reference to callback. |
False
|
Returns:
| Type | Description |
|---|---|
SubscriptionHandle
|
One handle for the subscriptions on every panel: its
|
set_loading ¶
set_loading(visual: object, **fields: Any) -> ProgressiveLoadingConfig
Change how every panel of a multiscale visual loads.
Mirrors CellierController.set_loading_config, applied to each
panel. The merged config is validated before any panel changes, so
an invalid combination raises and changes nothing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
visual
|
UUID, visual model, or dict
|
Any panel's multiscale visual; see |
required |
**fields
|
Any
|
|
{}
|
Returns:
| Type | Description |
|---|---|
ProgressiveLoadingConfig
|
The first panel's config after the call. |
set_lod_config ¶
set_lod_config(visual: object, **fields: Any) -> GeometryLodConfig
Change the level-of-detail settings of every panel of a mesh.
Mirrors CellierController.set_lod_config, applied to each
panel. The merged config is validated before any panel changes, so
an invalid value raises and changes nothing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
visual
|
UUID, visual model, or dict
|
Any panel's multiscale mesh, or the dict
|
required |
**fields
|
Any
|
|
{}
|
Returns:
| Type | Description |
|---|---|
GeometryLodConfig
|
The first panel's config after the call. |
add_clipping_plane_gizmo ¶
add_clipping_plane_gizmo(visual: object, plane: ClippingPlane | UUID) -> ClippingPlaneGizmoController
Put a gizmo on one clipping plane of a visual, in the 3D panel.
Dragging the gizmo moves and tilts the plane. The 2D panels follow
when the panels' planes are linked (clipping_controller.mode
"all", the default). Mirrors
CellierController.add_clipping_plane_gizmo: the 3D panel
has one gizmo at a time.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
visual
|
UUID, visual model, or dict
|
Any panel's visual, or the dict an |
required |
plane
|
ClippingPlane or UUID
|
One of the 3D panel's visual's |
required |
Returns:
| Type | Description |
|---|---|
ClippingPlaneGizmoController
|
The session. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the 3D panel's visual has no plane with that id. |
ValueError
|
If the 3D panel has no canvas yet, or the plane has a component on an axis the 3D panel does not show. |
add_render_plane_gizmo ¶
add_render_plane_gizmo(visual: object, plane: RenderPlane | UUID) -> RenderPlaneGizmoController
Put a gizmo on one render plane of a visual, in the 3D panel.
Dragging the gizmo moves, turns and resizes the plane. Mirrors
CellierController.add_render_plane_gizmo: the 3D panel has
one gizmo at a time, clipping planes included.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
visual
|
UUID, visual model, or dict
|
Any panel's visual, or the dict an |
required |
plane
|
RenderPlane or UUID
|
One of the 3D panel's visual's |
required |
Returns:
| Type | Description |
|---|---|
RenderPlaneGizmoController
|
The session. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the 3D panel's visual has no render plane with that id. |
ValueError
|
If |
remove_plane_gizmo ¶
Close the 3D panel's plane gizmo, of either kind; nothing if none.
set_image_composite ¶
Switch every panel's image between single and composite mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
visual
|
UUID, visual model, or dict
|
Any panel's visual; see |
required |
composite
|
bool
|
|
required |
update_image_single_field ¶
Set one single-mode field on every panel's image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
visual
|
UUID, visual model, or dict
|
Any panel's visual; see |
required |
field
|
str
|
Field name on |
required |
value
|
New value. |
required |
update_image_channel_field ¶
Launching and display¶
Use run as the entry point for launching a configured viewer. It picks the host from the viewer's gui= argument, constructs the GUI, and launches the application.
cellier.convenience.run ¶
run(viewer: ViewerLike, layout: Layout, *, fit: FitMode | None = None, on_ready: Callable[[], None] | None = None) -> object
Show a viewer, dispatching to the right host based on viewer.gui.
The portable entry point: replaces separate display / launch
calls so notebook and script code can be identical up to the gui=
argument on Viewer.
gui="anywidget"-- callsdisplay(non-blocking; returns aDisplayHandlefor Jupyter or the renderable for marimo).gui="qt"-- callslaunch(blocking; returnsNoneafter the window is closed).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
viewer
|
Viewer or OrthoViewer
|
The viewer whose |
required |
layout
|
Layout
|
Declarative layout spec. |
required |
fit
|
('ready', 'immediate', 'none' or None)
|
Camera-fit policy applied at startup. |
None
|
on_ready
|
Callable[[], None] or None
|
Optional zero-argument callback fired once every scene's startup data has committed to the GPU. |
None
|
Returns:
| Type | Description |
|---|---|
object
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
cellier.convenience.launch ¶
launch(viewer: ViewerLike, layout_or_window: object, *, fit: FitMode | None = None, on_ready: Callable[[], None] | None = None, handle_sigint: bool = True) -> None
Show layout_or_window and block until it is closed.
Creates a QApplication if one does not already exist, then starts the
Qt + asyncio event loop via PySide6.QtAsyncio. Intended for scripts
and the CLI. For interactive / Jupyter use, call show instead.
The initial camera fit and data load are deferred to the canvas's first
rendered frame (see CellierController.on_canvas_first_frame), so
they run only once the canvas has its final size and the event loop is
live — no timer required.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
viewer
|
Viewer or OrthoViewer
|
The viewer whose controller is used for |
required |
layout_or_window
|
Layout or QMainWindow or QWidget
|
Either a |
required |
fit
|
('ready', 'immediate', 'none' or None)
|
Camera-fit policy applied at startup. |
None
|
on_ready
|
Callable[[], None] or None
|
Optional zero-argument callback fired once, after every scene's startup
data has committed to the GPU. Fires in addition to any callbacks
registered via |
None
|
handle_sigint
|
bool
|
Pass |
True
|
cellier.convenience.show ¶
show(viewer: ViewerLike, layout_or_window: object, *, fit: FitMode | None = None, on_ready: Callable[[], None] | None = None) -> None
Show a viewer window without blocking.
Requires a Qt event loop that is already running (e.g. inside IPython /
Jupyter after %gui qt). The initial camera fit and data load are
deferred to the canvas's first rendered frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
viewer
|
Viewer or OrthoViewer
|
The viewer whose controller is used for |
required |
layout_or_window
|
Layout or QMainWindow or QWidget
|
Either a |
required |
fit
|
('ready', 'immediate', 'none' or None)
|
Camera-fit policy applied at startup. |
None
|
on_ready
|
Callable[[], None] or None
|
Optional zero-argument callback fired once, after every scene's startup data has committed to the GPU. |
None
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no |
cellier.convenience.display ¶
display(viewer: ViewerLike, layout: Layout, *, fit: FitMode | None = None, on_ready: Callable[[], None] | None = None, host: str | None = None, sidecar: bool | SidecarOptions | None = None, stall_timeout: float | None = _DEFAULT_STALL_TIMEOUT) -> object
Compose and present an anywidget viewer non-blockingly.
The notebook counterpart of launch. Resolves the anywidget host
(Jupyter or marimo), renders the layout spec for that host, presents
the result, and arms first-frame startup.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
viewer
|
Viewer or OrthoViewer
|
The viewer whose controller drives fit / reslice. |
required |
layout
|
Layout
|
Declarative layout spec -- center canvas(es) plus optional dock
controls. Build with |
required |
fit
|
('ready', 'immediate', 'none' or None)
|
Camera-fit policy applied at startup. |
None
|
on_ready
|
Callable[[], None] or None
|
Optional zero-argument callback fired once every scene's startup data has committed to the GPU. |
None
|
host
|
"jupyter", "marimo", or None
|
Explicit host override; auto-detected when |
None
|
stall_timeout
|
float or None
|
Seconds before startup is reported stalled through
|
_DEFAULT_STALL_TIMEOUT
|
sidecar
|
True, SidecarOptions, or None
|
Present the viewer in a |
None
|
Returns:
| Type | Description |
|---|---|
object
|
For imperative hosts (Jupyter) an inert |
cellier.convenience.DisplayHandle ¶
Inert teardown handle returned by display.
Rendering is performed imperatively by the host inside present(); this
handle is the cell's return value but has no representation of its own (its
_repr_mimebundle_ is empty), so the viewer is rendered exactly once.
Call close to unsubscribe the control panel(s) from the bus,
cancel any pending slices, and close the sidecar panel (if any) -- e.g.
before re-running a cell so the prior panel and in-flight reads do not
leak.
cellier.convenience.SidecarOptions
dataclass
¶
Config for opening an anywidget viewer in a jupyterlab-sidecar tab.
Passed as the sidecar= argument to
display. Mirrors the constructor of
sidecar.Sidecar.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str or None
|
Tab title. Defaults to |
'Cellier'
|
anchor
|
SidecarAnchor
|
Placement of the sidecar panel. |
'right'
|
ref
|
SidecarOptions, DisplayHandle, or None
|
Anchor the new sidecar relative to another sidecar's panel instead of
the notebook. Pass the |
None
|
cellier.convenience.StartupState ¶
How far a scene (or a whole viewer) has got through startup.
Read it from Viewer.startup_state (the whole viewer) or
Viewer.scene_startup_states (per scene; one per panel of an
OrthoViewer). A scene goes IDLE -> WAITING_FOR_CANVAS ->
WAITING_FOR_FRAME -> LOADING -> READY, or ends in
STALLED when it makes no progress within the stall window: 30 s by
default, set with display(..., stall_timeout=). run, launch
and show always use the default.
Ordered: a viewer's aggregate state is the least-advanced of its scenes, so one stuck panel is never hidden behind three finished ones.
IDLE
class-attribute
instance-attribute
¶
Nothing armed yet -- display/launch has not run.
WAITING_FOR_CANVAS
class-attribute
instance-attribute
¶
Armed, waiting for the front end to report the canvas is live.
The state an anywidget viewer sits in when the browser never mounted its canvas. On Qt it is normally over in a single event-loop turn.
WAITING_FOR_FRAME
class-attribute
instance-attribute
¶
The canvas is live; waiting for it to render its first frame.
Startup defers the camera fit and the initial load to the first frame, because only then does the canvas have its final size.
LOADING
class-attribute
instance-attribute
¶
The first frame arrived; the initial reslice is in flight.
READY
class-attribute
instance-attribute
¶
Data is committed to the GPU and the camera has been fitted.
STALLED
class-attribute
instance-attribute
¶
No progress within the timeout. Records where it stopped.
Not an error -- slow remote data legitimately takes a while -- but the
signal that something is worth looking at. A stalled scene keeps its
StartupTracker.stalled_at state so the report can say what it
was waiting for.
Layout¶
A Layout describes what goes in the centre of the window and in each dock.
cellier.convenience.Layout
dataclass
¶
Full layout specification (the model).
Describes what goes in the center region and each optional dock. Pass to
display (anywidget) or
launch / show
(Qt) to render.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center
|
canvas view or HStack or VStack or Grid
|
Main content. Typically a single |
required |
left_dock
|
object
|
Content for each dock region. Accepts The items of a visual's |
None
|
right_dock
|
object
|
Content for each dock region. Accepts The items of a visual's |
None
|
top_dock
|
object
|
Content for each dock region. Accepts The items of a visual's |
None
|
bottom_dock
|
object
|
Content for each dock region. Accepts The items of a visual's |
None
|
left_dock_min_width
|
int or None
|
The narrowest the left / right dock may be, in logical pixels, on both
toolkits. Must be at least |
None
|
right_dock_min_width
|
int or None
|
The narrowest the left / right dock may be, in logical pixels, on both
toolkits. Must be at least |
None
|
__post_init__ ¶
Reject a dock width that is not an int, is too narrow, or has no dock.
dock_min_widths ¶
The side docks' minimum widths, keyed "left" / "right".
single
classmethod
¶
single(canvas, *, appearance: Literal['left', 'right', 'top', 'bottom'] | bool = False, render: Literal['left', 'right', 'top', 'bottom'] | bool = False) -> Layout
Single-canvas preset.
Controls placed in the same dock stack top to bottom in the order appearance, render.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
canvas
|
Canvas view returned by |
required | |
appearance
|
dock name or False
|
Where to place appearance controls. |
False
|
render
|
dock name or False
|
Where to place the renderer settings panels (outlines, ambient
occlusion, temporal accumulation). |
False
|
cellier.convenience.HStack
dataclass
¶
Items side by side, left to right.
In Layout.center the items are canvas views or nested
HStack/VStack/Grid containers. In a dock the items are
dock specs (AppearanceControls, OverlayControls,
RenderControls, OrthoClippingControls) or nested
stacks; an item that builds nothing is dropped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
items
|
list
|
The items, in order. |
required |
cellier.convenience.VStack
dataclass
¶
Items one above the other, top to bottom.
Takes the same items as HStack: canvas views or containers in
Layout.center, dock specs or stacks in a dock.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
items
|
list
|
The items, in order. |
required |
cellier.convenience.Grid
dataclass
¶
Dock specs¶
cellier.convenience.AppearanceControls
dataclass
¶
Dock spec: appearance controls for the viewer's configured visuals.
The dock follows the viewer as visuals configured through controls=
are added and removed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
presentation
|
'selector' or 'collapsible_sections'
|
How the dock presents several visuals. |
'selector'
|
__post_init__ ¶
Reject an unknown presentation here rather than at render time.
cellier.convenience.OverlayControls
dataclass
¶
Dock spec: appearance controls for the viewer's overlays.
One target per overlay -- scene overlays and canvas overlays alike, in
the order Viewer.overlays lists them -- each titled with the
overlay's name. The dock follows the viewer as overlays are added and
removed through add_scene_overlay / add_canvas_overlay /
remove_overlay.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
presentation
|
'selector' or 'collapsible_sections'
|
How the dock presents several overlays; see
|
'collapsible_sections'
|
__post_init__ ¶
Reject an unknown presentation here rather than at render time.
cellier.convenience.RenderControls
dataclass
¶
Dock spec: one panel per renderer post-processing feature.
Renders the Qt (cellier.gui.qt.render) or anywidget
(cellier.gui.anywidget.render) panel for each named section, wired
to the viewer's controller. Unlike AppearanceControls this
needs no configured visual: render settings belong to the renderer, so
the dock is available on any viewer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sections
|
tuple[str, ...]
|
Which panels to show, in order. Any of |
('ambient_occlusion', 'outline', 'temporal')
|
cellier.convenience.OrthoClippingControls
dataclass
¶
Dock spec: the clipping planes controls of an OrthoViewer.
At the top, a selector of how the panels' clipping planes are linked
("All views", "2D views", "Not linked"), bound both ways to
ortho.clipping_controller.mode. Under it, for every visual whose
controls= list holds ClippingPlanesControl(), one clipping planes
control per group of linked panels, titled with the visual's name:
============== ================================= ================== Mode Controls per visual Gizmo toggle ============== ================================= ================== "All views" "All views" Yes "2D views" "2D views", "3D view" Only "3D view" "Not linked" "XY", "XZ", "YZ", "3D view" Only "3D view" ============== ================================= ==================
The dock follows the viewer as visuals are added and removed. A visual that has lost some of its panels keeps controls for the panels that are left. With no such visual it shows the selector and a placeholder.
Only for an OrthoViewer; on a Viewer the clipping planes control
is part of AppearanceControls. On an OrthoViewer this is
the only place the clipping planes controls are shown, so a visual
added with ClippingPlanesControl() needs this node in the layout.
Canvas builders¶
For an application that lays out its own window instead of using Layout:
each builder makes a viewer's canvas with its dims sliders, wired to the
viewer, on the viewer's toolkit.
cellier.convenience.gui.build_canvas_widget ¶
build_canvas_widget(viewer: Viewer, axis_values: Mapping[int, AxisValues], *, gui: GuiName | None = None, render_modes: set[str] | None = None, initial_dim: str | None = None, fov: float = 70.0, depth_range_3d: tuple[float, float] = (1.0, 8000.0), depth_range_2d: tuple[float, float] = (-500.0, 500.0), canvas_size: tuple[int, int] | None = None, fit_view_direction_3d: Mapping[AxisRef, float] | None = None, fit_up_3d: Mapping[AxisRef, float] | None = None) -> QtCanvasWidget | AnywidgetCanvasView
Build a canvas widget with wired dims sliders for the viewer.
Reuses the viewer's scene's canvas if it has one -- one restored by
from_file, or added with add_canvas -- with its camera state, and
otherwise creates one. Either way the dims sliders are connected to the
controller event bus. For gui="qt" this returns a
QtCanvasWidget (canvas above a dims slider panel); for
gui="anywidget" it returns an AnywidgetCanvasView holding the
canvas and control-panel leaves plus a compose(host) method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
viewer
|
Viewer
|
The viewer to attach the canvas to. |
required |
axis_values
|
Mapping[int, AxisValues]
|
Axis index to the values that axis's slider can take: a
|
required |
gui
|
"qt", "anywidget", or None
|
GUI toolkit. Defaults to |
None
|
render_modes
|
set[str] or None
|
Which camera modes to prepare on a new canvas. Defaults to the
scene's own |
None
|
initial_dim
|
str or None
|
Which mode is active first on a new canvas. Inferred from the
scene's current |
None
|
fov
|
float
|
Vertical field-of-view in degrees for the 3D perspective camera.
Default |
70.0
|
depth_range_3d
|
tuple[float, float]
|
|
(1.0, 8000.0)
|
depth_range_2d
|
tuple[float, float]
|
|
(-500.0, 500.0)
|
canvas_size
|
tuple[int, int] or None
|
Initial CSS pixel size for the anywidget canvas. Ignored for the Qt
gui. Defaults to |
None
|
fit_view_direction_3d
|
Mapping[AxisRef, float] or None
|
The view direction and up vector the 3D camera is fitted with, each
as the component along named world axes, e.g. |
None
|
fit_up_3d
|
Mapping[AxisRef, float] or None
|
The view direction and up vector the 3D camera is fitted with, each
as the component along named world axes, e.g. |
None
|
Returns:
| Type | Description |
|---|---|
QtCanvasWidget or AnywidgetCanvasView
|
For |
Raises:
| Type | Description |
|---|---|
ValueError
|
If gui conflicts with |
cellier.convenience.gui.AnywidgetCanvasView
dataclass
¶
An anywidget canvas leaf plus its dims panel leaf.
Returned by build_canvas_widget for gui="anywidget". Composes
to a single column: canvas above the dims sliders.
Appearance controls are not part of this view; put them beside the
canvas with Layout(left_dock=AppearanceControls()).
Attributes:
| Name | Type | Description |
|---|---|---|
canvas |
object
|
The |
dims |
AnywidgetDimsPanel
|
Axis slice sliders plus the 2D/3D toggle button, below the canvas. |
canvas_size |
tuple[int, int]
|
The CSS pixel size the canvas was constructed with. Reused by
|
dims_control
property
¶
dims_control: AnywidgetDimsPanel
The bus-facing dims widget, under the name every leaf uses.
QtCanvasWidget spells it dims_control; this spells it dims.
One name lets the shared canvas builder wire either without asking
which toolkit it is holding.
cellier.convenience.gui.build_ortho_grid_widget ¶
build_ortho_grid_widget(ortho: OrthoViewer, axis_values: Mapping[int, AxisValues], *, gui: GuiName | None = None, fov: float = 70.0, depth_range_3d: tuple[float, float] = (1.0, 8000.0), depth_range_2d: tuple[float, float] = (-500.0, 500.0), canvas_size: tuple[int, int] | None = None, fit_view_direction_3d: Mapping[AxisRef, float] | None = None, fit_up_3d: Mapping[AxisRef, float] | None = None) -> OrthoCanvasGrid
Build the 2x2 canvas grid for an OrthoViewer.
Creates (or reuses) a canvas per panel with wired dims sliders, and returns
a leaf whose compose(host) lays them out as a labelled grid -- XY
and XZ on the top row, YZ and the 3D volume on the bottom.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ortho
|
OrthoViewer
|
The orthoviewer whose four scenes are attached. |
required |
axis_values
|
Mapping[int, AxisValues]
|
Axis index to the values that axis's slider can take, typically
from |
required |
gui
|
"qt", "anywidget", or None
|
Defaults to |
None
|
fov
|
float
|
Vertical field of view in degrees for the 3D camera. |
70.0
|
depth_range_3d
|
tuple[float, float]
|
|
(1.0, 8000.0)
|
depth_range_2d
|
tuple[float, float]
|
|
(1.0, 8000.0)
|
canvas_size
|
tuple[int, int] or None
|
Initial CSS pixel size per panel. Meaningful to anywidget only. |
None
|
fit_view_direction_3d
|
Mapping[AxisRef, float] or None
|
The view direction and up vector the 3D panel's camera is fitted with, each
as the component along named world axes, e.g. |
None
|
fit_up_3d
|
Mapping[AxisRef, float] or None
|
The view direction and up vector the 3D panel's camera is fitted with, each
as the component along named world axes, e.g. |
None
|
Returns:
| Type | Description |
|---|---|
OrthoCanvasGrid
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If gui conflicts with |
cellier.convenience.gui.OrthoCanvasGrid ¶
The four ortho panel canvas leaves, arranged 2x2 on any toolkit.
compose(host) builds the grid through the host, so the arrangement --
which panel sits where, and what each is called -- is written once and
both front ends draw it the same way.
Attributes:
| Name | Type | Description |
|---|---|---|
canvases |
dict[str, object]
|
Per-panel canvas leaves keyed |
widget
property
¶
The composed Qt grid, for embedding in a hand-built Qt layout.
Qt only, and a convenience: the layout system reaches the grid through
compose like any other center leaf.
Controls¶
The Controls are models to declare GUI widgets for updating model properties.
viewer.add_image_multiscale(
store,
controls=[
ImageControl(fields=["visible", "color_map", "clim"], decimals=0),
LevelOfDetailControl(),
BoundingBoxControl(),
ClippingPlanesControl(),
],
)
cellier.convenience.Control
dataclass
¶
Base class of the control models.
Every item of a controls= list is an instance of one of its
subclasses, and each subclass names one control of the appearance dock.
The base class has no fields and is not listed itself; which subclasses
a visual accepts depends on its kind, and add_* raises on a model
the visual has no control for.
Appearance fields¶
cellier.convenience.ImageControl
dataclass
¶
Bases: Control
The image control: every image field in one widget.
A shared section, a composite switch when the visual has a channel axis, and a page per mode. The blending and interpolation rows and the switch are always there.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fields
|
list[str]
|
The rows to show, e.g. |
required |
colormap_names
|
list[str] or None
|
Names available in the colormap dropdowns. A curated list when
|
None
|
clim_range
|
tuple[float, float] or None
|
|
None
|
channel_labels
|
dict[int, str] or None
|
Per-channel names on the composite page. |
None
|
decimals
|
int
|
Decimal places shown for values in data units: the contrast limits and the iso threshold. Default 2. Set it to suit the data, e.g. 0 for integer images; fractions such as opacity always show 2. |
2
|
threshold_range
|
tuple[float, float] or None
|
|
None
|
thickness_range
|
tuple[float, float] or None
|
|
None
|
cellier.convenience.FieldControls
dataclass
¶
Bases: Control
One control per appearance field, for every visual but an image.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fields
|
list[str]
|
The fields to show, one control each, drawn in the order of this
list. Required and not empty. The names a visual accepts depend
on its kind (see |
required |
Notes
On labels, render_mode is the labels render mode
(iso_categorical / flat_categorical), not the image one.
Planes¶
cellier.convenience.ClippingPlanesControl
dataclass
¶
Bases: Control
The visual's clipping planes control.
A row per plane (on or off, the normal, a position slider along it) and a button to add one. Values are in the visual's data coordinates.
On a Viewer it is drawn in the appearance dock, at its place in the
list. On an OrthoViewer it is drawn in the
OrthoClippingControls() dock, one control per group of linked
panels, and its place in the list is ignored.
cellier.convenience.RenderPlanesControl
dataclass
¶
Bases: Control
The control of the planes of the "plane" render mode.
A row per plane (on or off, the normal, a position slider, the extents) and a button to add one. Values are in world units. It is disabled, with the reason shown, while the visual is not in plane mode or the view is 2D.
On an OrthoViewer it is drawn for the 3D view's group only: the 2D
views draw no render planes.
Drawing and picking¶
cellier.convenience.BoundingBoxControl
dataclass
¶
Bases: Control
The bounding box control.
A checkbox, a line-width slider and a colour picker for the visual's
aabb (AABBParams): the box drawn round the
visual's data. Every kind of visual has one. It has no options.
cellier.convenience.OutlineControl
dataclass
¶
Bases: Control
The visual's outline control.
The palette slot it is outlined in and the placement; for a labels
visual, the per-label selection. The outline reads the pick buffer:
choosing a slot turns pick_write on with a warning. List
PickingControl to show that flag.
cellier.convenience.AmbientOcclusionControl
dataclass
¶
Bases: Control
The visual's ambient-occlusion checkbox.
Ambient occlusion reads the pick buffer. List PickingControl
to show that flag.
cellier.convenience.PickingControl
dataclass
¶
Bases: Control
The pick_write checkbox: whether the visual is in the pick buffer.
A visual out of the pick buffer cannot be picked in the canvas, and
cannot be outlined or ambient-occluded, since both passes read that
buffer. List it beside OutlineControl or
AmbientOcclusionControl to show the flag those controls turn
on. For every kind of visual. It has no options.
Level of detail and loading¶
cellier.convenience.LevelOfDetailControl
dataclass
¶
Bases: Control
The level-of-detail control of an image or labels visual.
A slider for the appearance's settled_lod_bias (higher is coarser)
and checkboxes for coarsest_while_moving_3d and
coarsest_while_moving_2d (draw only the coarsest level while the
visual moves). For an in-memory or multiscale image, a MaskedImage,
and in-memory or multiscale labels. It has no options.
cellier.convenience.LoadingIndicator
dataclass
¶
Bases: Control
How far the visual's data has loaded: a bar and a status line.
For an image or labels visual, whose data loads progressively, brick by brick, and for a mesh, which is not drawn while a new position loads (its status is worded in levels). It has no options.
cellier.convenience.LoadingConfigControl
dataclass
¶
Bases: Control
A control for every ProgressiveLoadingConfig field.
Advanced settings of how an image or labels visual loads its data
progressively: the visual's render_config.loading
(ProgressiveLoadingConfig). For an in-memory
or multiscale image, a MaskedImage, and in-memory or multiscale labels.
It has no options.
Meshes and graphs¶
cellier.convenience.MeshSectionControl
dataclass
¶
Bases: Control
The "2D section" group of a mesh.
How the mesh is drawn in a 2D view: outline, fill, outline width, and
whether the cut is the slice plane or the scene's slab (see
MeshSectionConfig).
cellier.convenience.MeshLodControl
dataclass
¶
Bases: Control
The "LOD" group of a multiscale mesh.
What a dims scrub loads and draws, and what a moving camera draws (see
GeometryLodConfig). A multiscale mesh with
one level has no such settings and gets no group.
cellier.convenience.TrailControl
dataclass
¶
Bases: Control
The trail-window controls of a graph.
On or off, the extent before and after the slice position, and fade, for one or more of the graph's data axes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axes
|
list[int | str] or None
|
|
None
|
__post_init__ ¶
Check the shape of axes.
Only the shape: whether an axis exists depends on the graph's store, which is checked when the dock is built.
Dataset info¶
cellier.convenience.DatasetInfoControl
dataclass
¶
Bases: Control
The read-only dataset-info block.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
info
|
None or DatasetInfo or Sequence[tuple[str, str]]
|
Values are displayed, never interpreted as markup. |
None
|
Axis values¶
Utility functions to derive the values each dims slider can take from data a viewer holds. They return ContinuousAxisValues and DiscreteAxisValues, keyed by world axis index.
cellier.convenience.axis_values_from_viewer ¶
axis_values_from_viewer(viewer: Viewer, *, draw_ticks: Iterable[str] = (), step_size: Mapping[str, float] | None = None) -> dict[int, ContinuousAxisValues | DiscreteAxisValues]
Compute every world axis's slider values from the viewer's visuals.
Transforms each visual's data extent into world space and takes the union
per world axis, so the slider covers every visual. Extents run to the
voxel edges: a gridded axis of n voxels spans [-0.5, n - 0.5].
A non-space axis gets a DiscreteAxisValues when every visual reaching
it maps a discretely sampled data axis onto it -- an OME-Zarr channel or
time axis, or a tracking graph's frame column. Its values are the union
of those samples' world positions, labelled with the channel names when
every store that names its channels agrees on them. One continuous
contributor, or more than 10,000 samples, keeps the axis continuous.
Space axes are always continuous.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
viewer
|
Viewer
|
The viewer to inspect. Must have at least one visual whose store holds data. |
required |
draw_ticks
|
Iterable[str]
|
Names of world axes whose sliders mark each value with a tick, e.g.
|
()
|
step_size
|
Mapping[str, float] or None
|
World axis name to the world distance one arrow key or wheel notch
moves that axis's slider, e.g. |
None
|
Returns:
| Type | Description |
|---|---|
dict[int, ContinuousAxisValues | DiscreteAxisValues]
|
Mapping of axis index to that axis's slider values. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no visual holds any data, if draw_ticks or step_size names an
axis the world does not have, if a draw_ticks axis comes out
continuous, if a step_size axis comes out discrete, or if a step
is not finite and |
TypeError
|
If draw_ticks is a single string or holds something other than axis names, or if step_size is not a mapping of axis names to numbers. |
cellier.convenience.axis_values_from_ortho ¶
axis_values_from_ortho(ortho: OrthoViewer, *, draw_ticks: Iterable[str] = (), step_size: Mapping[str, float] | None = None) -> dict[int, ContinuousAxisValues | DiscreteAxisValues]
Compute every world axis's slider values for an OrthoViewer.
The four panels share their data stores, so the values are identical across panels. The first panel that has visuals with data is used.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ortho
|
OrthoViewer
|
The orthoviewer to inspect. Must have at least one visual whose store holds data on some panel. |
required |
draw_ticks
|
Iterable[str]
|
Names of world axes whose sliders mark each value with a tick. See
|
()
|
step_size
|
Mapping[str, float] or None
|
World axis name to that axis's slider step, in world units. See
|
None
|
Returns:
| Type | Description |
|---|---|
dict[int, ContinuousAxisValues | DiscreteAxisValues]
|
Mapping of axis index to that axis's slider values. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no panel has a visual with data, or for a bad draw_ticks or
step_size entry as in |
TypeError
|
If draw_ticks is a single string or holds something other than axis names, or if step_size is not a mapping of axis names to numbers. |
Window capture¶
To render a viewer to a PNG without a window, see Capture screenshots.
cellier.convenience.screenshot_window ¶
screenshot_window(window: object, controller: CellierController, *, frames: int | Literal['converged'] = 1, save: str | Path | None = None, **capture_kwargs) -> ndarray
Capture a Qt window, canvases included, as an RGBA uint8 array.
Works headless (QT_QPA_PLATFORM=offscreen), which is the setting it
exists for: on a real display the OS screenshot tool already does this.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
window
|
QWidget
|
The top-level window to capture, e.g. a |
required |
controller
|
CellierController
|
The controller owning the canvases inside window. Every canvas whose widget belongs to this window and is visible is composited in. |
required |
frames
|
int or 'converged'
|
Passed to each canvas capture; see
|
1
|
save
|
str, Path, or None
|
When given, also write the composite to this path as a PNG. |
None
|
**capture_kwargs
|
Forwarded to each canvas capture. |
{}
|
Returns:
| Type | Description |
|---|---|
ndarray
|
RGBA uint8 array of shape |
Notes
Only the canvas regions are reproducible. Chrome depends on the platform's widget style and font rendering, so this is a picture of a window rather than a value to assert on byte-for-byte.