Skip to main content

View Operations

Application Basics 📥 Download Script

View Operations Tutorial.

This tutorial demonstrates how to control the Volvicon view tab operations through the scripting API, including workspace layouts, scene orientations, slice view settings, 3D view rendering options, surface representation and shading, and camera controls.

Prerequisites
  • Volvicon application must be running
  • A valid license must be active
  • For some operations, a loaded volume or surface is required

Layout Presets​

# Set the workspace layout to a predefined arrangement of 3D and 2D slice views.
# Available presets:
# api.LayoutPreset.Conventional - 3D view with three orthogonal slices
# api.LayoutPreset.ThreeDOnly - 3D view only
# api.LayoutPreset.FourUpRight - Four views with 3D at upper right
# api.LayoutPreset.FourDownRight - Four views with 3D at lower right
# api.LayoutPreset.FourUpLeft - Four views with 3D at upper left
# api.LayoutPreset.FourDownLeft - Four views with 3D at lower left
# api.LayoutPreset.SliceViewsRight - Three slice views on the right, 3D on left
# api.LayoutPreset.SliceViewsLeft - Three slice views on the left, 3D on right
# api.LayoutPreset.Plane1Only - Plane 1 (YZ) slice view only
# api.LayoutPreset.Plane2Only - Plane 2 (XZ) slice view only
# api.LayoutPreset.Plane3Only - Plane 3 (XY) slice view only
# api.LayoutPreset.HorizontalSliceViewsOnly - Three slices arranged horizontally
# api.LayoutPreset.VerticalSliceViewsOnly - Three slices arranged vertically
# api.LayoutPreset.Plane3LeftPlane1Right - Two panels: Plane 3 (XY) left, Plane 1 (YZ) right
# api.LayoutPreset.Plane3LeftPlane2Right - Two panels: Plane 3 (XY) left, Plane 2 (XZ) right
# api.LayoutPreset.Plane1Left3DRight - Two panels: Plane 1 (YZ) left, 3D right
# api.LayoutPreset.Plane1Right3DLeft - Two panels: 3D left, Plane 1 (YZ) right
# api.LayoutPreset.Plane2Left3DRight - Two panels: Plane 2 (XZ) left, 3D right
# api.LayoutPreset.Plane2Right3DLeft - Two panels: 3D left, Plane 2 (XZ) right
# api.LayoutPreset.Plane3Left3DRight - Two panels: Plane 3 (XY) left, 3D right
# api.LayoutPreset.Plane3Right3DLeft - Two panels: 3D left, Plane 3 (XY) right

# Set the conventional (default) layout
view_operations.set_layout(api.LayoutPreset.Conventional)

# Get the current layout preset
current_layout = view_operations.get_layout()
print(f"Current layout: {current_layout}")

# Set the 3D-only layout
# view_operations.set_layout(api.LayoutPreset.ThreeDOnly)

# Set a two-panel layout with Plane 3 (XY) on the left and 3D on the right
# view_operations.set_layout(api.LayoutPreset.Plane3Left3DRight)

Scene Orientation​

# Set the scene orientation type, which determines the axis labels and view
# directions for both 3D and 2D slice views.
#
# Available orientations:
# api.SceneOrientation.Standard - Standard engineering (X, Y, Z)
# api.SceneOrientation.Classic - Classic engineering orientation
# api.SceneOrientation.Medical1 - Radiologist convention (most common in clinical radiology)
# api.SceneOrientation.Medical2 - Neurologist convention
# api.SceneOrientation.Orientation1 - Custom orientation preset 1
# api.SceneOrientation.Orientation2 - Custom orientation preset 2
# api.SceneOrientation.Orientation3 - Custom orientation preset 3
# api.SceneOrientation.Orientation4 - Custom orientation preset 4

# Set standard engineering orientation
view_operations.set_scene_orientation(api.SceneOrientation.Standard)

# Get the current scene orientation
current_orientation = view_operations.get_scene_orientation()
print(f"Current orientation: {current_orientation}")

# Set radiologist (medical) orientation
# view_operations.set_scene_orientation(api.SceneOrientation.Medical1)

Slice Views - 3D Contours​

