xushiting 2 vuotta sitten
vanhempi
commit
0663d2736b

+ 4 - 0
src/graphic/Geometry/Line.js

@@ -24,6 +24,10 @@ export default class Line extends Geometry {
     this.category = value;
   }
 
+  getCategory() {
+    return this.category;
+  }
+
   setArrowColor(value) {
     this.arrowColor = value;
   }

+ 4 - 0
src/graphic/Geometry/Point.js

@@ -20,6 +20,10 @@ export default class Point extends Geometry {
     this.y = position.y;
   }
 
+  getCategory() {
+    return this.category;
+  }
+
   //基准点:BasePoint
   setCategory(value) {
     if (!value) {

+ 46 - 2
src/graphic/Load.js

@@ -1,4 +1,8 @@
 import { dataService } from "./Service/DataService.js";
+import { lineService } from "./Service/LineService.js";
+import { pointService } from "./Service/PointService.js";
+import { imageService } from "./Service/ImageService.js";
+import VectorCategory from "./enum/VectorCategory.js";
 
 export default class Load {
   constructor(layer) {
@@ -12,6 +16,47 @@ export default class Load {
     if (dataLocal) {
       dataService.vectorData = JSON.parse(JSON.stringify(dataLocal));
     }
+    if (data3d) {
+      if (data3d.backImage) {
+        imageService.create(data3d.backImage);
+      }
+      if (data3d.baseLines) {
+        for (let i = 0; i < data3d.baseLines.length; ++i) {
+          //理论上基准线只能有一条
+          lineService.create(
+            data3d.baseLines[i][0],
+            data3d.baseLines[i][1],
+            VectorCategory.Line.BaseLine
+          );
+        }
+      }
+      if (data3d.measures) {
+        for (let i = 0; i < data3d.measures.length; ++i) {
+          //理论上基准线只能有一条
+          lineService.create(
+            data3d.measures[i][0],
+            data3d.measures[i][1],
+            VectorCategory.Line.MeasureLine
+          );
+        }
+      }
+      if (data3d.basePoints) {
+        for (let i = 0; i < data3d.basePoints.length; ++i) {
+          pointService.create(
+            data3d.basePoints[i],
+            VectorCategory.Point.BasePoint
+          );
+        }
+      }
+      if (data3d.fixPoints) {
+        for (let i = 0; i < data3d.fixPoints.length; ++i) {
+          pointService.create(
+            data3d.fixPoints[i],
+            VectorCategory.Point.FixPoint
+          );
+        }
+      }
+    }
   }
 
   save() {
@@ -20,7 +65,6 @@ export default class Load {
 
   // 退出页面清除缓存及其他操作
   clear() {
-    console.warn('clear')
-
+    console.warn("clear");
   }
 }

+ 4 - 4
src/graphic/Service/ImageService.js

@@ -5,10 +5,10 @@ import { mathUtil } from "../Util/MathUtil";
 export default class ImageService {
   constructor() {}
 
-  create(position, vectorId) {
-    let point = new Img(position, vectorId);
-    dataService.addRoadPoint(point);
-    return point;
+  create(src, vectorId) {
+    let img = new Img(src, vectorId);
+    dataService.addBackgroundImg(img);
+    return img;
   }
 }
 

+ 22 - 6
src/graphic/Service/StateService.js

@@ -1,5 +1,7 @@
 import VectorType from "../enum/VectorType.js";
 import SelectState from "../enum/SelectState.js";
+import VectorCategory from "../enum/VectorCategory.js";
+import { dataService } from "./DataService.js";
 
 export default class StateService {
   constructor() {
@@ -27,12 +29,12 @@ export default class StateService {
     this.selectItem.vectorId = vectorId;
     this.selectItem.type = type;
 
-    if (type == VectorType.Text) {
-      if (state == SelectState.Select) {
-        this.selectItem.selectIndex = SelectState.Select;
-      } else {
-        this.selectItem.selectIndex = state;
-      }
+    if (type == VectorType.Line) {
+      const line = dataService.getLine(vectorId);
+      this.selectItem.category = line.getCategory();
+    } else if (type == VectorType.Point) {
+      const point = dataService.getPoint(vectorId);
+      this.selectItem.category = point.getCategory();
     }
   }
 
@@ -50,6 +52,13 @@ export default class StateService {
 
   setDraggingItem(draggingItem) {
     this.draggingItem = draggingItem;
+    if (this.draggingItem.type == VectorType.Line) {
+      const line = dataService.getLine(this.draggingItem.vectorId);
+      this.draggingItem.category = line.getCategory();
+    } else if (this.draggingItem.type == VectorType.Point) {
+      const point = dataService.getPoint(this.draggingItem.vectorId);
+      this.draggingItem.category = point.getCategory();
+    }
   }
 
   clearDraggingItem() {
@@ -62,6 +71,13 @@ export default class StateService {
 
   setFocusItem(focusItem) {
     this.focusItem = focusItem;
+    if (this.focusItem.type == VectorType.Line) {
+      const line = dataService.getLine(this.focusItem.vectorId);
+      this.focusItem.category = line.getCategory();
+    } else if (this.focusItem.type == VectorType.Point) {
+      const point = dataService.getPoint(this.focusItem.vectorId);
+      this.focusItem.category = point.getCategory();
+    }
   }
 
   clearFocusItem() {

+ 1 - 0
src/graphic/enum/VectorCategory.js

@@ -11,6 +11,7 @@ const VectorCategory = {
     TestPoint: "TestPoint", //待测点
     NormalPoint: "NormalPoint", //正常点
     TestBasePoint: "TestBasePoint", //待测基准点
+    FixPoint: "FixPoint", //固定点
   },
 };
 export default VectorCategory;