diff --git a/src/components/tools/ruler/RulerWidget2D.vue b/src/components/tools/ruler/RulerWidget2D.vue index c239522e1..42ff3e2ab 100644 --- a/src/components/tools/ruler/RulerWidget2D.vue +++ b/src/components/tools/ruler/RulerWidget2D.vue @@ -2,6 +2,7 @@ import vtkRulerWidget, { InteractionState, vtkRulerViewWidget, + vtkRulerWidgetState, } from '@/src/vtk/RulerWidget'; import vtkWidgetManager from '@kitware/vtk.js/Widgets/Core/WidgetManager'; import { @@ -165,11 +166,16 @@ export default defineComponent({ secondPoint: false, }); - const widgetState = widgetFactory.getWidgetState(); - onVTKEvent(widgetFactory.getWidgetState(), 'onModified', () => { + const updateVisibleState = (widgetState: vtkRulerWidgetState) => { visibleStates.firstPoint = widgetState.getFirstPoint().getVisible(); visibleStates.secondPoint = widgetState.getSecondPoint().getVisible(); - }); + }; + + const widgetState = widgetFactory.getWidgetState(); + onVTKEvent(widgetFactory.getWidgetState(), 'onModified', () => + updateVisibleState(widgetState) + ); + updateVisibleState(widgetState); return { ruler,