diff --git a/src/components/LayoutGrid.vue b/src/components/LayoutGrid.vue
index e3a44c303..16ae3f36d 100644
--- a/src/components/LayoutGrid.vue
+++ b/src/components/LayoutGrid.vue
@@ -15,14 +15,20 @@
+
+
+
+
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/utils/lps.ts b/src/utils/lps.ts
index ae7e777a5..bddb0028b 100644
--- a/src/utils/lps.ts
+++ b/src/utils/lps.ts
@@ -1,5 +1,6 @@
import type { Bounds } from '@kitware/vtk.js/types';
import { vec3, mat3 } from 'gl-matrix';
+import { ViewTypes } from '@kitware/vtk.js/Widgets/Core/WidgetManager/Constants';
import {
LPSAxis,
LPSAxisDir,
@@ -51,6 +52,16 @@ export function getLPSAxisFromDir(dir: LPSAxisDir): LPSAxis {
}
}
+export function getVTKViewTypeFromLPSAxis(axis: LPSAxis): ViewTypes {
+ switch(axis) {
+ case 'Sagittal': return ViewTypes.YZ_PLANE;
+ case 'Coronal': return ViewTypes.XZ_PLANE;
+ case 'Axial': return ViewTypes.XY_PLANE;
+ default:
+ throw new Error(`Invalid LPS axis: ${axis}`);
+ }
+}
+
export const defaultLPSDirections = () => ({
Left: vec3.fromValues(1, 0, 0),
Right: vec3.fromValues(-1, 0, 0),
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' },
},
},
};