# Toggle the visibility of 3D contours in the 2D slice views.
# When enabled, the intersection of 3D objects with the current slice plane
# is rendered as contour lines in the 2D views.
#
# Available contour object types:
# api.ContourObjectType.Surface - Surface object contours
# api.ContourObjectType.VolumeMesh - Volume mesh object contours
# api.ContourObjectType.MaskPreview - Mask 3D preview contours

# Show (or hide) surface contours in slice views
# view_operations.set_3d_contours_enabled(api.ContourObjectType.Surface, True)

# Show (or hide) volume mesh contours in slice views
# view_operations.set_3d_contours_enabled(api.ContourObjectType.VolumeMesh, True)

# Show (or hide) mask preview contours in slice views
# view_operations.set_3d_contours_enabled(api.ContourObjectType.MaskPreview, True)

Slice Views - Crosshair, Voxel Info, and Linked Views​

# The crosshair shows the intersection of the three orthogonal slice planes.

# Check crosshair state
# is_crosshair_on = view_operations.is_crosshair_enabled()
# print(f"Crosshair enabled: {is_crosshair_on}")

# Enable the crosshair
# view_operations.set_crosshair_enabled(True)

# Disable the crosshair
# view_operations.set_crosshair_enabled(False)

# Check the current voxel information display mode.
# Available modes:
# api.VoxelInformationDisplayMode.Off - show no voxel information
# api.VoxelInformationDisplayMode.StatusBar - show it in the status bar only
# api.VoxelInformationDisplayMode.MouseHover - show it next to the mouse pointer only
# api.VoxelInformationDisplayMode.Both - show it in both places
# voxel_info_mode = view_operations.get_voxel_information_display_mode()
# print(f"Voxel information mode: {voxel_info_mode}")

# Show voxel information in the status bar only.
# view_operations.set_voxel_information_display_mode(api.VoxelInformationDisplayMode.StatusBar)

# Show voxel information as a compact mouse-hover tooltip only.
# view_operations.set_voxel_information_display_mode(api.VoxelInformationDisplayMode.MouseHover)

# Show voxel information in both the status bar and the mouse-hover tooltip.
# The hover text can include the voxel index, the gray value, the visible mask
# name under the cursor, and the label information for a visible multi-label mask.
# view_operations.set_voxel_information_display_mode(api.VoxelInformationDisplayMode.Both)

# Hide voxel information completely.
# view_operations.set_voxel_information_display_mode(api.VoxelInformationDisplayMode.Off)

# Check slice views linked state
# are_views_linked = view_operations.is_slice_views_linked()
# print(f"Slice views linked: {are_views_linked}")

# Link slice views so panning/zooming is synchronized
# view_operations.set_slice_views_linked(True)

# Unlink slice views
# view_operations.set_slice_views_linked(False)

Slice Views - Window / Level​

# Window and Level control the brightness and contrast of the 2D slice views.
# Window defines the range of gray values displayed, and Level defines the
# center of that range.
#
# For example, for CT bone visualization: window=1000, level=500
# For CT lung visualization: window=500, level=-200

# Get the current window and level values of the active volume
# wl = view_operations.get_window_level()
# print(f"Window: {wl[0]}, Level: {wl[1]}")

# Set window and level for bone visualization
# view_operations.set_window_level(1000.0, 500.0)

# Set window and level for soft tissue
# view_operations.set_window_level(400.0, 40.0)

# Set window and level for lung
# view_operations.set_window_level(500.0, -200.0)

3D View - Mask Preview​

# Generate a 3D surface preview of the visible masks.

# Get the current mask preview quality level
# quality = view_operations.get_mask_3d_preview_quality()
# print(f"Current mask preview quality: {quality}")

# Generate mask preview with the current quality setting
# view_operations.generate_mask_3d_preview()

# Generate mask preview with a specific quality level
# Available quality levels:
# api.Mask3dPreviewQuality.Optimal - Full resolution (slowest)
# api.Mask3dPreviewQuality.High - High quality
# api.Mask3dPreviewQuality.Medium - Medium quality
# api.Mask3dPreviewQuality.Low - Low quality (fastest)
# view_operations.generate_mask_3d_preview_with_quality(api.Mask3dPreviewQuality.High)

