|
@@ -23,6 +23,7 @@ import { mathUtil } from "./Util/MathUtil";
|
|
import History from "./History/History";
|
|
import History from "./History/History";
|
|
import { keyService } from "./Service/KeyService";
|
|
import { keyService } from "./Service/KeyService";
|
|
import mitt from "mitt";
|
|
import mitt from "mitt";
|
|
|
|
+import { roadService } from "./Service/RoadService";
|
|
|
|
|
|
export default class Layer {
|
|
export default class Layer {
|
|
constructor(canvas) {
|
|
constructor(canvas) {
|
|
@@ -36,10 +37,7 @@ export default class Layer {
|
|
this.display = false;
|
|
this.display = false;
|
|
this.mousePosition = null;
|
|
this.mousePosition = null;
|
|
|
|
|
|
- setTimeout(() => {
|
|
|
|
- console.log(this);
|
|
|
|
- this.start();
|
|
|
|
- });
|
|
|
|
|
|
+ this.start();
|
|
|
|
|
|
Object.setPrototypeOf(Object.getPrototypeOf(this), mitt());
|
|
Object.setPrototypeOf(Object.getPrototypeOf(this), mitt());
|
|
}
|
|
}
|
|
@@ -50,9 +48,12 @@ export default class Layer {
|
|
this.canvas.height = this.canvas.clientHeight;
|
|
this.canvas.height = this.canvas.clientHeight;
|
|
coordinate.init(this.canvas);
|
|
coordinate.init(this.canvas);
|
|
draw.initContext(this.canvas);
|
|
draw.initContext(this.canvas);
|
|
|
|
+ dataService.initVectorData();
|
|
this.history.init();
|
|
this.history.init();
|
|
this.bindEvents();
|
|
this.bindEvents();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ window.vectorData = dataService.vectorData;
|
|
}
|
|
}
|
|
|
|
|
|
bindEvents() {
|
|
bindEvents() {
|
|
@@ -88,19 +89,28 @@ export default class Layer {
|
|
const eventName = stateService.getEventName();
|
|
const eventName = stateService.getEventName();
|
|
//点击第一次
|
|
//点击第一次
|
|
if (eventName == LayerEvents.AddRoad) {
|
|
if (eventName == LayerEvents.AddRoad) {
|
|
- let flag = this.setNewRoadPoint("start", {
|
|
|
|
- x: this.startX,
|
|
|
|
- y: this.startY,
|
|
|
|
- });
|
|
|
|
|
|
+ let flag = addRoad.setNewRoadPoint(
|
|
|
|
+ "start",
|
|
|
|
+ coordinate.getXYFromScreen({
|
|
|
|
+ x: this.startX,
|
|
|
|
+ y: this.startY,
|
|
|
|
+ }),
|
|
|
|
+ listenLayer.modifyPoint
|
|
|
|
+ );
|
|
if (!flag) {
|
|
if (!flag) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//点击第二次
|
|
//点击第二次
|
|
else if (eventName == LayerEvents.AddingRoad) {
|
|
else if (eventName == LayerEvents.AddingRoad) {
|
|
- let flag = this.setNewRoadPoint(
|
|
|
|
|
|
+ let flag = addRoad.setNewRoadPoint(
|
|
"end",
|
|
"end",
|
|
- coordinate.getScreenXY(elementService.newWall.end)
|
|
|
|
|
|
+ //elementService.newWall.end,
|
|
|
|
+ coordinate.getXYFromScreen({
|
|
|
|
+ x: this.startX,
|
|
|
|
+ y: this.startY,
|
|
|
|
+ }),
|
|
|
|
+ listenLayer.modifyPoint
|
|
);
|
|
);
|
|
if (!flag) {
|
|
if (!flag) {
|
|
return;
|
|
return;
|
|
@@ -153,16 +163,14 @@ export default class Layer {
|
|
switch (eventName) {
|
|
switch (eventName) {
|
|
case null:
|
|
case null:
|
|
//监控
|
|
//监控
|
|
- needAutoRedraw = listenLayer.start(position);
|
|
|
|
|
|
+ //needAutoRedraw = listenLayer.start(position);
|
|
break;
|
|
break;
|
|
case LayerEvents.PanBackGround:
|
|
case LayerEvents.PanBackGround:
|
|
stateService.clearItems();
|
|
stateService.clearItems();
|
|
coordinate.center.x =
|
|
coordinate.center.x =
|
|
- coordinate.center.x -
|
|
|
|
- (dx * Constant.defaultZoom) / coordinate.zoom / coordinate.res;
|
|
|
|
|
|
+ coordinate.center.x - (dx * coordinate.defaultZoom) / coordinate.zoom;
|
|
coordinate.center.y =
|
|
coordinate.center.y =
|
|
- coordinate.center.y +
|
|
|
|
- (dy * Constant.defaultZoom) / coordinate.zoom / coordinate.res;
|
|
|
|
|
|
+ coordinate.center.y + (dy * coordinate.defaultZoom) / coordinate.zoom;
|
|
this.lastX = X;
|
|
this.lastX = X;
|
|
this.lastY = Y;
|
|
this.lastY = Y;
|
|
needAutoRedraw = true;
|
|
needAutoRedraw = true;
|
|
@@ -171,7 +179,7 @@ export default class Layer {
|
|
stateService.clearDraggingItem();
|
|
stateService.clearDraggingItem();
|
|
stateService.clearFocusItem();
|
|
stateService.clearFocusItem();
|
|
needAutoRedraw = true;
|
|
needAutoRedraw = true;
|
|
- listenLayer.start(position);
|
|
|
|
|
|
+ //listenLayer.start(position);
|
|
if (listenLayer.modifyPoint) {
|
|
if (listenLayer.modifyPoint) {
|
|
position = {
|
|
position = {
|
|
x: listenLayer.modifyPoint.x,
|
|
x: listenLayer.modifyPoint.x,
|
|
@@ -186,7 +194,7 @@ export default class Layer {
|
|
stateService.clearDraggingItem();
|
|
stateService.clearDraggingItem();
|
|
stateService.clearFocusItem();
|
|
stateService.clearFocusItem();
|
|
needAutoRedraw = true;
|
|
needAutoRedraw = true;
|
|
- listenLayer.start(position);
|
|
|
|
|
|
+ //listenLayer.start(position);
|
|
let startPosition = {
|
|
let startPosition = {
|
|
x: addRoad.startInfo.position.x,
|
|
x: addRoad.startInfo.position.x,
|
|
y: addRoad.startInfo.position.y,
|
|
y: addRoad.startInfo.position.y,
|
|
@@ -218,7 +226,7 @@ export default class Layer {
|
|
// elementService.setNewWallEndPosition(position); //改变end位置
|
|
// elementService.setNewWallEndPosition(position); //改变end位置
|
|
// }
|
|
// }
|
|
|
|
|
|
- addRoad.canAdd = addRoad.canAddWallForEnd(position);
|
|
|
|
|
|
+ addRoad.canAdd = addRoad.canAddRoadForEnd(position);
|
|
// if (!addRoad.canAdd) {
|
|
// if (!addRoad.canAdd) {
|
|
// elementService.setNewWallState("error");
|
|
// elementService.setNewWallState("error");
|
|
// } else {
|
|
// } else {
|
|
@@ -230,8 +238,8 @@ export default class Layer {
|
|
// }
|
|
// }
|
|
break;
|
|
break;
|
|
case LayerEvents.MoveRoad:
|
|
case LayerEvents.MoveRoad:
|
|
- dx = (dx * Constant.defaultZoom) / coordinate.zoom;
|
|
|
|
- dy = (dy * Constant.defaultZoom) / coordinate.zoom;
|
|
|
|
|
|
+ dx = (dx * coordinate.defaultZoom) / coordinate.zoom;
|
|
|
|
+ dy = (dy * coordinate.defaultZoom) / coordinate.zoom;
|
|
// 1表示可以继续移动,2表示不能移动(启动距离还不够),3表示wallId被删除了,4表示重新开始移动(需要达到一定距离才能启动),5表示不能移动(不合适)
|
|
// 1表示可以继续移动,2表示不能移动(启动距离还不够),3表示wallId被删除了,4表示重新开始移动(需要达到一定距离才能启动),5表示不能移动(不合适)
|
|
let moveFlag = moveRoad.moveWallPlane(draggingItem.vectorId, dx, dy);
|
|
let moveFlag = moveRoad.moveWallPlane(draggingItem.vectorId, dx, dy);
|
|
// 启动的时候需要点距离,所以真正移动了才更新lastX和lastY
|
|
// 启动的时候需要点距离,所以真正移动了才更新lastX和lastY
|
|
@@ -265,9 +273,9 @@ export default class Layer {
|
|
}
|
|
}
|
|
|
|
|
|
break;
|
|
break;
|
|
- case LayerEvents.MoveWallPoint:
|
|
|
|
|
|
+ case LayerEvents.MoveRoadPoint:
|
|
let point = dataService.getPoint(draggingItem.vectorId);
|
|
let point = dataService.getPoint(draggingItem.vectorId);
|
|
- listenLayer.start(position, draggingItem.vectorId, point.parent);
|
|
|
|
|
|
+ //listenLayer.start(position, draggingItem.vectorId, point.parent);
|
|
if (listenLayer.modifyPoint) {
|
|
if (listenLayer.modifyPoint) {
|
|
position = {
|
|
position = {
|
|
x: listenLayer.modifyPoint.x,
|
|
x: listenLayer.modifyPoint.x,
|
|
@@ -284,7 +292,7 @@ export default class Layer {
|
|
elementService.hideAll();
|
|
elementService.hideAll();
|
|
} else {
|
|
} else {
|
|
point = dataService.getPoint(draggingItem.vectorId);
|
|
point = dataService.getPoint(draggingItem.vectorId);
|
|
- listenLayer.start(point, draggingItem.vectorId, point.parent);
|
|
|
|
|
|
+ //listenLayer.start(point, draggingItem.vectorId, point.parent);
|
|
let otherPoint = null;
|
|
let otherPoint = null;
|
|
if (
|
|
if (
|
|
listenLayer.modifyPoint &&
|
|
listenLayer.modifyPoint &&
|
|
@@ -313,172 +321,6 @@ export default class Layer {
|
|
}
|
|
}
|
|
needAutoRedraw = true;
|
|
needAutoRedraw = true;
|
|
break;
|
|
break;
|
|
- // case LayerEvents.AddSymbol:
|
|
|
|
- // listenLayer.start(position);
|
|
|
|
- // //最近的墙
|
|
|
|
- // if (listenLayer.wallInfo.wallId) {
|
|
|
|
- // needAutoRedraw = true;
|
|
|
|
- // if (draggingItem == null) {
|
|
|
|
- // const symbolType = this.uiControl.getSymbolTypeForUI();
|
|
|
|
- // let symbolId = symbolService.addSymbol(
|
|
|
|
- // position,
|
|
|
|
- // symbolType,
|
|
|
|
- // listenLayer.wallInfo.wallId
|
|
|
|
- // );
|
|
|
|
- // if (symbolId) {
|
|
|
|
- // stateService.setSelectItem(symbolId, symbolType, SelectState.All);
|
|
|
|
- // stateService.setDraggingItem(stateService.selectItem);
|
|
|
|
- // //let symbol = dataService.getSymbol(symbolId)
|
|
|
|
- // }
|
|
|
|
- // } else {
|
|
|
|
- // moveSymbol.moveFullSymbol(
|
|
|
|
- // position,
|
|
|
|
- // draggingItem.vectorId,
|
|
|
|
- // listenLayer.wallInfo.wallId
|
|
|
|
- // );
|
|
|
|
- // }
|
|
|
|
- // } else {
|
|
|
|
- // needAutoRedraw = false;
|
|
|
|
- // }
|
|
|
|
- // break;
|
|
|
|
- // case LayerEvents.MoveSymbol:
|
|
|
|
- // listenLayer.start(position);
|
|
|
|
- // needAutoRedraw = true;
|
|
|
|
- // if (draggingItem != null && symbolService.isSymbol(draggingItem.type)) {
|
|
|
|
- // moveSymbol.moveFullSymbol(
|
|
|
|
- // position,
|
|
|
|
- // draggingItem.vectorId,
|
|
|
|
- // listenLayer.wallInfo.wallId
|
|
|
|
- // );
|
|
|
|
- // }
|
|
|
|
- // break;
|
|
|
|
- // case LayerEvents.MoveSymbolPoint:
|
|
|
|
- // needAutoRedraw = true;
|
|
|
|
- // if (draggingItem != null && symbolService.isSymbol(draggingItem.type)) {
|
|
|
|
- // //移动symbol的端点
|
|
|
|
- // moveSymbol.moveSymbolPoint(
|
|
|
|
- // position,
|
|
|
|
- // draggingItem.vectorId,
|
|
|
|
- // draggingItem.selectIndex
|
|
|
|
- // );
|
|
|
|
- // }
|
|
|
|
- // break;
|
|
|
|
- // case LayerEvents.AddComponent:
|
|
|
|
- // needAutoRedraw = true;
|
|
|
|
- // if (draggingItem == null) {
|
|
|
|
- // const componentType = this.uiControl.getComponentTypeForUI();
|
|
|
|
- // const component = componentService.createComponent(
|
|
|
|
- // position,
|
|
|
|
- // componentType
|
|
|
|
- // );
|
|
|
|
- // if (component.vectorId) {
|
|
|
|
- // stateService.setSelectItem(
|
|
|
|
- // component.vectorId,
|
|
|
|
- // componentType,
|
|
|
|
- // SelectState.All
|
|
|
|
- // );
|
|
|
|
- // stateService.setDraggingItem(stateService.selectItem);
|
|
|
|
- // }
|
|
|
|
- // } else {
|
|
|
|
- // moveRectangle.setStart(
|
|
|
|
- // position,
|
|
|
|
- // draggingItem.vectorId,
|
|
|
|
- // draggingItem.type
|
|
|
|
- // );
|
|
|
|
- // moveRectangle.moveFull(
|
|
|
|
- // position,
|
|
|
|
- // draggingItem.vectorId,
|
|
|
|
- // draggingItem.type
|
|
|
|
- // );
|
|
|
|
- // }
|
|
|
|
- // break;
|
|
|
|
- // case LayerEvents.MoveComponent:
|
|
|
|
- // needAutoRedraw = true;
|
|
|
|
- // if (
|
|
|
|
- // draggingItem != null &&
|
|
|
|
- // componentService.isComponent(draggingItem.type)
|
|
|
|
- // ) {
|
|
|
|
- // moveRectangle.setStart(
|
|
|
|
- // position,
|
|
|
|
- // draggingItem.vectorId,
|
|
|
|
- // draggingItem.type
|
|
|
|
- // );
|
|
|
|
- // moveRectangle.moveFull(
|
|
|
|
- // position,
|
|
|
|
- // draggingItem.vectorId,
|
|
|
|
- // draggingItem.type
|
|
|
|
- // );
|
|
|
|
- // }
|
|
|
|
- // break;
|
|
|
|
- // case LayerEvents.AddTag:
|
|
|
|
- // needAutoRedraw = true;
|
|
|
|
- // if (draggingItem == null) {
|
|
|
|
- // const tag = tagService.createTag(position);
|
|
|
|
- // if (tag.vectorId) {
|
|
|
|
- // stateService.setSelectItem(
|
|
|
|
- // tag.vectorId,
|
|
|
|
- // VectorType.Tag,
|
|
|
|
- // SelectState.All
|
|
|
|
- // );
|
|
|
|
- // stateService.setDraggingItem(stateService.selectItem);
|
|
|
|
- // }
|
|
|
|
- // } else {
|
|
|
|
- // moveTag.moveFullTag(position, draggingItem.vectorId);
|
|
|
|
- // }
|
|
|
|
- // break;
|
|
|
|
- // case LayerEvents.MoveTag:
|
|
|
|
- // needAutoRedraw = true;
|
|
|
|
- // if (draggingItem != null) {
|
|
|
|
- // moveTag.moveFullTag(position, draggingItem.vectorId);
|
|
|
|
- // }
|
|
|
|
- // break;
|
|
|
|
- // case LayerEvents.AddFurniture:
|
|
|
|
- // needAutoRedraw = true;
|
|
|
|
- // if (draggingItem == null) {
|
|
|
|
- // const furnitureType = this.uiControl.getFurnitureTypeForUI();
|
|
|
|
- // const furniture = furnitureService.createFurniture(
|
|
|
|
- // position,
|
|
|
|
- // furnitureType
|
|
|
|
- // );
|
|
|
|
- // if (furniture.vectorId) {
|
|
|
|
- // stateService.setSelectItem(
|
|
|
|
- // furniture.vectorId,
|
|
|
|
- // furnitureType,
|
|
|
|
- // SelectState.All
|
|
|
|
- // );
|
|
|
|
- // stateService.setDraggingItem(stateService.selectItem);
|
|
|
|
- // }
|
|
|
|
- // } else {
|
|
|
|
- // moveRectangle.setStart(
|
|
|
|
- // position,
|
|
|
|
- // draggingItem.vectorId,
|
|
|
|
- // draggingItem.type
|
|
|
|
- // );
|
|
|
|
- // moveRectangle.moveFull(
|
|
|
|
- // position,
|
|
|
|
- // draggingItem.vectorId,
|
|
|
|
- // draggingItem.type
|
|
|
|
- // );
|
|
|
|
- // }
|
|
|
|
- // break;
|
|
|
|
- // case LayerEvents.MoveFurniture:
|
|
|
|
- // needAutoRedraw = true;
|
|
|
|
- // if (
|
|
|
|
- // draggingItem != null &&
|
|
|
|
- // furnitureService.isFurniture(draggingItem.type)
|
|
|
|
- // ) {
|
|
|
|
- // moveRectangle.setStart(
|
|
|
|
- // position,
|
|
|
|
- // draggingItem.vectorId,
|
|
|
|
- // draggingItem.type
|
|
|
|
- // );
|
|
|
|
- // moveRectangle.moveFull(
|
|
|
|
- // position,
|
|
|
|
- // draggingItem.vectorId,
|
|
|
|
- // draggingItem.type
|
|
|
|
- // );
|
|
|
|
- // }
|
|
|
|
- // break;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
if (needAutoRedraw) {
|
|
if (needAutoRedraw) {
|
|
@@ -522,12 +364,12 @@ export default class Layer {
|
|
stateService.clearFocusItem();
|
|
stateService.clearFocusItem();
|
|
this.uiControl.currentUI = null;
|
|
this.uiControl.currentUI = null;
|
|
break;
|
|
break;
|
|
- case LayerEvents.MoveWallPoint:
|
|
|
|
|
|
+ case LayerEvents.MoveRoadPoint:
|
|
needAutoRedraw = true;
|
|
needAutoRedraw = true;
|
|
elementService.hideAll();
|
|
elementService.hideAll();
|
|
let point = dataService.getPoint(draggingItem.vectorId);
|
|
let point = dataService.getPoint(draggingItem.vectorId);
|
|
if (point) {
|
|
if (point) {
|
|
- listenLayer.start(point, draggingItem.vectorId, point.parent);
|
|
|
|
|
|
+ //listenLayer.start(point, draggingItem.vectorId, point.parent);
|
|
|
|
|
|
if (
|
|
if (
|
|
listenLayer.modifyPoint &&
|
|
listenLayer.modifyPoint &&
|
|
@@ -572,7 +414,7 @@ export default class Layer {
|
|
this.history.save();
|
|
this.history.save();
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
- case LayerEvents.AddingWall:
|
|
|
|
|
|
+ case LayerEvents.AddingRoad:
|
|
needAutoRedraw = true;
|
|
needAutoRedraw = true;
|
|
if (addRoad.startInfo && addRoad.startInfo.linkedPointId) {
|
|
if (addRoad.startInfo && addRoad.startInfo.linkedPointId) {
|
|
let addWallStartPoint = dataService.getPoint(
|
|
let addWallStartPoint = dataService.getPoint(
|
|
@@ -603,73 +445,6 @@ export default class Layer {
|
|
}
|
|
}
|
|
moveRoad.setStartMoving(false);
|
|
moveRoad.setStartMoving(false);
|
|
break;
|
|
break;
|
|
- case LayerEvents.AddSymbol:
|
|
|
|
- if (draggingItem == null) {
|
|
|
|
- this.setEventName("mouseUp");
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- focusItem = {
|
|
|
|
- vectorId: draggingItem.vectorId,
|
|
|
|
- type: draggingItem.type,
|
|
|
|
- cursor: { x: this.lastX, y: this.lastY },
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- stateService.setFocusItem(focusItem);
|
|
|
|
- this.uiControl.showAttributes();
|
|
|
|
- this.uiControl.currentUI = focusItem.type;
|
|
|
|
- this.history.save();
|
|
|
|
- break;
|
|
|
|
- case LayerEvents.MoveSymbol:
|
|
|
|
- symbol = dataService.getSymbol(draggingItem.vectorId);
|
|
|
|
- needAutoRedraw = true;
|
|
|
|
- if (focusItem != null && symbolService.isSymbol(focusItem.type)) {
|
|
|
|
- this.uiControl.currentUI = focusItem.type;
|
|
|
|
- this.history.save();
|
|
|
|
- } else if (symbol) {
|
|
|
|
- symbol.len = null;
|
|
|
|
- this.history.save();
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case LayerEvents.MoveSymbolPoint:
|
|
|
|
- needAutoRedraw = true;
|
|
|
|
- if (focusItem != null && symbolService.isSymbol(focusItem.type)) {
|
|
|
|
- this.uiControl.currentUI = focusItem.type;
|
|
|
|
- this.history.save();
|
|
|
|
- } else {
|
|
|
|
- this.history.save();
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
- case LayerEvents.AddComponent:
|
|
|
|
- needAutoRedraw = true;
|
|
|
|
- elementService.hideSignLine1();
|
|
|
|
- elementService.hideSignLine2();
|
|
|
|
- moveRectangle.clear();
|
|
|
|
-
|
|
|
|
- focusItem = {
|
|
|
|
- vectorId: draggingItem.vectorId,
|
|
|
|
- type: draggingItem.type,
|
|
|
|
- cursor: { x: this.lastX, y: this.lastY },
|
|
|
|
- };
|
|
|
|
-
|
|
|
|
- stateService.setFocusItem(focusItem);
|
|
|
|
- this.uiControl.showAttributes();
|
|
|
|
- this.uiControl.currentUI = focusItem.type;
|
|
|
|
- this.history.save();
|
|
|
|
- break;
|
|
|
|
- case LayerEvents.MoveComponent:
|
|
|
|
- needAutoRedraw = true;
|
|
|
|
- elementService.hideSignLine1();
|
|
|
|
- elementService.hideSignLine2();
|
|
|
|
- moveRectangle.clear();
|
|
|
|
-
|
|
|
|
- if (focusItem != null && componentService.isComponent(focusItem.type)) {
|
|
|
|
- this.uiControl.currentUI = focusItem.type;
|
|
|
|
- this.history.save();
|
|
|
|
- } else {
|
|
|
|
- this.history.save();
|
|
|
|
- }
|
|
|
|
- elementService.hideAll();
|
|
|
|
- break;
|
|
|
|
case LayerEvents.MoveTag:
|
|
case LayerEvents.MoveTag:
|
|
needAutoRedraw = true;
|
|
needAutoRedraw = true;
|
|
if (focusItem != null && focusItem.type == VectorType.Tag) {
|
|
if (focusItem != null && focusItem.type == VectorType.Tag) {
|
|
@@ -693,35 +468,6 @@ export default class Layer {
|
|
//}
|
|
//}
|
|
this.uiControl.currentUI = focusItem.type;
|
|
this.uiControl.currentUI = focusItem.type;
|
|
break;
|
|
break;
|
|
- case LayerEvents.AddFurniture:
|
|
|
|
- needAutoRedraw = true;
|
|
|
|
- elementService.hideSignLine1();
|
|
|
|
- elementService.hideSignLine2();
|
|
|
|
- moveRectangle.clear();
|
|
|
|
-
|
|
|
|
- focusItem = {
|
|
|
|
- vectorId: draggingItem.vectorId,
|
|
|
|
- type: draggingItem.type,
|
|
|
|
- cursor: { x: this.lastX, y: this.lastY },
|
|
|
|
- };
|
|
|
|
- stateService.setFocusItem(focusItem);
|
|
|
|
- this.uiControl.showAttributes();
|
|
|
|
- this.uiControl.currentUI = focusItem.type;
|
|
|
|
- this.history.save();
|
|
|
|
- break;
|
|
|
|
- case LayerEvents.MoveFurniture:
|
|
|
|
- needAutoRedraw = true;
|
|
|
|
- elementService.hideSignLine1();
|
|
|
|
- elementService.hideSignLine2();
|
|
|
|
- moveRectangle.clear();
|
|
|
|
-
|
|
|
|
- if (focusItem != null && furnitureService.isFurniture(focusItem.type)) {
|
|
|
|
- this.uiControl.currentUI = focusItem.type;
|
|
|
|
- this.history.save();
|
|
|
|
- } else {
|
|
|
|
- this.history.save();
|
|
|
|
- }
|
|
|
|
- break;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
this.setEventName("mouseUp");
|
|
this.setEventName("mouseUp");
|
|
@@ -746,10 +492,6 @@ export default class Layer {
|
|
}
|
|
}
|
|
|
|
|
|
coordinate.updateZoom(zoom);
|
|
coordinate.updateZoom(zoom);
|
|
-
|
|
|
|
- let info = coordinate.getScreenInfoForCAD();
|
|
|
|
- info.floorPlanAngle = dataService.getAngle();
|
|
|
|
-
|
|
|
|
this.renderer.autoRedraw();
|
|
this.renderer.autoRedraw();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -816,75 +558,6 @@ export default class Layer {
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
|
|
- //点击左侧栏后,更新事件
|
|
|
|
- updateEventNameForSelectUI() {
|
|
|
|
- elementService.hideAll();
|
|
|
|
- //正在添加tag的时候,需要先删除
|
|
|
|
- const eventName = stateService.getEventName();
|
|
|
|
- if (eventName == LayerEvents.AddTag) {
|
|
|
|
- let item = stateService.getDraggingItem();
|
|
|
|
- if (item && item.type == VectorType.Tag) {
|
|
|
|
- dataService.deleteTag(item.vectorId);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- stateService.clearItems();
|
|
|
|
- if (
|
|
|
|
- this.uiControl.selectUI == UIEvents.Wall ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.OutWall
|
|
|
|
- ) {
|
|
|
|
- stateService.setEventName(LayerEvents.AddRoad);
|
|
|
|
- } else if (
|
|
|
|
- this.uiControl.selectUI == UIEvents.SingleDoor ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.DoubleDoor ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.SlideDoor ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.SingleWindow ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.BayWindow ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.FrenchWindow ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.Pass
|
|
|
|
- ) {
|
|
|
|
- stateService.setEventName(LayerEvents.AddSymbol);
|
|
|
|
- } else if (
|
|
|
|
- this.uiControl.selectUI == UIEvents.Beam ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.Flue ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.Corridor
|
|
|
|
- ) {
|
|
|
|
- stateService.setEventName(LayerEvents.AddComponent);
|
|
|
|
- } else if (this.uiControl.selectUI == UIEvents.Tag) {
|
|
|
|
- stateService.setEventName(LayerEvents.AddTag);
|
|
|
|
- } else if (
|
|
|
|
- this.uiControl.selectUI == UIEvents.TV ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.CombinationSofa ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.SingleSofa ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.TeaTable ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.Carpet ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.Plant ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.DiningTable ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.DoubleBed ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.SingleBed ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.Wardrobe ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.Dresser ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.BedsideCupboard ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.Pillow ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.GasStove ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.Cupboard ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.Bathtub ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.Closestool ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.Washstand ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.Desk ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.BalconyChair ||
|
|
|
|
- this.uiControl.selectUI == UIEvents.Elevator
|
|
|
|
- ) {
|
|
|
|
- // // 测试代码
|
|
|
|
- // if (this.uiControl.selectUI == UIEvents.TV) {
|
|
|
|
- // furnitureService.getFurniture(UIEvents.TV).then(img => {
|
|
|
|
- // console.log(img)
|
|
|
|
- // })
|
|
|
|
- // }
|
|
|
|
-
|
|
|
|
- stateService.setEventName(LayerEvents.AddFurniture);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
setEventName(eventType) {
|
|
setEventName(eventType) {
|
|
let eventName = stateService.getEventName();
|
|
let eventName = stateService.getEventName();
|
|
|
|
|
|
@@ -923,7 +596,7 @@ export default class Layer {
|
|
stateService.setEventName(LayerEvents.MoveFurniture);
|
|
stateService.setEventName(LayerEvents.MoveFurniture);
|
|
}
|
|
}
|
|
} else if (eventName == LayerEvents.AddRoad) {
|
|
} else if (eventName == LayerEvents.AddRoad) {
|
|
- stateService.setEventName(LayerEvents.AddingWall);
|
|
|
|
|
|
+ stateService.setEventName(LayerEvents.AddingRoad);
|
|
}
|
|
}
|
|
} else if (eventType == "mouseUp") {
|
|
} else if (eventType == "mouseUp") {
|
|
if (eventName == LayerEvents.AddTag) {
|
|
if (eventName == LayerEvents.AddTag) {
|
|
@@ -931,45 +604,28 @@ export default class Layer {
|
|
//stateService.clearEventName()
|
|
//stateService.clearEventName()
|
|
} else if (
|
|
} else if (
|
|
eventName != LayerEvents.AddRoad &&
|
|
eventName != LayerEvents.AddRoad &&
|
|
- eventName != LayerEvents.AddingWall
|
|
|
|
|
|
+ eventName != LayerEvents.AddingRoad
|
|
) {
|
|
) {
|
|
stateService.clearEventName();
|
|
stateService.clearEventName();
|
|
- // if (this.uiControl.selectUI != null) {
|
|
|
|
- // this.uiControl.clearUI()
|
|
|
|
- // }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
exit() {
|
|
exit() {
|
|
- stateService.clearItems();
|
|
|
|
- stateService.clearEventName();
|
|
|
|
|
|
+ stateService.clear();
|
|
this.uiControl.clearUI();
|
|
this.uiControl.clearUI();
|
|
}
|
|
}
|
|
|
|
|
|
stopAddVector() {
|
|
stopAddVector() {
|
|
let eventName = stateService.getEventName();
|
|
let eventName = stateService.getEventName();
|
|
- if (eventName != LayerEvents.AddingWall) {
|
|
|
|
|
|
+ if (eventName != LayerEvents.AddingRoad) {
|
|
stateService.clearEventName();
|
|
stateService.clearEventName();
|
|
const draggingItem = stateService.getDraggingItem();
|
|
const draggingItem = stateService.getDraggingItem();
|
|
- if (eventName == LayerEvents.AddSymbol) {
|
|
|
|
- if (draggingItem && draggingItem.vectorId) {
|
|
|
|
- symbolService.deleteSymbol(draggingItem.vectorId);
|
|
|
|
- stateService.clearDraggingItem();
|
|
|
|
- }
|
|
|
|
- } else if (eventName == LayerEvents.AddComponent) {
|
|
|
|
- if (draggingItem && draggingItem.vectorId) {
|
|
|
|
- dataService.deleteComponent(draggingItem.vectorId);
|
|
|
|
- }
|
|
|
|
- } else if (eventName == LayerEvents.AddTag) {
|
|
|
|
|
|
+ if (eventName == LayerEvents.AddTag) {
|
|
if (draggingItem && draggingItem.vectorId) {
|
|
if (draggingItem && draggingItem.vectorId) {
|
|
- tagService.deleteTag(draggingItem.vectorId);
|
|
|
|
|
|
+ dataService.deleteTag(draggingItem.vectorId);
|
|
this.uiControl.currentUI = null;
|
|
this.uiControl.currentUI = null;
|
|
}
|
|
}
|
|
- } else if (eventName == LayerEvents.AddFurniture) {
|
|
|
|
- if (draggingItem && draggingItem.vectorId) {
|
|
|
|
- dataService.deleteFurniture(draggingItem.vectorId);
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
stateService.setEventName(LayerEvents.AddRoad);
|
|
stateService.setEventName(LayerEvents.AddRoad);
|
|
@@ -994,18 +650,13 @@ export default class Layer {
|
|
deleteItem() {
|
|
deleteItem() {
|
|
let item = stateService.getFocusItem();
|
|
let item = stateService.getFocusItem();
|
|
if (item) {
|
|
if (item) {
|
|
- if (item.type == VectorType.Wall) {
|
|
|
|
- dataService.deleteWall(item.vectorId);
|
|
|
|
- } else if (symbolService.isSymbol(item.type)) {
|
|
|
|
- symbolService.deleteSymbol(item.vectorId);
|
|
|
|
- } else if (componentService.isComponent(item.type)) {
|
|
|
|
- dataService.deleteComponent(item.vectorId);
|
|
|
|
|
|
+ if (item.type == VectorType.Road) {
|
|
|
|
+ dataService.deleteRoad(item.vectorId);
|
|
} else if (item.type == VectorType.Tag) {
|
|
} else if (item.type == VectorType.Tag) {
|
|
dataService.deleteTag(item.vectorId);
|
|
dataService.deleteTag(item.vectorId);
|
|
- } else if (furnitureService.isFurniture(item.type)) {
|
|
|
|
- dataService.deleteComponent(item.vectorId);
|
|
|
|
- } else if (item.type == VectorType.WallCorner) {
|
|
|
|
- wallService.deleteWallCorner(item.vectorId);
|
|
|
|
|
|
+ } else if (item.type == VectorType.RoadCorner) {
|
|
|
|
+ //这个比较复杂,参考deleteWallCorner
|
|
|
|
+ //dataService.deletePoint(item.vectorId);
|
|
}
|
|
}
|
|
this.history.save();
|
|
this.history.save();
|
|
this.renderer.autoRedraw();
|
|
this.renderer.autoRedraw();
|