From f831c2d640c9c4d27f41b000adb8071edd2e9523 Mon Sep 17 00:00:00 2001 From: andrewwallacespeckle <139135120+andrewwallacespeckle@users.noreply.github.com> Date: Mon, 12 Feb 2024 15:07:43 +0000 Subject: [PATCH] [WBX-110] Improvements to Measurement Mode (#2031) * Added clearMeasurements functionality to the measurements extension * Add tip & descriptions to measure mode * Add clearMeasurements * Clear measurements onMount * onMount to onBeforeUnmount * Small alignment fix * Change from Alex --------- Co-authored-by: AlexandruPopovici --- .../frontend-2/components/viewer/Controls.vue | 2 +- .../components/viewer/GlobalFilterReset.vue | 3 +-- .../components/viewer/PreSetupWrapper.vue | 13 ++++++++++-- packages/frontend-2/components/viewer/Tip.vue | 20 ++++++++++++++++++ .../viewer/measurements/Options.vue | 21 ++++++++++++++++--- .../lib/viewer/composables/setup/postSetup.ts | 7 +++++++ .../frontend-2/lib/viewer/composables/ui.ts | 9 ++++++-- .../src/components/form/Radio.stories.ts | 3 ++- .../src/components/form/Radio.vue | 21 +++++++++++++++---- 9 files changed, 84 insertions(+), 15 deletions(-) create mode 100644 packages/frontend-2/components/viewer/Tip.vue diff --git a/packages/frontend-2/components/viewer/Controls.vue b/packages/frontend-2/components/viewer/Controls.vue index a263b1c58a..597d877fc8 100644 --- a/packages/frontend-2/components/viewer/Controls.vue +++ b/packages/frontend-2/components/viewer/Controls.vue @@ -147,7 +147,7 @@ : '-translate-x-[100%] opacity-0' } ${isEmbedEnabled ? 'mt-1.5' : 'mt-[4rem]'}`" > -
+
diff --git a/packages/frontend-2/components/viewer/GlobalFilterReset.vue b/packages/frontend-2/components/viewer/GlobalFilterReset.vue index 78485e7164..c76582e120 100644 --- a/packages/frontend-2/components/viewer/GlobalFilterReset.vue +++ b/packages/frontend-2/components/viewer/GlobalFilterReset.vue @@ -1,8 +1,7 @@ diff --git a/packages/frontend-2/lib/viewer/composables/setup/postSetup.ts b/packages/frontend-2/lib/viewer/composables/setup/postSetup.ts index ad929fb6b3..09eed9cc1a 100644 --- a/packages/frontend-2/lib/viewer/composables/setup/postSetup.ts +++ b/packages/frontend-2/lib/viewer/composables/setup/postSetup.ts @@ -51,6 +51,7 @@ import { CameraController } from '@speckle/viewer' import type { Reference } from '@apollo/client' import type { Modifier } from '@apollo/client/cache' import { useEmbed } from '~/lib/viewer/composables/setup/embed' +import { useMeasurementUtilities } from '~~/lib/viewer/composables/ui' function useViewerIsBusyEventHandler() { const state = useInjectedViewerState() @@ -724,6 +725,12 @@ function useViewerMeasurementIntegration() { viewer: { instance } } = useInjectedViewerState() + const { clearMeasurements } = useMeasurementUtilities() + + onBeforeUnmount(() => { + clearMeasurements() + }) + watch( () => measurement.enabled.value, (newVal, oldVal) => { diff --git a/packages/frontend-2/lib/viewer/composables/ui.ts b/packages/frontend-2/lib/viewer/composables/ui.ts index 1e8d65dfbf..307653454c 100644 --- a/packages/frontend-2/lib/viewer/composables/ui.ts +++ b/packages/frontend-2/lib/viewer/composables/ui.ts @@ -1,6 +1,6 @@ import { SpeckleViewer, timeoutAt } from '@speckle/shared' import type { TreeNode } from '@speckle/viewer' -import { CameraController } from '@speckle/viewer' +import { CameraController, MeasurementsExtension } from '@speckle/viewer' import type { MeasurementOptions, PropertyInfo } from '@speckle/viewer' import { until } from '@vueuse/shared' import { difference, isString, uniq } from 'lodash-es' @@ -357,10 +357,15 @@ export function useMeasurementUtilities() { } } + const clearMeasurements = () => { + state.viewer.instance.getExtension(MeasurementsExtension).clearMeasurements() + } + return { enableMeasurements, setMeasurementOptions, - removeMeasurement + removeMeasurement, + clearMeasurements } } diff --git a/packages/ui-components/src/components/form/Radio.stories.ts b/packages/ui-components/src/components/form/Radio.stories.ts index 012ae95eeb..43cdabb90d 100644 --- a/packages/ui-components/src/components/form/Radio.stories.ts +++ b/packages/ui-components/src/components/form/Radio.stories.ts @@ -175,7 +175,8 @@ export const WithIcon: StoryObj = { args: { name: 'withIcon', label: 'Example radio with Icon', - icon: ArrowRightIcon + icon: ArrowRightIcon, + description: 'Example discription' } } diff --git a/packages/ui-components/src/components/form/Radio.vue b/packages/ui-components/src/components/form/Radio.vue index b199188d7e..02879cd988 100644 --- a/packages/ui-components/src/components/form/Radio.vue +++ b/packages/ui-components/src/components/form/Radio.vue @@ -1,7 +1,7 @@