volview 4.0.0 → 4.0.1
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/css/app.925b979f.css +1 -0
- package/dist/css/chunk-vendors.43a6a19a.css +5 -0
- package/{public → dist}/favicon.ico +0 -0
- package/{public → dist}/global.css +0 -0
- package/{src/assets/KitwareHeadAndNeck.jpg → dist/img/KitwareHeadAndNeck.11db5ffb.jpg} +0 -0
- package/dist/index.html +1 -0
- package/dist/itk/image-io/BMPImageIOReadImage.js +1 -0
- package/dist/itk/image-io/BMPImageIOReadImage.umd.js +1 -0
- package/dist/itk/image-io/BMPImageIOReadImage.wasm +0 -0
- package/dist/itk/image-io/BMPImageIOWriteImage.js +1 -0
- package/dist/itk/image-io/BMPImageIOWriteImage.umd.js +1 -0
- package/dist/itk/image-io/BMPImageIOWriteImage.wasm +0 -0
- package/dist/itk/image-io/GDCMImageIOReadImage.js +1 -0
- package/dist/itk/image-io/GDCMImageIOReadImage.umd.js +1 -0
- package/dist/itk/image-io/GDCMImageIOReadImage.wasm +0 -0
- package/dist/itk/image-io/GDCMImageIOWriteImage.js +1 -0
- package/dist/itk/image-io/GDCMImageIOWriteImage.umd.js +1 -0
- package/dist/itk/image-io/GDCMImageIOWriteImage.wasm +0 -0
- package/dist/itk/image-io/JPEGImageIOReadImage.js +1 -0
- package/dist/itk/image-io/JPEGImageIOReadImage.umd.js +1 -0
- package/dist/itk/image-io/JPEGImageIOReadImage.wasm +0 -0
- package/dist/itk/image-io/JPEGImageIOWriteImage.js +1 -0
- package/dist/itk/image-io/JPEGImageIOWriteImage.umd.js +1 -0
- package/dist/itk/image-io/JPEGImageIOWriteImage.wasm +0 -0
- package/dist/itk/image-io/MetaImageIOReadImage.js +1 -0
- package/dist/itk/image-io/MetaImageIOReadImage.umd.js +1 -0
- package/dist/itk/image-io/MetaImageIOReadImage.wasm +0 -0
- package/dist/itk/image-io/MetaImageIOWriteImage.js +1 -0
- package/dist/itk/image-io/MetaImageIOWriteImage.umd.js +1 -0
- package/dist/itk/image-io/MetaImageIOWriteImage.wasm +0 -0
- package/dist/itk/image-io/NiftiImageIOReadImage.js +1 -0
- package/dist/itk/image-io/NiftiImageIOReadImage.umd.js +1 -0
- package/dist/itk/image-io/NiftiImageIOReadImage.wasm +0 -0
- package/dist/itk/image-io/NiftiImageIOWriteImage.js +1 -0
- package/dist/itk/image-io/NiftiImageIOWriteImage.umd.js +1 -0
- package/dist/itk/image-io/NiftiImageIOWriteImage.wasm +0 -0
- package/dist/itk/image-io/NrrdImageIOReadImage.js +1 -0
- package/dist/itk/image-io/NrrdImageIOReadImage.umd.js +1 -0
- package/dist/itk/image-io/NrrdImageIOReadImage.wasm +0 -0
- package/dist/itk/image-io/NrrdImageIOWriteImage.js +1 -0
- package/dist/itk/image-io/NrrdImageIOWriteImage.umd.js +1 -0
- package/dist/itk/image-io/NrrdImageIOWriteImage.wasm +0 -0
- package/dist/itk/image-io/PNGImageIOReadImage.js +1 -0
- package/dist/itk/image-io/PNGImageIOReadImage.umd.js +1 -0
- package/dist/itk/image-io/PNGImageIOReadImage.wasm +0 -0
- package/dist/itk/image-io/PNGImageIOWriteImage.js +1 -0
- package/dist/itk/image-io/PNGImageIOWriteImage.umd.js +1 -0
- package/dist/itk/image-io/PNGImageIOWriteImage.wasm +0 -0
- package/dist/itk/image-io/ReadDICOMTags.js +1 -0
- package/dist/itk/image-io/ReadDICOMTags.umd.js +1 -0
- package/dist/itk/image-io/ReadDICOMTags.wasm +0 -0
- package/dist/itk/image-io/ReadImageDICOMFileSeries.js +1 -0
- package/dist/itk/image-io/ReadImageDICOMFileSeries.umd.js +1 -0
- package/dist/itk/image-io/ReadImageDICOMFileSeries.wasm +0 -0
- package/dist/itk/image-io/VTKImageIOReadImage.js +1 -0
- package/dist/itk/image-io/VTKImageIOReadImage.umd.js +1 -0
- package/dist/itk/image-io/VTKImageIOReadImage.wasm +0 -0
- package/dist/itk/image-io/VTKImageIOWriteImage.js +1 -0
- package/dist/itk/image-io/VTKImageIOWriteImage.umd.js +1 -0
- package/dist/itk/image-io/VTKImageIOWriteImage.wasm +0 -0
- package/dist/itk/pipelines/dicom.js +1 -0
- package/dist/itk/pipelines/dicom.umd.js +1 -0
- package/{src/io/itk-dicom/web-build → dist/itk/pipelines}/dicom.umd.wasm +0 -0
- package/{src/io/itk-dicom/web-build → dist/itk/pipelines}/dicom.wasm +0 -0
- package/dist/itk/web-workers/IOInput.d.ts +6 -0
- package/dist/itk/web-workers/IOInput.js +1 -0
- package/dist/itk/web-workers/ITKConfig.d.ts +8 -0
- package/dist/itk/web-workers/ITKConfig.js +1 -0
- package/dist/itk/web-workers/RunPipelineInput.d.ts +10 -0
- package/dist/itk/web-workers/RunPipelineInput.js +1 -0
- package/dist/itk/web-workers/WebWorkerInput.d.ts +6 -0
- package/dist/itk/web-workers/WebWorkerInput.js +1 -0
- package/dist/itk/web-workers/bundles/pipeline.worker.js +1 -0
- package/dist/itk/web-workers/loadImageIOPipelineModule.d.ts +4 -0
- package/dist/itk/web-workers/loadImageIOPipelineModule.js +1 -0
- package/dist/itk/web-workers/loadMeshIOPipelineModule.d.ts +4 -0
- package/dist/itk/web-workers/loadMeshIOPipelineModule.js +1 -0
- package/dist/itk/web-workers/loadPipelineModule.d.ts +3 -0
- package/dist/itk/web-workers/loadPipelineModule.js +1 -0
- package/dist/itk/web-workers/min-bundles/pipeline.worker.js +3 -0
- package/dist/itk/web-workers/pipeline.worker.d.ts +1 -0
- package/dist/itk/web-workers/pipeline.worker.js +1 -0
- package/dist/itk/web-workers/runPipeline.d.ts +5 -0
- package/dist/itk/web-workers/runPipeline.js +1 -0
- package/dist/js/23.be4d694e.js +21 -0
- package/dist/js/23.be4d694e.js.map +1 -0
- package/dist/js/385.51ca48a2.js +2 -0
- package/dist/js/385.51ca48a2.js.map +1 -0
- package/dist/js/422.c64a6aa7.js +2 -0
- package/dist/js/422.c64a6aa7.js.map +1 -0
- package/dist/js/979.c4823352.js +2 -0
- package/dist/js/979.c4823352.js.map +1 -0
- package/dist/js/app.81e49d9a.js +2 -0
- package/dist/js/app.81e49d9a.js.map +1 -0
- package/dist/js/chunk-vendors.0ab48f8d.js +33 -0
- package/dist/js/chunk-vendors.0ab48f8d.js.map +1 -0
- package/{public → dist}/pvm-sample.png +0 -0
- package/package.json +3 -2
- package/.browserslistrc +0 -4
- package/.editorconfig +0 -6
- package/.env +0 -6
- package/.eslintrc.js +0 -109
- package/.gitattributes +0 -1
- package/.github/workflows/checks.yml +0 -16
- package/.github/workflows/publish.yml +0 -52
- package/.prettierignore +0 -5
- package/CONTRIBUTING.md +0 -29
- package/babel.config.js +0 -3
- package/documentation/config.js +0 -15
- package/documentation/content/KWVolViewLogo.png +0 -0
- package/documentation/content/KWVolViewLogo.svg +0 -35
- package/documentation/content/VolViewLogo.png +0 -0
- package/documentation/content/VolViewLogo.svg +0 -22
- package/documentation/content/doc/index.md +0 -64
- package/documentation/content/doc/loading_data.md +0 -30
- package/documentation/content/doc/mouse_controls.md +0 -34
- package/documentation/content/doc/quick_start_guide.md +0 -75
- package/documentation/content/doc/rendering.md +0 -27
- package/documentation/content/doc/state_files.md +0 -18
- package/documentation/content/doc/toolbar.md +0 -20
- package/documentation/content/doc/welcome_screen.md +0 -23
- package/documentation/content/gallery/01-volview-welcome-notes.jpg +0 -0
- package/documentation/content/gallery/01-volview-welcome.jpg +0 -0
- package/documentation/content/gallery/02-volview-about.jpg +0 -0
- package/documentation/content/gallery/02-volview-notifications.jpg +0 -0
- package/documentation/content/gallery/02-volview-settings.jpg +0 -0
- package/documentation/content/gallery/03-volview-sample-datasets.jpg +0 -0
- package/documentation/content/gallery/04-volview-active-data.jpg +0 -0
- package/documentation/content/gallery/05-volview-select-data-to-delete.jpg +0 -0
- package/documentation/content/gallery/06-volview-corner-annotation.jpg +0 -0
- package/documentation/content/gallery/07-volview-layout-notes.jpg +0 -0
- package/documentation/content/gallery/07-volview-layout.jpg +0 -0
- package/documentation/content/gallery/09-volview-layout-3DPrimary.jpg +0 -0
- package/documentation/content/gallery/10-volview-wl-pan-zoom-notes.jpg +0 -0
- package/documentation/content/gallery/10-volview-wl-pan-zoom.jpg +0 -0
- package/documentation/content/gallery/11-volview-paint-notes.jpg +0 -0
- package/documentation/content/gallery/11-volview-paint.jpg +0 -0
- package/documentation/content/gallery/12-volview-paint-options.jpg +0 -0
- package/documentation/content/gallery/13-volview-crop-notes.jpg +0 -0
- package/documentation/content/gallery/13-volview-crop.jpg +0 -0
- package/documentation/content/gallery/14-volview-ruler.jpg +0 -0
- package/documentation/content/gallery/15-volview-crosshairs.jpg +0 -0
- package/documentation/content/gallery/16-volview-rendering.jpg +0 -0
- package/documentation/content/gallery/17-volview-colormap-notes.jpg +0 -0
- package/documentation/content/gallery/17-volview-colormap.jpg +0 -0
- package/documentation/content/gallery/17-volview-opacity-notes.jpg +0 -0
- package/documentation/content/gallery/17-volview-opacity.jpg +0 -0
- package/documentation/content/gallery/17-volview-opacity2.jpg +0 -0
- package/documentation/content/gallery/18-volview-presets.jpg +0 -0
- package/documentation/content/gallery/19-volview-color.jpg +0 -0
- package/documentation/content/gallery/19-volview-color2.jpg +0 -0
- package/documentation/content/gallery/20-volview-lightfollowcamera0.jpg +0 -0
- package/documentation/content/gallery/20-volview-lightfollowcamera1.jpg +0 -0
- package/documentation/content/gallery/20-volview-lightfollowcamera2.jpg +0 -0
- package/documentation/content/gallery/20-volview-lightfollowcamera3.jpg +0 -0
- package/documentation/content/gallery/21-volview-hybrid-final.jpg +0 -0
- package/documentation/content/gallery/21-volview-hybrid0.0.jpg +0 -0
- package/documentation/content/gallery/21-volview-hybrid0.5.jpg +0 -0
- package/documentation/content/gallery/21-volview-hybrid1.0.jpg +0 -0
- package/documentation/content/gallery/LocalAmbientOcclusion.jpg +0 -0
- package/documentation/content/gallery/Notes.pptx +0 -0
- package/documentation/content/gallery/VolView-Overview.jpg +0 -0
- package/documentation/content/gallery/index.md +0 -53
- package/documentation/content/icon/favicon-16x16.png +0 -0
- package/documentation/content/icon/favicon-196x196.png +0 -0
- package/documentation/content/icon/favicon-32x32.png +0 -0
- package/documentation/content/icon/favicon-96x96.png +0 -0
- package/documentation/content/index.pug +0 -43
- package/documentation/content/logo.png +0 -0
- package/documentation/content/logo.svg +0 -20
- package/documentation/data/menu.yml +0 -3
- package/documentation/themes/navy/layout/partial/footer.swig +0 -22
- package/documentation/tpl/__en__ +0 -31
- package/documentation/tpl/__sidebar__ +0 -11
- package/patches/jsdom-global+3.0.2.patch +0 -12
- package/patches/vue-toastification+1.7.14.patch +0 -41
- package/patches/vuetify+2.6.10.patch +0 -13
- package/prettier.config.js +0 -9
- package/public/index.html +0 -28
- package/server/helper.py +0 -147
- package/server/host.js +0 -134
- package/server/serialize.js +0 -111
- package/server/serialize.py +0 -203
- package/server/server.py +0 -84
- package/server/test.py +0 -17
- package/src/assets/logo.png +0 -0
- package/src/assets/logo.svg +0 -20
- package/src/assets/samples/3DUS-Fetus.jpg +0 -0
- package/src/assets/samples/CTA-Head_and_Neck.jpg +0 -0
- package/src/assets/samples/MRA-Head_and_Neck.jpg +0 -0
- package/src/assets/samples/MRI-Cardiac.jpg +0 -0
- package/src/assets/samples/MRI-PROSTATEx.jpg +0 -0
- package/src/components/AboutBox.vue +0 -157
- package/src/components/AiModule.vue +0 -60
- package/src/components/AnnotationsModule.vue +0 -37
- package/src/components/App.vue +0 -539
- package/src/components/ColorFunctionSlider.vue +0 -181
- package/src/components/DataBrowser.vue +0 -173
- package/src/components/DragAndDrop.vue +0 -107
- package/src/components/GroupableItem.vue +0 -30
- package/src/components/ImageDataBrowser.vue +0 -186
- package/src/components/ImageListCard.vue +0 -114
- package/src/components/ItemGroup.vue +0 -74
- package/src/components/LabelmapList.vue +0 -36
- package/src/components/LayoutGrid.vue +0 -96
- package/src/components/MeasurementsList.vue +0 -134
- package/src/components/MessageCenter.vue +0 -189
- package/src/components/MessageItem.vue +0 -83
- package/src/components/MessageNotificationContent.vue +0 -20
- package/src/components/MessageNotifications.vue +0 -84
- package/src/components/ModelBrowser.vue +0 -83
- package/src/components/ModulePanel.vue +0 -137
- package/src/components/PaintControls.vue +0 -174
- package/src/components/PatientBrowser.vue +0 -280
- package/src/components/PatientStudyVolumeBrowser.vue +0 -325
- package/src/components/RenderingModule.vue +0 -49
- package/src/components/ResizableNavDrawer.vue +0 -158
- package/src/components/SampleDataBrowser.vue +0 -198
- package/src/components/SaveSession.vue +0 -57
- package/src/components/Settings.vue +0 -35
- package/src/components/SliceSlider.vue +0 -182
- package/src/components/SpleenModule.vue +0 -101
- package/src/components/ToolButton.vue +0 -58
- package/src/components/ToolStrip.vue +0 -186
- package/src/components/ViewOverlayGrid.vue +0 -84
- package/src/components/VolumePresets.vue +0 -165
- package/src/components/VolumeProperties.vue +0 -171
- package/src/components/VolumeRendering.vue +0 -365
- package/src/components/VtkThreeView.vue +0 -512
- package/src/components/VtkTwoView.vue +0 -665
- package/src/components/__tests__/ResizableNavDrawer.spec.js +0 -32
- package/src/components/__tests__/ToolButton.spec.js +0 -46
- package/src/components/icons/KitwareLogoIcon.vue +0 -54
- package/src/components/icons/VolViewFullLogo.vue +0 -139
- package/src/components/icons/VolViewLogo.vue +0 -78
- package/src/components/styles/utils.css +0 -16
- package/src/components/styles/vtk-view.css +0 -116
- package/src/components/tools/CropTool.vue +0 -61
- package/src/components/tools/CrosshairsTool.vue +0 -93
- package/src/components/tools/MouseManipulatorTool.vue +0 -108
- package/src/components/tools/PaintTool.vue +0 -54
- package/src/components/tools/PanTool.vue +0 -35
- package/src/components/tools/RulerTool.vue +0 -202
- package/src/components/tools/SliceScrollTool.vue +0 -123
- package/src/components/tools/WindowLevelTool.vue +0 -191
- package/src/components/tools/ZoomTool.vue +0 -35
- package/src/components/tools/crop/Crop2D.vue +0 -367
- package/src/components/tools/crop/Crop2DLineHandle.vue +0 -103
- package/src/components/tools/crop/Crop3D.vue +0 -192
- package/src/components/tools/crop/CropControls.vue +0 -38
- package/src/components/tools/crop/types.ts +0 -12
- package/src/components/tools/crosshairs/CrosshairSVG2D.vue +0 -125
- package/src/components/tools/crosshairs/CrosshairsWidget2D.vue +0 -100
- package/src/components/tools/paint/PaintWidget2D.vue +0 -192
- package/src/components/tools/ruler/RulerSVG2D.vue +0 -181
- package/src/components/tools/ruler/RulerWidget2D.vue +0 -154
- package/src/composables/__tests__/useDoubleRecord.spec.ts +0 -57
- package/src/composables/__tests__/useOrientationLabels.spec.ts +0 -29
- package/src/composables/isViewAnimating.ts +0 -25
- package/src/composables/manageVTKSubscription.ts +0 -6
- package/src/composables/onProxyManagerEvent.ts +0 -50
- package/src/composables/proxyManager.ts +0 -13
- package/src/composables/sync/__tests__/createPrimitiveSyncContext.spec.ts +0 -41
- package/src/composables/sync/__tests__/useWindowingSync.spec.ts +0 -51
- package/src/composables/sync/createPrimitiveSyncContext.ts +0 -83
- package/src/composables/sync/useWindowingSync.ts +0 -48
- package/src/composables/useAppLoadingNotifications.ts +0 -73
- package/src/composables/useCameraOrientation.ts +0 -34
- package/src/composables/useCurrentImage.ts +0 -74
- package/src/composables/useCurrentSlice.ts +0 -43
- package/src/composables/useDoubleRecord.ts +0 -77
- package/src/composables/useEventListener.ts +0 -26
- package/src/composables/useGlobalErrorHook.ts +0 -18
- package/src/composables/useMultiSelection.ts +0 -29
- package/src/composables/useOrientationLabels.ts +0 -62
- package/src/composables/usePanels.ts +0 -42
- package/src/composables/usePersistCameraConfig.ts +0 -138
- package/src/composables/useResizeObserver.ts +0 -37
- package/src/composables/useResizeToFit.ts +0 -50
- package/src/composables/useSceneBuilder.ts +0 -96
- package/src/composables/useToast.js +0 -11
- package/src/composables/useVTKCallback.ts +0 -33
- package/src/composables/useVTKWorldToDisplay.ts +0 -141
- package/src/composables/useViewProxy.ts +0 -87
- package/src/composables/useVolumeThumbnailing.ts +0 -173
- package/src/composables/useWebGLWatchdog.ts +0 -32
- package/src/composables/useWidgetManager.ts +0 -41
- package/src/config.ts +0 -182
- package/src/constants.ts +0 -38
- package/src/core/id.ts +0 -18
- package/src/core/provider.ts +0 -31
- package/src/core/proxies.ts +0 -90
- package/src/core/thumbnailers/__tests__/vtk-image.spec.ts +0 -58
- package/src/core/thumbnailers/index.ts +0 -5
- package/src/core/thumbnailers/volume-thumbnailer.ts +0 -130
- package/src/core/thumbnailers/vtk-image.ts +0 -142
- package/src/core/tools/__tests__/paint.spec.ts +0 -101
- package/src/core/tools/__tests__/ruler.spec.ts +0 -73
- package/src/core/tools/paint/brush.ts +0 -20
- package/src/core/tools/paint/ellipse-brush.ts +0 -96
- package/src/core/tools/paint/index.ts +0 -141
- package/src/core/tools/ruler.ts +0 -149
- package/src/global.d.ts +0 -24
- package/src/io/__tests__/io.spec.ts +0 -26
- package/src/io/dicom.ts +0 -187
- package/src/io/index.ts +0 -11
- package/src/io/io.ts +0 -157
- package/src/io/itk/itkConfig.js +0 -8
- package/src/io/itk-dicom/dicom.cpp +0 -327
- package/src/io/itk-dicom/web-build/dicom.js +0 -16
- package/src/io/itk-dicom/web-build/dicom.umd.js +0 -21
- package/src/io/manifest.ts +0 -30
- package/src/io/readers.ts +0 -36
- package/src/io/state-file/index.ts +0 -170
- package/src/io/state-file/schema.ts +0 -277
- package/src/io/state-file/utils.ts +0 -33
- package/src/io/types.ts +0 -4
- package/src/io/vtk/async.reader.worker.ts +0 -50
- package/src/io/vtk/async.ts +0 -58
- package/src/io/vtk/async.writer.worker.ts +0 -46
- package/src/io/vtk/common.ts +0 -30
- package/src/io/zip.ts +0 -31
- package/src/main.js +0 -66
- package/src/main.ts +0 -1
- package/src/plugins/vuetify.js +0 -25
- package/src/shims-itk.d.ts +0 -67
- package/src/shims-misc.d.ts +0 -4
- package/src/shims-tsx.d.ts +0 -13
- package/src/shims-vtk.d.ts +0 -1042
- package/src/shims-vue.d.ts +0 -5
- package/src/store/__tests__/datasets.spec.ts +0 -75
- package/src/store/__tests__/messages.spec.ts +0 -74
- package/src/store/__tests__/rulers.spec.ts +0 -77
- package/src/store/__tests__/view-configs.spec.ts +0 -37
- package/src/store/datasets-dicom.ts +0 -398
- package/src/store/datasets-files.ts +0 -35
- package/src/store/datasets-images.ts +0 -118
- package/src/store/datasets-labelmaps.ts +0 -136
- package/src/store/datasets-models.ts +0 -25
- package/src/store/datasets.ts +0 -341
- package/src/store/messages.ts +0 -144
- package/src/store/tools/crop.ts +0 -136
- package/src/store/tools/crosshairs.ts +0 -131
- package/src/store/tools/index.ts +0 -95
- package/src/store/tools/paint.ts +0 -191
- package/src/store/tools/rulers.ts +0 -305
- package/src/store/tools/types.ts +0 -54
- package/src/store/view-configs/camera.ts +0 -51
- package/src/store/view-configs/common.ts +0 -61
- package/src/store/view-configs/slicing.ts +0 -86
- package/src/store/view-configs/types.ts +0 -39
- package/src/store/view-configs/volume-coloring.ts +0 -193
- package/src/store/view-configs/windowing.ts +0 -69
- package/src/store/view-configs.ts +0 -78
- package/src/store/views.ts +0 -130
- package/src/types/index.ts +0 -16
- package/src/types/layout.ts +0 -10
- package/src/types/lps.ts +0 -40
- package/src/types/views.ts +0 -65
- package/src/types/vtk-types.ts +0 -29
- package/src/utils/__tests__/lps.spec.ts +0 -102
- package/src/utils/color.ts +0 -23
- package/src/utils/errors.js +0 -3
- package/src/utils/fetch.ts +0 -101
- package/src/utils/hacks.ts +0 -14
- package/src/utils/index.ts +0 -83
- package/src/utils/lps.ts +0 -129
- package/src/utils/manipulators.ts +0 -35
- package/src/utils/promise-worker.ts +0 -45
- package/src/utils/vtk-helpers.ts +0 -215
- package/src/utils/workerHandler.js +0 -42
- package/src/vtk/ColorMaps.ts +0 -72
- package/src/vtk/CrosshairsWidget/behavior.ts +0 -112
- package/src/vtk/CrosshairsWidget/index.d.ts +0 -22
- package/src/vtk/CrosshairsWidget/index.js +0 -73
- package/src/vtk/CrosshairsWidget/state.ts +0 -51
- package/src/vtk/IJKSliceRepresentationProxy/index.d.ts +0 -9
- package/src/vtk/IJKSliceRepresentationProxy/index.js +0 -59
- package/src/vtk/LPSView2DProxy/index.d.ts +0 -18
- package/src/vtk/LPSView2DProxy/index.js +0 -89
- package/src/vtk/LPSView3DProxy/index.d.ts +0 -16
- package/src/vtk/LPSView3DProxy/index.js +0 -78
- package/src/vtk/LabelMap/index.d.ts +0 -16
- package/src/vtk/LabelMap/index.js +0 -49
- package/src/vtk/LabelMapSliceRepProxy/index.d.ts +0 -6
- package/src/vtk/LabelMapSliceRepProxy/index.js +0 -104
- package/src/vtk/MedicalColorPresets.json +0 -1448
- package/src/vtk/PaintBrushContextRepresentation/index.js +0 -191
- package/src/vtk/PaintWidget/behavior.ts +0 -101
- package/src/vtk/PaintWidget/index.d.ts +0 -28
- package/src/vtk/PaintWidget/index.js +0 -56
- package/src/vtk/PaintWidget/state.ts +0 -41
- package/src/vtk/PiecewiseWidget/index.js +0 -203
- package/src/vtk/RulerWidget/behavior.ts +0 -185
- package/src/vtk/RulerWidget/index.d.ts +0 -25
- package/src/vtk/RulerWidget/index.js +0 -79
- package/src/vtk/RulerWidget/state.ts +0 -63
- package/src/vtk/TreJsonConverter/index.js +0 -150
- package/src/vtk/proxy.js +0 -66
- package/src/vtk/proxyUtils.js +0 -16
- package/src/vtk/webvr-empty.js +0 -1
- package/tests/testUtils.js +0 -12
- package/tsconfig.json +0 -46
- package/vue.config.js +0 -86
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import vtkPolyData from '@kitware/vtk.js/Common/DataModel/PolyData';
|
|
2
|
-
import vtkActor2D from '@kitware/vtk.js/Rendering/Core/Actor2D';
|
|
3
|
-
import vtkContextRepresentation from '@kitware/vtk.js/Widgets/Representations/ContextRepresentation';
|
|
4
|
-
import vtkWidgetRepresentation from '@kitware/vtk.js/Widgets/Representations/WidgetRepresentation';
|
|
5
|
-
import macro from '@kitware/vtk.js/macros';
|
|
6
|
-
import vtkMapper2D from '@kitware/vtk.js/Rendering/Core/Mapper2D';
|
|
7
|
-
import vtkCoordinate from '@kitware/vtk.js/Rendering/Core/Coordinate';
|
|
8
|
-
import { Coordinate } from '@kitware/vtk.js/Rendering/Core/Coordinate/Constants';
|
|
9
|
-
import { Representation } from '@kitware/vtk.js/Rendering/Core/Property/Constants';
|
|
10
|
-
import { DisplayLocation } from '@kitware/vtk.js/Rendering/Core/Property2D/Constants';
|
|
11
|
-
import { vec3 } from 'gl-matrix';
|
|
12
|
-
|
|
13
|
-
function generateContour({ stencil, location, slicingIndex, indexToWorld }) {
|
|
14
|
-
const [xdim, ydim] = stencil.size;
|
|
15
|
-
const xoffset = Math.floor((xdim - 1) / 2);
|
|
16
|
-
const yoffset = Math.floor((ydim - 1) / 2);
|
|
17
|
-
|
|
18
|
-
// grid of corner points (top-left to bottom-right)
|
|
19
|
-
const gridxdim = xdim + 1;
|
|
20
|
-
const gridydim = ydim + 1;
|
|
21
|
-
|
|
22
|
-
const vertices = []; // arr of 3-tuples
|
|
23
|
-
const lines = []; // arr of 2-tuples of vertex indices
|
|
24
|
-
|
|
25
|
-
// maps grid x/y to vertex index
|
|
26
|
-
const vertexMap = {};
|
|
27
|
-
const getOrCreateVertexIndex = (x, y) => {
|
|
28
|
-
const key = `${x},${y}`;
|
|
29
|
-
if (key in vertexMap) {
|
|
30
|
-
return vertexMap[key];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const indexCoords = [...location].map((val) => Math.round(val));
|
|
34
|
-
if (slicingIndex === 0) {
|
|
35
|
-
indexCoords[1] += x - xoffset - 0.5;
|
|
36
|
-
indexCoords[2] += y - yoffset - 0.5;
|
|
37
|
-
} else if (slicingIndex === 1) {
|
|
38
|
-
indexCoords[0] += x - xoffset - 0.5;
|
|
39
|
-
indexCoords[2] += y - yoffset - 0.5;
|
|
40
|
-
} else if (slicingIndex === 2) {
|
|
41
|
-
indexCoords[0] += x - xoffset - 0.5;
|
|
42
|
-
indexCoords[1] += y - yoffset - 0.5;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// get the grid point x/y's actual vertex in world space
|
|
46
|
-
// since grid x/y represents the top-left of the actual pixel
|
|
47
|
-
// at x/y, the true continuous index value of the vertex
|
|
48
|
-
// is x-0.5/y-0.5.
|
|
49
|
-
|
|
50
|
-
const worldCoords = [];
|
|
51
|
-
vec3.transformMat4(worldCoords, indexCoords, indexToWorld);
|
|
52
|
-
vertices.push(worldCoords);
|
|
53
|
-
|
|
54
|
-
const index = vertices.length - 1;
|
|
55
|
-
vertexMap[key] = index;
|
|
56
|
-
return index;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
const getStampPixelAt = (x, y) => {
|
|
60
|
-
if (x < 0 || x >= xdim) return 0;
|
|
61
|
-
if (y < 0 || y >= ydim) return 0;
|
|
62
|
-
return stencil.pixels[y * xdim + x] || 0;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
for (let gy = 0; gy < gridydim; gy++) {
|
|
66
|
-
for (let gx = 0; gx < gridxdim; gx++) {
|
|
67
|
-
// evaluate point to see if it needs inclusion
|
|
68
|
-
// by looking at all 4 pixels that share this point
|
|
69
|
-
// as a corner.
|
|
70
|
-
// if all empty or all filled, the current point is
|
|
71
|
-
// not used in the contour.
|
|
72
|
-
const count =
|
|
73
|
-
getStampPixelAt(gx, gy) +
|
|
74
|
-
getStampPixelAt(gx - 1, gy) +
|
|
75
|
-
getStampPixelAt(gx, gy - 1) +
|
|
76
|
-
getStampPixelAt(gx - 1, gy - 1);
|
|
77
|
-
|
|
78
|
-
if (count > 0 && count < 4) {
|
|
79
|
-
const v0 = getOrCreateVertexIndex(gx, gy);
|
|
80
|
-
|
|
81
|
-
// now do line check. We look at the east and south lines.
|
|
82
|
-
// east first
|
|
83
|
-
if (getStampPixelAt(gx, gy) !== getStampPixelAt(gx, gy - 1)) {
|
|
84
|
-
const v1 = getOrCreateVertexIndex(gx + 1, gy);
|
|
85
|
-
lines.push([v0, v1]);
|
|
86
|
-
}
|
|
87
|
-
// south next
|
|
88
|
-
if (getStampPixelAt(gx, gy) !== getStampPixelAt(gx - 1, gy)) {
|
|
89
|
-
const v1 = getOrCreateVertexIndex(gx, gy + 1);
|
|
90
|
-
lines.push([v0, v1]);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return {
|
|
97
|
-
points: new Float32Array(vertices.flat()),
|
|
98
|
-
lines: new Uint16Array(lines.map(([v0, v1]) => [2, v0, v1]).flat()),
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function vtkPaintBrushContextRepresentation(publicAPI, model) {
|
|
103
|
-
model.classHierarchy.push('vtkPaintBrushContextRepresentation');
|
|
104
|
-
|
|
105
|
-
model.internalPolyData = vtkPolyData.newInstance({ mtime: 0 });
|
|
106
|
-
model.internalArrays = {
|
|
107
|
-
points: model.internalPolyData.getPoints(),
|
|
108
|
-
lines: model.internalPolyData.getLines(),
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
model.pipelines = {
|
|
112
|
-
brush: {
|
|
113
|
-
source: publicAPI,
|
|
114
|
-
mapper: vtkMapper2D.newInstance({
|
|
115
|
-
transformCoordinate: vtkCoordinate.newInstance({
|
|
116
|
-
coordinateSystem: Coordinate.WORLD,
|
|
117
|
-
}),
|
|
118
|
-
}),
|
|
119
|
-
actor: vtkActor2D.newInstance({ pickable: false, parentProp: publicAPI }),
|
|
120
|
-
},
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const actorProperty = model.pipelines.brush.actor.getProperty();
|
|
124
|
-
actorProperty.setLineWidth(2);
|
|
125
|
-
actorProperty.setColor([1, 0, 0]);
|
|
126
|
-
actorProperty.setDisplayLocation(DisplayLocation.FOREGROUND);
|
|
127
|
-
actorProperty.setRepresentation(Representation.SURFACE);
|
|
128
|
-
|
|
129
|
-
vtkWidgetRepresentation.connectPipeline(model.pipelines.brush);
|
|
130
|
-
|
|
131
|
-
publicAPI.addActor(model.pipelines.brush.actor);
|
|
132
|
-
|
|
133
|
-
publicAPI.requestData = (inData, outData) => {
|
|
134
|
-
const widgetState = inData[0];
|
|
135
|
-
|
|
136
|
-
const stencil = widgetState.getStencil();
|
|
137
|
-
const brush = widgetState.getBrush();
|
|
138
|
-
const { indexToWorld, worldToIndex } = model;
|
|
139
|
-
|
|
140
|
-
if (stencil && brush.getOrigin()) {
|
|
141
|
-
const location = [];
|
|
142
|
-
vec3.transformMat4(location, brush.getOrigin(), worldToIndex);
|
|
143
|
-
|
|
144
|
-
const contour = generateContour({
|
|
145
|
-
stencil,
|
|
146
|
-
location,
|
|
147
|
-
slicingIndex: model.slicingIndex,
|
|
148
|
-
indexToWorld,
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
const { points, lines } = model.internalArrays;
|
|
152
|
-
points.setData(contour.points);
|
|
153
|
-
lines.setData(contour.lines);
|
|
154
|
-
|
|
155
|
-
model.internalPolyData.modified();
|
|
156
|
-
}
|
|
157
|
-
outData[0] = model.internalPolyData;
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
const DEFAULT_VALUES = {
|
|
162
|
-
defaultScale: 1,
|
|
163
|
-
drawBorder: false,
|
|
164
|
-
drawFace: true,
|
|
165
|
-
worldToIndex: null,
|
|
166
|
-
indexToWorld: null,
|
|
167
|
-
slicingIndex: 0,
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
// ----------------------------------------------------------------------------
|
|
171
|
-
|
|
172
|
-
export function extend(publicAPI, model, initialValues = {}) {
|
|
173
|
-
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
174
|
-
vtkContextRepresentation.extend(publicAPI, model, initialValues);
|
|
175
|
-
macro.setGet(publicAPI, model, [
|
|
176
|
-
'slicingIndex',
|
|
177
|
-
'indexToWorld',
|
|
178
|
-
'worldToIndex',
|
|
179
|
-
]);
|
|
180
|
-
macro.get(publicAPI, model, ['mapper', 'actor']);
|
|
181
|
-
vtkPaintBrushContextRepresentation(publicAPI, model);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
// ----------------------------------------------------------------------------
|
|
185
|
-
|
|
186
|
-
export const newInstance = macro.newInstance(
|
|
187
|
-
extend,
|
|
188
|
-
'vtkPaintBrushContextRepresentation'
|
|
189
|
-
);
|
|
190
|
-
|
|
191
|
-
export default { newInstance, extend };
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import macro from '@kitware/vtk.js/macro';
|
|
2
|
-
|
|
3
|
-
export function shouldIgnoreEvent(e: any) {
|
|
4
|
-
return e.altKey || e.controlKey || e.shiftKey;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export default function widgetBehavior(publicAPI: any, model: any) {
|
|
8
|
-
model.classHierarchy.push('vtkPaintWidgetProp');
|
|
9
|
-
|
|
10
|
-
// support setting per-view widget manipulators
|
|
11
|
-
macro.setGet(publicAPI, model, ['manipulator']);
|
|
12
|
-
|
|
13
|
-
let isPainting = false;
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Starts painting
|
|
17
|
-
*/
|
|
18
|
-
publicAPI.handleLeftButtonPress = (eventData: any) => {
|
|
19
|
-
if (!model.manipulator || shouldIgnoreEvent(eventData)) {
|
|
20
|
-
return macro.VOID;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const worldCoords = model.manipulator.handleEvent(
|
|
24
|
-
eventData,
|
|
25
|
-
model._apiSpecificRenderWindow
|
|
26
|
-
);
|
|
27
|
-
|
|
28
|
-
if (!worldCoords) {
|
|
29
|
-
return macro.VOID;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const brush = model.widgetState.getBrush();
|
|
33
|
-
brush.setOrigin(...worldCoords);
|
|
34
|
-
|
|
35
|
-
isPainting = true;
|
|
36
|
-
publicAPI.invokeStartInteractionEvent();
|
|
37
|
-
return macro.EVENT_ABORT;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Paints
|
|
42
|
-
*/
|
|
43
|
-
publicAPI.handleMouseMove = (eventData: any) => {
|
|
44
|
-
if (shouldIgnoreEvent(eventData)) {
|
|
45
|
-
return macro.VOID;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const worldCoords = model.manipulator.handleEvent(
|
|
49
|
-
eventData,
|
|
50
|
-
model._apiSpecificRenderWindow
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
if (!worldCoords) {
|
|
54
|
-
return macro.VOID;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const brush = model.widgetState.getBrush();
|
|
58
|
-
brush.setOrigin(...worldCoords);
|
|
59
|
-
|
|
60
|
-
if (isPainting) {
|
|
61
|
-
publicAPI.invokeInteractionEvent();
|
|
62
|
-
}
|
|
63
|
-
return macro.EVENT_ABORT;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Finishes paint
|
|
68
|
-
*/
|
|
69
|
-
publicAPI.handleLeftButtonRelease = (eventData: any) => {
|
|
70
|
-
if (!isPainting || shouldIgnoreEvent(eventData)) {
|
|
71
|
-
return macro.VOID;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
isPainting = false;
|
|
75
|
-
publicAPI.invokeEndInteractionEvent();
|
|
76
|
-
return macro.EVENT_ABORT;
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
publicAPI.handleMouseWheel = () => {
|
|
80
|
-
if (isPainting) {
|
|
81
|
-
return macro.EVENT_ABORT;
|
|
82
|
-
}
|
|
83
|
-
return macro.VOID;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
publicAPI.grabFocus = () => {
|
|
87
|
-
if (!model.hasFocus) {
|
|
88
|
-
model.hasFocus = true;
|
|
89
|
-
model._interactor.requestAnimation(publicAPI);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
publicAPI.loseFocus = () => {
|
|
94
|
-
if (model.hasFocus) {
|
|
95
|
-
model._interactor.cancelAnimation(publicAPI);
|
|
96
|
-
}
|
|
97
|
-
model.hasFocus = false;
|
|
98
|
-
// model._widgetManager.enablePicking();
|
|
99
|
-
// model._interactor.render();
|
|
100
|
-
};
|
|
101
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import vtkAbstractWidget from '@kitware/vtk.js/Widgets/Core/AbstractWidget';
|
|
2
|
-
import vtkAbstractWidgetFactory from '@kitware/vtk.js/Widgets/Core/AbstractWidgetFactory';
|
|
3
|
-
import vtkPlaneManipulator from '@kitware/vtk.js/Widgets/Manipulators/PlaneManipulator';
|
|
4
|
-
import { mat4, vec3 } from 'gl-matrix';
|
|
5
|
-
import { PaintWidgetState } from './state';
|
|
6
|
-
|
|
7
|
-
export interface vtkPaintViewWidget extends vtkAbstractWidget {
|
|
8
|
-
setManipulator(manipulator: vtkPlaneManipulator): boolean;
|
|
9
|
-
getManipulator(): vtkPlaneManipulator;
|
|
10
|
-
setSlicingIndex(index: number): boolean;
|
|
11
|
-
setIndexToWorld(transform: mat4): boolean;
|
|
12
|
-
getIndexToWorld(): mat4;
|
|
13
|
-
setWorldToIndex(transform: mat4): boolean;
|
|
14
|
-
getWorldToIndex(): mat4;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface vtkPaintWidget extends vtkAbstractWidgetFactory {
|
|
18
|
-
getWidgetState(): PaintWidgetState;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function newInstance(): vtkPaintWidget;
|
|
22
|
-
|
|
23
|
-
export function shouldIgnoreEvent(ev: any): boolean;
|
|
24
|
-
|
|
25
|
-
export declare const vtkPaintWidget: {
|
|
26
|
-
newInstance: typeof newInstance;
|
|
27
|
-
};
|
|
28
|
-
export default vtkPaintWidget;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import macro from '@kitware/vtk.js/macro';
|
|
2
|
-
import vtkAbstractWidgetFactory from '@kitware/vtk.js/Widgets/Core/AbstractWidgetFactory';
|
|
3
|
-
import vtkPlanePointManipulator from '@kitware/vtk.js/Widgets/Manipulators/PlaneManipulator';
|
|
4
|
-
import vtkPaintBrushContextRepresentation from '@/src/vtk/PaintBrushContextRepresentation';
|
|
5
|
-
|
|
6
|
-
import widgetBehavior from './behavior';
|
|
7
|
-
import stateGenerator from './state';
|
|
8
|
-
|
|
9
|
-
export { shouldIgnoreEvent } from './behavior';
|
|
10
|
-
|
|
11
|
-
// ----------------------------------------------------------------------------
|
|
12
|
-
// Factory
|
|
13
|
-
// ----------------------------------------------------------------------------
|
|
14
|
-
|
|
15
|
-
function vtkPaintWidget(publicAPI, model) {
|
|
16
|
-
model.classHierarchy.push('vtkPaintWidget');
|
|
17
|
-
|
|
18
|
-
model.methodsToLink = ['slicingIndex', 'indexToWorld', 'worldToIndex'];
|
|
19
|
-
|
|
20
|
-
publicAPI.getRepresentationsForViewType = () => [
|
|
21
|
-
{
|
|
22
|
-
builder: vtkPaintBrushContextRepresentation,
|
|
23
|
-
labels: ['brush'],
|
|
24
|
-
},
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
// Default manipulator
|
|
28
|
-
model.manipulator = vtkPlanePointManipulator.newInstance();
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// ----------------------------------------------------------------------------
|
|
32
|
-
|
|
33
|
-
const DEFAULT_VALUES = {};
|
|
34
|
-
|
|
35
|
-
// ----------------------------------------------------------------------------
|
|
36
|
-
|
|
37
|
-
export function extend(publicAPI, model, initialValues = {}) {
|
|
38
|
-
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
39
|
-
|
|
40
|
-
vtkAbstractWidgetFactory.extend(publicAPI, model, {
|
|
41
|
-
...initialValues,
|
|
42
|
-
behavior: widgetBehavior,
|
|
43
|
-
widgetState: stateGenerator(),
|
|
44
|
-
});
|
|
45
|
-
macro.get(publicAPI, model, ['manipulator']);
|
|
46
|
-
|
|
47
|
-
vtkPaintWidget(publicAPI, model);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// ----------------------------------------------------------------------------
|
|
51
|
-
|
|
52
|
-
export const newInstance = macro.newInstance(extend, 'vtkPaintWidget');
|
|
53
|
-
|
|
54
|
-
// ----------------------------------------------------------------------------
|
|
55
|
-
|
|
56
|
-
export default { newInstance, extend };
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { IBrushStencil } from '@/src/core/tools/paint/brush';
|
|
2
|
-
import { Vector3 } from '@kitware/vtk.js/types';
|
|
3
|
-
import vtkStateBuilder from '@kitware/vtk.js/Widgets/Core/StateBuilder';
|
|
4
|
-
import vtkWidgetState from '@kitware/vtk.js/Widgets/Core/WidgetState';
|
|
5
|
-
|
|
6
|
-
export interface PaintPointWidgetState extends vtkWidgetState {
|
|
7
|
-
setOrigin(origin: Vector3 | null): boolean;
|
|
8
|
-
getOrigin(): Vector3 | null;
|
|
9
|
-
setScale1(scale: number): boolean;
|
|
10
|
-
getScale1(): number;
|
|
11
|
-
setVisible(visible: boolean): boolean;
|
|
12
|
-
getVisible(): boolean;
|
|
13
|
-
setColor(color: number): boolean;
|
|
14
|
-
getColor(): number;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface PaintWidgetState extends vtkWidgetState {
|
|
18
|
-
getBrush(): PaintPointWidgetState;
|
|
19
|
-
getStencil(): IBrushStencil;
|
|
20
|
-
setStencil(stencil: IBrushStencil): boolean;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export default function generateState() {
|
|
24
|
-
return vtkStateBuilder
|
|
25
|
-
.createBuilder()
|
|
26
|
-
.addStateFromMixin({
|
|
27
|
-
labels: ['brush'],
|
|
28
|
-
name: 'brush',
|
|
29
|
-
mixins: ['origin', 'scale1', 'visible', 'color'],
|
|
30
|
-
initialValues: {
|
|
31
|
-
scale1: 1,
|
|
32
|
-
origin: null,
|
|
33
|
-
visible: true,
|
|
34
|
-
},
|
|
35
|
-
})
|
|
36
|
-
.addField({
|
|
37
|
-
name: 'stencil',
|
|
38
|
-
initialValue: null,
|
|
39
|
-
})
|
|
40
|
-
.build() as PaintWidgetState;
|
|
41
|
-
}
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import macro from '@kitware/vtk.js/macro';
|
|
2
|
-
import vtkPiecewiseGaussianWidget from '@kitware/vtk.js/Interaction/Widgets/PiecewiseGaussianWidget';
|
|
3
|
-
|
|
4
|
-
export const Mode = {
|
|
5
|
-
Gaussians: 1,
|
|
6
|
-
Points: 2,
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const ADJUST_POSITION_CURSOR = '-webkit-grab';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Samples a piecewise linear function at regular intervals in [0,1].
|
|
13
|
-
* The first and last values are set to zero, since the output
|
|
14
|
-
* is used for vtkPiecewiseGaussianWidget.drawChart().
|
|
15
|
-
*
|
|
16
|
-
* Assumes normalized x/y coordinate points.
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
export function samplePiecewiseLinear(points, shift = 0, samples = 256) {
|
|
20
|
-
const filledPoints = [...points];
|
|
21
|
-
// set endpoints to drop to 0
|
|
22
|
-
filledPoints.push([points[0][0], 0]);
|
|
23
|
-
filledPoints.push([points[points.length - 1][0], 0]);
|
|
24
|
-
|
|
25
|
-
const sampledPoints = [];
|
|
26
|
-
let pi = 0;
|
|
27
|
-
let p1 = filledPoints[0]; // left
|
|
28
|
-
let p2 = filledPoints[1]; // right
|
|
29
|
-
let slope = (p2[1] - p1[1]) / (p2[0] - p1[0]);
|
|
30
|
-
for (let i = 0; i < samples; i += 1) {
|
|
31
|
-
const sx = i / (samples - 1) - shift; // sample x
|
|
32
|
-
if (i < samples - 1) {
|
|
33
|
-
while (sx > p2[0] && pi < filledPoints.length - 2) {
|
|
34
|
-
pi += 1;
|
|
35
|
-
// extraneous work if this loop goes over more than once,
|
|
36
|
-
// which only happens if sx > 0 on first iteration (aka shift < 0)
|
|
37
|
-
p1 = filledPoints[pi];
|
|
38
|
-
p2 = filledPoints[pi + 1];
|
|
39
|
-
if (Math.abs(p2[0] - p1[0]) < 1e-8) {
|
|
40
|
-
slope = Infinity * Math.sign(p2[1] - p1[1]);
|
|
41
|
-
} else {
|
|
42
|
-
slope = (p2[1] - p1[1]) / (p2[0] - p1[0]);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
if (slope === Infinity) {
|
|
46
|
-
sampledPoints.push(1);
|
|
47
|
-
} else if (slope === -Infinity) {
|
|
48
|
-
sampledPoints.push(0);
|
|
49
|
-
} else {
|
|
50
|
-
sampledPoints.push(slope * (sx - p1[0]) + p1[1]);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
return sampledPoints;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// ----------------------------------------------------------------------------
|
|
58
|
-
// vtkPiecewiseWidget methods
|
|
59
|
-
// ----------------------------------------------------------------------------
|
|
60
|
-
|
|
61
|
-
function vtkPiecewiseWidget(publicAPI, model) {
|
|
62
|
-
model.classHierarchy.push('vtkPiecewiseWidget');
|
|
63
|
-
|
|
64
|
-
const superClass = { ...publicAPI };
|
|
65
|
-
|
|
66
|
-
model.pwMode = Mode.Gaussians;
|
|
67
|
-
model.opacityPoints = [];
|
|
68
|
-
model.opacityPointShift = 0;
|
|
69
|
-
|
|
70
|
-
publicAPI.setGaussiansMode = () => {
|
|
71
|
-
model.pwMode = Mode.Gaussians;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
publicAPI.setPointsMode = () => {
|
|
75
|
-
// clear gaussians so we don't keep this ref around
|
|
76
|
-
model.gaussians = [];
|
|
77
|
-
model.pwMode = Mode.Points;
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
publicAPI.isModeGaussians = () => model.pwMode === Mode.Gaussians;
|
|
81
|
-
publicAPI.isModePoints = () => model.pwMode === Mode.Points;
|
|
82
|
-
publicAPI.getMode = () => model.pwMode;
|
|
83
|
-
|
|
84
|
-
publicAPI.shiftPosition = (coords, meta) => {
|
|
85
|
-
model.opacityPointShift =
|
|
86
|
-
meta.originalOpacityPointShift + coords[0] - meta.originalXY[0];
|
|
87
|
-
return true;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
publicAPI.onHover = (x, y) => {
|
|
91
|
-
if (publicAPI.isModeGaussians()) {
|
|
92
|
-
return superClass.onHover(x, y);
|
|
93
|
-
}
|
|
94
|
-
model.canvas.style.cursor = ADJUST_POSITION_CURSOR;
|
|
95
|
-
return true;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
publicAPI.onClick = (x, y) => {
|
|
99
|
-
if (publicAPI.isModeGaussians()) {
|
|
100
|
-
return superClass.onClick(x, y);
|
|
101
|
-
}
|
|
102
|
-
return undefined;
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
publicAPI.onDown = (x, y) => {
|
|
106
|
-
if (publicAPI.isModeGaussians()) {
|
|
107
|
-
return superClass.onDown(x, y);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
if (!model.mouseIsDown) {
|
|
111
|
-
publicAPI.invokeAnimation(true);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const mouseCoords = vtkPiecewiseGaussianWidget.normalizeCoordinates(
|
|
115
|
-
x,
|
|
116
|
-
y,
|
|
117
|
-
model.graphArea
|
|
118
|
-
);
|
|
119
|
-
|
|
120
|
-
model.mouseIsDown = true;
|
|
121
|
-
model.activeGaussian = -1;
|
|
122
|
-
model.dragAction = {
|
|
123
|
-
originalXY: mouseCoords,
|
|
124
|
-
originalOpacityPointShift: model.opacityPointShift,
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
return true;
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
publicAPI.onDrag = (x, y) => {
|
|
131
|
-
if (publicAPI.isModeGaussians()) {
|
|
132
|
-
return superClass.onDrag(x, y);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const normCoords = vtkPiecewiseGaussianWidget.normalizeCoordinates(
|
|
136
|
-
x,
|
|
137
|
-
y,
|
|
138
|
-
model.graphArea
|
|
139
|
-
);
|
|
140
|
-
if (publicAPI.shiftPosition(normCoords, model.dragAction)) {
|
|
141
|
-
model.opacities = samplePiecewiseLinear(
|
|
142
|
-
model.opacityPoints,
|
|
143
|
-
model.opacityPointShift
|
|
144
|
-
);
|
|
145
|
-
publicAPI.invokeOpacityChange(publicAPI, true);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
publicAPI.modified();
|
|
149
|
-
return true;
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
publicAPI.setOpacityPoints = (points, shift = 0) => {
|
|
153
|
-
if (publicAPI.isModePoints()) {
|
|
154
|
-
// deep copy
|
|
155
|
-
model.opacityPoints = points.map((p) => [p[0], p[1]]);
|
|
156
|
-
model.opacityPointShift = shift;
|
|
157
|
-
|
|
158
|
-
model.opacities = samplePiecewiseLinear(
|
|
159
|
-
model.opacityPoints,
|
|
160
|
-
model.opacityPointShift
|
|
161
|
-
);
|
|
162
|
-
publicAPI.modified();
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
publicAPI.getEffectiveOpacityPoints = () =>
|
|
167
|
-
model.opacityPoints.map((p) => [p[0] + model.opacityPointShift, p[1]]);
|
|
168
|
-
|
|
169
|
-
publicAPI.render = () => {
|
|
170
|
-
if (publicAPI.isModePoints()) {
|
|
171
|
-
model.activeGaussian = -1;
|
|
172
|
-
model.selectedGaussian = -1;
|
|
173
|
-
}
|
|
174
|
-
superClass.render();
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// ----------------------------------------------------------------------------
|
|
179
|
-
// Object factory
|
|
180
|
-
// ----------------------------------------------------------------------------
|
|
181
|
-
|
|
182
|
-
const DEFAULT_VALUES = {};
|
|
183
|
-
|
|
184
|
-
// ----------------------------------------------------------------------------
|
|
185
|
-
|
|
186
|
-
export function extend(publicAPI, model, initialValues = {}) {
|
|
187
|
-
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
188
|
-
|
|
189
|
-
vtkPiecewiseGaussianWidget.extend(publicAPI, model, initialValues);
|
|
190
|
-
|
|
191
|
-
macro.setGet(publicAPI, model, ['opacityPoints', 'opacityPointShift']);
|
|
192
|
-
|
|
193
|
-
// Object specific methods
|
|
194
|
-
vtkPiecewiseWidget(publicAPI, model);
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
// ----------------------------------------------------------------------------
|
|
198
|
-
|
|
199
|
-
export const newInstance = macro.newInstance(extend, 'vtkPiecewiseWidget');
|
|
200
|
-
|
|
201
|
-
// ----------------------------------------------------------------------------
|
|
202
|
-
|
|
203
|
-
export default { newInstance, extend };
|