xushiting 2 years ago
parent
commit
8d8b931334

+ 101 - 0
src/graphic/Controls/AddCrossRoad.js

@@ -0,0 +1,101 @@
+import { mathUtil } from "../Util/MathUtil";
+import { circleService } from "../Service/CircleService";
+import { listenLayer } from "../ListenLayer";
+import { roadPointService } from "../Service/RoadPointService";
+import { roadService } from "../Service/RoadService";
+import { edgeService } from "../Service/EdgeService";
+
+export default class AddCrossRoad {
+  constructor() {}
+
+  build(position, count) {}
+
+  //三岔口
+  buildThree(position) {
+    const len = 300;
+    let start = roadPointService.create(position);
+    let end1 = roadPointService.create({
+      x: start.x,
+      y: start.y + len,
+    });
+
+    let end2 = roadPointService.create({
+      x: start.x + len,
+      y: start.y,
+    });
+
+    let end3 = roadPointService.create({
+      x: start.x - len,
+      y: start.y,
+    });
+
+    //需要设置公路的车道数,是否双向等等
+    // this.leftDrivewayCount = Setting.roadLeftDrivewayCount;
+    // this.rightDrivewayCount = Setting.roadRightDrivewayCount;
+    // this.singleRoadDrivewayCount = Setting.singleRoadDrivewayCount;
+    // this.way = Setting.wayType;
+
+    roadService.create(start.vectorId, end1.vectorId);
+    roadService.create(start.vectorId, end2.vectorId);
+    roadService.create(start.vectorId, end3.vectorId);
+    edgeService.updateEdgeForMulRoad(start.vectorId);
+  }
+
+  //四岔口
+  buildFour(position) {
+    const len = 300;
+    let start = roadPointService.create(position);
+    let end1 = roadPointService.create({
+      x: start.x,
+      y: start.y + len,
+    });
+
+    let end2 = roadPointService.create({
+      x: start.x,
+      y: start.y - len,
+    });
+
+    let end3 = roadPointService.create({
+      x: start.x + len,
+      y: start.y,
+    });
+
+    let end4 = roadPointService.create({
+      x: start.x - len,
+      y: start.y,
+    });
+
+    //需要设置公路的车道数,是否双向等等
+    // this.leftDrivewayCount = Setting.roadLeftDrivewayCount;
+    // this.rightDrivewayCount = Setting.roadRightDrivewayCount;
+    // this.singleRoadDrivewayCount = Setting.singleRoadDrivewayCount;
+    // this.way = Setting.wayType;
+
+    roadService.create(start.vectorId, end1.vectorId);
+    roadService.create(start.vectorId, end2.vectorId);
+    roadService.create(start.vectorId, end3.vectorId);
+    roadService.create(start.vectorId, end4.vectorId);
+    edgeService.updateEdgeForMulRoad(start.vectorId);
+  }
+
+  //五岔口
+  buildFive(position) {
+    const len = 300;
+    const points = mathUtil.createFivePointedStar(position, len);
+    let start = roadPointService.create(position);
+    let end1 = roadPointService.create(points[0]);
+    let end2 = roadPointService.create(points[1]);
+    let end3 = roadPointService.create(points[2]);
+    let end4 = roadPointService.create(points[3]);
+    let end5 = roadPointService.create(points[4]);
+    roadService.create(start.vectorId, end1.vectorId);
+    roadService.create(start.vectorId, end2.vectorId);
+    roadService.create(start.vectorId, end3.vectorId);
+    roadService.create(start.vectorId, end4.vectorId);
+    roadService.create(start.vectorId, end5.vectorId);
+    edgeService.updateEdgeForMulRoad(start.vectorId);
+  }
+}
+
+const addCrossRoad = new AddCrossRoad();
+export { addCrossRoad };

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

