xushiting 2 years ago
parent
commit
14038daa2d

+ 11 - 2
src/graphic/Controls/MoveMagnifier.js

@@ -1,11 +1,20 @@
+import { coordinate } from "../Coordinate";
 import { dataService } from "../Service/DataService";
 
 export default class MoveMagnifier {
   constructor() {}
 
-  moveFullMagnifier(position, magnifierId) {
+  moveFullMagnifier(position, magnifierId, index) {
     let magnifier = dataService.getMagnifier(magnifierId);
-    magnifier.setPosition(position);
+    if (index == 0) {
+      magnifier.setPosition(position);
+    } else {
+      const popPosition = coordinate.getScreenXY(position);
+      magnifier.popPosition = {
+        x: popPosition.x,
+        y: popPosition.y,
+      };
+    }
   }
 }
 

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

@@ -129,6 +129,8 @@ export default class UIControl {
         roadEdge = dataService.getCurveRoadEdge(focusItem.vectorId);
         roadEdge.setStyle(selectUI);
       }
+      this.layer.history.save();
+      this.layer.renderer.autoRedraw();
     } else if (selectUI == VectorEvents.AddLane) {
       if (focusItem && focusItem.vectorId) {
         stateService.setEventName(VectorEvents.AddLane);
@@ -515,19 +517,30 @@ export default class UIControl {
     this.layer.renderer.autoRedraw();
   }
 
-
   // 设置默认设置
   setDefaultSetting(setting) {
-    console.log("获得设置", setting)
+    console.log("获得设置", setting);
+
+    uiService.setRoadMidDivideWidth(
+      setting.roadQuarantineWidth / coordinate.res
+    );
+    uiService.setCurveRoadMidDivideWidth(
+      setting.roadQuarantineWidth / coordinate.res
+    );
+    uiService.setSingleLaneWidth(setting.singleRoadWidth / coordinate.res);
+    uiService.setLineWidth(setting.lineWidth / 1000 / coordinate.res);
   }
 
   // 获取默认设置
   getDefaultSetting() {
+    const singleLaneWidth = uiService.getSingleLaneWidth();
+    const roadMidDivideWidth = uiService.getRoadMidDivideWidth();
+    const lineWidth = uiService.getLineWidth();
     return {
-      singleRoadWidth: 4,
-      roadQuarantineWidth: 1,
-      lineWidth: 1
-    }
+      singleRoadWidth: singleLaneWidth * coordinate.res,
+      roadQuarantineWidth: roadMidDivideWidth * coordinate.res,
+      lineWidth: lineWidth * coordinate.res * 1000,
+    };
   }
 
   hidePrompt() {

+ 1 - 1
src/graphic/Coordinate.js

@@ -2,7 +2,7 @@ import Constant from "./Constant";
 import { dataService } from "./Service/DataService";
 
 const defaultZoom = 100;
-const defaultRes = 1;
+const defaultRes = 0.1;
 const minAdsorbPix = 30;
 
 export default class Coordinate {

+ 6 - 3
src/graphic/Geometry/CurveRoad.js

@@ -11,8 +11,10 @@ export default class CurveRoad extends Road {
     this.singleLanesCurves = []; //单向车道
     this.leftDrivewayCount = Settings.curveRoadLeftDrivewayCount; //左边的车道个数
     this.rightDrivewayCount = Settings.curveRoadRightDrivewayCount; //右边的车道个数
-    this.leftWidth = Settings.leftCurveRoadWidth;
-    this.rightWidth = Settings.rightCurveRoadWidth;
+    this.leftWidth =
+      Settings.curveRoadLeftDrivewayCount * Settings.singleLaneWidth;
+    this.rightWidth =
+      Settings.curveRoadRightDrivewayCount * Settings.singleLaneWidth;
     this.midDivide = {
       leftMidDivide: [],
       leftMidDivideCurves: [],
@@ -21,8 +23,9 @@ export default class CurveRoad extends Road {
       midDivideWidth: Settings.curveRoadMidDivideWidth,
     };
     this.curves = [];
-    this.singleCurveRoadWidth = Settings.singleCurveRoadWidth;
     this.singleCurveRoadDrivewayCount = Settings.singleCurveRoadDrivewayCount;
+    this.singleCurveRoadWidth =
+      Settings.singleCurveRoadDrivewayCount * Settings.singleLaneWidth;
     this.geoType = VectorType.CurveRoad;
     this.setId(vectorId);
   }

+ 5 - 3
src/graphic/Geometry/Road.js

@@ -24,10 +24,12 @@ export default class Road extends Geometry {
     this.leftDrivewayCount = Settings.roadLeftDrivewayCount; //左边的车道个数
     this.rightDrivewayCount = Settings.roadRightDrivewayCount; //右边的车道个数
     this.geoType = VectorType.Road;
-    this.leftWidth = Settings.leftRoadWidth;
-    this.rightWidth = Settings.rightRoadWidth;
-    this.singleRoadWidth = Settings.singleRoadWidth;
+    this.leftWidth = Settings.roadLeftDrivewayCount * Settings.singleLaneWidth;
+    this.rightWidth =
+      Settings.roadRightDrivewayCount * Settings.singleLaneWidth;
     this.singleRoadDrivewayCount = Settings.singleRoadDrivewayCount;
+    this.singleRoadWidth =
+      Settings.singleRoadDrivewayCount * Settings.singleLaneWidth;
     this.way = Settings.wayType;
     this.setId(vectorId);
   }

+ 8 - 2
src/graphic/History/HistoryUtil.js

@@ -136,7 +136,8 @@ export default class HistoryUtil {
     if (
       mathUtil.equalPoint(roadEdge1.start, roadEdge2.start) &&
       mathUtil.equalPoint(roadEdge1.end, roadEdge2.end) &&
-      roadEdge1.parent == roadEdge2.parent
+      roadEdge1.parent == roadEdge2.parent &&
+      roadEdge1.style == roadEdge2.style
     ) {
       return false;
     } else {
@@ -198,7 +199,8 @@ export default class HistoryUtil {
       mathUtil.equalPoint(curveRoadEdge1.start, curveRoadEdge2.start) &&
       mathUtil.equalPoint(curveRoadEdge1.end, curveRoadEdge2.end) &&
       mathUtil.equalPoints(curveRoadEdge1.points, curveRoadEdge2.points) &&
-      curveRoadEdge1.parent == curveRoadEdge2.parent
+      curveRoadEdge1.parent == curveRoadEdge2.parent &&
+      curveRoadEdge1.style == curveRoadEdge2.style
     ) {
       return false;
     } else {
@@ -382,6 +384,7 @@ export default class HistoryUtil {
   assignRoadEdgeFromRoadEdge(roadEdge1, roadEdge2) {
     const roadEdgeInfo = {};
     roadEdgeInfo.vectorId = roadEdge1.vectorId;
+    roadEdgeInfo.style = roadEdge2.style;
     roadEdgeInfo.start = { x: roadEdge2.start.x, y: roadEdge2.start.y };
     roadEdgeInfo.end = { x: roadEdge2.end.x, y: roadEdge2.end.y };
     roadEdgeInfo.parent = roadEdge2.parent;
@@ -444,6 +447,7 @@ export default class HistoryUtil {
       JSON.stringify(curveRoadEdge2.curves)
     );
     curveRoadEdgeInfo.parent = curveRoadEdge2.parent;
+    curveRoadEdgeInfo.style = curveRoadEdge2.style;
     this.setCurveRoadEdgeInfo(curveRoadEdgeInfo);
   }
 
@@ -857,6 +861,7 @@ export default class HistoryUtil {
     mathUtil.clonePoint(roadEdge.start, roadEdgeInfo.start);
     mathUtil.clonePoint(roadEdge.end, roadEdgeInfo.end);
     roadEdge.type = roadEdgeInfo.type;
+    roadEdge.style = roadEdgeInfo.style;
   }
 
   setRoadInfo(roadInfo) {
@@ -904,6 +909,7 @@ export default class HistoryUtil {
     mathUtil.clonePoints(curveRoadEdge.points, curveRoadEdgeInfo.points);
     curveRoadEdge.curves = JSON.parse(JSON.stringify(curveRoadEdgeInfo.curves));
     curveRoadEdge.type = curveRoadEdgeInfo.type;
+    curveRoadEdge.style = curveRoadEdgeInfo.style;
   }
 
   setCurveRoadInfo(curveRoadInfo) {

+ 6 - 1
src/graphic/Layer.js

@@ -937,7 +937,11 @@ export default class Layer {
       case LayerEvents.MoveMagnifier:
         needAutoRedraw = true;
         if (draggingItem != null) {
-          moveMagnifier.moveFullMagnifier(position, draggingItem.vectorId);
+          moveMagnifier.moveFullMagnifier(
+            position,
+            draggingItem.vectorId,
+            draggingItem.state
+          );
         }
         break;
     }
@@ -1161,6 +1165,7 @@ export default class Layer {
           uiService.setSelectPointCategory(VectorCategory.Point.NormalPoint);
         }
         this.history.save();
+        elementService.hideAll();
         break;
       case LayerEvents.MoveCurvePoint:
         needAutoRedraw = true;

+ 21 - 2
src/graphic/ListenLayer.js

@@ -961,7 +961,7 @@ export default class ListenLayer {
         continue;
       }
       const magnifier = dataService.getMagnifier(magnifierId);
-      const distance = this.getDistance(position, magnifier.position);
+      let distance = this.getDistance(position, magnifier.position);
       if (distance < Constant.minAdsorbPix) {
         magnifierInfo = {
           magnifierId: magnifierId,
@@ -969,7 +969,25 @@ export default class ListenLayer {
           distance: distance,
           x: magnifier.position.x,
           y: magnifier.position.y,
+          index: 0,
         };
+        break;
+      } else {
+        const popPosition = coordinate.getXYFromScreen({
+          x: magnifier.popPosition.x / coordinate.ratio,
+          y: magnifier.popPosition.y / coordinate.ratio,
+        });
+        distance = this.getDistance(position, popPosition);
+        if (distance < 100) {
+          //圆圈的半径
+          magnifierInfo = {
+            magnifierId: magnifierId,
+            type: VectorType.Magnifier,
+            distance: distance,
+            index: 1,
+          };
+          break;
+        }
       }
     }
 
@@ -1086,6 +1104,7 @@ export default class ListenLayer {
     } else if (info && info.magnifierInfo.magnifierId) {
       this.modifyPoint = {};
       this.modifyPoint.magnifierId = info.magnifierInfo.magnifierId;
+      this.modifyPoint.index = info.magnifierInfo.index;
       this.modifyPoint.x = info.magnifierInfo.x;
       this.modifyPoint.y = info.magnifierInfo.y;
     } else if (
@@ -1270,7 +1289,7 @@ export default class ListenLayer {
       stateService.setSelectItem(
         this.modifyPoint.magnifierId,
         VectorType.Magnifier,
-        SelectState.Select
+        this.modifyPoint.index
       );
     } else if (this.modifyPoint.linkedEdgeId) {
       stateService.setSelectItem(

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

@@ -234,6 +234,34 @@ export default class UIService {
     return Settings.selectRoadStructure;
   }
 
+  setRoadMidDivideWidth(value) {
+    Settings.roadMidDivideWidth = value;
+  }
+
+  setCurveRoadMidDivideWidth(value) {
+    Settings.curveRoadMidDivideWidth = value;
+  }
+
+  setSingleLaneWidth(value) {
+    Settings.singleLaneWidth = value;
+  }
+
+  getSingleLaneWidth() {
+    return Settings.singleLaneWidth;
+  }
+
+  getRoadMidDivideWidth() {
+    return Settings.roadMidDivideWidth;
+  }
+
+  getLineWidth() {
+    return Settings.lineWidth;
+  }
+
+  setLineWidth(value) {
+    Settings.lineWidth = value;
+  }
+
   //如果position在屏幕左上角,返回的就朝向右下角,如果是右下角,则返回的是左上角。其他情况以此类推
   getNewPositionForPop(position) {
     const offset = 50;

+ 1 - 0
src/graphic/Settings.js

@@ -3,6 +3,7 @@ import VectorCategory from "./enum/VectorCategory";
 import { os } from "@/utils/vue.ts";
 
 const Settings = {
+  lineWidth: 1,
   roadLeftDrivewayCount: 1,
   roadRightDrivewayCount: 1,
   curveRoadLeftDrivewayCount: 1,