Browse Source

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

bill 2 năm trước cách đây
mục cha
commit
500f0f917f

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
server/test/a0k4xu045_202305311600080410/attach/sceneStore


+ 55 - 1
src/graphic/Controls/AddRoad.js

@@ -41,9 +41,17 @@ export default class AddRoad {
 
   buildRoad() {
     console.log("添加路!");
-    if (mathUtil.equalPoint(this.startInfo.position, this.endInfo.position)) {
+    let flag = this.needDelete();
+    if (flag) {
+      return null;
+    } else if (
+      this.startInfo.linkedRoadId &&
+      this.endInfo.linkedRoadId &&
+      this.startInfo.linkedRoadId == this.endInfo.linkedRoadId
+    ) {
       return null;
     }
+
     let joinInfos = this.getJoinsForRoads();
     let splitPointIds = this.splitAllJoins(joinInfos);
     this.creatNewRoads(splitPointIds);
@@ -319,6 +327,52 @@ export default class AddRoad {
     return false;
   }
 
+  needDelete() {
+    if (mathUtil.equalPoint(this.startInfo.position, this.endInfo.position)) {
+      return true;
+    } else if (this.startInfo.linkedRoadId && this.endInfo.linkedRoadId) {
+      return true;
+    } else if (this.startInfo.linkedRoadPointId && this.endInfo.linkedRoadId) {
+      let linkedRoad = dataService.getRoad(this.endInfo.linkedRoadId);
+      if (
+        linkedRoad.startId == this.startInfo.linkedRoadPointId ||
+        linkedRoad.endId == this.startInfo.linkedRoadPointId
+      ) {
+        return true;
+      } else {
+        return false;
+      }
+    } else if (this.startInfo.linkedRoadId && this.endInfo.linkedRoadPointId) {
+      let linkedRoad = dataService.getRoad(this.startInfo.linkedRoadId);
+      if (
+        linkedRoad.startId == this.endInfo.linkedRoadPointId ||
+        linkedRoad.endId == this.endInfo.linkedRoadPointId
+      ) {
+        return true;
+      } else {
+        return false;
+      }
+    } else if (
+      this.startInfo.linkedRoadPointId &&
+      this.endInfo.linkedRoadPointId
+    ) {
+      let startRoadPoint = dataService.getRoadPoint(
+        this.startInfo.linkedRoadPointId
+      );
+      let startParent = startRoadPoint.getParent();
+      let endRoadPoint = dataService.getRoadPoint(
+        this.endInfo.linkedRoadPointId
+      );
+      let endParent = endRoadPoint.getParent();
+      for (let key in startParent) {
+        if (endParent.hasOwnProperty(key)) {
+          return true;
+        }
+      }
+    }
+    return false;
+  }
+
   /******************************************************************************************************************************************************************************/
   buildCurveRoad() {
     console.log("添加曲线路段!");

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

@@ -58,11 +58,11 @@ export default class MovePoint {
       );
       const category = linkedPoint.getCategory();
       if (
+        category != VectorCategory.Point.FixPoint &&
         category != VectorCategory.Point.BasePoint &&
         category != VectorCategory.Point.TestBasePoint
       ) {
         pointService.mergePoint(pointId, listenLayer.modifyPoint.linkedPointId);
-        uiService.setSelectBasePointId(null);
       } else {
         let point = dataService.getPoint(pointId);
         const parent = point.getParent();

+ 45 - 0
src/graphic/Controls/MoveRoad.js

@@ -6,6 +6,8 @@ import { curveRoadService } from "../Service/CurveRoadService";
 import { coordinate } from "../Coordinate";
 import { edgeService } from "../Service/EdgeService";
 import { crossPointService } from "../Service/CrossPointService";
+import { roadPointService } from "../Service/RoadPointService";
+import { listenLayer } from "../ListenLayer";
 
 export default class MoveRoad {
   constructor() {
@@ -134,6 +136,49 @@ export default class MoveRoad {
     return true;
   }
 
+  finishByMoveRoadPoint(point) {
+    if (
+      listenLayer.modifyPoint &&
+      listenLayer.modifyPoint.hasOwnProperty("linkedRoadPointId")
+    ) {
+      this.moveTo(point.vectorId, listenLayer.modifyPoint.linkedRoadPointId);
+    } else if (
+      listenLayer.modifyPoint &&
+      (listenLayer.modifyPoint.linkedRoadPointIdX ||
+        listenLayer.modifyPoint.linkedRoadPointIdY)
+    ) {
+      mathUtil.clonePoint(point, listenLayer.modifyPoint);
+    } else if (
+      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");
+    }
+    //draggingItem.vectorId所在的墙面与其他墙角相交
+    this.updateForAbsorbRoadPoints();
+    let parent = point.getParent();
+    for (let key in parent) {
+      roadService.setLanes(key);
+    }
+  }
+
   //拖拽墙角/墙面,被其他墙角吸附
   updateForAbsorbRoadPoints() {
     if (Object.keys(this.adsorbPointRoads).length == 0) {

+ 20 - 6
src/graphic/Controls/UIControl.js

@@ -484,16 +484,24 @@ export default class UIControl {
     let item;
     switch (geoType) {
       case VectorType.Line:
-        lineService.copy(vectorId);
+        const lineId = lineService.copy(vectorId);
+        item = stateService.getFocusItem();
+        item.vectorId = lineId;
         break;
       case VectorType.CurveLine:
-        lineService.copyCurveLine(vectorId);
+        const curveLineId = lineService.copyCurveLine(vectorId);
+        item = stateService.getFocusItem();
+        item.vectorId = curveLineId;
         break;
       case VectorType.Circle:
-        circleService.copy(vectorId);
+        const circleId = circleService.copy(vectorId);
+        item = stateService.getFocusItem();
+        item.vectorId = circleId;
         break;
       case VectorType.Text:
-        textService.copy(vectorId);
+        const textId = textService.copy(vectorId);
+        item = stateService.getFocusItem();
+        item.vectorId = textId;
         break;
       case VectorType.Road:
         const roadId = roadService.copyRoad(vectorId);
@@ -506,10 +514,16 @@ export default class UIControl {
         item.vectorId = curveRoadId;
         break;
       case VectorType.Magnifier:
-        await magnifierService.copy(vectorId);
+        const magnifierId = await magnifierService.copy(vectorId);
+        item = stateService.getFocusItem();
+        if (magnifierId) {
+          item.vectorId = magnifierId;
+        }
         break;
       case VectorType.SVG:
-        svgService.copy(vectorId);
+        const svgId = svgService.copy(vectorId);
+        item = stateService.getFocusItem();
+        item.vectorId = svgId;
         break;
     }
     stateService.clearEventName();

+ 3 - 42
src/graphic/Layer.js

@@ -976,6 +976,8 @@ export default class Layer {
           let vectorText = dataService.getText(draggingItem.vectorId);
           if (!vectorText.linkedPointId) {
             moveText.moveFullText(position, draggingItem.vectorId);
+          } else {
+            movePoint.movePoint(position, vectorText.linkedPointId);
           }
         }
         break;
@@ -1068,7 +1070,6 @@ export default class Layer {
         stateService.clearFocusItem();
         this.uiControl.clearFocusVector();
         this.uiControl.clearCurrentUI();
-        uiService.setSelectBasePointId(null);
         break;
       case LayerEvents.MoveRoadPoint:
         if (!draggingItem || !draggingItem.vectorId) {
@@ -1083,47 +1084,7 @@ export default class Layer {
             exceptRoadIds: point.parent,
           });
 
-          if (
-            listenLayer.modifyPoint &&
-            listenLayer.modifyPoint.hasOwnProperty("linkedRoadPointId")
-          ) {
-            moveRoad.moveTo(
-              draggingItem.vectorId,
-              listenLayer.modifyPoint.linkedRoadPointId
-            );
-          } else if (
-            listenLayer.modifyPoint &&
-            (listenLayer.modifyPoint.linkedRoadPointIdX ||
-              listenLayer.modifyPoint.linkedRoadPointIdY)
-          ) {
-            mathUtil.clonePoint(point, listenLayer.modifyPoint);
-          } else if (
-            listenLayer.modifyPoint &&
-            listenLayer.modifyPoint.hasOwnProperty("linkedRoadId")
-          ) {
-            point = roadPointService.create({
-              x: listenLayer.modifyPoint.x,
-              y: listenLayer.modifyPoint.y,
-            });
-            roadService.splitRoad(
-              listenLayer.modifyPoint.linkedRoadId,
-              point.vectorId,
-              "start"
-            );
-            moveRoad.moveTo(draggingItem.vectorId, point.vectorId);
-          } else if (moveRoad.splitRoadId != null) {
-            roadService.splitRoad(
-              moveRoad.splitRoadId,
-              draggingItem.vectorId,
-              "start"
-            );
-          }
-          //draggingItem.vectorId所在的墙面与其他墙角相交
-          moveRoad.updateForAbsorbRoadPoints();
-          let parent = point.getParent();
-          for (let key in parent) {
-            roadService.setLanes(key);
-          }
+          moveRoad.finishByMoveRoadPoint(point);
           this.history.save();
         }
         break;

+ 1 - 1
src/graphic/Load.js

@@ -471,7 +471,6 @@ export default class Load {
       this.layer.updateForLocation();
     }
     this.layer.history.init();
-
     this.layer.renderer.autoRedraw();
   }
 
@@ -483,6 +482,7 @@ export default class Load {
   }
 
   save() {
+    this.layer.exit();
     const res = coordinate.getRes();
     dataService.setRes(res);
 

+ 10 - 2
src/graphic/Renderer/Render.js

@@ -5,6 +5,8 @@ import { coordinate } from "../Coordinate.js";
 import { draw } from "./Draw.js";
 import { listenLayer } from "../ListenLayer.js";
 import Settings from "../Settings.js";
+import VectorStyle from "../enum/VectorStyle.js";
+import VectorCategory from "../enum/VectorCategory.js";
 
 export default class Render {
   constructor(layer) {
@@ -153,8 +155,14 @@ export default class Render {
     }
 
     const lines = dataService.getLines();
-    for (const key in lines) {
-      this.drawGeometry(lines[key]);
+    const sortLine = Object.keys(lines)
+      .map((key) => dataService.getLine(key))
+      .sort((line) =>
+        line.getCategory() == VectorCategory.Line.GuideLocationLine ? -1 : 1
+      );
+
+    for (const line of sortLine) {
+      this.drawGeometry(line);
     }
 
     const curveLines = dataService.getCurveLines();

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

@@ -24,7 +24,7 @@ export default class CircleService {
     let radius = circle.radius;
     let newCircle = this.create(center, radius);
     newCircle.setColor(circle.color);
-    return newCircle;
+    return newCircle.vectorId;
   }
 
   updateRadiusXYForPoint(vectorId, pointIndex) {

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

@@ -77,7 +77,7 @@ export default class LineService {
     if (line.style) {
       newLine.setStyle(line.style);
     }
-    return newLine;
+    return newLine.vectorId;
   }
 
   getLine(pointId1, pointId2) {
@@ -216,7 +216,7 @@ export default class LineService {
       curveLine.points[curveLine.points.length - 1].getIndex()
     );
     newCurveLine.curves = mathUtil.getCurvesByPoints(newCurveLine.points);
-    return newCurveLine;
+    return newCurveLine.vectorId;
   }
 
   deleteCrossPointForCurveLine(curvePointId, curveLineId) {

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

@@ -22,9 +22,10 @@ export default class MagnifierService {
       if (newMagnifier.photoUrl) {
         await newMagnifier.setImageData();
       }
-      return newMagnifier;
+      return newMagnifier.vectorId;
     } catch (e) {
       dataService.deleteMagnifier(newMagnifier.vectorId);
+      return null;
     }
   }
 }

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

@@ -66,7 +66,7 @@ export default class PointService {
     if (point) {
       const category = point.getCategory();
       if (category == VectorCategory.Point.NormalPoint) {
-        dataService.deletePoint(pointId); //暂时简单粗暴
+        this.deleteNormalPoint(pointId); //暂时简单粗暴
       } else if (category == VectorCategory.Point.BasePoint) {
         this.deleteBasePoint(pointId);
       } else if (category == VectorCategory.Point.TestBasePoint) {
@@ -76,6 +76,7 @@ export default class PointService {
       }
     }
   }
+
   updateBasePointIds() {
     let points = dataService.vectorData.points;
     Settings.basePointIds = [];
@@ -86,6 +87,14 @@ export default class PointService {
     }
   }
 
+  deleteNormalPoint(normalPointId) {
+    let normalPoint = dataService.getPoint(normalPointId);
+    let parent = normalPoint.getParent();
+    for (let key in parent) {
+      dataService.deleteLine(key);
+    }
+  }
+
   deleteBasePoint(basePointId) {
     let lines = dataService.getLines();
     for (let key in lines) {

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

@@ -134,12 +134,14 @@ export default class RoadService {
     let oldLeftEdge = dataService.getRoadEdge(road.leftEdgeId);
     leftEdge.start = uiService.getNewPositionForPop(oldLeftEdge.start);
     leftEdge.end = uiService.getNewPositionForPop(oldLeftEdge.end);
+    leftEdge.setParent(newRoad.vectorId);
     leftEdge.setStyle(oldLeftEdge.getStyle());
     leftEdge.setWeight(oldLeftEdge.getWeight());
 
     let oldRightEdge = dataService.getRoadEdge(road.rightEdgeId);
     rightEdge.start = uiService.getNewPositionForPop(oldRightEdge.start);
     rightEdge.end = uiService.getNewPositionForPop(oldRightEdge.end);
+    rightEdge.setParent(newRoad.vectorId);
     rightEdge.setStyle(oldRightEdge.getStyle());
     rightEdge.setWeight(oldRightEdge.getWeight());
 
@@ -914,7 +916,6 @@ export default class RoadService {
       this.subtraRoadFromIntersect(road.endId, roadId);
     }
   }
-
   /****************************************************************************************************************************************************************/
 
   // updateDrivewayCount(roadId, dir, type) {

+ 1 - 1
src/graphic/Service/SVGService.js

@@ -23,7 +23,7 @@ export default class SVGService {
       newSVG.points[i].x = newSVG.center.x + dx;
       newSVG.points[i].y = newSVG.center.y + dy;
     }
-    return newSVG;
+    return newSVG.vectorId;
   }
 }
 

+ 1 - 1
src/graphic/Service/TextService.js

@@ -20,7 +20,7 @@ export default class TextService {
     newText.setColor(text.color);
     newText.setValue(text.value);
     newText.setFontSize(text.fontSize);
-    return newText;
+    return newText.vectorId;
   }
 }