xushiting 2 éve
szülő
commit
32e34a9799

+ 2 - 2
src/graphic/Controls/AddSVG.js

@@ -18,8 +18,8 @@ export default class AddSVG {
     this.value = value;
   }
 
-  buildSVG(center) {
-    this.newSVG = svgService.create(center);
+  buildSVG(center, type) {
+    this.newSVG = svgService.create(center, type);
     listenLayer.clear();
   }
 

+ 19 - 18
src/graphic/Controls/MoveRoad.js

@@ -1028,25 +1028,26 @@ export default class MoveRoad {
     leftCurveEdge.curves = mathUtil.getCurvesByPoints(leftCurveEdge.points);
     rightCurveEdge.curves = mathUtil.getCurvesByPoints(rightCurveEdge.points);
 
-    for (let i = 0; i < curveRoad.leftLanes.length; ++i) {
-      for (let j = 0; j < curveRoad.leftLanes[i].length; ++j) {
-        curveRoad.leftLanes[i][j].x += dx;
-        curveRoad.leftLanes[i][j].y += dy;
-      }
-      curveRoad.leftLanesCurves[i] = mathUtil.getCurvesByPoints(
-        curveRoad.leftLanes[i]
-      );
-    }
+    // for (let i = 0; i < curveRoad.leftLanes.length; ++i) {
+    //   for (let j = 0; j < curveRoad.leftLanes[i].length; ++j) {
+    //     curveRoad.leftLanes[i][j].x += dx;
+    //     curveRoad.leftLanes[i][j].y += dy;
+    //   }
+    //   curveRoad.leftLanesCurves[i] = mathUtil.getCurvesByPoints(
+    //     curveRoad.leftLanes[i]
+    //   );
+    // }
 
-    for (let i = 0; i < curveRoad.rightLanes.length; ++i) {
-      for (let j = 0; j < curveRoad.rightLanes[i].length; ++j) {
-        curveRoad.rightLanes[i][j].x += dx;
-        curveRoad.rightLanes[i][j].y += dy;
-      }
-      curveRoad.rightLanesCurves[i] = mathUtil.getCurvesByPoints(
-        curveRoad.rightLanes[i]
-      );
-    }
+    // for (let i = 0; i < curveRoad.rightLanes.length; ++i) {
+    //   for (let j = 0; j < curveRoad.rightLanes[i].length; ++j) {
+    //     curveRoad.rightLanes[i][j].x += dx;
+    //     curveRoad.rightLanes[i][j].y += dy;
+    //   }
+    //   curveRoad.rightLanesCurves[i] = mathUtil.getCurvesByPoints(
+    //     curveRoad.rightLanes[i]
+    //   );
+    // }
+    curveRoadService.setLanes(curveRoadId);
   }
 
   // pointId1移动到pointId2

+ 14 - 1
src/graphic/Controls/MoveSVG.js

@@ -6,8 +6,21 @@ export default class MoveSVG {
 
   moveFullSVG(position, svgId) {
     let svg = dataService.getSVG(svgId);
+    let dx = position.x - svg.center.x;
+    let dy = position.y - svg.center.y;
     mathUtil.clonePoint(svg.center, position);
-    svg.setBoundingVertexs();
+    //svg.setBoundingVertexs();
+    svg.points[0].x += dx;
+    svg.points[0].y += dy;
+
+    svg.points[1].x += dx;
+    svg.points[1].y += dy;
+
+    svg.points[2].x += dx;
+    svg.points[2].y += dy;
+
+    svg.points[3].x += dx;
+    svg.points[3].y += dy;
   }
 
   // movePoint(position, svgId, pointIndex) {

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

@@ -5,6 +5,7 @@ import VectorType from "../enum/VectorType.js";
 import VectorStyle from "../enum/VectorStyle.js";
 import GeoActions from "../enum/GeoActions.js";
 import VectorEvents from "../enum/VectorEvents.js";
+import SVGType from "../enum/SVGType.js";
 import { stateService } from "../Service/StateService.js";
 import { uiService } from "../Service/UIService.js";
 import { dataService } from "../Service/DataService.js";
@@ -102,12 +103,11 @@ export default class UIControl {
           stateService.setEventName(LayerEvents.AddText);
         } else if (selectUI == UIEvents.Magnifier) {
           stateService.setEventName(LayerEvents.AddMagnifier);
-        } else if (selectUI == UIEvents.SVG) {
+        } else if (SVGType[selectUI]) {
+          uiService.setSelectSVGType(selectUI);
           stateService.setEventName(LayerEvents.AddSVG);
         } else if (selectUI == UIEvents.Img) {
           stateService.setEventName(LayerEvents.Img);
-        } else if (uiService.isBelongSVG(selectUI)) {
-          stateService.setEventName(LayerEvents.AddSVG);
         }
       }
     }
