|
@@ -21,7 +21,7 @@ export default class MoveRoad {
|
|
|
// 测试要考虑pointId拖拽到包含他的所有墙的另一头
|
|
|
// 这个函数不会删除/拆分/合并墙或者点
|
|
|
moveingRoadPoint(pointId, position, modifyPoint) {
|
|
|
- let point = dataService.getPoint(pointId);
|
|
|
+ let point = dataService.getRoadPoint(pointId);
|
|
|
let linkedPointId = null;
|
|
|
let linkedRoadId = null;
|
|
|
|
|
@@ -58,8 +58,8 @@ export default class MoveRoad {
|
|
|
const road = dataService.getRoad(this.adsorbPointRoads[adsorbPointId]);
|
|
|
|
|
|
const otherPointId = road.getOtherPointId(pointId);
|
|
|
- let otherPoint = dataService.getPoint(otherPointId);
|
|
|
- let modifyPoint = dataService.getPoint(adsorbPointId);
|
|
|
+ let otherPoint = dataService.getRoadPoint(otherPointId);
|
|
|
+ let modifyPoint = dataService.getRoadPoint(adsorbPointId);
|
|
|
let line = mathUtil.createLine1(otherPoint, modifyPoint);
|
|
|
position = mathUtil.getJoinLinePoint(position, line);
|
|
|
point.setPosition(position);
|
|
@@ -85,8 +85,8 @@ export default class MoveRoad {
|
|
|
// 如果墙面的交点与其余墙角的距离过短,那也不允许拖动
|
|
|
else if (modifyPoint.hasOwnProperty("linkedRoadId")) {
|
|
|
const road = dataService.getRoad(modifyPoint.linkedRoadId);
|
|
|
- const startPoint = dataService.getPoint(road.startId);
|
|
|
- const endPoint = dataService.getPoint(road.endId);
|
|
|
+ const startPoint = dataService.getRoadPoint(road.startId);
|
|
|
+ const endPoint = dataService.getRoadPoint(road.endId);
|
|
|
|
|
|
// 与其余墙角的距离过短,不允许拖动
|
|
|
if (
|
|
@@ -127,7 +127,7 @@ export default class MoveRoad {
|
|
|
let joins = [];
|
|
|
let roadId = null;
|
|
|
for (let key in this.adsorbPointRoads) {
|
|
|
- let point = dataService.getPoint(key);
|
|
|
+ let point = dataService.getRoadPoint(key);
|
|
|
joins.push({
|
|
|
join: point,
|
|
|
pointId: key,
|
|
@@ -136,7 +136,7 @@ export default class MoveRoad {
|
|
|
}
|
|
|
|
|
|
const road = dataService.getRoad(roadId);
|
|
|
- const startPoint = dataService.getPoint(road.startId);
|
|
|
+ const startPoint = dataService.getRoadPoint(road.startId);
|
|
|
|
|
|
function sortNumber(a, b) {
|
|
|
return (
|
|
@@ -160,8 +160,8 @@ export default class MoveRoad {
|
|
|
dy = -dy;
|
|
|
|
|
|
const road = dataService.getRoad(roadId);
|
|
|
- const startPoint = dataService.getPoint(road.startId);
|
|
|
- const endPoint = dataService.getPoint(road.endId);
|
|
|
+ const startPoint = dataService.getRoadPoint(road.startId);
|
|
|
+ const endPoint = dataService.getRoadPoint(road.endId);
|
|
|
|
|
|
const p1 = { x: startPoint.x + dx, y: startPoint.y + dy };
|
|
|
const p2 = { x: endPoint.x + dx, y: endPoint.y + dy };
|
|
@@ -174,8 +174,8 @@ export default class MoveRoad {
|
|
|
|
|
|
getTwoLimitInfos(roadId, newLine) {
|
|
|
const road = dataService.getRoad(roadId);
|
|
|
- const startPoint = dataService.getPoint(road.startId);
|
|
|
- const endPoint = dataService.getPoint(road.endId);
|
|
|
+ const startPoint = dataService.getRoadPoint(road.startId);
|
|
|
+ const endPoint = dataService.getRoadPoint(road.endId);
|
|
|
let startLimitLine, endLimitLine, info;
|
|
|
const roadLine = roadService.getMidLine(road);
|
|
|
|
|
@@ -209,11 +209,11 @@ export default class MoveRoad {
|
|
|
let tempRoad, tempRoadId;
|
|
|
info = roadService.roadIdForMinAngle(road.startId, roadId);
|
|
|
const road1 = dataService.getRoad(info.min0.roadId);
|
|
|
- const startPoint1 = dataService.getPoint(road1.startId);
|
|
|
- const endPoint1 = dataService.getPoint(road1.endId);
|
|
|
+ const startPoint1 = dataService.getRoadPoint(road1.startId);
|
|
|
+ const endPoint1 = dataService.getRoadPoint(road1.endId);
|
|
|
const road2 = dataService.getRoad(info.min1.roadId);
|
|
|
- const startPoint2 = dataService.getPoint(road2.startId);
|
|
|
- const endPoint2 = dataService.getPoint(road2.endId);
|
|
|
+ const startPoint2 = dataService.getRoadPoint(road2.startId);
|
|
|
+ const endPoint2 = dataService.getRoadPoint(road2.endId);
|
|
|
|
|
|
const join1 = mathUtil.getIntersectionPoint4(
|
|
|
startPoint1,
|
|
@@ -261,8 +261,8 @@ export default class MoveRoad {
|
|
|
startLimitLine = roadService.getMidLine(tempRoad);
|
|
|
|
|
|
let join = mathUtil.getIntersectionPoint(startLimitLine, newLine);
|
|
|
- const tempStartPoint = dataService.getPoint(tempRoad.startId);
|
|
|
- const tempEndPoint = dataService.getPoint(tempRoad.endId);
|
|
|
+ const tempStartPoint = dataService.getRoadPoint(tempRoad.startId);
|
|
|
+ const tempEndPoint = dataService.getRoadPoint(tempRoad.endId);
|
|
|
if (
|
|
|
angle > Constant.maxAngle ||
|
|
|
!mathUtil.isPointOnSegment(join, tempStartPoint, tempEndPoint)
|
|
@@ -296,11 +296,11 @@ export default class MoveRoad {
|
|
|
let tempRoad, tempRoadId;
|
|
|
info = dataService.roadIdForMinAngle(road.endId, roadId);
|
|
|
const road1 = dataService.getRoad(info.min0.roadId);
|
|
|
- const startPoint1 = dataService.getPoint(road1.startId);
|
|
|
- const endPoint1 = dataService.getPoint(road1.endId);
|
|
|
+ const startPoint1 = dataService.getRoadPoint(road1.startId);
|
|
|
+ const endPoint1 = dataService.getRoadPoint(road1.endId);
|
|
|
const road2 = dataService.getRoad(info.min1.roadId);
|
|
|
- const startPoint2 = dataService.getPoint(road2.startId);
|
|
|
- const endPoint2 = dataService.getPoint(road2.endId);
|
|
|
+ const startPoint2 = dataService.getRoadPoint(road2.startId);
|
|
|
+ const endPoint2 = dataService.getRoadPoint(road2.endId);
|
|
|
|
|
|
const join1 = mathUtil.getIntersectionPoint4(
|
|
|
startPoint1,
|
|
@@ -347,8 +347,8 @@ export default class MoveRoad {
|
|
|
const angle = roadService.AngleForRoad(tempRoadId, roadId);
|
|
|
endLimitLine = roadService.getMidLine(tempRoad);
|
|
|
let join = mathUtil.getIntersectionPoint(endLimitLine, newLine);
|
|
|
- const tempStartPoint = dataService.getPoint(tempRoad.start);
|
|
|
- const tempEndPoint = dataService.getPoint(tempRoad.end);
|
|
|
+ const tempStartPoint = dataService.getRoadPoint(tempRoad.start);
|
|
|
+ const tempEndPoint = dataService.getRoadPoint(tempRoad.end);
|
|
|
|
|
|
if (
|
|
|
angle > Constant.maxAngle ||
|
|
@@ -367,7 +367,7 @@ export default class MoveRoad {
|
|
|
// 是否可以移动point
|
|
|
// 两个判断:拖拽的墙(可能是多个),一方面不能与其他墙相交,另一方面这些墙之间或者与别的墙之间的角度必须大于Constant.minAngle
|
|
|
canMoveForPoint(pointId, position, linkedPointId, linkedRoadId) {
|
|
|
- const point = dataService.getPoint(pointId);
|
|
|
+ const point = dataService.getRoadPoint(pointId);
|
|
|
// 先判断第二点(这些墙之间或者与别的墙之间的角度必须大于MinAngle)
|
|
|
let flag = this.isOKForMinAngleRoad(pointId, position);
|
|
|
// 开始考虑第一点
|
|
@@ -385,7 +385,7 @@ export default class MoveRoad {
|
|
|
}
|
|
|
|
|
|
isOKForMinAngleRoad(pointId, position) {
|
|
|
- const point = dataService.getPoint(pointId);
|
|
|
+ const point = dataService.getRoadPoint(pointId);
|
|
|
const parent = point.parent;
|
|
|
|
|
|
const angle = this.getMinAngle(pointId, position);
|
|
@@ -401,7 +401,7 @@ export default class MoveRoad {
|
|
|
if (info && Math.abs(info.angle) < Constant.minAngle) {
|
|
|
return false;
|
|
|
} else {
|
|
|
- const otherPoint = dataService.getPoint(otherPointId);
|
|
|
+ const otherPoint = dataService.getRoadPoint(otherPointId);
|
|
|
if (mathUtil.getDistance(position, otherPoint) < Constant.minRealDis) {
|
|
|
return false;
|
|
|
}
|
|
@@ -413,7 +413,7 @@ export default class MoveRoad {
|
|
|
|
|
|
//点pointId移动到position后,求出最小角度
|
|
|
getMinAngle(pointId, position) {
|
|
|
- const point = dataService.getPoint(pointId);
|
|
|
+ const point = dataService.getRoadPoint(pointId);
|
|
|
const parent = point.parent;
|
|
|
let angle = null;
|
|
|
if (Object.keys(parent).length == 1) {
|
|
@@ -423,9 +423,9 @@ export default class MoveRoad {
|
|
|
const road2 = dataService.getRoad(Object.keys(parent)[1]);
|
|
|
|
|
|
const otherPointId1 = road1.getOtherPointId(pointId);
|
|
|
- const otherPoint1 = dataService.getPoint(otherPointId1);
|
|
|
+ const otherPoint1 = dataService.getRoadPoint(otherPointId1);
|
|
|
const otherPointId2 = road2.getOtherPointId(pointId);
|
|
|
- const otherPoint2 = dataService.getPoint(otherPointId2);
|
|
|
+ const otherPoint2 = dataService.getRoadPoint(otherPointId2);
|
|
|
|
|
|
angle = mathUtil.Angle(position, otherPoint1, otherPoint2);
|
|
|
return angle;
|
|
@@ -438,7 +438,7 @@ export default class MoveRoad {
|
|
|
for (const key in parent) {
|
|
|
const road = dataService.getRoad(key);
|
|
|
const otherPointId = road.getOtherPointId(pointId);
|
|
|
- const otherPoint = dataService.getPoint(otherPointId);
|
|
|
+ const otherPoint = dataService.getRoadPoint(otherPointId);
|
|
|
if (mathUtil.equalPoint(_position, otherPoint)) {
|
|
|
angles.push(0);
|
|
|
continue;
|
|
@@ -484,7 +484,7 @@ export default class MoveRoad {
|
|
|
// pointId是顶点
|
|
|
// position是roadId相对于pointId另一头的点的坐标,一般发生改变的时候使用这个函数
|
|
|
getNeighMinAngle(otherPointId, roadId, position) {
|
|
|
- const point1 = dataService.getPoint(otherPointId);
|
|
|
+ const point1 = dataService.getRoadPoint(otherPointId);
|
|
|
const point2 = {
|
|
|
x: position.x,
|
|
|
y: position.y,
|
|
@@ -501,7 +501,7 @@ export default class MoveRoad {
|
|
|
|
|
|
const road = dataService.getRoad(key);
|
|
|
pointId3 = road.getOtherPointId(otherPointId);
|
|
|
- point3 = dataService.getPoint(pointId3);
|
|
|
+ point3 = dataService.getRoadPoint(pointId3);
|
|
|
|
|
|
const angle = mathUtil.Angle(point1, point2, point3);
|
|
|
if (minAngle == null || minAngle > angle) {
|
|
@@ -533,7 +533,7 @@ export default class MoveRoad {
|
|
|
}
|
|
|
const _road = dataService.getRoad(_key);
|
|
|
const otherPointId = _road.getOtherPointId(pointId);
|
|
|
- const otherPoint = dataService.getPoint(otherPointId);
|
|
|
+ const otherPoint = dataService.getRoadPoint(otherPointId);
|
|
|
|
|
|
const flag = this.isOKForCrossTwoRoad(
|
|
|
position,
|
|
@@ -572,8 +572,8 @@ export default class MoveRoad {
|
|
|
dragRoadId
|
|
|
) {
|
|
|
const road = dataService.getRoad(roadId);
|
|
|
- const startPoint = dataService.getPoint(road.startId);
|
|
|
- const endPoint = dataService.getPoint(road.endId);
|
|
|
+ const startPoint = dataService.getRoadPoint(road.startId);
|
|
|
+ const endPoint = dataService.getRoadPoint(road.endId);
|
|
|
const join = mathUtil.getIntersectionPoint3(
|
|
|
position1,
|
|
|
position2,
|
|
@@ -651,8 +651,8 @@ export default class MoveRoad {
|
|
|
|
|
|
isOKForCrossTwoRoad2(position1, position2, roadId) {
|
|
|
const road = dataService.getRoad(roadId);
|
|
|
- const startPoint = dataService.getPoint(road.startId);
|
|
|
- const endPoint = dataService.getPoint(road.endId);
|
|
|
+ const startPoint = dataService.getRoadPoint(road.startId);
|
|
|
+ const endPoint = dataService.getRoadPoint(road.endId);
|
|
|
let flag = mathUtil.crossTwoLines(
|
|
|
position1,
|
|
|
position2,
|
|
@@ -678,8 +678,8 @@ export default class MoveRoad {
|
|
|
|
|
|
isOKForCrossTwoRoad3(position1, position2, roadId) {
|
|
|
const road = dataService.getRoad(roadId);
|
|
|
- const startPoint = dataService.getPoint(road.startId);
|
|
|
- const endPoint = dataService.getPoint(road.endId);
|
|
|
+ const startPoint = dataService.getRoadPoint(road.startId);
|
|
|
+ const endPoint = dataService.getRoadPoint(road.endId);
|
|
|
const flag = mathUtil.crossTwoLines(
|
|
|
position1,
|
|
|
position2,
|
|
@@ -728,8 +728,8 @@ export default class MoveRoad {
|
|
|
|
|
|
isCoincide(position1, position2, roadId) {
|
|
|
const road = dataService.getRoad(roadId);
|
|
|
- const startPoint = dataService.getPoint(road.startId);
|
|
|
- const endPoint = dataService.getPoint(road.endId);
|
|
|
+ const startPoint = dataService.getRoadPoint(road.startId);
|
|
|
+ const endPoint = dataService.getRoadPoint(road.endId);
|
|
|
let line = mathUtil.createLine1(position1, position2);
|
|
|
let join1 = mathUtil.getJoinLinePoint(startPoint, line);
|
|
|
let join2 = mathUtil.getJoinLinePoint(endPoint, line);
|
|
@@ -770,14 +770,14 @@ export default class MoveRoad {
|
|
|
// 更新virtualPosition(一般是吸附)
|
|
|
updateVirtualPosition(pointId, virtualPosition, limitRoadId, needNew) {
|
|
|
const limitRoad = dataService.getRoad(limitRoadId);
|
|
|
- const point = dataService.getPoint(pointId);
|
|
|
+ const point = dataService.getRoadPoint(pointId);
|
|
|
let otherPointId, otherPoint;
|
|
|
let adsorb = false;
|
|
|
// 不需要新建墙
|
|
|
if (!needNew) {
|
|
|
if (limitRoad != null) {
|
|
|
otherPointId = limitRoad.getOtherPointId(pointId);
|
|
|
- otherPoint = dataService.getPoint(otherPointId);
|
|
|
+ otherPoint = dataService.getRoadPoint(otherPointId);
|
|
|
// 会吸附另一头
|
|
|
if (
|
|
|
mathUtil.getDistance(virtualPosition, otherPoint) <
|
|
@@ -807,9 +807,9 @@ export default class MoveRoad {
|
|
|
|
|
|
// 两条线段的夹角,这两条线段分别有一个端点挨的很近
|
|
|
isOKForTwoSegmentsAngle(pointId, pointId1, pointId2) {
|
|
|
- const point = dataService.getPoint(pointId);
|
|
|
- const point1 = dataService.getPoint(pointId1);
|
|
|
- const point2 = dataService.getPoint(pointId2);
|
|
|
+ const point = dataService.getRoadPoint(pointId);
|
|
|
+ const point1 = dataService.getRoadPoint(pointId1);
|
|
|
+ const point2 = dataService.getRoadPoint(pointId2);
|
|
|
const dx = point.x - point1.x;
|
|
|
const dy = point.y - point1.y;
|
|
|
|
|
@@ -821,7 +821,7 @@ export default class MoveRoad {
|
|
|
for (const key in point.parent) {
|
|
|
const road = dataService.getRoad(key);
|
|
|
const otherPointId = road.getOtherPointId(pointId);
|
|
|
- const otherPoint = dataService.getPoint(otherPointId);
|
|
|
+ const otherPoint = dataService.getRoadPoint(otherPointId);
|
|
|
const angle = mathUtil.Angle(point, otherPoint, newPoint2);
|
|
|
if (Math.abs(angle) < Constant.minAngle) {
|
|
|
return false;
|
|
@@ -852,7 +852,7 @@ export default class MoveRoad {
|
|
|
}
|
|
|
// 可能吸附的是两堵墙,但是这两堵墙呈180°
|
|
|
else {
|
|
|
- let adsorbPoint = dataService.getPoint(adsorbPointId1);
|
|
|
+ let adsorbPoint = dataService.getRoadPoint(adsorbPointId1);
|
|
|
let parent = adsorbPoint.parent;
|
|
|
for (const key in parent) {
|
|
|
const angle = roadService.AngleForRoad3(roadId, key);
|
|
@@ -861,7 +861,7 @@ export default class MoveRoad {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- adsorbPoint = dataService.getPoint(adsorbPointId2);
|
|
|
+ adsorbPoint = dataService.getRoadPoint(adsorbPointId2);
|
|
|
parent = adsorbPoint.parent;
|
|
|
for (const key in parent) {
|
|
|
const angle = roadService.AngleForRoad3(roadId, key);
|
|
@@ -888,8 +888,8 @@ export default class MoveRoad {
|
|
|
adsorbPointId1,
|
|
|
adsorbPointId2
|
|
|
) {
|
|
|
- const startPoint = dataService.getPoint(startPointId);
|
|
|
- const endPoint = dataService.getPoint(endPointId);
|
|
|
+ const startPoint = dataService.getRoadPoint(startPointId);
|
|
|
+ const endPoint = dataService.getRoadPoint(endPointId);
|
|
|
let flag = true;
|
|
|
const roads = dataService.getRoads();
|
|
|
for (const key in roads) {
|
|
@@ -958,8 +958,8 @@ export default class MoveRoad {
|
|
|
dy = -dy;
|
|
|
|
|
|
const road = dataService.getRoad(roadId);
|
|
|
- const startPoint = dataService.getPoint(road.startId);
|
|
|
- const endPoint = dataService.getPoint(road.endId);
|
|
|
+ const startPoint = dataService.getRoadPoint(road.startId);
|
|
|
+ const endPoint = dataService.getRoadPoint(road.endId);
|
|
|
|
|
|
if (
|
|
|
Object.keys(startPoint.getParent()).length == 1 &&
|
|
@@ -1035,8 +1035,8 @@ export default class MoveRoad {
|
|
|
moveTo(pointId1, pointId2) {
|
|
|
const roadId = roadService.getRoadId(pointId1, pointId2);
|
|
|
// 不能重合
|
|
|
- let point1 = dataService.getPoint(pointId1);
|
|
|
- let point2 = dataService.getPoint(pointId2);
|
|
|
+ let point1 = dataService.getRoadPoint(pointId1);
|
|
|
+ let point2 = dataService.getRoadPoint(pointId2);
|
|
|
if (!point2) {
|
|
|
return false;
|
|
|
}
|
|
@@ -1051,7 +1051,7 @@ export default class MoveRoad {
|
|
|
|
|
|
const road1 = dataService.getRoad(roadId1);
|
|
|
const otherPointId1 = road1.getOtherPointId(pointId1);
|
|
|
- const otherPoint1 = dataService.getPoint(otherPointId1);
|
|
|
+ const otherPoint1 = dataService.getRoadPoint(otherPointId1);
|
|
|
|
|
|
for (const roadId2 in parent2) {
|
|
|
if (roadId2 == roadId) {
|
|
@@ -1059,7 +1059,7 @@ export default class MoveRoad {
|
|
|
}
|
|
|
const road2 = dataService.getRoad(roadId2);
|
|
|
const otherPointId2 = road2.getOtherPointId(pointId2);
|
|
|
- const otherPoint2 = dataService.getPoint(otherPointId2);
|
|
|
+ const otherPoint2 = dataService.getRoadPoint(otherPointId2);
|
|
|
const angle = mathUtil.Angle(point2, otherPoint1, otherPoint2);
|
|
|
if (Math.abs(angle) < Constant.minAngle) {
|
|
|
return false;
|
|
@@ -1071,8 +1071,8 @@ export default class MoveRoad {
|
|
|
dataService.deleteRoad(roadId);
|
|
|
}
|
|
|
|
|
|
- point1 = dataService.getPoint(pointId1);
|
|
|
- point2 = dataService.getPoint(pointId2);
|
|
|
+ point1 = dataService.getRoadPoint(pointId1);
|
|
|
+ point2 = dataService.getRoadPoint(pointId2);
|
|
|
if (!point1 || !point2) {
|
|
|
return false;
|
|
|
}
|
|
@@ -1088,11 +1088,11 @@ export default class MoveRoad {
|
|
|
|
|
|
// road1上pointId1被pointId2取代
|
|
|
if (road1.startId == pointId1) {
|
|
|
- dataService.deletePoint(road1.startId, roadId1);
|
|
|
+ dataService.deleteRoadPoint(road1.startId, roadId1);
|
|
|
road1.startId = pointId2;
|
|
|
point2.setPointParent(roadId1, "start");
|
|
|
} else if (road1.endId == pointId1) {
|
|
|
- dataService.deletePoint(road1.endId, roadId1);
|
|
|
+ dataService.deleteRoadPoint(road1.endId, roadId1);
|
|
|
road1.endId = pointId2;
|
|
|
point2.setPointParent(roadId1, "end");
|
|
|
} else {
|
|
@@ -1115,7 +1115,7 @@ export default class MoveRoad {
|
|
|
// roadService.subtraRoadFromIntersect(pointId, roadId);
|
|
|
// // 第二步更新端点坐标
|
|
|
// const newPointId = road.getPointId(dir);
|
|
|
- // const newPoint = dataService.getPoint(newPointId);
|
|
|
+ // const newPoint = dataService.getRoadPoint(newPointId);
|
|
|
// newPoint.setPosition(newPosition);
|
|
|
// // 第三步先新建墙
|
|
|
// roadService.create(pointId, newPointId);
|