# Remove all mask previews from the 3D view
# view_operations.remove_all_mask_previews()

3D View - Object Widgets (Bounding Boxes)​

# Toggle bounding box and corner bounding box outlines for visible objects.
#
# Available widget object types:
# api.WidgetObjectType.Volume - Volume objects
# api.WidgetObjectType.Surface - Surface and mask objects
# api.WidgetObjectType.VolumeMesh - Volume mesh objects

# Show (or hide) volume bounding box outline
# view_operations.set_outline_enabled(api.WidgetObjectType.Volume, True)

# Show (or hide) surface bounding box outline
# view_operations.set_outline_enabled(api.WidgetObjectType.Surface, True)

# Show (or hide) volume mesh bounding box outline
# view_operations.set_outline_enabled(api.WidgetObjectType.VolumeMesh, True)

# Show (or hide) volume corner bounding box outline
# view_operations.set_corner_outline_enabled(api.WidgetObjectType.Volume, True)

# Show (or hide) surface corner bounding box outline
# view_operations.set_corner_outline_enabled(api.WidgetObjectType.Surface, True)

3D View - Volume Rendering Options​

# Show or hide slice planes, axes planes, and volume shading. Pass True to
# enable each feature and False to disable it.

# Show (or hide) 3D slice planes
# view_operations.set_slice_planes_enabled(True)

# Show (or hide) axes planes
# view_operations.set_axes_planes_enabled(True)

# Enable (or disable) volume shading (lighting)
# view_operations.set_volume_shading_enabled(True)

3D View - Surface Representation​

# Set the surface representation mode for all surface, volume mesh, and mask objects.
#
# Available representation modes:
# api.SurfaceRepresentation.Solid - Filled solid surface
# api.SurfaceRepresentation.SolidEdges - Solid surface with visible edges
# api.SurfaceRepresentation.Wireframe - Wireframe (edges only)
# api.SurfaceRepresentation.Points - Point cloud

# Set solid representation
# view_operations.set_surface_representation(api.SurfaceRepresentation.Solid)

# Set wireframe representation
# view_operations.set_surface_representation(api.SurfaceRepresentation.Wireframe)

# Set solid with edges representation
# view_operations.set_surface_representation(api.SurfaceRepresentation.SolidEdges)

3D View - Surface Shading​

# Set the surface shading (interpolation) method for all surface, volume mesh,
# and mask objects.
#
# Available interpolation methods:
# api.SurfaceInterpolation.Flat - Flat shading (per-face)
# api.SurfaceInterpolation.Gouraud - Gouraud shading (smooth, per-vertex)
# api.SurfaceInterpolation.Phong - Phong shading (smooth, per-pixel)
# api.SurfaceInterpolation.PBR - Physically Based Rendering

# Set flat shading
# view_operations.set_surface_shading(api.SurfaceInterpolation.Flat)

# Set Phong shading
# view_operations.set_surface_shading(api.SurfaceInterpolation.Phong)

# Set PBR shading
# view_operations.set_surface_shading(api.SurfaceInterpolation.PBR)

3D View - Point Colors​

# Show or hide scalar colors on all surface, volume mesh, and mask objects.
# When enabled, objects are colored by their vertex data (if available).
# When disabled, objects use their assigned solid color.

# Show (or hide) point colors
# view_operations.set_point_colors_enabled(True)

2D Views - Orientation Labels​

# Show or hide the edge-center orientation labels in all three 2D slice views.
#
# When enabled, each slice view displays orientation labels at the midpoint of
# its four viewport edges.
#
# The labels follow the active scene orientation:
# - medical orientations use anatomical shorthand (R, L, A, P, S, I)
# - engineering orientations use axis notation (+X, -Y, +Z, ...)
#
# Changing the scene orientation can change which axis and direction appear on
# a given edge.
# Labels are colored by axis: X=red, Y=green, Z=blue.
#
# This setting is independent of the corner annotations controlled by
# set_2d_annotations_visible().

# Check the current state
# is_labels_on = view_operations.is_2d_orientation_labels_visible()
# print(f"Orientation labels visible: {is_labels_on}")

