xushiting vor 1 Jahr
Ursprung
Commit
f8a204d9c0

+ 22 - 1
src/view/case/draw/board/editCAD/History/Change.js

@@ -56,6 +56,9 @@ export default class Change {
     this.lastData.compass = JSON.parse(
       JSON.stringify(floorplanService.getCompass())
     );
+    this.lastData.customImages = JSON.parse(
+      JSON.stringify(floorplanService.getCustomImages())
+    );
   }
 
   operate() {
@@ -80,6 +83,7 @@ export default class Change {
     this.compareTitle();
     this.compareImage();
     this.compareCompass();
+    this.compareCustomImages();
     // }
     // //旋转了
     // else {
@@ -99,7 +103,8 @@ export default class Change {
       this.elements.icons.length == 0 &&
       this.elements.title == null &&
       this.elements.image == null &&
-      this.elements.compass == null
+      this.elements.compass == null && 
+      this.elements.customImage == null
     ) {
       this.saveCurrentInfo();
       return false;
@@ -586,6 +591,22 @@ export default class Change {
       this.elements.compass = item;
     }
   }
+
+  compareCustomImages(){
+    this.elements.customImage = null;
+    const customImage = floorplanService.getCustomImage();
+    const lastCustomImage = this.lastData.customImage;
+
+    const flag = historyUtil.isDifferentForCustomImage(customImage, lastCustomImage);
+    if (flag) {
+      const item = {
+        handle: HistoryEvents.ModifyCustomImage,
+        preCustomImage: historyUtil.getDataForCustomImage(lastCustomImage),
+        curCustomImage: historyUtil.getDataForCustomImage(customImage),
+      };
+      this.elements.customImage = item;
+    }
+  }
 }
 
 const change = new Change();

+ 26 - 37
src/view/case/draw/board/editCAD/History/History.js

@@ -14,6 +14,7 @@ import { rectangleService } from '../Service/RectangleService'
 import { circleService } from '../Service/CircleService'
 import { arrowService } from '../Service/ArrowService'
 import { iconService } from '../Service/IconService'
+import { customImageService } from "../Service/CustomImageService";
 import mitt from 'mitt'
 
 export default class History {
@@ -141,6 +142,7 @@ export default class History {
             this.goPreForTitle(item.title)
             this.goPreForImage (item.image)
             this.goPreForCompass(item.compass)
+            this.goPreForCustomImages(item.customImage)
 
             historyService.undoHistoryRecord()
             change.saveCurrentInfo()
@@ -344,25 +346,13 @@ export default class History {
         }
     }
 
-
-    // goPreForAngle(itemForAngle) {
-    //     if (itemForAngle.handle == HistoryEvents.ModifyAngle) {
-    //         coordinate.reSet()
-    //         coordinate._setRes(itemForAngle.preState.res)
-    //         //旋转cad
-    //         floorplanService.setAngle(itemForAngle.preState.angle)
-    //         coordinate.updateForRotate(itemForAngle.preState.angle - itemForAngle.curState.angle)
-    //         //旋转三维模型
-    //         let info = coordinate.getScreenInfoForCAD()
-    //         info.floorPlanAngle = itemForAngle.preState.angle
-    //         this.layer.app.core.get('CameraControls').emit('syncCadAnd3DForRotate', info)
-    //         this.layer.app.store.getValue('metadata').floorPlanAngle = itemForAngle.preState.angle
-    //         this.layer.initPanos(floorplanService.getCurrentFloor())
-    //         return true
-    //     } else {
-    //         return false
-    //     }
-    // }
+    goPreForCustomImage(itemForCustomImage) {
+        if (itemForCustomImage != null && itemForCustomImage.handle == HistoryEvents.ModifyCustomImage) {
+            const preCustomImage = itemForCustomImage.preCustomImage
+            let curCustomImage = floorplanService.getCustomImage()
+            historyUtil.assignCustomImageFromCustomImage(curCustomImage, preCustomImage)
+        }
+    }
 
     goNextForPoints(itemForPoints) {
         for (let i = 0; i < itemForPoints.length; ++i) {
@@ -549,24 +539,21 @@ export default class History {
         }
     }
 
-    // goNextForAngle(itemForAngle) {
-    //     if (itemForAngle.handle == HistoryEvents.ModifyAngle) {
-    //         coordinate.reSet()
-    //         coordinate._setRes(itemForAngle.curState.res)
-    //         //旋转cad
-    //         floorplanService.setAngle(itemForAngle.curState.angle)
-    //         coordinate.updateForRotate(itemForAngle.curState.angle - itemForAngle.preState.angle)
-    //         //旋转三维模型
-    //         let info = coordinate.getScreenInfoForCAD()
-    //         info.floorPlanAngle = itemForAngle.curState.angle
-    //         this.layer.app.core.get('CameraControls').emit('syncCadAnd3DForRotate', info)
-    //         this.layer.app.store.getValue('metadata').floorPlanAngle = itemForAngle.curState.angle
-    //         this.layer.initPanos(floorplanService.getCurrentFloor())
-    //         return true
-    //     } else {
-    //         return false
-    //     }
-    // }
+    goNextForCustomImage(itemForCustomImages) {
+        for (let i = 0; i < itemForCustomImages.length; ++i) {
+            const item = itemForCustomImages[i]
+            if (item.handle == HistoryEvents.AddCustomImage) {
+                let vCustomImage = customImageService.createCustomImage(item.customImage.center, item.customImage.vectorId)
+                historyUtil.assignCustomImageFromCustomImage(vCustomImage, item.customImage)
+            } else if (item.handle == HistoryEvents.DeleteCustomImage) {
+                floorplanService.deleteCustomImage(item.customImage.id)
+            } else if (item.handle == HistoryEvents.ModifyCustomImage) {
+                const currentCustomImage = item.curCustomImage
+                let preCustomImage = floorplanService.getCustomImage(item.curCustomImage.id)
+                historyUtil.assignCustomImageFromCustomImage(preCustomImage, currentCustomImage)
+            }
+        }
+    }
 
     // 恢复
     goNextState() {
@@ -597,6 +584,8 @@ export default class History {
                 this.goNextForTitle(item.title)
                 this.goNextForImage (item.image)
                 this.goNextForCompass(item.compass)
+
+                this.goNextForCustomImage(item.customImage)
             }
             change.saveCurrentInfo()
             this.setState()

+ 26 - 14
src/view/case/draw/board/editCAD/History/HistoryUtil.js

@@ -1,6 +1,7 @@
 import { mathUtil } from '../MathUtil'
 import { arrowService } from '../Service/ArrowService'
 import { circleService } from '../Service/CircleService'
+import { customImageService } from '../Service/CustomImageService'
 import { floorplanService } from '../Service/FloorplanService'
 import { iconService } from '../Service/IconService'
 import { rectangleService } from '../Service/RectangleService'
@@ -147,13 +148,13 @@ export default class HistoryUtil {
         }
     }
 
-    // isDifferentForAngle(angle1, angle2) {
-    //     if (angle1 == angle2) {
-    //         return false
-    //     } else {
-    //         return true
-    //     }
-    // }
+    isDifferentForCustomImage(customImage1, customImage2) {
+        if (customImage1.angle == customImage2.angle && customImage1.scale == customImage2.scale && customImage1.url == customImage2.url) {
+            return false
+        } else {
+            return true
+        }
+    }
 
     // wall2赋值给wall1
     assignWallFromWall(wall1, wall2) {
@@ -281,6 +282,15 @@ export default class HistoryUtil {
         floorplanService.updateCompass(compassInfo.angle )
     }
 
+    assignCustomImageFromCustomImage(customImage1, customImage2) {
+        const customImageInfo = {}
+        customImageInfo.vectorId = customImage1.vectorId
+        customImageInfo.angle = customImage2.angle
+        customImageInfo.url = customImage2.url
+        customImageInfo.scale = customImage2.scale
+        customImageService.setCustomImageInfo(customImageInfo)
+    }
+
     deletePoint(pointId) {
         const point = floorplanService.getPoint(pointId)
         const parent = point.parent
@@ -420,13 +430,15 @@ export default class HistoryUtil {
         return data
     }
 
-    // getDataForAngle(angle) {
-    //     return angle
-    // }
-
-    // getDataForRes(res) {
-    //     return res
-    // }
+    getDataForCustomImage(customImage) {
+        const data = {}
+        data.id = customImage.vectorId
+        data.type = customImage.geoType
+        data.angle = customImage.angle
+        data.scale = customImage.scale
+        data.url = customImage.url
+        return data
+    }
 }
 
 const historyUtil = new HistoryUtil()

+ 8 - 0
src/view/case/draw/board/editCAD/Service/CustomImageService.js

@@ -30,6 +30,14 @@ export default class CustomImageService {
     deleteCustomImage(customImageId, floorNum) {
         floorplanService.deleteCustomImage(customImageId, floorNum)
     }
+
+    setCustomImageInfo(customImageInfo) {
+        let customImage = floorplanService.getCustomImage(customImageInfo.vectorId)
+        customImage.vectorId = customImageInfo.vectorId
+        customImage.angle = customImageInfo.angle
+        customImage.url = customImageInfo.url
+        customImage.scale = customImageInfo.scale
+    }
 }
 
 const customImageService = new CustomImageService()