xushiting 2 tahun lalu
induk
melakukan
171475ce7b

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

@@ -19,68 +19,8 @@ export default class AddPoint {
     this.testPointIds = []; //所有待测点
   }
 
-  buildPoint(position) {
-    //只有一个基准点的时候,测量的时候自动选择基准点
-    if (
-      (Settings.selectLocationMode == Constant.angleLocationMode ||
-        Settings.selectLocationMode == Constant.allLocationMode) &&
-      Settings.basePointIds.length == 1
-    ) {
-      Settings.selectBasePointId = Settings.basePointIds[0];
-    }
-    let newPoint;
-    if (Settings.selectPointCategory == VectorCategory.Point.BasePoint) {
-      newPoint = pointService.create(position);
-      Settings.selectBasePointId = newPoint.vectorId;
-    } else {
-      if (
-        Settings.selectBasePointId != null &&
-        Settings.selectLocationMode == Constant.angleLocationMode
-      ) {
-        newPoint = pointService.create(position);
-        this.setLocationByAngle(newPoint.vectorId);
-        newPoint.setLocationMode(Constant.angleLocationMode);
-        stateService.setEventName(LayerEvents.AddPoint);
-      } else if (
-        Settings.selectBasePointId != null &&
-        Settings.selectLocationMode == Constant.allLocationMode
-      ) {
-        newPoint = pointService.create(position);
-        this.setLocationByAll(newPoint.vectorId);
-        newPoint.setLocationMode(Constant.allLocationMode);
-        stateService.setEventName(LayerEvents.AddPoint);
-      } else if (
-        Settings.baseLineId != null &&
-        Settings.selectLocationMode == Constant.normalLocationMode
-      ) {
-        newPoint = pointService.create(position);
-        this.setLocationByNormal(newPoint.vectorId);
-        newPoint.setLocationMode(Constant.normalLocationMode);
-
-        stateService.setEventName(LayerEvents.AddPoint);
-      } else if (
-        Settings.selectBasePointId == null &&
-        (Settings.selectLocationMode == Constant.angleLocationMode ||
-          Settings.selectLocationMode == Constant.allLocationMode)
-      ) {
-        return null;
-      }
-      if (
-        newPoint &&
-        (newPoint.getLocationMode() == Constant.allLocationMode ||
-          newPoint.getLocationMode() == Constant.angleLocationMode ||
-          newPoint.getLocationMode() == Constant.normalLocationMode) &&
-        newPoint.getCategory() == VectorCategory.Point.TestPoint
-      ) {
-        this.testPointIds.push(newPoint.vectorId);
-      }
-    }
-    listenLayer.clear();
-    return newPoint;
-  }
-
   //添加固定点/基准点