@@ -272,9 +272,6 @@ export default class UIControl {
       case VectorType.Point:
         pointService.deletePoint(vectorId);
         break;
-      case VectorType.CurveRoadPoint:
-        curveRoadPointService.deletePoint(vectorId);
-        break;
       case VectorType.Line:
         dataService.deleteLine(vectorId);
         if (vectorId == Settings.baseLineId) {

+ 11 - 3
src/graphic/History/History.js

@@ -305,7 +305,11 @@ export default class History {
       if (item.handle == HistoryEvents.AddSVG) {
         dataService.deleteSVG(item.svg.id);
       } else if (item.handle == HistoryEvents.DeleteSVG) {
-        let newSVG = svgService.create(item.svg.center, item.svg.id);
+        let newSVG = svgService.create(
+          item.svg.center,
+          item.svg.type,
+          item.svg.id
+        );
         historyUtil.assignSVGFromSVG(newSVG, item.svg);
       } else if (item.handle == HistoryEvents.ModifySVG) {
         const preSVG = item.preSVG;
@@ -669,13 +673,17 @@ export default class History {
     for (let i = 0; i < itemForSVGs.length; ++i) {
       const item = itemForSVGs[i];
       if (item.handle == HistoryEvents.AddSVG) {
-        let vSVG = svgService.create(item.svg.center, item.svg.id);
+        let vSVG = svgService.create(
+          item.svg.center,
+          item.svg.type,
+          item.svg.id
+        );
         historyUtil.assignSVGFromSVG(vSVG, item.svg);
       } else if (item.handle == HistoryEvents.DeleteSVG) {
         dataService.deleteSVG(item.svg.id);
       } else if (item.handle == HistoryEvents.ModifySVG) {
         const currentSVG = item.curSVG;
-        let preSVG = dataService.getSVG(item.curSVG.id);
+        let preSVG = dataService.getSVG(item.preSVG.id);
         historyUtil.assignSVGFromSVG(preSVG, currentSVG);
       }
     }

+ 10 - 5
src/graphic/Layer.js

@@ -129,6 +129,7 @@ export default class Layer {
     //用于支持平板电脑
     listenLayer.start(position);
     let selectItem = stateService.getSelectItem();
+    let focusItem = stateService.getFocusItem();
     this.setEventName("mouseDown");
     const eventName = stateService.getEventName();
     switch (eventName) {
@@ -272,8 +273,8 @@ export default class Layer {
         }
         break;
       case VectorEvents.AddCrossPoint:
-        if (selectItem && selectItem.dir && selectItem.vectorId) {
-          const curveRoad = dataService.getCurveRoad(selectItem.vectorId);
+        if (focusItem && focusItem.vectorId) {
+          const curveRoad = dataService.getCurveRoad(focusItem.vectorId);
           let index = mathUtil.getIndexForCurvesPoints(
             position,
             curveRoad.points
@@ -296,17 +297,21 @@ export default class Layer {
               curveRoadService.addCPoint(curveRoad, position, 1);
             }
           }
+          curveRoadService.setLanes(curveRoad.vectorId);
           stateService.clearEventName();
           this.history.save();
           this.renderer.autoRedraw();
         }
         break;
       case VectorEvents.MinusCrossPoint:
-        if (selectItem && selectItem.dir && selectItem.vectorId) {
+        if (selectItem && selectItem.vectorId) {
           const curvePoint = dataService.getCurveRoadPoint(selectItem.vectorId);
           const curveRoad = dataService.getCurveRoad(curvePoint.parent);
-          curveRoadService.subCPoint(curveRoad, curvePoint.getIndex());
-          stateService.clearEventName();
+          if (curveRoad.points.length > 3) {
+            curveRoadService.subCPoint(curveRoad, curvePoint.getIndex());
+            curveRoadService.setLanes(curveRoad.vectorId);
+            stateService.clearEventName();
+          }
           this.history.save();
           this.renderer.autoRedraw();
         }

+ 18 - 16
src/graphic/ListenLayer.js

@@ -817,24 +817,26 @@ export default class ListenLayer {
           x: leftJoinInfo.position.x,
           y: leftJoinInfo.position.y,
         };
-      } else {
-        if (rightJoinInfo.distance < Constant.minAdsorbPix) {
-          const index = mathUtil.getIndexForCurvesPoints(
-            rightJoinInfo.position,
-            curveRoad.points
-          );
-          curveEdgeInfo = {
-            curveEdgeId: curveRoad.rightEdgeId,
-            type: VectorType.CurveRoadEdge,
-            distance: rightJoinInfo.distance,
-            selectIndex: index,
-            x: rightJoinInfo.position.x,
-            y: rightJoinInfo.position.y,
-          };
-        }
+      } else if (rightJoinInfo.distance < Constant.minAdsorbPix) {
+        const index = mathUtil.getIndexForCurvesPoints(
+          rightJoinInfo.position,
+          curveRoad.points
+        );
+        curveEdgeInfo = {
+          curveEdgeId: curveRoad.rightEdgeId,
+          type: VectorType.CurveRoadEdge,
+          distance: rightJoinInfo.distance,
+          selectIndex: index,
+          x: rightJoinInfo.position.x,
+          y: rightJoinInfo.position.y,
+        };
       }
     }
-    if (curveRoadInfo.curveRoadId) {
+    if (
+      curveRoadInfo.curveRoadId &&
+      (!curveEdgeInfo.curveEdgeId ||
+        curveRoadInfo.distance < curveEdgeInfo.distance)
+    ) {
       return curveRoadInfo;
     } else if (curveEdgeInfo.curveEdgeId) {
       return curveEdgeInfo;

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

@@ -3,7 +3,7 @@ import Line from "../Geometry/Line.js";
 import CurvePoint from "../Geometry/CurvePoint.js";
 import CurveLine from "../Geometry/CurveLine.js";
 import { dataService } from "./DataService.js";
-// import { curvePointService } from "./CurvePointService.js";
+import { curvePointService } from "./CurvePointService.js";
 import VectorCategory from "../enum/VectorCategory.js";
 import { mathUtil } from "../Util/MathUtil.js";
 import { uiService } from "./UIService.js";

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

@@ -5,8 +5,8 @@ import { mathUtil } from "../Util/MathUtil.js";
 export default class SVGService {
   constructor() {}
 
-  create(position, svgId) {
-    let svg = new SVG(position, svgId);
+  create(position, type, svgId) {
+    let svg = new SVG(position, type, svgId);
     dataService.addSVG(svg);
     return svg;
   }

+ 0 - 7
src/graphic/Service/UIService.js

@@ -105,13 +105,6 @@ export default class UIService {
     return false;
   }
 
-  isBelongSVG(ui) {
-    if (ui == UIEvents.BusPlane) {
-      this.setSelectSVGType(ui);
-      return true;
-    }
-  }
-
   isBelongRoadEdgeStyle(ui) {
     if (ui == VectorStyle.SingleSolidLine) {
       return true;