jinx il y a 2 ans
Parent
commit
6dcb1cfa0b

Fichier diff supprimé car celui-ci est trop grand
+ 1 - 1
server/test/a0k4xu045_202305311600080410/attach/sceneStore


+ 5 - 0
src/graphic/Controls/AddPoint.js

@@ -51,6 +51,7 @@ export default class AddPoint {
         newPoint.getCategory() == VectorCategory.Point.TestPoint
       ) {
         this.testPointIds.push(newPoint.vectorId);
+        console.error(this.testPointIds)
       }
     }
     listenLayer.clear();
@@ -156,6 +157,10 @@ export default class AddPoint {
     }
     this.testPointIds = [];
   }
+
+  resetTestPoints(){
+    this.testPointIds = [];
+  }
 }
 
 const addPoint = new AddPoint();

+ 58 - 71
src/graphic/Controls/UIControl.js

@@ -1,37 +1,37 @@
-import { coordinate } from "../Coordinate.js";
-import LayerEvents from "../enum/LayerEvents.js";
-import UIEvents from "../enum/UIEvents.js";
-import RoadTemplate from "../enum/RoadTemplate.js";
-import RoadStructure from "../enum/RoadStructure.js";
-import VectorType from "../enum/VectorType.js";
-import VectorStyle from "../enum/VectorStyle.js";
-import VectorWeight from "../enum/VectorWeight.js";
-import GeoActions from "../enum/GeoActions.js";
-import VectorEvents from "../enum/VectorEvents.js";
-import SVGType from "../enum/SVGType.js";
-import { stateService } from "../Service/StateService.js";
-import { uiService } from "../Service/UIService.js";
-import { dataService } from "../Service/DataService.js";
-import { historyService } from "../Service/HistoryService.js";
-import { elementService } from "../Service/ElementService";
-import { lineService } from "../Service/LineService.js";
-import { circleService } from "../Service/CircleService.js";
-import { textService } from "../Service/TextService.js";
-import { magnifierService } from "../Service/MagnifierService.js";
-import { mathUtil } from "../Util/MathUtil";
-import Constant from "../Constant";
+import { coordinate } from '../Coordinate.js';
+import LayerEvents from '../enum/LayerEvents.js';
+import UIEvents from '../enum/UIEvents.js';
+import RoadTemplate from '../enum/RoadTemplate.js';
+import RoadStructure from '../enum/RoadStructure.js';
+import VectorType from '../enum/VectorType.js';
+import VectorStyle from '../enum/VectorStyle.js';
+import VectorWeight from '../enum/VectorWeight.js';
+import GeoActions from '../enum/GeoActions.js';
+import VectorEvents from '../enum/VectorEvents.js';
+import SVGType from '../enum/SVGType.js';
+import { stateService } from '../Service/StateService.js';
+import { uiService } from '../Service/UIService.js';
+import { dataService } from '../Service/DataService.js';
+import { historyService } from '../Service/HistoryService.js';
+import { elementService } from '../Service/ElementService';
+import { lineService } from '../Service/LineService.js';
+import { circleService } from '../Service/CircleService.js';
+import { textService } from '../Service/TextService.js';
+import { magnifierService } from '../Service/MagnifierService.js';
+import { mathUtil } from '../Util/MathUtil';
+import Constant from '../Constant';
 // import { roomsUtil } from "../Room/RoomsUtil.js";
-import { addRoad } from "../Controls/AddRoad";
-import { addLine } from "./AddLine.js";
-import VectorCategory from "../enum/VectorCategory.js";
+import { addRoad } from '../Controls/AddRoad';
+import { addLine } from './AddLine.js';
+import VectorCategory from '../enum/VectorCategory.js';
 // import { floorplanData } from "../VectorData.js";
