|
@@ -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()
|