@cornerstonejs/core 2.0.0-beta.20 → 2.0.0-beta.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/RenderingEngine/BaseVolumeViewport.d.ts +23 -13
- package/dist/esm/RenderingEngine/BaseVolumeViewport.js +52 -50
- package/dist/esm/RenderingEngine/CanvasActor/CanvasMapper.d.ts +1 -1
- package/dist/esm/RenderingEngine/CanvasActor/CanvasProperties.d.ts +1 -1
- package/dist/esm/RenderingEngine/CanvasActor/index.js +2 -1
- package/dist/esm/RenderingEngine/RenderingEngine.d.ts +8 -10
- package/dist/esm/RenderingEngine/RenderingEngine.js +20 -18
- package/dist/esm/RenderingEngine/StackViewport.d.ts +28 -19
- package/dist/esm/RenderingEngine/StackViewport.js +81 -58
- package/dist/esm/RenderingEngine/VideoViewport.d.ts +19 -28
- package/dist/esm/RenderingEngine/VideoViewport.js +61 -24
- package/dist/esm/RenderingEngine/Viewport.d.ts +25 -14
- package/dist/esm/RenderingEngine/Viewport.js +24 -15
- package/dist/esm/RenderingEngine/VolumeViewport.d.ts +21 -9
- package/dist/esm/RenderingEngine/VolumeViewport.js +95 -10
- package/dist/esm/RenderingEngine/VolumeViewport3D.d.ts +3 -3
- package/dist/esm/RenderingEngine/VolumeViewport3D.js +10 -3
- package/dist/esm/RenderingEngine/WSIViewport.d.ts +58 -0
- package/dist/esm/RenderingEngine/WSIViewport.js +414 -0
- package/dist/esm/RenderingEngine/helpers/addImageSlicesToViewports.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/addImageSlicesToViewports.js +3 -3
- package/dist/esm/RenderingEngine/helpers/addVolumesToViewports.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/colors/colormap.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/colors/colormap.js +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/colors/lookupTable.d.ts +2 -2
- package/dist/esm/RenderingEngine/helpers/cpuFallback/colors/lookupTable.js +15 -5
- package/dist/esm/RenderingEngine/helpers/cpuFallback/drawImageSync.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/calculateTransform.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/canvasToPixel.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/correctShift.d.ts +3 -3
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/createViewport.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/doesImageNeedToBeRendered.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/fitToWindow.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/generateColorLUT.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/generateColorLUT.js +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/generateLut.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/generateLut.js +2 -2
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/getDefaultViewport.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/getImageFitScale.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/getImageSize.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/getLut.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/getLut.js +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/getTransform.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/initializeRenderCanvas.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/lutMatches.d.ts +2 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/lutMatches.js +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/pixelToCanvas.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/renderColorImage.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/renderColorImage.js +3 -4
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/renderGrayscaleImage.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/renderGrayscaleImage.js +2 -3
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/renderPseudoColorImage.js +3 -3
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/resetCamera.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/resize.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/saveLastRendered.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/setDefaultViewport.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/setToPixelCoordinateSystem.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/storedColorPixelDataToCanvasImageData.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/storedColorPixelDataToCanvasImageData.js +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/storedPixelDataToCanvasImageData.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/storedPixelDataToCanvasImageData.js +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/storedPixelDataToCanvasImageDataColorLUT.js +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/storedPixelDataToCanvasImageDataPET.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/storedPixelDataToCanvasImageDataPET.js +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/storedPixelDataToCanvasImageDataPseudocolorLUT.js +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/storedPixelDataToCanvasImageDataPseudocolorLUTPET.js +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/storedPixelDataToCanvasImageDataRGBA.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/storedPixelDataToCanvasImageDataRGBA.js +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/storedRGBAPixelDataToCanvasImageData.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/storedRGBAPixelDataToCanvasImageData.js +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/transform.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/cpuFallback/rendering/validator.d.ts +2 -2
- package/dist/esm/RenderingEngine/helpers/createVolumeActor.d.ts +3 -3
- package/dist/esm/RenderingEngine/helpers/createVolumeActor.js +4 -7
- package/dist/esm/RenderingEngine/helpers/createVolumeMapper.d.ts +4 -1
- package/dist/esm/RenderingEngine/helpers/getOrCreateCanvas.js +5 -4
- package/dist/esm/RenderingEngine/helpers/setDefaultVolumeVOI.d.ts +2 -2
- package/dist/esm/RenderingEngine/helpers/setDefaultVolumeVOI.js +13 -37
- package/dist/esm/RenderingEngine/helpers/setVolumesForViewports.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/viewportTypeToViewportClass.d.ts +2 -0
- package/dist/esm/RenderingEngine/helpers/viewportTypeToViewportClass.js +2 -0
- package/dist/esm/RenderingEngine/helpers/volumeNewImageEventDispatcher.d.ts +1 -1
- package/dist/esm/RenderingEngine/helpers/volumeNewImageEventDispatcher.js +4 -4
- package/dist/esm/RenderingEngine/renderingEngineCache.d.ts +1 -1
- package/dist/esm/RenderingEngine/vtkClasses/vtkSlabCamera.d.ts +4 -2
- package/dist/esm/RenderingEngine/vtkClasses/vtkStreamingOpenGLTexture.js +87 -78
- package/dist/esm/RenderingEngine/vtkClasses/vtkStreamingOpenGLViewNodeFactory.js +1 -1
- package/dist/esm/RenderingEngine/vtkClasses/vtkStreamingOpenGLVolumeMapper.js +83 -42
- package/dist/esm/Settings.d.ts +1 -1
- package/dist/esm/cache/cache.d.ts +15 -19
- package/dist/esm/cache/cache.js +112 -57
- package/dist/esm/cache/classes/Contour.d.ts +4 -4
- package/dist/esm/cache/classes/ContourSet.d.ts +3 -3
- package/dist/esm/cache/classes/ImageVolume.d.ts +19 -19
- package/dist/esm/cache/classes/ImageVolume.js +49 -254
- package/dist/esm/cache/classes/Surface.d.ts +3 -3
- package/dist/esm/cache/index.d.ts +1 -2
- package/dist/esm/cache/index.js +1 -2
- package/dist/esm/constants/cpuColormaps.d.ts +1 -1
- package/dist/esm/constants/viewportPresets.d.ts +1 -1
- package/dist/esm/enums/GenerateImageType.d.ts +5 -0
- package/dist/esm/enums/GenerateImageType.js +6 -0
- package/dist/esm/enums/MetadataModules.d.ts +2 -1
- package/dist/esm/enums/MetadataModules.js +1 -0
- package/dist/esm/enums/ViewportType.d.ts +2 -1
- package/dist/esm/enums/ViewportType.js +1 -0
- package/dist/esm/enums/index.d.ts +2 -2
- package/dist/esm/enums/index.js +2 -2
- package/dist/esm/eventTarget.js +2 -3
- package/dist/esm/getEnabledElement.d.ts +1 -1
- package/dist/esm/global.d.ts +0 -1
- package/dist/esm/index.d.ts +9 -5
- package/dist/esm/index.js +8 -4
- package/dist/esm/init.d.ts +5 -8
- package/dist/esm/init.js +22 -83
- package/dist/esm/loaders/ProgressiveRetrieveImages.d.ts +5 -5
- package/dist/esm/loaders/ProgressiveRetrieveImages.js +7 -3
- package/dist/esm/loaders/configuration/interleavedRetrieve.d.ts +1 -1
- package/dist/esm/loaders/fillNearbyFrames.d.ts +2 -2
- package/dist/esm/loaders/geometryLoader.d.ts +3 -3
- package/dist/esm/loaders/geometryLoader.js +1 -1
- package/dist/esm/loaders/imageLoader.d.ts +12 -17
- package/dist/esm/loaders/imageLoader.js +179 -96
- package/dist/esm/loaders/utils/contourSet/createContourSet.d.ts +1 -1
- package/dist/esm/loaders/utils/contourSet/validateContourSet.d.ts +1 -1
- package/dist/esm/loaders/utils/surface/createSurface.d.ts +1 -1
- package/dist/esm/loaders/utils/surface/validateSurface.d.ts +1 -1
- package/dist/esm/loaders/volumeLoader.d.ts +15 -22
- package/dist/esm/loaders/volumeLoader.js +88 -207
- package/dist/esm/metaData.d.ts +2 -4
- package/dist/esm/requestPool/requestPoolManager.d.ts +7 -9
- package/dist/esm/requestPool/requestPoolManager.js +1 -1
- package/dist/esm/types/AABB2.d.ts +2 -2
- package/dist/esm/types/AABB3.d.ts +2 -2
- package/dist/esm/types/ActorSliceRange.d.ts +5 -5
- package/dist/esm/types/BoundsIJK.d.ts +1 -1
- package/dist/esm/types/BoundsLPS.d.ts +1 -1
- package/dist/esm/types/CPUFallbackColormap.d.ts +3 -3
- package/dist/esm/types/CPUFallbackColormapData.d.ts +4 -4
- package/dist/esm/types/CPUFallbackColormapsData.d.ts +3 -5
- package/dist/esm/types/CPUFallbackEnabledElement.d.ts +2 -37
- package/dist/esm/types/CPUFallbackLUT.d.ts +4 -3
- package/dist/esm/types/CPUFallbackLookupTable.d.ts +2 -2
- package/dist/esm/types/CPUFallbackRenderingTools.d.ts +5 -5
- package/dist/esm/types/CPUFallbackTransform.d.ts +3 -3
- package/dist/esm/types/CPUFallbackViewport.d.ts +6 -6
- package/dist/esm/types/CPUFallbackViewportDisplayedArea.d.ts +3 -3
- package/dist/esm/types/CPUIImageData.d.ts +17 -9
- package/dist/esm/types/Color.d.ts +1 -1
- package/dist/esm/types/Colormap.d.ts +7 -7
- package/dist/esm/types/ContourData.d.ts +6 -6
- package/dist/esm/types/Cornerstone3DConfig.d.ts +7 -7
- package/dist/esm/types/CustomEventType.d.ts +2 -2
- package/dist/esm/types/EventTypes.d.ts +55 -55
- package/dist/esm/types/FlipDirection.d.ts +3 -3
- package/dist/esm/types/IActor.d.ts +3 -3
- package/dist/esm/types/ICache.d.ts +4 -4
- package/dist/esm/types/ICachedGeometry.d.ts +3 -3
- package/dist/esm/types/ICachedImage.d.ts +3 -2
- package/dist/esm/types/ICachedVolume.d.ts +3 -2
- package/dist/esm/types/ICamera.d.ts +3 -3
- package/dist/esm/types/IContour.d.ts +4 -3
- package/dist/esm/types/IContourSet.d.ts +5 -2
- package/dist/esm/types/IDynamicImageVolume.d.ts +3 -3
- package/dist/esm/types/IEnabledElement.d.ts +2 -2
- package/dist/esm/types/IGeometry.d.ts +4 -4
- package/dist/esm/types/IImage.d.ts +48 -11
- package/dist/esm/types/IImageCalibration.d.ts +2 -2
- package/dist/esm/types/IImageData.d.ts +11 -4
- package/dist/esm/types/IImageFrame.d.ts +42 -0
- package/dist/esm/types/IImageFrame.js +1 -0
- package/dist/esm/types/IImageVolume.d.ts +17 -14
- package/dist/esm/types/ILoadObject.d.ts +3 -3
- package/dist/esm/types/IPointsManager.d.ts +23 -0
- package/dist/esm/types/IPointsManager.js +1 -0
- package/dist/esm/types/IRLEVoxelMap.d.ts +16 -0
- package/dist/esm/types/IRLEVoxelMap.js +1 -0
- package/dist/esm/types/IRegisterImageLoader.d.ts +2 -2
- package/dist/esm/types/IRenderingEngine.d.ts +11 -12
- package/dist/esm/types/IRetrieveConfiguration.d.ts +6 -6
- package/dist/esm/types/IStackInput.d.ts +1 -1
- package/dist/esm/types/IStackViewport.d.ts +69 -2
- package/dist/esm/types/IStreamingImageVolume.d.ts +3 -4
- package/dist/esm/types/IStreamingVolumeProperties.d.ts +5 -5
- package/dist/esm/types/ISurface.d.ts +1 -1
- package/dist/esm/types/ITransferFunctionNode.d.ts +9 -0
- package/dist/esm/types/ITransferFunctionNode.js +1 -0
- package/dist/esm/types/IVideoViewport.d.ts +40 -2
- package/dist/esm/types/IViewport.d.ts +62 -41
- package/dist/esm/types/IVolume.d.ts +2 -2
- package/dist/esm/types/IVolumeInput.d.ts +2 -2
- package/dist/esm/types/IVolumeViewport.d.ts +17 -16
- package/dist/esm/types/IVoxelManager.d.ts +54 -0
- package/dist/esm/types/IVoxelManager.js +1 -0
- package/dist/esm/types/IWSIViewport.d.ts +16 -0
- package/dist/esm/types/IWSIViewport.js +1 -0
- package/dist/esm/types/ImageLoadListener.d.ts +2 -2
- package/dist/esm/types/ImageLoaderFn.d.ts +3 -3
- package/dist/esm/types/ImagePixelModule.d.ts +1 -1
- package/dist/esm/types/ImagePlaneModule.d.ts +2 -2
- package/dist/esm/types/ImageSliceData.d.ts +3 -3
- package/dist/esm/types/ImageVolumeProps.d.ts +4 -4
- package/dist/esm/types/Mat3.d.ts +1 -1
- package/dist/esm/types/Metadata.d.ts +6 -6
- package/dist/esm/types/MetadataModuleTypes.d.ts +65 -0
- package/dist/esm/types/MetadataModuleTypes.js +1 -0
- package/dist/esm/types/OrientationVectors.d.ts +4 -4
- package/dist/esm/types/Plane.d.ts +1 -1
- package/dist/esm/types/Point2.d.ts +1 -1
- package/dist/esm/types/Point3.d.ts +3 -3
- package/dist/esm/types/Point4.d.ts +1 -1
- package/dist/esm/types/RGB.d.ts +1 -1
- package/dist/esm/types/ScalingParameters.d.ts +7 -7
- package/dist/esm/types/StackViewportProperties.d.ts +3 -3
- package/dist/esm/types/SurfaceData.d.ts +5 -5
- package/dist/esm/types/TransformMatrix2D.d.ts +1 -1
- package/dist/esm/types/VideoViewportProperties.d.ts +3 -3
- package/dist/esm/types/VideoViewportTypes.d.ts +7 -7
- package/dist/esm/types/ViewportInputOptions.d.ts +7 -7
- package/dist/esm/types/ViewportPreset.d.ts +1 -1
- package/dist/esm/types/ViewportProperties.d.ts +5 -5
- package/dist/esm/types/VolumeLoaderFn.d.ts +4 -3
- package/dist/esm/types/VolumeProps.d.ts +10 -5
- package/dist/esm/types/VolumeViewportProperties.d.ts +3 -3
- package/dist/esm/types/WSIViewportProperties.d.ts +3 -0
- package/dist/esm/types/WSIViewportProperties.js +1 -0
- package/dist/esm/types/WSIViewportTypes.d.ts +13 -0
- package/dist/esm/types/WSIViewportTypes.js +1 -0
- package/dist/esm/types/displayArea.d.ts +4 -4
- package/dist/esm/types/index.d.ts +16 -8
- package/dist/esm/types/voi.d.ts +4 -4
- package/dist/esm/utilities/PointsManager.d.ts +8 -10
- package/dist/esm/utilities/ProgressiveIterator.d.ts +1 -1
- package/dist/esm/utilities/ProgressiveIterator.js +3 -1
- package/dist/esm/utilities/RLEVoxelMap.d.ts +3 -8
- package/dist/esm/utilities/RLEVoxelMap.js +19 -19
- package/dist/esm/utilities/VoxelManager.d.ts +82 -20
- package/dist/esm/utilities/VoxelManager.js +466 -60
- package/dist/esm/utilities/actorCheck.d.ts +1 -1
- package/dist/esm/utilities/applyPreset.d.ts +2 -2
- package/dist/esm/utilities/calculateViewportsSpatialRegistration.d.ts +1 -1
- package/dist/esm/utilities/calculateViewportsSpatialRegistration.js +5 -5
- package/dist/esm/utilities/calibratedPixelSpacingMetadataProvider.d.ts +1 -1
- package/dist/esm/utilities/colormap.d.ts +1 -1
- package/dist/esm/utilities/convertStackToVolumeViewport.d.ts +2 -2
- package/dist/esm/utilities/convertStackToVolumeViewport.js +4 -4
- package/dist/esm/utilities/convertVolumeToStackViewport.d.ts +1 -1
- package/dist/esm/utilities/convertVolumeToStackViewport.js +3 -2
- package/dist/esm/utilities/createLinearRGBTransferFunction.d.ts +1 -1
- package/dist/esm/utilities/createLinearRGBTransferFunction.js +1 -3
- package/dist/esm/utilities/createSigmoidRGBTransferFunction.d.ts +2 -3
- package/dist/esm/utilities/createSigmoidRGBTransferFunction.js +8 -7
- package/dist/esm/utilities/decimate.d.ts +1 -1
- package/dist/esm/utilities/eventListener/TargetEventListeners.js +5 -3
- package/dist/esm/utilities/generateVolumePropsFromImageIds.d.ts +1 -1
- package/dist/esm/utilities/generateVolumePropsFromImageIds.js +33 -80
- package/dist/esm/utilities/genericMetadataProvider.d.ts +9 -2
- package/dist/esm/utilities/genericMetadataProvider.js +7 -1
- package/dist/esm/utilities/getBufferConfiguration.d.ts +2 -3
- package/dist/esm/utilities/getBufferConfiguration.js +5 -15
- package/dist/esm/utilities/getClosestImageId.js +1 -1
- package/dist/esm/utilities/getClosestStackImageIndexForPoint.d.ts +1 -1
- package/dist/esm/utilities/getClosestStackImageIndexForPoint.js +2 -2
- package/dist/esm/utilities/getCurrentVolumeViewportSlice.d.ts +4 -5
- package/dist/esm/utilities/getCurrentVolumeViewportSlice.js +8 -58
- package/dist/esm/utilities/getImageLegacy.d.ts +1 -1
- package/dist/esm/utilities/getImageLegacy.js +1 -1
- package/dist/esm/utilities/getImageSliceDataForVolumeViewport.d.ts +1 -1
- package/dist/esm/utilities/getMinMax.d.ts +2 -1
- package/dist/esm/utilities/getScalingParameters.d.ts +1 -1
- package/dist/esm/utilities/getScalingParameters.js +4 -4
- package/dist/esm/utilities/getSpacingInNormalDirection.d.ts +2 -2
- package/dist/esm/utilities/getTargetVolumeAndSpacingInNormalDir.d.ts +1 -1
- package/dist/esm/utilities/getTargetVolumeAndSpacingInNormalDir.js +2 -2
- package/dist/esm/utilities/getViewportImageCornersInWorld.d.ts +1 -1
- package/dist/esm/utilities/getViewportImageIds.d.ts +1 -1
- package/dist/esm/utilities/getViewportImageIds.js +1 -1
- package/dist/esm/utilities/getViewportModality.d.ts +7 -3
- package/dist/esm/utilities/getViewportModality.js +9 -6
- package/dist/esm/utilities/getViewportsWithImageURI.d.ts +2 -2
- package/dist/esm/utilities/getViewportsWithVolumeId.d.ts +2 -2
- package/dist/esm/utilities/getViewportsWithVolumeId.js +3 -7
- package/dist/esm/utilities/getVoiFromSigmoidRGBTransferFunction.d.ts +1 -1
- package/dist/esm/utilities/getVolumeActorCorners.d.ts +2 -2
- package/dist/esm/utilities/getVolumeId.js +2 -2
- package/dist/esm/utilities/getVolumeSliceRangeInfo.d.ts +1 -1
- package/dist/esm/utilities/getVolumeViewportScrollInfo.d.ts +1 -1
- package/dist/esm/utilities/getVolumeViewportsContainingSameVolumes.d.ts +2 -2
- package/dist/esm/utilities/hasFloatScalingParameters.d.ts +1 -1
- package/dist/esm/utilities/imageRetrieveMetadataProvider.d.ts +1 -1
- package/dist/esm/utilities/imageToWorldCoords.d.ts +1 -1
- package/dist/esm/utilities/imageToWorldCoords.js +2 -2
- package/dist/esm/utilities/index.d.ts +3 -8
- package/dist/esm/utilities/index.js +4 -8
- package/dist/esm/utilities/indexWithinDimensions.d.ts +1 -1
- package/dist/esm/utilities/invertRgbTransferFunction.d.ts +2 -1
- package/dist/esm/utilities/isEqual.js +6 -1
- package/dist/esm/utilities/isPTPrescaledWithSUV.d.ts +1 -1
- package/dist/esm/utilities/isPTPrescaledWithSUV.js +1 -1
- package/dist/esm/utilities/isValidVolume.js +1 -1
- package/dist/esm/utilities/loadImageToCanvas.d.ts +6 -6
- package/dist/esm/utilities/loadImageToCanvas.js +1 -1
- package/dist/esm/utilities/makeVolumeMetadata.d.ts +2 -2
- package/dist/esm/utilities/makeVolumeMetadata.js +5 -5
- package/dist/esm/utilities/planar.d.ts +2 -2
- package/dist/esm/utilities/renderToCanvasCPU.d.ts +1 -1
- package/dist/esm/utilities/renderToCanvasGPU.d.ts +2 -2
- package/dist/esm/utilities/renderToCanvasGPU.js +1 -1
- package/dist/esm/utilities/scaleRgbTransferFunction.d.ts +2 -1
- package/dist/esm/utilities/snapFocalPointToSlice.d.ts +1 -1
- package/dist/esm/utilities/sortImageIdsAndGetSpacing.d.ts +5 -5
- package/dist/esm/utilities/sortImageIdsAndGetSpacing.js +2 -1
- package/dist/esm/utilities/transformCanvasToIJK.d.ts +2 -2
- package/dist/esm/utilities/transformIJKToCanvas.d.ts +1 -1
- package/dist/esm/utilities/triggerEvent.js +1 -1
- package/dist/esm/utilities/updateVTKImageDataWithCornerstoneImage.d.ts +2 -2
- package/dist/esm/utilities/updateVTKImageDataWithCornerstoneImage.js +1 -1
- package/dist/esm/utilities/uuidv4.js +3 -1
- package/dist/esm/utilities/worldToImageCoords.d.ts +1 -1
- package/dist/esm/utilities/worldToImageCoords.js +2 -2
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +6 -6
- package/dist/esm/cache/utils/restoreImagesFromBuffer.d.ts +0 -2
- package/dist/esm/cache/utils/restoreImagesFromBuffer.js +0 -28
- package/dist/esm/enums/SharedArrayBufferModes.d.ts +0 -6
- package/dist/esm/enums/SharedArrayBufferModes.js +0 -7
- package/dist/esm/utilities/cacheUtils.d.ts +0 -2
- package/dist/esm/utilities/cacheUtils.js +0 -86
- package/dist/esm/utilities/createFloat32SharedArray.d.ts +0 -2
- package/dist/esm/utilities/createFloat32SharedArray.js +0 -27
- package/dist/esm/utilities/createInt16SharedArray.d.ts +0 -2
- package/dist/esm/utilities/createInt16SharedArray.js +0 -11
- package/dist/esm/utilities/createUInt16SharedArray.d.ts +0 -2
- package/dist/esm/utilities/createUInt16SharedArray.js +0 -11
- package/dist/esm/utilities/createUint8SharedArray.d.ts +0 -2
- package/dist/esm/utilities/createUint8SharedArray.js +0 -12
- package/dist/esm/utilities/getScalarDataType.d.ts +0 -2
- package/dist/esm/utilities/getScalarDataType.js +0 -19
- package/dist/esm/utilities/isTypedArray.d.ts +0 -1
- package/dist/esm/utilities/isTypedArray.js +0 -11
|
@@ -1,19 +1,26 @@
|
|
|
1
|
+
import { mat4, vec3 } from 'gl-matrix';
|
|
1
2
|
import vtkPlane from '@kitware/vtk.js/Common/DataModel/Plane';
|
|
2
|
-
import cache from '../cache';
|
|
3
|
-
import { MPR_CAMERA_VALUES, RENDERING_DEFAULTS } from '../constants';
|
|
3
|
+
import cache from '../cache/cache';
|
|
4
|
+
import { EPSILON, MPR_CAMERA_VALUES, RENDERING_DEFAULTS } from '../constants';
|
|
4
5
|
import { OrientationAxis, Events } from '../enums';
|
|
5
|
-
import { actorIsA,
|
|
6
|
+
import { actorIsA, isImageActor } from '../utilities/actorCheck';
|
|
7
|
+
import getClosestImageId from '../utilities/getClosestImageId';
|
|
8
|
+
import getSliceRange from '../utilities/getSliceRange';
|
|
9
|
+
import getSpacingInNormalDirection from '../utilities/getSpacingInNormalDirection';
|
|
10
|
+
import snapFocalPointToSlice from '../utilities/snapFocalPointToSlice';
|
|
11
|
+
import triggerEvent from '../utilities/triggerEvent';
|
|
6
12
|
import BaseVolumeViewport from './BaseVolumeViewport';
|
|
7
13
|
import setDefaultVolumeVOI from './helpers/setDefaultVolumeVOI';
|
|
8
14
|
import { setTransferFunctionNodes } from '../utilities/transferFunctionUtils';
|
|
9
15
|
import getImageSliceDataForVolumeViewport from '../utilities/getImageSliceDataForVolumeViewport';
|
|
10
|
-
import {
|
|
16
|
+
import { transformCanvasToIJK } from '../utilities/transformCanvasToIJK';
|
|
17
|
+
import { transformIJKToCanvas } from '../utilities/transformIJKToCanvas';
|
|
11
18
|
class VolumeViewport extends BaseVolumeViewport {
|
|
12
19
|
constructor(props) {
|
|
13
20
|
super(props);
|
|
14
21
|
this._useAcquisitionPlaneForViewPlane = false;
|
|
15
22
|
this.getNumberOfSlices = () => {
|
|
16
|
-
const { numberOfSlices } = getImageSliceDataForVolumeViewport(this);
|
|
23
|
+
const { numberOfSlices } = getImageSliceDataForVolumeViewport(this) || {};
|
|
17
24
|
return numberOfSlices;
|
|
18
25
|
};
|
|
19
26
|
this.getCurrentImageIdIndex = (volumeId) => {
|
|
@@ -30,7 +37,7 @@ class VolumeViewport extends BaseVolumeViewport {
|
|
|
30
37
|
return Math.round(Math.abs(distance) / spacingInNormal);
|
|
31
38
|
};
|
|
32
39
|
this.getSliceIndex = () => {
|
|
33
|
-
const { imageIndex } = getImageSliceDataForVolumeViewport(this);
|
|
40
|
+
const { imageIndex } = getImageSliceDataForVolumeViewport(this) || {};
|
|
34
41
|
return imageIndex;
|
|
35
42
|
};
|
|
36
43
|
this.getCurrentImageId = () => {
|
|
@@ -176,14 +183,14 @@ class VolumeViewport extends BaseVolumeViewport {
|
|
|
176
183
|
}
|
|
177
184
|
}
|
|
178
185
|
resetCamera(options) {
|
|
179
|
-
const { resetPan = true, resetZoom = true, resetRotation = true, resetToCenter = true, suppressEvents = false, } = options || {};
|
|
186
|
+
const { resetPan = true, resetZoom = true, resetRotation = true, resetToCenter = true, suppressEvents = false, resetOrientation = true, } = options || {};
|
|
180
187
|
const { orientation } = this.viewportProperties;
|
|
181
|
-
if (orientation) {
|
|
188
|
+
if (orientation && resetOrientation) {
|
|
182
189
|
this.applyViewOrientation(orientation, false);
|
|
183
190
|
}
|
|
184
191
|
super.resetCamera({ resetPan, resetZoom, resetToCenter });
|
|
185
|
-
this.resetVolumeViewportClippingRange();
|
|
186
192
|
const activeCamera = this.getVtkActiveCamera();
|
|
193
|
+
this.setCameraClippingRange();
|
|
187
194
|
const viewPlaneNormal = activeCamera.getViewPlaneNormal();
|
|
188
195
|
const focalPoint = activeCamera.getFocalPoint();
|
|
189
196
|
const actorEntries = this.getActors();
|
|
@@ -242,6 +249,7 @@ class VolumeViewport extends BaseVolumeViewport {
|
|
|
242
249
|
});
|
|
243
250
|
const currentCamera = this.getCamera();
|
|
244
251
|
this.updateClippingPlanesForActors(currentCamera);
|
|
252
|
+
this.setCameraClippingRange();
|
|
245
253
|
this.triggerCameraModifiedEventIfNecessary(currentCamera, currentCamera);
|
|
246
254
|
this.viewportProperties.slabThickness = slabThickness;
|
|
247
255
|
}
|
|
@@ -257,6 +265,74 @@ class VolumeViewport extends BaseVolumeViewport {
|
|
|
257
265
|
this.triggerCameraModifiedEventIfNecessary(currentCamera, currentCamera);
|
|
258
266
|
this.viewportProperties.slabThickness = undefined;
|
|
259
267
|
}
|
|
268
|
+
getSliceViewInfo() {
|
|
269
|
+
const { width: canvasWidth, height: canvasHeight } = this.getCanvas();
|
|
270
|
+
const ijkOriginPoint = transformCanvasToIJK(this, [0, 0]);
|
|
271
|
+
const ijkRowPoint = transformCanvasToIJK(this, [canvasWidth - 1, 0]);
|
|
272
|
+
const ijkColPoint = transformCanvasToIJK(this, [0, canvasHeight - 1]);
|
|
273
|
+
const ijkRowVec = vec3.sub(vec3.create(), ijkRowPoint, ijkOriginPoint);
|
|
274
|
+
const ijkColVec = vec3.sub(vec3.create(), ijkColPoint, ijkOriginPoint);
|
|
275
|
+
const ijkSliceVec = vec3.cross(vec3.create(), ijkRowVec, ijkColVec);
|
|
276
|
+
vec3.normalize(ijkRowVec, ijkRowVec);
|
|
277
|
+
vec3.normalize(ijkColVec, ijkColVec);
|
|
278
|
+
vec3.normalize(ijkSliceVec, ijkSliceVec);
|
|
279
|
+
const { dimensions } = this.getImageData();
|
|
280
|
+
const [sx, sy, sz] = dimensions;
|
|
281
|
+
const ijkCorners = [
|
|
282
|
+
[0, 0, 0],
|
|
283
|
+
[sx - 1, 0, 0],
|
|
284
|
+
[0, sy - 1, 0],
|
|
285
|
+
[sx - 1, sy - 1, 0],
|
|
286
|
+
[0, 0, sz - 1],
|
|
287
|
+
[sx - 1, 0, sz - 1],
|
|
288
|
+
[0, sy - 1, sz - 1],
|
|
289
|
+
[sx - 1, sy - 1, sz - 1],
|
|
290
|
+
];
|
|
291
|
+
const canvasCorners = ijkCorners.map((ijkCorner) => transformIJKToCanvas(this, ijkCorner));
|
|
292
|
+
const canvasAABB = canvasCorners.reduce((aabb, canvasPoint) => {
|
|
293
|
+
aabb.minX = Math.min(aabb.minX, canvasPoint[0]);
|
|
294
|
+
aabb.minY = Math.min(aabb.minY, canvasPoint[1]);
|
|
295
|
+
aabb.maxX = Math.max(aabb.maxX, canvasPoint[0]);
|
|
296
|
+
aabb.maxY = Math.max(aabb.maxY, canvasPoint[1]);
|
|
297
|
+
return aabb;
|
|
298
|
+
}, { minX: Infinity, minY: Infinity, maxX: -Infinity, maxY: -Infinity });
|
|
299
|
+
const ijkTopLeft = transformCanvasToIJK(this, [
|
|
300
|
+
canvasAABB.minX,
|
|
301
|
+
canvasAABB.minY,
|
|
302
|
+
]);
|
|
303
|
+
const sliceToIndexMatrix = mat4.fromValues(ijkRowVec[0], ijkRowVec[1], ijkRowVec[2], 0, ijkColVec[0], ijkColVec[1], ijkColVec[2], 0, ijkSliceVec[0], ijkSliceVec[1], ijkSliceVec[2], 0, ijkTopLeft[0], ijkTopLeft[1], ijkTopLeft[2], 1);
|
|
304
|
+
const ijkBottomRight = transformCanvasToIJK(this, [
|
|
305
|
+
canvasAABB.maxX,
|
|
306
|
+
canvasAABB.maxY,
|
|
307
|
+
]);
|
|
308
|
+
const ijkDiagonal = vec3.sub(vec3.create(), ijkBottomRight, ijkTopLeft);
|
|
309
|
+
const indexToSliceMatrix = mat4.invert(mat4.create(), sliceToIndexMatrix);
|
|
310
|
+
const { viewPlaneNormal } = this.getCamera();
|
|
311
|
+
const isOblique = viewPlaneNormal.filter((component) => Math.abs(component) > EPSILON)
|
|
312
|
+
.length > 1;
|
|
313
|
+
if (isOblique) {
|
|
314
|
+
throw new Error('getSliceInfo is not supported for oblique views');
|
|
315
|
+
}
|
|
316
|
+
const sliceAxis = viewPlaneNormal.findIndex((component) => Math.abs(component) > 1 - EPSILON);
|
|
317
|
+
if (sliceAxis === -1) {
|
|
318
|
+
throw new Error('Unable to determine slice axis');
|
|
319
|
+
}
|
|
320
|
+
const sliceWidth = vec3.dot(ijkRowVec, ijkDiagonal) + 1;
|
|
321
|
+
const sliceHeight = vec3.dot(ijkColVec, ijkDiagonal) + 1;
|
|
322
|
+
return {
|
|
323
|
+
sliceIndex: this.getSliceIndex(),
|
|
324
|
+
width: sliceWidth,
|
|
325
|
+
height: sliceHeight,
|
|
326
|
+
slicePlane: sliceAxis,
|
|
327
|
+
sliceToIndexMatrix,
|
|
328
|
+
indexToSliceMatrix,
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
getCurrentSlicePixelData() {
|
|
332
|
+
const { voxelManager } = this.getImageData();
|
|
333
|
+
const sliceData = voxelManager.getSliceData(this.getSliceViewInfo());
|
|
334
|
+
return sliceData;
|
|
335
|
+
}
|
|
260
336
|
getViewReference(viewRefSpecifier = {}) {
|
|
261
337
|
const viewRef = super.getViewReference(viewRefSpecifier);
|
|
262
338
|
if (!viewRef?.volumeId) {
|
|
@@ -285,7 +361,7 @@ class VolumeViewport extends BaseVolumeViewport {
|
|
|
285
361
|
if (!imageVolume) {
|
|
286
362
|
throw new Error(`imageVolume with id: ${volumeActor.uid} does not exist in cache`);
|
|
287
363
|
}
|
|
288
|
-
setDefaultVolumeVOI(volumeActor.actor, imageVolume
|
|
364
|
+
setDefaultVolumeVOI(volumeActor.actor, imageVolume);
|
|
289
365
|
if (isImageActor(volumeActor)) {
|
|
290
366
|
const transferFunction = volumeActor.actor
|
|
291
367
|
.getProperty()
|
|
@@ -307,6 +383,15 @@ class VolumeViewport extends BaseVolumeViewport {
|
|
|
307
383
|
});
|
|
308
384
|
triggerEvent(this.element, Events.VOI_MODIFIED, eventDetails);
|
|
309
385
|
}
|
|
386
|
+
setCameraClippingRange() {
|
|
387
|
+
const activeCamera = this.getVtkActiveCamera();
|
|
388
|
+
if (activeCamera.getParallelProjection()) {
|
|
389
|
+
activeCamera.setClippingRange(activeCamera.getDistance(), activeCamera.getDistance() + this.getSlabThickness());
|
|
390
|
+
}
|
|
391
|
+
else {
|
|
392
|
+
activeCamera.setClippingRange(RENDERING_DEFAULTS.MINIMUM_SLAB_THICKNESS, RENDERING_DEFAULTS.MAXIMUM_RAY_DISTANCE);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
310
395
|
getSlicesClippingPlanes() {
|
|
311
396
|
const focalPoints = this.getSlicePlaneCoordinates();
|
|
312
397
|
const { viewPlaneNormal } = this.getCamera();
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { BlendModes } from '../enums';
|
|
1
|
+
import type { BlendModes } from '../enums';
|
|
2
2
|
import type { ViewportInput } from '../types/IViewport';
|
|
3
3
|
import BaseVolumeViewport from './BaseVolumeViewport';
|
|
4
4
|
declare class VolumeViewport3D extends BaseVolumeViewport {
|
|
5
5
|
constructor(props: ViewportInput);
|
|
6
6
|
resetCamera(resetPan?: boolean, resetZoom?: boolean, resetToCenter?: boolean): boolean;
|
|
7
7
|
getRotation: () => number;
|
|
8
|
-
getCurrentImageIdIndex: () => number
|
|
8
|
+
getCurrentImageIdIndex: () => number;
|
|
9
9
|
getCurrentImageId: () => string;
|
|
10
|
-
setSlabThickness(slabThickness: number, filterActorUIDs?:
|
|
10
|
+
setSlabThickness(slabThickness: number, filterActorUIDs?: string[]): void;
|
|
11
11
|
setBlendMode(blendMode: BlendModes, filterActorUIDs?: string[], immediate?: boolean): void;
|
|
12
12
|
resetProperties(volumeId?: string): void;
|
|
13
13
|
resetSlabThickness(): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RENDERING_DEFAULTS } from '../constants';
|
|
1
2
|
import { OrientationAxis } from '../enums';
|
|
2
3
|
import BaseVolumeViewport from './BaseVolumeViewport';
|
|
3
4
|
class VolumeViewport3D extends BaseVolumeViewport {
|
|
@@ -5,7 +6,7 @@ class VolumeViewport3D extends BaseVolumeViewport {
|
|
|
5
6
|
super(props);
|
|
6
7
|
this.getRotation = () => 0;
|
|
7
8
|
this.getCurrentImageIdIndex = () => {
|
|
8
|
-
return
|
|
9
|
+
return 0;
|
|
9
10
|
};
|
|
10
11
|
this.getCurrentImageId = () => {
|
|
11
12
|
return null;
|
|
@@ -21,8 +22,14 @@ class VolumeViewport3D extends BaseVolumeViewport {
|
|
|
21
22
|
}
|
|
22
23
|
resetCamera(resetPan = true, resetZoom = true, resetToCenter = true) {
|
|
23
24
|
super.resetCamera({ resetPan, resetZoom, resetToCenter });
|
|
24
|
-
this.
|
|
25
|
-
|
|
25
|
+
const activeCamera = this.getVtkActiveCamera();
|
|
26
|
+
if (activeCamera.getParallelProjection()) {
|
|
27
|
+
activeCamera.setClippingRange(-RENDERING_DEFAULTS.MAXIMUM_RAY_DISTANCE, RENDERING_DEFAULTS.MAXIMUM_RAY_DISTANCE);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
activeCamera.setClippingRange(RENDERING_DEFAULTS.MINIMUM_SLAB_THICKNESS, RENDERING_DEFAULTS.MAXIMUM_RAY_DISTANCE);
|
|
31
|
+
}
|
|
32
|
+
return true;
|
|
26
33
|
}
|
|
27
34
|
setSlabThickness(slabThickness, filterActorUIDs) {
|
|
28
35
|
return null;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { IWSIViewport, WSIViewportProperties, Point3, Point2, ICamera, WSIViewportInput, CPUIImageData } from '../types';
|
|
2
|
+
import { Transform } from './helpers/cpuFallback/rendering/transform';
|
|
3
|
+
import Viewport from './Viewport';
|
|
4
|
+
declare class WSIViewport extends Viewport implements IWSIViewport {
|
|
5
|
+
modality: any;
|
|
6
|
+
protected imageIds: string[];
|
|
7
|
+
readonly uid: any;
|
|
8
|
+
readonly renderingEngineId: string;
|
|
9
|
+
private frameOfReferenceUID;
|
|
10
|
+
protected metadata: any;
|
|
11
|
+
protected metadataDicomweb: any;
|
|
12
|
+
private microscopyElement;
|
|
13
|
+
protected map: any;
|
|
14
|
+
private internalCamera;
|
|
15
|
+
private viewer;
|
|
16
|
+
private voiRange;
|
|
17
|
+
constructor(props: WSIViewportInput);
|
|
18
|
+
static get useCustomRenderingPipeline(): boolean;
|
|
19
|
+
private addEventListeners;
|
|
20
|
+
private removeEventListeners;
|
|
21
|
+
private elementDisabledHandler;
|
|
22
|
+
private getImageDataMetadata;
|
|
23
|
+
setFrameNumber(frame: number): Promise<void>;
|
|
24
|
+
setProperties(props: WSIViewportProperties): void;
|
|
25
|
+
getProperties: () => WSIViewportProperties;
|
|
26
|
+
resetProperties(): void;
|
|
27
|
+
protected getScalarData(): any;
|
|
28
|
+
getImageData(): CPUIImageData;
|
|
29
|
+
hasImageURI(imageURI: string): boolean;
|
|
30
|
+
setCamera(camera: ICamera): void;
|
|
31
|
+
getCurrentImageId(): string;
|
|
32
|
+
getFrameNumber(): number;
|
|
33
|
+
getCamera(): ICamera;
|
|
34
|
+
resetCamera: () => boolean;
|
|
35
|
+
getNumberOfSlices: () => number;
|
|
36
|
+
static getDicomMicroscopyViewer: () => Promise<any>;
|
|
37
|
+
getFrameOfReferenceUID: () => string;
|
|
38
|
+
resize: () => void;
|
|
39
|
+
canvasToWorld: (canvasPos: Point2) => Point3;
|
|
40
|
+
worldToCanvas: (worldPos: Point3) => Point2;
|
|
41
|
+
setDataIds(imageIds: string[]): Promise<void>;
|
|
42
|
+
setWSI(imageIds: string[], client: any): Promise<void>;
|
|
43
|
+
postrender: () => void;
|
|
44
|
+
scroll(delta: number): void;
|
|
45
|
+
getRotation: () => number;
|
|
46
|
+
protected canvasToIndex: (canvasPos: Point2) => Point2;
|
|
47
|
+
protected indexToCanvas: (indexPos: Point2) => Point2;
|
|
48
|
+
getSliceIndex(): number;
|
|
49
|
+
getView(): any;
|
|
50
|
+
private refreshRenderValues;
|
|
51
|
+
customRenderViewportToCanvas: () => void;
|
|
52
|
+
getZoom(): any;
|
|
53
|
+
setZoom(zoom: number): void;
|
|
54
|
+
protected getTransform(): Transform;
|
|
55
|
+
getReferenceId(): string;
|
|
56
|
+
getCurrentImageIdIndex(): number;
|
|
57
|
+
}
|
|
58
|
+
export default WSIViewport;
|
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
import { vec3 } from 'gl-matrix';
|
|
2
|
+
import { Events as EVENTS, MetadataModules } from '../enums';
|
|
3
|
+
import uuidv4 from '../utilities/uuidv4';
|
|
4
|
+
import * as metaData from '../metaData';
|
|
5
|
+
import { Transform } from './helpers/cpuFallback/rendering/transform';
|
|
6
|
+
import Viewport from './Viewport';
|
|
7
|
+
import { getOrCreateCanvas } from './helpers';
|
|
8
|
+
import { EPSILON } from '../constants';
|
|
9
|
+
import triggerEvent from '../utilities/triggerEvent';
|
|
10
|
+
import { peerImport } from '../init';
|
|
11
|
+
const _map = Symbol.for('map');
|
|
12
|
+
const EVENT_POSTRENDER = 'postrender';
|
|
13
|
+
class WSIViewport extends Viewport {
|
|
14
|
+
constructor(props) {
|
|
15
|
+
super({
|
|
16
|
+
...props,
|
|
17
|
+
canvas: props.canvas || getOrCreateCanvas(props.element),
|
|
18
|
+
});
|
|
19
|
+
this.internalCamera = {
|
|
20
|
+
rotation: 0,
|
|
21
|
+
centerIndex: [0, 0],
|
|
22
|
+
extent: [0, -2, 1, -1],
|
|
23
|
+
xSpacing: 1,
|
|
24
|
+
ySpacing: 1,
|
|
25
|
+
resolution: 1,
|
|
26
|
+
zoom: 1,
|
|
27
|
+
};
|
|
28
|
+
this.voiRange = {
|
|
29
|
+
lower: 0,
|
|
30
|
+
upper: 255,
|
|
31
|
+
};
|
|
32
|
+
this.getProperties = () => {
|
|
33
|
+
return {};
|
|
34
|
+
};
|
|
35
|
+
this.resetCamera = () => {
|
|
36
|
+
return true;
|
|
37
|
+
};
|
|
38
|
+
this.getNumberOfSlices = () => {
|
|
39
|
+
return 1;
|
|
40
|
+
};
|
|
41
|
+
this.getFrameOfReferenceUID = () => {
|
|
42
|
+
return this.frameOfReferenceUID;
|
|
43
|
+
};
|
|
44
|
+
this.resize = () => {
|
|
45
|
+
const canvas = this.canvas;
|
|
46
|
+
const { clientWidth, clientHeight } = canvas;
|
|
47
|
+
if (canvas.width !== clientWidth || canvas.height !== clientHeight) {
|
|
48
|
+
canvas.width = clientWidth;
|
|
49
|
+
canvas.height = clientHeight;
|
|
50
|
+
}
|
|
51
|
+
this.refreshRenderValues();
|
|
52
|
+
};
|
|
53
|
+
this.canvasToWorld = (canvasPos) => {
|
|
54
|
+
if (!this.metadata) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const [px, py] = this.canvasToIndex(canvasPos);
|
|
58
|
+
const { origin, spacing, direction } = this.getImageData();
|
|
59
|
+
const worldPos = vec3.fromValues(0, 0, 0);
|
|
60
|
+
const iVector = direction.slice(0, 3);
|
|
61
|
+
const jVector = direction.slice(3, 6);
|
|
62
|
+
vec3.scaleAndAdd(worldPos, origin, iVector, px * spacing[0]);
|
|
63
|
+
vec3.scaleAndAdd(worldPos, worldPos, jVector, py * spacing[1]);
|
|
64
|
+
return [worldPos[0], worldPos[1], worldPos[2]];
|
|
65
|
+
};
|
|
66
|
+
this.worldToCanvas = (worldPos) => {
|
|
67
|
+
if (!this.metadata) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const { spacing, direction, origin } = this.metadata;
|
|
71
|
+
const iVector = direction.slice(0, 3);
|
|
72
|
+
const jVector = direction.slice(3, 6);
|
|
73
|
+
const diff = vec3.subtract([0, 0, 0], worldPos, origin);
|
|
74
|
+
const indexPoint = [
|
|
75
|
+
vec3.dot(diff, iVector) / spacing[0],
|
|
76
|
+
vec3.dot(diff, jVector) / spacing[1],
|
|
77
|
+
];
|
|
78
|
+
const canvasPoint = this.indexToCanvas(indexPoint);
|
|
79
|
+
return canvasPoint;
|
|
80
|
+
};
|
|
81
|
+
this.postrender = () => {
|
|
82
|
+
this.refreshRenderValues();
|
|
83
|
+
triggerEvent(this.element, EVENTS.IMAGE_RENDERED, {
|
|
84
|
+
element: this.element,
|
|
85
|
+
viewportId: this.id,
|
|
86
|
+
viewport: this,
|
|
87
|
+
renderingEngineId: this.renderingEngineId,
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
this.getRotation = () => 0;
|
|
91
|
+
this.canvasToIndex = (canvasPos) => {
|
|
92
|
+
const transform = this.getTransform();
|
|
93
|
+
transform.invert();
|
|
94
|
+
return transform.transformPoint(canvasPos);
|
|
95
|
+
};
|
|
96
|
+
this.indexToCanvas = (indexPos) => {
|
|
97
|
+
const transform = this.getTransform();
|
|
98
|
+
return transform.transformPoint(indexPos);
|
|
99
|
+
};
|
|
100
|
+
this.customRenderViewportToCanvas = () => {
|
|
101
|
+
};
|
|
102
|
+
this.renderingEngineId = props.renderingEngineId;
|
|
103
|
+
this.element.setAttribute('data-viewport-uid', this.id);
|
|
104
|
+
this.element.setAttribute('data-rendering-engine-uid', this.renderingEngineId);
|
|
105
|
+
this.element.style.position = 'relative';
|
|
106
|
+
this.microscopyElement = document.createElement('div');
|
|
107
|
+
this.microscopyElement.id = uuidv4();
|
|
108
|
+
this.microscopyElement.innerText = 'Initial';
|
|
109
|
+
this.microscopyElement.style.background = 'grey';
|
|
110
|
+
this.microscopyElement.style.width = '100%';
|
|
111
|
+
this.microscopyElement.style.height = '100%';
|
|
112
|
+
this.microscopyElement.style.position = 'absolute';
|
|
113
|
+
this.microscopyElement.style.left = '0';
|
|
114
|
+
this.microscopyElement.style.top = '0';
|
|
115
|
+
const cs3dElement = this.element.firstElementChild;
|
|
116
|
+
cs3dElement.insertBefore(this.microscopyElement, cs3dElement.childNodes[1]);
|
|
117
|
+
this.addEventListeners();
|
|
118
|
+
this.resize();
|
|
119
|
+
}
|
|
120
|
+
static get useCustomRenderingPipeline() {
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
addEventListeners() {
|
|
124
|
+
this.canvas.addEventListener(EVENTS.ELEMENT_DISABLED, this.elementDisabledHandler);
|
|
125
|
+
}
|
|
126
|
+
removeEventListeners() {
|
|
127
|
+
this.canvas.removeEventListener(EVENTS.ELEMENT_DISABLED, this.elementDisabledHandler);
|
|
128
|
+
}
|
|
129
|
+
elementDisabledHandler() {
|
|
130
|
+
this.removeEventListeners();
|
|
131
|
+
}
|
|
132
|
+
getImageDataMetadata(imageIndex = 0) {
|
|
133
|
+
const maxImage = this.metadataDicomweb.reduce((maxImage, image) => {
|
|
134
|
+
return maxImage?.NumberOfFrames < image.NumberOfFrames ? image : maxImage;
|
|
135
|
+
});
|
|
136
|
+
const { TotalPixelMatrixColumns: columns, TotalPixelMatrixRows: rows, ImageOrientationSlide, ImagedVolumeWidth: width, ImagedVolumeHeight: height, ImagedVolumeDepth: depth, } = maxImage;
|
|
137
|
+
const imagePlaneModule = metaData.get(MetadataModules.IMAGE_PLANE, this.imageIds[imageIndex]);
|
|
138
|
+
let rowCosines = ImageOrientationSlide.slice(0, 3);
|
|
139
|
+
let columnCosines = ImageOrientationSlide.slice(3, 6);
|
|
140
|
+
if (rowCosines == null || columnCosines == null) {
|
|
141
|
+
rowCosines = [1, 0, 0];
|
|
142
|
+
columnCosines = [0, 1, 0];
|
|
143
|
+
}
|
|
144
|
+
const rowCosineVec = vec3.fromValues(rowCosines[0], rowCosines[1], rowCosines[2]);
|
|
145
|
+
const colCosineVec = vec3.fromValues(columnCosines[0], columnCosines[1], columnCosines[2]);
|
|
146
|
+
const scanAxisNormal = vec3.create();
|
|
147
|
+
vec3.cross(scanAxisNormal, rowCosineVec, colCosineVec);
|
|
148
|
+
const { XOffsetInSlideCoordinateSystem = 0, YOffsetInSlideCoordinateSystem = 0, ZOffsetInSlideCoordinateSystem = 0, } = maxImage.TotalPixelMatrixOriginSequence?.[0] || {};
|
|
149
|
+
const origin = [
|
|
150
|
+
XOffsetInSlideCoordinateSystem,
|
|
151
|
+
YOffsetInSlideCoordinateSystem,
|
|
152
|
+
ZOffsetInSlideCoordinateSystem,
|
|
153
|
+
];
|
|
154
|
+
const xSpacing = width / columns;
|
|
155
|
+
const ySpacing = height / rows;
|
|
156
|
+
const xVoxels = columns;
|
|
157
|
+
const yVoxels = rows;
|
|
158
|
+
const zSpacing = depth;
|
|
159
|
+
const zVoxels = 1;
|
|
160
|
+
this.hasPixelSpacing = !!(width && height);
|
|
161
|
+
return {
|
|
162
|
+
bitsAllocated: 8,
|
|
163
|
+
numberOfComponents: 3,
|
|
164
|
+
origin,
|
|
165
|
+
direction: [...rowCosineVec, ...colCosineVec, ...scanAxisNormal],
|
|
166
|
+
dimensions: [xVoxels, yVoxels, zVoxels],
|
|
167
|
+
spacing: [xSpacing, ySpacing, zSpacing],
|
|
168
|
+
hasPixelSpacing: this.hasPixelSpacing,
|
|
169
|
+
numVoxels: xVoxels * yVoxels * zVoxels,
|
|
170
|
+
imagePlaneModule,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
async setFrameNumber(frame) {
|
|
174
|
+
}
|
|
175
|
+
setProperties(props) {
|
|
176
|
+
}
|
|
177
|
+
resetProperties() {
|
|
178
|
+
this.setProperties({});
|
|
179
|
+
}
|
|
180
|
+
getScalarData() {
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
getImageData() {
|
|
184
|
+
const { metadata } = this;
|
|
185
|
+
if (!metadata) {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
const { spacing } = metadata;
|
|
189
|
+
return {
|
|
190
|
+
dimensions: metadata.dimensions,
|
|
191
|
+
spacing,
|
|
192
|
+
numberOfComponents: 3,
|
|
193
|
+
origin: metadata.origin,
|
|
194
|
+
direction: metadata.direction,
|
|
195
|
+
metadata: {
|
|
196
|
+
Modality: this.modality,
|
|
197
|
+
FrameOfReferenceUID: this.frameOfReferenceUID,
|
|
198
|
+
},
|
|
199
|
+
imageData: {
|
|
200
|
+
getDirection: () => metadata.direction,
|
|
201
|
+
getDimensions: () => metadata.dimensions,
|
|
202
|
+
getRange: () => [0, 255],
|
|
203
|
+
getScalarData: () => this.getScalarData(),
|
|
204
|
+
getSpacing: () => metadata.spacing,
|
|
205
|
+
worldToIndex: (point) => {
|
|
206
|
+
const canvasPoint = this.worldToCanvas(point);
|
|
207
|
+
const pixelCoord = this.canvasToIndex(canvasPoint);
|
|
208
|
+
return [pixelCoord[0], pixelCoord[1], 0];
|
|
209
|
+
},
|
|
210
|
+
indexToWorld: (point) => {
|
|
211
|
+
const canvasPoint = this.indexToCanvas([point[0], point[1]]);
|
|
212
|
+
return this.canvasToWorld(canvasPoint);
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
hasPixelSpacing: this.hasPixelSpacing,
|
|
216
|
+
calibration: this.calibration,
|
|
217
|
+
preScale: {
|
|
218
|
+
scaled: false,
|
|
219
|
+
},
|
|
220
|
+
scalarData: this.getScalarData(),
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
hasImageURI(imageURI) {
|
|
224
|
+
return true;
|
|
225
|
+
}
|
|
226
|
+
setCamera(camera) {
|
|
227
|
+
const previousCamera = this.getCamera();
|
|
228
|
+
const { parallelScale, focalPoint } = camera;
|
|
229
|
+
const view = this.getView();
|
|
230
|
+
const { xSpacing } = this.internalCamera;
|
|
231
|
+
if (parallelScale) {
|
|
232
|
+
const worldToCanvasRatio = this.element.clientHeight / parallelScale;
|
|
233
|
+
const resolution = 1 / xSpacing / worldToCanvasRatio;
|
|
234
|
+
view.setResolution(resolution);
|
|
235
|
+
}
|
|
236
|
+
if (focalPoint) {
|
|
237
|
+
const newCanvas = this.worldToCanvas(focalPoint);
|
|
238
|
+
const newIndex = this.canvasToIndex(newCanvas);
|
|
239
|
+
view.setCenter(newIndex);
|
|
240
|
+
}
|
|
241
|
+
const updatedCamera = this.getCamera();
|
|
242
|
+
this.triggerCameraModifiedEventIfNecessary(previousCamera, updatedCamera);
|
|
243
|
+
}
|
|
244
|
+
getCurrentImageId() {
|
|
245
|
+
return this.imageIds[0];
|
|
246
|
+
}
|
|
247
|
+
getFrameNumber() {
|
|
248
|
+
return 1;
|
|
249
|
+
}
|
|
250
|
+
getCamera() {
|
|
251
|
+
this.refreshRenderValues();
|
|
252
|
+
const { resolution, xSpacing } = this.internalCamera;
|
|
253
|
+
const canvasToWorldRatio = resolution * xSpacing;
|
|
254
|
+
const canvasCenter = [
|
|
255
|
+
this.element.clientWidth / 2,
|
|
256
|
+
this.element.clientHeight / 2,
|
|
257
|
+
];
|
|
258
|
+
const focalPoint = this.canvasToWorld(canvasCenter);
|
|
259
|
+
return {
|
|
260
|
+
parallelProjection: true,
|
|
261
|
+
focalPoint,
|
|
262
|
+
position: focalPoint,
|
|
263
|
+
viewUp: [0, -1, 0],
|
|
264
|
+
parallelScale: this.element.clientHeight * canvasToWorldRatio,
|
|
265
|
+
viewPlaneNormal: [0, 0, 1],
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
static { this.getDicomMicroscopyViewer = async () => {
|
|
269
|
+
return peerImport('dicom-microscopy-viewer');
|
|
270
|
+
}; }
|
|
271
|
+
setDataIds(imageIds) {
|
|
272
|
+
const webClient = metaData.get(MetadataModules.WADO_WEB_CLIENT, imageIds[0]);
|
|
273
|
+
if (!webClient) {
|
|
274
|
+
throw new Error(`To use setDataIds on WSI data, you must provide metaData.webClient for ${imageIds[0]}`);
|
|
275
|
+
}
|
|
276
|
+
return this.setWSI(imageIds, webClient);
|
|
277
|
+
}
|
|
278
|
+
async setWSI(imageIds, client) {
|
|
279
|
+
this.microscopyElement.style.background = 'black';
|
|
280
|
+
this.microscopyElement.innerText = 'Loading';
|
|
281
|
+
this.imageIds = imageIds;
|
|
282
|
+
const DicomMicroscopyViewer = await WSIViewport.getDicomMicroscopyViewer();
|
|
283
|
+
this.frameOfReferenceUID = null;
|
|
284
|
+
const metadataDicomweb = this.imageIds.map((imageId) => {
|
|
285
|
+
const imageMetadata = client.getDICOMwebMetadata(imageId);
|
|
286
|
+
Object.defineProperty(imageMetadata, 'isMultiframe', {
|
|
287
|
+
value: imageMetadata.isMultiframe,
|
|
288
|
+
enumerable: false,
|
|
289
|
+
});
|
|
290
|
+
Object.defineProperty(imageMetadata, 'frameNumber', {
|
|
291
|
+
value: undefined,
|
|
292
|
+
enumerable: false,
|
|
293
|
+
});
|
|
294
|
+
const imageType = imageMetadata['00080008']?.Value;
|
|
295
|
+
if (imageType?.length === 1) {
|
|
296
|
+
imageMetadata['00080008'].Value = imageType[0].split('\\');
|
|
297
|
+
}
|
|
298
|
+
const frameOfReference = imageMetadata['00200052']?.Value?.[0];
|
|
299
|
+
if (!this.frameOfReferenceUID) {
|
|
300
|
+
this.frameOfReferenceUID = frameOfReference;
|
|
301
|
+
}
|
|
302
|
+
else if (frameOfReference !== this.frameOfReferenceUID) {
|
|
303
|
+
imageMetadata['00200052'].Value = [this.frameOfReferenceUID];
|
|
304
|
+
}
|
|
305
|
+
return imageMetadata;
|
|
306
|
+
});
|
|
307
|
+
const volumeImages = [];
|
|
308
|
+
metadataDicomweb.forEach((m) => {
|
|
309
|
+
const image = new DicomMicroscopyViewer.metadata.VLWholeSlideMicroscopyImage({
|
|
310
|
+
metadata: m,
|
|
311
|
+
});
|
|
312
|
+
const imageFlavor = image.ImageType[2];
|
|
313
|
+
if (imageFlavor === 'VOLUME' || imageFlavor === 'THUMBNAIL') {
|
|
314
|
+
volumeImages.push(image);
|
|
315
|
+
}
|
|
316
|
+
else {
|
|
317
|
+
console.log('Unknown image type', image.ImageType);
|
|
318
|
+
}
|
|
319
|
+
});
|
|
320
|
+
this.metadataDicomweb = volumeImages;
|
|
321
|
+
const viewer = new DicomMicroscopyViewer.viewer.VolumeImageViewer({
|
|
322
|
+
client,
|
|
323
|
+
metadata: volumeImages,
|
|
324
|
+
controls: [],
|
|
325
|
+
bindings: {},
|
|
326
|
+
});
|
|
327
|
+
viewer.render({ container: this.microscopyElement });
|
|
328
|
+
this.metadata = this.getImageDataMetadata();
|
|
329
|
+
viewer.deactivateDragPanInteraction();
|
|
330
|
+
this.viewer = viewer;
|
|
331
|
+
this.map = viewer[_map];
|
|
332
|
+
this.map.on(EVENT_POSTRENDER, this.postrender);
|
|
333
|
+
this.resize();
|
|
334
|
+
this.microscopyElement.innerText = '';
|
|
335
|
+
Object.assign(this.microscopyElement.style, {
|
|
336
|
+
'--ol-partial-background-color': 'rgba(127, 127, 127, 0.7)',
|
|
337
|
+
'--ol-foreground-color': '#000000',
|
|
338
|
+
'--ol-subtle-foreground-color': '#000',
|
|
339
|
+
'--ol-subtle-background-color': 'rgba(78, 78, 78, 0.5)',
|
|
340
|
+
background: 'none',
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
scroll(delta) {
|
|
344
|
+
const camera = this.getCamera();
|
|
345
|
+
this.setCamera({
|
|
346
|
+
parallelScale: camera.parallelScale * (1 + 0.1 * delta),
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
getSliceIndex() {
|
|
350
|
+
return 0;
|
|
351
|
+
}
|
|
352
|
+
getView() {
|
|
353
|
+
if (!this.viewer) {
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
const map = this.viewer[_map];
|
|
357
|
+
const anyWindow = window;
|
|
358
|
+
anyWindow.map = map;
|
|
359
|
+
anyWindow.viewer = this.viewer;
|
|
360
|
+
anyWindow.view = map?.getView();
|
|
361
|
+
anyWindow.wsi = this;
|
|
362
|
+
return map?.getView();
|
|
363
|
+
}
|
|
364
|
+
refreshRenderValues() {
|
|
365
|
+
const view = this.getView();
|
|
366
|
+
if (!view) {
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
const resolution = view.getResolution();
|
|
370
|
+
if (!resolution || resolution < EPSILON) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
const centerIndex = view.getCenter();
|
|
374
|
+
const extent = view.getProjection().getExtent();
|
|
375
|
+
const rotation = view.getRotation();
|
|
376
|
+
const zoom = view.getZoom();
|
|
377
|
+
const { metadata: { spacing: [xSpacing, ySpacing], }, } = this;
|
|
378
|
+
const worldToCanvasRatio = 1 / resolution / xSpacing;
|
|
379
|
+
Object.assign(this.internalCamera, {
|
|
380
|
+
extent,
|
|
381
|
+
centerIndex,
|
|
382
|
+
worldToCanvasRatio,
|
|
383
|
+
xSpacing,
|
|
384
|
+
ySpacing,
|
|
385
|
+
resolution,
|
|
386
|
+
rotation,
|
|
387
|
+
zoom,
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
getZoom() {
|
|
391
|
+
return this.getView()?.getZoom();
|
|
392
|
+
}
|
|
393
|
+
setZoom(zoom) {
|
|
394
|
+
this.getView()?.setZoom(zoom);
|
|
395
|
+
}
|
|
396
|
+
getTransform() {
|
|
397
|
+
this.refreshRenderValues();
|
|
398
|
+
const { centerIndex: center, resolution, rotation } = this.internalCamera;
|
|
399
|
+
const halfCanvas = [this.canvas.width / 2, this.canvas.height / 2];
|
|
400
|
+
const transform = new Transform();
|
|
401
|
+
transform.translate(halfCanvas[0], halfCanvas[1]);
|
|
402
|
+
transform.rotate(rotation);
|
|
403
|
+
transform.scale(1 / resolution, -1 / resolution);
|
|
404
|
+
transform.translate(-center[0], -center[1]);
|
|
405
|
+
return transform;
|
|
406
|
+
}
|
|
407
|
+
getReferenceId() {
|
|
408
|
+
return `imageId:${this.getCurrentImageId()}`;
|
|
409
|
+
}
|
|
410
|
+
getCurrentImageIdIndex() {
|
|
411
|
+
return 0;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
export default WSIViewport;
|