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
- VolumeCroppingControlTool - Companion tool for 2D viewport reference lines
- BaseTool - Base class providing core tool functionality
Extends
Constructors
new VolumeCroppingTool()
new VolumeCroppingTool(
toolProps,defaultToolProps):VolumeCroppingTool
Parameters
• toolProps: PublicToolProps = {}
• defaultToolProps: SharedToolProp = ...
Returns
Overrides
Defined in
tools/src/tools/VolumeCroppingTool.ts:238
Properties
_hasResolutionChanged
_hasResolutionChanged:
boolean=false
Flag tracking if rendering resolution has been modified during interaction
Defined in
tools/src/tools/VolumeCroppingTool.ts:205
_resizeObservers
_resizeObservers:
Map<any,any>
Map of ResizeObserver instances for viewport resize handling
Defined in
tools/src/tools/VolumeCroppingTool.ts:203
_viewportAddedListener()
_viewportAddedListener: (
evt) =>void
Event listener for new viewport additions
Parameters
• evt: any
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:204
cleanUp()
cleanUp: () =>
void
Cleanup function for resetting tool state after interactions
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:202
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
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:210
draggingSphereIndex
draggingSphereIndex:
number=null
Index of currently dragged sphere, null when not dragging
Defined in
tools/src/tools/VolumeCroppingTool.ts:207
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:229
faceDragOffset
faceDragOffset:
number=null
1D offset value for face sphere dragging along single axis
Defined in
tools/src/tools/VolumeCroppingTool.ts:211
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
Defined in
tools/src/tools/base/BaseTool.ts:121
memo
protectedmemo: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
Defined in
tools/src/tools/base/BaseTool.ts:127
mode
mode:
ToolModes
Tool Mode - Active/Passive/Enabled/Disabled/
Inherited from
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:201
originalClippingPlanes
originalClippingPlanes:
ClippingPlane[] =[]
Array of clipping plane objects with origin and normal vectors
Defined in
tools/src/tools/VolumeCroppingTool.ts:206
rotatePlanesOnDrag
rotatePlanesOnDrag:
boolean=false
If true, dragging rotates clipping planes instead of camera (default: false)
Defined in
tools/src/tools/VolumeCroppingTool.ts:208
seriesInstanceUID?
optionalseriesInstanceUID:string
Frame of reference for the tool
Defined in
tools/src/tools/VolumeCroppingTool.ts:199
sphereStates
sphereStates:
object[] =[]
Array of sphere state objects containing position, VTK actors, and metadata
Defined in
tools/src/tools/VolumeCroppingTool.ts:219
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:209
toolGroupId
toolGroupId:
string
ToolGroup ID the tool instance belongs to
Inherited from
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:200
volumeDirectionVectors
volumeDirectionVectors:
object=null
xDir
xDir:
Point3
yDir
yDir:
Point3
zDir
zDir:
Point3
Defined in
tools/src/tools/VolumeCroppingTool.ts:213
activeCursorTool
staticactiveCursorTool: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
Defined in
tools/src/tools/base/BaseTool.ts:54
defaults
staticdefaults: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
Defined in
tools/src/tools/base/BaseTool.ts:132
MOUSE_PROXIMITY
readonlystaticMOUSE_PROXIMITY:6
Canvas-pixel radius used to hit-test annotations and handles for mouse interactions.
Inherited from
Defined in
tools/src/tools/base/BaseTool.ts:69
toolName
statictoolName:any
Static tool identifier: 'VolumeCropping'
Overrides
Defined in
tools/src/tools/VolumeCroppingTool.ts:198
TOUCH_PROXIMITY
readonlystaticTOUCH_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
Defined in
tools/src/tools/base/BaseTool.ts:63
TOUCH_TAP_MAX_CANVAS_DISTANCE
readonlystaticTOUCH_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
readonlystaticTOUCH_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
getconfigurationTyped():ToolConfiguration
Returns
Inherited from
Defined in
tools/src/tools/base/BaseTool.ts:112
toolName
gettoolName():string
Newer method for getting the tool name as a property
Returns
string
Inherited from
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:1060
_applyClippingPlanesToMapper()
_applyClippingPlanesToMapper(
mapper):void
Parameters
• mapper: vtkVolumeMapper
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:1408
_averagePoints()
_averagePoints(
points):Point3
Parameters
• points: Point3[]
Returns
Point3
Defined in
tools/src/tools/VolumeCroppingTool.ts:2109
_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:2140
_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:2171
_dragCallback()
_dragCallback(
evt):void
Parameters
• evt: InteractionEventType
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:730
_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:1121
_getDirectionVectors()
_getDirectionVectors():
object
Returns
object
xDir
xDir:
Point3
yDir
yDir:
Point3
zDir
zDir:
Point3
Defined in
tools/src/tools/VolumeCroppingTool.ts:2061
_getViewport()
_getViewport():
VolumeViewport
Returns
VolumeViewport
Defined in
tools/src/tools/VolumeCroppingTool.ts:1380
_getViewportAndWorldCoords()
_getViewportAndWorldCoords(
evt):object
Parameters
• evt: any
Returns
object
viewport
viewport:
VolumeViewport
world
world:
Point3
Defined in
tools/src/tools/VolumeCroppingTool.ts:1371
_getViewportsInfo()
_getViewportsInfo():
any[]
Returns
any[]
Defined in
tools/src/tools/VolumeCroppingTool.ts:1055
_getVolumeActor()
_getVolumeActor(
viewport?):vtkVolume
Parameters
• viewport?: VolumeViewport
Returns
vtkVolume
Defined in
tools/src/tools/VolumeCroppingTool.ts:1391
_getVolumeMapper()
_getVolumeMapper(
viewport?):vtkVolumeMapper
Parameters
• viewport?: VolumeViewport
Returns
vtkVolumeMapper
Defined in
tools/src/tools/VolumeCroppingTool.ts:1401
_initialize3DViewports()
_initialize3DViewports(
viewportsInfo):void
Parameters
• viewportsInfo: IViewportId[]
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:1165
_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
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:2121
_onControlToolChange()
_onControlToolChange(
evt):void
Parameters
• evt: any
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:949
_onMouseMoveSphere()
_onMouseMoveSphere(
evt):boolean
Parameters
• evt: any
Returns
boolean
Defined in
tools/src/tools/VolumeCroppingTool.ts:816
_onNewVolume()
_onNewVolume():
void
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:1739
_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:2204
_rotateClippingPlanes()
_rotateClippingPlanes(
evt):void
Parameters
• evt: InteractionEventType
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:1777
_subscribeToViewportNewVolumeSet()
_subscribeToViewportNewVolumeSet(
viewports):void
Parameters
• viewports: any
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:1762
_unsubscribeToViewportNewVolumeSet()
_unsubscribeToViewportNewVolumeSet(
viewportsInfo):void
Parameters
• viewportsInfo: any
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:1747
_updateClippingPlanes()
_updateClippingPlanes(
viewport):void
Parameters
• viewport: any
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:980
_updateClippingPlanesFromFaceSpheres()
_updateClippingPlanesFromFaceSpheres(
viewport):void
Parameters
• viewport: any
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:1427
_updateCornerSpheres()
_updateCornerSpheres():
void
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:1625
_updateCornerSpheresFromFaces()
_updateCornerSpheresFromFaces():
void
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:1455
_updateEdgeLines()
_updateEdgeLines():
void
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:2190
_updateFaceSpheresFromClippingPlanes()
_updateFaceSpheresFromClippingPlanes():
void
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:2091
_updateFaceSpheresFromCorners()
_updateFaceSpheresFromCorners():
void
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:1566
_updateHandlesVisibility()
_updateHandlesVisibility():
void
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:1039
_updateSpherePosition()
_updateSpherePosition(
sphereIndex,newPoint):void
Parameters
• sphereIndex: number
• newPoint: Point3
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:2082
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
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
Defined in
tools/src/tools/base/BaseTool.ts:771
ensureCachedStatsTargets()
protectedensureCachedStatsTargets(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) {
console.log('Volume is currently being cropped');
} else {
console.log('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:631
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) {
console.log('Cropping handles are currently shown');
} else {
console.log('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:579
getMeasurementTargetCandidates()
protectedgetMeasurementTargetCandidates(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
Inherited from
BaseTool.getMeasurementTargetCandidates
Defined in
tools/src/tools/base/BaseTool.ts:498
getMeasurementTargets()
protectedgetMeasurementTargets(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) {
console.log('Dragging will rotate clipping planes');
} else {
console.log('Dragging will rotate camera');
}
Defined in
tools/src/tools/VolumeCroppingTool.ts:696
getTargetId()
protectedgetTargetId(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
Defined in
tools/src/tools/base/BaseTool.ts:397
getTargetImageData()
protectedgetTargetImageData(targetId):IImageData|CPUIImageData
Parameters
• targetId: string
Returns
IImageData | CPUIImageData
Inherited from
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
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:382
onSetToolActive()
onSetToolActive():
void
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:270
onSetToolConfiguration()
onSetToolConfiguration():
void
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:355
onSetToolDisabled()
onSetToolDisabled():
void
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:363
onSetToolEnabled()
onSetToolEnabled():
void
Returns
void
Defined in
tools/src/tools/VolumeCroppingTool.ts:359
preMouseDownCallback()
preMouseDownCallback(
evt):boolean
Parameters
• evt: InteractionEventType
Returns
boolean
Defined in
tools/src/tools/VolumeCroppingTool.ts:391
redo()
redo():
void
Redo an action (undo the undo)
Returns
void
Inherited from
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
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:660
setConfiguration()
setConfiguration(
newConfiguration):void
merges the new configuration with the tool configuration
Parameters
• newConfiguration: Record<string, any>
Returns
void
Inherited from
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:588
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:541
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:722
undo()
undo():
void
Undoes an action
Returns
void
Inherited from
Defined in
tools/src/tools/base/BaseTool.ts:708
calculateLengthInIndex()
staticcalculateLengthInIndex(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()
staticcreateZoomPanMemo(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
Defined in
tools/src/tools/base/BaseTool.ts:726
endGroupRecording()
staticendGroupRecording():void
Ends a group recording of history memo
Returns
void
Inherited from
Defined in
tools/src/tools/base/BaseTool.ts:784
findCachedStatsTargetId()
protectedstaticfindCachedStatsTargetId(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()
protectedstaticgetExemplarInstance(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
Defined in
tools/src/tools/base/BaseTool.ts:643
getViewportDisplaySets()
protectedstaticgetViewportDisplaySets(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()
staticisInsideVolume(dimensions,indexPoints):boolean
Return true if all the index points are within the dimensions provided.
Parameters
• dimensions: any
• indexPoints: any
Returns
boolean
Inherited from
Defined in
tools/src/tools/base/BaseTool.ts:816
isSpecifiedTargetId()
staticisSpecifiedTargetId(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
Defined in
tools/src/tools/base/BaseTool.ts:191
mergeDefaultProps()
staticmergeDefaultProps(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
Defined in
tools/src/tools/base/BaseTool.ts:171
startGroupRecording()
staticstartGroupRecording():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