Bläddra i källkod

直角定位法,有一条线可以拖拽

xushiting 2 år sedan
förälder
incheckning
aa48256f13

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

@@ -101,11 +101,12 @@ export default class AddPoint {
       VectorCategory.Line.GuidePositionLine
     );
 
-    lineService.createByPointId(
+    let guidePositionLine = lineService.createByPointId(
       basePoint.vectorId,
       join.vectorId,
       VectorCategory.Line.PositionLine
     );
+    guidePositionLine.setLocationMode(Constant.angleLocationMode);
   }
 
   //综合定位法
@@ -159,8 +160,8 @@ export default class AddPoint {
     if (testPoint.getCategory() != VectorCategory.Point.TestPoint) {
       return;
     }
-    if(!Settings.baseLineId){
-    return;
+    if (!Settings.baseLineId) {
+      return;
     }
     let lineGeometry = dataService.getLine(Settings.baseLineId);
     let startPoint = dataService.getPoint(lineGeometry.startId);

+ 28 - 4
src/graphic/Controls/MoveLine.js

@@ -1,5 +1,7 @@
+import Constant from "../Constant";
 import { dataService } from "../Service/DataService";
 import { mathUtil } from "../Util/MathUtil";
+import VectorCategory from "../enum/VectorCategory";
 
 export default class MoveLine {
   constructor() {}
@@ -10,10 +12,32 @@ export default class MoveLine {
     let line = dataService.getLine(lineId);
     let startPoint = dataService.getPoint(line.startId);
     let endPoint = dataService.getPoint(line.endId);
-    startPoint.x += dx;
-    startPoint.y += dy;
-    endPoint.x += dx;
-    endPoint.y += dy;
+    //垂直移动
+    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,
+      };
+      line = mathUtil.createLine1(point1, point2);
+      point1 = mathUtil.getJoinLinePoint(startPoint, line);
+      startPoint.x = point1.x;
+      startPoint.y = point1.y;
+      point2 = mathUtil.getJoinLinePoint(endPoint, line);
+      endPoint.x = point2.x;
+      endPoint.y = point2.y;
+    } else {
+      startPoint.x += dx;
+      startPoint.y += dy;
+      endPoint.x += dx;
+      endPoint.y += dy;
+    }
   }
 
   moveCurveLine(curveLineId, dx, dy) {

+ 12 - 0
src/graphic/Geometry/Geometry.js

@@ -116,6 +116,18 @@ export default class Geometry {
     this.type = type;
   }
 
+  getCategory() {
+    return this.category;
+  }
+
+  setLocationMode(value) {
+    this.locationMode = value;
+  }
+
+  getLocationMode() {
+    return this.locationMode;
+  }
+
   // ptSrc: 圆上某点(初始点);
   // ptRotationCenter: 圆心点;
   // angle: 旋转角度°  -- [angle * M_PI / 180]:将角度换算为弧度

+ 1 - 4
src/graphic/Geometry/Line.js

@@ -12,6 +12,7 @@ export default class Line extends Geometry {
     this.startId = startId;
     this.endId = endId;
     this.category = Settings.selectLineCategory;
+    this.locationMode = null;
     this.color = Style.SingleArrowLine.strokeStyle; //箭头类型会用到
     this.value = null; //测量线会用到
     this.geoType = VectorType.Line;
@@ -27,10 +28,6 @@ export default class Line extends Geometry {
     this.category = value;
   }
 
-  getCategory() {
-    return this.category;
-  }
-
   getDir(pointId) {
     if (this.startId == pointId) {
       return "start";

+ 0 - 12
src/graphic/Geometry/Point.js

@@ -24,10 +24,6 @@ export default class Point extends Geometry {
     this.y = position.y;
   }
 
-  getCategory() {
-    return this.category;
-  }
-
   getLinkedBasePointId() {
     return this.linkedBasePointId;
   }
@@ -52,12 +48,4 @@ export default class Point extends Geometry {
       this.category = value;
     }
   }
-
-  setLocationMode(value) {
-    this.locationMode = value;
-  }
-
-  getLocationMode() {
-    return this.locationMode;
-  }
 }

+ 5 - 2
src/graphic/History/HistoryUtil.js

@@ -27,7 +27,8 @@ export default class HistoryUtil {
     if (
       line1.startId == line2.startId &&
       line1.endId == line2.endId &&
-      line1.category == line2.category
+      line1.category == line2.category &&
+      line1.locationMode == line2.locationMode
     ) {
       return false;
     } else {
@@ -295,6 +296,7 @@ export default class HistoryUtil {
     lineInfo.start = line2.start;
     lineInfo.end = line2.end;
     lineInfo.category = line2.category;
+    lineInfo.locationMode = line2.locationMode;
     lineInfo.value = line2.value;
     this.setLineInfo(lineInfo);
   }
@@ -543,6 +545,7 @@ export default class HistoryUtil {
     data.start = line.startId;
     data.end = line.endId;
     data.category = line.category;
+    data.locationMode = line.locationMode;
     data.type = line.geoType;
     return data;
   }
@@ -780,6 +783,7 @@ export default class HistoryUtil {
     line.startId = lineInfo.start;
     line.endId = lineInfo.end;
     line.category = lineInfo.category;
+    line.locationMode = lineInfo.locationMode;
     line.value = lineInfo.value;
     return line;
   }
@@ -897,7 +901,6 @@ export default class HistoryUtil {
       JSON.stringify(curveRoadPointInfo.parent)
     );
     curveRoadPoint.index = curveRoadPointInfo.index;
-
   }
 
   setCurveRoadEdgeInfo(curveRoadEdgeInfo) {

+ 7 - 9
src/graphic/ListenLayer.js

@@ -302,8 +302,9 @@ export default class ListenLayer {
 
       const line = dataService.getLine(lineId);
       if (
-        line.getCategory() == VectorCategory.Line.PositionLine ||
-        line.getCategory() == VectorCategory.Line.GuidePositionLine
+        line.getCategory() == VectorCategory.Line.GuidePositionLine ||
+        (line.getCategory() == VectorCategory.Line.PositionLine &&
+          line.getLocationMode() != Constant.angleLocationMode)
       ) {
         continue;
       }
@@ -1285,20 +1286,17 @@ export default class ListenLayer {
         VectorType.SVG,
         this.modifyPoint.index
       );
-    } else if (this.modifyPoint.magnifierId) {  
-      if(this.modifyPoint.index==0){
+    } else if (this.modifyPoint.magnifierId) {
+      if (this.modifyPoint.index == 0) {
         //点击隐藏的放大镜不显示
         stateService.setSelectItem(
           this.modifyPoint.magnifierId,
           VectorType.Magnifier,
           this.modifyPoint.index
         );
-      }else{
-        stateService.setSelectState(
-          this.modifyPoint.index
-        );
+      } else {
+        stateService.setSelectState(this.modifyPoint.index);
       }
-    
     } else if (this.modifyPoint.linkedEdgeId) {
       stateService.setSelectItem(
         this.modifyPoint.linkedEdgeId,