|
@@ -17,18 +17,34 @@ export default class AddPoint {
|
|
|
}
|
|
|
|
|
|
buildPoint(position) {
|
|
|
- const newPoint = pointService.create(position);
|
|
|
- if (newPoint.getCategory() == VectorCategory.Point.BasePoint) {
|
|
|
+ let newPoint;
|
|
|
+ if (Settings.pointCategory == VectorCategory.Point.BasePoint) {
|
|
|
+ newPoint = pointService.create(position);
|
|
|
Settings.selectBasePointId = newPoint.vectorId;
|
|
|
} else {
|
|
|
- if (Settings.locationMode == Constant.angleLocationMode) {
|
|
|
+ if (
|
|
|
+ Settings.selectBasePointId != null &&
|
|
|
+ Settings.locationMode == Constant.angleLocationMode
|
|
|
+ ) {
|
|
|
+ newPoint = pointService.create(position);
|
|
|
this.setLocationByAngle(newPoint.vectorId);
|
|
|
- } else if (Settings.locationMode == Constant.allLocationMode) {
|
|
|
+ newPoint.setLocationMode(Constant.angleLocationMode);
|
|
|
+ } else if (
|
|
|
+ Settings.selectBasePointId != null &&
|
|
|
+ Settings.locationMode == Constant.allLocationMode
|
|
|
+ ) {
|
|
|
+ newPoint = pointService.create(position);
|
|
|
this.setLocationByAll(newPoint.vectorId);
|
|
|
+ newPoint.setLocationMode(Constant.allLocationMode);
|
|
|
} else if (Settings.locationMode == Constant.normalLocationMode) {
|
|
|
+ newPoint = pointService.create(position);
|
|
|
this.setLocationByNormal(newPoint.vectorId);
|
|
|
+ newPoint.setLocationMode(Constant.normalLocationMode);
|
|
|
}
|
|
|
- if (newPoint.getCategory() == VectorCategory.Point.TestPoint) {
|
|
|
+ if (
|
|
|
+ newPoint &&
|
|
|
+ newPoint.getCategory() == VectorCategory.Point.TestPoint
|
|
|
+ ) {
|
|
|
this.testPointIds.push(newPoint.vectorId);
|
|
|
}
|
|
|
}
|
|
@@ -50,10 +66,8 @@ export default class AddPoint {
|
|
|
setLocationByAngle(testPointId) {
|
|
|
let basePoint = this.isFocusBasePoint();
|
|
|
if (!basePoint) {
|
|
|
- console.error("没有基准点");
|
|
|
return;
|
|
|
}
|
|
|
- console.error("选中基准点:" + basePoint.vectorId);
|
|
|
let testPoint = dataService.getPoint(testPointId);
|
|
|
if (testPoint.getCategory() != VectorCategory.Point.TestPoint) {
|
|
|
return;
|
|
@@ -67,6 +81,7 @@ export default class AddPoint {
|
|
|
let join = mathUtil.getJoinLinePoint(basePoint, vLine);
|
|
|
join = pointService.create(join);
|
|
|
join.setCategory(VectorCategory.Point.TestBasePoint);
|
|
|
+ join.setLocationMode(Constant.angleLocationMode);
|
|
|
join.setLinkedBasePointId(basePoint.vectorId);
|
|
|
join.setLinkedTestPointId(testPointId);
|
|
|
lineService.createByPointId(
|
|
@@ -82,38 +97,6 @@ export default class AddPoint {
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- //待测基准点,待测点与基准线相交的点
|
|
|
- getTestBasePoint(basePointId, testPointId) {
|
|
|
- let points = dataService.getPoints();
|
|
|
- for (let key in points) {
|
|
|
- const point = dataService.getPoint(key);
|
|
|
- if (point.getCategory() == VectorCategory.Point.TestBasePoint) {
|
|
|
- if (
|
|
|
- point.getLinkedBasePointId() == basePointId &&
|
|
|
- point.getLinkedTestPointId() == testPointId
|
|
|
- ) {
|
|
|
- return point;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- //更新待测点(直角定位法)
|
|
|
- updateTestPointByAngle(testPointId, newPosition) {
|
|
|
- let testPoint = dataService.getPoint(testPointId);
|
|
|
- mathUtil.clonePoint(testPoint, newPosition);
|
|
|
- let basePoint = dataService.getPoint(testPoint.getLinkedBasePointId());
|
|
|
- let lineGeometry = dataService.getLine(Settings.baseLineId);
|
|
|
- let startPoint = dataService.getPoint(lineGeometry.startId);
|
|
|
- let endPoint = dataService.getPoint(lineGeometry.endId);
|
|
|
- let line = mathUtil.createLine1(startPoint, endPoint);
|
|
|
- let vLine = mathUtil.getVerticalLine(line, testPoint);
|
|
|
- let join = mathUtil.getJoinLinePoint(basePoint, vLine);
|
|
|
- let testBasePoint = this.getTestBasePoint(basePoint.vectorId, testPointId);
|
|
|
- mathUtil.clonePoint(testBasePoint, join);
|
|
|
- }
|
|
|
-
|
|
|
//综合定位法
|
|
|
setLocationByAll(testPointId) {
|
|
|
let basePoint = this.isFocusBasePoint();
|
|
@@ -130,6 +113,7 @@ export default class AddPoint {
|
|
|
let join = mathUtil.getJoinLinePoint(testPoint, line);
|
|
|
join = pointService.create(join); //经过待测点且与基准线垂直的线段,与基准线的交点
|
|
|
join.setCategory(VectorCategory.Point.TestBasePoint);
|
|
|
+ join.setLocationMode(Constant.allLocationMode);
|
|
|
join.setLinkedBasePointId(basePoint.vectorId);
|
|
|
join.setLinkedTestPointId(testPointId);
|
|
|
//待测点与基准线的垂直线
|
|
@@ -159,20 +143,6 @@ export default class AddPoint {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //更新待测点(综合定位法)
|
|
|
- updateTestPointByAll(testPointId, newPosition) {
|
|
|
- let testPoint = dataService.getPoint(testPointId);
|
|
|
- mathUtil.clonePoint(testPoint, newPosition);
|
|
|
- let basePoint = dataService.getPoint(testPoint.getLinkedBasePointId());
|
|
|
- let lineGeometry = dataService.getLine(Settings.baseLineId);
|
|
|
- let startPoint = dataService.getPoint(lineGeometry.startId);
|
|
|
- let endPoint = dataService.getPoint(lineGeometry.endId);
|
|
|
- let line = mathUtil.createLine1(startPoint, endPoint);
|
|
|
- let join = getJoinLinePoint(testPoint, line);
|
|
|
- let testBasePoint = this.getTestBasePoint(basePoint.vectorId, testPointId);
|
|
|
- mathUtil.clonePoint(testBasePoint, join);
|
|
|
- }
|
|
|
-
|
|
|
setLocationByNormal(testPointId) {
|
|
|
let testPoint = dataService.getPoint(testPointId);
|
|
|
if (testPoint.getCategory() != VectorCategory.Point.TestPoint) {
|
|
@@ -186,6 +156,7 @@ export default class AddPoint {
|
|
|
let join = mathUtil.getIntersectionPoint(vLine, line);
|
|
|
join = pointService.create(join);
|
|
|
join.setCategory(VectorCategory.Point.TestBasePoint);
|
|
|
+ join.setLocationMode(Constant.normalLocationMode);
|
|
|
join.setLinkedTestPointId(testPointId);
|
|
|
lineService.createByPointId(
|
|
|
testPointId,
|
|
@@ -193,20 +164,6 @@ export default class AddPoint {
|
|
|
VectorCategory.Line.PositionLine
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
- //更新待测点(自由定位法)
|
|
|
- updateTestPointByNormal(testPointId, newPosition) {
|
|
|
- let testPoint = dataService.getPoint(testPointId);
|
|
|
- mathUtil.clonePoint(testPoint, newPosition);
|
|
|
- let basePoint = dataService.getPoint(testPoint.getLinkedBasePointId());
|
|
|
- let lineGeometry = dataService.getLine(Settings.baseLineId);
|
|
|
- let startPoint = dataService.getPoint(lineGeometry.startId);
|
|
|
- let endPoint = dataService.getPoint(lineGeometry.endId);
|
|
|
- let line = mathUtil.createLine1(startPoint, endPoint);
|
|
|
- let join = getJoinLinePoint(testPoint, line);
|
|
|
- let testBasePoint = this.getTestBasePoint(basePoint.vectorId, testPointId);
|
|
|
- mathUtil.clonePoint(testBasePoint, join);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
const addPoint = new AddPoint();
|