|
@@ -1,4 +1,5 @@
|
|
|
import Point from "../Geometry/Point.js";
|
|
|
+import Line from "../Geometry/Line.js";
|
|
|
import Road from "../Geometry/Road.js";
|
|
|
import RoadEdge from "../Geometry/RoadEdge.js";
|
|
|
import ElementEvents from "../enum/ElementEvents.js";
|
|
@@ -8,20 +9,30 @@ import Constant from "../Constant";
|
|
|
import { dataService } from "./DataService.js";
|
|
|
import { mathUtil } from "../Util/MathUtil";
|
|
|
import { coordinate } from "../Coordinate.js";
|
|
|
-import SimpleLine from "../Geometry/SimpleLine.js";
|
|
|
|
|
|
export class ElementService {
|
|
|
constructor() {
|
|
|
this.point = null;
|
|
|
|
|
|
this.newLine = null;
|
|
|
+ this.newLineStart = null;
|
|
|
+ this.newLineEnd = null;
|
|
|
+
|
|
|
this.newRoad = null;
|
|
|
|
|
|
+ this.checkLinesXStart = null;
|
|
|
+ this.checkLinesXEnd = null;
|
|
|
+ this.checkLinesYStart = null;
|
|
|
+ this.checkLinesYEnd = null;
|
|
|
this.checkLines = {
|
|
|
X: null,
|
|
|
Y: null,
|
|
|
};
|
|
|
|
|
|
+ this.vCheckLinesXStart = null;
|
|
|
+ this.vCheckLinesXEnd = null;
|
|
|
+ this.vCheckLinesYStart = null;
|
|
|
+ this.vCheckLinesYEnd = null;
|
|
|
this.vCheckLines = {
|
|
|
X: null,
|
|
|
Y: null,
|
|
@@ -30,29 +41,39 @@ export class ElementService {
|
|
|
}
|
|
|
|
|
|
init() {
|
|
|
- this.point = new Point(0, 0);
|
|
|
+ this.point = new Point({ x: 0, y: 0 });
|
|
|
this.point.name = ElementEvents.AddingPoint;
|
|
|
|
|
|
this.newRoad = this.createTempRoad();
|
|
|
this.newRoad.name = ElementEvents.NewRoad;
|
|
|
|
|
|
- this.newLine = new SimpleLine({ x: 0, y: 0 }, { x: 1, y: 1 });
|
|
|
+ this.newLineStart = new Point({ x: 0, y: 0 });
|
|
|
+ this.newLineEnd = new Point({ x: 1, y: 1 });
|
|
|
+ this.newLine = new Line(this.newLineStart, this.newLineEnd);
|
|
|
this.newLine.setCategory(VectorCategory.Line.NormalLine);
|
|
|
this.newLine.name = ElementEvents.NewLine;
|
|
|
|
|
|
- this.checkLines.X = new SimpleLine({ x: 0, y: 0 }, { x: 1, y: 1 });
|
|
|
+ this.checkLinesXStart = new Point({ x: 0, y: 0 });
|
|
|
+ this.checkLinesXEnd = new Point({ x: 1, y: 1 });
|
|
|
+ this.checkLines.X = new Line(this.checkLinesXStart, this.checkLinesXEnd);
|
|
|
this.newLine.setCategory(VectorCategory.Line.GuideLine);
|
|
|
this.checkLines.X.name = ElementEvents.CheckLinesX;
|
|
|
|
|
|
- this.checkLines.Y = new SimpleLine({ x: 0, y: 0 }, { x: 1, y: 1 });
|
|
|
+ this.checkLinesYStart = new Point({ x: 0, y: 0 });
|
|
|
+ this.checkLinesYEnd = new Point({ x: 1, y: 1 });
|
|
|
+ this.checkLines.Y = new Line(this.checkLinesYStart, this.checkLinesYEnd);
|
|
|
this.newLine.setCategory(VectorCategory.Line.GuideLine);
|
|
|
this.checkLines.Y.name = ElementEvents.CheckLinesY;
|
|
|
|
|
|
- this.vCheckLines.X = new SimpleLine({ x: 0, y: 0 }, { x: 1, y: 1 });
|
|
|
+ this.vCheckLinesXStart = new Point({ x: 0, y: 0 });
|
|
|
+ this.vCheckLinesXEnd = new Point({ x: 1, y: 1 });
|
|
|
+ this.vCheckLines.X = new Line(this.vCheckLinesXStart, this.vCheckLinesXEnd);
|
|
|
this.newLine.setCategory(VectorCategory.Line.GuideLine);
|
|
|
this.vCheckLines.X.name = ElementEvents.VCheckLinesX;
|
|
|
|
|
|
- this.vCheckLines.Y = new SimpleLine({ x: 0, y: 0 }, { x: 1, y: 1 });
|
|
|
+ this.vCheckLinesYStart = new Point({ x: 0, y: 0 });
|
|
|
+ this.vCheckLinesYEnd = new Point({ x: 1, y: 1 });
|
|
|
+ this.vCheckLines.Y = new Line(this.vCheckLinesYStart, this.vCheckLinesYEnd);
|
|
|
this.newLine.setCategory(VectorCategory.Line.GuideLine);
|
|
|
this.vCheckLines.Y.name = ElementEvents.VCheckLinesY;
|
|
|
|
|
@@ -75,8 +96,8 @@ export class ElementService {
|
|
|
p1,
|
|
|
p2,
|
|
|
this.newRoad.leftWidth +
|
|
|
- this.newRoad.rightWidth +
|
|
|
- this.newRoad.midDivide.midDivideWidth
|
|
|
+ this.newRoad.rightWidth +
|
|
|
+ this.newRoad.midDivide.midDivideWidth
|
|
|
);
|
|
|
}
|
|
|
let leftEdge = new RoadEdge(
|
|
@@ -150,7 +171,8 @@ export class ElementService {
|
|
|
}
|
|
|
|
|
|
setNewLine(point1, point2) {
|
|
|
- this.newLine.setPositions(point1, point2);
|
|
|
+ this.newLineStart.setPositions(point1);
|
|
|
+ this.newLineEnd.setPositions(point2);
|
|
|
}
|
|
|
|
|
|
showNewLine() {
|
|
@@ -174,7 +196,8 @@ export class ElementService {
|
|
|
}
|
|
|
|
|
|
setCheckLinesX(point1, point2) {
|
|
|
- this.checkLines.X.setPositions(point1, point2);
|
|
|
+ this.checkLinesXStart.setPositions(point1);
|
|
|
+ this.checkLinesXEnd.setPositions(point2);
|
|
|
}
|
|
|
|
|
|
showCheckLinesY() {
|
|
@@ -186,7 +209,8 @@ export class ElementService {
|
|
|
}
|
|
|
|
|
|
setCheckLinesY(point1, point2) {
|
|
|
- this.checkLines.Y.setPositions(point1, point2);
|
|
|
+ this.checkLinesYStart.setPositions(point1);
|
|
|
+ this.checkLinesYEnd.setPositions(point2);
|
|
|
}
|
|
|
|
|
|
showVCheckLinesX() {
|
|
@@ -198,7 +222,8 @@ export class ElementService {
|
|
|
}
|
|
|
|
|
|
setVCheckLinesX(point1, point2) {
|
|
|
- this.vCheckLines.X.setPositions(point1, point2);
|
|
|
+ this.vCheckLinesXStart.setPositions(point1);
|
|
|
+ this.vCheckLinesXEnd.setPositions(point2);
|
|
|
}
|
|
|
|
|
|
showVCheckLinesY() {
|
|
@@ -210,7 +235,8 @@ export class ElementService {
|
|
|
}
|
|
|
|
|
|
setVCheckLinesY(point1, point2) {
|
|
|
- this.vCheckLines.Y.setPositions(point1, point2);
|
|
|
+ this.vCheckLinesYStart.setPositions(point1);
|
|
|
+ this.vCheckLinesYEnd.setPositions(point2);
|
|
|
}
|
|
|
|
|
|
hideAll() {
|