Browse Source

临时补充批量添加定位法

xushiting 2 years ago
parent
commit
c06eb6f8d8

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

@@ -7,6 +7,7 @@ import { mathUtil } from "../Util/MathUtil";
 import addLine from "./AddLine";
 import Settings from "../Settings";
 import { stateService } from "../Service/StateService";
+import LayerEvents from "../enum/LayerEvents";
 import VectorType from "../enum/VectorType";
 import Constant from "../Constant";
 import { listenLayer } from "../ListenLayer";
@@ -29,6 +30,7 @@ export default class AddPoint {
         newPoint = pointService.create(position);
         this.setLocationByAngle(newPoint.vectorId);
         newPoint.setLocationMode(Constant.angleLocationMode);
+        stateService.setEventName(LayerEvents.AddPoint);
       } else if (
         Settings.selectBasePointId != null &&
         Settings.locationMode == Constant.allLocationMode
@@ -36,6 +38,7 @@ export default class AddPoint {
         newPoint = pointService.create(position);
         this.setLocationByAll(newPoint.vectorId);
         newPoint.setLocationMode(Constant.allLocationMode);
+        stateService.setEventName(LayerEvents.AddPoint);
       } else if (Settings.locationMode == Constant.normalLocationMode) {
         newPoint = pointService.create(position);
         this.setLocationByNormal(newPoint.vectorId);
@@ -49,7 +52,8 @@ export default class AddPoint {
       }
       if (
         newPoint &&
-        newPoint.getLocationMode() == Constant.allLocationMode &&
+        (newPoint.getLocationMode() == Constant.allLocationMode ||
+          newPoint.getLocationMode() == Constant.angleLocationMode) &&
         newPoint.getCategory() == VectorCategory.Point.TestPoint
       ) {
         this.testPointIds.push(newPoint.vectorId);
@@ -171,6 +175,13 @@ export default class AddPoint {
       VectorCategory.Line.PositionLine
     );
   }
+
+  deleteTestPoints() {
+    for (let i = 0; i < this.testPointIds.length; ++i) {
+      pointService.deletePoint(this.testPointIds[i]);
+    }
+    this.testPointIds = [];
+  }
 }
 
 const addPoint = new AddPoint();

+ 14 - 0
src/graphic/Controls/UIControl.js

@@ -22,6 +22,7 @@ import VectorCategory from "../enum/VectorCategory.js";
 import Message from "@/components/base/components/message/message.vue";
 import { pointService } from "../Service/PointService.js";
 import Settings from "../Settings.js";
+import { addPoint } from "./AddPoint.js";
 
 export default class UIControl {
   constructor(layer, newsletter, graphicStateUI) {
@@ -316,10 +317,23 @@ export default class UIControl {
   confirmEntry() {
     console.log("确认");
     this.graphicStateUI.continuedMode = false;
+    this.layer.exit();
+    uiService.setLineCategory(VectorCategory.Line.NormalLine);
+    uiService.setPointCategory(VectorCategory.Point.NormalPoint);
+    this.focusVector = null;
+    this.layer.history.save();
+    this.layer.renderer.autoRedraw();
   }
   confirmCancel() {
     console.log("取消");
     this.graphicStateUI.continuedMode = false;
+    addPoint.deleteTestPoints();
+    this.layer.exit();
+    uiService.setLineCategory(VectorCategory.Line.NormalLine);
+    uiService.setPointCategory(VectorCategory.Point.NormalPoint);
+    this.focusVector = null;
+    this.layer.history.save();
+    this.layer.renderer.autoRedraw();
   }
 
   hidePrompt() {

+ 19 - 0
src/graphic/Layer.js

@@ -37,6 +37,7 @@ import { roadPointService } from "./Service/RoadPointService";
 import { curveRoadService } from "./Service/CurveRoadService";
 import VectorCategory from "./enum/VectorCategory";
 import Settings from "./Settings";
+import Constant from "./Constant";
 import { uiService } from "./Service/UIService";
 import { imageService } from "./Service/ImageService";
 
@@ -956,6 +957,18 @@ export default class Layer {
         needAutoRedraw = true;
         this.history.save();
         break;
+      case LayerEvents.AddPoint:
+        if (
+          Settings.selectBasePointId != null &&
+          (Settings.locationMode == Constant.angleLocationMode ||
+            Settings.locationMode == Constant.allLocationMode)
+        ) {
+          this.uiControl.showConfirm();
+          needAutoRedraw = true;
+          this.history.save();
+          elementService.hideAll();
+        }
+        break;
     }
 
     this.setEventName("mouseUp");
@@ -1244,6 +1257,12 @@ export default class Layer {
         }
       } else if (eventName == LayerEvents.AddLine) {
         stateService.setEventName(LayerEvents.AddingLine);
+      } else if (
+        eventName == LayerEvents.AddPoint &&
+        Settings.selectBasePointId != null &&
+        (Settings.locationMode == Constant.angleLocationMode ||
+          Settings.locationMode == Constant.allLocationMode)
+      ) {
       } else {
         stateService.clearEventName();
       }

+ 9 - 7
src/graphic/Service/PointService.js

@@ -45,13 +45,15 @@ export default class PointService {
 
   deletePoint(pointId) {
     let point = dataService.getPoint(pointId);
-    const category = point.getCategory();
-    if (category == VectorCategory.Point.NormalPoint) {
-      dataService.deletePoint(pointId); //暂时简单粗暴
-    } else if (category == VectorCategory.Point.BasePoint) {
-      this.deleteBasePoint(pointId);
-    } else if (category == VectorCategory.Point.TestPoint) {
-      this.deleteTestPoint(pointId);
+    if (point) {
+      const category = point.getCategory();
+      if (category == VectorCategory.Point.NormalPoint) {
+        dataService.deletePoint(pointId); //暂时简单粗暴
+      } else if (category == VectorCategory.Point.BasePoint) {
+        this.deleteBasePoint(pointId);
+      } else if (category == VectorCategory.Point.TestPoint) {
+        this.deleteTestPoint(pointId);
+      }
     }
   }