-  buildPoint2(position) {
+  buildPoint(position) {
     let newPoint = null;
     if (listenLayer.modifyPoint && listenLayer.modifyPoint.linkedPointId) {
       return null;
@@ -112,109 +52,6 @@ export default class AddPoint {
     return null;
   }
 
-  //直角定位法
-  setLocationByAngle(testPointId) {
-    let basePoint = this.isFocusBasePoint();
-    if (!basePoint) {
-      return;
-    }
-    let testPoint = dataService.getPoint(testPointId);
-    if (testPoint.getCategory() != VectorCategory.Point.TestPoint) {
-      return;
-    }
-    testPoint.setLinkedBasePointId(basePoint.vectorId);
-    let lineGeometry = dataService.getLine(Settings.baseLineId);
-    let startPoint = dataService.getPoint(lineGeometry.startId);
-    let endPoint = dataService.getPoint(lineGeometry.endId);
-    let line = mathUtil.createLine1(startPoint, endPoint);
-    let vLine = mathUtil.getVerticalLine(line, testPoint);
-    let join = mathUtil.getJoinLinePoint(basePoint, vLine);
-    join = pointService.create(join);
-    join.setCategory(VectorCategory.Point.TestBasePoint);
-    join.setLocationMode(Constant.angleLocationMode);
-    join.setLinkedBasePointId(basePoint.vectorId);
-    let guidePositionLine = lineService.createByPointId(
-      testPointId,
-      join.vectorId,
-      VectorCategory.Line.GuidePositionLine
-    );
-
-    let positionLine = lineService.createByPointId(
-      basePoint.vectorId,
-      join.vectorId,
-      VectorCategory.Line.PositionLine
-    );
-    guidePositionLine.setLocationMode(Constant.angleLocationMode);
-    positionLine.setLocationMode(Constant.angleLocationMode);
-    join.setCategory(VectorCategory.Point.TestBasePoint);
-  }
-
-  //综合定位法
-  setLocationByAll(testPointId) {
-    let basePoint = this.isFocusBasePoint();
-    if (!basePoint) {
-      return;
-    }
-
-    let testPoint = dataService.getPoint(testPointId);
-    testPoint.setLinkedBasePointId(basePoint.vectorId);
-    let lineGeometry = dataService.getLine(Settings.baseLineId);
-    let startPoint = dataService.getPoint(lineGeometry.startId);
-    let endPoint = dataService.getPoint(lineGeometry.endId);
-    let line = mathUtil.createLine1(startPoint, endPoint);
-    let join = mathUtil.getJoinLinePoint(testPoint, line);
-    join = pointService.create(join); //经过待测点且与基准线垂直的线段,与基准线的交点
-    join.setCategory(VectorCategory.Point.TestBasePoint);
-    join.setLocationMode(Constant.allLocationMode);
-    join.setLinkedBasePointId(basePoint.vectorId);
-    //待测点与基准线的垂直线
-    lineService.createByPointId(
-      testPointId,
-      join.vectorId,
-      VectorCategory.Line.PositionLine
-    );
-    //暂时没有其他待测点
-    if (this.testPointIds.length == 0) {
-      //待测点与基准线点的连线
-      lineService.createByPointId(
-        basePoint.vectorId,
-        testPointId,
-        VectorCategory.Line.PositionLine
-      );
-    } else {
-      //取上一个待测点
-      lineService.createByPointId(
-        this.testPointIds[this.testPointIds.length - 1],
-        testPointId,
-        VectorCategory.Line.PositionLine
-      );
-    }
-  }
-
-  setLocationByNormal(testPointId) {
-    let testPoint = dataService.getPoint(testPointId);
-    if (testPoint.getCategory() != VectorCategory.Point.TestPoint) {
-      return;
-    }
-    if (!Settings.baseLineId) {
-      return;
-    }
-    let lineGeometry = dataService.getLine(Settings.baseLineId);
-    let startPoint = dataService.getPoint(lineGeometry.startId);
-    let endPoint = dataService.getPoint(lineGeometry.endId);
-    let line = mathUtil.createLine1(startPoint, endPoint);
-    let vLine = mathUtil.getVerticalLine(line, testPoint);
-    let join = mathUtil.getIntersectionPoint(vLine, line);
-    join = pointService.create(join);
-    join.setCategory(VectorCategory.Point.TestBasePoint);
-    join.setLocationMode(Constant.normalLocationMode);
-    lineService.createByPointId(
-      testPointId,
-      join.vectorId,
-      VectorCategory.Line.PositionLine
-    );
-  }
-
   deleteTestPoints() {
     for (let i = 0; i < this.testPointIds.length; ++i) {
       pointService.deletePoint(this.testPointIds[i]);

+ 1 - 77
src/graphic/Controls/MoveLine.js

@@ -13,83 +13,6 @@ import { uiService } from "../Service/UIService";
 export default class MoveLine {
   constructor() {}
 
-  // moveLine(lineId, dx, dy) {
-  //   dx = dx;
-  //   dy = -dy;
-  //   let line = dataService.getLine(lineId);
-  //   let startPoint = dataService.getPoint(line.startId);
-  //   let endPoint = dataService.getPoint(line.endId);
-
-  //   //垂直移动
-  //   if (line.getCategory() == VectorCategory.Line.PositionLine && line.getLocationMode() == Constant.angleLocationMode) {
-  //     let point1 = {
-  //       x: startPoint.x + dx,
-  //       y: startPoint.y + dy,
-  //     };
-  //     let point2 = {
-  //       x: endPoint.x + dx,
-  //       y: endPoint.y + dy,
-  //     };
-  //     let lineGeometry = mathUtil.createLine1(point1, point2);
-  //     point1 = mathUtil.getJoinLinePoint(startPoint, lineGeometry);
-  //     //startPoint本来是基准点
-  //     if (startPoint.getCategory() == VectorCategory.Point.BasePoint) {
-  //       //达到一定距离才能移动
-  //       if (mathUtil.getDistance(startPoint, point1) < Constant.minAdsorbPix) {
-  //         return false;
-  //       }
-  //       let newStartPoint = pointService.create(point1);
-  //       let extendedPositionLine = lineService.createByPointId(startPoint.vectorId, newStartPoint.vectorId, VectorCategory.Line.ExtendedPositionLine);
-  //       extendedPositionLine.setLocationMode(Constant.angleLocationMode);
-  //       dataService.deletePointParent(startPoint.vectorId, lineId);
-  //       line.startId = newStartPoint.vectorId;
-  //       newStartPoint.setPointParent(line.vectorId, 'start');
-  //       newStartPoint.setCategory(VectorCategory.Point.TestBasePoint);
-  //     } else {
-  //       startPoint.x = point1.x;
-  //       startPoint.y = point1.y;
-  //       let parents = Object.keys(startPoint.parent);
-  //       let extendedLine = dataService.getLine(parents[0]);
-  //       if (extendedLine.getCategory() != VectorCategory.Line.ExtendedPositionLine) {
-  //         extendedLine = dataService.getLine(parents[1]);
-  //       }
-  //       if (extendedLine.getCategory() == VectorCategory.Line.ExtendedPositionLine) {
-  //         //point1是基准点
-  //         point1 = dataService.getPoint(extendedLine.startId);
-  //         point2 = dataService.getPoint(extendedLine.endId);
-  //         if (mathUtil.getDistance(point1, point2) < Constant.minAdsorbPix) {
-  //           dataService.deleteLine(extendedLine.vectorId);
-  //           dataService.deletePoint(extendedLine.endId);
-
-  //           line.startId = point1.vectorId;
-  //           point1.setPointParent(line.vectorId, 'start');
-
-  //           lineGeometry = mathUtil.createLine3(lineGeometry, point1);
-  //         }
-  //       }
-  //     }
-
-  //     point2 = mathUtil.getJoinLinePoint(endPoint, lineGeometry);
-  //     endPoint.x = point2.x;
-  //     endPoint.y = point2.y;
-  //   } else {
-  //     //综合定位和垂线定位,拖动基准线更新位置
-  //     if (line.getCategory() == VectorCategory.Line.BaseLine) {
-  //       let points = dataService.vectorData.points;
-  //       for (let key in points) {
-  //         if (points[key].category == VectorCategory.Point.TestPoint && (points[key].locationMode == Constant.allLocationMode || points[key].locationMode == Constant.normalLocationMode)) {
-  //           movePoint.updatePositionByTestPoint(points[key].vectorId);
-  //         }
-  //       }
-  //     }
-  //     startPoint.x += dx;
-  //     startPoint.y += dy;
-  //     endPoint.x += dx;
-  //     endPoint.y += dy;
-  //   }
-  //   return true;
-  // }
-
   moveLine(lineId, dx, dy) {
     dx = dx;
     dy = -dy;
@@ -233,6 +156,7 @@ export default class MoveLine {
             dataService.deleteLine(extendedPositionLine.vectorId);
             dataService.deletePoint(otherPoint.vectorId);
             line.startId = startPoint.vectorId;
+            startPoint.setPointParent(line.vectorId, "start");
           }
           join = mathUtil.getJoinLinePoint(startPoint, baseLine);
           mathUtil.clonePoint(endPoint, join);

+ 11 - 65
src/graphic/Controls/MovePoint.js

@@ -6,37 +6,11 @@ import VectorCategory from "../enum/VectorCategory";
 import { listenLayer } from "../ListenLayer";
 import { uiService } from "../Service/UIService";
 import { mathUtil } from "../Util/MathUtil";
+import { moveText } from "./MoveText";
+import { locationModeControl } from "./LocationModeControl";
 
 export default class MovePoint {
   constructor() {}
-
-  // movePoint(position, pointId) {
-  //   let point = dataService.getPoint(pointId);
-  //   point.x = position.x;
-  //   point.y = position.y;
-  //   if (point.getCategory() == VectorCategory.Point.TestPoint) {
-  //     this.updatePositionByTestPoint(pointId);
-  //   } else if (point.getCategory() == VectorCategory.Point.BasePoint) {
-  //     this.updateBasePoint(pointId);
-  //   } else {
-  //     let parent = point.getParent();
-  //     for (let key in parent) {
-  //       let line = dataService.getLine(key);
-  //       line.setValue(null);
-  //       //拖拽的点是基准线
-  //       if (line.category == VectorCategory.Line.BaseLine) {
-  //         let points = dataService.getPoints();
-  //         for (let key in points) {
-  //           let testPoint = dataService.getPoint(key);
-  //           if (testPoint.category == VectorCategory.Point.TestPoint) {
-  //             this.updatePositionByTestPoint(key);
-  //           }
-  //         }
-  //       }
-  //     }
-  //   }
-  // }
-
   movePoint(position, pointId) {
     let point = dataService.getPoint(pointId);
     if (point.getCategory() == VectorCategory.Point.BasePoint) {
@@ -46,32 +20,17 @@ export default class MovePoint {
     } else {
       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();
+        }
+      }
     }
   }
 
   finish(pointId) {
-    // if (
-    //   pointId &&
-    //   listenLayer.modifyPoint &&
-    //   listenLayer.modifyPoint.linkedPointId
-    // ) {
-    //   let linkedPoint = dataService.getPoint(
-    //     listenLayer.modifyPoint.linkedPointId
-    //   );
-    //   const category = linkedPoint.getCategory();
-    //   if (
-    //     category != VectorCategory.Point.BasePoint &&
-    //     category != VectorCategory.Point.TestBasePoint &&
-    //     category != VectorCategory.Point.TestPoint
-    //   ) {
-    //     pointService.mergePoint(pointId, listenLayer.modifyPoint.linkedPointId);
-    //     Settings.selectBasePointId = null;
-    //   } else if (category == VectorCategory.Point.BasePoint) {
-    //     Settings.selectBasePointId = pointId;
-    //   } else {
-    //     Settings.selectBasePointId = null;
-    //   }
-    // }
     if (
       pointId &&
       listenLayer.modifyPoint &&
@@ -83,8 +42,7 @@ export default class MovePoint {
       const category = linkedPoint.getCategory();
       if (
         category != VectorCategory.Point.BasePoint &&
-        category != VectorCategory.Point.TestBasePoint &&
-        category != VectorCategory.Point.TestPoint
+        category != VectorCategory.Point.TestBasePoint
       ) {
         pointService.mergePoint(pointId, listenLayer.modifyPoint.linkedPointId);
         Settings.selectBasePointId = null;
@@ -224,19 +182,6 @@ export default class MovePoint {
     mathUtil.clonePoint(testBasePoint, join);
   }
 
-  // updateBasePoint(basePointId) {
-  //   let points = dataService.getPoints();
-  //   for (let key in points) {
-  //     let point = dataService.getPoint(key);
-  //     if (
-  //       point.getCategory() == VectorCategory.Point.TestPoint &&
-  //       point.getLinkedBasePointId() == basePointId
-  //     ) {
-  //       this.updatePositionByTestPoint(key);
-  //     }
-  //   }
-  // }
-
   updateBasePoint(position, basePointId) {
     let lineGeometry = dataService.getLine(Settings.baseLineId);
     let startPoint = dataService.getPoint(lineGeometry.startId);
@@ -285,6 +230,7 @@ export default class MovePoint {
         let otherPointId = line.getOtherPointId(fixPointId);
         let otherPoint = dataService.getPoint(otherPointId);
         mathUtil.clonePoint(otherPoint, join);
+        moveText.moveFullText(position, fixPoint.linkedTextId);
       } else if (line.getCategory() == VectorCategory.Line.GuideLocationLine) {
         let otherPointId = line.getOtherPointId(fixPointId);
         let otherPoint = dataService.getPoint(otherPointId);

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

@@ -6,7 +6,7 @@ export default class MoveText {
 
   moveFullText(position, textId) {
     let text = dataService.getText(textId);
-    if (text && !text.linkedPointId) {
+    if (text) {
       mathUtil.clonePoint(text.center, position);
     }
   }

+ 11 - 7
src/graphic/Layer.js

@@ -154,7 +154,7 @@ export default class Layer {
       //   break;
       case LayerEvents.AddPoint:
         stateService.setEventName(LayerEvents.MovePoint);
-        const newPoint = addPoint.buildPoint2(position);
+        const newPoint = addPoint.buildPoint(position);
         if (newPoint) {
           stateService.setSelectItem(
             newPoint.vectorId,
@@ -593,9 +593,14 @@ export default class Layer {
         if (addLine.newLine != null) {
           exceptLineId = addLine.newLine.vectorId;
           exceptPointId = addLine.newLine.endId;
+          if (exceptPointId) {
+            let exceptPoint = dataService.getPoint(exceptPointId);
+            exceptLineId = exceptPoint.getParent();
+          }
         }
         listenLayer.start(position, {
-          exceptLineId: exceptLineId,
+          //exceptLineId: exceptLineId,
+          exceptLineIds: exceptLineId,
           exceptPointId: exceptPointId,
         });
         if (listenLayer.modifyPoint) {
@@ -850,10 +855,6 @@ export default class Layer {
             };
           }
           movePoint.movePoint(position, draggingItem.vectorId);
-          point = dataService.getPoint(draggingItem.vectorId);
-          if (point.getCategory() == VectorCategory.Point.FixPoint) {
-            moveText.moveFullText(position, point.linkedTextId);
-          }
           needAutoRedraw = true;
           if (!point) {
             stateService.clearEventName();
@@ -920,7 +921,10 @@ export default class Layer {
       case LayerEvents.MoveText:
         needAutoRedraw = true;
         if (draggingItem != null) {
-          moveText.moveFullText(position, draggingItem.vectorId);
+          let vectorText = dataService.getText(draggingItem.vectorId);
+          if (!vectorText.linkedPointId) {
+            moveText.moveFullText(position, draggingItem.vectorId);
+          }
         }
         break;
       case LayerEvents.MoveSVG:

+ 16 - 21
src/graphic/ListenLayer.js

@@ -24,7 +24,8 @@ export default class ListenLayer {
    *
    * @param exceptVectorIds:{
           exceptPointId,
-          exceptLineId,
+          //exceptLineId,
+          exceptLineIds,
           exceptCurvePointId,
           exceptCurveLineId,
           exceptRoadPointId,
@@ -60,18 +61,18 @@ export default class ListenLayer {
       position,
       exceptVectorIds.exceptRoadPointId
     );
-    // selectInfo.pointInfo = this.isSelectPoint(
-    //   position,
-    //   exceptVectorIds.exceptPointId,
-    //   exceptVectorIds.exceptLineIds
-    // );
     selectInfo.pointInfo = this.isSelectPoint(
       position,
-      exceptVectorIds.exceptPointId
+      exceptVectorIds.exceptPointId,
+      exceptVectorIds.exceptLineIds
     );
+    // selectInfo.pointInfo = this.isSelectPoint(
+    //   position,
+    //   exceptVectorIds.exceptPointId
+    // );
     selectInfo.lineInfo = this.isSelectLine(
       position,
-      exceptVectorIds.exceptLineId
+      exceptVectorIds.exceptLineIds
     );
     selectInfo.curvePointInfo = this.isSelectCurvePoint(
       position,
@@ -234,9 +235,6 @@ export default class ListenLayer {
     };
 
     let exceptPointIds = [];
-    if (exceptPointId) {
-      exceptPointIds.push(exceptPointId);
-    }
     if (exceptLineIds) {
       for (let key in exceptLineIds) {
         let exceptLine = dataService.getLine(key);
@@ -248,20 +246,20 @@ export default class ListenLayer {
     let seqInfo = {};
     const points = dataService.getPoints();
     for (const pointId in points) {
-      // if (pointId == exceptPointId) {
-      //   continue;
-      // }
-      if (exceptPointIds.indexOf(pointId) > -1) {
+      if (pointId == exceptPointId) {
         continue;
       }
-      const point = dataService.getPoint(pointId);
 
+      const point = dataService.getPoint(pointId);
       if (point.getCategory() == VectorCategory.Point.TestBasePoint) {
         continue;
       }
 
       const distance = this.getDistance(position, point);
       if (distance < Constant.minAdsorbPix) {
+        if (exceptPointIds.indexOf(pointId) > -1) {
+          continue;
+        }
         if (pointInfo.pointId == null) {
           pointInfo = {
             pointId: pointId,
@@ -326,7 +324,7 @@ export default class ListenLayer {
     return pointInfo;
   }
 
-  isSelectLine(position, exceptLineId) {
+  isSelectLine(position, exceptLineIds) {
     let lineInfo = {
       lineId: null,
       type: null,
@@ -334,10 +332,7 @@ export default class ListenLayer {
     };
     const lines = dataService.getLines();
     for (const lineId in lines) {
-      if (
-        exceptLineId &&
-        (exceptLineId == lineId || exceptLineId.hasOwnProperty(lineId))
-      ) {
+      if (exceptLineIds && exceptLineIds.hasOwnProperty(lineId)) {
         continue;
       }
 

+ 1 - 2
src/graphic/Service/LineService.js

@@ -53,8 +53,7 @@ export default class LineService {
         let category = point.getCategory();
         if (
           category == VectorCategory.Point.BasePoint ||
-          category == VectorCategory.Point.TestBasePoint ||
-          category == VectorCategory.Point.TestPoint
+          category == VectorCategory.Point.TestBasePoint
         ) {
           dataService.deletePoint(key);
         }

+ 1 - 4
src/graphic/Service/PointService.js

@@ -52,10 +52,7 @@ export default class PointService {
         dataService.deletePoint(pointId); //暂时简单粗暴
       } else if (category == VectorCategory.Point.BasePoint) {
         this.deleteBasePoint(pointId);
-      } else if (
-        category == VectorCategory.Point.TestPoint ||
-        category == VectorCategory.Point.TestBasePoint
-      ) {
+      } else if (category == VectorCategory.Point.TestBasePoint) {
         this.deleteTestPoint(pointId);
       } else if (category == VectorCategory.Point.FixPoint) {
         this.deleteFixPoint(pointId);

+ 0 - 1
src/graphic/enum/VectorCategory.js

@@ -22,7 +22,6 @@ const VectorCategory = {
   },
   Point: {
     BasePoint: "BasePoint", //基准点
-    TestPoint: "TestPoint", //待测点
     NormalPoint: "NormalPoint", //正常点
     TestBasePoint: "TestBasePoint", //待测基准点,待测点与基准线相交的点
     FixPoint: "FixPoint", //固定点