StackViewport
Hierarchy
- Viewport
- StackViewport
Implements
Index
Constructors
Properties
- _actors
- _suppressCameraModifiedEvents
- addActor
- addActors
- canvas
- canvasToWorld
- defaultOptions
- element
- getActor
- getActors
- getCamera
- getDefaultActor
- getImageData
- getRenderer
- getRotation
- id
- isDisabled
- modality
- options
- removeAllActors
- renderingEngineId
- resetCamera
- sHeight
- sWidth
- scaling
- setActors
- setCamera
- stackActorReInitialized
- suppressEvents
- sx
- sy
- type
- unsetColormap
- viewportStatus
- worldToCanvas
- CameraViewPresentation
- TransferViewPresentation
Accessors
Methods
- _getCorners
- _getEdges
- _getFocalPointForResetCamera
- _isInBounds
- _removeActor
- addImages
- addWidget
- calibrateSpacing
- clearDefaultProperties
- createVTKImageData
- customRenderViewportToCanvas
- errorCallback
- getActorByIndex
- getActorUIDByIndex
- getActorUIDs
- getCanvas
- getClippingPlanesForActor
- getCornerstoneImage
- getCurrentImageId
- getCurrentImageIdIndex
- getDefaultProperties
- getDisplayArea
- getFrameOfReferenceUID
- getImageDataMetadata
- getImageIds
- getImagePlaneReferenceData
- getLoaderImageOptions
- getNumberOfSlices
- getPan
- getProperties
- getReferenceId
- getRenderingEngine
- getTargetImageIdIndex
- getViewPresentation
- getViewReference
- getWidget
- getWidgets
- getZoom
- hasImageId
- hasImageURI
- isReferenceViewable
- loadImages
- removeActors
- removeWidgets
- render
- renderImageObject
- reset
- resetProperties
- resetToDefaultProperties
- resize
- scroll
- setDefaultProperties
- setDisplayArea
- setImageIdIndex
- setOptions
- setOrientationOfClippingPlanes
- setPan
- setProperties
- setRendered
- setStack
- setUseCPURendering
- setViewPresentation
- setViewReference
- setZoom
- successCallback
- triggerCameraModifiedEventIfNecessary
- updateCameraClippingPlanesAndRange
- updateRenderingPipeline
- boundsRadius
Constructors
constructor
Constructor for the StackViewport class
Parameters
props: ViewportInput
ViewportInput
Returns StackViewport
Properties
_actors
a Map containing the actor uid and actors
_suppressCameraModifiedEvents
informs if a new actor was added before a resetCameraClippingRange phase
publicaddActor
Type declaration
If the renderer is CPU based, throw an error. Otherwise, add the actor to the viewport
Parameters
actorEntry: ActorEntry
The ActorEntry object that was created by the user.
Returns void
publicaddActors
Type declaration
If the renderer is CPU based, throw an error. Otherwise, add a list of actors to the viewport
Parameters
actors: ActorEntry[]
An array of ActorEntry objects.
Returns void
readonlycanvas
an internal canvas that is created on the provided HTML element
publiccanvasToWorld
readonlydefaultOptions
Default options for the viewport which includes orientation, viewPlaneNormal and backgroundColor
readonlyelement
HTML element in DOM that is used for rendering the viewport
publicgetActor
Type declaration
If the renderer is CPU based, throw an error. Otherwise, it returns the actor entry for the given actor UID.
Parameters
actorUID: string
The unique ID of the actor you want to get.
Returns ActorEntry
An ActorEntry object.
publicgetActors
Type declaration
If the renderer is CPU based, throw an error. Otherwise, return the actors in the viewport
Returns ActorEntry[]
An array of ActorEntry objects.
publicgetCamera
Type declaration
If the user has selected CPU rendering, return the CPU camera, otherwise return the default camera
Returns ICamera
The camera object.
publicgetDefaultActor
Type declaration
If the renderer is CPU based, throw an error. Otherwise, return the default actor which is the first actor in the renderer.
Returns ActorEntry
An actor entry.
publicgetImageData
Type declaration
Returns the image and its properties that is being shown inside the stack viewport. It returns, the image dimensions, image direction, image scalar data, vtkImageData object, metadata, and scaling (e.g., PET suvbw)
Returns IImageData | CPUIImageData
IImageData: dimensions, direction, scalarData, vtkImageData, metadata, scaling
publicgetRenderer
Type declaration
If the renderer is CPU based, throw an error. Otherwise, returns the
vtkRenderer
responsible for rendering theViewport
.Returns any
The
vtkRenderer
for theViewport
.
publicgetRotation
Type declaration
Returns number
readonlyid
unique identifier for the viewport
publicisDisabled
if the viewport has been disabled
publicmodality
options
options for the viewport which includes orientation axis, backgroundColor and displayArea
publicremoveAllActors
Type declaration
It throws an error if the renderer is CPU based. Otherwise, it removes the actors from the viewport.
Returns void
readonlyrenderingEngineId
RenderingEngine id that the viewport belongs to
publicresetCamera
Type declaration
Centers Pan and resets the zoom for stack viewport.
Parameters
optionalresetPan: boolean
optionalresetZoom: boolean
Returns boolean
sHeight
sHeight of viewport on the offscreen canvas
sWidth
sWidth of viewport on the offscreen canvas
publicscaling
Scaling parameters
publicsetActors
Type declaration
If the renderer is CPU-based, throw an error; otherwise, set the actors in the viewport.
Parameters
actors: ActorEntry[]
An array of ActorEntry objects.
Returns void
publicsetCamera
Type declaration
Set the camera based on the provided camera object.
Parameters
cameraInterface: ICamera
The camera interface that will be used to render the scene.
optionalstoreAsInitialCamera: boolean
Returns void
publicstackActorReInitialized
readonlysuppressEvents
A flag representing if viewport methods should fire events or not
sx
sx of viewport on the offscreen canvas
sy
sy of viewport on the offscreen canvas
readonlytype
Type of viewport
publicunsetColormap
Type declaration
It sets the colormap to the default colormap.
Returns void
publicviewportStatus
Record the rendering status, mostly for testing purposes, but can also be useful for knowing things like whether the viewport is initialized
publicworldToCanvas
publicstaticreadonlyCameraViewPresentation
CameraViewPresentation is a view preentation selector that has all the camera related presentation selections, and would typically be used for choosing presentation information between two viewports showing the same type of orientation of a view, such as the CT, PT and fusion views in the same orientation view.
publicstaticreadonlyTransferViewPresentation
TransferViewPresentation is a view presentation selector that selects all the transfer function related attributes. It would typically be used for synchronizing different orientations of the same series, or for synchronizing two views of the same type of series such as a CT.
Accessors
staticuseCustomRenderingPipeline
Returns boolean
Methods
_getCorners
Parameters
bounds: number[]
Returns number[][]
_getEdges
Returns a list of edges for the imageData bounds, which are the cube edges in the case of volumeViewport edges. p1: front, bottom, left p2: front, top, left p3: back, bottom, left p4: back, top, left p5: front, bottom, right p6: front, top, right p7: back, bottom, right p8: back, top, right
Parameters
bounds: number[]
Bounds of the renderer
Returns [number[], number[]][]
Edges of the containing bounds
_getFocalPointForResetCamera
_isInBounds
Determines whether or not the 3D point position is inside the boundaries of the 3D imageData.
Parameters
point: Point3
3D coordinate
bounds: number[]
Bounds of the image
Returns boolean
boolean
_removeActor
Remove the actor from the viewport
Parameters
actorUID: string
The unique identifier for the actor.
Returns void
publicaddImages
This method is used to add images to the stack viewport. It takes an array of stack inputs, each containing an imageId and an actor UID. For each stack input, it retrieves the image from the cache and creates a VTK image data object. It then creates an actor mapper for the image data and adds it to the list of actors. Finally, it sets the actors for the stack viewport.
Parameters
stackInputs: IStackInput[]
An array of stack inputs, each containing an image ID and an actor UID.
Returns void
publicaddWidget
Parameters
widgetId: any
widget: any
Returns void
publiccalibrateSpacing
Calibrates the image with new metadata that has been added for imageId. To calibrate a viewport, you should add your calibration data manually to calibratedPixelSpacingMetadataProvider and call viewport.calibrateSpacing for it get applied.
Parameters
imageId: string
imageId to be calibrated
Returns void
publicclearDefaultProperties
Remove the global default properties of the viewport or remove default properties for an imageId if specified
Parameters
optionalimageId: string
If given, we remove the default properties only for this imageID, if not the global default properties will be removed
Returns void
createVTKImageData
Parameters
__namedParameters: Object
Returns vtkImageData
publiccustomRenderViewportToCanvas
Custom rendering pipeline for the rendering for the CPU fallback
Returns { canvas: HTMLCanvasElement; element: HTMLDivElement; renderingEngineId: string; viewportId: string; viewportStatus: ViewportStatus }
canvas: HTMLCanvasElement
element: HTMLDivElement
renderingEngineId: string
viewportId: string
viewportStatus: ViewportStatus
publicerrorCallback
Parameters
imageId: any
permanent: any
error: any
Returns void
publicgetActorByIndex
Get an actor by its index
Parameters
index: number
array index.
Returns ActorEntry
actorUID
publicgetActorUIDByIndex
Get an actor UID by its index
Parameters
index: number
array index.
Returns string
actorUID
publicgetActorUIDs
Returns an array of unique identifiers for all the actors in the viewport.
Returns string[]
An array of strings
publicgetCanvas
Gets the target output canvas for the
Viewport
.Returns HTMLCanvasElement
an HTMLCanvasElement.
publicgetClippingPlanesForActor
Method to get the clipping planes of a given actor
Parameters
optionalactorEntry: ActorEntry
The actor entry (a specific type you’ll define dependent on your code)
Returns vtkPlane[]
vtkPlanes - An array of vtkPlane objects associated with the given actor
publicgetCornerstoneImage
Returns the raw/loaded image being shown inside the stack viewport.
Returns IImage
publicgetCurrentImageId
Returns the currently rendered imageId
Returns string
string for imageId
publicgetCurrentImageIdIndex
Returns the index of the imageId being renderer
Returns number
currently shown imageId index
publicgetDefaultProperties
Retrieve the viewport default properties
Parameters
optionalimageId: string
If given, we retrieve the default properties of an image index if it exists If not given,we return the global properties of the viewport
Returns StackViewportProperties
viewport properties including voi, invert, interpolation type, rotation, flip
publicgetDisplayArea
returns the displayArea
Returns DisplayArea
publicgetFrameOfReferenceUID
Returns the frame of reference UID, if the image doesn’t have imagePlaneModule metadata, it returns undefined, otherwise, frameOfReferenceUID is returned.
Parameters
optionalsliceIndex: number
Returns string
frameOfReferenceUID : string representing frame of reference id
publicgetImageDataMetadata
Calculates image metadata based on the image object. It calculates normal axis for the images, and output image metadata
Parameters
image: IImage
stack image containing cornerstone image
Returns ImageDataMetaData
image metadata: bitsAllocated, number of components, origin, direction, dimensions, spacing, number of voxels.
publicgetImageIds
Returns the list of image Ids for the current viewport
Returns string[]
list of strings for image Ids
publicgetImagePlaneReferenceData
Gets the view reference data for a given image slice. This uses the image plane module to read a default focal point/normal, and also returns the referenced image id and the frame of reference uid.
Parameters
sliceIndex: number = ...
Returns ViewReference
publicgetLoaderImageOptions
Parameters
imageId: string
Returns { additionalDetails: { imageId: string; imageIdIndex: number }; preScale: { enabled: boolean }; priority: number; requestType: RequestType; targetBuffer: { type: string }; transferSyntaxUID: any; useNativeDataType: boolean; useRGBA: boolean }
additionalDetails: { imageId: string; imageIdIndex: number }
imageId: string
imageIdIndex: number
preScale: { enabled: boolean }
enabled: boolean
priority: number
requestType: RequestType
targetBuffer: { type: string }
type: string
transferSyntaxUID: any
useNativeDataType: boolean
useRGBA: boolean
publicgetNumberOfSlices
Gets the number of slices
Returns number
publicgetPan
publicgetProperties
Retrieve the viewport properties
Returns StackViewportProperties
viewport properties including voi, invert, interpolation type, rotation, flip
publicgetReferenceId
Returns the imageId string for the specified view, using the
imageId:<imageId>
URN format.Parameters
specifier: ViewReferenceSpecifier = {}
Returns string
publicgetRenderingEngine
Returns the rendering engine driving the
Viewport
.Returns default
The RenderingEngine instance.
publicgetTargetImageIdIndex
Returns the imageIdIndex that is targeted to be loaded, in case of debounced loading (with scroll), the targetImageIdIndex is the latest imageId index that is requested to be loaded but debounced.
Returns number
publicgetViewPresentation
Gets a view presentation information specifying HOW a viewport displays something, but not what is being displayed. See getViewReference to get information on WHAT is being displayed.
This is intended to have information on how an image is presented to the user, without specifying what image s displayed. All of this information is available externally, but this method combines the parts of this that are appropriate for remember or applying to other views, without necessarily needing to know what all the atributes are. That differs from methods like getCamera which fetch exact view details that are not likely to be identical between viewports as they change sizes or apply to different images.
Note that the results of this can be used on different viewports, for example, the pan values can be applied to a volume viewport showing a CT, and a stack viewport showing an ultrasound.
The selector allows choosing which view presentation attributes to return. Some default values are available from
Viewport.CameraViewPresentation
andViewport.TransferViewPresentation
Parameters
viewPresSel: ViewPresentationSelector = ...
select which attributes to display.
Returns ViewPresentation
publicgetViewReference
Gets a standard target to show this image instance. Returns undefined if the requested slice index is not available.
<b>Warning<b>If using sliceIndex for requeseting a specific reference, the slice index MUST come from the stack of image ids. Using slice index from a volume or from a different stack of images ids, EVEN if they contain the same set of images will result in random images being chosen.Parameters
viewRefSpecifier: ViewReferenceSpecifier = {}
Returns ViewReference
publicgetWidget
Parameters
id: any
Returns any
publicgetWidgets
Returns any[]
publicgetZoom
Returns a current zoom level relative to the initial parallel scale originally applied to the image. That is, on initial display, the zoom level is 1. Computed as a function of the camera.
Parameters
compareCamera: ICamera = ...
Returns number
publichasImageId
Returns true if the viewport contains the given imageId
Parameters
imageId: string
imageId
Returns boolean
boolean if imageId is in viewport
publichasImageURI
Returns true if the viewport contains the given imageURI (no data loader scheme)
Parameters
imageURI: string
imageURI
Returns boolean
boolean if imageURI is in viewport
publicisReferenceViewable
Checks to see if this target is or could be shown in this viewport
Parameters
viewRef: ViewReference
options: ReferenceCompatibleOptions = {}
Returns boolean
publicloadImages
Parameters
imageIds: string[]
listener: ImageLoadListener
Returns Promise<unknown>
publicremoveActors
Remove the actors with the given UIDs from the viewport
Parameters
actorUIDs: string[]
An array of actor UIDs to remove.
Returns void
publicremoveWidgets
Returns void
publicrender
Renders the
Viewport
using theRenderingEngine
.Returns void
publicrenderImageObject
Renders the given Cornerstone image object in the viewport. This method is intended to be used by utilities to render an individual image, rather than by applications that want to display a complete image stack. If you want to load and display a complete image stack, use the setStack method instead of this one.
The rendered image will appear in the viewport’s element. Use this method if you have other means of loading and the cornerstone image object is already available.
If you don’t understand the difference between this method and setStack, you probably want to use setStack.
Parameters
image: any
The Cornerstone image object to render.
Returns void
publicreset
Resets the options the
Viewport
‘sdefaultOptions
Parameters
immediate: boolean = false
If
true
, renders the viewport after the options are reset.
Returns void
publicresetProperties
Reset the viewport properties to the default values
Returns void
publicresetToDefaultProperties
Reset the viewport properties to the his default values if possible
Returns void
publicresize
Resizes the viewport - only used in CPU fallback for StackViewport. The GPU resizing happens inside the RenderingEngine.
Returns void
publicscroll
It scrolls the stack of imageIds by the delta amount provided. If the debounce flag is set, it will only scroll the stack if the delta is greater than the debounceThreshold which is 40 milliseconds by default.
Parameters
delta: number
number of indices to scroll, it can be positive or negative
debounce: boolean = true
whether to debounce the scroll event
loop: boolean = false
whether to loop the stack
Returns void
publicsetDefaultProperties
Update the default properties of the viewport and add properties by imageId if specified
Parameters
ViewportProperties: StackViewportProperties
The properties to set
optionalimageId: string
If given, we set the default properties only for this image index, if not the default properties will be set for all imageIds
Returns void
publicsetDisplayArea
Sets the camera to an initial bounds. If resetPan and resetZoom are true it places the focal point at the center of the volume (or slice); otherwise, only the camera zoom and camera Pan or Zoom is reset for the current view.
Parameters
displayArea: DisplayArea
The display area of interest.
suppressEvents: boolean = false
If true, don’t fire displayArea event.
Returns void
publicsetImageIdIndex
Loads the image based on the provided imageIdIndex. It is an Async function which returns a promise that resolves to the imageId.
Parameters
imageIdIndex: number
number represents imageId index in the list of provided imageIds in setStack
Returns Promise<string>
publicsetOptions
Sets new options and (TODO) applies them.
Parameters
options: ViewportInputOptions
The viewport options to set.
immediate: boolean = false
If
true
, renders the viewport after the options are set.
Returns void
publicsetOrientationOfClippingPlanes
publicsetPan
Sets the canvas pan value relative to the initial view position of 0,0 Modifies the camera to perform the pan.
Parameters
pan: Point2
storeAsInitialCamera: boolean = false
Returns void
publicsetProperties
Configures the properties of the viewport. This method allows customization of the viewport by setting attributes like VOI (Value of Interest), color inversion, interpolation type, and image rotation. If setProperties is called for the first time, the provided properties will become the default settings for all images in the stack in case the resetPropertiese need to be called
Parameters
properties: StackViewportProperties = {}
An object containing the properties to be set.
suppressEvents: boolean = false
A boolean value to control event suppression. If true, the related events will not be triggered. Default is false.
Returns void
publicsetRendered
Indicate that the image has been rendered. This will set the viewportStatus to RENDERED if there is image data available to actually be rendered - otherwise, the rendering simply showed the background image.
Returns void
publicsetStack
Sets the imageIds to be visualized inside the stack viewport. It accepts list of imageIds, the index of the first imageId to be viewed. It is a asynchronous function that returns a promise resolving to imageId being displayed in the stack viewport.
Parameters
imageIds: string[]
list of strings, that represents list of image Ids
currentImageIdIndex: number = 0
number representing the index of the initial image to be displayed
Returns Promise<string>
publicsetUseCPURendering
Parameters
value: boolean
Returns void
publicsetViewPresentation
Applies the display area, zoom, pan and rotation from the view presentation. No-op is viewPres isn’t defined.
Parameters
viewPres: ViewPresentation
Returns void
publicsetViewReference
Applies the view reference, which may navigate the slice index and apply other camera modifications. Assumes that the slice index is correct for this viewport
Parameters
viewRef: ViewReference
Returns void
publicsetZoom
Zooms the image using parallel scale by updating the camera value.
Parameters
value: number
The relative parallel scale to apply. It is relative to the initial offsets value.
storeAsInitialCamera: boolean = false
can be set to true to reset the camera after applying this zoom as the initial camera. A subsequent getZoom call will return “1”, but the zoom will have been applied.
Returns void
publicsuccessCallback
Parameters
imageId: any
image: any
Returns void
publictriggerCameraModifiedEventIfNecessary
publicupdateCameraClippingPlanesAndRange
Updates the camera’s clipping planes and range.
Returns void
publicupdateRenderingPipeline
Returns void
staticboundsRadius
Computes the bounds radius value
Parameters
bounds: number[]
Returns number
An object representing a single stack viewport, which is a camera looking into an internal viewport, and an associated target output
canvas
.StackViewports can be rendered using both GPU and a fallback CPU is the GPU is not available (or low performance). Read more about StackViewports in the documentation section of this website.