xushiting 2 anos atrás
pai
commit
b915cb3815

+ 2 - 0
src/graphic/Constant.js

@@ -36,5 +36,7 @@ const Constant = {
   twoWay: "twoWay", //one表示单向,two表示双向
   defaultSingleLaneWidth: 30, //单个车道的宽度
   defaultMidDivideWidth: 5, //隔离带的宽度
+  angleLocationMode: "AngleLocationMode", //直角定位
+  allLocationMode: "AllLocationMode", //综合定位
 };
 export default Constant;

+ 1 - 11
src/graphic/Controls/AddLine.js

@@ -10,7 +10,6 @@ export default class AddLine {
     this.newLine = null;
     this.startInfo = {};
     this.baseLineId = null;
-    this.category = VectorCategory.Line.NormalLine;
   }
 
   setPointInfo(pointInfo) {
@@ -38,11 +37,7 @@ export default class AddLine {
       this.newLine == null &&
       !mathUtil.equalPoint(this.startInfo.position, position)
     ) {
-      this.newLine = lineService.create(
-        this.startInfo.position,
-        position,
-        this.category
-      );
+      this.newLine = lineService.create(this.startInfo.position, position);
     }
   }
 
@@ -65,10 +60,6 @@ export default class AddLine {
     }
   }
 
-  setCategory(value) {
-    this.category = value;
-  }
-
   setBaseLineId(baseLineId) {
     this.baseLineId = baseLineId;
   }
@@ -87,7 +78,6 @@ export default class AddLine {
     this.newLine = null;
     this.startInfo = {};
     this.baseLineId = null;
-    this.category = VectorCategory.Line.NormalLine;
   }
 }
 

+ 7 - 14
src/graphic/Controls/UIControl.js

@@ -74,13 +74,7 @@ export default class UIControl {
           stateService.setEventName(LayerEvents.AddRoad);
         } else if (selectUI == UIEvents.CurveRoad) {
           stateService.setEventName(LayerEvents.AddCurveRoad);
-        } else if (selectUI == UIEvents.Arrow) {
-          stateService.setEventName(LayerEvents.AddLine);
-          addLine.setCategory(VectorCategory.Line.ArrowLine);
-        } else if (selectUI == UIEvents.MeasureLine) {
-          stateService.setEventName(LayerEvents.AddLine);
-          addLine.setCategory(VectorCategory.Line.MeasureLine);
-        } else if (selectUI == UIEvents.Line) {
+        } else if (uiService.isBelongLine(selectUI)) {
           stateService.setEventName(LayerEvents.AddLine);
         } else if (selectUI == UIEvents.Circle) {
           stateService.setEventName(LayerEvents.AddCircle);
@@ -119,7 +113,6 @@ export default class UIControl {
     }
   }
 