@@ -22,7 +22,7 @@ export default class AddPoint {
     let line = mathUtil.createLine1(startPoint, endPoint);
     let line = mathUtil.createLine1(startPoint, endPoint);
     let vLine1 = mathUtil.getVerticalLine(line, testPoint);
     let vLine1 = mathUtil.getVerticalLine(line, testPoint);
     let join = mathUtil.getJoinLinePoint(basePoint, vLine1);
     let join = mathUtil.getJoinLinePoint(basePoint, vLine1);
-    join = pointService.addPoint(join, VectorCategory.Point.TestBasePoint);
+    join = pointService.create(join, VectorCategory.Point.TestBasePoint);
 
 
     lineService.createByPointId(
     lineService.createByPointId(
       testPointId,
       testPointId,
@@ -49,7 +49,7 @@ export default class AddPoint {
       let line = mathUtil.createLine1(startPoint, endPoint);
       let line = mathUtil.createLine1(startPoint, endPoint);
       if (testPointId2 == null) {
       if (testPointId2 == null) {
         let join = mathUtil.getJoinLinePoint(testPoint1, line);
         let join = mathUtil.getJoinLinePoint(testPoint1, line);
-        join = pointService.addPoint(join, VectorCategory.Point.TestBasePoint);
+        join = pointService.create(join, VectorCategory.Point.TestBasePoint);
         lineService.createByPointId(
         lineService.createByPointId(
           testPointId1,
           testPointId1,
           join.vectorId,
           join.vectorId,
@@ -64,7 +64,7 @@ export default class AddPoint {
       } else {
       } else {
         let testPoint2 = dataService.getPoint(testPointId2);
         let testPoint2 = dataService.getPoint(testPointId2);
         let join = mathUtil.getJoinLinePoint(testPoint2, line);
         let join = mathUtil.getJoinLinePoint(testPoint2, line);
-        join = pointService.addPoint(join, VectorCategory.Point.TestBasePoint);
+        join = pointService.create(join, VectorCategory.Point.TestBasePoint);
         lineService.createByPointId(
         lineService.createByPointId(
           testPointId2,
           testPointId2,
           join.vectorId,
           join.vectorId,

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

@@ -139,7 +139,6 @@ export default class UIControl {
   //撤销
   //撤销
   menu_revoke() {
   menu_revoke() {
     this.layer.history.goPreState();
     this.layer.history.goPreState();
-    this.layer.renderer.autoRedraw();
 
 
     const historyState = historyService.getHistoryState();
     const historyState = historyService.getHistoryState();
     // if (historyState.pre) {
     // if (historyState.pre) {
@@ -149,13 +148,13 @@ export default class UIControl {
     // }
     // }
 
 
     this.layer.stopAddVector();
     this.layer.stopAddVector();
+    this.layer.renderer.autoRedraw();
     this.layer.revokeHistory();
     this.layer.revokeHistory();
   }
   }
 
 
   //恢复
   //恢复
   menu_recovery() {
   menu_recovery() {
     this.layer.history.goNextState();
     this.layer.history.goNextState();
-    this.layer.renderer.autoRedraw();
 
 
     const historyState = historyService.getHistoryState();
     const historyState = historyService.getHistoryState();
     // if (historyState.next) {
     // if (historyState.next) {
@@ -164,6 +163,8 @@ export default class UIControl {
     //   this.layer.$xui.toolbar.recover = false;
     //   this.layer.$xui.toolbar.recover = false;
     // }
     // }
     // this.layer.$xui.toolbar.recall = true;
     // this.layer.$xui.toolbar.recall = true;
+    this.layer.stopAddVector();
+    this.layer.renderer.autoRedraw();
     this.layer.recoveryHistory();
     this.layer.recoveryHistory();
   }
   }
 
 

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

@@ -1,4 +1,5 @@
 import VectorType from "../enum/VectorType.js";
 import VectorType from "../enum/VectorType.js";
+import VectorCategory from "../enum/VectorCategory.js";
 import SelectState from "../enum/SelectState.js";
 import SelectState from "../enum/SelectState.js";
 import Geometry from "./Geometry";
 import Geometry from "./Geometry";
 import Constant from "../Constant.js";
 import Constant from "../Constant.js";
@@ -8,7 +9,7 @@ export default class Line extends Geometry {
     super();
     super();
     this.startId = startId;
     this.startId = startId;
     this.endId = endId;
     this.endId = endId;
-    this.category = null;
+    this.category = VectorCategory.Line.NormalLine;
     this.arrowColor = null; //箭头类型会用到
     this.arrowColor = null; //箭头类型会用到
     this.geoType = VectorType.Line;
     this.geoType = VectorType.Line;
     this.setId(vectorId);
     this.setId(vectorId);
@@ -16,6 +17,10 @@ export default class Line extends Geometry {
 
 
   //NormalLine,GuideLine,MeasureLine,BaseLine
   //NormalLine,GuideLine,MeasureLine,BaseLine
   setCategory(value) {
   setCategory(value) {
+    if (!value) {
+      this.category = VectorCategory.Line.NormalLine;
+    } else {
+    }
     this.category = value;
     this.category = value;
   }
   }
 
 

+ 7 - 2
src/graphic/Geometry/Point.js

@@ -1,4 +1,5 @@
 import VectorType from "../enum/VectorType.js";
 import VectorType from "../enum/VectorType.js";
+import VectorCategory from "../enum/VectorCategory.js";
 import Geometry from "./Geometry";
 import Geometry from "./Geometry";
 
 
 export default class Point extends Geometry {
 export default class Point extends Geometry {
@@ -7,7 +8,7 @@ export default class Point extends Geometry {
     this.x = null;
     this.x = null;
     this.y = null;
     this.y = null;
     this.parent = {};
     this.parent = {};
-    this.category = null;
+    this.category = VectorCategory.Point.NormalPoint;
     this.geoType = VectorType.Point;
     this.geoType = VectorType.Point;
     this.setId(vectorId);
     this.setId(vectorId);
 
 
@@ -21,6 +22,10 @@ export default class Point extends Geometry {
 
 
   //基准点:BasePoint
   //基准点:BasePoint
   setCategory(value) {
   setCategory(value) {
-    this.category = value;
+    if (!value) {
+      this.category = VectorCategory.Point.NormalPoint;
+    } else {
+      this.category = value;
+    }
   }
   }
 }
 }

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

@@ -6,7 +6,7 @@ import { mathUtil } from "../Util/MathUtil.js";
 export default class PointService {
 export default class PointService {
   constructor() {}
   constructor() {}
 
 
-  addPoint(position, categoryType) {
+  create(position, categoryType) {
     let point = new Point(position);
     let point = new Point(position);
     point.setCategory(categoryType);
     point.setCategory(categoryType);
     dataService.addPoint(point);
     dataService.addPoint(point);

+ 27 - 0
src/graphic/Util/MathUtil.js

@@ -1022,6 +1022,33 @@ export default class MathUtil {
     }
     }
   }
   }
 
 
+  //生成五角星
+  createFivePointedStar(position, r) {
+    let deg = Math.PI / 180; //角度
+    let points = [];
+    points[0] = {
+      x: position.x - r * Math.cos(54 * deg),
+      y: position.y + r * Math.sin(54 * deg),
+    };
+    points[1] = {
+      x: position.x,
+      y: position.y - r,
+    };
+    points[2] = {
+      x: position.x + r * Math.cos(54 * deg),
+      y: position.y + r * Math.sin(54 * deg),
+    };
+    points[3] = {
+      x: position.x - r * Math.cos(18 * deg),
+      y: position.y - r * Math.sin(18 * deg),
+    };
+    points[4] = {
+      x: position.x + r * Math.cos(18 * deg),
+      y: position.y - r * Math.sin(18 * deg),
+    };
+    return points;
+  }
+
   angleTo(v1, v2) {
   angleTo(v1, v2) {
     const denominator = Math.sqrt(this.lengthSq(v1) * this.lengthSq(v2));
     const denominator = Math.sqrt(this.lengthSq(v1) * this.lengthSq(v2));
     if (denominator === 0) return 90;
     if (denominator === 0) return 90;