Просмотр исходного кода

Merge branch 'master' of http://192.168.0.115:3000/bill/traffic-laser

xzw 2 лет назад
Родитель
Сommit
00210ae61f

+ 1 - 12
src/graphic/Controls/AddPoint.js

@@ -27,7 +27,7 @@ export default class AddPoint {
     }
     if (Settings.selectPointCategory == VectorCategory.Point.BasePoint) {
       newPoint = pointService.create(position);
-      Settings.selectBasePointId = newPoint.vectorId;
+      uiService.setSelectBasePointId(newPoint.vectorId);
       stateService.setEventName(LayerEvents.AddPoint);
     } else if (Settings.selectPointCategory == VectorCategory.Point.FixPoint) {
       newPoint = pointService.create(position);
@@ -37,21 +37,10 @@ export default class AddPoint {
       newPoint.linkedTextId = textVector.vectorId;
       textVector.linkedPointId = newPoint.vectorId;
     }
-    uiService.setSelectPointCategory(VectorCategory.Point.NormalPoint);
     listenLayer.clear();
     return newPoint;
   }
 
-  isFocusBasePoint() {
-    if (Settings.selectBasePointId) {
-      let point = dataService.getPoint(Settings.selectBasePointId);
-      if (point.getCategory() == VectorCategory.Point.BasePoint) {
-        return point;
-      }
-    }
-    return null;
-  }
-
   deleteTestPoints() {
     for (let i = 0; i < this.testPointIds.length; ++i) {
       pointService.deletePoint(this.testPointIds[i]);

+ 37 - 24
src/graphic/Controls/LocationModeControl.js

@@ -6,6 +6,7 @@ import { dataService } from "../Service/DataService";
 import { lineService } from "../Service/LineService";
 import { pointService } from "../Service/PointService";
 import VectorCategory from "../enum/VectorCategory";
+import Msg from "../enum/Msg";
 import Constant from "../Constant";
 import { uiService } from "../Service/UIService";
 
@@ -14,8 +15,9 @@ export default class LocationModeControl {
 
   //设置直角定位法
   setAngle() {
-    let selectBasePoint = this.isFocusBasePoint();
-    if (selectBasePoint) {
+    const code = this.beforeSetLocation();
+    if (code == Msg.OK) {
+      let selectBasePoint = dataService.getPoint(Settings.selectBasePointId);
       this.deleteOldLines();
       let points = dataService.getPoints();
       for (let key in points) {
@@ -28,6 +30,7 @@ export default class LocationModeControl {
         }
       }
     }
+    return code;
   }
 
   //对一个点进行直角定位法
@@ -82,40 +85,50 @@ export default class LocationModeControl {
     guideLocationLine.setLinkedFixPointId(fixPointId);
   }
 
-  /******************************************************************************************************************************************************/
-
-  //设置综合定位法
-  setAll() {}
-
-  /******************************************************************************************************************************************************/
-
-  isFocusBasePoint() {
+  //要考虑是否有基准点,基准线,固定点
+  beforeSetLocation() {
     let basePointCount = 0;
+    let fixPointCount = 0;
     let selectBasePointId = null;
-    if (!Settings.selectBasePointId) {
-      let points = dataService.getPoints();
-      for (let key in points) {
-        let point = dataService.getPoint(key);
-        if (point.getCategory() == VectorCategory.Point.BasePoint) {
-          ++basePointCount;
-          selectBasePointId = key;
-        }
+    let points = dataService.getPoints();
+    for (let key in points) {
+      let point = dataService.getPoint(key);
+      if (point.getCategory() == VectorCategory.Point.BasePoint) {
+        ++basePointCount;
+        selectBasePointId = key;
+      } else if (point.getCategory() == VectorCategory.Point.FixPoint) {
+        ++fixPointCount;
       }
     }
-
     if (basePointCount == 1) {
       uiService.setSelectBasePointId(selectBasePointId);
+    } else if (basePointCount > 1 && Settings.selectBasePointId == null) {
+      return Msg.UnSelectBasePoint;
     }
 
-    if (Settings.selectBasePointId) {
-      let point = dataService.getPoint(Settings.selectBasePointId);
-      if (point.getCategory() == VectorCategory.Point.BasePoint) {
-        return point;
+    if (
+      basePointCount == 0 ||
+      fixPointCount == 0 ||
+      Settings.baseLineId == null
+    ) {
+      if (basePointCount == 0) {
+        return Msg.UnBasePoint;
+      } else if (fixPointCount == 0) {
+        return Msg.UnFixPoint;
+      } else if (Settings.baseLineId == null) {
+        return Msg.UnBaseLine;
       }
     }
-    return null;
+    return Msg.OK;
   }
 
+  /******************************************************************************************************************************************************/
+
+  //设置综合定位法
+  setAll() {}
+
+  /******************************************************************************************************************************************************/
+
   //设置定位法前,需要删除和定位法相关的线条
   deleteOldLines() {
     let lines = dataService.getLines();

+ 9 - 5
src/graphic/Controls/MovePoint.js

@@ -21,10 +21,14 @@ export default class MovePoint {
       point.x = position.x;
       point.y = position.y;
       let parent = point.getParent();
-      let line = dataService.getLine(Object.keys(parent)[0]);
-      if (line.getCategory() == VectorCategory.Line.BaseLine) {
-        if (uiService.getSelectLocationMode() == Constant.angleLocationMode) {
-          locationModeControl.setAngle();
+      for (let key in parent) {
+        let line = dataService.getLine(key);
+        if (line.getCategory() == VectorCategory.Line.BaseLine) {
+          if (uiService.getSelectLocationMode() == Constant.angleLocationMode) {
+            locationModeControl.setAngle();
+          }
+        } else {
+          line.setValue(null);
         }
       }
     }
@@ -45,7 +49,7 @@ export default class MovePoint {
         category != VectorCategory.Point.TestBasePoint
       ) {
         pointService.mergePoint(pointId, listenLayer.modifyPoint.linkedPointId);
-        Settings.selectBasePointId = null;
+        uiService.setSelectBasePointId(null);
       } else {
         let point = dataService.getPoint(pointId);
         const parent = point.getParent();

+ 28 - 15
src/graphic/Controls/UIControl.js

@@ -34,6 +34,7 @@ import { locationModeControl } from "./LocationModeControl.js";
 import { curveRoadPointService } from "../Service/CurveRoadPointService.js";
 import { roadService } from "../Service/RoadService.js";
 import { curveRoadService } from "../Service/CurveRoadService.js";
+import Msg from "../enum/Msg.js";
 
 export default class UIControl {
   constructor(layer, newsletter, graphicStateUI) {
@@ -72,10 +73,22 @@ export default class UIControl {
   }
 
   clearUI() {
-    this.currentUI = null;
+    this.clearCurrentUI();
+    this.clearSelectUI();
+  }
+
+  clearFocusVector() {
+    this.focusVector = null;
+  }
+
+  clearSelectUI() {
     this.selectUI = null;
   }
 
+  clearCurrentUI() {
+    this.currentUI = null;
+  }
+
   //点击左侧栏后,更新事件
   updateEventNameForSelectUI(selectUI) {
     console.log(this.selectUI, selectUI);
@@ -118,9 +131,13 @@ export default class UIControl {
           stateService.setEventName(LayerEvents.AddRoadStructure);
         } else if (selectUI == Constant.angleLocationMode) {
           uiService.setSelectLocationMode(Constant.angleLocationMode);
-          locationModeControl.setAngle();
-          this.layer.history.save();
-          this.layer.renderer.autoRedraw();
+          let msg = locationModeControl.setAngle();
+          if (msg != Msg.OK) {
+            this.prompt({ msg: msg, time: 1000 });
+          } else {
+            this.layer.history.save();
+            this.layer.renderer.autoRedraw();
+          }
         }
       }
     }
@@ -409,7 +426,7 @@ export default class UIControl {
     this.layer.exit();
     uiService.setSelectLineCategory(VectorCategory.Line.NormalLine);
     uiService.setSelectPointCategory(VectorCategory.Point.NormalPoint);
-    this.focusVector = null;
+    this.clearFocusVector();
   }
 
   //复制按钮
@@ -564,7 +581,7 @@ export default class UIControl {
     dataService.clear();
     Settings.selectLocationMode = null;
     Settings.baseLineId = null;
-    Settings.selectBasePointId = null;
+    uiService.setSelectBasePointId(null);
     elementService.hideAll();
     this.layer.exit();
     this.layer.initLocation();
@@ -592,26 +609,22 @@ export default class UIControl {
   }
   confirmEntry() {
     console.log("确认");
-    Settings.selectLocationMode = null;
     this.graphicStateUI.continuedMode = false;
     this.layer.exit();
-    uiService.setSelectLineCategory(VectorCategory.Line.NormalLine);
-    uiService.setSelectPointCategory(VectorCategory.Point.NormalPoint);
-    addPoint.resetTestPoints(); //重置testPoints数组
     this.layer.history.save();
     this.layer.renderer.autoRedraw();
+    uiService.setSelectPointCategory(VectorCategory.Point.NormalPoint);
+    uiService.setSelectLineCategory(VectorCategory.Line.NormalLine);
   }
   confirmCancel() {
     console.log("取消");
-    Settings.selectLocationMode = null;
     this.graphicStateUI.continuedMode = false;
-    addPoint.deleteTestPoints();
-    addLine.deleteTestLines();
     this.layer.exit();
-    uiService.setSelectLineCategory(VectorCategory.Line.NormalLine);
-    uiService.setSelectPointCategory(VectorCategory.Point.NormalPoint);
     this.layer.history.save();
+    this.layer.history.handleUndo();
     this.layer.renderer.autoRedraw();
+    uiService.setSelectPointCategory(VectorCategory.Point.NormalPoint);
+    uiService.setSelectLineCategory(VectorCategory.Line.NormalLine);
   }
 
   // 设置默认设置

+ 84 - 97
src/graphic/Layer.js

@@ -132,6 +132,9 @@ export default class Layer {
     listenLayer.start(position);
     let selectItem = stateService.getSelectItem();
     let focusItem = stateService.getFocusItem();
+    if (selectItem && focusItem && selectItem.vectorId != focusItem.vectorId) {
+      stateService.clearFocusItem();
+    }
 
     this.setEventName("mouseDown");
     const eventName = stateService.getEventName();
@@ -161,16 +164,7 @@ export default class Layer {
             VectorType.Point,
             SelectState.Select
           );
-          this.history.save();
           this.renderer.autoRedraw();
-        } else {
-          if (Settings.basePointIds.length > 1) {
-            this.uiControl.prompt({ msg: "请先选择基准点", time: 1000 });
-          } else {
-            this.uiControl.prompt({ msg: "请先添加基准点", time: 1000 });
-          }
-
-          // this.uiControl.prompt({ msg: '请先选择基准点', time: 1000 });
         }
         break;
       case LayerEvents.AddCircle:
@@ -207,9 +201,11 @@ export default class Layer {
         addMagnifier.clear();
         break;
       case VectorEvents.AddLane:
+        let selectAddLaneFlag = false;
         if (selectItem && selectItem.dir && selectItem.vectorId) {
           let road = dataService.getRoad(selectItem.vectorId);
           if (road) {
+            selectAddLaneFlag = true;
             let roadLanCount = road.getLanesCount(selectItem.dir);
             if (selectItem.dir == "left") {
               roadService.updateForAddSubtractLanesCount(
@@ -226,30 +222,37 @@ export default class Layer {
             }
           } else {
             road = dataService.getCurveRoad(selectItem.vectorId);
-            let curveRoadLanCount = road.getLanesCount(selectItem.dir);
-            if (selectItem.dir == "left") {
-              curveRoadService.updateForAddSubtractLanesCount(
-                road.vectorId,
-                curveRoadLanCount + 1,
-                selectItem.dir
-              );
-            } else {
-              curveRoadService.updateForAddSubtractLanesCount(
-                road.vectorId,
-                curveRoadLanCount + 1,
-                selectItem.dir
-              );
+            if (road) {
+              selectAddLaneFlag = true;
+              let curveRoadLanCount = road.getLanesCount(selectItem.dir);
+              if (selectItem.dir == "left") {
+                curveRoadService.updateForAddSubtractLanesCount(
+                  road.vectorId,
+                  curveRoadLanCount + 1,
+                  selectItem.dir
+                );
+              } else {
+                curveRoadService.updateForAddSubtractLanesCount(
+                  road.vectorId,
+                  curveRoadLanCount + 1,
+                  selectItem.dir
+                );
+              }
             }
           }
-          stateService.clearEventName();
           this.history.save();
           this.renderer.autoRedraw();
         }
+        if (!selectAddLaneFlag) {
+          stateService.clearEventName();
+        }
         break;
       case VectorEvents.DelLane:
+        let selectDelLaneFlag = false;
         if (selectItem && selectItem.dir && selectItem.vectorId) {
           let road = dataService.getRoad(selectItem.vectorId);
           if (road) {
+            selectDelLaneFlag = true;
             let roadLanCount = road.getLanesCount(selectItem.dir);
             if (selectItem.dir == "left") {
               roadService.updateForAddSubtractLanesCount(
@@ -266,25 +269,30 @@ export default class Layer {
             }
           } else {
             road = dataService.getCurveRoad(selectItem.vectorId);
-            let curveRoadLanCount = road.getLanesCount(selectItem.dir);
-            if (selectItem.dir == "left") {
-              curveRoadService.updateForAddSubtractLanesCount(
-                road.vectorId,
-                curveRoadLanCount - 1,
-                selectItem.dir
-              );
-            } else {
-              curveRoadService.updateForAddSubtractLanesCount(
-                road.vectorId,
-                curveRoadLanCount - 1,
-                selectItem.dir
-              );
+            if (road) {
+              selectDelLaneFlag = true;
+              let curveRoadLanCount = road.getLanesCount(selectItem.dir);
+              if (selectItem.dir == "left") {
+                curveRoadService.updateForAddSubtractLanesCount(
+                  road.vectorId,
+                  curveRoadLanCount - 1,
+                  selectItem.dir
+                );
+              } else {
+                curveRoadService.updateForAddSubtractLanesCount(
+                  road.vectorId,
+                  curveRoadLanCount - 1,
+                  selectItem.dir
+                );
+              }
             }
           }
-          stateService.clearEventName();
           this.history.save();
           this.renderer.autoRedraw();
         }
+        if (!selectDelLaneFlag) {
+          stateService.clearEventName();
+        }
         break;
       case VectorEvents.AddCrossPoint:
         if (focusItem && focusItem.vectorId) {
@@ -373,7 +381,15 @@ export default class Layer {
     selectItem = stateService.getSelectItem();
     stateService.setDraggingItem(selectItem);
     stateService.clearFocusItem();
-    this.uiControl.focusVector = null;
+    if (
+      selectItem &&
+      this.uiControl.focusVector &&
+      selectItem.vectorId == this.uiControl.focusVector.vectorId
+    ) {
+    } else {
+      this.uiControl.clearFocusVector();
+    }
+
     // 清除上一个状态
     // 设置当前事件名称
     e.preventDefault();
@@ -454,7 +470,7 @@ export default class Layer {
         ) {
         } else {
           stateService.clearFocusItem();
-          this.uiControl.focusVector = null;
+          this.uiControl.clearFocusVector();
         }
       }
     }
@@ -994,7 +1010,7 @@ export default class Layer {
       this.uiControl.focusVector = focusItem;
       stateService.clearDraggingItem();
     } else {
-      this.uiControl.focusVector = null;
+      this.uiControl.clearFocusVector();
     }
     this.dragging = false;
     let position = coordinate.getXYFromScreen({
@@ -1007,16 +1023,16 @@ export default class Layer {
         if (e instanceof TouchEvent) {
           stateService.clearSelectItem();
           stateService.clearDraggingItem();
-          this.uiControl.focusVector = null;
+          this.uiControl.clearFocusVector();
           this.renderer.autoRedraw();
         }
         return;
       case LayerEvents.PanBackGround:
         needAutoRedraw = true;
         stateService.clearFocusItem();
-        this.uiControl.focusVector = null;
-        this.uiControl.currentUI = null;
-        Settings.selectBasePointId = null;
+        this.uiControl.clearFocusVector();
+        this.uiControl.clearCurrentUI();
+        uiService.setSelectBasePointId(null);
         break;
       case LayerEvents.MoveRoadPoint:
         if (!draggingItem || !draggingItem.vectorId) {
@@ -1082,22 +1098,20 @@ export default class Layer {
         needAutoRedraw = true;
         if (addRoad.canAdd) {
           addRoad.buildRoad();
-          this.history.save();
           elementService.hideAll();
         }
         break;
       case LayerEvents.AddingLine:
-        if (Settings.selectLocationMode == Constant.freeLocationMode) {
-          this.uiControl.showConfirm();
-        }
-
         needAutoRedraw = true;
         addLine.finish(position);
         this.updateForLocation();
+        //绘制的是基准线
+        if (Settings.baseLineId == addLine.newLine.vectorId) {
+          stateService.clearEventName();
+          this.history.save();
+        }
         addLine.clearVectorData();
-        this.history.save();
         elementService.hideAll();
-
         break;
       case LayerEvents.AddingCurveLine:
         needAutoRedraw = true;
@@ -1147,7 +1161,6 @@ export default class Layer {
         needAutoRedraw = true;
         if (addRoad.canAdd) {
           addRoad.buildCurveRoad();
-          this.history.save();
           elementService.hideAll();
         }
         break;
@@ -1207,7 +1220,6 @@ export default class Layer {
         }
         this.history.save();
         elementService.hideAll();
-
         break;
       case LayerEvents.MoveCurvePoint:
         needAutoRedraw = true;
@@ -1241,17 +1253,15 @@ export default class Layer {
         this.history.save();
         break;
       case LayerEvents.AddPoint:
-        if (
-          (Settings.selectBasePointId != null &&
-            (Settings.selectLocationMode == Constant.angleLocationMode ||
-              Settings.selectLocationMode == Constant.allLocationMode)) ||
-          (Settings.baseLineId != null &&
-            Settings.selectLocationMode == Constant.normalLocationMode)
-        ) {
+        // 绘制的是基准点
+        if (Settings.selectPointCategory == VectorCategory.Point.BasePoint) {
+          stateService.clearEventName();
+          this.history.save();
+        } else {
           this.uiControl.showConfirm();
-          needAutoRedraw = true;
-          elementService.hideAll();
         }
+        needAutoRedraw = true;
+        elementService.hideAll();
         break;
       case LayerEvents.AddRoadTemplate:
         addCrossRoad.build(position);
@@ -1259,9 +1269,9 @@ export default class Layer {
         this.renderer.autoRedraw();
         break;
     }
-
     this.setEventName("mouseUp");
     stateService.clearDraggingItem();
+    stateService.clearSelectItem();
     if (needAutoRedraw) {
       this.renderer.autoRedraw();
     }
@@ -1350,42 +1360,19 @@ export default class Layer {
       }
     } else if (eventType == "mouseUp") {
       if (eventName == LayerEvents.AddingRoad) {
-        if (Settings.isMobile) {
-          stateService.clearEventName();
-          this.exit();
-        } else {
-          stateService.setEventName(LayerEvents.AddRoad);
-        }
+        this.uiControl.showConfirm();
+        stateService.setEventName(LayerEvents.AddRoad);
       } else if (eventName == LayerEvents.AddingLine) {
-        if (Settings.isMobile) {
-          if (Settings.selectLocationMode == Constant.freeLocationMode) {
-            stateService.setEventName(LayerEvents.AddLine);
-          } else {
-            stateService.clearEventName();
-            this.exit();
-            uiService.setSelectLineCategory(VectorCategory.Line.NormalLine);
-          }
-        } else {
-          stateService.setEventName(LayerEvents.AddLine);
-        }
+        this.uiControl.showConfirm();
+        stateService.setEventName(LayerEvents.AddLine);
       } else if (eventName == LayerEvents.AddingCurveRoad) {
-        if (Settings.isMobile) {
-          stateService.clearEventName();
-          this.exit();
-        } else {
-          stateService.setEventName(LayerEvents.AddCurveRoad);
-        }
+        this.uiControl.showConfirm();
+        stateService.setEventName(LayerEvents.AddCurveRoad);
       } else if (eventName == LayerEvents.AddLine) {
         stateService.setEventName(LayerEvents.AddingLine);
-      } else if (
-        (eventName == LayerEvents.AddPoint &&
-          Settings.selectBasePointId != null &&
-          (Settings.selectLocationMode == Constant.angleLocationMode ||
-            Settings.selectLocationMode == Constant.allLocationMode)) ||
-        (eventName == LayerEvents.AddPoint &&
-          Settings.baseLineId != null &&
-          Settings.selectLocationMode == Constant.normalLocationMode)
-      ) {
+      } else if (eventName == LayerEvents.AddPoint) {
+      } else if (eventName == VectorEvents.AddLane) {
+      } else if (eventName == VectorEvents.DelLane) {
       } else {
         stateService.clearEventName();
       }
@@ -1395,8 +1382,8 @@ export default class Layer {
   exit() {
     stateService.clear();
     this.uiControl.clearUI();
-    this.uiControl.focusVector = null;
-    this.uiControl.currentUI = null;
+    this.uiControl.clearFocusVector();
+    this.uiControl.clearCurrentUI();
   }
 
   stopAddVector() {

+ 15 - 27
src/graphic/ListenLayer.js

@@ -14,6 +14,7 @@ import VectorCategory from "./enum/VectorCategory";
 import LayerEvents from "./enum/LayerEvents";
 import Style from "./CanvasStyle";
 import Settings from "./Settings";
+import { uiService } from "./Service/UIService";
 export default class ListenLayer {
   constructor(canvas, newsletter, graphicState) {
     this.modifyPoint = null;
@@ -302,7 +303,7 @@ export default class ListenLayer {
       pointInfo.y = linkedPoint.y;
       //判断当时基准点则要高亮
       if (linkedPoint.getCategory() == VectorCategory.Point.BasePoint) {
-        Settings.selectBasePointId = linkedPoint.vectorId;
+        uiService.setSelectBasePointId(linkedPoint.vectorId);
       }
     } else {
       if (seqInfo.hasOwnProperty("linkedPointIdX")) {
@@ -638,19 +639,6 @@ export default class ListenLayer {
       let rightLine = mathUtil.createLine1(rightEdge.start, rightEdge.end);
       let rightJoin = mathUtil.getJoinLinePoint(position, rightLine);
 
-      // let distance = this.getDistance(position, join);
-      // if (
-      //   mathUtil.isContainForSegment(join, startPoint, endPoint) &&
-      //   distance < Constant.minAdsorbPix
-      // ) {
-      //   if (!roadInfo.roadId || distance < roadInfo.distance) {
-      //     roadInfo = {
-      //       roadId: roadId,
-      //       type: VectorType.Road,
-      //       distance: distance,
-      //     };
-      //   }
-      // }
       let distance = this.getDistance(position, join);
       if (
         mathUtil.isContainForSegment(join, startPoint, endPoint) &&
@@ -664,6 +652,19 @@ export default class ListenLayer {
             distance: distance,
           };
         }
+
+        if (roadInfo.roadId) {
+          const join1 = mathUtil.getJoinLinePoint(position, leftLine);
+          const join2 = mathUtil.getJoinLinePoint(position, rightLine);
+          if (
+            mathUtil.getDistance(join1, position) >
+            mathUtil.getDistance(join2, position)
+          ) {
+            roadInfo.dir = "right";
+          } else {
+            roadInfo.dir = "left";
+          }
+        }
       }
 
       //检查edge
@@ -700,19 +701,6 @@ export default class ListenLayer {
           };
         }
       }
-
-      if (roadInfo.roadId && !edgeInfo.edgeId) {
-        const join1 = mathUtil.getJoinLinePoint(position, leftLine);
-        const join2 = mathUtil.getJoinLinePoint(position, rightLine);
-        if (
-          mathUtil.getDistance(join1, position) >
-          mathUtil.getDistance(join2, position)
-        ) {
-          roadInfo.dir = "right";
-        } else {
-          roadInfo.dir = "left";
-        }
-      }
     }
 
     if (

+ 0 - 5
src/graphic/Load.js

@@ -109,11 +109,6 @@ export default class Load {
             Settings.basePointIds.push(points[key].vectorId);
           }
         }
-        // if(  Settings.basePointIds.length==1){
-        //   Settings.selectBasePointId =  Settings.basePointIds[0];
-        // }else{
-        //   // Settings.selectBasePointId =null
-        // }
       }
       if (dataLocal.svgs) {
         for (let key in dataLocal.svgs) {

+ 1 - 1
src/graphic/Renderer/Draw.js

@@ -1015,7 +1015,7 @@ export default class Draw {
   }
 
   drawPoint(vector, screenSave) {
-    console.log(vector);
+    // console.log(vector);
     const screenNotDrawTypes = [VectorCategory.Point.NormalPoint];
     if (!screenSave) {
       if (

+ 4 - 0
src/graphic/Service/DataService.js

@@ -132,6 +132,10 @@ export class DataService {
     return this.vectorData.lines[lineId];
   }
 
+  getGeo(type, id) {
+    return this[`get${type}`](id);
+  }
+
   deleteLine(lineId) {
     let line = this.getLine(lineId);
     if (!line) {

+ 0 - 27
src/graphic/Service/PointService.js

@@ -68,33 +68,6 @@ export default class PointService {
       }
     }
   }
-  // deleteBasePoint(basePointId) {
-  //   let points = dataService.getPoints();
-  //   let needDeletePointIds = [];
-  //   for (let key in points) {
-  //     let point = dataService.getPoint(key);
-  //     if (point.vectorId == basePointId) {
-  //       needDeletePointIds.push(basePointId);
-  //     } else if (point.linkedBasePointId == basePointId) {
-  //       needDeletePointIds.push(key);
-  //     }
-  //   }
-  //   let lines = dataService.getLines();
-  //   for (let key in lines) {
-  //     let line = dataService.getLine(key);
-  //     if (
-  //       needDeletePointIds.indexOf(line.startId) > -1 ||
-  //       needDeletePointIds.indexOf(line.endId) > -1
-  //     ) {
-  //       dataService.deleteLine(key);
-  //     }
-  //   }
-  //   dataService.deletePoint(basePointId);
-  //   if (Settings.selectBasePointId == basePointId) {
-  //     Settings.selectBasePointId = null;
-  //   }
-  //   this.updateBasePointIds();
-  // }
 
   deleteBasePoint(basePointId) {
     let lines = dataService.getLines();

+ 10 - 19
src/graphic/Service/StateService.js

@@ -1,7 +1,7 @@
-import VectorType from '../enum/VectorType.js';
-import SelectState from '../enum/SelectState.js';
-import VectorCategory from '../enum/VectorCategory.js';
-import { dataService } from './DataService.js';
+import VectorType from "../enum/VectorType.js";
+import SelectState from "../enum/SelectState.js";
+import VectorCategory from "../enum/VectorCategory.js";
+import { dataService } from "./DataService.js";
 
 export default class StateService {
   constructor() {
@@ -38,7 +38,7 @@ export default class StateService {
       const point = dataService.getPoint(vectorId);
       this.selectItem.category = point.getCategory();
     }
-    console.log('选中的元素:' + JSON.stringify(this.selectItem));
+    console.log("选中的元素:" + JSON.stringify(this.selectItem));
   }
   setSelectState(state) {
     if (!state || !this.selectItem) {
@@ -65,8 +65,8 @@ export default class StateService {
       return;
     } else if (this.draggingItem.type == VectorType.Line) {
       const line = dataService.getLine(this.draggingItem.vectorId);
-      if(!line){
-        return 
+      if (!line) {
+        return;
       }
       this.draggingItem.category = line.getCategory();
     } else if (this.draggingItem.type == VectorType.Point) {
@@ -84,18 +84,9 @@ export default class StateService {
   }
 
   setFocusItem(focusItem) {
-    this.focusItem = focusItem;
-    if (this.focusItem == null) {
-      return;
-    } else if (this.focusItem.type == VectorType.Line) {
-      const line = dataService.getLine(this.focusItem.vectorId);
-      if(!line){
-        return
-      }
-      this.focusItem.category = line.getCategory();
-    } else if (this.focusItem.type == VectorType.Point) {
-      const point = dataService.getPoint(this.focusItem.vectorId);
-      this.focusItem.category = point.getCategory();
+    this.focusItem = {};
+    for (let key in focusItem) {
+      this.focusItem[key] = focusItem[key];
     }
   }
 

+ 9 - 0
src/graphic/enum/Msg.js

@@ -0,0 +1,9 @@
+const Msg = {
+  OK: "成功",
+  UnBaseLine: "请先创建基准线",
+  UnBasePoint: "请先创建基准点",
+  UnSelectBasePoint: "请先选择基准点",
+  UnFixPoint: "请先创建固定点",
+};
+
+export default Msg;

+ 10 - 4
src/views/graphic/index.vue

@@ -54,6 +54,7 @@ import {
 } from "./menus";
 import { currentVector, drawRef, graphicState, uiType } from "@/hook/useGraphic";
 import geos, { GlobalComp } from "./geos/index";
+import { dataService } from "@/graphic/Service/DataService";
 
 const menusRaws = computed(() => {
   const mode = Number(router.currentRoute.value.params.mode) as Mode;
@@ -85,10 +86,15 @@ watchEffect(() => {
 const focusMenus = computed(() => focusMenuRaw[currentVector.value?.type]);
 const geoComponent = computed(() => {
   if (currentVector.value) {
-    console.log(currentVector.value);
-    return (
-      geos[currentVector.value?.category] || geos[currentVector.value?.type] || GlobalComp
-    );
+    let category = currentVector.value?.category;
+    if (!category) {
+      const geo = dataService.getGeo(
+        currentVector.value.type,
+        currentVector.value.vectorId
+      );
+      category = currentVector.value.category = geo?.category;
+    }
+    return geos[category] || geos[currentVector.value?.type] || GlobalComp;
   }
 });
 const isFull = computed(() => customMap.sysView === "full");

+ 21 - 21
src/views/graphic/menus.ts

@@ -113,32 +113,32 @@ export const measureMenusRaw = [
     key: UIType.AngleLocationMode,
     text: "直角定位法",
     icon: "measure_r",
-    onClick(data) {
-      console.error(graphicState.value.canAllLocationMode);
-      if (graphicState.value.canAllLocationMode) {
-        uiType.change(data.key);
-      } else {
-        Message.success({
-          msg: "请添加基准线及基准点后再执行此操作",
-          time: 3000,
-        });
-      }
-    },
+    // onClick(data) {
+    //   console.error(graphicState.value.canAllLocationMode);
+    //   if (graphicState.value.canAllLocationMode) {
+    //     uiType.change(data.key);
+    //   } else {
+    //     Message.success({
+    //       msg: "请添加基准线及基准点后再执行此操作",
+    //       time: 3000,
+    //     });
+    //   }
+    // },
   },
   {
     key: UIType.AllLocationMode,
     text: "综合定位法",
     icon: "measure_c",
-    onClick(data) {
-      if (graphicState.value.canAllLocationMode) {
-        uiType.change(data.key);
-      } else {
-        Message.success({
-          msg: "请添加基准线及基准点后再执行此操作",
-          time: 3000,
-        });
-      }
-    },
+    // onClick(data) {
+    //   if (graphicState.value.canAllLocationMode) {
+    //     uiType.change(data.key);
+    //   } else {
+    //     Message.success({
+    //       msg: "请添加基准线及基准点后再执行此操作",
+    //       time: 3000,
+    //     });
+    //   }
+    // },
     border: true,
   },
   {