|
@@ -4,6 +4,7 @@ import { dataService } from "./DataService.js";
|
|
|
import VectorCategory from "../enum/VectorCategory.js";
|
|
|
import { mathUtil } from "../Util/MathUtil.js";
|
|
|
import { lineService } from "./LineService.js";
|
|
|
+import Settings from "../Settings.js";
|
|
|
export default class PointService {
|
|
|
constructor() {}
|
|
|
|
|
@@ -41,6 +42,69 @@ export default class PointService {
|
|
|
dataService.deletePoint(pointId1);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ deletePoint(pointId) {
|
|
|
+ let point = dataService.getPoint(pointId);
|
|
|
+ const category = point.getCategory();
|
|
|
+ if (category == VectorCategory.Point.NormalPoint) {
|
|
|
+ dataService.deletePoint(pointId); //暂时简单粗暴
|
|
|
+ } else if (category == VectorCategory.Point.BasePoint) {
|
|
|
+ this.deleteBasePoint(pointId);
|
|
|
+ } else if (category == VectorCategory.Point.TestPoint) {
|
|
|
+ this.deleteTestPoint(pointId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ deleteBasePoint(basePointId) {
|
|
|
+ let points = dataService.getPoints();
|
|
|
+ let needDeletePointIds = [];
|
|
|
+ for (let key in points) {
|
|
|
+ let point = dataService.getPoint(key);
|
|
|
+ if (point.vectorId == basePointId) {
|
|
|
+ needDeletePointIds.push(basePointId);
|
|
|
+ } else if (point.linkedBasePointId == basePointId) {
|
|
|
+ needDeletePointIds.push(key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let lines = dataService.getLines();
|
|
|
+ for (let key in lines) {
|
|
|
+ let line = dataService.getLine(key);
|
|
|
+ if (
|
|
|
+ needDeletePointIds.indexOf(line.startId) > -1 ||
|
|
|
+ needDeletePointIds.indexOf(line.endId) > -1
|
|
|
+ ) {
|
|
|
+ dataService.deleteLine(key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dataService.deletePoint(basePointId);
|
|
|
+ if (Settings.selectBasePointId == basePointId) {
|
|
|
+ Settings.selectBasePointId = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ deleteTestPoint(testPointId) {
|
|
|
+ let points = dataService.getPoints();
|
|
|
+ let needDeletePointIds = [];
|
|
|
+ for (let key in points) {
|
|
|
+ let point = dataService.getPoint(key);
|
|
|
+ if (point.vectorId == testPointId) {
|
|
|
+ needDeletePointIds.push(testPointId);
|
|
|
+ } else if (point.linkedTestPointId == testPointId) {
|
|
|
+ needDeletePointIds.push(key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let lines = dataService.getLines();
|
|
|
+ for (let key in lines) {
|
|
|
+ let line = dataService.getLine(key);
|
|
|
+ if (
|
|
|
+ needDeletePointIds.indexOf(line.startId) > -1 ||
|
|
|
+ needDeletePointIds.indexOf(line.endId) > -1
|
|
|
+ ) {
|
|
|
+ dataService.deleteLine(key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dataService.deletePoint(testPointId);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
const pointService = new PointService();
|