|
@@ -1,91 +1,18 @@
|
|
|
import Constant from "../Constant";
|
|
|
+import Settings from "../Settings";
|
|
|
+
|
|
|
import { dataService } from "../Service/DataService";
|
|
|
import { lineService } from "../Service/LineService";
|
|
|
import { pointService } from "../Service/PointService";
|
|
|
import { movePoint } from "./MovePoint";
|
|
|
import { mathUtil } from "../Util/MathUtil";
|
|
|
import VectorCategory from "../enum/VectorCategory";
|
|
|
+import { locationModeControl } from "./LocationModeControl";
|
|
|
+import { uiService } from "../Service/UIService";
|
|
|
|
|
|
export default class MoveLine {
|
|
|
constructor() {}
|
|
|
|
|
|
- // moveLine(lineId, dx, dy) {
|
|
|
- // dx = dx;
|
|
|
- // dy = -dy;
|
|
|
- // let line = dataService.getLine(lineId);
|
|
|
- // let startPoint = dataService.getPoint(line.startId);
|
|
|
- // let endPoint = dataService.getPoint(line.endId);
|
|
|
-
|
|
|
- // //垂直移动
|
|
|
- // if (line.getCategory() == VectorCategory.Line.PositionLine && line.getLocationMode() == Constant.angleLocationMode) {
|
|
|
- // let point1 = {
|
|
|
- // x: startPoint.x + dx,
|
|
|
- // y: startPoint.y + dy,
|
|
|
- // };
|
|
|
- // let point2 = {
|
|
|
- // x: endPoint.x + dx,
|
|
|
- // y: endPoint.y + dy,
|
|
|
- // };
|
|
|
- // let lineGeometry = mathUtil.createLine1(point1, point2);
|
|
|
- // point1 = mathUtil.getJoinLinePoint(startPoint, lineGeometry);
|
|
|
- // //startPoint本来是基准点
|
|
|
- // if (startPoint.getCategory() == VectorCategory.Point.BasePoint) {
|
|
|
- // //达到一定距离才能移动
|
|
|
- // if (mathUtil.getDistance(startPoint, point1) < Constant.minAdsorbPix) {
|
|
|
- // return false;
|
|
|
- // }
|
|
|
- // let newStartPoint = pointService.create(point1);
|
|
|
- // let extendedPositionLine = lineService.createByPointId(startPoint.vectorId, newStartPoint.vectorId, VectorCategory.Line.ExtendedPositionLine);
|
|
|
- // extendedPositionLine.setLocationMode(Constant.angleLocationMode);
|
|
|
- // dataService.deletePointParent(startPoint.vectorId, lineId);
|
|
|
- // line.startId = newStartPoint.vectorId;
|
|
|
- // newStartPoint.setPointParent(line.vectorId, 'start');
|
|
|
- // newStartPoint.setCategory(VectorCategory.Point.TestBasePoint);
|
|
|
- // } else {
|
|
|
- // startPoint.x = point1.x;
|
|
|
- // startPoint.y = point1.y;
|
|
|
- // let parents = Object.keys(startPoint.parent);
|
|
|
- // let extendedLine = dataService.getLine(parents[0]);
|
|
|
- // if (extendedLine.getCategory() != VectorCategory.Line.ExtendedPositionLine) {
|
|
|
- // extendedLine = dataService.getLine(parents[1]);
|
|
|
- // }
|
|
|
- // if (extendedLine.getCategory() == VectorCategory.Line.ExtendedPositionLine) {
|
|
|
- // //point1是基准点
|
|
|
- // point1 = dataService.getPoint(extendedLine.startId);
|
|
|
- // point2 = dataService.getPoint(extendedLine.endId);
|
|
|
- // if (mathUtil.getDistance(point1, point2) < Constant.minAdsorbPix) {
|
|
|
- // dataService.deleteLine(extendedLine.vectorId);
|
|
|
- // dataService.deletePoint(extendedLine.endId);
|
|
|
-
|
|
|
- // line.startId = point1.vectorId;
|
|
|
- // point1.setPointParent(line.vectorId, 'start');
|
|
|
-
|
|
|
- // lineGeometry = mathUtil.createLine3(lineGeometry, point1);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
-
|
|
|
- // point2 = mathUtil.getJoinLinePoint(endPoint, lineGeometry);
|
|
|
- // endPoint.x = point2.x;
|
|
|
- // endPoint.y = point2.y;
|
|
|
- // } else {
|
|
|
- // //综合定位和垂线定位,拖动基准线更新位置
|
|
|
- // if (line.getCategory() == VectorCategory.Line.BaseLine) {
|
|
|
- // let points = dataService.vectorData.points;
|
|
|
- // for (let key in points) {
|
|
|
- // if (points[key].category == VectorCategory.Point.TestPoint && (points[key].locationMode == Constant.allLocationMode || points[key].locationMode == Constant.normalLocationMode)) {
|
|
|
- // movePoint.updatePositionByTestPoint(points[key].vectorId);
|
|
|
- // }
|
|
|
- // }
|
|
|
- // }
|
|
|
- // startPoint.x += dx;
|
|
|
- // startPoint.y += dy;
|
|
|
- // endPoint.x += dx;
|
|
|
- // endPoint.y += dy;
|
|
|
- // }
|
|
|
- // return true;
|
|
|
- // }
|
|
|
-
|
|
|
moveLine(lineId, dx, dy) {
|
|
|
dx = dx;
|
|
|
dy = -dy;
|
|
@@ -93,10 +20,16 @@ export default class MoveLine {
|
|
|
let startPoint = dataService.getPoint(line.startId);
|
|
|
let endPoint = dataService.getPoint(line.endId);
|
|
|
|
|
|
+ let baseLine = dataService.getLine(Settings.baseLineId);
|
|
|
+ if (baseLine) {
|
|
|
+ let baseStartPoint = dataService.getPoint(baseLine.startId);
|
|
|
+ let baseEndPoint = dataService.getPoint(baseLine.endId);
|
|
|
+ baseLine = mathUtil.createLine1(baseStartPoint, baseEndPoint);
|
|
|
+ }
|
|
|
+
|
|
|
//垂直移动,直角定位法只支持定位线的拖拽
|
|
|
if (
|
|
|
- (line.getCategory() == VectorCategory.Line.LocationLineByFixPoint ||
|
|
|
- line.getCategory() == VectorCategory.Line.LocationLineByBasePoint) &&
|
|
|
+ line.getCategory() == VectorCategory.Line.LocationLineByBasePoint &&
|
|
|
line.getLocationMode() == Constant.angleLocationMode
|
|
|
) {
|
|
|
let point1 = {
|
|
@@ -122,6 +55,9 @@ export default class MoveLine {
|
|
|
VectorCategory.Line.ExtendedPositionLine
|
|
|
);
|
|
|
extendedPositionLine.setLocationMode(Constant.angleLocationMode);
|
|
|
+ extendedPositionLine.setLinkedBasePointId(line.getLinkedBasePointId());
|
|
|
+ extendedPositionLine.setLinkedFixPointId(line.getLinkedFixPointId());
|
|
|
+
|
|
|
dataService.deletePointParent(startPoint.vectorId, lineId);
|
|
|
line.startId = newStartPoint.vectorId;
|
|
|
newStartPoint.setPointParent(line.vectorId, "start");
|
|
@@ -157,6 +93,75 @@ export default class MoveLine {
|
|
|
point2 = mathUtil.getJoinLinePoint(endPoint, lineGeometry);
|
|
|
endPoint.x = point2.x;
|
|
|
endPoint.y = point2.y;
|
|
|
+ } else if (
|
|
|
+ line.getCategory() == VectorCategory.Line.LocationLineByFixPoint &&
|
|
|
+ line.getLocationMode() == Constant.angleLocationMode
|
|
|
+ ) {
|
|
|
+ let point1 = {
|
|
|
+ x: startPoint.x + dx,
|
|
|
+ y: startPoint.y + dy,
|
|
|
+ };
|
|
|
+ let point2 = {
|
|
|
+ x: endPoint.x + dx,
|
|
|
+ y: endPoint.y + dy,
|
|
|
+ };
|
|
|
+ let lineGeometry = mathUtil.createLine1(point1, point2);
|
|
|
+ point1 = mathUtil.getJoinLinePoint(startPoint, lineGeometry);
|
|
|
+ if (startPoint.getCategory() == VectorCategory.Point.FixPoint) {
|
|
|
+ //达到一定距离才能移动
|
|
|
+ if (mathUtil.getDistance(startPoint, point1) < Constant.minAdsorbPix) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ let newStartPoint = pointService.create(point1);
|
|
|
+ let extendedPositionLine = lineService.createByPointId(
|
|
|
+ startPoint.vectorId,
|
|
|
+ newStartPoint.vectorId,
|
|
|
+ VectorCategory.Line.ExtendedPositionLine
|
|
|
+ );
|
|
|
+ extendedPositionLine.setLocationMode(Constant.angleLocationMode);
|
|
|
+ extendedPositionLine.setLinkedBasePointId(line.getLinkedBasePointId());
|
|
|
+ extendedPositionLine.setLinkedFixPointId(line.getLinkedFixPointId());
|
|
|
+
|
|
|
+ dataService.deletePointParent(startPoint.vectorId, lineId);
|
|
|
+ line.startId = newStartPoint.vectorId;
|
|
|
+ newStartPoint.setPointParent(line.vectorId, "start");
|
|
|
+ newStartPoint.setCategory(VectorCategory.Point.TestBasePoint);
|
|
|
+ let join = mathUtil.getIntersectionPoint(lineGeometry, baseLine);
|
|
|
+ mathUtil.clonePoint(endPoint, join);
|
|
|
+ } else {
|
|
|
+ let extendedPositionLine = mathUtil.createLine3(baseLine, startPoint);
|
|
|
+ let join = mathUtil.getIntersectionPoint(
|
|
|
+ lineGeometry,
|
|
|
+ extendedPositionLine
|
|
|
+ );
|
|
|
+ mathUtil.clonePoint(startPoint, join);
|
|
|
+ join = mathUtil.getIntersectionPoint(lineGeometry, baseLine);
|
|
|
+ mathUtil.clonePoint(endPoint, join);
|
|
|
+
|
|
|
+ let parent = startPoint.getParent();
|
|
|
+ for (let key in parent) {
|
|
|
+ if (key == lineId) {
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ extendedPositionLine = dataService.getLine(key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ startPoint = dataService.getPoint(extendedPositionLine.startId);
|
|
|
+ if (mathUtil.getDistance(point1, startPoint) < Constant.minAdsorbPix) {
|
|
|
+ let otherPointId = extendedPositionLine.getOtherPointId(
|
|
|
+ startPoint.vectorId
|
|
|
+ );
|
|
|
+ let otherPoint = dataService.getPoint(otherPointId);
|
|
|
+ if (startPoint.getCategory() == VectorCategory.Point.FixPoint) {
|
|
|
+ dataService.deleteLine(extendedPositionLine.vectorId);
|
|
|
+ dataService.deletePoint(otherPoint.vectorId);
|
|
|
+ line.startId = startPoint.vectorId;
|
|
|
+ startPoint.setPointParent(line.vectorId, "start");
|
|
|
+ }
|
|
|
+ join = mathUtil.getJoinLinePoint(startPoint, baseLine);
|
|
|
+ mathUtil.clonePoint(endPoint, join);
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
//综合定位和垂线定位,拖动基准线更新位置
|
|
|
//缺
|
|
@@ -164,6 +169,11 @@ export default class MoveLine {
|
|
|
startPoint.y += dy;
|
|
|
endPoint.x += dx;
|
|
|
endPoint.y += dy;
|
|
|
+ if (line.getCategory() == VectorCategory.Line.BaseLine) {
|
|
|
+ if (uiService.getSelectLocationMode() == Constant.angleLocationMode) {
|
|
|
+ locationModeControl.setAngle();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
return true;
|
|
|
}
|