Browse Source

修复bug,主要是撤销恢复

xushiting 2 years ago
parent
commit
1f3a3d65ab

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


+ 93 - 38
src/graphic/Geometry/Magnifier.js

@@ -36,48 +36,103 @@ export default class Magnifier extends Geometry {
     if (mathUtil.equalPoint(position, coordinate.center)) {
     if (mathUtil.equalPoint(position, coordinate.center)) {
       mathUtil.clonePoint(this.popPosition, this.position);
       mathUtil.clonePoint(this.popPosition, this.position);
     } else {
     } else {
-      let line = mathUtil.createLine1(position, coordinate.center);
-      let vLine = mathUtil.getVerticalLine(line, position);
-      let parallelLines = mathUtil.getParallelLineForDistance(
-        vLine,
-        (distance * coordinate.zoom) / coordinate.defaultZoom
-      );
-      let join1 = mathUtil.getJoinLinePoint(
-        coordinate.center,
-        parallelLines.line1
-      );
-      let join2 = mathUtil.getJoinLinePoint(
-        coordinate.center,
-        parallelLines.line2
-      );
+      // let line = mathUtil.createLine1(position, coordinate.center);
+      // let vLine = mathUtil.getVerticalLine(line, position);
+      // let parallelLines = mathUtil.getParallelLineForDistance(
+      //   vLine,
+      //   (distance * coordinate.zoom) / coordinate.defaultZoom
+      // );
+      // let join1 = mathUtil.getJoinLinePoint(
+      //   coordinate.center,
+      //   parallelLines.line1
+      // );
+      // let join2 = mathUtil.getJoinLinePoint(
+      //   coordinate.center,
+      //   parallelLines.line2
+      // );
 
 
-      if (
-        mathUtil.getDistance(join1, coordinate.center) <
-        mathUtil.getDistance(join2, coordinate.center)
-      ) {
-        //this.popPosition = coordinate.getXYFromScreen(join1);
-        this.popPosition = {
-          x: join1.x,
-          y: join1.y,
-        };
-      } else if (
-        mathUtil.getDistance(join2, coordinate.center) <
-        mathUtil.getDistance(join1, coordinate.center)
-      ) {
-        //this.popPosition = coordinate.getXYFromScreen(join2);
-        this.popPosition = {
-          x: join2.x,
-          y: join2.y,
-        };
-      }
+      // if (
+      //   mathUtil.getDistance(join1, coordinate.center) <
+      //   mathUtil.getDistance(join2, coordinate.center)
+      // ) {
+      //   //this.popPosition = coordinate.getXYFromScreen(join1);
+      //   this.popPosition = {
+      //     x: join1.x,
+      //     y: join1.y,
+      //   };
+      // } else if (
+      //   mathUtil.getDistance(join2, coordinate.center) <
+      //   mathUtil.getDistance(join1, coordinate.center)
+      // ) {
+      //   //this.popPosition = coordinate.getXYFromScreen(join2);
+      //   this.popPosition = {
+      //     x: join2.x,
+      //     y: join2.y,
+      //   };
+      // }
+      this.setPopPosition();
     }
     }
   }
   }
 
 
