From bf0165e5f93db23dd76660e679f07135714c770f Mon Sep 17 00:00:00 2001 From: Forrest Date: Fri, 8 Sep 2023 18:50:54 -0400 Subject: [PATCH] feat(ruler): separate out placing ruler A dedicated placing tool avoids mixing placing logic with regular tool logic. --- .../tools/ruler/PlacingRulerWidget2D.vue | 163 ++++++++++++++++++ src/components/tools/ruler/RulerSVG2D.vue | 5 +- src/components/tools/ruler/RulerTool.vue | 141 ++++----------- src/components/tools/ruler/RulerWidget2D.vue | 106 ++++-------- src/components/tools/ruler/common.ts | 38 ++++ src/composables/annotationTool.ts | 3 +- src/composables/useCurrentFrameOfReference.ts | 32 ++++ src/composables/useViewWidget.ts | 25 +++ src/vtk/RulerWidget/behavior.ts | 5 + src/vtk/RulerWidget/index.d.ts | 7 +- src/vtk/RulerWidget/index.js | 8 +- src/vtk/RulerWidget/standaloneState.js | 33 ++++ .../RulerWidget/{state.ts => storeState.ts} | 7 +- src/vtk/ToolWidgetUtils/common.ts | 2 + src/vtk/ToolWidgetUtils/pointState.js | 23 +-- src/vtk/ToolWidgetUtils/utils.ts | 24 +++ 16 files changed, 405 insertions(+), 217 deletions(-) create mode 100644 src/components/tools/ruler/PlacingRulerWidget2D.vue create mode 100644 src/components/tools/ruler/common.ts create mode 100644 src/composables/useCurrentFrameOfReference.ts create mode 100644 src/composables/useViewWidget.ts create mode 100644 src/vtk/RulerWidget/standaloneState.js rename src/vtk/RulerWidget/{state.ts => storeState.ts} (90%) create mode 100644 src/vtk/ToolWidgetUtils/common.ts diff --git a/src/components/tools/ruler/PlacingRulerWidget2D.vue b/src/components/tools/ruler/PlacingRulerWidget2D.vue new file mode 100644 index 000000000..91573abaf --- /dev/null +++ b/src/components/tools/ruler/PlacingRulerWidget2D.vue @@ -0,0 +1,163 @@ + + + diff --git a/src/components/tools/ruler/RulerSVG2D.vue b/src/components/tools/ruler/RulerSVG2D.vue index a2bea6bff..b12bd30b9 100644 --- a/src/components/tools/ruler/RulerSVG2D.vue +++ b/src/components/tools/ruler/RulerSVG2D.vue @@ -65,6 +65,7 @@ import { watch, inject, } from 'vue'; +import { Maybe } from '@/src/types'; type SVGPoint = { x: number; @@ -73,8 +74,8 @@ type SVGPoint = { export default defineComponent({ props: { - point1: Array as PropType>, - point2: Array as PropType>, + point1: Array as PropType>>, + point2: Array as PropType>>, color: String, length: Number, viewId: { diff --git a/src/components/tools/ruler/RulerTool.vue b/src/components/tools/ruler/RulerTool.vue index e3359dd9c..b3d1e8332 100644 --- a/src/components/tools/ruler/RulerTool.vue +++ b/src/components/tools/ruler/RulerTool.vue @@ -5,12 +5,19 @@ v-for="ruler in rulers" :key="ruler.id" :ruler-id="ruler.id" - :is-placing="ruler.id === placingRulerID" :current-slice="currentSlice" :view-id="viewId" :view-direction="viewDirection" :widget-manager="widgetManager" @contextmenu="openContextMenu(ruler.id, $event)" + /> + @@ -19,32 +26,24 @@