jinx 2 years ago
parent
commit
b7f0a6497c

File diff suppressed because it is too large
+ 1 - 1
server/test/a0k4xu045_202305311600080410/attach/sceneStore


+ 28 - 66
src/graphic/Controls/AddPoint.js

@@ -1,16 +1,16 @@
-import { dataService } from "../Service/DataService";
-import { lineService } from "../Service/LineService";
-import { pointService } from "../Service/PointService";
-import VectorCategory from "../enum/VectorCategory";
-import Point from "../Geometry/Point.js";
-import { mathUtil } from "../Util/MathUtil";
-import addLine from "./AddLine";
-import Settings from "../Settings";
-import { stateService } from "../Service/StateService";
-import LayerEvents from "../enum/LayerEvents";
-import VectorType from "../enum/VectorType";
-import Constant from "../Constant";
-import { listenLayer } from "../ListenLayer";
+import { dataService } from '../Service/DataService';
+import { lineService } from '../Service/LineService';
+import { pointService } from '../Service/PointService';
+import VectorCategory from '../enum/VectorCategory';
+import Point from '../Geometry/Point.js';
+import { mathUtil } from '../Util/MathUtil';
+import addLine from './AddLine';
+import Settings from '../Settings';
+import { stateService } from '../Service/StateService';
+import LayerEvents from '../enum/LayerEvents';
+import VectorType from '../enum/VectorType';
+import Constant from '../Constant';
+import { listenLayer } from '../ListenLayer';
 
 export default class AddPoint {
   constructor() {
@@ -18,48 +18,36 @@ export default class AddPoint {
   }
 
   buildPoint(position) {
+    if ((Settings.selectLocationMode == Constant.angleLocationMode || Settings.selectLocationMode == Constant.allLocationMode) && Settings.basePointIds.length == 1) {
+      Settings.selectBasePointId = Settings.basePointIds[0];
+    }
     let newPoint;
     if (Settings.selectPointCategory == VectorCategory.Point.BasePoint) {
       newPoint = pointService.create(position);
       Settings.selectBasePointId = newPoint.vectorId;
     } else {
-      if (
-        Settings.selectBasePointId != null &&
-        Settings.selectLocationMode == Constant.angleLocationMode
-      ) {
+      if (Settings.selectBasePointId != null && Settings.selectLocationMode == Constant.angleLocationMode) {
         newPoint = pointService.create(position);
         this.setLocationByAngle(newPoint.vectorId);
         newPoint.setLocationMode(Constant.angleLocationMode);
         stateService.setEventName(LayerEvents.AddPoint);
-      } else if (
-        Settings.selectBasePointId != null &&
-        Settings.selectLocationMode == Constant.allLocationMode
-      ) {
+      } else if (Settings.selectBasePointId != null && Settings.selectLocationMode == Constant.allLocationMode) {
         newPoint = pointService.create(position);
         this.setLocationByAll(newPoint.vectorId);
         newPoint.setLocationMode(Constant.allLocationMode);
         stateService.setEventName(LayerEvents.AddPoint);
-      } else if (
-        Settings.baseLineId != null &&
-        Settings.selectLocationMode == Constant.normalLocationMode
-      ) {
+      } else if (Settings.baseLineId != null && Settings.selectLocationMode == Constant.normalLocationMode) {
         newPoint = pointService.create(position);
         this.setLocationByNormal(newPoint.vectorId);
         newPoint.setLocationMode(Constant.normalLocationMode);
 
         stateService.setEventName(LayerEvents.AddPoint);
-      } else if (
-        Settings.selectBasePointId == null &&
-        (Settings.selectLocationMode == Constant.angleLocationMode ||
-          Settings.selectLocationMode == Constant.allLocationMode)
-      ) {
+      } else if (Settings.selectBasePointId == null && (Settings.selectLocationMode == Constant.angleLocationMode || Settings.selectLocationMode == Constant.allLocationMode)) {
         return null;
       }
       if (
         newPoint &&
-        (newPoint.getLocationMode() == Constant.allLocationMode ||
-          newPoint.getLocationMode() == Constant.angleLocationMode ||
-          newPoint.getLocationMode() == Constant.normalLocationMode) &&
+        (newPoint.getLocationMode() == Constant.allLocationMode || newPoint.getLocationMode() == Constant.angleLocationMode || newPoint.getLocationMode() == Constant.normalLocationMode) &&
         newPoint.getCategory() == VectorCategory.Point.TestPoint
       ) {
         this.testPointIds.push(newPoint.vectorId);
@@ -101,17 +89,9 @@ export default class AddPoint {
     join.setLocationMode(Constant.angleLocationMode);
     join.setLinkedBasePointId(basePoint.vectorId);
     join.setLinkedTestPointId(testPointId);
-    let guidePositionLine = lineService.createByPointId(
-      testPointId,
-      join.vectorId,
-      VectorCategory.Line.GuidePositionLine
-    );
+    let guidePositionLine = lineService.createByPointId(testPointId, join.vectorId, VectorCategory.Line.GuidePositionLine);
 
-    let positionLine = lineService.createByPointId(
-      basePoint.vectorId,
-      join.vectorId,
-      VectorCategory.Line.PositionLine
-    );
+    let positionLine = lineService.createByPointId(basePoint.vectorId, join.vectorId, VectorCategory.Line.PositionLine);
     guidePositionLine.setLocationMode(Constant.angleLocationMode);
     positionLine.setLocationMode(Constant.angleLocationMode);
     join.setCategory(VectorCategory.Point.TestBasePoint);
@@ -137,29 +117,15 @@ export default class AddPoint {
     join.setLinkedBasePointId(basePoint.vectorId);
     join.setLinkedTestPointId(testPointId);
     //待测点与基准线的垂直线
-    lineService.createByPointId(
-      testPointId,
-      join.vectorId,
-      VectorCategory.Line.PositionLine
-    );
+    lineService.createByPointId(testPointId, join.vectorId, VectorCategory.Line.PositionLine);
     //暂时没有其他待测点
     if (this.testPointIds.length == 0) {
       //待测点与基准线点的连线
-      lineService.createByPointId(
-        basePoint.vectorId,
-        testPointId,
-        VectorCategory.Line.PositionLine
-      );
+      lineService.createByPointId(basePoint.vectorId, testPointId, VectorCategory.Line.PositionLine);
     } else {
       //取上一个待测点
-      lineService.createByPointId(
-        this.testPointIds[this.testPointIds.length - 1],
-        testPointId,
-        VectorCategory.Line.PositionLine
-      );
-      testPoint.setLinkedTestPointId(
-        this.testPointIds[this.testPointIds.length - 1]
-      );
+      lineService.createByPointId(this.testPointIds[this.testPointIds.length - 1], testPointId, VectorCategory.Line.PositionLine);
+      testPoint.setLinkedTestPointId(this.testPointIds[this.testPointIds.length - 1]);
     }
   }
 
@@ -181,11 +147,7 @@ export default class AddPoint {
     join.setCategory(VectorCategory.Point.TestBasePoint);
     join.setLocationMode(Constant.normalLocationMode);
     join.setLinkedTestPointId(testPointId);
-    lineService.createByPointId(
-      testPointId,
-      join.vectorId,
-      VectorCategory.Line.PositionLine
-    );
+    lineService.createByPointId(testPointId, join.vectorId, VectorCategory.Line.PositionLine);
   }
 
   deleteTestPoints() {

+ 1 - 8
src/graphic/Layer.js

@@ -161,14 +161,7 @@ export default class Layer {
           this.history.save();
           this.renderer.autoRedraw();
         } else {
-          let points = dataService.vectorData.points;
-          let basePoints = []
-          for (let key in points) {
-            if (points[key].category == VectorCategory.Point.BasePoint) {
-              basePoints.push(points[key].vectorId)
-            }
-          }
-          if(basePoints.length==1){
+          if(Settings.basePointIds.length>1){
             this.uiControl.prompt({ msg: '请先选择基准点', time: 1000 });
           }else{
             this.uiControl.prompt({ msg: '请先添加基准点', time: 1000 });

+ 15 - 0
src/graphic/Load.js

@@ -79,6 +79,21 @@ export default class Load {
           );
           point.setDisplay(dataLocal.points[key].display);
         }
+    
+        // let points = dataService.vectorData.points;
+        let points = dataLocal.points;
+        Settings.basePointIds =[]
+        for (let key in points) {
+          if (points[key].category == VectorCategory.Point.BasePoint) {
+            Settings.basePointIds.push(points[key].vectorId)
+          }
+        }
+        // if(  Settings.basePointIds.length==1){
+        //   Settings.selectBasePointId =  Settings.basePointIds[0];
+        // }else{
+        //   // Settings.selectBasePointId =null
+        // }
+        console.error(Settings.basePointIds)
       }
       if (dataLocal.svgs) {
         for (let key in dataLocal.svgs) {

+ 14 - 13
src/graphic/Renderer/Draw.js

@@ -945,21 +945,22 @@ export default class Draw {
       ctx.fill();
       ctx.restore();
     };
-    let points = dataService.vectorData.points;
-    let basePoints = []
-    for (let key in points) {
-      if (points[key].category == VectorCategory.Point.BasePoint) {
-        basePoints.push(points[key].vectorId)
-      }
-    }
-    if(basePoints.length==1){
-      Settings.selectBasePointId = basePoints[0];
-    }else{
-      Settings.selectBasePointId =null
-    }
+    // let points = dataService.vectorData.points;
+    // Settings.basePointIds =[]
+    // for (let key in points) {
+    //   if (points[key].category == VectorCategory.Point.BasePoint) {
+    //     Settings.basePointIds.push(points[key].vectorId)
+    //   }
+    // }
+    // if(  Settings.basePointIds.length==1){
+    //   Settings.selectBasePointId =  Settings.basePointIds[0];
+    // }else{
+    //   // Settings.selectBasePointId =null
+    // }
     let focusItem = stateService.getFocusItem()
     // if (Settings.selectBasePointId === vector.vectorId && focusItem?.vectorId == vector.vectorId ) {
     if (Settings.selectBasePointId === vector.vectorId  ) {
+
       style = {
         ...style,
         strokeStyle: "rgba(255,255,255,1)",
@@ -1057,7 +1058,7 @@ export default class Draw {
     const dires = [points[0], { ...points[0], x: 10000 }, points[1]];
     let angle = mathUtil.Angle(...dires) * (Math.PI / 180);
     angle = mathUtil.isClockwise(dires) ? angle : -angle;
-
+    console.log(angle)
     this.context.save();
     this.context.translate(points[0].x, points[0].y);
     this.context.rotate(angle);

+ 1 - 0
src/graphic/Settings.js

@@ -30,6 +30,7 @@ const Settings = {
   selectSVGType: null, //图例
   selectRoadTemplate: null, //道路模板
   selectRoadStructure: null, //道路结构
+  basePointIds:[],//基准点
 };
 console.error(os.isPc);
 export default Settings;