# Enable orientation labels
# view_operations.set_2d_orientation_labels_visible(True)

# Disable orientation labels
# view_operations.set_2d_orientation_labels_visible(False)

Camera - Standard Views​

# Set the 3D view camera to a predefined standard view direction.
#
# Available standard views:
# api.StandardView.XMinus - View from negative X direction (Left/Right)
# api.StandardView.XPlus - View from positive X direction (Right/Left)
# api.StandardView.YMinus - View from negative Y direction (Posterior/Anterior)
# api.StandardView.YPlus - View from positive Y direction (Anterior/Posterior)
# api.StandardView.ZMinus - View from negative Z direction (Inferior/Superior)
# api.StandardView.ZPlus - View from positive Z direction (Superior/Inferior)
# api.StandardView.Isometric - Isometric (45-degree) view

# Set the camera to look from the positive Z direction
# view_operations.set_standard_view(api.StandardView.ZPlus)

# Set the camera to the isometric view
# view_operations.set_standard_view(api.StandardView.Isometric)

View Rendering​

# Force a redraw of specific views when a script drives the camera or other
# view state in a loop.

# Render the 3D view only
# view_operations.render_3d_view()

# Render individual 2D slice views
# view_operations.render_2d_view1() # Plane 1 / YZ / sagittal
# view_operations.render_2d_view2() # Plane 2 / XZ / coronal
# view_operations.render_2d_view3() # Plane 3 / XY / axial

# Render all 2D and 3D views
# view_operations.render_all_views()

Camera - Full State and Center of Rotation​

# Read and apply the full 3D camera state.
#
# Important:
# - camera.distance must stay consistent with camera.position and camera.focal_point
# - translating position and focal_point by the same offset preserves the distance
# - camera.view_up must stay non-zero and must not be parallel to (camera.focal_point - camera.position)
# - the renderer may refine the clipping range internally after the camera is applied

# camera_settings : api.CameraSettings = view_operations.get_3d_camera_settings()
# print(f"Camera position: {camera_settings.position}")
# print(f"Camera focal point: {camera_settings.focal_point}")
# print(f"Camera view up: {camera_settings.view_up}")

# Move the camera and focal point together along X while preserving the current distance
# camera_settings.position = [camera_settings.position[0] + 10.0, camera_settings.position[1], camera_settings.position[2]]
# camera_settings.focal_point = [camera_settings.focal_point[0] + 10.0, camera_settings.focal_point[1], camera_settings.focal_point[2]]
# view_operations.set_3d_camera_settings(camera_settings)

# Read and control the current center of rotation used by 3D navigation
# center_of_rotation = view_operations.get_3d_center_of_rotation()
# print(f"Center of rotation: {center_of_rotation}")

# Set a custom center of rotation
# view_operations.set_3d_center_of_rotation([0.0, 0.0, 0.0])

# Reset the center of rotation to the center of the visible scene
# view_operations.reset_3d_center_of_rotation()

Camera - Incremental Motion Helpers​

# Apply small camera deltas directly from gesture, joystick, or tracker input.
#
# Sign conventions:
# - positive yaw rotates left, negative yaw rotates right
# - positive pitch rotates up, negative pitch rotates down
# - positive roll rotates right, negative roll rotates left
# - dolly factors greater than 1.0 zoom in; factors between 0.0 and 1.0 zoom out
# - pan offsets move along the camera's local right/up axes in world units

# Rotate the camera a little to the left
# view_operations.yaw_3d_camera(5.0)

# Tilt the camera slightly downward
# view_operations.pitch_3d_camera(-3.0)

# Roll the camera to the right (top of scene moves right)
# view_operations.roll_3d_camera(2.0)

# Move the camera closer to the focal point
# view_operations.dolly_3d_camera(1.1)

# Pan right and slightly downward in the camera plane
# view_operations.pan_3d_camera(2.0, -1.0)

Camera - Center and Reset​

# Center the 3D view on the scene without changing zoom level.
# view_operations.center_3d_view()

# Reset the 3D view camera to fit all visible objects.
# view_operations.reset_3d_view()

# Reset all 2D slice view cameras and slice positions.
# view_operations.reset_slice_views()