|
@@ -1,17 +1,13 @@
|
|
|
import { dataService } from "../Service/DataService";
|
|
|
-import { elementService } from "../Service/ElementService";
|
|
|
-import { wallService } from "../Service/WallService";
|
|
|
import { historyUtil } from "./HistoryUtil";
|
|
|
import { change } from "./Change";
|
|
|
-import { symbolService } from "../Service/SymbolService";
|
|
|
import { stateService } from "../Service/StateService";
|
|
|
import HistoryEvents from "../enum/HistoryEvents";
|
|
|
-import { componentService } from "../Service/ComponentService";
|
|
|
import { historyService } from "../Service/HistoryService";
|
|
|
import { tagService } from "../Service/TagService";
|
|
|
-import { coordinate } from "../Coordinate";
|
|
|
import { measureService } from "../Service/MeasureService";
|
|
|
-import { furnitureService } from "../Service/FurnitureService";
|
|
|
+import { roadService } from "../Service/RoadService";
|
|
|
+import { pointService } from "../Service/PointService";
|
|
|
|
|
|
export default class History {
|
|
|
constructor(layer) {
|
|
@@ -21,13 +17,13 @@ export default class History {
|
|
|
init() {
|
|
|
change.saveCurrentInfo();
|
|
|
const points = dataService.getPoints();
|
|
|
- if (Object.keys(points).length > 0) {
|
|
|
- this.layer.$xui.toolbar.clear = true;
|
|
|
- this.layer.$xui.toolbar.download = true;
|
|
|
- } else {
|
|
|
- this.layer.$xui.toolbar.clear = false;
|
|
|
- this.layer.$xui.toolbar.download = false;
|
|
|
- }
|
|
|
+ // if (Object.keys(points).length > 0) {
|
|
|
+ // this.layer.$xui.toolbar.clear = true;
|
|
|
+ // this.layer.$xui.toolbar.download = true;
|
|
|
+ // } else {
|
|
|
+ // this.layer.$xui.toolbar.clear = false;
|
|
|
+ // this.layer.$xui.toolbar.download = false;
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
save() {
|
|
@@ -36,28 +32,27 @@ export default class History {
|
|
|
return;
|
|
|
}
|
|
|
measureService.update();
|
|
|
- historyService.addHistoryRecord(change.elements);
|
|
|
+ historyService.addHistoryRecord(change.currentData);
|
|
|
change.saveCurrentInfo();
|
|
|
this.setState();
|
|
|
const historyState = historyService.getHistoryState();
|
|
|
- if (historyState.pre) {
|
|
|
- this.layer.$xui.toolbar.recall = true;
|
|
|
- }
|
|
|
- this.layer.$xui.toolbar.recover = false;
|
|
|
+ // if (historyState.pre) {
|
|
|
+ // this.layer.$xui.toolbar.recall = true;
|
|
|
+ // }
|
|
|
+ // this.layer.$xui.toolbar.recover = false;
|
|
|
|
|
|
const points = dataService.getPoints();
|
|
|
- if (Object.keys(points).length > 0) {
|
|
|
- this.layer.$xui.toolbar.clear = true;
|
|
|
- this.layer.$xui.toolbar.download = true;
|
|
|
- } else {
|
|
|
- this.layer.$xui.toolbar.clear = false;
|
|
|
- this.layer.$xui.toolbar.download = false;
|
|
|
- }
|
|
|
+ // if (Object.keys(points).length > 0) {
|
|
|
+ // this.layer.$xui.toolbar.clear = true;
|
|
|
+ // this.layer.$xui.toolbar.download = true;
|
|
|
+ // } else {
|
|
|
+ // this.layer.$xui.toolbar.clear = false;
|
|
|
+ // this.layer.$xui.toolbar.download = false;
|
|
|
+ // }
|
|
|
|
|
|
//给UI发送事件
|
|
|
this.layer.emit("change");
|
|
|
-
|
|
|
- return change.elements;
|
|
|
+ return change.currentData;
|
|
|
}
|
|
|
|
|
|
setState() {
|
|
@@ -118,39 +113,25 @@ export default class History {
|
|
|
if (item) {
|
|
|
stateService.clearFocusItem();
|
|
|
stateService.clearEventName();
|
|
|
- //this.layer.$xui.hideProps()
|
|
|
- this.layer.uiControl.currentUI = null;
|
|
|
+ //this.layer.uiControl.currentUI = null;
|
|
|
item.type = "pre";
|
|
|
- let flag = false;
|
|
|
- if (item.rotate == null) {
|
|
|
- flag = false;
|
|
|
- } else {
|
|
|
- flag = this.goPreForAngle(item.rotate);
|
|
|
- }
|
|
|
-
|
|
|
- if (!flag) {
|
|
|
- this.goPreForPoints(item.points);
|
|
|
- this.goPreForWalls(item.walls);
|
|
|
- // 必须在墙的后面,因为删除带symbol的墙的时候,撤销时,必须是先有墙才有symbol
|
|
|
- this.goPreForSymbols(item.symbols);
|
|
|
- this.goPreForComponents(item.components);
|
|
|
- this.goPreForTags(item.tags);
|
|
|
- this.goPreForFurnitures(item.furnitures);
|
|
|
- }
|
|
|
+ this.goPreForPoints(item.points);
|
|
|
+ this.goPreForRoads(item.roads);
|
|
|
+ this.goPreForTags(item.tags);
|
|
|
|
|
|
measureService.update();
|
|
|
historyService.undoHistoryRecord();
|
|
|
change.saveCurrentInfo();
|
|
|
this.setState();
|
|
|
|
|
|
- const points = dataService.getPoints();
|
|
|
- if (Object.keys(points).length > 0) {
|
|
|
- this.layer.$xui.toolbar.clear = true;
|
|
|
- this.layer.$xui.toolbar.download = true;
|
|
|
- } else {
|
|
|
- this.layer.$xui.toolbar.clear = false;
|
|
|
- this.layer.$xui.toolbar.download = false;
|
|
|
- }
|
|
|
+ // const points = dataService.getPoints();
|
|
|
+ // if (Object.keys(points).length > 0) {
|
|
|
+ // this.layer.$xui.toolbar.clear = true;
|
|
|
+ // this.layer.$xui.toolbar.download = true;
|
|
|
+ // } else {
|
|
|
+ // this.layer.$xui.toolbar.clear = false;
|
|
|
+ // this.layer.$xui.toolbar.download = false;
|
|
|
+ // }
|
|
|
} else {
|
|
|
console.error("goPreState超出范围!");
|
|
|
}
|
|
@@ -162,11 +143,7 @@ export default class History {
|
|
|
if (item.handle == HistoryEvents.AddPoint) {
|
|
|
historyUtil.deletePoint(item.point.id);
|
|
|
} else if (item.handle == HistoryEvents.DeletePoint) {
|
|
|
- let point = wallService.createPoint(
|
|
|
- item.point.x,
|
|
|
- item.point.y,
|
|
|
- item.point.id
|
|
|
- );
|
|
|
+ let point = pointService.create(item.point, item.point.id);
|
|
|
point.parent = JSON.parse(JSON.stringify(item.point.parent));
|
|
|
} else if (item.handle == HistoryEvents.ModifyPoint) {
|
|
|
const prePoint = item.prePoint;
|
|
@@ -176,91 +153,23 @@ export default class History {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- goPreForWalls(itemForWalls) {
|
|
|
- for (let i = 0; i < itemForWalls.length; ++i) {
|
|
|
- const item = itemForWalls[i];
|
|
|
+ goPreForRoads(itemForRoads) {
|
|
|
+ for (let i = 0; i < itemForRoads.length; ++i) {
|
|
|
+ const item = itemForRoads[i];
|
|
|
if (item.handle == HistoryEvents.AddRoad) {
|
|
|
- dataService.deleteWallNoSymbol(item.wall.id);
|
|
|
- } else if (item.handle == HistoryEvents.DeleteWall) {
|
|
|
- const preWall = item.wall;
|
|
|
- let newWall = wallService.createWall(
|
|
|
- preWall.start,
|
|
|
- preWall.end,
|
|
|
- preWall.id
|
|
|
- );
|
|
|
- historyUtil.assignWallFromWall(newWall, preWall);
|
|
|
- } else if (item.handle == HistoryEvents.ModifyWall) {
|
|
|
- const preWall = item.preWall;
|
|
|
- let currentWall = dataService.getWall(item.curWall.id);
|
|
|
- historyUtil.assignWallFromWall(currentWall, preWall);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- goPreForSymbols(itemForSymbols) {
|
|
|
- for (let i = 0; i < itemForSymbols.length; ++i) {
|
|
|
- const item = itemForSymbols[i];
|
|
|
- if (item.handle == HistoryEvents.AddSymbol) {
|
|
|
- symbolService.deleteSymbol(item.symbol.id);
|
|
|
- } else if (item.handle == HistoryEvents.DeleteSymbol) {
|
|
|
- let newSymbol = symbolService.createSymbol(
|
|
|
- item.symbol.start,
|
|
|
- item.symbol.end,
|
|
|
- item.symbol.type,
|
|
|
- item.symbol.parent,
|
|
|
- item.symbol.id
|
|
|
- );
|
|
|
- historyUtil.assignSymbolFromSymbol(newSymbol, item.symbol);
|
|
|
- } else if (item.handle == HistoryEvents.ModifySymbol) {
|
|
|
- const preSymbol = item.preSymbol;
|
|
|
- let currentSymbol = dataService.getSymbol(item.curSymbol.id);
|
|
|
- historyUtil.assignSymbolFromSymbol(currentSymbol, preSymbol);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- goPreForComponents(itemForComponents) {
|
|
|
- for (let i = 0; i < itemForComponents.length; ++i) {
|
|
|
- const item = itemForComponents[i];
|
|
|
- if (item.handle == HistoryEvents.AddComponent) {
|
|
|
- dataService.deleteComponent(item.component.id);
|
|
|
- } else if (item.handle == HistoryEvents.DeleteComponent) {
|
|
|
- let vComponent = componentService.createComponent(
|
|
|
- item.component.center,
|
|
|
- item.component.type,
|
|
|
- item.component.id
|
|
|
- );
|
|
|
- historyUtil.assignComponentFromComponent(vComponent, item.component);
|
|
|
- } else if (item.handle == HistoryEvents.ModifyComponent) {
|
|
|
- const preComponent = item.preComponent;
|
|
|
- let currentComponent = dataService.getComponent(item.curComponent.id);
|
|
|
- historyUtil.assignComponentFromComponent(
|
|
|
- currentComponent,
|
|
|
- preComponent
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- goPreForFurnitures(itemForFurnitures) {
|
|
|
- for (let i = 0; i < itemForFurnitures.length; ++i) {
|
|
|
- const item = itemForFurnitures[i];
|
|
|
- if (item.handle == HistoryEvents.AddFurniture) {
|
|
|
- dataService.deleteFurniture(item.furniture.id);
|
|
|
- } else if (item.handle == HistoryEvents.DeleteFurniture) {
|
|
|
- let vFurniture = furnitureService.createFurniture(
|
|
|
- item.furniture.center,
|
|
|
- item.furniture.type,
|
|
|
- item.furniture.id
|
|
|
- );
|
|
|
- historyUtil.assignFurnitureFromFurniture(vFurniture, item.furniture);
|
|
|
- } else if (item.handle == HistoryEvents.ModifyFurniture) {
|
|
|
- const preFurniture = item.preFurniture;
|
|
|
- let currentFurniture = dataService.getFurniture(item.curFurniture.id);
|
|
|
- historyUtil.assignFurnitureFromFurniture(
|
|
|
- currentFurniture,
|
|
|
- preFurniture
|
|
|
+ dataService.deleteRoad(item.road.id);
|
|
|
+ } else if (item.handle == HistoryEvents.DeleteRoad) {
|
|
|
+ const preRoad = item.road;
|
|
|
+ let newRoad = roadService.create(
|
|
|
+ preRoad.start,
|
|
|
+ preRoad.end,
|
|
|
+ preRoad.id
|
|
|
);
|
|
|
+ historyUtil.assignRoadFromRoad(newRoad, preRoad);
|
|
|
+ } else if (item.handle == HistoryEvents.ModifyRoad) {
|
|
|
+ const preRoad = item.preRoad;
|
|
|
+ let currentRoad = dataService.getRoad(item.curRoad.id);
|
|
|
+ historyUtil.assignRoadFromRoad(currentRoad, preRoad);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -281,39 +190,11 @@ export default class History {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- goPreForAngle(itemForAngle) {
|
|
|
- if (itemForAngle.handle == HistoryEvents.ModifyAngle) {
|
|
|
- coordinate.reSet();
|
|
|
- coordinate._setRes(itemForAngle.preState.res);
|
|
|
- //旋转cad
|
|
|
- dataService.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(dataService.getCurrentFloor());
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
goNextForPoints(itemForPoints) {
|
|
|
for (let i = 0; i < itemForPoints.length; ++i) {
|
|
|
const item = itemForPoints[i];
|
|
|
if (item.handle == HistoryEvents.AddPoint) {
|
|
|
- let newPoint = wallService.createPoint(
|
|
|
- item.point.x,
|
|
|
- item.point.y,
|
|
|
- item.point.id
|
|
|
- );
|
|
|
+ let newPoint = pointService.create(item.point, item.point.id);
|
|
|
historyUtil.assignPointFromPoint(newPoint, item.point);
|
|
|
} else if (item.handle == HistoryEvents.DeletePoint) {
|
|
|
historyUtil.deletePoint(item.point.id);
|
|
@@ -325,68 +206,23 @@ export default class History {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- goNextForWalls(itemForWalls) {
|
|
|
- for (let i = 0; i < itemForWalls.length; ++i) {
|
|
|
- const item = itemForWalls[i];
|
|
|
+ goNextForRoads(itemForRoads) {
|
|
|
+ for (let i = 0; i < itemForRoads.length; ++i) {
|
|
|
+ const item = itemForRoads[i];
|
|
|
if (item.handle == HistoryEvents.AddRoad) {
|
|
|
- const preWall = item.wall;
|
|
|
- let newWall = wallService.createWall(
|
|
|
- preWall.start,
|
|
|
- preWall.end,
|
|
|
- preWall.id
|
|
|
- );
|
|
|
- historyUtil.assignWallFromWall(newWall, preWall);
|
|
|
- } else if (item.handle == HistoryEvents.DeleteWall) {
|
|
|
- dataService.deleteWallNoSymbol(item.wall.id);
|
|
|
- } else if (item.handle == HistoryEvents.ModifyWall) {
|
|
|
- const currentWall = item.curWall;
|
|
|
- let preWall = dataService.getWall(item.preWall.id);
|
|
|
- historyUtil.assignWallFromWall(preWall, currentWall);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- goNextForSymbols(itemForSymbols) {
|
|
|
- for (let i = 0; i < itemForSymbols.length; ++i) {
|
|
|
- const item = itemForSymbols[i];
|
|
|
- if (item.handle == HistoryEvents.AddSymbol) {
|
|
|
- let newSymbol = symbolService.createSymbol(
|
|
|
- item.symbol.start,
|
|
|
- item.symbol.end,
|
|
|
- item.symbol.type,
|
|
|
- item.symbol.parent,
|
|
|
- item.symbol.id
|
|
|
- );
|
|
|
- historyUtil.assignSymbolFromSymbol(newSymbol, item.symbol);
|
|
|
- } else if (item.handle == HistoryEvents.DeleteSymbol) {
|
|
|
- symbolService.deleteSymbol(item.symbol.id);
|
|
|
- } else if (item.handle == HistoryEvents.ModifySymbol) {
|
|
|
- const currentSymbol = item.curSymbol;
|
|
|
- let preSymbol = dataService.getSymbol(item.curSymbol.id);
|
|
|
- historyUtil.assignSymbolFromSymbol(preSymbol, currentSymbol);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- goNextForComponents(itemForComponents) {
|
|
|
- for (let i = 0; i < itemForComponents.length; ++i) {
|
|
|
- const item = itemForComponents[i];
|
|
|
- if (item.handle == HistoryEvents.AddComponent) {
|
|
|
- let vComponent = componentService.createComponent(
|
|
|
- item.component.center,
|
|
|
- item.component.type,
|
|
|
- item.component.id
|
|
|
- );
|
|
|
- historyUtil.assignComponentFromComponent(vComponent, item.component);
|
|
|
- } else if (item.handle == HistoryEvents.DeleteComponent) {
|
|
|
- dataService.deleteComponent(item.component.id);
|
|
|
- } else if (item.handle == HistoryEvents.ModifyComponent) {
|
|
|
- const currentComponent = item.curComponent;
|
|
|
- let preComponent = dataService.getComponent(item.curComponent.id);
|
|
|
- historyUtil.assignComponentFromComponent(
|
|
|
- preComponent,
|
|
|
- currentComponent
|
|
|
+ const preRoad = item.road;
|
|
|
+ let newRoad = roadService.create(
|
|
|
+ preRoad.start,
|
|
|
+ preRoad.end,
|
|
|
+ preRoad.id
|
|
|
);
|
|
|
+ historyUtil.assignRoadFromRoad(newRoad, preRoad);
|
|
|
+ } else if (item.handle == HistoryEvents.DeleteRoad) {
|
|
|
+ dataService.deleteRoad(item.road.id);
|
|
|
+ } else if (item.handle == HistoryEvents.ModifyRoad) {
|
|
|
+ const currentRoad = item.curRoad;
|
|
|
+ let preRoad = dataService.getRoad(item.preRoad.id);
|
|
|
+ historyUtil.assignRoadFromRoad(preRoad, currentRoad);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -407,53 +243,6 @@ export default class History {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- goNextForFurnitures(itemForFurnitures) {
|
|
|
- for (let i = 0; i < itemForFurnitures.length; ++i) {
|
|
|
- const item = itemForFurnitures[i];
|
|
|
- if (item.handle == HistoryEvents.AddFurniture) {
|
|
|
- let vFurniture = furnitureService.createFurniture(
|
|
|
- item.furniture.center,
|
|
|
- item.furniture.type,
|
|
|
- item.furniture.id
|
|
|
- );
|
|
|
- historyUtil.assignFurnitureFromFurniture(vFurniture, item.furniture);
|
|
|
- } else if (item.handle == HistoryEvents.DeleteFurniture) {
|
|
|
- dataService.deleteFurniture(item.furniture.id);
|
|
|
- } else if (item.handle == HistoryEvents.ModifyFurniture) {
|
|
|
- const currentFurniture = item.curFurniture;
|
|
|
- let preFurniture = dataService.getFurniture(item.curFurniture.id);
|
|
|
- historyUtil.assignFurnitureFromFurniture(
|
|
|
- preFurniture,
|
|
|
- currentFurniture
|
|
|
- );
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- goNextForAngle(itemForAngle) {
|
|
|
- if (itemForAngle.handle == HistoryEvents.ModifyAngle) {
|
|
|
- coordinate.reSet();
|
|
|
- coordinate._setRes(itemForAngle.curState.res);
|
|
|
- //旋转cad
|
|
|
- dataService.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(dataService.getCurrentFloor());
|
|
|
- return true;
|
|
|
- } else {
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
// 恢复
|
|
|
goNextState() {
|
|
|
historyService.redoHistoryRecord();
|
|
@@ -461,34 +250,21 @@ export default class History {
|
|
|
if (item) {
|
|
|
stateService.clearFocusItem();
|
|
|
stateService.clearEventName();
|
|
|
- //this.layer.$xui.hideProps()
|
|
|
- this.layer.uiControl.currentUI = null;
|
|
|
- let flag = false;
|
|
|
- if (item.rotate == null) {
|
|
|
- flag = false;
|
|
|
- } else {
|
|
|
- flag = this.goNextForAngle(item.rotate);
|
|
|
- }
|
|
|
- if (!flag) {
|
|
|
- this.goNextForPoints(item.points);
|
|
|
- this.goNextForWalls(item.walls);
|
|
|
- this.goNextForSymbols(item.symbols);
|
|
|
- this.goNextForComponents(item.components);
|
|
|
- this.goNextForTags(item.tags);
|
|
|
- this.goNextForFurnitures(item.furnitures);
|
|
|
- }
|
|
|
- measureService.update();
|
|
|
+ //this.layer.uiControl.currentUI = null;
|
|
|
+ this.goNextForPoints(item.points);
|
|
|
+ this.goNextForRoads(item.roads);
|
|
|
+ this.goNextForTags(item.tags);
|
|
|
change.saveCurrentInfo();
|
|
|
this.setState();
|
|
|
|
|
|
- const points = dataService.getPoints();
|
|
|
- if (Object.keys(points).length > 0) {
|
|
|
- this.layer.$xui.toolbar.clear = true;
|
|
|
- this.layer.$xui.toolbar.download = true;
|
|
|
- } else {
|
|
|
- this.layer.$xui.toolbar.clear = false;
|
|
|
- this.layer.$xui.toolbar.download = false;
|
|
|
- }
|
|
|
+ // const points = dataService.getPoints();
|
|
|
+ // if (Object.keys(points).length > 0) {
|
|
|
+ // this.layer.$xui.toolbar.clear = true;
|
|
|
+ // this.layer.$xui.toolbar.download = true;
|
|
|
+ // } else {
|
|
|
+ // this.layer.$xui.toolbar.clear = false;
|
|
|
+ // this.layer.$xui.toolbar.download = false;
|
|
|
+ // }
|
|
|
} else {
|
|
|
historyService.undoHistoryRecord();
|
|
|
console.error("goNextState超出范围!");
|