Browse Source

修复bug

xushiting 2 years ago
parent
commit
505fedbf4d

+ 1 - 11
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);
@@ -41,16 +41,6 @@ export default class AddPoint {
     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]);

+ 35 - 23
src/graphic/Controls/LocationModeControl.js

@@ -14,7 +14,7 @@ export default class LocationModeControl {
 
   //设置直角定位法
   setAngle() {
-    let selectBasePoint = this.isFocusBasePoint();
+    let selectBasePoint = this.beforeSetLocation();
     if (selectBasePoint) {
       this.deleteOldLines();
       let points = dataService.getPoints();
@@ -27,6 +27,9 @@ export default class LocationModeControl {
           );
         }
       }
+      return true;
+    } else {
+      return false;
     }
   }
 
@@ -82,40 +85,49 @@ 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);
     }
 
-    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
+    ) {
+      return null;
+    } else {
+      if (Settings.selectBasePointId) {
+        let point = dataService.getPoint(Settings.selectBasePointId);
+        if (point.getCategory() == VectorCategory.Point.BasePoint) {
+          return point;
+        }
       }
+      return null;
     }
-    return null;
   }
 
+  /******************************************************************************************************************************************************/
+
+  //设置综合定位法
+  setAll() {}
+
+  /******************************************************************************************************************************************************/
+
   //设置定位法前,需要删除和定位法相关的线条
   deleteOldLines() {
     let lines = dataService.getLines();

+ 1 - 1
src/graphic/Controls/MovePoint.js

@@ -49,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();

+ 5 - 2
src/graphic/Controls/UIControl.js

@@ -130,7 +130,10 @@ export default class UIControl {
           stateService.setEventName(LayerEvents.AddRoadStructure);
         } else if (selectUI == Constant.angleLocationMode) {
           uiService.setSelectLocationMode(Constant.angleLocationMode);
-          locationModeControl.setAngle();
+          let flag = locationModeControl.setAngle();
+          if (!flag) {
+            this.prompt({ msg: "请先选择基准点", time: 1000 });
+          }
           this.layer.history.save();
           this.layer.renderer.autoRedraw();
         }
@@ -576,7 +579,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();

+ 9 - 10
src/graphic/Layer.js

@@ -165,14 +165,6 @@ export default class Layer {
             SelectState.Select
           );
           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:
@@ -391,6 +383,7 @@ export default class Layer {
     stateService.clearFocusItem();
     if (
       selectItem &&
+      this.uiControl.focusVector &&
       selectItem.vectorId == this.uiControl.focusVector.vectorId
     ) {
     } else {
@@ -1039,7 +1032,7 @@ export default class Layer {
         stateService.clearFocusItem();
         this.uiControl.clearFocusVector();
         this.uiControl.clearCurrentUI();
-        Settings.selectBasePointId = null;
+        uiService.setSelectBasePointId(null);
         break;
       case LayerEvents.MoveRoadPoint:
         if (!draggingItem || !draggingItem.vectorId) {
@@ -1260,7 +1253,13 @@ export default class Layer {
         this.history.save();
         break;
       case LayerEvents.AddPoint:
-        this.uiControl.showConfirm();
+        // 绘制的是基准点
+        if (Settings.selectPointCategory == VectorCategory.Point.BasePoint) {
+          stateService.clearEventName();
+          this.history.save();
+        } else {
+          this.uiControl.showConfirm();
+        }
         needAutoRedraw = true;
         elementService.hideAll();
         break;

+ 2 - 1
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")) {

+ 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) {

+ 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();