-  setPopPosition(value) {
-    if (value) {
-      this.popPosition = {};
-      this.popPosition.x = value.x;
-      this.popPosition.y = value.y;
+  // setPopPosition() {
+  //   let line = mathUtil.createLine1(this.position, coordinate.center);
+  //   let vLine = mathUtil.getVerticalLine(line, this.position);
+  //   let parallelLines = mathUtil.getParallelLineForDistance(
+  //     vLine,
+  //     (distance * coordinate.zoom) / coordinate.defaultZoom
+  //   );
+  //   let join1 = mathUtil.getJoinLinePoint(
+  //     coordinate.center,
+  //     parallelLines.line1
+  //   );
+  //   let join2 = mathUtil.getJoinLinePoint(
+  //     coordinate.center,
+  //     parallelLines.line2
+  //   );
+
+  //   if (
+  //     mathUtil.getDistance(join1, coordinate.center) <
+  //     mathUtil.getDistance(join2, coordinate.center)
+  //   ) {
+  //     //this.popPosition = coordinate.getXYFromScreen(join1);
+  //     this.popPosition = {
+  //       x: join1.x,
+  //       y: join1.y,
+  //     };
+  //   } else if (
+  //     mathUtil.getDistance(join2, coordinate.center) <
+  //     mathUtil.getDistance(join1, coordinate.center)
+  //   ) {
+  //     //this.popPosition = coordinate.getXYFromScreen(join2);
+  //     this.popPosition = {
+  //       x: join2.x,
+  //       y: join2.y,
+  //     };
+  //   }
+  // }
+  setPopPosition() {
+    const position = coordinate.getScreenXY(this.position);
+    const center = coordinate.getScreenXY(coordinate.center);
+    let line = mathUtil.createLine1(position, center);
+    let vLine = mathUtil.getVerticalLine(line, position);
+    let parallelLines = mathUtil.getParallelLineForDistance(vLine, distance);
+    let join1 = mathUtil.getIntersectionPoint(line, parallelLines.line1);
+    let join2 = mathUtil.getIntersectionPoint(line, parallelLines.line2);
+
+    if (
+      mathUtil.getDistance(join1, center) < mathUtil.getDistance(join2, center)
+    ) {
+      this.popPosition = {
+        x: join1.x,
+        y: join1.y,
+      };
+    } else if (
+      mathUtil.getDistance(join2, center) < mathUtil.getDistance(join1, center)
+    ) {
+      this.popPosition = {
+        x: join2.x,
+        y: join2.y,
+      };
     }
     }
   }
   }
 
 

+ 19 - 1
src/graphic/History/Change.js

@@ -4,6 +4,7 @@ import { historyUtil } from "./HistoryUtil";
 import HistoryEvents from "../enum/HistoryEvents";
 import HistoryEvents from "../enum/HistoryEvents";
 import { coordinate } from "../Coordinate";
 import { coordinate } from "../Coordinate";
 import { mathUtil } from "../Util/MathUtil";
 import { mathUtil } from "../Util/MathUtil";
