|
@@ -1,41 +1,54 @@
|
|
|
-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 {activeBasePointStack, activeFixPointStack, customMap} from "@/hook";
|
|
|
-import {getCoverPos} from '../linkage/cover'
|
|
|
-import {Pos3D} from "@/sdk";
|
|
|
-import {fixPoints} from "@/store/fixPoint";
|
|
|
+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 {
|
|
|
+ activeBasePointStack,
|
|
|
+ activeFixPointStack,
|
|
|
+ customMap,
|
|
|
+ useConfirm,
|
|
|
+} 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";
|
|
|
-import { getId } from '@/utils'
|
|
|
+import { getId } from "@/utils";
|
|
|
|
|
|
-const trackPosMenuAction = (onComplete: () => void, onAddStore: (pos: Pos3D) => void, continued = false) => {
|
|
|
- let onCleanup
|
|
|
- let stop = false
|
|
|
+const trackPosMenuAction = (
|
|
|
+ onComplete: () => void,
|
|
|
+ onAddStore: (pos: Pos3D) => void,
|
|
|
+ continued = false
|
|
|
+) => {
|
|
|
+ let onCleanup;
|
|
|
+ let stop = false;
|
|
|
const trackCoverPos = () => {
|
|
|
- onCleanup && onCleanup()
|
|
|
- onCleanup = getCoverPos(pos => {
|
|
|
- onAddStore(pos)
|
|
|
+ onCleanup && onCleanup();
|
|
|
+ onCleanup = getCoverPos((pos) => {
|
|
|
+ onAddStore(pos);
|
|
|
if (!continued) {
|
|
|
- onComplete()
|
|
|
+ onComplete();
|
|
|
} else if (!stop) {
|
|
|
- trackCoverPos()
|
|
|
+ trackCoverPos();
|
|
|
}
|
|
|
- })
|
|
|
- }
|
|
|
- trackCoverPos()
|
|
|
+ });
|
|
|
+ };
|
|
|
+ trackCoverPos();
|
|
|
return () => {
|
|
|
- stop = true
|
|
|
- onCleanup()
|
|
|
- }
|
|
|
-}
|
|
|
+ stop = true;
|
|
|
+ onCleanup();
|
|
|
+ };
|
|
|
+};
|
|
|
|
|
|
const stopMeasure = () => {
|
|
|
- stopMeasureRaw()
|
|
|
+ stopMeasureRaw();
|
|
|
// customMap.magnifier = false
|
|
|
-}
|
|
|
+};
|
|
|
const trackMeasureMenuAction = (
|
|
|
measureType: MeasureType,
|
|
|
menu: MenuRaw,
|
|
@@ -44,156 +57,157 @@ const trackMeasureMenuAction = (
|
|
|
name: string,
|
|
|
color = "#3290ff"
|
|
|
) => {
|
|
|
- let hide
|
|
|
- let startTipEd = false
|
|
|
- let endTipEd = false
|
|
|
+ let hide;
|
|
|
+ let startTipEd = false;
|
|
|
+ let endTipEd = false;
|
|
|
const startTip = () => {
|
|
|
- hide && hide()
|
|
|
+ hide && hide();
|
|
|
if (!startTipEd) {
|
|
|
- hide = Message.success({msg: `请绘制${name}`})
|
|
|
+ hide = Message.success({ msg: `请绘制${name}` });
|
|
|
// 请选择一个位置单击,确定${name}的起点
|
|
|
- startTipEd = true
|
|
|
+ startTipEd = true;
|
|
|
}
|
|
|
- }
|
|
|
+ };
|
|
|
const firstTip = () => {
|
|
|
- hide && hide()
|
|
|
+ hide && hide();
|
|
|
if (!endTipEd) {
|
|
|
- endTipEd = true
|
|
|
+ endTipEd = true;
|
|
|
// hide = Message.success({msg: `再选择一个位置单击,确定${name}的终点`})
|
|
|
}
|
|
|
- }
|
|
|
- startTip()
|
|
|
+ };
|
|
|
+ startTip();
|
|
|
// customMap.magnifier = true
|
|
|
const onAddMeasure = (data: MeasureAtom) => {
|
|
|
if (data) {
|
|
|
data.id = getId();
|
|
|
- onAddStore(data)
|
|
|
- onComplete()
|
|
|
+ onAddStore(data);
|
|
|
+ onComplete();
|
|
|
}
|
|
|
if (menu.continued) {
|
|
|
- startTip()
|
|
|
+ startTip();
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
+ };
|
|
|
|
|
|
if (menu.continued) {
|
|
|
- continuedMeasure(measureType as any, color, onAddMeasure, firstTip)
|
|
|
+ continuedMeasure(measureType as any, color, onAddMeasure, firstTip);
|
|
|
} else {
|
|
|
- startMeasure(measureType as any, color, firstTip).then(onAddMeasure)
|
|
|
+ startMeasure(measureType as any, color, firstTip).then(onAddMeasure);
|
|
|
}
|
|
|
|
|
|
return () => {
|
|
|
- stopMeasure()
|
|
|
- hide()
|
|
|
- }
|
|
|
-}
|
|
|
+ stopMeasure();
|
|
|
+ hide();
|
|
|
+ };
|
|
|
+};
|
|
|
|
|
|
const menuActions = {
|
|
|
[menuEnum.BASE_POINT]: (_, onComplete) => {
|
|
|
- let hide = Message.success({ msg: "请单击选择基准点位置" })
|
|
|
+ let hide = Message.success({ msg: "请单击选择基准点位置" });
|
|
|
const onDestroy = trackPosMenuAction(
|
|
|
() => {
|
|
|
- hide && hide()
|
|
|
- onComplete()
|
|
|
+ hide && hide();
|
|
|
+ onComplete();
|
|
|
},
|
|
|
- pos => {
|
|
|
- const len = basePoints.value.push({ id: getId(), pos })
|
|
|
- activeBasePointStack.current.value.value = basePoints.value[len - 1]
|
|
|
+ (pos) => {
|
|
|
+ const len = basePoints.value.push({ id: getId(), pos });
|
|
|
+ activeBasePointStack.current.value.value = basePoints.value[len - 1];
|
|
|
if (hide) {
|
|
|
- hide()
|
|
|
- hide = null
|
|
|
+ hide();
|
|
|
+ hide = null;
|
|
|
}
|
|
|
},
|
|
|
true
|
|
|
- )
|
|
|
+ );
|
|
|
return () => {
|
|
|
- onDestroy()
|
|
|
- hide && hide()
|
|
|
- }
|
|
|
+ onDestroy();
|
|
|
+ hide && hide();
|
|
|
+ };
|
|
|
},
|
|
|
- [menuEnum.FIX_POINT]: (_, onComplete) => {
|
|
|
- let hide = Message.success({ msg: "请单击选择固定点位置" })
|
|
|
+ [menuEnum.FIX_POINT]: (_, onComplete) => {
|
|
|
+ let hide = Message.success({ msg: "请单击选择固定点位置" });
|
|
|
const onDestroy = trackPosMenuAction(
|
|
|
() => {
|
|
|
- hide && hide()
|
|
|
- onComplete()
|
|
|
+ hide && hide();
|
|
|
+ onComplete();
|
|
|
},
|
|
|
- pos => {
|
|
|
- const len = fixPoints.value.push({ id: getId(), pos, text: "固定点" })
|
|
|
- activeFixPointStack.current.value.value = fixPoints.value[len - 1]
|
|
|
+ (pos) => {
|
|
|
+ const len = fixPoints.value.push({ id: getId(), pos, text: "固定点" });
|
|
|
+ activeFixPointStack.current.value.value = fixPoints.value[len - 1];
|
|
|
if (hide) {
|
|
|
- hide()
|
|
|
- hide = null
|
|
|
+ hide();
|
|
|
+ hide = null;
|
|
|
}
|
|
|
},
|
|
|
true
|
|
|
- )
|
|
|
+ );
|
|
|
return () => {
|
|
|
- onDestroy()
|
|
|
- hide && hide()
|
|
|
- }
|
|
|
+ onDestroy();
|
|
|
+ hide && hide();
|
|
|
+ };
|
|
|
},
|
|
|
[menuEnum.MEASURE_ROW]: (menu, onComplete) => {
|
|
|
return trackMeasureMenuAction(
|
|
|
- 'L_LINE',
|
|
|
+ "L_LINE",
|
|
|
menu,
|
|
|
(data) => list.value.push(data),
|
|
|
onComplete,
|
|
|
"测量线"
|
|
|
- )
|
|
|
+ );
|
|
|
},
|
|
|
[menuEnum.MEASURE_COLUMN]: (menu, onComplete) => {
|
|
|
return trackMeasureMenuAction(
|
|
|
- 'V_LINE',
|
|
|
+ "V_LINE",
|
|
|
menu,
|
|
|
(data) => list.value.push(data),
|
|
|
onComplete,
|
|
|
"测量线"
|
|
|
- )
|
|
|
+ );
|
|
|
},
|
|
|
[menuEnum.MEASURE_FREE]: (menu, onComplete) => {
|
|
|
return trackMeasureMenuAction(
|
|
|
- 'LINE',
|
|
|
+ "LINE",
|
|
|
menu,
|
|
|
(data) => list.value.push(data),
|
|
|
onComplete,
|
|
|
"测量线"
|
|
|
- )
|
|
|
+ );
|
|
|
},
|
|
|
[menuEnum.BASE_LINE]: (menu, onComplete) => {
|
|
|
return trackMeasureMenuAction(
|
|
|
- 'BASE_LINE',
|
|
|
+ "BASE_LINE",
|
|
|
menu,
|
|
|
(data) => baseLines.value.push(data),
|
|
|
onComplete,
|
|
|
"基准线",
|
|
|
"#ED1C24"
|
|
|
- )
|
|
|
+ );
|
|
|
},
|
|
|
- [menuEnum.CLEAR]: (menu, onComplete) => {
|
|
|
- list.value = []
|
|
|
- baseLines.value = []
|
|
|
- basePoints.value = []
|
|
|
- fixPoints.value = []
|
|
|
- onComplete()
|
|
|
+ [menuEnum.CLEAR]: async (menu, onComplete) => {
|
|
|
+ if (await useConfirm("确认情况?该操作无法撤销")) {
|
|
|
+ list.value = [];
|
|
|
+ baseLines.value = [];
|
|
|
+ basePoints.value = [];
|
|
|
+ fixPoints.value = [];
|
|
|
+ }
|
|
|
+ onComplete();
|
|
|
},
|
|
|
-}
|
|
|
+};
|
|
|
|
|
|
export const joinActions = (activeKey: Ref<string>) => {
|
|
|
return watch(
|
|
|
() => activeKey.value,
|
|
|
(key, oldKey, onCleanup) => {
|
|
|
if (key && menuActions[key]) {
|
|
|
- const menu = findMenuByKey(key as any)
|
|
|
+ const menu = findMenuByKey(key as any);
|
|
|
const cleanup = menuActions[key](menu, () => {
|
|
|
if (!menu.continued) {
|
|
|
activeKey.value = null;
|
|
|
}
|
|
|
});
|
|
|
- if (typeof cleanup === 'function') {
|
|
|
+ if (typeof cleanup === "function") {
|
|
|
onCleanup(cleanup);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- )
|
|
|
-}
|
|
|
+ );
|
|
|
+};
|