Bläddra i källkod

历史记录模块开发

xushiting 2 år sedan
förälder
incheckning
3dff9e93f0

+ 27 - 0
src/views/draw-file/board/editCAD/Geometry/Table.js

@@ -91,6 +91,9 @@ export default class Table extends Geometry {
     }
 
     setValue(value) {
+        let maxCol = 0;
+        let maxRow = 0;
+        let newCells = [];
         for(let i=0;i<value.length;++i){
             const item = value[i]
             let cell = this.cells[item.rowIndex][item.colIndex]
@@ -103,7 +106,31 @@ export default class Table extends Geometry {
             cell.value = item.value
             cell.colIndex = item.colIndex
             cell.rowIndex = item.rowIndex
+
+            newCells[item.rowIndex][item.colIndex]
+
+            if(maxRow < item.rowIndex){
+                maxRow = item.rowIndex
+            }
+
+            if(maxCol < item.colIndex){
+                maxCol = item.colIndex
+            }
         }
+
+        //删除多余的
+        for(let i=maxRow+1;i<this.cells.length;++i){
+            for(let j=maxCol+1;j<this.cells[i].length;++j){
+                const cell = floorplanService.getCell(this.cells[i][j]);
+                if(cell){
+                    floorplanService.deleteCell(this.cells[i][j]);
+                }
+            }
+        }
+
+        this.cells = newCells;
+        this.rowLen = this.cells.length;
+        this.colLen = this.cells[0].length;
     }
 
     getCellPos(vectorId){

+ 259 - 35
src/views/draw-file/board/editCAD/History/Change.js

@@ -17,38 +17,62 @@ export default class Change {
         this.lastData.currentFloor = floorplanService.getCurrentFloor()
         this.lastData.points = JSON.parse(JSON.stringify(floorplanService.getPoints()))
         this.lastData.walls = JSON.parse(JSON.stringify(floorplanService.getWalls()))
+
         this.lastData.signs = JSON.parse(JSON.stringify(floorplanService.getSigns()))
+
         this.lastData.tags = JSON.parse(JSON.stringify(floorplanService.getTags()))
-        this.lastData.angle = floorplanService.getAngle()
-        this.lastData.res = coordinate.res
+        this.lastData.tables = JSON.parse(JSON.stringify(floorplanService.getTables()))
+
+        this.lastData.rectangles = JSON.parse(JSON.stringify(floorplanService.getRectangles()))
+        this.lastData.circles = JSON.parse(JSON.stringify(floorplanService.getCircles()))
+        this.lastData.arrows = JSON.parse(JSON.stringify(floorplanService.getArrows()))
+        this.lastData.icons = JSON.parse(JSON.stringify(floorplanService.getIcons()))
+
+        //this.lastData.angle = floorplanService.getAngle()
+        //this.lastData.res = coordinate.res
     }
 
     operate() {
         //
         this.elements = {}
-        let flag = this.compareAngle()
-        if (!flag) {
+        // let flag = this.compareAngle()
+        // if (!flag) {
             this.comparePoints()
             this.compareWalls()
-            this.compareTags()
+    
             this.compareSigns()
-        }
-        //旋转了
-        else {
-            this.lastData = {}
-            return true
-        }
 
+            this.compareTags()
+            this.compareTables()
+
+            this.compareRectangles()
+            this.compareCircles()
+            this.compareArrows()
+            this.compareIcons()
+        // }
+        // //旋转了
+        // else {
+        //     this.lastData = {}
+        //     return true
+        // }
         if (
             this.elements.points.length == 0 &&
             this.elements.walls.length == 0 &&
-            this.elements.components.length == 0 &&
+
+            this.elements.signs.length == 0 &&
+
             this.elements.tags.length == 0 &&
-            this.elements.signs.length == 0
+            this.elements.tables.length == 0 &&
+
+            this.elements.rectangles.length == 0 &&
+            this.elements.circles.length == 0 &&
+            this.elements.arrows.length == 0 &&
+            this.elements.icons.length == 0 
         ) {
             this.saveCurrentInfo()
             return false
         }
+
         this.lastData = {}
         // 这里不能取this.records.length-1,因为可能撤销后操作,这时候应该是覆盖,而不是往后面添加
         return true
@@ -174,6 +198,206 @@ export default class Change {
         }
     }
 
+    compareTables() {
+        this.elements.tables = []
+        const tables = floorplanService.getTables()
+
+        for (const key in tables) {
+            const table = tables[key]
+            const lastTable = this.lastData.tables[key]
+
+            // 不存在意味着增加
+            if (!lastTable) {
+                const item = {
+                    handle: HistoryEvents.AddTable,
+                    table: historyUtil.getDataForTable(table),
+                }
+                this.elements.tables.push(item)
+            } else {
+                if (!historyUtil.isDifferentForTables(table, lastTable)) {
+                    delete this.lastData.tables[key]
+                    continue
+                } else {
+                    const item = {
+                        handle: HistoryEvents.ModifyTable,
+                        preTable: historyUtil.getDataForTable(lastTable),
+                        curTable: historyUtil.getDataForTable(table),
+                    }
+                    this.elements.tables.push(item)
+                }
+            }
+            delete this.lastData.tables[key]
+        }
+
+        for (const key in this.lastData.tables) {
+            const item = {
+                handle: HistoryEvents.DeleteTable,
+                table: historyUtil.getDataForTable(this.lastData.tables[key]),
+            }
+            this.elements.tables.push(item)
+        }
+    }
+
+    compareRectangles() {
+        this.elements.rectangles = []
+        const rectangles = floorplanService.getRectangles()
+
+        for (const key in rectangles) {
+            const rectangle = rectangles[key]
+            const lastRectangle = this.lastData.rectangles[key]
+
+            // 不存在意味着增加
+            if (!lastRectangle) {
+                const item = {
+                    handle: HistoryEvents.AddRectangle,
+                    rectangle: historyUtil.getDataForRectangle(rectangle),
+                }
+                this.elements.rectangles.push(item)
+            } else {
+                if (!historyUtil.isDifferentForRectangles(rectangle, lastRectangle)) {
+                    delete this.lastData.rectangles[key]
+                    continue
+                } else {
+                    const item = {
+                        handle: HistoryEvents.ModifyRectangle,
+                        preRectangle: historyUtil.getDataForRectangle(lastRectangle),
+                        curRectangle: historyUtil.getDataForRectangle(rectangle),
+                    }
+                    this.elements.rectangles.push(item)
+                }
+            }
+            delete this.lastData.rectangles[key]
+        }
+
+        for (const key in this.lastData.rectangles) {
+            const item = {
+                handle: HistoryEvents.DeleteRectangle,
+                rectangle: historyUtil.getDataForRectangle(this.lastData.rectangles[key]),
+            }
+            this.elements.rectangles.push(item)
+        }
+    }
+
+    compareCircles() {
+        this.elements.circles = []
+        const circles = floorplanService.getCircles()
+
+        for (const key in circles) {
+            const circle = circles[key]
+            const lastCircle = this.lastData.circles[key]
+
+            // 不存在意味着增加
+            if (!lastCircle) {
+                const item = {
+                    handle: HistoryEvents.AddCircle,
+                    circle: historyUtil.getDataForCircle(circle),
+                }
+                this.elements.circles.push(item)
+            } else {
+                if (!historyUtil.isDifferentForCircles(circle, lastCircle)) {
+                    delete this.lastData.circles[key]
+                    continue
+                } else {
+                    const item = {
+                        handle: HistoryEvents.ModifyCircle,
+                        preCircle: historyUtil.getDataForCircle(lastCircle),
+                        curCircle: historyUtil.getDataForCircle(circle),
+                    }
+                    this.elements.circles.push(item)
+                }
+            }
+            delete this.lastData.circles[key]
+        }
+
+        for (const key in this.lastData.circles) {
+            const item = {
+                handle: HistoryEvents.DeleteCircle,
+                circle: historyUtil.getDataForCircle(this.lastData.circles[key]),
+            }
+            this.elements.circles.push(item)
+        }
+    }
+
+    compareArrows() {
+        this.elements.arrows = []
+        const arrows = floorplanService.getArrows()
+
+        for (const key in arrows) {
+            const arrow = arrows[key]
+            const lastArrow = this.lastData.arrows[key]
+
+            // 不存在意味着增加
+            if (!lastArrow) {
+                const item = {
+                    handle: HistoryEvents.AddArrow,
+                    arrow: historyUtil.getDataForArrow(arrow),
+                }
+                this.elements.arrows.push(item)
+            } else {
+                if (!historyUtil.isDifferentForArrows(arrow, lastArrow)) {
+                    delete this.lastData.arrows[key]
+                    continue
+                } else {
+                    const item = {
+                        handle: HistoryEvents.ModifyArrow,
+                        preArrow: historyUtil.getDataForArrow(lastArrow),
+                        curArrow: historyUtil.getDataForArrow(arrow),
+                    }
+                    this.elements.arrows.push(item)
+                }
+            }
+            delete this.lastData.arrows[key]
+        }
+
+        for (const key in this.lastData.arrows) {
+            const item = {
+                handle: HistoryEvents.DeleteArrow,
+                arrow: historyUtil.getDataForArrow(this.lastData.arrows[key]),
+            }
+            this.elements.arrows.push(item)
+        }
+    }
+
+    compareIcons() {
+        this.elements.icons = []
+        const icons = floorplanService.getIcons()
+
+        for (const key in icons) {
+            const icon = icons[key]
+            const lastIcon = this.lastData.icons[key]
+
+            // 不存在意味着增加
+            if (!lastIcon) {
+                const item = {
+                    handle: HistoryEvents.AddIcon,
+                    icon: historyUtil.getDataForIcon(icon),
+                }
+                this.elements.icons.push(item)
+            } else {
+                if (!historyUtil.isDifferentForIcons(icon, lastIcon)) {
+                    delete this.lastData.icons[key]
+                    continue
+                } else {
+                    const item = {
+                        handle: HistoryEvents.ModifyIcon,
+                        preIcon: historyUtil.getDataForIcon(lastIcon),
+                        curIcon: historyUtil.getDataForIcon(icon),
+                    }
+                    this.elements.icons.push(item)
+                }
+            }
+            delete this.lastData.icons[key]
+        }
+
+        for (const key in this.lastData.icons) {
+            const item = {
+                handle: HistoryEvents.DeleteIcon,
+                icon: historyUtil.getDataForIcon(this.lastData.icons[key]),
+            }
+            this.elements.icons.push(item)
+        }
+    }
+
     compareSigns() {
         //const currentFloor = floorplanService.getCurrentFloorNum();
         this.elements.signs = []
@@ -215,28 +439,28 @@ export default class Change {
         }
     }
 
-    compareAngle() {
-        const angle = floorplanService.getAngle()
-        const lastAngle = this.lastData.angle
-        const lastRes = this.lastData.res
-        if (historyUtil.isDifferentForAngle(angle, lastAngle)) {
-            const item = {
-                handle: HistoryEvents.ModifyAngle,
-                preState: {
-                    angle: historyUtil.getDataForAngle(lastAngle),
-                    res: historyUtil.getDataForRes(lastRes),
-                },
-                curState: {
-                    angle: historyUtil.getDataForAngle(angle),
-                    res: historyUtil.getDataForRes(coordinate.res),
-                },
-            }
-            this.elements.rotate = item
-            return true
-        } else {
-            return false
-        }
-    }
+    // compareAngle() {
+    //     const angle = floorplanService.getAngle()
+    //     const lastAngle = this.lastData.angle
+    //     const lastRes = this.lastData.res
+    //     if (historyUtil.isDifferentForAngle(angle, lastAngle)) {
+    //         const item = {
+    //             handle: HistoryEvents.ModifyAngle,
+    //             preState: {
+    //                 angle: historyUtil.getDataForAngle(lastAngle),
+    //                 res: historyUtil.getDataForRes(lastRes),
+    //             },
+    //             curState: {
+    //                 angle: historyUtil.getDataForAngle(angle),
+    //                 res: historyUtil.getDataForRes(coordinate.res),
+    //             },
+    //         }
+    //         this.elements.rotate = item
+    //         return true
+    //     } else {
+    //         return false
+    //     }
+    // }
 }
 
 const change = new Change()

+ 230 - 60
src/views/draw-file/board/editCAD/History/History.js

@@ -9,6 +9,11 @@ import { historyService } from '../Service/HistoryService'
 import { tagService } from '../Service/TagService'
 import { coordinate } from '../Coordinate'
 import { signService } from '../Service/SignService'
+import { tableService } from '../Service/TableService'
+import { rectangleService } from '../Service/RectangleService'
+import { circleService } from '../Service/CircleService'
+import { arrowService } from '../Service/ArrowService'
+import { iconService } from '../Service/IconService'
 
 export default class History {
     constructor(layer) {
@@ -28,19 +33,22 @@ export default class History {
     }
 
     save() {
-        // const flag = change.operate()
-        // if (!flag) {
-        //     return
-        // }
-        // historyService.addHistoryRecord(change.elements)
-        // change.saveCurrentInfo()
-        // this.setState()
-        // const historyState = historyService.getHistoryState()
-
+        const flag = change.operate()
+        if (!flag) {
+            return
+        }
+        historyService.addHistoryRecord(change.elements)
+        change.saveCurrentInfo()
+        this.setState()
+        const historyState = historyService.getHistoryState()
+        if (historyState.pre) {
+            //this.layer.$xui.toolbar.recall = true
+        }
+        //this.layer.$xui.toolbar.recover = false
         // //给UI发送事件
         // // this.layer.emit('change')
 
-        // return change.elements
+        return change.elements
     }
 
     setState() {
@@ -99,23 +107,20 @@ export default class History {
     goPreState() {
         const item = historyService.getHistoryRecord()
         if (item) {
-            stateService.clearFocusItem()
-            //this.layer.$xui.hideProps()
-            this.layer.uiControl.selectUI = null
-            item.type = 'pre'
-            let flag = false
-            if (item.rotate == null) {
-                flag = false
-            } else {
-                flag = this.goPreForAngle(item.rotate)
-            }
+            stateService.clearItems()
+            this.layer.uiControl.clearUI()
 
-            if (!flag) {
-                this.goPreForPoints(item.points)
-                this.goPreForWalls(item.walls)
-                this.goPreForTags(item.tags)
-                this.goPreForSigns(item.signs)
-            }
+            item.type = 'pre'
+        
+            this.goPreForPoints(item.points)
+            this.goPreForWalls(item.walls)
+            this.goPreForTags(item.tags)
+            this.goPreForTables(item.tables)
+            this.goPreForRectangles(item.rectangles)
+            this.goPreForCircles(item.Circles)
+            this.goPreForArrows(item.Arrows)
+            this.goPreForIcons(item.Icons)
+            this.goPreForSigns(item.signs)
 
             historyService.undoHistoryRecord()
             change.saveCurrentInfo()
@@ -199,25 +204,105 @@ 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
+    goPreForTables(itemForTables) {
+        for (let i = 0; i < itemForTables.length; ++i) {
+            const item = itemForTables[i]
+            if (item.handle == HistoryEvents.AddTable) {
+                tableService.deleteTable(item.table.id)
+            } else if (item.handle == HistoryEvents.DeleteTable) {
+                let newTable = tableService.createTable(item.table.center, item.table.id)
+                historyUtil.assignTableFromTable(newTable, item.table)
+            } else if (item.handle == HistoryEvents.ModifyTable) {
+                const preTable = item.preTable
+                let curTable = floorplanService.getTable(item.curTable.id)
+                historyUtil.assignTableFromTable(curTable, preTable)
+            }
+        }
+    }
+
+    goPreForRectangles(itemForRectangles) {
+        for (let i = 0; i < itemForRectangles.length; ++i) {
+            const item = itemForRectangles[i]
+            if (item.handle == HistoryEvents.AddRectangle) {    
+                rectangleService.deleteRectangle(item.rectangle.id)
+            } else if (item.handle == HistoryEvents.DeleteRectangle) {
+                let newRectangle = rectangleService.createRectangle(item.rectangle.points[0],item.rectangle.points[2],item.rectangle.id)
+                historyUtil.assignRectangleFromRectangle(newRectangle, item.rectangle)
+            } else if (item.handle == HistoryEvents.ModifyRectangle) {
+                const preRectangle = item.preRectangle
+                let curRectangle = floorplanService.getRectangle(item.curRectangle.id)
+                historyUtil.assignRectangleFromRectangle(curRectangle, preRectangle)
+            }
+        }
+    }
+
+    goPreForCircles(itemForCircles) {
+        for (let i = 0; i < itemForCircles.length; ++i) {
+            const item = itemForCircles[i]
+            if (item.handle == HistoryEvents.AddCircle) {    
+                circleService.deleteCircle(item.circle.id)
+            } else if (item.handle == HistoryEvents.DeleteCircle) {
+                let newCircle = circleService.createCircle(item.circle.points[0],item.circle.points[2],item.circle.id)
+                historyUtil.assignCircleFromCircle(newCircle, item.circle)
+            } else if (item.handle == HistoryEvents.ModifyCircle) {
+                const preCircle = item.preCircle
+                let curCircle = floorplanService.getCircle(item.curCircle.id)
+                historyUtil.assignCircleFromCircle(curCircle, preCircle)
+            }
         }
     }
 
+    goPreForArrows(itemForArrows) {
+        for (let i = 0; i < itemForArrows.length; ++i) {
+            const item = itemForArrows[i]
+            if (item.handle == HistoryEvents.AddArrow) {    
+                arrowService.deleteArrow(item.arrow.id)
+            } else if (item.handle == HistoryEvents.DeleteArrow) {
+                let newArrow = arrowService.createArrow(item.arrow.startPoint,item.arrow.endPoint,item.arrow.id)
+                historyUtil.assignArrowFromArrow(newArrow, item.arrow)
+            } else if (item.handle == HistoryEvents.ModifyArrow) {
+                const preArrow = item.preArrow
+                let curArrow = floorplanService.getArrow(item.curArrow.id)
+                historyUtil.assignArrowFromArrow(curArrow, preArrow)
+            }
+        }
+    }
+
+    goPreForIcons(itemForIcons) {
+        for (let i = 0; i < itemForIcons.length; ++i) {
+            const item = itemForIcons[i]
+            if (item.handle == HistoryEvents.AddIcon) {  
+                iconService.deleteIcon(item.icon.id)
+            } else if (item.handle == HistoryEvents.DeleteIcon) {
+                let newIcon = iconService.createIcon(item.icon.points[0],item.icon.points[2],item.value,item.icon.id)
+                historyUtil.assignIconFromIcon(newIcon, item.icon)
+            } else if (item.handle == HistoryEvents.ModifyIcon) {
+                const preIcon = item.preIcon
+                let curIcon = floorplanService.getIcon(item.curIcon.id)
+                historyUtil.assignIconFromIcon(curIcon, preIcon)
+            }
+        }
+    }
+
+    // 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
+    //     }
+    // }
+
     goNextForPoints(itemForPoints) {
         for (let i = 0; i < itemForPoints.length; ++i) {
             const item = itemForPoints[i]
@@ -267,6 +352,86 @@ export default class History {
         }
     }
 
+    goNextForTables(itemForTables) {
+        for (let i = 0; i < itemForTables.length; ++i) {
+            const item = itemForTables[i]
+            if (item.handle == HistoryEvents.AddTable) {
+                let vTable = tableService.createTable(item.table.center, item.table.id)
+                historyUtil.assignTableFromTable(vTable, item.table)
+            } else if (item.handle == HistoryEvents.DeleteTable) {
+                tableService.deleteTable(item.table.id)
+            } else if (item.handle == HistoryEvents.ModifyTable) {
+                const curTable = item.curTable
+                let preTable = floorplanService.getTable(item.curTable.id)
+                historyUtil.assignTableFromTable(preTable, curTable)
+            }
+        }
+    }
+
+    goNextForRectangles(itemForRectangles) {
+        for (let i = 0; i < itemForRectangles.length; ++i) {
+            const item = itemForRectangles[i]
+            if (item.handle == HistoryEvents.AddRectangle) {
+                let vRectangle = rectangleService.createRectangle(item.rectangle.points[0],item.rectangle.points[2],item.rectangle.id)
+                historyUtil.assignRectangleFromRectangle(vRectangle, item.rectangle)
+            } else if (item.handle == HistoryEvents.DeleteRectangle) {
+                rectangleService.deleteRectangle(item.rectangle.id)
+            } else if (item.handle == HistoryEvents.ModifyRectangle) {
+                const currentRectangle = item.curRectangle
+                let preRectangle = floorplanService.getRectangle(item.curRectangle.id)
+                historyUtil.assignRectangleFromRectangle(preRectangle, currentRectangle)
+            }
+        }
+    }
+
+    goNextForCircles(itemForCircles) {
+        for (let i = 0; i < itemForCircles.length; ++i) {
+            const item = itemForCircles[i]
+            if (item.handle == HistoryEvents.AddCircle) {
+                let vCircle = circleService.createCircle(item.circle.points[0],item.circle.points[2],item.circle.id)
+                historyUtil.assignCircleFromCircle(vCircle, item.circle)
+            } else if (item.handle == HistoryEvents.DeleteCircle) {
+                floorplanService.deleteCircle(item.circle.id)
+            } else if (item.handle == HistoryEvents.ModifyCircle) {
+                const currentCircle = item.curCircle
+                let preCircle = floorplanService.getCircle(item.curCircle.id)
+                historyUtil.assignCircleFromCircle(preCircle, currentCircle)
+            }
+        }
+    }
+
+    goNextForArrows(itemForArrows) {
+        for (let i = 0; i < itemForArrows.length; ++i) {
+            const item = itemForArrows[i]
+            if (item.handle == HistoryEvents.AddArrow) {
+                let vArrow = arrowService.createArrow(item.arrow.startPoint,item.arrow.endPoint,item.arrow.id)
+                historyUtil.assignArrowFromArrow(vArrow, item.arrow)
+            } else if (item.handle == HistoryEvents.DeleteArrow) {
+                arrowService.deleteArrow(item.arrow.id)
+            } else if (item.handle == HistoryEvents.ModifyArrow) {
+                const currentArrow = item.curArrow
+                let preArrow = floorplanService.getArrow(item.curArrow.id)
+                historyUtil.assignArrowFromArrow(preArrow, currentArrow)
+            }
+        }
+    }
+
+    goNextForIcons(itemForIcons) {
+        for (let i = 0; i < itemForIcons.length; ++i) {
+            const item = itemForIcons[i]
+            if (item.handle == HistoryEvents.AddIcon) {
+                let vIcon = iconService.createIcon(item.icon.points[0],item.icon.points[2],item.value,item.icon.id)
+                historyUtil.assignIconFromIcon(vSign, item.icon)
+            } else if (item.handle == HistoryEvents.DeleteIcon) {
+                floorplanService.deleteIcon(item.icon.id)
+            } else if (item.handle == HistoryEvents.ModifyIcon) {
+                const currentIcon = item.curIcon
+                let preIcon = floorplanService.getIcon(item.curIcon.id)
+                historyUtil.assignIconFromIcon(preIcon, currentIcon)
+            }
+        }
+    }
+
     goNextForSigns(itemForSigns) {
         for (let i = 0; i < itemForSigns.length; ++i) {
             const item = itemForSigns[i]
@@ -283,24 +448,24 @@ 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
-        }
-    }
+    // 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
+    //     }
+    // }
 
     // 恢复
     goNextState() {
@@ -320,6 +485,11 @@ export default class History {
                 this.goNextForPoints(item.points)
                 this.goNextForWalls(item.walls)
                 this.goNextForTags(item.tags)
+                this.goNextForTables(item.tables)
+                this.goNextForRectangles(item.rectangles)
+                this.goNextForCircles(item.Circles)
+                this.goNextForArrows(item.Arrows)
+                this.goNextForIcons(item.Icons)
                 this.goNextForSigns(item.signs)
             }
             change.saveCurrentInfo()

+ 219 - 8
src/views/draw-file/board/editCAD/History/HistoryUtil.js

@@ -1,6 +1,11 @@
 import { mathUtil } from '../MathUtil'
+import { arrowService } from '../Service/ArrowService'
+import { circleService } from '../Service/CircleService'
 import { floorplanService } from '../Service/FloorplanService'
+import { iconService } from '../Service/IconService'
+import { rectangleService } from '../Service/RectangleService'
 import { signService } from '../Service/SignService'
+import { tableService } from '../Service/TableService'
 import { tagService } from '../Service/TagService'
 import { wallService } from '../Service/WallService'
 
@@ -22,22 +27,111 @@ export default class HistoryUtil {
             return true
         }
     }
-    isDifferentForSigns(sign1, sign2) {
-        if (sign1.scale == sign2.scale && JSON.stringify(sign1.center) == JSON.stringify(sign2.center) && sign1.angle == sign2.angle) {
+
+    isDifferentForTables(table1, table2) {
+        if(!mathUtil.equalPoint(table1.center, table2.center)){
+            return true;
+        }
+        else if(table1.rowLen != table2.rowLen || table1.colLen != table2.colLen || table1.cells.length != table2.cells.length){
+            return true;
+        }
+        else{
+            for(let i=0;i<table1.cells.length;++i){
+                for(let j=0;j<table1.cells[i].length;++j){
+                    const cell1 = floorplanService.getCell(table1.cells[i][j]);
+                    const cell2 = floorplanService.getCell(table2.cells[i][j]);
+                    if(this.isDifferentForCells(cell1,cell2)){
+                        return true;
+                    }
+                }
+            }
+        }
+
+        return false
+    }
+
+    isDifferentForCells(cell1, cell2) {
+        if (cell1.value == cell2.value&&cell1.width == cell2.width&&cell1.height == cell2.height) {
             return false
         } else {
             return true
         }
     }
 
-    isDifferentForAngle(angle1, angle2) {
-        if (angle1 == angle2) {
+
+    isDifferentForRectangles(rectangle1, rectangle2) {
+        for(let i=0;i<rectangle1.points.length;++i){
+            if(!mathUtil.equalPoint(rectangle1.points[i], rectangle2.points[i])){
+                return true;
+            }
+        }
+        return false;
+    }
+
+    isDifferentForCircles(circle1, circle2) {
+        if(!mathUtil.equalPoint(circle1.center, circle2.center)){
+            return true;
+        }
+        else if(circle1.radius != circle2.radius){
+            return true;
+        }
+        else {
+            for(let i=0;i<circle1.points.length;++i){
+                if(!mathUtil.equalPoint(circle1.points[i], circle2.points[i])){
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    isDifferentForArrows(arrow1, arrow2) {
+        if (mathUtil.equalPoint(arrow1.startPoint, arrow2.startPoint) && mathUtil.equalPoint(arrow1.endPoint, arrow2.endPoint)) {
             return false
         } else {
             return true
         }
     }
 
+    isDifferentForIcons(icon1, icon2) {
+        if(!mathUtil.equalPoint(icon1.center, icon2.center)){
+            return true;
+        }
+        else if(icon1.radius != icon2.radius){
+            return true;
+        }
+        else if(icon1.value != icon2.value){
+            return true;
+        }
+        else if(icon1.angle != icon2.angle){
+            return true;
+        }
+        else {
+            for(let i=0;i<icon1.points.length;++i){
+                if(!mathUtil.equalPoint(icon1.points[i], icon2.points[i])){
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+
+    isDifferentForSigns(sign1, sign2) {
+        if (sign1.scale == sign2.scale && JSON.stringify(sign1.center) == JSON.stringify(sign2.center) && sign1.angle == sign2.angle) {
+            return false
+        } else {
+            return true
+        }
+    }
+
+    // isDifferentForAngle(angle1, angle2) {
+    //     if (angle1 == angle2) {
+    //         return false
+    //     } else {
+    //         return true
+    //     }
+    // }
+
     // wall2赋值给wall1
     assignWallFromWall(wall1, wall2) {
         const wallInfo = {}
@@ -46,6 +140,7 @@ export default class HistoryUtil {
         wallInfo.end = wall2.end
         wallService.setWallInfo(wallInfo)
     }
+
     assignPointFromPoint(point1, point2) {
         const pointInfo = {}
         pointInfo.vectorId = point1.vectorId
@@ -62,6 +157,64 @@ export default class HistoryUtil {
         tagInfo.points2d = JSON.parse(JSON.stringify(tag2.points))
         tagService.setTagInfo(tagInfo)
     }
+
+    assignTableFromTable(table1, table2) {
+        const tableInfo = {}
+        tableInfo.vectorId = table1.vectorId
+        tableInfo.rowLen = table2.rowLen
+        tableInfo.colLen = table2.colLen
+        tableInfo.center = JSON.parse(JSON.stringify(table2.center))
+        tableInfo.points = JSON.parse(JSON.stringify(table2.points))
+        tableInfo.cells = table2.cells
+        tableService.setTableInfo(tableInfo)
+    }
+
+    assignTagFromTag(tag1, tag2) {
+        const tagInfo = {}
+        tagInfo.vectorId = tag1.vectorId
+        tagInfo.value = tag2.value
+        tagInfo.center = JSON.parse(JSON.stringify(tag2.center))
+        tagInfo.points2d = JSON.parse(JSON.stringify(tag2.points))
+        tagService.setTagInfo(tagInfo)
+    }
+
+    assignRectangleFromRectangle(rectangle1, rectangle2) {
+        const rectangleInfo = {}
+        rectangleInfo.vectorId = rectangle1.vectorId
+        rectangleInfo.angle = rectangle2.angle
+        rectangleInfo.points = JSON.parse(JSON.stringify(rectangle2.points))
+        rectangleService.setRectangleInfo(rectangleInfo)
+    }
+
+    assignCircleFromCircle(circle1, circle2) {
+        const circleInfo = {}
+        circleInfo.vectorId = circle1.vectorId
+        circleInfo.radius = circle2.radius
+        circleInfo.center = JSON.parse(JSON.stringify(circle2.center))
+        circleInfo.points = JSON.parse(JSON.stringify(circle2.points))
+        circleService.setCircleInfo(circleInfo)
+    }
+
+    assignArrowFromArrow(arrow1, arrow2) {
+        const arrowInfo = {}
+        arrowInfo.vectorId = arrow1.vectorId
+        arrowInfo.startPoint = JSON.parse(JSON.stringify(arrow2.startPoint))
+        arrowInfo.endPoint = JSON.parse(JSON.stringify(arrow2.endPoint))
+        arrowService.setArrowInfo(arrowInfo)
+    }
+
+    assignIconFromIcon(icon1, icon2) {
+        const iconInfo = {}
+        iconInfo.vectorId = icon1.vectorId
+        iconInfo.radius = icon2.radius
+        iconInfo.value = icon2.value
+        iconInfo.angle = icon2.angle
+        iconInfo.center = JSON.parse(JSON.stringify(icon2.center))
+        iconInfo.points = JSON.parse(JSON.stringify(icon2.points))
+        iconService.setIconInfo(iconInfo)
+    }
+
+
     assignSignFromSign(sign1, sign2) {
         const SignInfo = {}
         SignInfo.vectorId = sign1.vectorId
@@ -70,6 +223,7 @@ export default class HistoryUtil {
         SignInfo.scale = sign2.scale
         signService.setSignInfo(SignInfo)
     }
+
     deletePoint(pointId) {
         const point = floorplanService.getPoint(pointId)
         const parent = point.parent
@@ -115,13 +269,70 @@ export default class HistoryUtil {
         return data
     }
 
-    getDataForAngle(angle) {
-        return angle
+    getDataForTable(table) {
+        const data = {}
+        data.id = table.vectorId
+        data.type = table.geoType
+        data.rowLen = table.rowLen
+        data.colLen = table.colLen
+        data.center = {}
+        mathUtil.clonePoint(data.center, table.center)
+        data.points = [].concat(table.points)
+        data.cells = [].concat(table.cells)
+        return data
+    }
+
+    getDataForRectangle(rectangle) {
+        const data = {}
+        data.id = rectangle.vectorId
+        data.type = rectangle.geoType
+        data.angle = rectangle.angle
+        data.points = [].concat(rectangle.points)
+        return data
     }
 
-    getDataForRes(res) {
-        return res
+    getDataForCircle(circle) {
+        const data = {}
+        data.id = circle.vectorId
+        data.type = circle.geoType
+        data.center = {}
+        mathUtil.clonePoint(data.center, circle.center)
+        data.points = [].concat(circle.points)
+        data.radius = circle.radius
+        return data
     }
+
+    getDataForArrow(arrow) {
+        const data = {}
+        data.id = arrow.vectorId
+        data.type = arrow.geoType
+        data.startPoint = {}
+        mathUtil.clonePoint(data.startPoint, arrow.startPoint)
+        data.endPoint = {}
+        mathUtil.clonePoint(data.endPoint, arrow.endPoint)
+        return data
+    }
+
+    getDataForIcon(icon) {
+        const data = {}
+        data.id = icon.vectorId
+        data.type = icon.geoType
+        data.value = icon.value
+        data.angle = icon.angle
+        data.center = {}
+        mathUtil.clonePoint(data.center, icon.center)
+        data.points = [].concat(icon.points)
+        data.radius = icon.radius
+        return data
+    }
+
+    // getDataForAngle(angle) {
+    //     return angle
+    // }
+
+    // getDataForRes(res) {
+    //     return res
+    // }
 }
 
 const historyUtil = new HistoryUtil()

+ 13 - 2
src/views/draw-file/board/editCAD/Service/ArrowService.js

@@ -8,8 +8,8 @@ export default class ArrowService {
     constructor() {
     }
   
-    createArrow(startPosition,endPosition) {
-        const arrow = new Arrow(startPosition, endPosition)
+    createArrow(startPosition,endPosition,vectorId) {
+        const arrow = new Arrow(startPosition, endPosition,vectorId)
         floorplanService.addArrow(arrow)
         return arrow
     }
@@ -18,6 +18,17 @@ export default class ArrowService {
         const arrow = floorplanService.getArrow(vectorId)
         arrow.updatePoint(newPosition,dir)
     }
+
+    setArrowInfo(arrowInfo) {
+        let arrow = floorplanService.getArrow(arrowInfo.vectorId)
+        arrow.vectorId = arrowInfo.vectorId
+        arrow.startPoint = JSON.parse(JSON.stringify(arrowInfo.startPoint))
+        arrow.endPoint = JSON.parse(JSON.stringify(arrowInfo.endPoint))
+    }
+
+    deleteArrow(arrowId, floorNum) {
+        floorplanService.deleteArrow(arrowId, floorNum)
+    }
 }
 
 const arrowService = new ArrowService()

+ 14 - 2
src/views/draw-file/board/editCAD/Service/CircleService.js

@@ -8,13 +8,13 @@ export default class CircleService {
     constructor() {
     }
   
-    createCircle(leftTopPosition,rightDownPosition) {
+    createCircle(leftTopPosition,rightDownPosition,vectorId) {
         const radius = mathUtil.getDistance(leftTopPosition,rightDownPosition)/2
         const center = {
             x:(leftTopPosition.x+rightDownPosition.x)/2,
             y:(leftTopPosition.y+rightDownPosition.y)/2
         }
-        const circle = new Circle(center, radius)
+        const circle = new Circle(center, radius,vectorId)
         floorplanService.addCircle(circle)
         return circle
     }
@@ -23,6 +23,18 @@ export default class CircleService {
         const circle = floorplanService.getCircle(vectorId)
         circle.updatePoints(newPosition,index)
     }
+
+    setCircleInfo(circleInfo) {
+        let circle = floorplanService.getCircle(circleInfo.vectorId)
+        circle.vectorId = circleInfo.vectorId
+        circle.radius = circleInfo.radius
+        circle.center = JSON.parse(JSON.stringify(circleInfo.center))
+        circle.points = JSON.parse(JSON.stringify(circleInfo.points))
+    }
+
+    deleteCircle(circleId, floorNum) {
+        floorplanService.deleteCircle(circleId, floorNum)
+    }
 }
 
 const circleService = new CircleService()

+ 19 - 3
src/views/draw-file/board/editCAD/Service/IconService.js

@@ -24,14 +24,16 @@ export default class IconService {
         return value;
     }
 
-    createIcon(leftTopPosition,rightDownPosition) {
+    createIcon(leftTopPosition,rightDownPosition,value,vectorId) {
         const radius = mathUtil.getDistance(leftTopPosition,rightDownPosition)/2
         const center = {
             x:(leftTopPosition.x+rightDownPosition.x)/2,
             y:(leftTopPosition.y+rightDownPosition.y)/2
         }
-        const value = this.getNewValue();
-        const icon = new Icon(center, radius,value)
+        if(!value){
+            value = this.getNewValue();
+        }
+        const icon = new Icon(center, radius,value,vectorId)
         floorplanService.addIcon(icon)
         return icon
     }
@@ -40,6 +42,20 @@ export default class IconService {
         const icon = floorplanService.getIcon(vectorId)
         icon.updatePoints(newPosition,index)
     }
+
+    setIconInfo(iconInfo) {
+        let icon = floorplanService.getIcon(iconInfo.vectorId)
+        icon.vectorId = iconInfo.vectorId
+        icon.radius = iconInfo.radius
+        icon.value = iconInfo.value
+        icon.angle = iconInfo.angle
+        icon.center = JSON.parse(JSON.stringify(iconInfo.center))
+        icon.points = JSON.parse(JSON.stringify(iconInfo.points))
+    }
+
+    deleteIcon(iconId, floorNum) {
+        floorplanService.deleteIcon(iconId, floorNum)
+    }
 }
 
 const iconService = new IconService()

+ 13 - 2
src/views/draw-file/board/editCAD/Service/RectangleService.js

@@ -7,8 +7,8 @@ export default class RectangleService {
     constructor() {
     }
   
-    createRectangle(leftTopPosition,rightDownPosition) {
-        const rectangle = new Rectangle(leftTopPosition,rightDownPosition)
+    createRectangle(leftTopPosition,rightDownPosition,vectorId) {
+        const rectangle = new Rectangle(leftTopPosition,rightDownPosition,vectorId)
         floorplanService.addRectangle(rectangle)
         return rectangle
     }
@@ -17,6 +17,17 @@ export default class RectangleService {
         const rectangle = floorplanService.getRectangle(vectorId)
         rectangle.updatePoints(newPosition,index)
     }
+
+    setRectangleInfo(rectangleInfo) {
+        let rectangle = floorplanService.getRectangle(rectangleInfo.vectorId)
+        rectangle.vectorId = rectangleInfo.vectorId
+        rectangle.angle = rectangleInfo.angle
+        rectangle.points = JSON.parse(JSON.stringify(rectangleInfo.points))
+    }
+
+    deleteRectangle(rectangleId, floorNum) {
+        floorplanService.deleteRectangle(rectangleId, floorNum)
+    }
 }
 
 const rectangleService = new RectangleService()

+ 21 - 1
src/views/draw-file/board/editCAD/enum/HistoryEvents.js

@@ -11,10 +11,30 @@ const HistoryEvents = {
     DeleteTag: 'deleteTag',
     ModifyTag: 'modifyTag',
 
+    AddTable: 'addTable',
+    DeleteTable: 'deleteTable',
+    ModifyTable: 'modifyTable',
+
+    AddRectangle: 'addRectangle',
+    DeleteRectangle: 'deleteRectangle',
+    ModifyRectangle: 'modifyRectangle',
+
+    AddCircle: 'addCircle',
+    DeleteCircle: 'deleteCircle',
+    ModifyCircle: 'modifyCircle',
+
+    AddArrow: 'addArrow',
+    DeleteArrow: 'deleteArrow',
+    ModifyArrow: 'modifyArrow',
+
+    AddIcon: 'addIcon',
+    DeleteIcon: 'deleteIcon',
+    ModifyIcon: 'modifyIcon',
+
     AddSign: 'addSign',
     DeleteSign: 'deleteSign',
     ModifySign: 'modifySign',
 
-    ModifyAngle: 'modifyAngle',
+    //ModifyAngle: 'modifyAngle',
 }
 export default HistoryEvents