Skip to main content

Class: VolumeCroppingTool

VolumeCroppingTool provides manipulatable spheres and real-time volume cropping capabilities. It renders interactive handles (spheres) at face centers and corners of a cropping box, allowing users to precisely adjust volume boundaries through direct manipulation in 3D space.

Remarks​

This tool creates a complete 3D cropping interface with:

  • 6 face spheres for individual axis cropping (along volume's X, Y, Z axes)
  • 8 corner spheres for multi-axis cropping
  • 12 edge lines connecting corner spheres
  • Real-time clipping plane updates
  • Synchronization with VolumeCroppingControlTool working on the same series instance UID for cross-viewport interaction
  • Support for volumes with any orientation (including oblique/rotated volumes)

The tool automatically adapts to the volume's orientation by using the volume's direction matrix. Clipping planes are aligned with the volume's intrinsic axes (X, Y, Z) rather than world axes, ensuring proper cropping regardless of how the volume is oriented in 3D space.

Example​

// Basic setup
const toolGroup = ToolGroupManager.createToolGroup('volume3D');
toolGroup.addTool(VolumeCroppingTool.toolName);

// Configure with custom settings
toolGroup.setToolConfiguration(VolumeCroppingTool.toolName, {
showCornerSpheres: true,
showHandles: true,
initialCropFactor: 0.1,
sphereColors: {
SAGITTAL: [1.0, 1.0, 0.0], // Yellow for X-axis (typically sagittal) spheres
CORONAL: [0.0, 1.0, 0.0], // Green for Y-axis (typically coronal) spheres
AXIAL: [1.0, 0.0, 0.0], // Red for Z-axis (typically axial) spheres
CORNERS: [0.0, 0.0, 1.0] // Blue for corner spheres
},
sphereRadius: 10,
grabSpherePixelDistance: 25
});

// Activate the tool
toolGroup.setToolActive(VolumeCroppingTool.toolName);

// Programmatically control visibility
const tool = toolGroup.getToolInstance(VolumeCroppingTool.toolName);
tool.setHandlesVisible(true);
tool.setClippingPlanesVisible(true);

// Toggle visibility for interactive UI
function toggleCroppingInterface() {
const handlesVisible = tool.getHandlesVisible();
const planesVisible = tool.getClippingPlanesVisible();

// Toggle handles (spheres and edge lines)
tool.setHandlesVisible(!handlesVisible);

// Toggle clipping effect
tool.setClippingPlanesVisible(!planesVisible);

}

// Common UI scenarios
// Show handles but disable cropping (for positioning)
tool.setHandlesVisible(true);
tool.setClippingPlanesVisible(false);

// Hide handles but keep cropping active (for clean view)
tool.setHandlesVisible(false);
tool.setClippingPlanesVisible(true);

VolumeCroppingTool

Configuration​

Events​

VOLUMECROPPING_TOOL_CHANGED - Fired when sphere positions change or clipping planes are updated. Event detail includes:

  • originalClippingPlanes: ClippingPlane[] - Array of 6 clipping planes [XMIN, XMAX, YMIN, YMAX, ZMIN, ZMAX]
  • seriesInstanceUID: string - Series instance UID for event filtering
  • viewportId?: string - Optional viewport ID
  • renderingEngineId?: string - Optional rendering engine ID VOLUMECROPPINGCONTROL_TOOL_CHANGED - Listens for changes from VolumeCroppingControlTool VOLUME_VIEWPORT_NEW_VOLUME - Listens for new volume loading to reinitialize cropping bounds TOOLGROUP_VIEWPORT_ADDED - Listens for new viewport additions to extend resize observation

Methods​

  • setHandlesVisible(visible: boolean): Show/hide manipulation spheres and edge lines
  • setClippingPlanesVisible(visible: boolean): Enable/disable volume clipping planes
  • getHandlesVisible(): Get current handle visibility state
  • getClippingPlanesVisible(): Get current clipping plane visibility state
  • setRotatePlanesOnDrag(enable: boolean): Enable/disable rotating clipping planes on drag (default: false)
  • getRotatePlanesOnDrag(): Get current rotate planes on drag state

See​

Extends​

Constructors​

new VolumeCroppingTool()​

new VolumeCroppingTool(toolProps, defaultToolProps): VolumeCroppingTool

Parameters​

• toolProps: PublicToolProps = {}

• defaultToolProps: SharedToolProp = ...

Returns​

VolumeCroppingTool

Overrides​

BaseTool.constructor

Defined in​

tools/src/tools/VolumeCroppingTool.ts:243

Properties​

_hasResolutionChanged​

_hasResolutionChanged: boolean = false

Flag tracking if rendering resolution has been modified during interaction

Defined in​

tools/src/tools/VolumeCroppingTool.ts:210


_resizeObservers​

_resizeObservers: Map<any, any>

Map of ResizeObserver instances for viewport resize handling

Defined in​

tools/src/tools/VolumeCroppingTool.ts:208


_viewportAddedListener()​

_viewportAddedListener: (evt) => void

Event listener for new viewport additions

Parameters​

• evt: any

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:209


cleanUp()​

cleanUp: () => void

Cleanup function for resetting tool state after interactions

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:207


configuration​

configuration: Record<string, any>

The configuration for this tool. IBaseTool contains some default configuration values, and you can use configurationTyped to get the typed version of this.

Inherited from​

BaseTool.configuration

Defined in​

tools/src/tools/base/BaseTool.ts:111


cornerDragOffset​

cornerDragOffset: [number, number, number] = null

3D offset vector for corner sphere dragging [dx, dy, dz]

Defined in​

tools/src/tools/VolumeCroppingTool.ts:215


draggingSphereIndex​

draggingSphereIndex: number = null

Index of currently dragged sphere, null when not dragging

Defined in​

tools/src/tools/VolumeCroppingTool.ts:212


edgeLines​

edgeLines: object = {}

Dictionary of edge line actors connecting corner spheres for wireframe visualization

Index Signature​

[uid: string]: object

Defined in​

tools/src/tools/VolumeCroppingTool.ts:234


faceDragOffset​

faceDragOffset: number = null

1D offset value for face sphere dragging along single axis

Defined in​

tools/src/tools/VolumeCroppingTool.ts:216


handlesMultiTouchGestures​

handlesMultiTouchGestures: boolean = false

Whether this tool implements its own handling for touch points that arrive after a gesture has already started.

When false (the default), an extra finger during an in-progress gesture releases the tool through cancel() so the gesture can re-resolve to the tool bound to the new finger count - normally pinch zoom or multi-finger scroll. See releaseToolForMultiTouchGesture.

Multi-part tools set this to true: cancelling them would discard points the user has already placed, and they instead ignore the extra finger for the duration of the gesture. Declaring it also keeps the manipulation tools reachable, since the dispatcher bypasses the interaction guard for such tools rather than clearing it.

Inherited from​

BaseTool.handlesMultiTouchGestures

Defined in​

tools/src/tools/base/BaseTool.ts:104


isPrimary​

isPrimary: boolean = false

Primary tool - this is set to true when this tool is primary

Inherited from​

BaseTool.isPrimary

Defined in​

tools/src/tools/base/BaseTool.ts:121


memo​

protected memo: Memo

A memo recording the starting state of a tool. This will be updated as changes are made, and reflects the fact that a memo has been created.

Inherited from​

BaseTool.memo

Defined in​

tools/src/tools/base/BaseTool.ts:127


mode​

mode: ToolModes

Tool Mode - Active/Passive/Enabled/Disabled/

Inherited from​

BaseTool.mode

Defined in​

tools/src/tools/base/BaseTool.ts:119


mouseDragCallback()​

mouseDragCallback: (evt) => void

Mouse drag event handler for desktop interactions

Parameters​

• evt: InteractionEventType

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:206


originalClippingPlanes​

originalClippingPlanes: ClippingPlane[] = []

Array of clipping plane objects with origin and normal vectors

Defined in​

tools/src/tools/VolumeCroppingTool.ts:211


rotatePlanesOnDrag​

rotatePlanesOnDrag: boolean = false

If true, dragging rotates clipping planes instead of camera (default: false)

Defined in​

tools/src/tools/VolumeCroppingTool.ts:213


seriesInstanceUID?​

optional seriesInstanceUID: string

Frame of reference for the tool

Defined in​

tools/src/tools/VolumeCroppingTool.ts:204


sphereStates​

sphereStates: object[] = []

Array of sphere state objects containing position, VTK actors, and metadata

Defined in​

tools/src/tools/VolumeCroppingTool.ts:224


supportedInteractionTypes​

supportedInteractionTypes: InteractionTypes[]

Supported Interaction Types - currently only Mouse

Inherited from​

BaseTool.supportedInteractionTypes

Defined in​

tools/src/tools/base/BaseTool.ts:87


suppressPlaneRotationForCurrentDrag​

suppressPlaneRotationForCurrentDrag: boolean = false

Defined in​

tools/src/tools/VolumeCroppingTool.ts:214


toolGroupId​

toolGroupId: string

ToolGroup ID the tool instance belongs to

Inherited from​

BaseTool.toolGroupId

Defined in​

tools/src/tools/base/BaseTool.ts:117


touchDragCallback()​

touchDragCallback: (evt) => void

Touch drag event handler for mobile interactions

Parameters​

• evt: InteractionEventType

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:205


volumeDirectionVectors​

volumeDirectionVectors: object = null

xDir​

xDir: Point3

yDir​

yDir: Point3

zDir​

zDir: Point3

Defined in​

tools/src/tools/VolumeCroppingTool.ts:218


activeCursorTool​

static activeCursorTool: any

Set to the tool that is currently drawing the active cursor. This will be either primary mouse button tool if no tool is currently being directly interacted with, OR the tool that is directly interacted with. This logic ensures that there is only a single tool at a time drawing, which prevents tools not getting mouse updates from over-writing the cursor.

  • If the tool bound to the primary button is a cursor drawing tool, use that tool and there is NOT a tool currently drawing directly
  • If there is a tool currently drawing directly, then that tool should display a cursor EVEN if it normally doesn't have a custom cursor
  • When a tool finishes drawing direct, it should stop being the active cursor tool unless it is also the primary tool

Inherited from​

BaseTool.activeCursorTool

Defined in​

tools/src/tools/base/BaseTool.ts:54


defaults​

static defaults: object

Has the defaults associated with the base tool.

configuration​

configuration: object

configuration.activeStrategy​

activeStrategy: any = undefined

configuration.defaultStrategy​

defaultStrategy: any = undefined

configuration.strategies​

strategies: object = {}

configuration.strategyOptions​

strategyOptions: object = {}

Inherited from​

BaseTool.defaults

Defined in​

tools/src/tools/base/BaseTool.ts:132


MOUSE_PROXIMITY​

readonly static MOUSE_PROXIMITY: 6

Canvas-pixel radius used to hit-test annotations and handles for mouse interactions.

Inherited from​

BaseTool.MOUSE_PROXIMITY

Defined in​

tools/src/tools/base/BaseTool.ts:69


toolName​

static toolName: any

Static tool identifier: 'VolumeCropping'

Overrides​

BaseTool.toolName

Defined in​

tools/src/tools/VolumeCroppingTool.ts:203


TOUCH_PROXIMITY​

readonly static TOUCH_PROXIMITY: 36

Canvas-pixel radius used to hit-test annotations and handles for touch interactions. A fingertip covers far more screen than a cursor hotspot, so touch targets are much larger than BaseTool.MOUSE_PROXIMITY. Tools that need to widen an in-draw target for touch should use this rather than restating the number.

Inherited from​

BaseTool.TOUCH_PROXIMITY

Defined in​

tools/src/tools/base/BaseTool.ts:63


TOUCH_TAP_MAX_CANVAS_DISTANCE​

readonly static TOUCH_TAP_MAX_CANVAS_DISTANCE: 24

Maximum canvas-pixel distance a gesture may travel and still be counted as a tap by the touch start listener. Tools that commit a gesture on TOUCH_END need this to recognize the trailing TOUCH_TAP echo.

Inherited from​

BaseTool.TOUCH_TAP_MAX_CANVAS_DISTANCE

Defined in​

tools/src/tools/base/BaseTool.ts:76


TOUCH_TAP_TOLERANCE_MS​

readonly static TOUCH_TAP_TOLERANCE_MS: 300

Window in milliseconds within which successive taps are aggregated into a single multi-tap TOUCH_TAP. The tap is emitted one tolerance after the chain's last touchend.

Inherited from​

BaseTool.TOUCH_TAP_TOLERANCE_MS

Defined in​

tools/src/tools/base/BaseTool.ts:84

Accessors​

configurationTyped​

get configurationTyped(): ToolConfiguration

Returns​

ToolConfiguration

Inherited from​

BaseTool.configurationTyped

Defined in​

tools/src/tools/base/BaseTool.ts:112


toolName​

get toolName(): string

Newer method for getting the tool name as a property

Returns​

string

Inherited from​

BaseTool.toolName

Defined in​

tools/src/tools/base/BaseTool.ts:205

Methods​

_addSphere()​

_addSphere(viewport, point, axis, position, cornerKey, adaptiveRadius): void

Parameters​

• viewport: VolumeViewport

• point: Point3

• axis: string

• position: string

• cornerKey: string = null

• adaptiveRadius: number

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:1065


_applyClippingPlanesToMapper()​

_applyClippingPlanesToMapper(mapper): void

Parameters​

• mapper: vtkVolumeMapper

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:1415


_averagePoints()​

_averagePoints(points): Point3

Parameters​

• points: Point3[]

Returns​

Point3

Defined in​

tools/src/tools/VolumeCroppingTool.ts:2116


_calculateCornerFromFaces()​

_calculateCornerFromFaces(faceX, faceY, faceZ, xDir, yDir, zDir): Point3

Parameters​

• faceX: Point3

• faceY: Point3

• faceZ: Point3

• xDir: Point3

• yDir: Point3

• zDir: Point3

Returns​

Point3

Defined in​

tools/src/tools/VolumeCroppingTool.ts:2147


_calculateCornerFromProjection()​

_calculateCornerFromProjection(faceX, faceY, faceZ, xDir, yDir, zDir): Point3

Parameters​

• faceX: Point3

• faceY: Point3

• faceZ: Point3

• xDir: Point3

• yDir: Point3

• zDir: Point3

Returns​

Point3

Defined in​

tools/src/tools/VolumeCroppingTool.ts:2178


_dragCallback()​

_dragCallback(evt): void

Parameters​

• evt: InteractionEventType

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:735


_getDirectionVectorForAxis()​

_getDirectionVectorForAxis(axis): Point3

Get the direction vector for a given axis ('x', 'y', or 'z').

Parameters​

• axis: string

The axis identifier

Returns​

Point3

The direction vector in world space

Defined in​

tools/src/tools/VolumeCroppingTool.ts:1126


_getDirectionVectors()​

_getDirectionVectors(): object

Returns​

object

xDir​

xDir: Point3

yDir​

yDir: Point3

zDir​

zDir: Point3

Defined in​

tools/src/tools/VolumeCroppingTool.ts:2068


_getViewport()​

_getViewport(): VolumeViewport

Returns​

VolumeViewport

Defined in​

tools/src/tools/VolumeCroppingTool.ts:1387


_getViewportAndWorldCoords()​

_getViewportAndWorldCoords(evt): object

Parameters​

• evt: any

Returns​

object

viewport​

viewport: VolumeViewport

world​

world: Point3

Defined in​

tools/src/tools/VolumeCroppingTool.ts:1378


_getViewportsInfo()​

_getViewportsInfo(): any[]

Returns​

any[]

Defined in​

tools/src/tools/VolumeCroppingTool.ts:1060


_getVolumeActor()​

_getVolumeActor(viewport?): vtkVolume

Parameters​

• viewport?: VolumeViewport

Returns​

vtkVolume

Defined in​

tools/src/tools/VolumeCroppingTool.ts:1398


_getVolumeMapper()​

_getVolumeMapper(viewport?): vtkVolumeMapper

Parameters​

• viewport?: VolumeViewport

Returns​

vtkVolumeMapper

Defined in​

tools/src/tools/VolumeCroppingTool.ts:1408


_initialize3DViewports()​

_initialize3DViewports(viewportsInfo): void

Parameters​

• viewportsInfo: IViewportId[]

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:1170


_isTouchInteraction()​

protected _isTouchInteraction(evt?): boolean

Whether an interaction event came in through the touch pipeline rather than the mouse pipeline.

Note this is a property of the gesture, not of the device: hybrid hardware (touchscreen laptops, tablets with a mouse attached) delivers both, so tools must branch on the event rather than on a device probe such as isMobile().

Parameters​

• evt?: InteractionEventType

The interaction event, or undefined when a caller has no event to attribute (treated as not-touch).

Returns​

boolean

Inherited from​

BaseTool._isTouchInteraction

Defined in​

tools/src/tools/base/BaseTool.ts:316


_notifyClippingPlanesChanged()​

_notifyClippingPlanesChanged(viewport?): void

Parameters​

• viewport?: any

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:2128


_onControlToolChange()​

_onControlToolChange(evt): void

Parameters​

• evt: any

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:954


_onMouseMoveSphere()​

_onMouseMoveSphere(evt): boolean

Parameters​

• evt: any

Returns​

boolean

Defined in​

tools/src/tools/VolumeCroppingTool.ts:821


_onNewVolume()​

_onNewVolume(): void

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:1746


_rotateCamera()​

_rotateCamera(viewport, centerWorld, axis, angle): void

Parameters​

• viewport: any

• centerWorld: any

• axis: any

• angle: any

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:2211


_rotateClippingPlanes()​

_rotateClippingPlanes(evt): void

Parameters​

• evt: InteractionEventType

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:1784


_subscribeToViewportNewVolumeSet()​

_subscribeToViewportNewVolumeSet(viewports): void

Parameters​

• viewports: any

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:1769


_unsubscribeToViewportNewVolumeSet()​

_unsubscribeToViewportNewVolumeSet(viewportsInfo): void

Parameters​

• viewportsInfo: any

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:1754


_updateClippingPlanes()​

_updateClippingPlanes(viewport): void

Parameters​

• viewport: any

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:985


_updateClippingPlanesFromFaceSpheres()​

_updateClippingPlanesFromFaceSpheres(viewport): void

Parameters​

• viewport: any

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:1434


_updateCornerSpheres()​

_updateCornerSpheres(): void

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:1632


_updateCornerSpheresFromFaces()​

_updateCornerSpheresFromFaces(): void

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:1462


_updateEdgeLines()​

_updateEdgeLines(): void

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:2197


_updateFaceSpheresFromClippingPlanes()​

_updateFaceSpheresFromClippingPlanes(): void

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:2098


_updateFaceSpheresFromCorners()​

_updateFaceSpheresFromCorners(): void

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:1573


_updateHandlesVisibility()​

_updateHandlesVisibility(): void

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:1044


_updateSpherePosition()​

_updateSpherePosition(sphereIndex, newPoint): void

Parameters​

• sphereIndex: number

• newPoint: Point3

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:2089


applyActiveStrategy()​

applyActiveStrategy(enabledElement, operationData): any

Applies the active strategy function to the enabled element with the specified operation data.

Parameters​

• enabledElement: IEnabledElement

The element that is being operated on.

• operationData: unknown

The data that needs to be passed to the strategy.

Returns​

any

The result of the strategy.

Inherited from​

BaseTool.applyActiveStrategy

Defined in​

tools/src/tools/base/BaseTool.ts:225


applyActiveStrategyCallback()​

applyActiveStrategyCallback(enabledElement, operationData, callbackType, ...extraArgs): any

Applies the active strategy, with a given event type being applied. The event type function is found by indexing it on the active strategy function.

Parameters​

• enabledElement: IEnabledElement

The element that is being operated on.

• operationData: unknown

The data that needs to be passed to the strategy.

• callbackType: string

the type of the callback

• ...extraArgs: any[]

Returns​

any

The result of the strategy.

Inherited from​

BaseTool.applyActiveStrategyCallback

Defined in​

tools/src/tools/base/BaseTool.ts:249


doneEditMemo()​

doneEditMemo(): void

This clears and edit memo storage to allow for further history functions to be called. Calls the complete function if present, and pushes the memo to the history memo stack.

This should be called when a tool has finished making a change which should be separated from future/other changes in terms of the history. Usually that means on endCallback (mouse up), but some tools also make changes on the initial creation of an object or have alternate flows and the doneEditMemo has to be called on mouse down or other initiation events to ensure that new changes are correctly recorded.

If the tool has no end callback, then the doneEditMemo is called from the pre mouse down callback. See ZoomTool for an example of this usage.

Returns​

void

Inherited from​

BaseTool.doneEditMemo

Defined in​

tools/src/tools/base/BaseTool.ts:771


ensureCachedStatsTargets()​

protected ensureCachedStatsTargets(data, targetIds, needsUpdate?): boolean

Ensures a cachedStats entry exists for every measurement target, so that the tool stats calculators (which iterate the cachedStats keys) compute statistics for each of them. This is what allows a single fusion viewport to compute the statistics of several display sets at once, even when no other viewport has computed them.

Parameters​

• data: AnnotationData

the annotation data containing the cachedStats

• targetIds: string[]

the targets to seed (see getMeasurementTargets)

• needsUpdate?

optional test flagging an existing entry as incomplete (eg hydrated annotations missing units) and needing to be recalculated

Returns​

boolean

true if any entry was added or flagged, meaning the stats need to be (re)calculated

Inherited from​

BaseTool.ensureCachedStatsTargets

Defined in​

tools/src/tools/base/BaseTool.ts:688


getClippingPlanesVisible()​

getClippingPlanesVisible(): any

Gets the current visibility state of the clipping planes.

Returns​

any

Whether the clipping planes are currently visible and actively cropping the volume

Example​

// Check if clipping planes are currently active
const planesVisible = volumeCroppingTool.getClippingPlanesVisible();
if (planesVisible) {
logger.info('Volume is currently being cropped');
} else {
logger.info('Volume is displayed in full');
}

Remarks​

This method returns the configuration state that controls whether:

  • The volume rendering respects the current clipping plane boundaries
  • Parts of the volume outside the crop bounds are hidden from view
  • The cropping effect is applied to the 3D volume visualization

Defined in​

tools/src/tools/VolumeCroppingTool.ts:636


getHandlesVisible()​

getHandlesVisible(): any

Gets the current visibility state of the cropping handles.

Returns​

any

Whether the cropping handles (spheres and edge lines) are currently visible

Example​

// Check if handles are currently visible
const handlesVisible = volumeCroppingTool.getHandlesVisible();
if (handlesVisible) {
logger.info('Cropping handles are currently shown');
} else {
logger.info('Cropping handles are currently hidden');
}

Remarks​

This method returns the configuration state, which controls the visibility of:

  • Face spheres (6 spheres for individual axis cropping)
  • Corner spheres (8 spheres for multi-axis cropping)
  • Edge lines connecting the corner spheres

Defined in​

tools/src/tools/VolumeCroppingTool.ts:584


getMeasurementTargetCandidates()​

protected getMeasurementTargetCandidates(viewport, data?): MeasurementTargetCandidate[]

Builds the list of candidate measurement targets for the given viewport: one per volume actor being displayed (including segmentation representations, which carry a representationUID and are excluded by the default filter rather than skipped here), falling back to a single candidate for the default view reference when there are none. The candidates are what the targetsFilter tool configuration chooses from - each carries the display set related parameters (display set, uid, exemplar instance and index) where they are known.

The candidate modality is taken from the display set where available - the exemplar instance or volume metadata for volume backed candidates, or the registered display set of the viewport for the fallback candidate. When the display set is unknown (eg a stack viewport using the legacy set image ids), the candidate has none of the display set fields, and filters can choose whether to include it based on that.

When the annotation already has a cachedStats entry for a candidate's volume (possibly created by another viewport with a different view reference), the existing key is reused as the targetId so statistics are shared rather than recomputed per view.

Parameters​

• viewport: Viewport

• data?: AnnotationData

Returns​

MeasurementTargetCandidate[]

Inherited from​

BaseTool.getMeasurementTargetCandidates

Defined in​

tools/src/tools/base/BaseTool.ts:498


getMeasurementTargets()​

protected getMeasurementTargets(viewport, data?): string[]

Gets the array of targetIds the tool should compute and display measurement statistics for on the given viewport.

The targets are selected by the targetsFilter tool configuration option (see measurementTargetFilters for ready made filters). The filter receives the viewport's candidate display sets and the viewport, and returns the subset to measure.

Each returned targetId reuses an existing cachedStats key when statistics were already computed for the same volume (possibly by a different viewport), and is otherwise the view reference id of this viewport for that volume - so a single fusion viewport can seed and compute the statistics of every filtered target itself, even when no other viewport has computed them.

A configured filter's result is authoritative: when it returns no candidates (eg a PT-only filter on a CT viewport, or the default allPixelData filter when only a SEG is shown), an empty array is returned and no statistics are computed or displayed.

The deprecated isPreferredTargetId configuration is honoured before the filter, so existing configurations keep their behaviour. When neither selects anything and no filter is configured, the viewport's default view reference id is the single target.

Multi-target selection only works for volumes displayed on screen

TODO: Fix this for other fusion types on stack and also for inclusion of annotation measurements which are not currently on screen.

Parameters​

• viewport: Viewport

• data?: AnnotationData

Returns​

string[]

Inherited from​

BaseTool.getMeasurementTargets

Defined in​

tools/src/tools/base/BaseTool.ts:435


getRotatePlanesOnDrag()​

getRotatePlanesOnDrag(): boolean

Gets whether dragging rotates clipping planes instead of the camera.

Returns​

boolean

True if dragging rotates clipping planes, false if it rotates the camera

Example​

const isRotatingPlanes = volumeCroppingTool.getRotatePlanesOnDrag();
if (isRotatingPlanes) {
logger.info('Dragging will rotate clipping planes');
} else {
logger.info('Dragging will rotate camera');
}

Defined in​

tools/src/tools/VolumeCroppingTool.ts:701


getTargetId()​

protected getTargetId(viewport, data?): string

Get the target Id for the viewport which will be used to store the cached statistics scoped to that target in the annotations. For StackViewport, targetId is usually derived from the imageId. For VolumeViewport, it's derived from the volumeId.

This is the primary (first) entry of getMeasurementTargets, so it honours the targetsFilter tool configuration - configuring, for example, measurementTargetFilters.forModality('PT') makes the PT volume of a fusion viewport the target the statistics are stored/read for.

Parameters​

• viewport: Viewport

viewport to get the targetId for

• data?: AnnotationData

Optional: The annotation's data object, containing cachedStats.

Returns​

string

targetId, or undefined when a configured filter selects no targets for this viewport

Inherited from​

BaseTool.getTargetId

Defined in​

tools/src/tools/base/BaseTool.ts:397


getTargetImageData()​

protected getTargetImageData(targetId): IImageData | CPUIImageData

Parameters​

• targetId: string

Returns​

IImageData | CPUIImageData

Inherited from​

BaseTool.getTargetImageData

Defined in​

tools/src/tools/base/BaseTool.ts:330


getToolName()​

getToolName(): string

Returns the name of the tool

Returns​

string

The name of the tool.

Inherited from​

BaseTool.getToolName

Defined in​

tools/src/tools/base/BaseTool.ts:213


onCameraModified()​

onCameraModified(evt): void

Parameters​

• evt: any

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:387


onSetToolActive()​

onSetToolActive(): void

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:275


onSetToolConfiguration()​

onSetToolConfiguration(): void

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:360


onSetToolDisabled()​

onSetToolDisabled(): void

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:368


onSetToolEnabled()​

onSetToolEnabled(): void

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:364


preMouseDownCallback()​

preMouseDownCallback(evt): boolean

Parameters​

• evt: InteractionEventType

Returns​

boolean

Defined in​

tools/src/tools/VolumeCroppingTool.ts:396


redo()​

redo(): void

Redo an action (undo the undo)

Returns​

void

Inherited from​

BaseTool.redo

Defined in​

tools/src/tools/base/BaseTool.ts:718


setActiveStrategy()​

setActiveStrategy(strategyName): void

Sets the active strategy for a tool. Strategies are multiple implementations of tool behavior that can be switched by tool configuration.

Parameters​

• strategyName: string

name of the strategy to be set as active

Returns​

void

Inherited from​

BaseTool.setActiveStrategy

Defined in​

tools/src/tools/base/BaseTool.ts:290


setClippingPlanesVisible()​

setClippingPlanesVisible(visible): void

Sets the visibility of the clipping planes to enable or disable volume cropping.

When clipping planes are visible, the volume rendering is cropped according to the current sphere positions. When disabled, the full volume is displayed without cropping. The viewport is automatically re-rendered after the change.

Parameters​

• visible: boolean

Whether to enable (true) or disable (false) volume clipping

Returns​

void

Example​

// Enable volume cropping
volumeCroppingTool.setClippingPlanesVisible(true);

// Disable volume cropping to show full volume
volumeCroppingTool.setClippingPlanesVisible(false);

Remarks​

  • When enabled, parts of the volume outside the crop bounds are hidden
  • When disabled, all clipping planes are removed from the volume mapper
  • The cropping bounds are determined by the current sphere positions
  • The viewport is automatically re-rendered to reflect the change
  • This method updates the internal configuration and applies changes immediately

Defined in​

tools/src/tools/VolumeCroppingTool.ts:665


setConfiguration()​

setConfiguration(newConfiguration): void

merges the new configuration with the tool configuration

Parameters​

• newConfiguration: Record<string, any>

Returns​

void

Inherited from​

BaseTool.setConfiguration

Defined in​

tools/src/tools/base/BaseTool.ts:276


setHandleRadius()​

setHandleRadius(radius): void

Sets the radius of all cropping handles and re-renders the viewport.

Parameters​

• radius: number

New handle radius in world units

Returns​

void

Defined in​

tools/src/tools/VolumeCroppingTool.ts:593


setHandlesVisible()​

setHandlesVisible(visible): void

Sets the visibility of the cropping handles (spheres and edge lines).

When handles are being shown, this method automatically synchronizes the sphere positions with the current clipping plane positions to ensure visual consistency. This includes updating face spheres, corner spheres, and edge lines to match the current crop bounds.

Parameters​

• visible: boolean

Whether to show or hide the cropping handles

Returns​

void

Example​

// Hide all cropping handles
volumeCroppingTool.setHandlesVisible(false);

// Show handles and sync with current crop state
volumeCroppingTool.setHandlesVisible(true);

Defined in​

tools/src/tools/VolumeCroppingTool.ts:546


setRotatePlanesOnDrag()​

setRotatePlanesOnDrag(enable): void

Sets whether dragging should rotate clipping planes instead of the camera.

When enabled, dragging the mouse will rotate the clipping planes around the volume. When disabled, dragging will rotate the camera view (default behavior).

Parameters​

• enable: boolean

Whether to enable (true) or disable (false) rotating planes on drag

Returns​

void

Example​

// Enable rotating clipping planes on drag
volumeCroppingTool.setRotatePlanesOnDrag(true);

// Disable to use default camera rotation
volumeCroppingTool.setRotatePlanesOnDrag(false);

Remarks​

  • Default is false (camera rotation)
  • When enabled, the clipping planes rotate around the volume center
  • The rotation increment is controlled by rotateClippingPlanesIncrementDegrees configuration

Defined in​

tools/src/tools/VolumeCroppingTool.ts:727


undo()​

undo(): void

Undoes an action

Returns​

void

Inherited from​

BaseTool.undo

Defined in​

tools/src/tools/base/BaseTool.ts:708


calculateLengthInIndex()​

static calculateLengthInIndex(calibrate, indexPoints, closed): number

Calculates the length between two index coordinates using the calibrate information for scaling information.

Parameters​

• calibrate: any

• indexPoints: any

• closed: boolean = false

set to true to calculate the closed length, including the line between the first/last index

Returns​

number

Inherited from​

BaseTool.calculateLengthInIndex

Defined in​

tools/src/tools/base/BaseTool.ts:794


createZoomPanMemo()​

static createZoomPanMemo(viewport): object

Creates a zoom/pan memo that remembers the original zoom/pan position for the given viewport.

Parameters​

• viewport: any

Returns​

object

restoreMemo()​

restoreMemo: () => void

Returns​

void

Inherited from​

BaseTool.createZoomPanMemo

Defined in​

tools/src/tools/base/BaseTool.ts:726


endGroupRecording()​

static endGroupRecording(): void

Ends a group recording of history memo

Returns​

void

Inherited from​

BaseTool.endGroupRecording

Defined in​

tools/src/tools/base/BaseTool.ts:784


findCachedStatsTargetId()​

protected static findCachedStatsTargetId(data, referencedId): string

Finds an existing cachedStats key for the given referenced volume id, if statistics were already computed for that volume - the keys are view reference ids of the form volumeId:<volumeId>?..., so entries created by other viewports (with a different slice/orientation) still match.

Parameters​

• data: AnnotationData

• referencedId: string

Returns​

string

Inherited from​

BaseTool.findCachedStatsTargetId

Defined in​

tools/src/tools/base/BaseTool.ts:660


getExemplarInstance()​

protected static getExemplarInstance(imageIds?): Record<string, unknown>

Resolves an exemplar (first) instance - naturalized DICOM metadata - from the image ids of a display set/volume, when available.

Parameters​

• imageIds?: string[]

Returns​

Record<string, unknown>

Inherited from​

BaseTool.getExemplarInstance

Defined in​

tools/src/tools/base/BaseTool.ts:643


getViewportDisplaySets()​

protected static getViewportDisplaySets(viewport): object[]

Resolves the display sets a viewport is displaying, when known. Viewports displaying registered display sets (see setDisplaySets on the generic viewports) resolve through the displaySetModule metadata (an IDisplaySet from @cornerstonejs/metadata) falling back to the generic viewport display set registration; legacy viewports (setStack with plain image ids) have no display set, so an empty list is returned and their candidates carry no display set fields.

Parameters​

• viewport: Viewport

Returns​

object[]

Inherited from​

BaseTool.getViewportDisplaySets

Defined in​

tools/src/tools/base/BaseTool.ts:572


isInsideVolume()​

static isInsideVolume(dimensions, indexPoints): boolean

Return true if all the index points are within the dimensions provided.

Parameters​

• dimensions: any

• indexPoints: any

Returns​

boolean

Inherited from​

BaseTool.isInsideVolume

Defined in​

tools/src/tools/base/BaseTool.ts:816


isSpecifiedTargetId()​

static isSpecifiedTargetId(desiredVolumeId): (_viewport, __namedParameters) => any

A function generator to test if the target id is the desired one. Used for deciding which set of cached stats is appropriate to display for a given viewport.

This relies on the fact that the target id contains a substring which is the desired volume id when the target is a volume. It is also possible to use series query parameters such as /series/{seriesUID}/ to generate specific series selections within a stack viewport.

Parameters​

• desiredVolumeId: string

Returns​

Function

Parameters​

• _viewport: any

• __namedParameters

• __namedParameters.targetId: any

Returns​

any

Deprecated​

Use the targetsFilter configuration option with measurementTargetFilters.forId instead.

Inherited from​

BaseTool.isSpecifiedTargetId

Defined in​

tools/src/tools/base/BaseTool.ts:191


mergeDefaultProps()​

static mergeDefaultProps(defaultProps, additionalProps?): any

Does a deep merge of property options. Allows extending the default values for a child class.

Parameters​

• defaultProps = {}

this is a base set of defaults to merge into

• additionalProps?: any

the additional properties to merge into the default props

Returns​

any

defaultProps if additional props not defined, or a merge into a new object containing additionalProps adding onto and overriding defaultProps.

Inherited from​

BaseTool.mergeDefaultProps

Defined in​

tools/src/tools/base/BaseTool.ts:171


startGroupRecording()​

static startGroupRecording(): void

Starts a group recording of history memo, so that with a single undo you can undo multiple actions that are related to each other

Returns​

void

Inherited from​

BaseTool.startGroupRecording

Defined in​

tools/src/tools/base/BaseTool.ts:779