xushiting 2 years ago
parent
commit
844e2cbd4c

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

@@ -49,6 +49,7 @@ export default class AddPoint {
       }
       if (
         newPoint &&
+        newPoint.getLocationMode() == Constant.allLocationMode &&
         newPoint.getCategory() == VectorCategory.Point.TestPoint
       ) {
         this.testPointIds.push(newPoint.vectorId);

+ 15 - 0
src/graphic/Controls/MovePoint.js

@@ -18,6 +18,21 @@ export default class MovePoint {
       this.updatePositionByTestPoint(pointId);
     } else if (point.getCategory() == VectorCategory.Point.BasePoint) {
       this.updateBasePoint(pointId);
+    } else {
+      let parent = point.getParent();
+      for (let key in parent) {
+        let line = dataService.getLine(key);
+        //拖拽的点是基准线
+        if (line.category == VectorCategory.Line.BaseLine) {
+          let points = dataService.getPoints();
+          for (let key in points) {
+            let testPoint = dataService.getPoint(key);
+            if (testPoint.category == VectorCategory.Point.TestPoint) {
+              this.updatePositionByTestPoint(key);
+            }
+          }
+        }
+      }
     }
   }
 

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

@@ -21,6 +21,7 @@ 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";
 
 export default class UIControl {
   constructor(layer, newsletter, graphicStateUI) {
@@ -129,6 +130,10 @@ export default class UIControl {
         break;
       case VectorType.Line:
         dataService.deleteLine(vectorId);
+        if (vectorId == Settings.baseLineId) {
+          this.layer.initLocation();
+          Settings.baseLineId = null;
+        }
         break;
       case VectorType.Circle:
         dataService.deleteCircle(vectorId);
@@ -273,7 +278,12 @@ export default class UIControl {
 
   menu_clear() {
     dataService.clear();
+    Settings.locationMode = null;
+    Settings.baseLineId = null;
+    Settings.selectBasePointId = null;
     elementService.hideAll();
+    this.layer.exit();
+    this.layer.initLocation();
     this.layer.history.save();
     this.layer.renderer.autoRedraw();
   }

+ 23 - 7
src/graphic/Layer.js

@@ -37,6 +37,7 @@ import { roadPointService } from "./Service/RoadPointService";
 import { curveRoadService } from "./Service/CurveRoadService";
 import VectorCategory from "./enum/VectorCategory";
 import Settings from "./Settings";
+import { uiService } from "./Service/UIService";
 
 const minDragDis = 10;
 const minZoom = 20;
@@ -231,8 +232,8 @@ export default class Layer {
       }
     }
 
-    let dx = (X - this.lastX) * coordinate.ratio;
-    let dy = (Y - this.lastY) * coordinate.ratio;
+    let dx = X - this.lastX;
+    let dy = Y - this.lastY;
 
     let position = coordinate.getXYFromScreen({
       x: X,
@@ -1082,15 +1083,28 @@ export default class Layer {
       }
     } else if (eventType == "mouseUp") {
       if (eventName == LayerEvents.AddingRoad) {
-        stateService.setEventName(LayerEvents.AddRoad);
+        if (Settings.isMobile) {
+          stateService.clearEventName();
+          this.exit();
+        } else {
+          stateService.setEventName(LayerEvents.AddRoad);
+        }
       } else if (eventName == LayerEvents.AddingLine) {
-        stateService.setEventName(LayerEvents.AddLine);
+        if (Settings.isMobile) {
+          stateService.clearEventName();
+          this.exit();
+        } else {
+          stateService.setEventName(LayerEvents.AddLine);
+        }
       } else if (eventName == LayerEvents.AddingCurveRoad) {
-        stateService.setEventName(LayerEvents.AddCurveRoad);
+        if (Settings.isMobile) {
+          stateService.clearEventName();
+          this.exit();
+        } else {
+          stateService.setEventName(LayerEvents.AddCurveRoad);
+        }
       } else if (eventName == LayerEvents.AddLine) {
         stateService.setEventName(LayerEvents.AddingLine);
-      } else if (eventName == LayerEvents.AddingLine) {
-        stateService.setEventName(LayerEvents.AddLine);
       } else {
         stateService.clearEventName();
       }
@@ -1101,6 +1115,8 @@ export default class Layer {
     stateService.clear();
     this.uiControl.clearUI();
     this.uiControl.focusVector = null;
+    uiService.setPointCategory(VectorCategory.Point.NormalPoint);
+    uiService.setLineCategory(VectorCategory.Line.NormalLine);
   }
 
   stopAddVector() {

+ 135 - 135
src/graphic/Load.js

@@ -19,141 +19,141 @@ export default class Load {
 
   async load(dataLocal, data3d) {
     this.layer.initLocation();
-    // if (dataLocal) {
-    //   if (dataLocal.backgroundImg) {
-    //     let bgImg = imageService.create(
-    //       dataLocal.backgroundImg.src,
-    //       dataLocal.backgroundImg.vectorId
-    //     );
-    //     bgImg.setCenter(dataLocal.backgroundImg.center);
-    //     bgImg.setDisplay(dataLocal.backgroundImg.display);
-    //     bgImg.setAngle(dataLocal.backgroundImg.angle);
-    //     try {
-    //       if (dataLocal.backgroundImg.src) {
-    //         await bgImg.setImageData();
-    //       }
-    //     } catch (e) {}
-    //   }
-    //   if (dataLocal.circles) {
-    //     for (let key in dataLocal.circles) {
-    //       let circle = circleService.create(
-    //         dataLocal.circles[key].center,
-    //         dataLocal.circles[key].radius,
-    //         key
-    //       );
-    //       circle.setPoints(dataLocal.circles[key].points);
-    //       circle.setColor(dataLocal.circles[key].color);
-    //       circle.setDisplay(dataLocal.circles[key].display);
-    //     }
-    //   }
-    //   if (dataLocal.magnifiers) {
-    //     for (let key in dataLocal.magnifiers) {
-    //       let magnifier = magnifierService.create(
-    //         dataLocal.magnifiers[key].position,
-    //         key
-    //       );
-    //       magnifier.setSrc(dataLocal.magnifiers[key].photoUrl);
-    //       magnifier.setDisplay(dataLocal.magnifiers[key].display);
-    //       try {
-    //         if (dataLocal.magnifiers[key].photoUrl) {
-    //           await magnifier.setImageData();
-    //         }
-    //       } catch (e) {}
-    //     }
-    //   }
-    //   if (dataLocal.texts) {
-    //     for (let key in dataLocal.texts) {
-    //       let text = textService.create(dataLocal.texts[key].center, key);
-    //       text.setValue(dataLocal.texts[key].value);
-    //       text.setFontSize(dataLocal.texts[key].fontSize);
-    //       text.setColor(dataLocal.texts[key].color);
-    //       text.setDisplay(dataLocal.texts[key].display);
-    //     }
-    //   }
-    //   if (dataLocal.points) {
-    //     for (let key in dataLocal.points) {
-    //       let point = pointService.create(dataLocal.points[key], key);
-    //       point.setCategory(dataLocal.points[key].category);
-    //       point.setParent(
-    //         JSON.parse(JSON.stringify(dataLocal.points[key].parent))
-    //       );
-    //       point.setDisplay(dataLocal.points[key].display);
-    //     }
-    //   }
-    //   if (dataLocal.lines) {
-    //     for (let key in dataLocal.lines) {
-    //       let line = lineService.createByPointId(
-    //         dataLocal.lines[key].startId,
-    //         dataLocal.lines[key].endId,
-    //         dataLocal.lines[key].category,
-    //         key
-    //       );
-    //       if (dataLocal.lines[key].arrowColor) {
-    //         line.setArrowColor(dataLocal.lines[key].arrowColor);
-    //       }
-    //       line.setDisplay(dataLocal.lines[key].display);
-    //       if (line.getCategory() == VectorCategory.Line.BaseLine) {
-    //         Settings.baseLineId = key;
-    //       }
-    //     }
-    //   }
-    //   if (dataLocal.hasOwnProperty("currentId")) {
-    //     dataService.setCurrentId(dataLocal.currentId);
-    //   }
-    // }
-    // if (data3d) {
-    //   if (data3d.backImage) {
-    //     let bgImg = imageService.create(data3d.backImage, data3d.vectorId);
-    //     bgImg.setCenter(coordinate.center);
-    //     try {
-    //       if (bgImg.src) {
-    //         await bgImg.setImageData();
-    //       }
-    //     } catch (e) {}
-    //     if (data3d.meterPerPixel) {
-    //       const width = bgImg.imageData.width;
-    //       const height = bgImg.imageData.height;
-    //       coordinate.setRes(data3d.meterPerPixel);
-    //       if (data3d.baseLines) {
-    //         for (let i = 0; i < data3d.baseLines.length; ++i) {
-    //           //理论上基准线只能有一条
-    //           let baseLine = lineService.create(
-    //             this.getXY(width, height, data3d.baseLines[i][0]),
-    //             this.getXY(width, height, data3d.baseLines[i][1]),
-    //             VectorCategory.Line.BaseLine
-    //           );
-    //           Settings.baseLineId = baseLine.vectorId;
-    //         }
-    //       }
-    //       if (data3d.measures) {
-    //         for (let i = 0; i < data3d.measures.length; ++i) {
-    //           //理论上基准线只能有一条
-    //           lineService.create(
-    //             this.getXY(width, height, data3d.measures[i][0]),
-    //             this.getXY(width, height, data3d.measures[i][1]),
-    //             VectorCategory.Line.MeasureLine
-    //           );
-    //         }
-    //       }
-    //       if (data3d.basePoints) {
-    //         for (let i = 0; i < data3d.basePoints.length; ++i) {
-    //           let point = pointService.create(
-    //             this.getXY(width, height, data3d.basePoints[i])
-    //           );
-    //           point.setCategory(VectorCategory.Point.BasePoint);
-    //         }
-    //       }
-    //       if (data3d.fixPoints) {
-    //         for (let i = 0; i < data3d.fixPoints.length; ++i) {
-    //           let point = pointService.create(
-    //             this.getXY(width, height, data3d.fixPoints[i])
-    //           );
-    //           point.setCategory(VectorCategory.Point.FixPoint);
-    //         }
-    //       }
-    //     }
-    //   }
-    // }
+    if (dataLocal) {
+      if (dataLocal.backgroundImg) {
+        let bgImg = imageService.create(
+          dataLocal.backgroundImg.src,
+          dataLocal.backgroundImg.vectorId
+        );
+        bgImg.setCenter(dataLocal.backgroundImg.center);
+        bgImg.setDisplay(dataLocal.backgroundImg.display);
+        bgImg.setAngle(dataLocal.backgroundImg.angle);
+        try {
+          if (dataLocal.backgroundImg.src) {
+            await bgImg.setImageData();
+          }
+        } catch (e) {}
+      }
+      if (dataLocal.circles) {
+        for (let key in dataLocal.circles) {
+          let circle = circleService.create(
+            dataLocal.circles[key].center,
+            dataLocal.circles[key].radius,
+            key
+          );
+          circle.setPoints(dataLocal.circles[key].points);
+          circle.setColor(dataLocal.circles[key].color);
+          circle.setDisplay(dataLocal.circles[key].display);
+        }
+      }
+      if (dataLocal.magnifiers) {
+        for (let key in dataLocal.magnifiers) {
+          let magnifier = magnifierService.create(
+            dataLocal.magnifiers[key].position,
+            key
+          );
+          magnifier.setSrc(dataLocal.magnifiers[key].photoUrl);
+          magnifier.setDisplay(dataLocal.magnifiers[key].display);
+          try {
+            if (dataLocal.magnifiers[key].photoUrl) {
+              await magnifier.setImageData();
+            }
+          } catch (e) {}
+        }
+      }
+      if (dataLocal.texts) {
+        for (let key in dataLocal.texts) {
+          let text = textService.create(dataLocal.texts[key].center, key);
+          text.setValue(dataLocal.texts[key].value);
+          text.setFontSize(dataLocal.texts[key].fontSize);
+          text.setColor(dataLocal.texts[key].color);
+          text.setDisplay(dataLocal.texts[key].display);
+        }
+      }
+      if (dataLocal.points) {
+        for (let key in dataLocal.points) {
+          let point = pointService.create(dataLocal.points[key], key);
+          point.setCategory(dataLocal.points[key].category);
+          point.setParent(
+            JSON.parse(JSON.stringify(dataLocal.points[key].parent))
+          );
+          point.setDisplay(dataLocal.points[key].display);
+        }
+      }
+      if (dataLocal.lines) {
+        for (let key in dataLocal.lines) {
+          let line = lineService.createByPointId(
+            dataLocal.lines[key].startId,
+            dataLocal.lines[key].endId,
+            dataLocal.lines[key].category,
+            key
+          );
+          if (dataLocal.lines[key].arrowColor) {
+            line.setArrowColor(dataLocal.lines[key].arrowColor);
+          }
+          line.setDisplay(dataLocal.lines[key].display);
+          if (line.getCategory() == VectorCategory.Line.BaseLine) {
+            Settings.baseLineId = key;
+          }
+        }
+      }
+      if (dataLocal.hasOwnProperty("currentId")) {
+        dataService.setCurrentId(dataLocal.currentId);
+      }
+    }
+    if (data3d) {
+      if (data3d.backImage) {
+        let bgImg = imageService.create(data3d.backImage, data3d.vectorId);
+        bgImg.setCenter(coordinate.center);
+        try {
+          if (bgImg.src) {
+            await bgImg.setImageData();
+          }
+        } catch (e) {}
+        if (data3d.meterPerPixel) {
+          const width = bgImg.imageData.width;
+          const height = bgImg.imageData.height;
+          coordinate.setRes(data3d.meterPerPixel);
+          if (data3d.baseLines) {
+            for (let i = 0; i < data3d.baseLines.length; ++i) {
+              //理论上基准线只能有一条
+              let baseLine = lineService.create(
+                this.getXY(width, height, data3d.baseLines[i][0]),
+                this.getXY(width, height, data3d.baseLines[i][1]),
+                VectorCategory.Line.BaseLine
+              );
+              Settings.baseLineId = baseLine.vectorId;
+            }
+          }
+          if (data3d.measures) {
+            for (let i = 0; i < data3d.measures.length; ++i) {
+              //理论上基准线只能有一条
+              lineService.create(
+                this.getXY(width, height, data3d.measures[i][0]),
+                this.getXY(width, height, data3d.measures[i][1]),
+                VectorCategory.Line.MeasureLine
+              );
+            }
+          }
+          if (data3d.basePoints) {
+            for (let i = 0; i < data3d.basePoints.length; ++i) {
+              let point = pointService.create(
+                this.getXY(width, height, data3d.basePoints[i])
+              );
+              point.setCategory(VectorCategory.Point.BasePoint);
+            }
+          }
+          if (data3d.fixPoints) {
+            for (let i = 0; i < data3d.fixPoints.length; ++i) {
+              let point = pointService.create(
+                this.getXY(width, height, data3d.fixPoints[i])
+              );
+              point.setCategory(VectorCategory.Point.FixPoint);
+            }
+          }
+        }
+      }
+    }
     if (Settings.baseLineId) {
       this.layer.updateForLocation();
     }

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

@@ -4,6 +4,7 @@ import { elementService } from "../Service/ElementService.js";
 import { coordinate } from "../Coordinate.js";
 import { draw } from "./Draw.js";
 import { listenLayer } from "../ListenLayer.js";
+import Settings from "../Settings.js";
 
 export default class Render {
   constructor(layer) {

+ 2 - 2
src/graphic/Settings.js

@@ -19,9 +19,9 @@ const Settings = {
   wayType: Constant.twoWay, //one表示单向,two表示双向
   lineCategory: VectorCategory.Line.NormalLine,
   pointCategory: VectorCategory.Point.NormalPoint,
-  locationMode: Constant.angleLocationMode,
+  locationMode: null,
   baseLineId: null, //基准线id,有且只有一条
   selectBasePointId: null, //选中的基准点
-  isMobile: false,
+  isMobile: true,
 };
 export default Settings;