diff --git a/src/components/tools/common.ts b/src/components/tools/common.ts index a6ae524ea..7b6751bf1 100644 --- a/src/components/tools/common.ts +++ b/src/components/tools/common.ts @@ -1,5 +1,6 @@ import { AnnotationToolStore } from '@/src/store/tools/useAnnotationTool'; import { Maybe } from '@/src/types'; +import { AnnotationTool } from '@/src/types/annotation-tool'; import { vtkAnnotationToolWidget } from '@/src/vtk/ToolWidgetUtils/utils'; import vtkAbstractWidgetFactory from '@kitware/vtk.js/Widgets/Core/AbstractWidgetFactory'; import vtkWidgetState from '@kitware/vtk.js/Widgets/Core/WidgetState'; @@ -59,10 +60,16 @@ export interface WidgetComponentMeta< /** * An optional render function + * + * @param viewId the view ID + * @param syncedState the synced state from the widget + * @param labelProps the label props associated with the tool + * @param tool an optional tool. Not available for the placing widget. */ render?: ( viewId: string, syncedState: SyncedState, - labelProps: Maybe + labelProps: Maybe, + tool?: AnnotationTool ) => VNode; } diff --git a/src/components/tools/createWidget2DComponent.ts b/src/components/tools/createWidget2DComponent.ts index c6b36f057..0da6c8559 100644 --- a/src/components/tools/createWidget2DComponent.ts +++ b/src/components/tools/createWidget2DComponent.ts @@ -146,7 +146,12 @@ export function createWidget2DComponent< return () => currentSlice.value === tool.value.slice - ? meta.render?.(viewId.value, syncedState, labelProps.value) + ? meta.render?.( + viewId.value, + syncedState, + labelProps.value, + tool.value + ) : null; }, }); diff --git a/src/components/tools/polygon/PlacingPolygonWidget2D.vue b/src/components/tools/polygon/PlacingPolygonWidget2D.vue deleted file mode 100644 index 60b419442..000000000 --- a/src/components/tools/polygon/PlacingPolygonWidget2D.vue +++ /dev/null @@ -1,152 +0,0 @@ - - - diff --git a/src/components/tools/polygon/PolygonTool.vue b/src/components/tools/polygon/PolygonTool.vue index 3a241fd37..f90b3c906 100644 --- a/src/components/tools/polygon/PolygonTool.vue +++ b/src/components/tools/polygon/PolygonTool.vue @@ -1,127 +1,83 @@ - - diff --git a/src/components/tools/polygon/PolygonWidget2D.vue b/src/components/tools/polygon/PolygonWidget2D.vue deleted file mode 100644 index c1168d452..000000000 --- a/src/components/tools/polygon/PolygonWidget2D.vue +++ /dev/null @@ -1,153 +0,0 @@ - - - diff --git a/src/components/tools/polygon/common.ts b/src/components/tools/polygon/common.ts index 548dcf557..7c53a9802 100644 --- a/src/components/tools/polygon/common.ts +++ b/src/components/tools/polygon/common.ts @@ -10,10 +10,18 @@ export interface PolygonInitState { points: Vector3[]; } -export function useSyncedPolygonState(widgetFactory: vtkPolygonWidget) { - const syncedState = shallowReactive({ - points: [] as Vector3[], - movePoint: null as Maybe, +export interface PolygonSyncedState { + points: Vector3[]; + movePoint: Maybe; + finishable: boolean; +} + +export function useSyncedPolygonState( + widgetFactory: vtkPolygonWidget +): PolygonSyncedState { + const syncedState = shallowReactive({ + points: [], + movePoint: null, finishable: false, }); diff --git a/src/store/tools/polygons.ts b/src/store/tools/polygons.ts index 69f91d381..4710c04b0 100644 --- a/src/store/tools/polygons.ts +++ b/src/store/tools/polygons.ts @@ -50,3 +50,5 @@ export const usePolygonStore = defineStore('polygon', () => { deserialize, }; }); + +export type PolygonStore = ReturnType;