From 82ce49f6c4327fd5cd2753c7570269c2001d5e1f Mon Sep 17 00:00:00 2001 From: Shreeraj Jadhav Date: Thu, 13 Jul 2023 18:46:01 -0400 Subject: [PATCH] feat(ObliqueView): add ResliceCursorWidget to control oblique views --- package-lock.json | 12 +- package.json | 2 +- src/components/LayoutGrid.vue | 54 ++++- src/components/VtkObliqueView.vue | 242 +++++---------------- src/components/tools/ResliceCursorTool.vue | 133 +++++++++++ src/constants.ts | 12 + src/shims-vtk.d.ts | 76 +++---- src/vtk/proxy.js | 1 - 8 files changed, 281 insertions(+), 251 deletions(-) create mode 100644 src/components/tools/ResliceCursorTool.vue diff --git a/package-lock.json b/package-lock.json index 8d25fc3c0..fec25d6b8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "hasInstallScript": true, "dependencies": { "@aws-sdk/client-s3": "^3.321.1", - "@kitware/vtk.js": "^27.4.6", + "@kitware/vtk.js": "../vtk-js/dist/esm", "@sentry/vue": "^7.54.0", "@vueuse/core": "^8.5.0", "@vueuse/shared": "^9.2.0", @@ -3477,9 +3477,9 @@ } }, "node_modules/@kitware/vtk.js": { - "version": "27.4.6", - "resolved": "https://registry.npmjs.org/@kitware/vtk.js/-/vtk.js-27.4.6.tgz", - "integrity": "sha512-upeOyCykz/5KOl4+0y7o20BHS5Jcn5ml6dNkNi/O4hHKgifj7gXGtfv6+ncFj0R7MT2Ca3gREFSFYGUAR6SUXQ==", + "version": "0.0.0-semantically-release", + "resolved": "file:../vtk-js/dist/esm", + "license": "BSD-3-Clause", "dependencies": { "@babel/runtime": "7.17.9", "commander": "9.2.0", @@ -16692,9 +16692,7 @@ } }, "@kitware/vtk.js": { - "version": "27.4.6", - "resolved": "https://registry.npmjs.org/@kitware/vtk.js/-/vtk.js-27.4.6.tgz", - "integrity": "sha512-upeOyCykz/5KOl4+0y7o20BHS5Jcn5ml6dNkNi/O4hHKgifj7gXGtfv6+ncFj0R7MT2Ca3gREFSFYGUAR6SUXQ==", + "version": "0.0.0-semantically-release", "requires": { "@babel/runtime": "7.17.9", "commander": "9.2.0", diff --git a/package.json b/package.json index 86f3ae1ce..2e3b371ac 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ }, "dependencies": { "@aws-sdk/client-s3": "^3.321.1", - "@kitware/vtk.js": "^27.4.6", + "@kitware/vtk.js": "../vtk-js/dist/esm", "@sentry/vue": "^7.54.0", "@vueuse/core": "^8.5.0", "@vueuse/shared": "^9.2.0", diff --git a/src/components/LayoutGrid.vue b/src/components/LayoutGrid.vue index e3a44c303..b69aefa1f 100644 --- a/src/components/LayoutGrid.vue +++ b/src/components/LayoutGrid.vue @@ -15,14 +15,19 @@ diff --git a/src/constants.ts b/src/constants.ts index 71164650a..34afdddb3 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,4 +1,5 @@ import vtkWidgetManager from '@kitware/vtk.js/Widgets/Core/WidgetManager'; +import vtkResliceCursorWidget, { vtkResliceCursorViewWidget } from '@kitware/vtk.js/Widgets/Widgets3D/ResliceCursorWidget'; import { ComputedRef, InjectionKey, Ref } from 'vue'; export const EPSILON = 10e-6; @@ -10,6 +11,17 @@ export const DarkTheme = 'kw-dark'; export const LightTheme = 'kw-light'; export const DefaultTheme = DarkTheme; +/** + * Retrieves the global ResliceCursorWidget instance. + */ +export const VTKResliceCursor: InjectionKey< + ComputedRef +> = Symbol('VTKResliceCursor'); + +export const VTKResliceCursorViewWidget: InjectionKey< + ComputedRef +> = Symbol('VTKResliceCursorViewWidget'); + /** * Retrieves the parent VtkTwoView's widget manager. */ diff --git a/src/shims-vtk.d.ts b/src/shims-vtk.d.ts index 1376761cd..43e28663c 100644 --- a/src/shims-vtk.d.ts +++ b/src/shims-vtk.d.ts @@ -36,55 +36,6 @@ declare module '@kitware/vtk.js/Widgets/Core/StateBuilder/boundsMixin' { export declare function extend(publicAPI: any, model: any): void; } -declare module '@kitware/vtk.js/Widgets/Core/AbstractWidgetFactory' { - import { vtkObject } from '@kitware/vtk.js/interfaces'; - import vtkRenderer from '@kitware/vtk.js/Rendering/Core/Renderer'; - import vtkAbstractWidget from '@kitware/vtk.js/Widgets/Core/AbstractWidget'; - import { ViewTypes } from '@kitware/vtk.js/Widgets/Core/WidgetManager'; - import vtkWidgetState from '@kitware/vtk.js/Widgets/Core/WidgetState'; - import { Bounds } from '@kitware/vtk.js/types'; - - export interface vtkAbstractWidgetFactory extends vtkObject { - getWidgetForView(locator: { - viewId: string; - renderer: vtkRenderer; - viewType: ViewTypes; - initialValues?: object; - }): vtkAbstractWidget | null; - getViewIds(): string[]; - setVisibility(visible: boolean): void; - setPickable(pickable: boolean): void; - setDragable(dragable: boolean): void; - setContextVisibility(visible: boolean): void; - setHandleVisibility(visible: boolean): void; - placeWidget(bounds: Bounds); - getPlaceFactor(): number; - setPlaceFactor(factor: number): void; - getWidgetState(): vtkWidgetState; - invokeWidgetChangeEvent(...args: any[]): void; - onWidgetChangeEvent(cb: EventHandler, priority?: number): void; - } - - export interface IAbstractWidgetFactoryInitialValues { - widgetState?: vtkWidgetState; - } - - export function extend( - publicAPI: object, - model: object, - initialValues?: IAbstractWidgetFactoryInitialValues - ); - - export function newInstance( - initialValues?: IAbstractWidgetFactoryInitialValues - ): vtkAbstractWidgetFactory; - - export declare const vtkAbstractWidgetFactory: { - extend: typeof extend; - }; - export default vtkAbstractWidgetFactory; -} - declare module '@kitware/vtk.js/Widgets/Core/WidgetManager' { import { vtkObject } from '@kitware/vtk.js/interfaces'; import vtkSelectionNode from '@kitware/vtk.js/Common/DataModel/SelectionNode'; @@ -281,3 +232,30 @@ declare module '@kitware/vtk.js/Widgets/Widgets3D/ImageCroppingWidget' { }; export default vtkImageCroppingWidget; } + +// declare module '@kitware/vtk.js/Widgets/Widgets3D/ResliceCursorViewWidget' { +declare module '@kitware/vtk.js/Widgets/Widgets3D/ResliceCursorWidget' { + import vtkAbstractWidget from '@kitware/vtk.js/Widgets/Core/AbstractWidget'; + import vtkWidgetState from '@kitware/vtk.js/Widgets/Core/WidgetState'; + import type { Vector3 } from '@kitware/vtk.js/types'; + import vtkResliceCursorWidget from '@kitware/vtk.js/Widgets/Widgets3D/ResliceCursorWidget'; + + export interface vtkResliceCursorViewWidget extends vtkAbstractWidget { + setManipulator(manipulator: vtkPlaneManipulator): boolean; + getManipulator(): vtkPlaneManipulator; + setImage(image: vtkImageData): void; + setKeepOrthogonality(keepOrthogonality: boolean): void; + setScaleInPixels(scaleInPixels: boolean): void; + } + + export interface ResliceCursorWidgetState extends vtkWidgetState { + placeWidget(bounds: Bounds): void; + setScale1(scale: number): void; + getPlanes(): Record; + setPlanes(planes: Record): void; + getCenter(): Vector3; + } + + // Just forwarding vtk-js's definition as default export: + export default vtkResliceCursorWidget; +} diff --git a/src/vtk/proxy.js b/src/vtk/proxy.js index c73950ea0..062f4bbc7 100644 --- a/src/vtk/proxy.js +++ b/src/vtk/proxy.js @@ -67,7 +67,6 @@ export default { }, Oblique: { vtkImageData: { name: 'ImageReslice' }, - // vtkLabelMap: { name: 'LabelMapSlice' }, }, }, };