Skip to main content

ViewOperations

Operations

Provides operations for controlling the application views, scene orientation, camera, layout, rendering representation, and visualization settings. This class exposes the functionality available through the View ribbon tab, including layout presets, scene orientations, 3D/2D view controls, surface representation modes, shading options, and object widget visibility.

Import

import ScriptingApi as api

# Access via Application
app = api.Application()
ops = app.get_view_operations()

Methods

Properties

set_layout

Sets the workspace layout to a predefined arrangement of 3D and 2D slice views.

Signature:

set_layout(preset: LayoutPreset) -> None

Parameters:

ParameterTypeDescription
presetanyThe layout preset to apply. Use api.LayoutPreset values (e.g., api.LayoutPreset.Conventional, api.LayoutPreset.ThreeDOnly, api.LayoutPreset.FourUpRight).

get_layout

Returns the current workspace layout preset.

Signature:

get_layout() -> LayoutPreset

Returns: LayoutPreset — The active layout preset value as api.LayoutPreset.


set_scene_orientation

Sets the scene orientation type, which determines the axis labels and view directions for both 3D and 2D slice views. Standard and Classic orientations use engineering conventions (X, Y, Z). Medical orientations use anatomical conventions (Sagittal, Coronal, Axial).

Signature:

set_scene_orientation(orientation: SceneOrientation) -> None

Parameters:

ParameterTypeDescription
orientationanyThe scene orientation to apply. Use api.SceneOrientation values (e.g., api.SceneOrientation.Standard, api.SceneOrientation.Medical1).

get_scene_orientation

Returns the current scene orientation type.

Signature:

get_scene_orientation() -> SceneOrientation

Returns: SceneOrientation — The active scene orientation value as api.SceneOrientation.


set_crosshair_enabled

Enables or disables the crosshair in both the slice and 3D views. When enabled, the crosshair indicates the intersection of the three orthogonal slice planes in all views.

Signature:

set_crosshair_enabled(enabled: bool) -> None

Parameters:

ParameterTypeDescription
enabledanyIf true, enables the crosshair; if false, disables it.

is_crosshair_enabled

Returns whether the crosshair is currently enabled.

Signature:

is_crosshair_enabled() -> bool

Returns: bool — True if the crosshair is enabled; false otherwise.


set_voxel_information_enabled

Enables or disables voxel information display in the slice views. When enabled, the voxel coordinates and gray value are displayed in the status bar as the mouse moves over the slice views.

Signature:

set_voxel_information_enabled(enabled: bool) -> None

Parameters:

ParameterTypeDescription
enabledanyIf true, enables voxel information display; if false, disables it.

is_voxel_information_enabled

Returns whether voxel information display is currently enabled.

Signature:

is_voxel_information_enabled() -> bool

Returns: bool — True if voxel information is enabled; false otherwise.


set_slice_views_linked

Enables or disables camera synchronization (linking) of the slice views. When enabled, panning and zooming in one slice view is synchronized across all slice views.

Signature:

set_slice_views_linked(enabled: bool) -> None

Parameters:

ParameterTypeDescription
enabledanyIf true, links the slice views; if false, unlinks them.

is_slice_views_linked

Returns whether the slice views are currently linked (camera synchronized).

Signature:

is_slice_views_linked() -> bool

Returns: bool — True if slice views are linked; false otherwise.


set_window_level

Sets the window and level values for the active volume in the slice views. Window defines the range of gray values displayed, and level defines the center of that range. Together they control the brightness and contrast of the 2D slice views. The window value must be non-negative. A window of 0 means all voxels at the level value will be displayed at maximum brightness.

Signature:

set_window_level(window: float, level: float) -> None

Parameters:

ParameterTypeDescription
windowanyThe window (contrast) value. Must be >= 0.
levelanyThe level (brightness center) value.

get_window_level

Returns the current window and level values of the active volume. The returned array contains two elements: [window, level]. Window is the range of displayed gray values and level is the center of that range.

Signature:

get_window_level() -> list

Returns: list — A std::array with [window, level] values.


get_mask_3d_preview_quality

Returns the current quality level used for mask 3D previews.

Signature:

get_mask_3d_preview_quality() -> Mask3dPreviewQuality

Returns: Mask3dPreviewQuality — The current mask preview quality value as api.Mask3dPreviewQuality.


set_surface_representation

Sets the surface representation mode for all surface, volume mesh, and mask objects. Changes how the 3D mesh geometry is rendered in the 3D view for all objects.

Signature:

set_surface_representation(representation: SurfaceRepresentation) -> None

Parameters:

ParameterTypeDescription
representationanyThe representation mode to apply. Use api.SurfaceRepresentation values (e.g., api.SurfaceRepresentation.Solid, api.SurfaceRepresentation.Wireframe).

set_surface_shading