+import Settings from "../Settings";
 
 
 export default class Change {
 export default class Change {
   constructor() {
   constructor() {
@@ -54,6 +55,8 @@ export default class Change {
     this.lastData.crossPoints = JSON.parse(
     this.lastData.crossPoints = JSON.parse(
       JSON.stringify(dataService.getCrossPoints())
       JSON.stringify(dataService.getCrossPoints())
     );
     );
+
+    this.lastData.settings = JSON.parse(JSON.stringify(Settings));
   }
   }
 
 
   operate() {
   operate() {
@@ -75,6 +78,7 @@ export default class Change {
     this.compareCurveRoadEdges();
     this.compareCurveRoadEdges();
     this.compareCurveRoads();
     this.compareCurveRoads();
     this.compareCrossPoints();
     this.compareCrossPoints();
+    this.compareSettings();
     if (
     if (
       this.currentData.points.length == 0 &&
       this.currentData.points.length == 0 &&
       this.currentData.lines.length == 0 &&
       this.currentData.lines.length == 0 &&
@@ -89,7 +93,8 @@ export default class Change {
       this.currentData.curveRoadPoints.length == 0 &&
       this.currentData.curveRoadPoints.length == 0 &&
       this.currentData.curveRoadEdges.length == 0 &&
       this.currentData.curveRoadEdges.length == 0 &&
       this.currentData.curveRoads.length == 0 &&
       this.currentData.curveRoads.length == 0 &&
-      this.currentData.crossPoints.length == 0
+      this.currentData.crossPoints.length == 0 &&
+      this.currentData.settings
     ) {
     ) {
       this.saveCurrentInfo();
       this.saveCurrentInfo();
       return false;
       return false;
@@ -725,6 +730,19 @@ export default class Change {
       this.currentData.crossPoints.push(item);
       this.currentData.crossPoints.push(item);
     }
     }
   }
   }
+
+  compareSettings() {
+    const lastSettings = this.lastData.settings;
+    this.currentData.settings = null;
+    if (historyUtil.isDifferentForSettings(Settings, lastSettings)) {
+      const item = {
+        handle: HistoryEvents.ModifySettings,
+        preSettings: historyUtil.getDataForSettings(lastSettings),
+        curSettings: historyUtil.getDataForSettings(Settings),
+      };
+      this.currentData.settings = item;
+    }
+  }
 }
 }
 
 
 const change = new Change();
 const change = new Change();

+ 29 - 2
src/graphic/History/History.js

@@ -18,6 +18,7 @@ import { curveRoadPointService } from "../Service/CurveRoadPointService";
 import { curveEdgeService } from "../Service/CurveEdgeService";
 import { curveEdgeService } from "../Service/CurveEdgeService";
 import { curveRoadService } from "../Service/CurveRoadService";
 import { curveRoadService } from "../Service/CurveRoadService";
 import { curvePointService } from "../Service/CurvePointService";
 import { curvePointService } from "../Service/CurvePointService";
+import Settings from "../Settings";
 
 
 export default class History {
 export default class History {
   constructor(layer) {
   constructor(layer) {
@@ -95,6 +96,7 @@ export default class History {
 
 
   // 撤销
   // 撤销
   goPreState() {
   goPreState() {
+    this.layer.exit();
     const item = historyService.getHistoryRecord();
     const item = historyService.getHistoryRecord();
     if (item) {
     if (item) {
       stateService.clear();
       stateService.clear();
@@ -114,6 +116,7 @@ export default class History {
       this.goPreForCurveRoadEdges(item.curveRoadEdges);
       this.goPreForCurveRoadEdges(item.curveRoadEdges);
       this.goPreForCurveRoads(item.curveRoads);
       this.goPreForCurveRoads(item.curveRoads);
       this.goPreForCrossPoints(item.crossPoints);
       this.goPreForCrossPoints(item.crossPoints);
+      this.goPreForSettings(item.settings);
       historyService.undoHistoryRecord();
       historyService.undoHistoryRecord();
       change.saveCurrentInfo();
       change.saveCurrentInfo();
       this.setState();
       this.setState();
@@ -129,7 +132,7 @@ export default class History {
         dataService.deletePoint(item.point.id);
         dataService.deletePoint(item.point.id);
       } else if (item.handle == HistoryEvents.DeletePoint) {
       } else if (item.handle == HistoryEvents.DeletePoint) {
         let point = pointService.create(item.point, item.point.id);
         let point = pointService.create(item.point, item.point.id);
-        point.setCategory(item.category);
+        point.setCategory(item.point.category);
         point.parent = JSON.parse(JSON.stringify(item.point.parent));
         point.parent = JSON.parse(JSON.stringify(item.point.parent));
       } else if (item.handle == HistoryEvents.ModifyPoint) {
       } else if (item.handle == HistoryEvents.ModifyPoint) {
         const prePoint = item.prePoint;
         const prePoint = item.prePoint;
@@ -455,12 +458,23 @@ export default class History {
     }
     }
   }
   }
 
 
+  goPreForSettings(itemForSettings) {
+    if (
+      itemForSettings &&
+      itemForSettings.handle == HistoryEvents.ModifySettings
+    ) {
+      const preSettings = itemForSettings.preSettings;
+      historyUtil.assignSettingsFromSettings(Settings, preSettings);
+      this.layer.updateForLocation();
+    }
+  }
+
   goNextForPoints(itemForPoints) {
   goNextForPoints(itemForPoints) {
     for (let i = 0; i < itemForPoints.length; ++i) {
     for (let i = 0; i < itemForPoints.length; ++i) {
       const item = itemForPoints[i];
       const item = itemForPoints[i];
       if (item.handle == HistoryEvents.AddPoint) {
       if (item.handle == HistoryEvents.AddPoint) {
         let newPoint = pointService.create(item.point, item.point.id);
         let newPoint = pointService.create(item.point, item.point.id);
-        newPoint.setCategory(item.category);
+        newPoint.setCategory(item.point.category);
         historyUtil.assignPointFromPoint(newPoint, item.point);
         historyUtil.assignPointFromPoint(newPoint, item.point);
       } else if (item.handle == HistoryEvents.DeletePoint) {
       } else if (item.handle == HistoryEvents.DeletePoint) {
         dataService.deletePoint(item.point.id);
         dataService.deletePoint(item.point.id);
@@ -783,8 +797,20 @@ export default class History {
     }
     }
   }
   }
 
 
+  goNextForSettings(itemForSettings) {
+    if (
+      itemForSettings &&
+      itemForSettings.handle == HistoryEvents.ModifySettings
+    ) {
+      const currentSettings = itemForSettings.curSettings;
+      historyUtil.assignSettingsFromSettings(Settings, currentSettings);
+      this.layer.updateForLocation();
+    }
+  }
+
   // 恢复
   // 恢复
   goNextState() {
   goNextState() {
+    this.layer.exit();
     historyService.redoHistoryRecord();
     historyService.redoHistoryRecord();
     const item = historyService.getHistoryRecord();
     const item = historyService.getHistoryRecord();
     if (item) {
     if (item) {
@@ -805,6 +831,7 @@ export default class History {
       this.goNextForCurveRoadEdges(item.curveRoadEdges);
       this.goNextForCurveRoadEdges(item.curveRoadEdges);
       this.goNextForCurveRoads(item.curveRoads);
       this.goNextForCurveRoads(item.curveRoads);
       this.goNextForCrossPoints(item.crossPoints);
       this.goNextForCrossPoints(item.crossPoints);
+      this.goNextForSettings(item.settings);
       change.saveCurrentInfo();
       change.saveCurrentInfo();
       this.setState();
       this.setState();
     } else {
     } else {

+ 33 - 0
src/graphic/History/HistoryUtil.js

@@ -2,6 +2,7 @@ import { mathUtil } from "../Util/MathUtil";
 import { dataService } from "../Service/DataService";
 import { dataService } from "../Service/DataService";
 import { textService } from "../Service/TextService";
 import { textService } from "../Service/TextService";
 import Constant from "../Constant";
 import Constant from "../Constant";
+import Settings from "../Settings";
 
 
 export default class HistoryUtil {
 export default class HistoryUtil {
   constructor() {}
   constructor() {}
@@ -244,6 +245,20 @@ export default class HistoryUtil {
     }
     }
   }
   }
 
 
+  isDifferentForSettings(settings1, settings2) {
+    if (
+      settings1.lineCategory == settings2.lineCategory &&
+      settings1.pointCategory == settings2.pointCategory &&
+      settings1.locationMode == settings2.locationMode &&
+      settings1.baseLineId == settings2.baseLineId &&
+      settings1.selectBasePointId == settings2.selectBasePointId
+    ) {
+      return false;
+    } else {
+      return true;
+    }
+  }
+
   assignPointFromPoint(point1, point2) {
   assignPointFromPoint(point1, point2) {
     const pointInfo = {};
     const pointInfo = {};
     pointInfo.vectorId = point1.vectorId;
     pointInfo.vectorId = point1.vectorId;
@@ -465,6 +480,14 @@ export default class HistoryUtil {
     this.setCrossPointInfo(crossPointInfo);
     this.setCrossPointInfo(crossPointInfo);
   }
   }
 
 
+  assignSettingsFromSettings(settings1, settings2) {
+    settings1.lineCategory = settings2.lineCategory;
+    settings1.pointCategory = settings2.pointCategory;
+    settings1.locationMode = settings2.locationMode;
+    settings1.baseLineId = settings2.baseLineId;
+    settings1.selectBasePointId = settings2.selectBasePointId;
+  }
+
   getDataForPoint(point) {
   getDataForPoint(point) {
     const data = {};
     const data = {};
     data.id = point.vectorId;
     data.id = point.vectorId;
@@ -671,6 +694,16 @@ export default class HistoryUtil {
     return data;
     return data;
   }
   }
 
 
+  getDataForSettings(settings) {
+    const data = {};
+    data.lineCategory = settings.lineCategory;
+    data.pointCategory = settings.pointCategory;
+    data.locationMode = settings.locationMode;
+    data.baseLineId = settings.baseLineId;
+    data.selectBasePointId = settings.selectBasePointId;
+    return data;
+  }
+
   setPointInfo(pointInfo) {
   setPointInfo(pointInfo) {
     let point = dataService.getPoint(pointInfo.vectorId);
     let point = dataService.getPoint(pointInfo.vectorId);
     mathUtil.clonePoint(point, pointInfo.position);
     mathUtil.clonePoint(point, pointInfo.position);

+ 6 - 0
src/graphic/Layer.js

@@ -1245,6 +1245,8 @@ export default class Layer {
   exit() {
   exit() {
     stateService.clear();
     stateService.clear();
     this.uiControl.clearUI();
     this.uiControl.clearUI();
+    this.uiControl.focusVector = null;
+    this.uiControl.currentUI = null;
   }
   }
 
 
   stopAddVector() {
   stopAddVector() {
@@ -1278,6 +1280,10 @@ export default class Layer {
       this.uiControl.graphicStateUI.canAngleLocationMode = true;
       this.uiControl.graphicStateUI.canAngleLocationMode = true;
       this.uiControl.graphicStateUI.canAllLocationMode = true;
       this.uiControl.graphicStateUI.canAllLocationMode = true;
       this.uiControl.graphicStateUI.existsBaseLine = true;
       this.uiControl.graphicStateUI.existsBaseLine = true;
+    } else {
+      this.uiControl.graphicStateUI.canAngleLocationMode = false;
+      this.uiControl.graphicStateUI.canAllLocationMode = false;
+      this.uiControl.graphicStateUI.existsBaseLine = false;
     }
     }
   }
   }
 }
 }

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

@@ -538,7 +538,12 @@ export default class Draw {
       radius: Style.Magnifier.radius,
       radius: Style.Magnifier.radius,
     });
     });
     const pt = coordinate.getScreenXY(vector.position);
     const pt = coordinate.getScreenXY(vector.position);
-    const target = coordinate.getScreenXY(vector.popPosition);
+    vector.setPopPosition();
+    //const target = coordinate.getScreenXY(vector.popPosition);
+    const target = {
+      x: vector.popPosition.x,
+      y: vector.popPosition.y,
+    };
     const [style] = help.setVectorStyle(ctx, vector);
     const [style] = help.setVectorStyle(ctx, vector);
     const radius = help.getReal(vector.radius || style.radius);
     const radius = help.getReal(vector.radius || style.radius);
     const offset = radius / 2;
     const offset = radius / 2;
@@ -719,7 +724,9 @@ export default class Draw {
       this.context,
       this.context,
       coordinate.getScreenXY(startReal),
       coordinate.getScreenXY(startReal),
       coordinate.getScreenXY(endReal),
       coordinate.getScreenXY(endReal),
-      (vector.value ? (Math.round(vector.value * 100) / 100) : help.getRealDistance(startReal, endReal)) + "m",
+      (vector.value
+        ? Math.round(vector.value * 100) / 100
+        : help.getRealDistance(startReal, endReal)) + "m",
       style
       style
     );
     );
   }
   }

+ 2 - 0
src/graphic/enum/HistoryEvents.js

@@ -58,5 +58,7 @@ const HistoryEvents = {
   AddCurveRoad: "addCurveRoad",
   AddCurveRoad: "addCurveRoad",
   DeleteCurveRoad: "deleteCurveRoad",
   DeleteCurveRoad: "deleteCurveRoad",
   ModifyCurveRoad: "modifyCurveRoad",
   ModifyCurveRoad: "modifyCurveRoad",
+
+  ModifySettings: "modifySettings",
 };
 };
 export default HistoryEvents;
 export default HistoryEvents;