Pārlūkot izejas kodu

Merge branch 'master' of http://192.168.0.115:3000/bill/traffic-laser

bill 2 gadi atpakaļ
vecāks
revīzija
6cb9e2bcdf

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
server/test/a0k4xu045_202305311600080410/attach/sceneStore


+ 1 - 0
src/graphic/Controls/LocationModeControl.js

@@ -114,6 +114,7 @@ export default class LocationModeControl {
       if (basePointCount == 0) {
         return Msg.UnBasePoint;
       } else if (fixPointCount == 0) {
+        uiService.setSelectLocationMode(null)
         return Msg.UnFixPoint;
       } else if (Settings.baseLineId == null) {
         return Msg.UnBaseLine;

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

@@ -165,10 +165,14 @@ export default class MoveLine {
       }
     } else {
       if (line.getCategory() == VectorCategory.Line.BaseLine) {
-        if (uiService.getSelectLocationMode() == Constant.angleLocationMode) {
+        if (
+          uiService.getSelectLocationMode() == Constant.angleLocationMode ||
+          lineService.hasLocationModeByAngle()
+        ) {
           let msg = locationModeControl.beforeSetLocation();
           if (msg != Msg.OK) {
             uiService.prompt({ msg: msg, time: 1000 });
+            uiService.setSelectLocationMode(null);
           } else {
             startPoint.x += dx;
             startPoint.y += dy;

+ 28 - 25
src/graphic/Controls/MovePoint.js

@@ -27,6 +27,7 @@ export default class MovePoint {
             let msg = locationModeControl.beforeSetLocation();
             if (msg != Msg.OK) {
               uiService.prompt({ msg: msg, time: 1000 });
+              uiService.setSelectLocationMode(null);
               return false;
             } else {
               point.x = position.x;
@@ -53,18 +54,17 @@ export default class MovePoint {
       listenLayer.modifyPoint &&
       listenLayer.modifyPoint.linkedPointId
     ) {
+      let point = dataService.getPoint(pointId);
       let linkedPoint = dataService.getPoint(
         listenLayer.modifyPoint.linkedPointId
       );
       const category = linkedPoint.getCategory();
       if (
-        category != VectorCategory.Point.FixPoint &&
-        category != VectorCategory.Point.BasePoint &&
-        category != VectorCategory.Point.TestBasePoint
+        point.getCategory() == VectorCategory.Point.NormalPoint &&
+        category == VectorCategory.Point.NormalPoint
       ) {
         pointService.mergePoint(pointId, listenLayer.modifyPoint.linkedPointId);
       } else {
-        let point = dataService.getPoint(pointId);
         const parent = point.getParent();
         for (let key in parent) {
           let line = dataService.getLine(key);
@@ -201,30 +201,33 @@ export default class MovePoint {
 
   updateBasePoint(position, basePointId) {
     let lineGeometry = dataService.getLine(Settings.baseLineId);
-    let startPoint = dataService.getPoint(lineGeometry.startId);
-    let endPoint = dataService.getPoint(lineGeometry.endId);
-    lineGeometry = mathUtil.createLine1(startPoint, endPoint);
     let basePoint = dataService.getPoint(basePointId);
-    let parent = basePoint.getParent();
-    for (let key in parent) {
-      let line = dataService.getLine(key);
-      if (line.getCategory() == VectorCategory.Line.LocationLineByBasePoint) {
-        let otherPointId = line.getOtherPointId(basePointId);
-        let otherPoint = dataService.getPoint(otherPointId);
-        let otherLine = mathUtil.getLineForPoint(lineGeometry, otherPoint);
-        line = mathUtil.createLine3(lineGeometry, position);
-        let join = mathUtil.getIntersectionPoint(line, otherLine);
-        mathUtil.clonePoint(otherPoint, join);
-      } else if (
-        line.getCategory() == VectorCategory.Line.ExtendedPositionLine
-      ) {
-        let otherPointId = line.getOtherPointId(basePointId);
-        let otherPoint = dataService.getPoint(otherPointId);
-        let otherLine = mathUtil.createLine3(lineGeometry, otherPoint);
-        let join = mathUtil.getJoinLinePoint(position, otherLine);
-        mathUtil.clonePoint(otherPoint, join);
+    if (lineGeometry) {
+      let startPoint = dataService.getPoint(lineGeometry.startId);
+      let endPoint = dataService.getPoint(lineGeometry.endId);
+      lineGeometry = mathUtil.createLine1(startPoint, endPoint);
+      let parent = basePoint.getParent();
+      for (let key in parent) {
+        let line = dataService.getLine(key);
+        if (line.getCategory() == VectorCategory.Line.LocationLineByBasePoint) {
+          let otherPointId = line.getOtherPointId(basePointId);
+          let otherPoint = dataService.getPoint(otherPointId);
+          let otherLine = mathUtil.getLineForPoint(lineGeometry, otherPoint);
+          line = mathUtil.createLine3(lineGeometry, position);
+          let join = mathUtil.getIntersectionPoint(line, otherLine);
+          mathUtil.clonePoint(otherPoint, join);
+        } else if (
+          line.getCategory() == VectorCategory.Line.ExtendedPositionLine
+        ) {
+          let otherPointId = line.getOtherPointId(basePointId);
+          let otherPoint = dataService.getPoint(otherPointId);
+          let otherLine = mathUtil.createLine3(lineGeometry, otherPoint);
+          let join = mathUtil.getJoinLinePoint(position, otherLine);
+          mathUtil.clonePoint(otherPoint, join);
+        }
       }
     }
+
     mathUtil.clonePoint(basePoint, position);
   }
 

+ 52 - 13
src/graphic/Controls/MoveRoad.js

@@ -152,31 +152,35 @@ export default class MoveRoad {
       listenLayer.modifyPoint &&
       listenLayer.modifyPoint.hasOwnProperty("linkedRoadId")
     ) {
-      // let splitRoadPoint = roadPointService.create({
-      //   x: listenLayer.modifyPoint.x,
-      //   y: listenLayer.modifyPoint.y,
-      // });
-      // roadService.splitRoad(
-      //   listenLayer.modifyPoint.linkedRoadId,
-      //   splitRoadPoint.vectorId,
-      //   "start"
-      // );
       roadService.splitRoad(
         listenLayer.modifyPoint.linkedRoadId,
         point.vectorId,
         "start"
       );
-      //this.moveTo(point.vectorId, point.vectorId);
       edgeService.updateEdgeForMovePoint(point.vectorId);
-    } else if (this.splitRoadId != null) {
-      roadService.splitRoad(this.splitRoadId, point.vectorId, "start");
     }
+    // else if (this.splitRoadId != null) {
+    //   roadService.splitRoad(this.splitRoadId, point.vectorId, "start");
+    // }
     //draggingItem.vectorId所在的墙面与其他墙角相交
-    this.updateForAbsorbRoadPoints();
+    //this.updateForAbsorbRoadPoints();
+    // if (
+    //   this.adsorbPointRoads != null &&
+    //   Object.keys(this.adsorbPointRoads).length > 0
+    // ) {
+    //   debugger;
+    // }
+
     let parent = point.getParent();
     for (let key in parent) {
       roadService.setLanes(key);
     }
+
+    //draggingItem.vectorId所在的墙面与其他墙角相交
+    let splitPointId = this.updateForSplitRoad(point);
+    if (splitPointId) {
+      edgeService.updateEdgeForMovePoint(splitPointId);
+    }
   }
 
   //拖拽墙角/墙面,被其他墙角吸附
@@ -218,6 +222,41 @@ export default class MoveRoad {
     }
   }
 
+  updateForSplitRoad(point) {
+    if (this.splitRoadId) {
+      let splitRoad = dataService.getRoad(this.splitRoadId);
+      let splitRoadStartPoint = dataService.getRoadPoint(splitRoad.startId);
+      let splitRoadEndPoint = dataService.getRoadPoint(splitRoad.endId);
+      let splitLine = mathUtil.createLine1(
+        splitRoadStartPoint,
+        splitRoadEndPoint
+      );
+      let parent = point.getParent();
+      for (let key in parent) {
+        let road = dataService.getRoad(key);
+        let startPoint = dataService.getRoadPoint(road.startId);
+        let endPoint = dataService.getRoadPoint(road.endId);
+        let line = mathUtil.createLine1(startPoint, endPoint);
+        let join = mathUtil.getIntersectionPoint(splitLine, line);
+        if (
+          mathUtil.isContainForSegment(join, startPoint, endPoint) &&
+          mathUtil.getDistance(join, splitRoadStartPoint) <
+            Constant.minAdsorbPix
+        ) {
+          roadService.splitRoad(key, splitRoadStartPoint.vectorId, "start");
+          return splitRoadStartPoint.vectorId;
+        } else if (
+          mathUtil.isContainForSegment(join, startPoint, endPoint) &&
+          mathUtil.getDistance(join, splitRoadEndPoint) < Constant.minAdsorbPix
+        ) {
+          roadService.splitRoad(key, splitRoadEndPoint.vectorId, "end");
+          return splitRoadEndPoint.vectorId;
+        }
+      }
+    }
+    return null;
+  }
+
   getNewPointsForMoveRoad(roadId, dx, dy) {
     dx = dx;
     dy = -dy;

+ 4 - 1
src/graphic/Controls/UIControl.js

@@ -100,7 +100,10 @@ export default class UIControl {
           //先取消当前事件和进程
           this.layer.exit();
         }
-
+        //恢复默认
+        uiService.setSelectLocationMode(null);
+        uiService.setSelectPointCategory(VectorCategory.Point.NormalPoint);
+        uiService.setSelectLineCategory(VectorCategory.Line.NormalLine);
         //执行新的事件
         if (uiService.isBelongRoad(selectUI) || selectUI == "road") {
           stateService.setEventName(LayerEvents.AddRoad);

+ 35 - 33
src/graphic/Geometry/Circle.js

@@ -66,39 +66,41 @@ export default class Circle extends Geometry {
       this.setRadiusX(distance);
       distance = this.radiusY;
     }
-    const lines = mathUtil.getParallelLineForDistance(line, distance);
-    const vLine = mathUtil.getVerticalLine(line, this.center);
-    const join1 = mathUtil.getIntersectionPoint(lines.line1, vLine);
-    const join2 = mathUtil.getIntersectionPoint(lines.line2, vLine);
-    //顺时针
-    if (
-      !mathUtil.isClockwise([
-        this.points[index],
-        join1,
-        this.points[oppositeIndex],
-      ])
-    ) {
-      let nextIndex = this.getNext(index);
-      this.points[nextIndex] = {
-        x: join1.x,
-        y: join1.y,
-      };
-      nextIndex = this.getOpposite(nextIndex);
-      this.points[nextIndex] = {
-        x: join2.x,
-        y: join2.y,
-      };
-    } else {
-      let nextIndex = this.getNext(index);
-      this.points[nextIndex] = {
-        x: join2.x,
-        y: join2.y,
-      };
-      nextIndex = this.getOpposite(nextIndex);
-      this.points[nextIndex] = {
-        x: join1.x,
-        y: join1.y,
-      };
+    if (line) {
+      const lines = mathUtil.getParallelLineForDistance(line, distance);
+      const vLine = mathUtil.getVerticalLine(line, this.center);
+      const join1 = mathUtil.getIntersectionPoint(lines.line1, vLine);
+      const join2 = mathUtil.getIntersectionPoint(lines.line2, vLine);
+      //顺时针
+      if (
+        !mathUtil.isClockwise([
+          this.points[index],
+          join1,
+          this.points[oppositeIndex],
+        ])
+      ) {
+        let nextIndex = this.getNext(index);
+        this.points[nextIndex] = {
+          x: join1.x,
+          y: join1.y,
+        };
+        nextIndex = this.getOpposite(nextIndex);
+        this.points[nextIndex] = {
+          x: join2.x,
+          y: join2.y,
+        };
+      } else {
+        let nextIndex = this.getNext(index);
+        this.points[nextIndex] = {
+          x: join2.x,
+          y: join2.y,
+        };
+        nextIndex = this.getOpposite(nextIndex);
+        this.points[nextIndex] = {
+          x: join1.x,
+          y: join1.y,
+        };
+      }
     }
   }
 

+ 1 - 0
src/graphic/History/History.js

@@ -135,6 +135,7 @@ export default class History {
         point.setCategory(item.point.category);
         point.setLinkedBasePointId(item.point.linkedBasePointId);
         point.setLocationMode(item.point.locationMode);
+        point.linkedTextId = item.point.linkedTextId;
         point.parent = JSON.parse(JSON.stringify(item.point.parent));
       } else if (item.handle == HistoryEvents.ModifyPoint) {
         const prePoint = item.prePoint;

+ 1 - 0
src/graphic/Layer.js

@@ -1243,6 +1243,7 @@ export default class Layer {
         break;
       case LayerEvents.MoveCircle:
         needAutoRedraw = true;
+        this.uiControl.clearSelectUI();
         this.history.save();
         break;
       case LayerEvents.AddPoint:

+ 4 - 0
src/graphic/Load.js

@@ -35,6 +35,10 @@ export default class Load {
   async load(dataLocal, data3d) {
     this.layer.initLocation();
     coordinate.init(this.layer.canvas);
+    //恢复默认
+    uiService.setSelectLocationMode(null);
+    uiService.setSelectPointCategory(VectorCategory.Point.NormalPoint);
+    uiService.setSelectLineCategory(VectorCategory.Line.NormalLine);
     if (dataLocal) {
       if (dataLocal.Settings) {
         for (let key in dataLocal.Settings) {

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

@@ -10,7 +10,8 @@ export default class CircleService {
   constructor() {}
 
   create(center, radius, vectorId) {
-    if (!center || !radius || radius < Constant.minAdsorbPix / 2) {
+    // if (!center || !radius || radius < Constant.minAdsorbPix / 2) {
+    if (!center || !radius ) {
       return null;
     }
     let circle = new Circle(center, radius, vectorId);

+ 13 - 0
src/graphic/Service/LineService.js

@@ -8,6 +8,7 @@ import VectorCategory from "../enum/VectorCategory.js";
 import { mathUtil } from "../Util/MathUtil.js";
 import { uiService } from "./UIService.js";
 import { addLine } from "../Controls/AddLine.js";
+import Constant from "../Constant.js";
 
 export default class LineService {
   constructor() {}
@@ -94,6 +95,18 @@ export default class LineService {
     return null;
   }
 
+  //是否已经设置了直角测量法
+  hasLocationModeByAngle() {
+    let lines = dataService.getLines();
+    for (let key in lines) {
+      let line = dataService.getLine(key);
+      if (line.getLocationMode() == Constant.angleLocationMode) {
+        return true;
+      }
+    }
+    return false;
+  }
+
   /******************************************************************************曲线**************************************************************************************/
   createCurveLine(startPosition, endPosition, vectorId) {
     if (

+ 3 - 0
src/graphic/Service/PointService.js

@@ -108,6 +108,9 @@ export default class PointService {
       }
     }
     dataService.deletePoint(basePointId);
+    if (Settings.selectBasePointId == basePointId) {
+      uiService.setSelectBasePointId(null);
+    }
   }
 
   deleteFixPoint(fixPointId) {