xushiting 2 vuotta sitten
vanhempi
commit
7586591a85

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

@@ -105,7 +105,6 @@ export default class UIControl {
 
 
     this.layer.stopAddVector();
     this.layer.stopAddVector();
     this.layer.renderer.autoRedraw();
     this.layer.renderer.autoRedraw();
-    this.layer.revokeHistory();
   }
   }
 
 
   //恢复
   //恢复
@@ -118,7 +117,6 @@ export default class UIControl {
 
 
     this.layer.stopAddVector();
     this.layer.stopAddVector();
     this.layer.renderer.autoRedraw();
     this.layer.renderer.autoRedraw();
-    this.layer.recoveryHistory();
   }
   }
 
 
   // value 为true则开 false则关
   // value 为true则开 false则关

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

@@ -35,7 +35,7 @@ export default class Change {
     this.compareLines();
     this.compareLines();
     this.compareCircles();
     this.compareCircles();
     this.compareTexts();
     this.compareTexts();
-
+    this.compareSVGs();
     if (
     if (
       this.currentData.points.length == 0 &&
       this.currentData.points.length == 0 &&
       this.currentData.lines.length == 0 &&
       this.currentData.lines.length == 0 &&

+ 3 - 5
src/graphic/History/History.js

@@ -28,11 +28,9 @@ export default class History {
     historyService.addHistoryRecord(change.currentData);
     historyService.addHistoryRecord(change.currentData);
     change.saveCurrentInfo();
     change.saveCurrentInfo();
     this.setState();
     this.setState();
-    // const historyState = historyService.getHistoryState();
-    // const points = dataService.getRoadPoints();
-    // //给UI发送事件
-    // this.layer.emit("change");
-    // return change.currentData;
+    const historyState = historyService.getHistoryState();
+    this.layer.uiControl.graphicStateUI.canRevoke = historyState.pre;
+    this.layer.uiControl.graphicStateUI.canRecovery = historyState.next;
   }
   }
 
 
   setState() {
   setState() {

+ 0 - 11
src/graphic/Layer.js

@@ -58,7 +58,6 @@ export default class Layer {
       this.canvas.height = this.canvas.clientHeight;
       this.canvas.height = this.canvas.clientHeight;
       coordinate.init(this.canvas);
       coordinate.init(this.canvas);
       draw.initContext(this.canvas);
       draw.initContext(this.canvas);
-      dataService.initVectorData();
       this.history.init();
       this.history.init();
       this.bindEvents();
       this.bindEvents();
     }
     }
@@ -1031,14 +1030,4 @@ export default class Layer {
     this.uiControl.clearUI();
     this.uiControl.clearUI();
     elementService.hideAll();
     elementService.hideAll();
   }
   }
-
-  revokeHistory() {
-    this.history.goPreState();
-    this.renderer.autoRedraw();
-  }
-
-  recoveryHistory() {
-    this.history.goNextState();
-    this.renderer.autoRedraw();
-  }
 }
 }

+ 1 - 0
src/graphic/Load.js

@@ -13,6 +13,7 @@ export default class Load {
   }
   }
 
 
   load(dataLocal, data3d) {
   load(dataLocal, data3d) {
+    dataService.initVectorData();
     if (dataLocal) {
     if (dataLocal) {
       dataService.vectorData = JSON.parse(JSON.stringify(dataLocal));
       dataService.vectorData = JSON.parse(JSON.stringify(dataLocal));
     }
     }

+ 9 - 40
src/graphic/Service/DataService.js

@@ -54,7 +54,7 @@ export class DataService {
     //基准点
     //基准点
     this.vectorData.basePointIds = [];
     this.vectorData.basePointIds = [];
     this.vectorData.texts = {};
     this.vectorData.texts = {};
-    this.vectorData.SVGs = {};
+    this.vectorData.svgs = {};
     this.vectorData.magnifiers = {};
     this.vectorData.magnifiers = {};
   }
   }
 
 
@@ -133,41 +133,10 @@ export class DataService {
     this.vectorData.points[point.vectorId] = point;
     this.vectorData.points[point.vectorId] = point;
   }
   }
 
 
-  // deletePoint(pointId) {
-  //   delete this.vectorData.points[pointId];
-  // }
-
-  deletePoint(pointId, lineId) {
-    let point = this.getPoint(pointId);
-    //有可能先删除墙,导致点没了
-    if (point) {
-      if (Object.keys(point.parent).length == 0) {
-        point = null;
-        delete this.vectorData.points[pointId];
-      } else if (Object.keys(point.parent).length == 1 && !lineId) {
-        delete this.vectorData.points[pointId];
-      } else if (
-        Object.keys(point.parent).length == 1 &&
-        point.parent[lineId]
-      ) {
-        delete this.vectorData.points[pointId];
-      } else if (
-        Object.keys(point.parent).length == 1 &&
-        !point.parent[lineId]
-      ) {
-        return;
-      } else {
-        delete point.parent[lineId];
-      }
-    }
-  }
-
   deletePoint(pointId) {
   deletePoint(pointId) {
-    const point = dataService.getRoadPoint(pointId);
-    const parent = point.parent;
-    for (const key in parent) {
-      dataService.deleteRoadPoint(pointId, key);
-    }
+    let point = this.getPoint(pointId);
+    delete this.vectorData.points[pointId];
+    point = null;
   }
   }
 
 
   //圆圈
   //圆圈
@@ -489,19 +458,19 @@ export class DataService {
 
 
   //处理从svg转换来的图标
   //处理从svg转换来的图标
   addSVG(SVG) {
   addSVG(SVG) {
-    this.vectorData.SVGs[SVG.vectorId] = SVG;
+    this.vectorData.svgs[SVG.vectorId] = SVG;
   }
   }
 
 
   getSVG(SVGId) {
   getSVG(SVGId) {
-    return this.vectorData.SVGs[SVGId];
+    return this.vectorData.svgs[SVGId];
   }
   }
 
 
   deleteSVG(SVGId) {
   deleteSVG(SVGId) {
-    delete this.vectorData.SVGs[SVGId];
+    delete this.vectorData.svgs[SVGId];
   }
   }
 
 
   getSVGs() {
   getSVGs() {
-    return this.vectorData.SVGs;
+    return this.vectorData.svgs;
   }
   }
 
 
   clear() {
   clear() {
@@ -525,7 +494,7 @@ export class DataService {
     //基准点
     //基准点
     this.vectorData.basePointIds = [];
     this.vectorData.basePointIds = [];
     this.vectorData.texts = {};
     this.vectorData.texts = {};
-    this.vectorData.SVGs = {};
+    this.vectorData.svgs = {};
     this.vectorData.magnifiers = {};
     this.vectorData.magnifiers = {};
   }
   }
 }
 }