|
@@ -10,30 +10,42 @@ import { mathUtil } from "../Util/MathUtil";
|
|
|
export default class MovePoint {
|
|
|
constructor() {}
|
|
|
|
|
|
+ // movePoint(position, pointId) {
|
|
|
+ // let point = dataService.getPoint(pointId);
|
|
|
+ // point.x = position.x;
|
|
|
+ // point.y = position.y;
|
|
|
+ // if (point.getCategory() == VectorCategory.Point.TestPoint) {
|
|
|
+ // this.updatePositionByTestPoint(pointId);
|
|
|
+ // } else if (point.getCategory() == VectorCategory.Point.BasePoint) {
|
|
|
+ // this.updateBasePoint(pointId);
|
|
|
+ // } else {
|
|
|
+ // let parent = point.getParent();
|
|
|
+ // for (let key in parent) {
|
|
|
+ // let line = dataService.getLine(key);
|
|
|
+ // line.setValue(null);
|
|
|
+ // //拖拽的点是基准线
|
|
|
+ // if (line.category == VectorCategory.Line.BaseLine) {
|
|
|
+ // let points = dataService.getPoints();
|
|
|
+ // for (let key in points) {
|
|
|
+ // let testPoint = dataService.getPoint(key);
|
|
|
+ // if (testPoint.category == VectorCategory.Point.TestPoint) {
|
|
|
+ // this.updatePositionByTestPoint(key);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
movePoint(position, pointId) {
|
|
|
let point = dataService.getPoint(pointId);
|
|
|
- point.x = position.x;
|
|
|
- point.y = position.y;
|
|
|
- if (point.getCategory() == VectorCategory.Point.TestPoint) {
|
|
|
- this.updatePositionByTestPoint(pointId);
|
|
|
- } else if (point.getCategory() == VectorCategory.Point.BasePoint) {
|
|
|
- this.updateBasePoint(pointId);
|
|
|
+ if (point.getCategory() == VectorCategory.Point.BasePoint) {
|
|
|
+ this.updateBasePoint(position, pointId);
|
|
|
+ } else if (point.getCategory() == VectorCategory.Point.FixPoint) {
|
|
|
+ this.updateFixPoint(position, pointId);
|
|
|
} else {
|
|
|
- let parent = point.getParent();
|
|
|
- for (let key in parent) {
|
|
|
- let line = dataService.getLine(key);
|
|
|
- line.setValue(null);
|
|
|
- //拖拽的点是基准线
|
|
|
- if (line.category == VectorCategory.Line.BaseLine) {
|
|
|
- let points = dataService.getPoints();
|
|
|
- for (let key in points) {
|
|
|
- let testPoint = dataService.getPoint(key);
|
|
|
- if (testPoint.category == VectorCategory.Point.TestPoint) {
|
|
|
- this.updatePositionByTestPoint(key);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ point.x = position.x;
|
|
|
+ point.y = position.y;
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -213,17 +225,84 @@ export default class MovePoint {
|
|
|
mathUtil.clonePoint(testBasePoint, join);
|
|
|
}
|
|
|
|
|
|
- updateBasePoint(basePointId) {
|
|
|
- let points = dataService.getPoints();
|
|
|
- for (let key in points) {
|
|
|
- let point = dataService.getPoint(key);
|
|
|
- if (
|
|
|
- point.getCategory() == VectorCategory.Point.TestPoint &&
|
|
|
- point.getLinkedBasePointId() == basePointId
|
|
|
+ // updateBasePoint(basePointId) {
|
|
|
+ // let points = dataService.getPoints();
|
|
|
+ // for (let key in points) {
|
|
|
+ // let point = dataService.getPoint(key);
|
|
|
+ // if (
|
|
|
+ // point.getCategory() == VectorCategory.Point.TestPoint &&
|
|
|
+ // point.getLinkedBasePointId() == basePointId
|
|
|
+ // ) {
|
|
|
+ // this.updatePositionByTestPoint(key);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+
|
|
|
+ updateBasePoint(position, basePointId) {
|
|
|
+ let lineGeometry = dataService.getLine(Settings.baseLineId);
|
|
|
+ let startPoint = dataService.getPoint(lineGeometry.startId);
|
|
|
+ let endPoint = dataService.getPoint(lineGeometry.endId);
|
|
|
+ lineGeometry = mathUtil.createLine1(startPoint, endPoint);
|
|
|
+ let basePoint = dataService.getPoint(basePointId);
|
|
|
+ let parent = basePoint.getParent();
|
|
|
+ for (let key in parent) {
|
|
|
+ let line = dataService.getLine(key);
|
|
|
+ if (line.getCategory() == VectorCategory.Line.LocationLineByBasePoint) {
|
|
|
+ let otherPointId = line.getOtherPointId(basePointId);
|
|
|
+ let otherPoint = dataService.getPoint(otherPointId);
|
|
|
+ let otherLine = mathUtil.getLineForPoint(lineGeometry, otherPoint);
|
|
|
+ line = mathUtil.createLine3(lineGeometry, position);
|
|
|
+ let join = mathUtil.getIntersectionPoint(line, otherLine);
|
|
|
+ mathUtil.clonePoint(otherPoint, join);
|
|
|
+ mathUtil.clonePoint(basePoint, position);
|
|
|
+ } else if (
|
|
|
+ line.getCategory() == VectorCategory.Line.ExtendedPositionLine
|
|
|
) {
|
|
|
- this.updatePositionByTestPoint(key);
|
|
|
+ let otherPointId = line.getOtherPointId(basePointId);
|
|
|
+ let otherPoint = dataService.getPoint(otherPointId);
|
|
|
+ let otherLine = mathUtil.createLine3(lineGeometry, otherPoint);
|
|
|
+ let join = mathUtil.getJoinLinePoint(position, otherLine);
|
|
|
+ mathUtil.clonePoint(otherPoint, join);
|
|
|
+ mathUtil.clonePoint(basePoint, position);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ updateFixPoint(position, fixPointId) {
|
|
|
+ let fixPoint = dataService.getPoint(fixPointId);
|
|
|
+ let basePoint = dataService.getPoint(fixPoint.linkedBasePointId);
|
|
|
+ let baseLine = dataService.getLine(Settings.baseLineId);
|
|
|
+ let startPoint = dataService.getPoint(baseLine.startId);
|
|
|
+ let endPoint = dataService.getPoint(baseLine.endId);
|
|
|
+
|
|
|
+ let baseLineGeometry = mathUtil.createLine1(startPoint, endPoint);
|
|
|
+ let vLine = mathUtil.getVerticalLine(baseLineGeometry, position);
|
|
|
+ let join = mathUtil.getIntersectionPoint(baseLineGeometry, vLine);
|
|
|
+
|
|
|
+ let parent = fixPoint.getParent();
|
|
|
+ for (let key in parent) {
|
|
|
+ let line = dataService.getLine(key);
|
|
|
+ if (line.getCategory() == VectorCategory.Line.LocationLineByFixPoint) {
|
|
|
+ let otherPointId = line.getOtherPointId(fixPointId);
|
|
|
+ let otherPoint = dataService.getPoint(otherPointId);
|
|
|
+ mathUtil.clonePoint(otherPoint, join);
|
|
|
+ } else if (line.getCategory() == VectorCategory.Line.GuideLocationLine) {
|
|
|
+ let otherPointId = line.getOtherPointId(fixPointId);
|
|
|
+ let otherPoint = dataService.getPoint(otherPointId);
|
|
|
+ let line2 = mathUtil.createLine3(baseLineGeometry, otherPoint);
|
|
|
+ join = mathUtil.getIntersectionPoint(line2, vLine);
|
|
|
+ mathUtil.clonePoint(otherPoint, join);
|
|
|
+ } else if (
|
|
|
+ line.getCategory() == VectorCategory.Line.ExtendedPositionLine
|
|
|
+ ) {
|
|
|
+ let otherPointId = line.getOtherPointId(fixPointId);
|
|
|
+ let otherPoint = dataService.getPoint(otherPointId);
|
|
|
+ let line2 = mathUtil.createLine3(baseLineGeometry, fixPoint);
|
|
|
+ join = mathUtil.getJoinLinePoint(otherPoint, line2);
|
|
|
+ mathUtil.clonePoint(otherPoint, join);
|
|
|
}
|
|
|
}
|
|
|
+ mathUtil.clonePoint(fixPoint, position);
|
|
|
}
|
|
|
|
|
|
/*****************************************************************************曲线上的点********************************************************************************/
|