|
@@ -42,6 +42,7 @@ import Settings from "./Settings";
|
|
|
import Constant from "./Constant";
|
|
|
import { uiService } from "./Service/UIService";
|
|
|
import { imageService } from "./Service/ImageService";
|
|
|
+import VectorEvents from "./enum/VectorEvents";
|
|
|
|
|
|
const minDragDis = 10;
|
|
|
const minZoom = 20;
|
|
@@ -127,6 +128,7 @@ export default class Layer {
|
|
|
this.dragging = false;
|
|
|
//用于支持平板电脑
|
|
|
listenLayer.start(position);
|
|
|
+ let selectItem = stateService.getSelectItem();
|
|
|
this.setEventName("mouseDown");
|
|
|
const eventName = stateService.getEventName();
|
|
|
switch (eventName) {
|
|
@@ -193,8 +195,124 @@ export default class Layer {
|
|
|
);
|
|
|
addMagnifier.clear();
|
|
|
break;
|
|
|
+ case VectorEvents.AddLane:
|
|
|
+ if (selectItem && selectItem.dir && selectItem.vectorId) {
|
|
|
+ let road = dataService.getRoad(selectItem.vectorId);
|
|
|
+ if (road) {
|
|
|
+ if (selectItem.dir == "left") {
|
|
|
+ roadService.updateForAddSubtractLanesCount(
|
|
|
+ road.vectorId,
|
|
|
+ road.leftDrivewayCount + 1,
|
|
|
+ selectItem.dir
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ roadService.updateForAddSubtractLanesCount(
|
|
|
+ road.vectorId,
|
|
|
+ road.rightDrivewayCount + 1,
|
|
|
+ selectItem.dir
|
|
|
+ );
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ road = dataService.getCurveRoad(selectItem.vectorId);
|
|
|
+ if (selectItem.dir == "left") {
|
|
|
+ curveRoadService.updateForAddSubtractLanesCount(
|
|
|
+ road.vectorId,
|
|
|
+ road.leftDrivewayCount + 1,
|
|
|
+ selectItem.dir
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ curveRoadService.updateForAddSubtractLanesCount(
|
|
|
+ road.vectorId,
|
|
|
+ road.rightDrivewayCount + 1,
|
|
|
+ selectItem.dir
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ stateService.clearEventName();
|
|
|
+ this.history.save();
|
|
|
+ this.renderer.autoRedraw();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case VectorEvents.DelLane:
|
|
|
+ if (selectItem && selectItem.dir && selectItem.vectorId) {
|
|
|
+ let road = dataService.getRoad(selectItem.vectorId);
|
|
|
+ if (road) {
|
|
|
+ if (selectItem.dir == "left") {
|
|
|
+ roadService.updateForAddSubtractLanesCount(
|
|
|
+ road.vectorId,
|
|
|
+ road.leftDrivewayCount - 1,
|
|
|
+ selectItem.dir
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ roadService.updateForAddSubtractLanesCount(
|
|
|
+ road.vectorId,
|
|
|
+ road.rightDrivewayCount - 1,
|
|
|
+ selectItem.dir
|
|
|
+ );
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ road = dataService.getCurveRoad(selectItem.vectorId);
|
|
|
+ if (selectItem.dir == "left") {
|
|
|
+ curveRoadService.updateForAddSubtractLanesCount(
|
|
|
+ road.vectorId,
|
|
|
+ road.leftDrivewayCount - 1,
|
|
|
+ selectItem.dir
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ curveRoadService.updateForAddSubtractLanesCount(
|
|
|
+ road.vectorId,
|
|
|
+ road.rightDrivewayCount - 1,
|
|
|
+ selectItem.dir
|
|
|
+ );
|
|
|
+ }
|
|
|
+ }
|
|
|
+ stateService.clearEventName();
|
|
|
+ this.history.save();
|
|
|
+ this.renderer.autoRedraw();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case VectorEvents.AddCrossPoint:
|
|
|
+ if (selectItem && selectItem.dir && selectItem.vectorId) {
|
|
|
+ const curveRoad = dataService.getCurveRoad(selectItem.vectorId);
|
|
|
+ let index = mathUtil.getIndexForCurvesPoints(
|
|
|
+ position,
|
|
|
+ curveRoad.points
|
|
|
+ );
|
|
|
+ if (index != -1) {
|
|
|
+ curveRoadService.addCPoint(curveRoad, position, index);
|
|
|
+ } else {
|
|
|
+ const dis1 = mathUtil.getDistance(curveRoad.points[0], position);
|
|
|
+ const dis2 = mathUtil.getDistance(
|
|
|
+ curveRoad.points[curveRoad.points.length - 1],
|
|
|
+ position
|
|
|
+ );
|
|
|
+ if (dis1 > dis2) {
|
|
|
+ curveRoadService.addCPoint(
|
|
|
+ curveRoad,
|
|
|
+ position,
|
|
|
+ curveRoad.points.length - 2
|
|
|
+ );
|
|
|
+ } else {
|
|
|
+ curveRoadService.addCPoint(curveRoad, position, 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ stateService.clearEventName();
|
|
|
+ this.history.save();
|
|
|
+ this.renderer.autoRedraw();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case VectorEvents.MinusCrossPoint:
|
|
|
+ if (selectItem && selectItem.dir && selectItem.vectorId) {
|
|
|
+ const curvePoint = dataService.getCurveRoadPoint(selectItem.vectorId);
|
|
|
+ const curveRoad = dataService.getCurveRoad(curvePoint.parent);
|
|
|
+ curveRoadService.subCPoint(curveRoad, curvePoint.getIndex());
|
|
|
+ stateService.clearEventName();
|
|
|
+ this.history.save();
|
|
|
+ this.renderer.autoRedraw();
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
- const selectItem = stateService.getSelectItem();
|
|
|
+ selectItem = stateService.getSelectItem();
|
|
|
stateService.setDraggingItem(selectItem);
|
|
|
// 清除上一个状态
|
|
|
// 设置当前事件名称
|
|
@@ -322,7 +440,7 @@ export default class Layer {
|
|
|
//鼠标样式
|
|
|
elementService.setPoint(position);
|
|
|
elementService.showPoint();
|
|
|
- this.showElementLine(position);
|
|
|
+ this.showElementLine(position, eventName);
|
|
|
break;
|
|
|
case LayerEvents.AddLine:
|
|
|
needAutoRedraw = true;
|
|
@@ -336,7 +454,7 @@ export default class Layer {
|
|
|
elementService.hideAll();
|
|
|
elementService.setPoint(position);
|
|
|
elementService.showPoint();
|
|
|
- this.showElementLine(position);
|
|
|
+ this.showElementLine(position, eventName);
|
|
|
break;
|
|
|
case LayerEvents.AddCurveLine:
|
|
|
needAutoRedraw = true;
|
|
@@ -350,7 +468,7 @@ export default class Layer {
|
|
|
elementService.hideAll();
|
|
|
elementService.setPoint(position);
|
|
|
elementService.showPoint();
|
|
|
- this.showElementLine(position);
|
|
|
+ this.showElementLine(position, eventName);
|
|
|
break;
|
|
|
case LayerEvents.AddCircle:
|
|
|
needAutoRedraw = true;
|
|
@@ -403,7 +521,7 @@ export default class Layer {
|
|
|
elementService.setNewRoadState("normal");
|
|
|
}
|
|
|
elementService.showPoint();
|
|
|
- this.showElementLine(position);
|
|
|
+ this.showElementLine(position, eventName);
|
|
|
break;
|
|
|
case LayerEvents.AddingLine:
|
|
|
needAutoRedraw = true;
|
|
@@ -433,7 +551,7 @@ export default class Layer {
|
|
|
elementService.hideAll();
|
|
|
elementService.setPoint(position);
|
|
|
elementService.showPoint();
|
|
|
- this.showElementLine(position);
|
|
|
+ this.showElementLine(position, eventName);
|
|
|
break;
|
|
|
case LayerEvents.AddingCurveLine:
|
|
|
needAutoRedraw = true;
|
|
@@ -463,7 +581,7 @@ export default class Layer {
|
|
|
elementService.hideAll();
|
|
|
elementService.setPoint(position);
|
|
|
elementService.showPoint();
|
|
|
- this.showElementLine(position);
|
|
|
+ this.showElementLine(position, eventName);
|
|
|
break;
|
|
|
case LayerEvents.AddingCircle:
|
|
|
needAutoRedraw = true;
|
|
@@ -535,11 +653,19 @@ export default class Layer {
|
|
|
exceptRoadPointId: draggingItem.vectorId,
|
|
|
exceptRoadIds: point.parent,
|
|
|
});
|
|
|
- if (listenLayer.modifyPoint) {
|
|
|
+ if (
|
|
|
+ listenLayer.modifyPoint &&
|
|
|
+ (listenLayer.modifyPoint.linkedRoadPointId ||
|
|
|
+ listenLayer.modifyPoint.linkedRoadId ||
|
|
|
+ listenLayer.modifyPoint.linkedRoadPointIdX ||
|
|
|
+ listenLayer.modifyPoint.linkedRoadPointIdY)
|
|
|
+ ) {
|
|
|
position = {
|
|
|
x: listenLayer.modifyPoint.x,
|
|
|
y: listenLayer.modifyPoint.y,
|
|
|
};
|
|
|
+ } else {
|
|
|
+ listenLayer.modifyPoint = null;
|
|
|
}
|
|
|
|
|
|
let flag = moveRoad.moveingRoadPoint(
|
|
@@ -550,7 +676,7 @@ export default class Layer {
|
|
|
if (!flag) {
|
|
|
elementService.hideAll();
|
|
|
} else {
|
|
|
- this.showElementLine(point);
|
|
|
+ this.showElementLine(point, eventName);
|
|
|
}
|
|
|
needAutoRedraw = true;
|
|
|
break;
|
|
@@ -566,7 +692,7 @@ export default class Layer {
|
|
|
elementService.hideAll();
|
|
|
elementService.setPoint(position);
|
|
|
elementService.showPoint();
|
|
|
- this.showElementLine(position);
|
|
|
+ this.showElementLine(position, eventName);
|
|
|
break;
|
|
|
case LayerEvents.AddingCurveRoad:
|
|
|
needAutoRedraw = true;
|
|
@@ -591,7 +717,7 @@ export default class Layer {
|
|
|
elementService.setNewRoadState("normal");
|
|
|
}
|
|
|
elementService.showPoint();
|
|
|
- this.showElementLine(position);
|
|
|
+ this.showElementLine(position, eventName);
|
|
|
break;
|
|
|
case LayerEvents.MoveCurveRoad:
|
|
|
needAutoRedraw = true;
|
|
@@ -610,14 +736,23 @@ export default class Layer {
|
|
|
exceptRoadPointId: draggingItem.vectorId,
|
|
|
exceptCurveRoadId: point.parent, //不会融合,所以parent只有一个
|
|
|
});
|
|
|
- if (listenLayer.modifyPoint) {
|
|
|
+ if (
|
|
|
+ listenLayer.modifyPoint &&
|
|
|
+ (listenLayer.modifyPoint.linkedRoadPointId ||
|
|
|
+ listenLayer.modifyPoint.linkedRoadId ||
|
|
|
+ listenLayer.modifyPoint.linkedRoadPointIdX ||
|
|
|
+ listenLayer.modifyPoint.linkedRoadPointIdY ||
|
|
|
+ listenLayer.modifyPoint.linkedCurvePointIdX ||
|
|
|
+ listenLayer.modifyPoint.linkedCurvePointIdY ||
|
|
|
+ listenLayer.modifyPoint.linkedCurveRoadPointIdX)
|
|
|
+ ) {
|
|
|
position = {
|
|
|
x: listenLayer.modifyPoint.x,
|
|
|
y: listenLayer.modifyPoint.y,
|
|
|
};
|
|
|
}
|
|
|
moveRoad.moveCurveRoadPoint(draggingItem.vectorId, position);
|
|
|
- this.showElementLine(point);
|
|
|
+ this.showElementLine(point, eventName);
|
|
|
needAutoRedraw = true;
|
|
|
break;
|
|
|
case LayerEvents.MoveCrossPoint:
|
|
@@ -665,7 +800,7 @@ export default class Layer {
|
|
|
};
|
|
|
}
|
|
|
movePoint.movePoint(position, draggingItem.vectorId);
|
|
|
- this.showElementLine(point);
|
|
|
+ this.showElementLine(point, eventName);
|
|
|
needAutoRedraw = true;
|
|
|
}
|
|
|
break;
|
|
@@ -683,7 +818,7 @@ export default class Layer {
|
|
|
};
|
|
|
}
|
|
|
movePoint.moveCurvePoint(position, draggingItem.vectorId);
|
|
|
- this.showElementLine(curvePoint);
|
|
|
+ this.showElementLine(curvePoint, eventName);
|
|
|
needAutoRedraw = true;
|
|
|
}
|
|
|
break;
|
|
@@ -811,6 +946,7 @@ export default class Layer {
|
|
|
vectorId: selectItem.vectorId,
|
|
|
type: selectItem.type,
|
|
|
cursor: { x: this.lastX, y: this.lastY },
|
|
|
+ dir: selectItem.dir,
|
|
|
};
|
|
|
stateService.setFocusItem(focusItem);
|
|
|
this.uiControl.focusVector = focusItem;
|
|
@@ -1368,6 +1504,104 @@ export default class Layer {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // showElementLine(point, eventName) {
|
|
|
+ // let otherPoint1 = null;
|
|
|
+ // let otherPoint2 = null;
|
|
|
+ // if (
|
|
|
+ // listenLayer.modifyPoint &&
|
|
|
+ // listenLayer.modifyPoint.linkedRoadPointIdX &&
|
|
|
+ // (eventName == LayerEvents.AddingRoad ||
|
|
|
+ // eventName == LayerEvents.MoveRoadPoint ||
|
|
|
+ // eventName == LayerEvents.AddRoad)
|
|
|
+ // ) {
|
|
|
+ // otherPoint1 = dataService.getRoadPoint(
|
|
|
+ // listenLayer.modifyPoint.linkedRoadPointIdX
|
|
|
+ // );
|
|
|
+ // } else if (
|
|
|
+ // listenLayer.modifyPoint &&
|
|
|
+ // listenLayer.modifyPoint.linkedCurveRoadPointIdX &&
|
|
|
+ // (eventName == LayerEvents.AddingCurveRoad ||
|
|
|
+ // eventName == LayerEvents.MoveCurveRoadPoint ||
|
|
|
+ // eventName == LayerEvents.AddCurveRoad)
|
|
|
+ // ) {
|
|
|
+ // otherPoint1 = dataService.getCurveRoadPoint(
|
|
|
+ // listenLayer.modifyPoint.linkedCurvePointIdX
|
|
|
+ // );
|
|
|
+ // } else if (
|
|
|
+ // listenLayer.modifyPoint &&
|
|
|
+ // listenLayer.modifyPoint.linkedPointIdX &&
|
|
|
+ // (eventName == LayerEvents.AddLine || eventName == LayerEvents.MovePoint)
|
|
|
+ // ) {
|
|
|
+ // otherPoint1 = dataService.getPoint(
|
|
|
+ // listenLayer.modifyPoint.linkedPointIdX
|
|
|
+ // );
|
|
|
+ // } else if (
|
|
|
+ // listenLayer.modifyPoint &&
|
|
|
+ // listenLayer.modifyPoint.linkedCurvePointIdX &&
|
|
|
+ // (eventName == LayerEvents.AddCurveLine ||
|
|
|
+ // eventName == LayerEvents.MoveCurvePoint)
|
|
|
+ // ) {
|
|
|
+ // otherPoint1 = dataService.getCurvePoint(
|
|
|
+ // listenLayer.modifyPoint.linkedCurvePointIdX
|
|
|
+ // );
|
|
|
+ // }
|
|
|
+
|
|
|
+ // if (
|
|
|
+ // listenLayer.modifyPoint &&
|
|
|
+ // listenLayer.modifyPoint.linkedRoadPointIdY &&
|
|
|
+ // (eventName == LayerEvents.AddingRoad ||
|
|
|
+ // eventName == LayerEvents.MoveRoadPoint ||
|
|
|
+ // eventName == LayerEvents.AddRoad)
|
|
|
+ // ) {
|
|
|
+ // otherPoint2 = dataService.getRoadPoint(
|
|
|
+ // listenLayer.modifyPoint.linkedRoadPointIdY
|
|
|
+ // );
|
|
|
+ // } else if (
|
|
|
+ // listenLayer.modifyPoint &&
|
|
|
+ // listenLayer.modifyPoint.linkedCurvePointIdY &&
|
|
|
+ // (eventName == LayerEvents.AddingCurveRoad ||
|
|
|
+ // eventName == LayerEvents.MoveCurveRoadPoint ||
|
|
|
+ // eventName == LayerEvents.AddCurveRoad)
|
|
|
+ // ) {
|
|
|
+ // otherPoint2 = dataService.getCurveRoadPoint(
|
|
|
+ // listenLayer.modifyPoint.linkedCurvePointIdY
|
|
|
+ // );
|
|
|
+ // } else if (
|
|
|
+ // listenLayer.modifyPoint &&
|
|
|
+ // listenLayer.modifyPoint.linkedPointIdY &&
|
|
|
+ // (eventName == LayerEvents.AddLine || eventName == LayerEvents.MovePoint)
|
|
|
+ // ) {
|
|
|
+ // otherPoint2 = dataService.getPoint(
|
|
|
+ // listenLayer.modifyPoint.linkedPointIdY
|
|
|
+ // );
|
|
|
+ // } else if (
|
|
|
+ // listenLayer.modifyPoint &&
|
|
|
+ // listenLayer.modifyPoint.linkedCurvePointIdY &&
|
|
|
+ // (eventName == LayerEvents.AddCurveLine ||
|
|
|
+ // eventName == LayerEvents.MoveCurvePoint)
|
|
|
+ // ) {
|
|
|
+ // otherPoint2 = dataService.getCurvePoint(
|
|
|
+ // listenLayer.modifyPoint.linkedCurvePointIdY
|
|
|
+ // );
|
|
|
+ // }
|
|
|
+
|
|
|
+ // let otherPoint = {};
|
|
|
+ // if (otherPoint1) {
|
|
|
+ // otherPoint.x = otherPoint1.x;
|
|
|
+ // otherPoint.y = otherPoint1.y;
|
|
|
+ // }
|
|
|
+ // if (otherPoint2) {
|
|
|
+ // otherPoint.y = otherPoint2.y;
|
|
|
+ // if (!otherPoint.hasOwnProperty("x")) {
|
|
|
+ // otherPoint.x = otherPoint2.x;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // if (otherPoint.hasOwnProperty("x") && otherPoint.hasOwnProperty("y")) {
|
|
|
+ // elementService.execute(otherPoint, point);
|
|
|
+ // } else {
|
|
|
+ // elementService.hideAll();
|
|
|
+ // }
|
|
|
+ // }
|
|
|
showElementLine(point) {
|
|
|
let otherPoint1 = null;
|
|
|
let otherPoint2 = null;
|
|
@@ -1377,7 +1611,7 @@ export default class Layer {
|
|
|
);
|
|
|
} else if (
|
|
|
listenLayer.modifyPoint &&
|
|
|
- listenLayer.modifyPoint.linkedCurvePointIdX
|
|
|
+ listenLayer.modifyPoint.linkedCurveRoadPointIdX
|
|
|
) {
|
|
|
otherPoint1 = dataService.getCurveRoadPoint(
|
|
|
listenLayer.modifyPoint.linkedCurvePointIdX
|
|
@@ -1436,7 +1670,6 @@ export default class Layer {
|
|
|
otherPoint.x = otherPoint2.x;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
elementService.execute(otherPoint, point);
|
|
|
}
|
|
|
}
|