-import Message from "@/components/base/components/message/message.vue";
-import { pointService } from "../Service/PointService.js";
-import Settings from "../Settings.js";
-import { addPoint } from "./AddPoint.js";
-import { curveRoadPointService } from "../Service/CurveRoadPointService.js";
-import { roadService } from "../Service/RoadService.js";
-import { curveRoadService } from "../Service/CurveRoadService.js";
+import Message from '@/components/base/components/message/message.vue';
+import { pointService } from '../Service/PointService.js';
+import Settings from '../Settings.js';
+import { addPoint } from './AddPoint.js';
+import { curveRoadPointService } from '../Service/CurveRoadPointService.js';
+import { roadService } from '../Service/RoadService.js';
+import { curveRoadService } from '../Service/CurveRoadService.js';
 
 export default class UIControl {
   constructor(layer, newsletter, graphicStateUI) {
@@ -87,7 +87,7 @@ export default class UIControl {
         }
 
         //执行新的事件
-        if (uiService.isBelongRoad(selectUI) || selectUI == "road") {
+        if (uiService.isBelongRoad(selectUI) || selectUI == 'road') {
           stateService.setEventName(LayerEvents.AddRoad);
         } else if (selectUI == UIEvents.CurveRoad) {
           stateService.setEventName(LayerEvents.AddCurveRoad);
@@ -118,7 +118,7 @@ export default class UIControl {
   }
 
   updateVectorForSelectUI(selectUI) {
-    console.log("selectUI", selectUI);
+    console.log('selectUI', selectUI);
     const focusItem = stateService.getFocusItem();
 
     // if (selectUI == VectorStyle.Bold || selectUI == VectorStyle.Thinning) {
@@ -141,9 +141,9 @@ export default class UIControl {
     if (uiService.isBelongRoadEdgeStyle(selectUI)) {
       let key = null;
       if (VectorStyle[selectUI]) {
-        key = "setStyle";
+        key = 'setStyle';
       } else if (VectorWeight[selectUI]) {
-        key = "setWeight";
+        key = 'setWeight';
       }
       console.log(key);
 
@@ -330,6 +330,7 @@ export default class UIControl {
         break;
       case VectorType.Line:
         let line = dataService.getLine(vectorId);
+
         dataService.deleteLine(vectorId);
         if (vectorId == Settings.baseLineId) {
           this.layer.initLocation();
@@ -339,8 +340,14 @@ export default class UIControl {
           line.getCategory() == VectorCategory.Line.PositionLine ||
           line.getCategory() == VectorCategory.Line.GuidePositionLine
         ) {
-          pointService.deletePoint(line.startId);
-          pointService.deletePoint(line.endId);
+          let startPoint = dataService.getPoint(line.startId);
+          let endPoint = dataService.getPoint(line.endId);
+          if (startPoint.getCategory() != VectorCategory.Point.BasePoint) {
+            pointService.deletePoint(line.startId);
+          }
+          if (endPoint.getCategory() != VectorCategory.Point.BasePoint) {
+            pointService.deletePoint(line.endId);
+          }
         }
         break;
       case VectorType.CurveLine:
@@ -420,18 +427,18 @@ export default class UIControl {
   }
 
   getCadBlob(canvas) {
-    var type = "jpg";
+    var type = 'jpg';
     return new Promise((resolve) => canvas.toBlob(resolve, `${type}/image`));
   }
 
   downloadCadImg(canvas, filename) {
     // 图片导出为 jpg 格式
-    var type = "jpg";
+    var type = 'jpg';
     var imgData = canvas.toDataURL(type, 3);
     canvas.toBlob(`${type}/image`);
 
     // 加工image data,替换mime type
-    imgData = imgData.replace(this._fixType(type), "image/octet-stream");
+    imgData = imgData.replace(this._fixType(type), 'image/octet-stream');
     // 下载后的图片名
     //var filename = 'cad_' + new Date().getTime() + '.' + type
     // download
@@ -439,38 +446,19 @@ export default class UIControl {
   }
 
   saveFile(data, filename) {
-    var save_link = document.createElementNS(
-      "http://www.w3.org/1999/xhtml",
-      "a"
-    );
+    var save_link = document.createElementNS('http://www.w3.org/1999/xhtml', 'a');
     save_link.href = data;
     save_link.download = filename;
 
-    var event = document.createEvent("MouseEvents");
-    event.initMouseEvent(
-      "click",
-      true,
-      false,
-      window,
-      0,
-      0,
-      0,
-      0,
-      0,
-      false,
-      false,
-      false,
-      false,
-      0,
-      null
-    );
+    var event = document.createEvent('MouseEvents');
+    event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
     save_link.dispatchEvent(event);
   }
 
   _fixType(type) {
-    type = type.toLowerCase().replace(/jpg/i, "jpeg");
+    type = type.toLowerCase().replace(/jpg/i, 'jpeg');
     var r = type.match(/png|jpeg|bmp|gif/)[0];
-    return "image/" + r;
+    return 'image/' + r;
   }
   /****************************************************************************针对菜单*******************************************************************************/
 
@@ -529,9 +517,7 @@ export default class UIControl {
   /******************************************************************************************************************************************************************/
 
   prompt(msg) {
-    this._prompts.push(
-      Message.success(typeof msg === "string" ? { msg } : msg)
-    );
+    this._prompts.push(Message.success(typeof msg === 'string' ? { msg } : msg));
   }
 
   // 进入持续添加出确认与取消框
@@ -539,16 +525,17 @@ export default class UIControl {
     this.graphicStateUI.continuedMode = true;
   }
   confirmEntry() {
-    console.log("确认");
+    console.log('确认');
     this.graphicStateUI.continuedMode = false;
     this.layer.exit();
     uiService.setSelectLineCategory(VectorCategory.Line.NormalLine);
     uiService.setSelectPointCategory(VectorCategory.Point.NormalPoint);
+    addPoint.resetTestPoints(); //重置testPoints数组
     this.layer.history.save();
     this.layer.renderer.autoRedraw();
   }
   confirmCancel() {
-    console.log("取消");
+    console.log('取消');
     this.graphicStateUI.continuedMode = false;
     addPoint.deleteTestPoints();
     addLine.deleteTestLines();
@@ -561,7 +548,7 @@ export default class UIControl {
 
   // 设置默认设置
   setDefaultSetting(setting) {
-    console.log("获得设置", setting);
+    console.log('获得设置', setting);
 
     uiService.setRoadMidDivideWidth(
       // (setting.roadQuarantineWidth / coordinate.res) * coordinate.ratio

+ 2 - 2
src/graphic/Service/DataService.js

@@ -138,7 +138,7 @@ export class DataService {
       return
     }
     let start = this.getPoint(line.startId);
-    if (start) {
+    if (start  && start.getCategory()!= VectorCategory.Point.BasePoint) {
       let startParent = start.getParent();
       delete startParent[lineId];
       if (
@@ -153,6 +153,7 @@ export class DataService {
     if (end) {
       let endParent = end.getParent();
       delete endParent[lineId];
+      
       if (
         Object.keys(endParent).length == 0 &&
         end.getCategory() != VectorCategory.Point.BasePoint
@@ -160,7 +161,6 @@ export class DataService {
         this.deletePoint(line.endId);
       }
     }
-
     delete this.vectorData.lines[lineId];
   }