Sets the surface shading (interpolation) method for all surface, volume mesh, and mask objects. Controls the shading algorithm used to render surfaces in the 3D view.

Signature:

set_surface_shading(interpolation: SurfaceInterpolation) -> None

Parameters:

ParameterTypeDescription
interpolationanyThe interpolation method to apply. Use api.SurfaceInterpolation values (e.g., api.SurfaceInterpolation.Flat, api.SurfaceInterpolation.Phong).

set_standard_view

Sets the 3D view camera to a predefined standard view direction.

Signature:

set_standard_view(view: StandardView) -> None

Parameters:

ParameterTypeDescription
viewanyThe standard view direction. Use api.StandardView values (e.g., api.StandardView.XPlus, api.StandardView.ZMinus, api.StandardView.Isometric).

reset_3d_view

Resets the 3D view camera to fit all visible objects in the scene. Adjusts the camera position, focal point, and zoom so that all visible objects fit within the view.

Signature:

reset_3d_view() -> None

reset_slice_views

Resets the 2D slice view cameras to fit the image data. Restores all slice views to their default zoom and pan positions, and resets the slice positions to the middle of the volume.

Signature:

reset_slice_views() -> None

General

toggle_3d_contours

Toggles the visibility of 3D contours in the 2D slice views for the specified object type. When enabled, the intersection of 3D objects with the current slice plane is rendered as contour lines in the 2D views.

Signature:

toggle_3d_contours(objectType: ContourObjectType) -> None

Parameters:

ParameterTypeDescription
objectTypeanyThe type of object whose contours to toggle. Use api.ContourObjectType.Surface, api.ContourObjectType.VolumeMesh, or api.ContourObjectType.MaskPreview.

remove_all_mask_previews

Removes all 3D mask previews from the 3D view. After removal, the 3D preview of visible masks will need to be regenerated.

Signature:

remove_all_mask_previews() -> None

toggle_outline

Toggles the bounding box outline visibility for visible objects of the specified type. If any visible object of the specified type currently has its bounding box shown, the bounding box is hidden for all objects. Otherwise, it is shown for all visible objects.

Signature:

toggle_outline(objectType: WidgetObjectType) -> None

Parameters:

ParameterTypeDescription
objectTypeanyThe type of objects to toggle the outline for. Use api.WidgetObjectType.Volume, api.WidgetObjectType.Surface, or api.WidgetObjectType.VolumeMesh.

toggle_corner_outline

Toggles the corner bounding box outline visibility for visible objects of the specified type. If any visible object of the specified type currently has its corner outline shown, the corner outline is hidden for all objects. Otherwise, it is shown for all visible objects.

Signature:

toggle_corner_outline(objectType: WidgetObjectType) -> None

Parameters:

ParameterTypeDescription
objectTypeanyThe type of objects to toggle the corner outline for. Use api.WidgetObjectType.Volume, api.WidgetObjectType.Surface, or api.WidgetObjectType.VolumeMesh.

toggle_slice_planes

Toggles the visibility of the 3D slice planes in the 3D view. Slice planes show the current slice positions from the 2D views overlaid in the 3D view.

Signature:

toggle_slice_planes() -> None

toggle_axes_planes

Toggles the visibility of the axes planes in the 3D view. Axes planes show the three orthogonal planes at the origin of the volume coordinate system.

Signature:

toggle_axes_planes() -> None

toggle_volume_shading

Toggles volume shading in the 3D view. When shading is enabled, the volume rendering uses lighting to enhance depth perception of the rendered volume data.

Signature:

toggle_volume_shading() -> None

toggle_point_colors

Toggles the visibility of scalar colors on all surface, volume mesh, and mask objects. When enabled, objects are rendered using their vertex color data (if available). When disabled, objects are rendered with their assigned solid color.

Signature:

toggle_point_colors() -> None

center_3d_view

Centers the 3D view on the scene by resetting the focal point. Moves the camera focal point to the center of the visible scene without changing the zoom level.

Signature:

center_3d_view() -> None

Creation

generate_mask_3d_preview

Generates 3D preview of the visible masks in the 3D view. The 3D preview creates a surface mesh representation of the mask data for visualization in the 3D view.

Signature:

generate_mask_3d_preview() -> None

generate_mask_3d_preview_with_quality

Generates 3D preview of the visible masks with the specified quality level, then regenerates the preview. Lower quality settings use downsampled mask data, which renders faster but may exhibit reduced geometric accuracy.

Signature:

generate_mask_3d_preview_with_quality(quality: Mask3dPreviewQuality) -> None

Parameters:

ParameterTypeDescription
qualityanyThe quality level for the mask preview. Use api.Mask3dPreviewQuality values (e.g., api.Mask3dPreviewQuality.Low, api.Mask3dPreviewQuality.Medium, api.Mask3dPreviewQuality.High).

See Also