|
@@ -0,0 +1,140 @@
|
|
|
+import {findMenuByKey, menuEnum, MenuRaw} from "@/views/scene/menus/menus";
|
|
|
+import {continuedMeasure, startMeasure, stopMeasure as stopMeasureRaw} from "@/views/scene/linkage/measure";
|
|
|
+import {list, MeasureAtom, MeasureType} from "@/store/measure";
|
|
|
+import {baseLines} from '@/store/baseLine'
|
|
|
+import {basePoints} from "@/store/basePoint";
|
|
|
+import {Ref, watch} from "vue";
|
|
|
+import {customMap} from "@/hook";
|
|
|
+import {getCoverPos} from '../linkage/cover'
|
|
|
+import {Pos3D} from "@/sdk";
|
|
|
+import {fixPoints} from "@/store/fixPoint";
|
|
|
+import Message from "@/components/base/components/message/message.vue";
|
|
|
+
|
|
|
+const trackPosMenuAction = (onComplete: () => void, onAddStore: (pos: Pos3D) => void) => {
|
|
|
+ customMap.magnifier = true
|
|
|
+ const onCleanup = getCoverPos(pos => {
|
|
|
+ onComplete()
|
|
|
+ onAddStore(pos)
|
|
|
+ })
|
|
|
+ return () => {
|
|
|
+ customMap.magnifier = false
|
|
|
+ onCleanup()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const stopMeasure = () => {
|
|
|
+ stopMeasureRaw()
|
|
|
+ customMap.magnifier = false
|
|
|
+}
|
|
|
+const trackMeasureMenuAction = (
|
|
|
+ measureType: MeasureType,
|
|
|
+ menu: MenuRaw,
|
|
|
+ onAddStore: (data: MeasureAtom) => void,
|
|
|
+ onComplete,
|
|
|
+ name: string
|
|
|
+) => {
|
|
|
+ const hide = Message.success({ msg: "请选择一个位置单击,确定基准线的起点" })
|
|
|
+ customMap.magnifier = true
|
|
|
+ const onAddMeasure = (data: MeasureAtom) => {
|
|
|
+ if (data) {
|
|
|
+ onAddStore(data)
|
|
|
+ onComplete()
|
|
|
+ }
|
|
|
+ hide()
|
|
|
+ }
|
|
|
+
|
|
|
+ if (menu.continued) {
|
|
|
+ continuedMeasure(measureType as any, onAddMeasure)
|
|
|
+ } else {
|
|
|
+ startMeasure(measureType as any).then(onAddMeasure)
|
|
|
+ }
|
|
|
+
|
|
|
+ return () => {
|
|
|
+ stopMeasure()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const menuActions = {
|
|
|
+ [menuEnum.BASE_POINT]: (_, onComplete) => {
|
|
|
+ const hide = Message.success({ msg: "请单击选择基准点位置" })
|
|
|
+ return trackPosMenuAction(
|
|
|
+ () => {
|
|
|
+ hide()
|
|
|
+ onComplete()
|
|
|
+ },
|
|
|
+ pos => basePoints.value.push({ id: "aa", pos })
|
|
|
+ )
|
|
|
+ },
|
|
|
+ [menuEnum.FIX_POINT]: (_, onComplete) => {
|
|
|
+ const hide = Message.success({ msg: "请单击选择固定点位置" })
|
|
|
+ return trackPosMenuAction(
|
|
|
+ () => {
|
|
|
+ hide()
|
|
|
+ onComplete()
|
|
|
+ },
|
|
|
+ pos => fixPoints.value.push({ id: "aa", pos })
|
|
|
+ )
|
|
|
+ },
|
|
|
+ [menuEnum.MEASURE_ROW]: (menu, onComplete) => {
|
|
|
+ return trackMeasureMenuAction(
|
|
|
+ 'L_LINE',
|
|
|
+ menu,
|
|
|
+ (data) => list.value.push(data),
|
|
|
+ onComplete,
|
|
|
+ "测量线"
|
|
|
+ )
|
|
|
+ },
|
|
|
+ [menuEnum.MEASURE_COLUMN]: (menu, onComplete) => {
|
|
|
+ return trackMeasureMenuAction(
|
|
|
+ 'V_LINE',
|
|
|
+ menu,
|
|
|
+ (data) => list.value.push(data),
|
|
|
+ onComplete,
|
|
|
+ "测量线"
|
|
|
+ )
|
|
|
+ },
|
|
|
+ [menuEnum.MEASURE_FREE]: (menu, onComplete) => {
|
|
|
+ return trackMeasureMenuAction(
|
|
|
+ 'LINE',
|
|
|
+ menu,
|
|
|
+ (data) => list.value.push(data),
|
|
|
+ onComplete,
|
|
|
+ "测量线"
|
|
|
+ )
|
|
|
+ },
|
|
|
+ [menuEnum.BASE_LINE]: (menu, onComplete) => {
|
|
|
+ return trackMeasureMenuAction(
|
|
|
+ 'LINE',
|
|
|
+ menu,
|
|
|
+ (data) => baseLines.value.push(data),
|
|
|
+ onComplete,
|
|
|
+ "基准线"
|
|
|
+ )
|
|
|
+ },
|
|
|
+ [menuEnum.CLEAR]: (menu, onComplete) => {
|
|
|
+ list.value = []
|
|
|
+ baseLines.value = []
|
|
|
+ basePoints.value = []
|
|
|
+ fixPoints.value = []
|
|
|
+ onComplete()
|
|
|
+ },
|
|
|
+}
|
|
|
+
|
|
|
+export const joinActions = (activeKey: Ref<string>) => {
|
|
|
+ return watch(
|
|
|
+ () => activeKey.value,
|
|
|
+ (key, oldKey, onCleanup) => {
|
|
|
+ if (key) {
|
|
|
+ const menu = findMenuByKey(key as any)
|
|
|
+ const cleanup = menuActions[key](menu, () => {
|
|
|
+ if (!menu.continued) {
|
|
|
+ activeKey.value = null;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (typeof cleanup === 'function') {
|
|
|
+ onCleanup(cleanup);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+}
|