View Controller Operations
View Controller Operations Tutorial.
This tutorial demonstrates how to control the 3D view controller settings, 2D slice view controller settings, and the 3D view render settings through the scripting API.
Topics covered:
- 3D view render settings (GPU rendering, memory budget, multi-volume renderer)
- 3D view controller (ruler, orientation marker, stereo, animation, background, visibility)
- 2D slice view controller (ruler, orientation marker, interpolation, visibility, background, flip)
- Per-view 2D operations (center, zoom, flip, background)
Prerequisites
- Volvicon application must be running
- A valid license must be active
3D View Render Settings - GPU Volume Rendering​
# Control whether the graphics card or the CPU is used for grayscale volume
# rendering. GPU rendering provides better quality and performance.
# Enable GPU volume rendering (default)
view_operations.set_gpu_volume_rendering_enabled(True)
# Check whether GPU volume rendering is active
is_gpu = view_operations.is_gpu_volume_rendering_enabled()
print(f"GPU volume rendering enabled: {is_gpu}")
# Disable GPU rendering (fall back to CPU)
# view_operations.set_gpu_volume_rendering_enabled(False)
3D View Render Settings - GPU Memory Budget​
# Set how much graphics memory the application may use for volume rendering.
# Lower values can reduce image quality for large datasets.
#
# Available options:
# api.GpuMemoryBudget.Auto - Application chooses automatically (default)
# api.GpuMemoryBudget.GB1 - 1 GB fixed budget
# api.GpuMemoryBudget.GB2 - 2 GB fixed budget
# api.GpuMemoryBudget.GB4 - 4 GB fixed budget
# api.GpuMemoryBudget.GB6 - 6 GB fixed budget
# api.GpuMemoryBudget.GB8 - 8 GB fixed budget
# api.GpuMemoryBudget.GB12 - 12 GB fixed budget
# api.GpuMemoryBudget.GB16 - 16 GB fixed budget
# api.GpuMemoryBudget.GB24 - 24 GB fixed budget
# api.GpuMemoryBudget.GB32 - 32 GB fixed budget
# Let the application choose the memory budget automatically
view_operations.set_gpu_memory_budget(api.GpuMemoryBudget.Auto)
# Get the current GPU memory budget
budget = view_operations.get_gpu_memory_budget()
print(f"GPU memory budget: {budget}")
# Set a fixed 8 GB budget for a system with dedicated GPU memory
# view_operations.set_gpu_memory_budget(api.GpuMemoryBudget.GB8)
3D View Render Settings - Volume Renderer​
# Choose how grayscale volumes and direct mask previews are blended
# when multiple objects overlap in the 3D view.
# Enable multi-volume renderer for overlapping grayscale volumes
# view_operations.set_volume_multi_volume_renderer(True)
# Check the current setting
is_multi = view_operations.is_volume_multi_volume_renderer()
print(f"Multi-volume renderer (volumes): {is_multi}")
# Disable multi-volume renderer (each volume rendered separately)
# view_operations.set_volume_multi_volume_renderer(False)
# Enable multi-volume renderer for direct mask previews (on by default)
# view_operations.set_mask_direct_multi_volume_renderer(True)
# Check the mask direct renderer setting
is_mask_multi = view_operations.is_mask_direct_multi_volume_renderer()
print(f"Multi-volume renderer (mask direct): {is_mask_multi}")
3D View Controller - Camera Mode​
# Switch between perspective and orthographic display.
# The ruler overlay is only available in orthographic mode.
# Enable orthographic (parallel projection) mode
view_operations.set_orthographic_mode_enabled(True)
# Check the current projection mode
is_ortho = view_operations.is_orthographic_mode_enabled()
print(f"Orthographic mode: {is_ortho}")
# Return to perspective mode
view_operations.set_orthographic_mode_enabled(False)
3D View Controller - Ruler​
# Display a scale ruler in the 3D view.
# Note: selecting a ruler type other than Off automatically enables
# orthographic mode, since the ruler requires parallel projection.
#
# Available ruler types:
# api.RulerType.Off - No ruler (default)
# api.RulerType.Thin - Thin ruler style
# api.RulerType.Thick - Thick ruler style
#
# Available ruler colors:
# api.RulerColor.White - White ruler
# api.RulerColor.Black - Black ruler
# api.RulerColor.Yellow - Yellow ruler (default)
# Show a thin ruler in yellow
view_operations.set_3d_ruler_type(api.RulerType.Thin)
view_operations.set_3d_ruler_color(api.RulerColor.Yellow)
# Check the current ruler settings
ruler_type = view_operations.get_3d_ruler_type()
ruler_color = view_operations.get_3d_ruler_color()
print(f"3D ruler type: {ruler_type}, color: {ruler_color}")
# Hide the ruler
view_operations.set_3d_ruler_type(api.RulerType.Off)
# Return to perspective mode (ruler enabled orthographic automatically)
view_operations.set_orthographic_mode_enabled(False)
3D View Controller - Orientation Marker​
# Display an orientation marker in the corner of the 3D view.
#
# Available marker types:
# api.OrientationMarkerType.Off - No marker
# api.OrientationMarkerType.Axes - Unidirectional axes labels
# api.OrientationMarkerType.BidirectionalAxes - Bidirectional axes labels
# api.OrientationMarkerType.Cube - Labeled cube marker
# api.OrientationMarkerType.Human - Body orientation marker
#
# Available marker sizes:
# api.OrientationMarkerSize.Small - Small marker
# api.OrientationMarkerSize.Medium - Medium marker (default)
# api.OrientationMarkerSize.Large - Large marker
# Show a cube orientation marker at medium size
view_operations.set_3d_orientation_marker_type(api.OrientationMarkerType.Cube)
view_operations.set_3d_orientation_marker_size(api.OrientationMarkerSize.Medium)
# Get the current settings
marker_type = view_operations.get_3d_orientation_marker_type()
marker_size = view_operations.get_3d_orientation_marker_size()
print(f"3D orientation marker: {marker_type}, size: {marker_size}")
# Restore default (axes marker)
view_operations.set_3d_orientation_marker_type(api.OrientationMarkerType.Axes)
3D View Controller - Stereo Display​
# Select a stereo display mode. Requires compatible hardware for most modes.
#
# Available stereo types:
# api.StereoType.NoStereo - No stereo (default)
# api.StereoType.RedBlue - Red/blue anaglyph
# api.StereoType.Anaglyph - Color anaglyph
# api.StereoType.Interlaced - Interlaced for polarized displays
# api.StereoType.CrystalEyes - CrystalEyes shutter glasses
# api.StereoType.Left - Left eye only
# api.StereoType.Right - Right eye only
# api.StereoType.Dresden - Dresden display
# api.StereoType.Checkerboard - Checkerboard pattern
# api.StereoType.SplitHorizontal - Split viewport horizontal
# api.StereoType.Fake - Fake stereo (testing)
# api.StereoType.Emulate - Emulated stereo
# Enable red/blue anaglyph stereo
# view_operations.set_stereo_type(api.StereoType.RedBlue)
# Get the current stereo mode
stereo = view_operations.get_stereo_type()
print(f"Stereo type: {stereo}")
# Disable stereo
# view_operations.set_stereo_type(api.StereoType.NoStereo)
3D View Controller - Animation​
# Start or stop animated rotation of the 3D scene.
#
# Available animation modes:
# api.AnimationMode3d.Off - No animation (default)
# api.AnimationMode3d.Spin - Continuous rotation around the vertical axis
# api.AnimationMode3d.Rock - Oscillating back-and-forth rotation
# Start spinning
# view_operations.set_3d_animation_mode(api.AnimationMode3d.Spin)
# Get the current animation mode
mode = view_operations.get_3d_animation_mode()
print(f"3D animation mode: {mode}")
# Stop animation
# view_operations.set_3d_animation_mode(api.AnimationMode3d.Off)
3D View Controller - Background​
# Set the background color of the 3D view to a predefined preset.
#
# Available presets:
# api.Background3dPreset.Default - Default gradient (blue-gray, default)
# api.Background3dPreset.CenterGlow - Dark center-glow radial gradient
# api.Background3dPreset.LightBlue - Uniform light blue
# api.Background3dPreset.Black - Uniform black
# api.Background3dPreset.White - Uniform white
# api.Background3dPreset.Gray - Gray radial gradient
# Set the default gradient background
view_operations.set_3d_background(api.Background3dPreset.Default)
# Set a black background for screenshots
# view_operations.set_3d_background(api.Background3dPreset.Black)
# Set a white background
# view_operations.set_3d_background(api.Background3dPreset.White)
# Set a gray radial gradient background
# view_operations.set_3d_background(api.Background3dPreset.Gray)
3D View Controller - Custom Background​
# Set a custom background color or gradient for the 3D view.
# Colors are specified as [r, g, b] arrays with component values in [0.0, 1.0].
#
# Background types:
# api.Background3dType.Single - Uniform single color (uses bottom color only)
# api.Background3dType.Gradient - Linear or radial color gradient
#
# Gradient directions (used with Gradient type):
# api.GradientDirection.Vertical - Bottom-to-top color transition
# api.GradientDirection.Horizontal - Left-to-right color transition
# api.GradientDirection.RadialFarthest - Radial gradient to farthest side
# api.GradientDirection.RadialFarthestCorner - Radial gradient to farthest corner
# Single uniform color (dark navy)
# view_operations.set_3d_custom_background(
# api.Background3dType.Single,
# [0.05, 0.05, 0.15], # bottom/primary color
# [0.0, 0.0, 0.0], # ignored for Single type
# api.GradientDirection.Vertical
# )
# Vertical gradient (dark bottom, light top)
# view_operations.set_3d_custom_background(
# api.Background3dType.Gradient,
# [0.1, 0.1, 0.2], # bottom color
# [0.7, 0.7, 0.9], # top color
# api.GradientDirection.Vertical
# )
# Radial gradient for a spotlight effect
# view_operations.set_3d_custom_background(
# api.Background3dType.Gradient,
# [0.2, 0.2, 0.3], # center color
# [0.0, 0.0, 0.0], # outer edge color
# api.GradientDirection.RadialFarthest
# )
3D View Controller - Visibility​
# Show or hide individual overlay elements in the 3D view.
# Hide the origin axes (coordinate axes at scene origin)
view_operations.set_3d_origin_axes_visible(False)
is_origin_visible = view_operations.is_3d_origin_axes_visible()
print(f"3D origin axes visible: {is_origin_visible}")
# Show the center of rotation axes so the current 3D orbit point stays visible.
# In the 3D view, press C over a feature to move this marker there and center it on screen.
view_operations.set_3d_center_of_rotation_axes_visible(True)
is_rotation_center_visible = view_operations.is_3d_center_of_rotation_axes_visible()
print(f"3D center of rotation axes visible: {is_rotation_center_visible}")
# Hide the logo image overlay in the 3D view.
view_operations.set_3d_logo_visible(False)
is_logo_visible = view_operations.is_3d_logo_visible()
print(f"3D logo image visible: {is_logo_visible}")
# Hide the color map bar
view_operations.set_3d_color_map_bar_visible(False)
# Hide the scene scale ruler
view_operations.set_3d_scale_ruler_visible(False)
# Hide the scene bounding box outline
view_operations.set_3d_scene_bounding_box_visible(False)
# Hide the scene axes labels
view_operations.set_3d_scene_axes_labels_visible(False)
# Hide the frames-per-second counter
view_operations.set_3d_fps_visible(False)
2D Slice View Controller - Ruler​
# Display a scale ruler in the 2D slice views.
# Ruler type and color are synchronized across all three slice views.
#
# Available ruler types:
# api.RulerType.Off - No ruler (default)
# api.RulerType.Thin - Thin ruler style
# api.RulerType.Thick - Thick ruler style
#
# Available ruler colors:
# api.RulerColor.White - White ruler
# api.RulerColor.Black - Black ruler
# api.RulerColor.Yellow - Yellow ruler (default)
# Show a thin yellow ruler in all slice views
view_operations.set_2d_ruler_type(api.RulerType.Thin)
view_operations.set_2d_ruler_color(api.RulerColor.Yellow)
# Get the current 2D ruler settings
ruler_type_2d = view_operations.get_2d_ruler_type()
ruler_color_2d = view_operations.get_2d_ruler_color()
print(f"2D ruler type: {ruler_type_2d}, color: {ruler_color_2d}")
# Hide the ruler in all slice views
view_operations.set_2d_ruler_type(api.RulerType.Off)
2D Slice View Controller - Orientation Marker​
# Display an orientation marker in the corner of each slice view.
# Marker type and size are synchronized across all three slice views.
#
# Same marker types and sizes as for the 3D view.
# Show a cube marker at large size in all slice views
view_operations.set_2d_orientation_marker_type(api.OrientationMarkerType.Axes)
view_operations.set_2d_orientation_marker_size(api.OrientationMarkerSize.Medium)
# Get the current 2D marker settings
marker_type_2d = view_operations.get_2d_orientation_marker_type()
print(f"2D orientation marker: {marker_type_2d}")
# Hide the orientation marker in all slice views
# view_operations.set_2d_orientation_marker_type(api.OrientationMarkerType.Off)
2D Slice View Controller - Interpolation​
# Set the image interpolation mode used when rendering slice images.
# This setting is synchronized across all three slice views.
#
# Available modes:
# api.Interpolation2d.Nearest - Nearest-neighbor (sharpest voxel edges)
# api.Interpolation2d.Linear - Linear interpolation (default)
# api.Interpolation2d.Cubic - Cubic interpolation (smoothest)
# Set linear interpolation (default)
view_operations.set_2d_interpolation_mode(api.Interpolation2d.Linear)
# Get the current interpolation mode
interp = view_operations.get_2d_interpolation_mode()
print(f"2D interpolation mode: {interp}")
# Use nearest-neighbor for pixel-accurate inspection
# view_operations.set_2d_interpolation_mode(api.Interpolation2d.Nearest)
2D Slice View Controller - Visibility​
# Show or hide overlay elements shared across all slice views.
# Show corner annotations (patient/volume info overlays)
view_operations.set_2d_annotations_visible(True)
is_ann_visible = view_operations.is_2d_annotations_visible()
print(f"2D annotations visible: {is_ann_visible}")
# Hide the color map bar
view_operations.set_2d_color_map_bar_visible(False)
# Hide the scene scale ruler
view_operations.set_2d_scale_ruler_visible(False)
2D Slice View Controller - Background (per-view)​
# Set the background color for each slice view individually.
# Background changes apply only to the specified view.
#
# Slice views:
# api.SliceViewIndex.SliceView1_YZ - YZ-plane view (index 0)
# api.SliceViewIndex.SliceView2_XZ - XZ-plane view (index 1)
# api.SliceViewIndex.SliceView3_XY - XY-plane view (index 2)
#
# Available presets:
# api.Background2dPreset.DarkGray - Dark gray (default)
# api.Background2dPreset.Black - Black
# api.Background2dPreset.White - White
# Set all slice views to dark gray (default)
view_operations.set_2d_background(api.SliceViewIndex.SliceView1_YZ, api.Background2dPreset.DarkGray)
view_operations.set_2d_background(api.SliceViewIndex.SliceView2_XZ, api.Background2dPreset.DarkGray)
view_operations.set_2d_background(api.SliceViewIndex.SliceView3_XY, api.Background2dPreset.DarkGray)
# Set the XY-plane view to white for a report-ready appearance
# view_operations.set_2d_background(api.SliceViewIndex.SliceView3_XY, api.Background2dPreset.White)
2D Slice View Controller - Flip (per-view)​
# Flip the display of a specific slice view.
# Flip applies only to the specified view.
#
# Available flip types:
# api.FlipType.Horizontal - Mirror left-to-right
# api.FlipType.Vertical - Mirror top-to-bottom
# api.FlipType.Both - Apply both horizontal and vertical flip
# Flip the YZ-plane view horizontally
# view_operations.flip_2d_view(api.SliceViewIndex.SliceView1_YZ, api.FlipType.Horizontal)
# Flip the XY-plane view vertically
# view_operations.flip_2d_view(api.SliceViewIndex.SliceView3_XY, api.FlipType.Vertical)
# Flip the XZ-plane view in both directions
# view_operations.flip_2d_view(api.SliceViewIndex.SliceView2_XZ, api.FlipType.Both)
2D Slice View Controller - Navigation (per-view)​
# Center, zoom in, or zoom out a specific slice view.
# These operations apply only to the specified view.
# Center (fit) each slice view to the available space
view_operations.center_2d_view(api.SliceViewIndex.SliceView1_YZ)
view_operations.center_2d_view(api.SliceViewIndex.SliceView2_XZ)
view_operations.center_2d_view(api.SliceViewIndex.SliceView3_XY)
# Zoom in on the XY-plane view
# view_operations.zoom_in_2d_view(api.SliceViewIndex.SliceView3_XY)
# Zoom out on the YZ-plane view
# view_operations.zoom_out_2d_view(api.SliceViewIndex.SliceView1_YZ)
print("View controller operations tutorial complete.")
Related Resources​
- API Reference - API documentation
- Quick Reference - Common methods at a glance