|
@@ -17,8 +17,7 @@ import { iconService } from '../Service/IconService'
|
|
|
import mitt from 'mitt'
|
|
|
|
|
|
export default class History {
|
|
|
- constructor(layer) {
|
|
|
- this.layer = layer
|
|
|
+ constructor() {
|
|
|
this.bus = mitt()
|
|
|
this.init();
|
|
|
}
|
|
@@ -99,11 +98,35 @@ export default class History {
|
|
|
// 撤销
|
|
|
handleUndo() {
|
|
|
this.goPreState()
|
|
|
+ this.layer.renderer.autoRedraw()
|
|
|
+ const historyState = historyService.getHistoryState()
|
|
|
+ if (historyState.pre) {
|
|
|
+ //可以继续撤销
|
|
|
+ history.bus.emit('undoAvailable', true)
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ //不能继续撤销
|
|
|
+ history.bus.emit('undoAvailable', false)
|
|
|
+ }
|
|
|
+ history.bus.emit('redoAvailable', true)
|
|
|
+ this.layer.uiControl.clearUI();
|
|
|
}
|
|
|
|
|
|
// 恢复
|
|
|
handleRedo() {
|
|
|
this.goNextState()
|
|
|
+ this.layer.renderer.autoRedraw()
|
|
|
+ const historyState = historyService.getHistoryState()
|
|
|
+ if (historyState.next) {
|
|
|
+ //可以继续恢复
|
|
|
+ history.bus.emit('redoAvailable', true)
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ //不能继续恢复
|
|
|
+ history.bus.emit('redoAvailable', false)
|
|
|
+ }
|
|
|
+ history.bus.emit('undoAvailable', true)
|
|
|
+ this.layer.uiControl.clearUI();
|
|
|
}
|
|
|
|
|
|
// 撤销
|
|
@@ -120,9 +143,9 @@ export default class History {
|
|
|
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.goPreForCircles(item.circles)
|
|
|
+ this.goPreForArrows(item.arrows)
|
|
|
+ this.goPreForIcons(item.icons)
|
|
|
this.goPreForSigns(item.signs)
|
|
|
|
|
|
historyService.undoHistoryRecord()
|
|
@@ -277,7 +300,7 @@ export default class History {
|
|
|
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)
|
|
|
+ let newIcon = iconService.createIcon(item.icon.points[0],item.icon.points[2],item.icon.value,item.icon.id)
|
|
|
historyUtil.assignIconFromIcon(newIcon, item.icon)
|
|
|
} else if (item.handle == HistoryEvents.ModifyIcon) {
|
|
|
const preIcon = item.preIcon
|
|
@@ -423,8 +446,8 @@ export default class History {
|
|
|
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)
|
|
|
+ let vIcon = iconService.createIcon(item.icon.points[0],item.icon.points[2],item.icon.value,item.icon.id)
|
|
|
+ historyUtil.assignIconFromIcon(vIcon, item.icon)
|
|
|
} else if (item.handle == HistoryEvents.DeleteIcon) {
|
|
|
floorplanService.deleteIcon(item.icon.id)
|
|
|
} else if (item.handle == HistoryEvents.ModifyIcon) {
|
|
@@ -490,9 +513,9 @@ export default class History {
|
|
|
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.goNextForCircles(item.circles)
|
|
|
+ this.goNextForArrows(item.arrows)
|
|
|
+ this.goNextForIcons(item.icons)
|
|
|
this.goNextForSigns(item.signs)
|
|
|
}
|
|
|
change.saveCurrentInfo()
|