|
@@ -91,7 +91,6 @@ export default class Layer {
|
|
this.canvas.addEventListener("mousewheel", this.onWheel.bind(this));
|
|
this.canvas.addEventListener("mousewheel", this.onWheel.bind(this));
|
|
this.canvas.addEventListener("DOMMouseScroll", this.onWheel.bind(this));
|
|
this.canvas.addEventListener("DOMMouseScroll", this.onWheel.bind(this));
|
|
this.canvas.addEventListener("resize", this.reSize.bind(this));
|
|
this.canvas.addEventListener("resize", this.reSize.bind(this));
|
|
- document.addEventListener("keydown", this.onKeydown.bind(this));
|
|
|
|
}
|
|
}
|
|
|
|
|
|
reSize = function () {
|
|
reSize = function () {
|
|
@@ -1238,179 +1237,6 @@ export default class Layer {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //测试用
|
|
|
|
- onKeydown(e) {
|
|
|
|
- let focusItem = stateService.getFocusItem();
|
|
|
|
- let dir = "left";
|
|
|
|
- if (focusItem) {
|
|
|
|
- console.log("键盘(foucus有效):" + e.code);
|
|
|
|
- if (e.code == "Delete") {
|
|
|
|
- //删除
|
|
|
|
- const road = dataService.getRoad(focusItem.vectorId);
|
|
|
|
- roadService.subtraRoadFromIntersect(road.startId, focusItem.vectorId);
|
|
|
|
- roadService.subtraRoadFromIntersect(road.endId, focusItem.vectorId);
|
|
|
|
- //dataService.deleteCrossPoint()
|
|
|
|
- dataService.deleteRoad(focusItem.vectorId);
|
|
|
|
- this.renderer.autoRedraw();
|
|
|
|
- this.history.save();
|
|
|
|
- }
|
|
|
|
- //加宽
|
|
|
|
- else if (e.code == "KeyA") {
|
|
|
|
- let road = dataService.getRoad(focusItem.vectorId);
|
|
|
|
- if (road) {
|
|
|
|
- roadService.updateForWidth(road.vectorId, road.leftWidth + 50, dir);
|
|
|
|
- } else {
|
|
|
|
- road = dataService.getCurveRoad(focusItem.vectorId);
|
|
|
|
- curveRoadService.updateForWidth(
|
|
|
|
- road.vectorId,
|
|
|
|
- road.leftWidth + 50,
|
|
|
|
- dir
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- this.renderer.autoRedraw();
|
|
|
|
- this.history.save();
|
|
|
|
- }
|
|
|
|
- //变窄
|
|
|
|
- else if (e.code == "KeyB") {
|
|
|
|
- let road = dataService.getRoad(focusItem.vectorId);
|
|
|
|
- if (road) {
|
|
|
|
- roadService.updateForWidth(road.vectorId, road.leftWidth - 25, dir);
|
|
|
|
- } else {
|
|
|
|
- road = dataService.getCurveRoad(focusItem.vectorId);
|
|
|
|
- curveRoadService.updateForWidth(
|
|
|
|
- road.vectorId,
|
|
|
|
- road.leftWidth - 25,
|
|
|
|
- dir
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
- this.renderer.autoRedraw();
|
|
|
|
- this.history.save();
|
|
|
|
- }
|
|
|
|
- //添加左车道
|
|
|
|
- else if (e.code == "KeyQ") {
|
|
|
|
- let road = dataService.getRoad(focusItem.vectorId);
|
|
|
|
- if (road) {
|
|
|
|
- roadService.updateForAddSubtractLanesCount(
|
|
|
|
- focusItem.vectorId,
|
|
|
|
- road.leftDrivewayCount + 1,
|
|
|
|
- "left"
|
|
|
|
- );
|
|
|
|
- } else {
|
|
|
|
- road = dataService.getCurveRoad(focusItem.vectorId);
|
|
|
|
- curveRoadService.updateForAddSubtractLanesCount(
|
|
|
|
- road,
|
|
|
|
- road.leftDrivewayCount + 1, //rightDrivewayCount
|
|
|
|
- "left"
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
- this.renderer.autoRedraw();
|
|
|
|
- this.history.save();
|
|
|
|
- }
|
|
|
|
- //减少左车道
|
|
|
|
- else if (e.code == "KeyW") {
|
|
|
|
- let road = dataService.getRoad(focusItem.vectorId);
|
|
|
|
- if (road) {
|
|
|
|
- roadService.updateForAddSubtractLanesCount(
|
|
|
|
- focusItem.vectorId,
|
|
|
|
- road.leftDrivewayCount - 1,
|
|
|
|
- "left"
|
|
|
|
- );
|
|
|
|
- } else {
|
|
|
|
- road = dataService.getCurveRoad(focusItem.vectorId);
|
|
|
|
- curveRoadService.updateForAddSubtractLanesCount(
|
|
|
|
- road,
|
|
|
|
- road.leftDrivewayCount - 1, //rightDrivewayCount
|
|
|
|
- "left"
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
- this.renderer.autoRedraw();
|
|
|
|
- this.history.save();
|
|
|
|
- }
|
|
|
|
- //添加右车道
|
|
|
|
- else if (e.code == "KeyE") {
|
|
|
|
- let road = dataService.getRoad(focusItem.vectorId);
|
|
|
|
- if (road) {
|
|
|
|
- roadService.updateForAddSubtractLanesCount(
|
|
|
|
- focusItem.vectorId,
|
|
|
|
- road.rightDrivewayCount + 1,
|
|
|
|
- "right"
|
|
|
|
- );
|
|
|
|
- } else {
|
|
|
|
- road = dataService.getCurveRoad(focusItem.vectorId);
|
|
|
|
- curveRoadService.updateForAddSubtractLanesCount(
|
|
|
|
- road,
|
|
|
|
- road.rightDrivewayCount + 1, //rightDrivewayCount
|
|
|
|
- "right"
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
- this.renderer.autoRedraw();
|
|
|
|
- this.history.save();
|
|
|
|
- }
|
|
|
|
- //减少右车道
|
|
|
|
- else if (e.code == "KeyR") {
|
|
|
|
- let road = dataService.getRoad(focusItem.vectorId);
|
|
|
|
- if (road) {
|
|
|
|
- roadService.updateForAddSubtractLanesCount(
|
|
|
|
- focusItem.vectorId,
|
|
|
|
- road.rightDrivewayCount - 1,
|
|
|
|
- "right"
|
|
|
|
- );
|
|
|
|
- } else {
|
|
|
|
- road = dataService.getCurveRoad(focusItem.vectorId);
|
|
|
|
- curveRoadService.updateForAddSubtractLanesCount(
|
|
|
|
- road,
|
|
|
|
- road.rightDrivewayCount - 1, //rightDrivewayCount
|
|
|
|
- "right"
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
- this.renderer.autoRedraw();
|
|
|
|
- this.history.save();
|
|
|
|
- }
|
|
|
|
- //弯路添加控制点
|
|
|
|
- else if (e.code == "KeyT") {
|
|
|
|
- const curveRoad = dataService.getCurveRoad(focusItem.vectorId);
|
|
|
|
- let index = mathUtil.getIndexForCurvesPoints(
|
|
|
|
- this.mousePosition,
|
|
|
|
- curveRoad.points
|
|
|
|
- );
|
|
|
|
- if (index != -1) {
|
|
|
|
- curveRoadService.addCPoint(curveRoad, this.mousePosition, index);
|
|
|
|
- } else {
|
|
|
|
- const dis1 = mathUtil.getDistance(
|
|
|
|
- curveRoad.points[0],
|
|
|
|
- this.mousePosition
|
|
|
|
- );
|
|
|
|
- const dis2 = mathUtil.getDistance(
|
|
|
|
- curveRoad.points[curveRoad.points.length - 1],
|
|
|
|
- this.mousePosition
|
|
|
|
- );
|
|
|
|
- if (dis1 > dis2) {
|
|
|
|
- curveRoadService.addCPoint(
|
|
|
|
- curveRoad,
|
|
|
|
- this.mousePosition,
|
|
|
|
- curveRoad.points.length - 2
|
|
|
|
- );
|
|
|
|
- } else {
|
|
|
|
- curveRoadService.addCPoint(curveRoad, this.mousePosition, 1);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- this.renderer.autoRedraw();
|
|
|
|
- this.history.save();
|
|
|
|
- }
|
|
|
|
- //弯路删除控制点
|
|
|
|
- else if (e.code == "KeyY") {
|
|
|
|
- const curvePoint = dataService.getCurveRoadPoint(focusItem.vectorId);
|
|
|
|
- const curveRoad = dataService.getCurveRoad(curvePoint.parent);
|
|
|
|
- curveRoadService.subCPoint(curveRoad, curvePoint.getIndex());
|
|
|
|
- this.renderer.autoRedraw();
|
|
|
|
- this.history.save();
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- console.log("键盘(foucus无效):" + e.code);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
setEventName(eventType) {
|
|
setEventName(eventType) {
|
|
let eventName = stateService.getEventName();
|
|
let eventName = stateService.getEventName();
|
|
|
|
|