xushiting hace 2 años
padre
commit
039499493a
Se han modificado 4 ficheros con 32 adiciones y 26 borrados
  1. 17 16
      src/graphic/Controls/AddLine.js
  2. 3 5
      src/graphic/Controls/AddPoint.js
  3. 8 5
      src/graphic/Layer.js
  4. 4 0
      src/graphic/Load.js

+ 17 - 16
src/graphic/Controls/AddLine.js

@@ -53,24 +53,25 @@ export default class AddLine {
   }
 
   finish(position) {
-    if (
-      this.newLine != null &&
-      mathUtil.equalPoint(this.startInfo.position, position)
-    ) {
-      dataService.deleteLine(this.newLine.vectorId);
-    } else if (
-      listenLayer.modifyPoint &&
-      listenLayer.modifyPoint.linkedPointId &&
-      this.newLine.getCategory() != VectorCategory.Line.ArrowLine &&
-      this.newLine.getCategory() != VectorCategory.Line.GuideLine
-    ) {
-      pointService.mergePoint(
-        this.newLine.endId,
-        listenLayer.modifyPoint.linkedPointId
-      );
+    if (this.newLine != null) {
+      if (mathUtil.equalPoint(this.startInfo.position, position)) {
+        dataService.deleteLine(this.newLine.vectorId);
+      } else if (
+        listenLayer.modifyPoint &&
+        listenLayer.modifyPoint.linkedPointId &&
+        this.newLine.getCategory() != VectorCategory.Line.ArrowLine &&
+        this.newLine.getCategory() != VectorCategory.Line.GuideLine
+      ) {
+        pointService.mergePoint(
+          this.newLine.endId,
+          listenLayer.modifyPoint.linkedPointId
+        );
+      }
+      if (this.newLine.getCategory() == VectorCategory.Line.BaseLine) {
+        Settings.baseLineId = this.newLine.vectorId;
+      }
     }
   }
-
   clearVectorData() {
     this.newLine = null;
     this.startInfo = {};

+ 3 - 5
src/graphic/Controls/AddPoint.js

@@ -13,14 +13,13 @@ import { listenLayer } from "../ListenLayer";
 
 export default class AddPoint {
   constructor() {
-    this.basePointIds = []; //所有基准点
     this.testPointIds = []; //所有待测点
   }
 
   buildPoint(position) {
     const newPoint = pointService.create(position);
     if (newPoint.getCategory() == VectorCategory.Point.BasePoint) {
-      this.basePointIds.push(newPoint.vectorId);
+      Settings.selectBasePointId = newPoint.vectorId;
     } else {
       if (Settings.locationMode == Constant.angleLocationMode) {
         this.setLocationByAngle(newPoint.vectorId);
@@ -38,9 +37,8 @@ export default class AddPoint {
   }
 
   isFocusBasePoint() {
-    let focusItem = stateService.getFocusItem();
-    if (focusItem && focusItem.type == VectorType.Point) {
-      let point = dataService.getPoint(focusItem.vectorId);
+    if (Settings.selectBasePointId) {
+      let point = dataService.getPoint(Settings.selectBasePointId);
       if (point.getCategory() == VectorCategory.Point.BasePoint) {
         return point;
       }

+ 8 - 5
src/graphic/Layer.js

@@ -1114,13 +1114,16 @@ export default class Layer {
     this.renderer.autoRedraw();
   }
 
+  initLocation() {
+    Settings.baseLineId = null;
+    this.uiControl.graphicStateUI.canAngleLocationMode = false;
+    this.uiControl.graphicStateUI.canAllLocationMode = false;
+    this.uiControl.graphicStateUI.existsBaseLine = false;
+  }
+
   //更新定位信息
   updateForLocation() {
-    if (
-      addLine.newLine &&
-      addLine.newLine.getCategory() == VectorCategory.Line.BaseLine
-    ) {
-      Settings.baseLineId = addLine.newLine.vectorId;
+    if (Settings.baseLineId) {
       this.uiControl.graphicStateUI.canAngleLocationMode = true;
       this.uiControl.graphicStateUI.canAllLocationMode = true;
       this.uiControl.graphicStateUI.existsBaseLine = true;

+ 4 - 0
src/graphic/Load.js

@@ -18,6 +18,7 @@ export default class Load {
   }
 
   async load(dataLocal, data3d) {
+    this.layer.initLocation();
     // if (dataLocal) {
     //   if (dataLocal.backgroundImg) {
     //     let bgImg = imageService.create(
@@ -153,6 +154,9 @@ export default class Load {
     //     }
     //   }
     // }
+    if (Settings.baseLineId) {
+      this.layer.updateForLocation();
+    }
     this.layer.history.init();
     this.layer.renderer.autoRedraw();
   }