Browse Source

自由测量无限

jinx 2 years ago
parent
commit
4149820f38

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


+ 1 - 0
src/graphic/Constant.js

@@ -39,5 +39,6 @@ const Constant = {
   angleLocationMode: "AngleLocationMode", //直角定位
   allLocationMode: "AllLocationMode", //综合定位
   normalLocationMode: "NormalLocationMode", //自由测量
+  freeLocationMode: "FreeLocationMode", //自由测量
 };
 export default Constant;

+ 36 - 33
src/graphic/Controls/AddLine.js

@@ -1,16 +1,17 @@
-import { dataService } from "../Service/DataService";
-import { lineService } from "../Service/LineService";
-import { listenLayer } from "../ListenLayer";
-import VectorCategory from "../enum/VectorCategory";
-import Point from "../Geometry/Point.js";
-import { mathUtil } from "../Util/MathUtil";
-import Settings from "../Settings";
-import { pointService } from "../Service/PointService";
-
+import { dataService } from '../Service/DataService';
+import { lineService } from '../Service/LineService';
+import { listenLayer } from '../ListenLayer';
+import VectorCategory from '../enum/VectorCategory';
+import Point from '../Geometry/Point.js';
+import { mathUtil } from '../Util/MathUtil';
+import Settings from '../Settings';
+import { pointService } from '../Service/PointService';
+import Constant from '../Constant';
 export default class AddLine {
   constructor() {
     this.newLine = null;
     this.startInfo = {};
+    this.testLineIds = []; //所有待测点
   }
 
   setPointInfo(pointInfo) {
@@ -34,19 +35,25 @@ export default class AddLine {
   }
 
   buildLine(position) {
-    if (
-      this.newLine == null &&
-      !mathUtil.equalPoint(this.startInfo.position, position)
-    ) {
+    // if (Settings.selectLineCategory == VectorCategory.Line.NormalLine) {
+    if (this.newLine == null && !mathUtil.equalPoint(this.startInfo.position, position)) {
       this.newLine = lineService.create(this.startInfo.position, position);
+      if (Settings.selectLineCategory == VectorCategory.Line.FreeMeasureLine) {
+        this.testLineIds.push(this.newLine.vectorId);
+        this.newLine.setLocationMode(Constant.freeLocationMode);
+      }
     }
+    // } else {
+    //   console.error(this.startInfo.position, position);
+    //   if (Settings.selectLineCategory == Constant.freeLocationMode) {
+    //     this.newLine = lineService.create(this.startInfo.position, position);
+    //     this.newLine.setLocationMode(Constant.freeLocationMode);
+    //   }
+    // }
   }
 
   updateLine(position) {
-    if (
-      this.newLine != null &&
-      !mathUtil.equalPoint(this.startInfo.position, position)
-    ) {
+    if (this.newLine != null && !mathUtil.equalPoint(this.startInfo.position, position)) {
       let point = dataService.getPoint(this.newLine.endId);
       point.setPosition(position);
     }
@@ -63,10 +70,7 @@ export default class AddLine {
         this.newLine.getCategory() != VectorCategory.Line.DoubleArrowLine &&
         this.newLine.getCategory() != VectorCategory.Line.GuideLine
       ) {
-        pointService.mergePoint(
-          this.newLine.endId,
-          listenLayer.modifyPoint.linkedPointId
-        );
+        pointService.mergePoint(this.newLine.endId, listenLayer.modifyPoint.linkedPointId);
       }
       if (this.newLine.getCategory() == VectorCategory.Line.BaseLine) {
         Settings.baseLineId = this.newLine.vectorId;
@@ -75,22 +79,13 @@ export default class AddLine {
   }
 
   buildCurveLine(position) {
-    if (
-      this.newLine == null &&
-      !mathUtil.equalPoint(this.startInfo.position, position)
-    ) {
-      this.newLine = lineService.createCurveLine(
-        this.startInfo.position,
-        position
-      );
+    if (this.newLine == null && !mathUtil.equalPoint(this.startInfo.position, position)) {
+      this.newLine = lineService.createCurveLine(this.startInfo.position, position);
     }
   }
 
   updateCurveLine(position) {
-    if (
-      this.newLine != null &&
-      !mathUtil.equalPoint(this.startInfo.position, position)
-    ) {
+    if (this.newLine != null && !mathUtil.equalPoint(this.startInfo.position, position)) {
       let curvePoint = dataService.getCurvePoint(this.newLine.endId);
       curvePoint.setPosition(position);
     }
@@ -113,6 +108,14 @@ export default class AddLine {
     this.newLine = null;
     this.startInfo = {};
   }
+
+  deleteTestLines() {
+    for (let i = 0; i < this.testLineIds.length; ++i) {
+      console.log(this.testLineIds[i]);
+      dataService.deleteLine(this.testLineIds[i]);
+    }
+    this.testLineIds = [];
+  }
 }
 
 const addLine = new AddLine();

+ 1 - 0
src/graphic/Controls/UIControl.js

@@ -544,6 +544,7 @@ export default class UIControl {
     console.log("取消");
     this.graphicStateUI.continuedMode = false;
     addPoint.deleteTestPoints();
+    addLine.deleteTestLines();
     this.layer.exit();
     uiService.setSelectLineCategory(VectorCategory.Line.NormalLine);
     uiService.setSelectPointCategory(VectorCategory.Point.NormalPoint);

+ 13 - 3
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) {
@@ -877,12 +878,17 @@ export default class Layer {
         }
         break;
       case LayerEvents.AddingLine:
+        if (Settings.selectLocationMode == Constant.freeLocationMode) {
+          this.uiControl.showConfirm();
+        }
+
         needAutoRedraw = true;
         addLine.finish(position);
         this.updateForLocation();
         addLine.clearVectorData();
         this.history.save();
         elementService.hideAll();
+
         break;
       case LayerEvents.AddingCurveLine:
         needAutoRedraw = true;
@@ -1235,9 +1241,13 @@ export default class Layer {
         }
       } else if (eventName == LayerEvents.AddingLine) {
         if (Settings.isMobile) {
-          stateService.clearEventName();
-          this.exit();
-          uiService.setSelectLineCategory(VectorCategory.Line.NormalLine);
+          if (Settings.selectLocationMode == Constant.freeLocationMode) {
+            stateService.setEventName(LayerEvents.AddLine);
+          } else {
+            stateService.clearEventName();
+            this.exit();
+            uiService.setSelectLineCategory(VectorCategory.Line.NormalLine);
+          }
         } else {
           stateService.setEventName(LayerEvents.AddLine);
         }

+ 0 - 1
src/graphic/Renderer/Draw.js

@@ -1166,7 +1166,6 @@ export default class Draw {
     help.drawStyleLine(this.context, [start, end], vector.style, vector.weight)
 
 
-    console.log(vector)
     switch (vector.category) {
       case VectorCategory.Line.SingleArrowLine:
         this.drawArrow(vector);

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

@@ -79,9 +79,11 @@ export default class UIService {
       return true;
     } else if (ui == UIEvents.Line) {
       this.setSelectLineCategory(VectorCategory.Line.NormalLine);
+      this.setSelectLocationMode(Constant.null);
       return true;
     } else if (ui == UIEvents.FreeMeasureLine) {
       this.setSelectLineCategory(VectorCategory.Line.FreeMeasureLine);
+      this.setSelectLocationMode(Constant.freeLocationMode);
       return true;
     } else if (ui == UIEvents.BaseLine) {
       this.setSelectLineCategory(VectorCategory.Line.BaseLine);