|
@@ -1,16 +1,17 @@
|
|
|
-import { dataService } from "../Service/DataService";
|
|
|
-import { lineService } from "../Service/LineService";
|
|
|
-import { listenLayer } from "../ListenLayer";
|
|
|
-import VectorCategory from "../enum/VectorCategory";
|
|
|
-import Point from "../Geometry/Point.js";
|
|
|
-import { mathUtil } from "../Util/MathUtil";
|
|
|
-import Settings from "../Settings";
|
|
|
-import { pointService } from "../Service/PointService";
|
|
|
-
|
|
|
+import { dataService } from '../Service/DataService';
|
|
|
+import { lineService } from '../Service/LineService';
|
|
|
+import { listenLayer } from '../ListenLayer';
|
|
|
+import VectorCategory from '../enum/VectorCategory';
|
|
|
+import Point from '../Geometry/Point.js';
|
|
|
+import { mathUtil } from '../Util/MathUtil';
|
|
|
+import Settings from '../Settings';
|
|
|
+import { pointService } from '../Service/PointService';
|
|
|
+import Constant from '../Constant';
|
|
|
export default class AddLine {
|
|
|
constructor() {
|
|
|
this.newLine = null;
|
|
|
this.startInfo = {};
|
|
|
+ this.testLineIds = []; //所有待测点
|
|
|
}
|
|
|
|
|
|
setPointInfo(pointInfo) {
|
|
@@ -34,19 +35,25 @@ export default class AddLine {
|
|
|
}
|
|
|
|
|
|
buildLine(position) {
|
|
|
- if (
|
|
|
- this.newLine == null &&
|
|
|
- !mathUtil.equalPoint(this.startInfo.position, position)
|
|
|
- ) {
|
|
|
+ // if (Settings.selectLineCategory == VectorCategory.Line.NormalLine) {
|
|
|
+ if (this.newLine == null && !mathUtil.equalPoint(this.startInfo.position, position)) {
|
|
|
this.newLine = lineService.create(this.startInfo.position, position);
|
|
|
+ if (Settings.selectLineCategory == VectorCategory.Line.FreeMeasureLine) {
|
|
|
+ this.testLineIds.push(this.newLine.vectorId);
|
|
|
+ this.newLine.setLocationMode(Constant.freeLocationMode);
|
|
|
+ }
|
|
|
}
|
|
|
+ // } else {
|
|
|
+ // console.error(this.startInfo.position, position);
|
|
|
+ // if (Settings.selectLineCategory == Constant.freeLocationMode) {
|
|
|
+ // this.newLine = lineService.create(this.startInfo.position, position);
|
|
|
+ // this.newLine.setLocationMode(Constant.freeLocationMode);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
}
|
|
|
|
|
|
updateLine(position) {
|
|
|
- if (
|
|
|
- this.newLine != null &&
|
|
|
- !mathUtil.equalPoint(this.startInfo.position, position)
|
|
|
- ) {
|
|
|
+ if (this.newLine != null && !mathUtil.equalPoint(this.startInfo.position, position)) {
|
|
|
let point = dataService.getPoint(this.newLine.endId);
|
|
|
point.setPosition(position);
|
|
|
}
|
|
@@ -63,10 +70,7 @@ export default class AddLine {
|
|
|
this.newLine.getCategory() != VectorCategory.Line.DoubleArrowLine &&
|
|
|
this.newLine.getCategory() != VectorCategory.Line.GuideLine
|
|
|
) {
|
|
|
- pointService.mergePoint(
|
|
|
- this.newLine.endId,
|
|
|
- listenLayer.modifyPoint.linkedPointId
|
|
|
- );
|
|
|
+ pointService.mergePoint(this.newLine.endId, listenLayer.modifyPoint.linkedPointId);
|
|
|
}
|
|
|
if (this.newLine.getCategory() == VectorCategory.Line.BaseLine) {
|
|
|
Settings.baseLineId = this.newLine.vectorId;
|
|
@@ -75,22 +79,13 @@ export default class AddLine {
|
|
|
}
|
|
|
|
|
|
buildCurveLine(position) {
|
|
|
- if (
|
|
|
- this.newLine == null &&
|
|
|
- !mathUtil.equalPoint(this.startInfo.position, position)
|
|
|
- ) {
|
|
|
- this.newLine = lineService.createCurveLine(
|
|
|
- this.startInfo.position,
|
|
|
- position
|
|
|
- );
|
|
|
+ if (this.newLine == null && !mathUtil.equalPoint(this.startInfo.position, position)) {
|
|
|
+ this.newLine = lineService.createCurveLine(this.startInfo.position, position);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
updateCurveLine(position) {
|
|
|
- if (
|
|
|
- this.newLine != null &&
|
|
|
- !mathUtil.equalPoint(this.startInfo.position, position)
|
|
|
- ) {
|
|
|
+ if (this.newLine != null && !mathUtil.equalPoint(this.startInfo.position, position)) {
|
|
|
let curvePoint = dataService.getCurvePoint(this.newLine.endId);
|
|
|
curvePoint.setPosition(position);
|
|
|
}
|
|
@@ -113,6 +108,14 @@ export default class AddLine {
|
|
|
this.newLine = null;
|
|
|
this.startInfo = {};
|
|
|
}
|
|
|
+
|
|
|
+ deleteTestLines() {
|
|
|
+ for (let i = 0; i < this.testLineIds.length; ++i) {
|
|
|
+ console.log(this.testLineIds[i]);
|
|
|
+ dataService.deleteLine(this.testLineIds[i]);
|
|
|
+ }
|
|
|
+ this.testLineIds = [];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const addLine = new AddLine();
|