فهرست منبع

Merge branch 'master' of http://192.168.0.115:3000/bill/traffic-laser

xzw 2 سال پیش
والد
کامیت
f996fc1789

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 1
server/test/a0k4xu045_202305311600080410/attach/sceneStore


+ 1 - 0
src/graphic/CanvasStyle/default.js

@@ -226,6 +226,7 @@ export default {
   Magnifier,
   Font: CanvasFont,
   MeasureLine,
+  FreeMeasureLine: MeasureLine,
   PositionLine: MeasureLine,
   Measure,
   Element,

+ 1 - 0
src/graphic/CanvasStyle/focus.js

@@ -129,6 +129,7 @@ export default {
   CurveRoad,
   MeasureLine,
   TestPoint,
+  FreeMeasureLine: MeasureLine,
   Circle,
   CurveLine,
   RoadEdge,

+ 1 - 0
src/graphic/CanvasStyle/select.js

@@ -123,6 +123,7 @@ export default {
   CurveRoad,
   MeasureLine,
   BaseLine,
+  FreeMeasureLine: MeasureLine,
   CurveLine,
   Circle,
   RoadEdge,

+ 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();

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

@@ -86,10 +86,11 @@ export default class UIControl {
           this.layer.exit();
         }
 
+
         //执行新的事件
         if (uiService.isBelongRoad(selectUI) || selectUI == "road") {
           stateService.setEventName(LayerEvents.AddRoad);
-        } else if (selectUI == UIEvents.CurveRoad) {
+        }  else if (selectUI == UIEvents.CurveRoad) {
           stateService.setEventName(LayerEvents.AddCurveRoad);
         } else if (uiService.isBelongLine(selectUI)) {
           stateService.setEventName(LayerEvents.AddLine);
@@ -543,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);
@@ -556,11 +558,11 @@ export default class UIControl {
 
     uiService.setRoadMidDivideWidth(
       // (setting.roadQuarantineWidth / coordinate.res) * coordinate.ratio
-      (setting.roadQuarantineWidth / coordinate.res) 
+      (setting.roadQuarantineWidth / coordinate.res)
     );
     uiService.setCurveRoadMidDivideWidth(
       // (setting.roadQuarantineWidth / coordinate.res) * coordinate.ratio
-      (setting.roadQuarantineWidth / coordinate.res) 
+      (setting.roadQuarantineWidth / coordinate.res)
     );
     uiService.setSingleLaneWidth(
       // (setting.singleRoadWidth / coordinate.res) * coordinate.ratio

+ 11 - 7
src/graphic/Geometry/Text.js

@@ -1,20 +1,21 @@
-import VectorType from "../enum/VectorType.js";
-import Geometry from "./Geometry.js";
-import { mathUtil } from "../Util/MathUtil.js";
-import { coordinate } from "../Coordinate.js";
-import Constant from "../Constant.js";
-import Style from "@/graphic/CanvasStyle/index.js";
+import VectorType from '../enum/VectorType.js';
+import Geometry from './Geometry.js';
+import { mathUtil } from '../Util/MathUtil.js';
+import { coordinate } from '../Coordinate.js';
+import Constant from '../Constant.js';
+import Style from '@/graphic/CanvasStyle/index.js';
 
 //不靠墙
 export default class Text extends Geometry {
   constructor(center, vectorId) {
     super();
     this.center = center;
-    this.value = "文本";
+    this.value = '文本';
     this.angle = 0;
     this.color = Style.Text.fillStyle;
     this.fontSize = Style.Text.fontSize;
     this.geoType = VectorType.Text;
+    this.displayPoint = false;
     this.setId(vectorId);
   }
 
@@ -25,6 +26,9 @@ export default class Text extends Geometry {
   setAngle(angle) {
     this.angle = angle;
   }
+  setDisplayPoint(displayPoint) {
+    this.displayPoint = displayPoint;
+  }
 
   setValue(value) {
     this.value = value;

+ 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);
         }

+ 1 - 0
src/graphic/Load.js

@@ -254,6 +254,7 @@ export default class Load {
             );
             text.setValue(data3d.fixPoints[i].text);
             text.setAngle(angle);
+            text.setDisplayPoint (true);
           }
         }
       }

+ 12 - 9
src/graphic/Renderer/Draw.js

@@ -481,7 +481,7 @@ export default class Draw {
     ctx.stroke();
     ctx.restore();
 
-    console.log("lan:" , start.x, end.x)
+
     if (import.meta.env.DEV) {
       // this.drawPoint(lan.start);
       // this.drawPoint(lan.end);
@@ -676,14 +676,12 @@ export default class Draw {
           leftEdge.curves,
           rightEdge.curves
         ]);
-        console.log(edgeCurves[1])
         edgeCurves[1] = edgeCurves[1].reverse().map(curve => ({
           start: curve.end,
           end: curve.start,
           controls: curve.controls.reverse()
         }))
 
-        console.log(edgeCurves[1])
 
         ctx.beginPath();
         ctx.setLineDash([])
@@ -709,7 +707,6 @@ export default class Draw {
   drawCurveRoadEdge(vector, roadVector) {
     const [coves] = help.transformCoves([vector.curves]);
     const ctx = this.context;
-    console.log(coves)
     const [style, select] = help.getVectorStyle(roadVector)
     ctx.save();
     help.setVectorStyle(ctx, vector);
@@ -879,7 +876,6 @@ export default class Draw {
   }
 
   drawCircle(element) {
-    console.log(element)
     this.context.save()
     const geo = [element.center, element.points[1], {...element.center, x: 999}]
     let angle = mathUtil.Angle(...geo)
@@ -949,8 +945,14 @@ export default class Draw {
       ctx.fill();
       ctx.restore();
     };
-
-    if (Settings.selectBasePointId === vector.vectorId) {
+    let points = dataService.vectorData.points;
+    for (let key in points) {
+      if (points[key].category == VectorCategory.Point.BasePoint) {
+        Settings.selectBasePointId = points[key].vectorId;
+      }
+    }
+    let focusItem = stateService.getFocusItem()
+    if (Settings.selectBasePointId === vector.vectorId && focusItem?.vectorId == vector.vectorId ) {
       style = {
         ...style,
         strokeStyle: "rgba(255,255,255,1)",
@@ -1020,7 +1022,7 @@ export default class Draw {
     }px Microsoft YaHei`;
     const bound = help.getTextCenter(this.context, vector.value)
 
-    console.log(vector)
+    // console.log(vector)
     const screen = coordinate.getScreenXY(vector.center)
     this.drawTextByInfo(
       // vector.center,
@@ -1035,7 +1037,8 @@ export default class Draw {
     );
 
     this.context.restore();
-    this.drawPoint({...vector.center, color: vector.color}, true)
+
+    vector.displayPoint && this.drawPoint({...vector.center, color: vector.color}, true)
   }
 
   drawSVG(vector) {

+ 3 - 0
src/graphic/Service/DataService.js

@@ -134,6 +134,9 @@ export class DataService {
 
   deleteLine(lineId) {
     let line = this.getLine(lineId);
+    if(!line){
+      return
+    }
     let start = this.getPoint(line.startId);
     if (start) {
       let startParent = start.getParent();

+ 19 - 14
src/graphic/Service/UIService.js

@@ -1,15 +1,15 @@
-import Text from "../Geometry/Text.js";
-import { dataService } from "./DataService.js";
-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";
-import VectorStyle from "../enum/VectorStyle.js";
-import VectorWeight from "../enum/VectorWeight.js";
-import RoadTemplate from "../enum/RoadTemplate.js";
-import RoadStructure from "../enum/RoadStructure.js";
+import Text from '../Geometry/Text.js';
+import { dataService } from './DataService.js';
+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';
+import VectorStyle from '../enum/VectorStyle.js';
+import VectorWeight from '../enum/VectorWeight.js';
+import RoadTemplate from '../enum/RoadTemplate.js';
+import RoadStructure from '../enum/RoadStructure.js';
 
 export default class UIService {
   constructor() {}
@@ -56,7 +56,7 @@ export default class UIService {
   }
 
   isBelongCurveRoad(ui) {
-    if (ui == "SBend") {
+    if (ui == 'SBend') {
       this.setRoadLeftDrivewayCount(0);
       this.setRoadRightDrivewayCount(0);
       return true;
@@ -77,8 +77,13 @@ export default class UIService {
     } else if (ui == UIEvents.MeasureLine) {
       this.setSelectLineCategory(VectorCategory.Line.MeasureLine);
       return true;
-    } else if (ui == UIEvents.Line || ui == UIEvents.FreeMeasureLine) {
+    } 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);

+ 1 - 1
src/views/graphic/index.vue

@@ -1,5 +1,5 @@
 <template>
-  <MainPanel :menus="store.menus as any" :active-menu-key="store.activeMenuKey.value">
+  <MainPanel :menus="graphicState.continuedMode ? null : store.menus as any" :active-menu-key="store.activeMenuKey.value">
     <template v-slot:header>
       <Header />
     </template>