-
   //截图
   async screenShot() {
     let canvas = this.layer.canvas;
@@ -127,31 +120,31 @@ export default class UIControl {
     dataService.setGridDisplay(false);
     this.layer.renderer.autoRedraw();
     // this.downloadCadImg(canvas, "test.jpg");
-    const blob = await this.getCadBlob(canvas)
+    const blob = await this.getCadBlob(canvas);
     //显示grid
     dataService.setGridDisplay(true);
     this.layer.renderer.autoRedraw();
 
-    return blob
+    return blob;
   }
 
   getCadBlob(canvas) {
     var type = "jpg";
-    return new Promise(resolve => canvas.toBlob(resolve, `${type}/image`))
+    return new Promise((resolve) => canvas.toBlob(resolve, `${type}/image`));
   }
 
   downloadCadImg(canvas, filename) {
     // 图片导出为 jpg 格式
     var type = "jpg";
     var imgData = canvas.toDataURL(type, 3);
-    canvas.toBlob(`${type}/image`)
+    canvas.toBlob(`${type}/image`);
 
     // 加工image data,替换mime type
     imgData = imgData.replace(this._fixType(type), "image/octet-stream");
     // 下载后的图片名
     //var filename = 'cad_' + new Date().getTime() + '.' + type
     // download
-    debugger
+    debugger;
     this.saveFile(imgData, filename);
   }
 
@@ -222,7 +215,7 @@ export default class UIControl {
 
   // value 为true则开 false则关
   menu_backgroundImg(value) {
-    console.log(value)
+    console.log(value);
     //
     const backgroundImg = dataService.getBackgroundImg();
     backgroundImg.setDisplay(value);

+ 3 - 2
src/graphic/Geometry/Line.js

@@ -4,13 +4,14 @@ import SelectState from "../enum/SelectState.js";
 import Geometry from "./Geometry";
 import Constant from "../Constant.js";
 import Style from "@/graphic/CanvasStyle/index.js";
+import Settings from "../Settings";
 
 export default class Line extends Geometry {
   constructor(startId, endId, vectorId) {
     super();
     this.startId = startId;
     this.endId = endId;
-    this.category = VectorCategory.Line.NormalLine;
+    this.category = Settings.lineCategory;
     this.arrowColor = Style.Arrow.strokeStyle; //箭头类型会用到
     this.geoType = VectorType.Line;
     this.setId(vectorId);
@@ -19,7 +20,7 @@ export default class Line extends Geometry {
   //NormalLine,GuideLine,MeasureLine,BaseLine
   setCategory(value) {
     if (!value) {
-      this.category = VectorCategory.Line.NormalLine;
+      this.category = Settings.lineCategory;
     } else {
     }
     this.category = value;

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

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

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

@@ -4,6 +4,7 @@ import { mathUtil } from "../Util/MathUtil.js";
 import Settings from "../Settings";
 import { coordinate } from "../Coordinate.js";
 import UIEvents from "../enum/UIEvents.js";
+import VectorCategory from "../enum/VectorCategory.js";
 import Constant from "../Constant.js";
 
 export default class UIService {
@@ -62,6 +63,34 @@ export default class UIService {
     }
   }
 
+  isBelongLine(ui) {
+    if (ui == UIEvents.Arrow) {
+      this.setLineCategory(VectorCategory.Line.ArrowLine);
+      return true;
+    } else if (ui == UIEvents.MeasureLine) {
+      this.setLineCategory(VectorCategory.Line.MeasureLine);
+      return true;
+    } else if (ui == UIEvents.Line) {
+      this.setLineCategory(VectorCategory.Line.NormalLine);
+      return true;
+    }
+    return false;
+  }
+
+  isBelongPoint(ui) {
+    // if (ui == UIEvents.Arrow) {
+    //   this.setLineCategory(VectorCategory.Line.ArrowLine);
+    //   return true;
+    // } else if (ui == UIEvents.MeasureLine) {
+    //   this.setLineCategory(VectorCategory.Line.MeasureLine);
+    //   return true;
+    // } else if (ui == UIEvents.Line) {
+    //   this.setLineCategory(VectorCategory.Line.NormalLine);
+    //   return true;
+    // }
+    // return false;
+  }
+
   setWayType(value) {
     Settings.wayType = value;
   }
@@ -98,6 +127,19 @@ export default class UIService {
     Settings.rightRoadWidth = value;
   }
 
+  setLineCategory(value) {
+    Settings.lineCategory = value;
+  }
+
+  setPointCategory(value) {
+    Settings.pointCategory = value;
+  }
+
+  //设置定位法
+  setLocationMode(value) {
+    Settings.locationMode = value;
+  }
+
   //如果position在屏幕左上角,返回的就朝向右下角,如果是右下角,则返回的是左上角。其他情况以此类推
   getNewPositionForPop(position) {
     const offset = 50;

+ 4 - 0
src/graphic/Settings.js

@@ -1,4 +1,5 @@
 import Constant from "./Constant";
+import VectorCategory from "./enum/VectorCategory";
 const Settings = {
   roadLeftDrivewayCount: 1,
   roadRightDrivewayCount: 1,
@@ -16,5 +17,8 @@ const Settings = {
   roadMidDivideWidth: Constant.defaultMidDivideWidth,
   curveRoadMidDivideWidth: Constant.defaultMidDivideWidth,
   wayType: Constant.twoWay, //one表示单向,two表示双向
+  lineCategory: VectorCategory.Line.NormalLine,
+  pointCategory: VectorCategory.Point.NormalPoint,
+  locationMode: Constant.angleLocationMode,
 };
 export default Settings;

+ 2 - 2
src/graphic/enum/VectorCategory.js

@@ -5,13 +5,13 @@ const VectorCategory = {
     BaseLine: "BaseLine",
     MeasureLine: "MeasureLine",
     GuideLine: "GuideLine",
-    PositionLine: "PositionLine", //定位线。与定位法相关的
+    PositionLine: "PositionLine", //定位线。基准点与待测点相连的线,或者与待测基准点相连的线
   },
   Point: {
     BasePoint: "BasePoint", //基准点
     TestPoint: "TestPoint", //待测点
     NormalPoint: "NormalPoint", //正常点
-    TestBasePoint: "TestBasePoint", //待测基准点
+    TestBasePoint: "TestBasePoint", //待测基准点,待测点与基准线相交的点
     FixPoint: "FixPoint", //固定点
   },
 };