|
@@ -1,11 +1,16 @@
|
|
|
-import {UIType} from "@/hook/useGraphic";
|
|
|
-import { toRaw } from 'vue'
|
|
|
+import {uiType, UIType, VectorType} from "@/hook/useGraphic";
|
|
|
+import {computed, Ref, ref, toRaw} from 'vue'
|
|
|
|
|
|
export const UITypeExtend = {
|
|
|
structure: "structure",
|
|
|
template: "template",
|
|
|
+ road: "road",
|
|
|
photo: "photo",
|
|
|
- setup: "setup"
|
|
|
+ setup: "setup",
|
|
|
+ lineType: "lineType",
|
|
|
+ width: "width",
|
|
|
+ lock: "lock",
|
|
|
+ basemap: "Basemap"
|
|
|
}
|
|
|
|
|
|
export type MenuRaw = {
|
|
@@ -18,83 +23,127 @@ export type MenusRaw = Array<MenuRaw>
|
|
|
|
|
|
|
|
|
export const structureMenusRaw = [
|
|
|
- { key: UIType.CurveRoad, text: "支路" },
|
|
|
- { key: UIType.CurveRoad, text: "窄路" },
|
|
|
- { key: UIType.CurveRoad, text: "路肩" },
|
|
|
- { key: UIType.CurveRoad, text: "斑马线" },
|
|
|
- { key: UIType.CurveRoad, text: "桥" },
|
|
|
- { key: UIType.CurveRoad, text: "隧道" },
|
|
|
- { key: UIType.CurveRoad, text: "人行道" },
|
|
|
- { key: UIType.CurveRoad, text: "施工路段" },
|
|
|
- { key: UIType.CurveRoad, text: "下坡" },
|
|
|
- { key: UIType.CurveRoad, text: "上坡" },
|
|
|
- { key: UIType.CurveRoad, text: "路边水沟" },
|
|
|
- { key: UIType.CurveRoad, text: "道路与铁..." },
|
|
|
- { key: UIType.CurveRoad, text: "消火栓井" },
|
|
|
- { key: UIType.CurveRoad, text: "雨水口" },
|
|
|
- { key: UIType.CurveRoad, text: "路面凹坑" },
|
|
|
- { key: UIType.CurveRoad, text: "路面凸出..." },
|
|
|
- { key: UIType.CurveRoad, text: "路面积水" },
|
|
|
+ { key: UIType.BranchRoad, text: "支路" },
|
|
|
+ { key: UIType.NarrowRoad, text: "窄路" },
|
|
|
+ { key: UIType.ShoulderRoad, text: "路肩" },
|
|
|
+ { key: UIType.ZebraCrossing, text: "斑马线" },
|
|
|
+ { key: UIType.Bridge, text: "桥" },
|
|
|
+ { key: UIType.Tunnel, text: "隧道" },
|
|
|
+ { key: UIType.Sidewalk, text: "人行道" },
|
|
|
+ { key: UIType.ConstructionSection, text: "施工路段" },
|
|
|
+ { key: UIType.Downhill, text: "下坡" },
|
|
|
+ { key: UIType.Uphill, text: "上坡" },
|
|
|
+ { key: UIType.RoadsideGutter, text: "路边水沟" },
|
|
|
+ { key: UIType.RoadsAndRails, text: "道路与铁..." },
|
|
|
+ { key: UIType.FireHydrantWell, text: "消火栓井" },
|
|
|
+ { key: UIType.Gullies, text: "雨水口" },
|
|
|
+ { key: UIType.RoadPotholes, text: "路面凹坑" },
|
|
|
+ { key: UIType.ProtrudingRoad, text: "路面凸出..." },
|
|
|
+ { key: UIType.WaterOnTheRoad, text: "路面积水" },
|
|
|
]
|
|
|
|
|
|
export const templateMenusRaw = [
|
|
|
- { key: UIType.CurveRoad, text: "s型弯路" },
|
|
|
- { key: UIType.CurveRoad, text: "丁字路口" },
|
|
|
- { key: UIType.CurveRoad, text: "五岔路口" },
|
|
|
- { key: UIType.CurveRoad, text: "出口匝道" },
|
|
|
- { key: UIType.CurveRoad, text: "十字路口" },
|
|
|
- { key: UIType.CurveRoad, text: "国道(路肩)" },
|
|
|
- { key: UIType.CurveRoad, text: "室内路段" },
|
|
|
- { key: UIType.CurveRoad, text: "弯道" },
|
|
|
- { key: UIType.CurveRoad, text: "急转弯道" },
|
|
|
- { key: UIType.CurveRoad, text: "六岔路口" },
|
|
|
- { key: UIType.CurveRoad, text: "宽变窄路段" },
|
|
|
- { key: UIType.CurveRoad, text: "直角弯道" },
|
|
|
- { key: UIType.CurveRoad, text: "进口砸到" },
|
|
|
- { key: UIType.CurveRoad, text: "高速收费站" },
|
|
|
- { key: UIType.CurveRoad, text: "高速港湾" },
|
|
|
- { key: UIType.CurveRoad, text: "高速路段" }
|
|
|
+ { key: UIType.SBend, text: "s型弯路" },
|
|
|
+ { key: UIType.TJunction, text: "丁字路口" },
|
|
|
+ { key: UIType.FiveForks, text: "五岔路口" },
|
|
|
+ { key: UIType.ExitRamp, text: "出口匝道" },
|
|
|
+ { key: UIType.Crossroads, text: "十字路口" },
|
|
|
+ { key: UIType.NationalHighwayShoulder, text: "国道(路肩)" },
|
|
|
+ { key: UIType.IndoorSection, text: "室内路段" },
|
|
|
+ { key: UIType.Bend, text: "弯道" },
|
|
|
+ { key: UIType.SharpCurve, text: "急转弯道" },
|
|
|
+ { key: UIType.SixForkIntersection, text: "六岔路口" },
|
|
|
+ { key: UIType.WideNarrowRoad, text: "宽变窄路段" },
|
|
|
+ { key: UIType.Corner, text: "直角弯道" },
|
|
|
+ { key: UIType.ImportSmashedRoad, text: "进口砸到" },
|
|
|
+ { key: UIType.HighSpeedTollBooth, text: "高速收费站" },
|
|
|
+ { key: UIType.HighSpeedHarbor, text: "高速港湾" },
|
|
|
+ { key: UIType.HighwaySection, text: "高速路段" }
|
|
|
]
|
|
|
|
|
|
export const mainMenusRaw: MenusRaw = [
|
|
|
+ { key: UIType.CurveRoad, text: "弯路" },
|
|
|
+ { key: UIType.Road, text: "直路" },
|
|
|
{ key: UIType.Line, text: "画线" },
|
|
|
{
|
|
|
- key: UIType.Road,
|
|
|
+ key: UITypeExtend.road,
|
|
|
text: "道路",
|
|
|
children: [
|
|
|
- { key: UIType.Road, text: "画线" },
|
|
|
- { key: UIType.Road, text: "画线" },
|
|
|
- { key: UIType.Road, text: "画线" },
|
|
|
- { key: UIType.Road, text: "画线" },
|
|
|
- { key: UIType.Road, text: "画线" },
|
|
|
- { key: UIType.Road, text: "画线" },
|
|
|
+ { key: UIType.OneEdgeOneLanRoad, text: "单向单车道直路" },
|
|
|
+ { key: UIType.OneEdgeTwoLanRoad, text: "单向双车道直路" },
|
|
|
+ { key: UIType.OneEdgeThreeLanRoad, text: "单向三车道直路" },
|
|
|
+ { key: UIType.TwoEdgeOneLanRoad, text: "双向单车道直路" },
|
|
|
+ { key: UIType.TwoEdgeTwoLanRoad, text: "双向双车道直路" },
|
|
|
+ { key: UIType.TwoEdgeThreeLanRoad, text: "双向三车道直路" },
|
|
|
{ key: UITypeExtend.structure, text: "道路结构", extend: structureMenusRaw },
|
|
|
{ key: UITypeExtend.template, text: "道路模板", extend: templateMenusRaw },
|
|
|
]
|
|
|
},
|
|
|
- { key: UIType.CurveRoad, text: "弯路" },
|
|
|
- { key: UIType.CurveRoad, text: "图例" },
|
|
|
+ { key: UIType.Img, text: "图例" },
|
|
|
{ key: UIType.MeasureLine, text: "测量" },
|
|
|
{ key: UIType.Tag, text: "文字" },
|
|
|
- { key: UIType.MeasureLine, text: "放大镜" },
|
|
|
+ { key: UIType.magnifier, text: "放大镜" },
|
|
|
{ key: UITypeExtend.photo, text: "照片库" },
|
|
|
{ key: UITypeExtend.setup, text: "设置" },
|
|
|
];
|
|
|
|
|
|
export const headActionMenuRaw = [
|
|
|
- { key: UIType.Road, text: "画线" },
|
|
|
- { key: UIType.Road, text: "画线" },
|
|
|
- { key: UIType.Road, text: "画线" },
|
|
|
- { key: UIType.Road, text: "画线" },
|
|
|
- { key: UIType.Road, text: "画线" }
|
|
|
+ { key: UIType.GoBack, text: "回退" },
|
|
|
+ { key: UIType.GoAhead, text: "前进" },
|
|
|
+ { key: UIType.Clear, text: "清除" },
|
|
|
+ { key: UITypeExtend.basemap, text: "底图开关" },
|
|
|
]
|
|
|
|
|
|
+export const focusMenuRaw : { [key in string]: MenusRaw } = {
|
|
|
+ [VectorType.RoadEdge]: [
|
|
|
+ {
|
|
|
+ key: UITypeExtend.lineType,
|
|
|
+ text: "单实线",
|
|
|
+ children: [
|
|
|
+ { key: UIType.SingleSolidLine, text: "单实线" },
|
|
|
+ { key: UIType.SingleDashedLine, text: "单虚线" },
|
|
|
+ { key: UIType.DoubleSolidLine, text: "双实线" },
|
|
|
+ { key: UIType.DoubleDashedLine, text: "双虚线" },
|
|
|
+ { key: UIType.BrokenLine, text: "折线" },
|
|
|
+ { key: UIType.PointDrawLine, text: "点画线" },
|
|
|
+ { key: UIType.Greenbelt, text: "绿化带 " },
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ key: UITypeExtend.width,
|
|
|
+ text: "宽度",
|
|
|
+ children: [
|
|
|
+ { key: UIType.Bold, text: "粗" },
|
|
|
+ { key: UIType.Thinning, text: "细" },
|
|
|
+
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ { key: UIType.AddControlPoint, text: "加控制点" },
|
|
|
+ { key: UIType.MinusControlPoint, text: "减控制点" },
|
|
|
+ { key: UIType.Copy, text: "复制" },
|
|
|
+ { key: UIType.Delete, text: "删除" }
|
|
|
+ ],
|
|
|
+ [VectorType.Road]: [
|
|
|
+ { key: UITypeExtend.lineType, text: "锁定", },
|
|
|
+ { key: UIType.AddBranchRoad, text: "加支路" },
|
|
|
+ { key: UIType.AddNarrowRoad, text: "加窄路" },
|
|
|
+ { key: UIType.AddLane, text: "加车道" },
|
|
|
+ { key: UIType.DelLane, text: "减车道" },
|
|
|
+ { key: UIType.AddControlPoint, text: "加控制点" },
|
|
|
+ { key: UIType.MinusControlPoint, text: "减控制点" },
|
|
|
+ { key: UIType.Copy, text: "复制" },
|
|
|
+ { key: UIType.Delete, text: "删除" }
|
|
|
+ ],
|
|
|
+}
|
|
|
+
|
|
|
+focusMenuRaw[VectorType.CurveRoadEdge] = focusMenuRaw[VectorType.RoadEdge]
|
|
|
+focusMenuRaw[VectorType.CurveRoad] = focusMenuRaw[VectorType.Road]
|
|
|
|
|
|
|
|
|
export const isUITypeExtend = (key: string) =>
|
|
|
Object.values(UITypeExtend).some(v => v === key)
|
|
|
|
|
|
-type GenerateResult<T extends {}> = Array<T & { children: GenerateResult<T> }>;
|
|
|
+type GenerateResult<T extends {}, E = {}> = Array<T & { children: GenerateResult<T> } & E>;
|
|
|
export const generateByMenus = <T>(
|
|
|
generateFn: (men: MenuRaw) => T,
|
|
|
mainMenus: MenusRaw = mainMenusRaw
|
|
@@ -104,15 +153,59 @@ export const generateByMenus = <T>(
|
|
|
children: mainMenu.children ? generateByMenus(generateFn, mainMenu.children) : []
|
|
|
}))
|
|
|
}
|
|
|
-export const findMainMenuByExtend = (extend: MenusRaw, mainMenus = mainMenusRaw) => {
|
|
|
+export const findMainMenuByAttr = (
|
|
|
+ value: MenusRaw,
|
|
|
+ attr = "extend",
|
|
|
+ mainMenus = mainMenusRaw
|
|
|
+) => {
|
|
|
for (const mainMenu of mainMenus) {
|
|
|
- if (toRaw(mainMenu.extend) === toRaw(extend)) {
|
|
|
+ if (toRaw(mainMenu[attr]) === toRaw(value)) {
|
|
|
return mainMenu
|
|
|
} else if (mainMenu.children) {
|
|
|
- const childMainMenu = findMainMenuByExtend(extend, mainMenu.children)
|
|
|
+ const childMainMenu = findMainMenuByAttr(value, attr, mainMenu.children)
|
|
|
if (childMainMenu) {
|
|
|
return childMainMenu;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+}
|
|
|
+
|
|
|
+export type GenerateMinMenusResult<T extends {}, K extends keyof MenuRaw> = {
|
|
|
+ menus: GenerateResult<T, { onClick: () => void }>,
|
|
|
+ child: Ref<MenuRaw[K]>,
|
|
|
+ activeMenuKey: Ref<string>
|
|
|
+}
|
|
|
+export const generateMixMenus = <T extends {}, K extends keyof MenuRaw>(
|
|
|
+ childKey: K,
|
|
|
+ generateFn: (men: MenuRaw) => T,
|
|
|
+ mainMenus: MenusRaw = mainMenusRaw
|
|
|
+): GenerateMinMenusResult<T, K> => {
|
|
|
+ const child = ref();
|
|
|
+ const menus = generateByMenus((menu) => ({
|
|
|
+ ...generateFn(menu),
|
|
|
+ onClick: () => {
|
|
|
+ if (menu[childKey]) {
|
|
|
+ if (toRaw(menu[childKey]) !== toRaw(child.value)) {
|
|
|
+ child.value = menu[childKey]
|
|
|
+ console.log("变成为", child.value)
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ uiType.change(menu.key as any)
|
|
|
+ }
|
|
|
+ child.value = null
|
|
|
+ }
|
|
|
+ }), mainMenus)
|
|
|
+
|
|
|
+ const activeMenuKey = computed(() =>
|
|
|
+ child.value
|
|
|
+ ? findMainMenuByAttr(child.value, childKey, mainMenus)?.key
|
|
|
+ : uiType.current
|
|
|
+ )
|
|
|
+
|
|
|
+ return {
|
|
|
+ child,
|
|
|
+ menus,
|
|
|
+ activeMenuKey
|
|
|
+ };
|
|
|
}
|