|
@@ -2,6 +2,7 @@ import { PointModel } from "../../point-component/models/point-model";
|
|
|
import { ELEMENTS_CLASS } from "../../../core/enums/elements-class-enum";
|
|
|
import { DrawerAggregator } from "../../../core/drawers/drawer-aggregator";
|
|
|
import { GeometricObject } from "../../../core/models/objects/geometric-object";
|
|
|
+import { setWith } from "lodash";
|
|
|
|
|
|
export class IntersectionModel extends PointModel {
|
|
|
/**
|
|
@@ -10,7 +11,7 @@ export class IntersectionModel extends PointModel {
|
|
|
* @param {GeometricObject} s Geometric Object
|
|
|
* @param {boolean} visible Visiblity of Object
|
|
|
* @param {number} index Index position of Object ex (1)
|
|
|
-
|
|
|
+ * @param {id} id indentity of intersection ex: 0
|
|
|
*/
|
|
|
constructor(posX, posY, label, r, s, visible, index, id) {
|
|
|
super(posX, posY, label, id);
|
|
@@ -66,7 +67,7 @@ export class IntersectionModel extends PointModel {
|
|
|
}
|
|
|
|
|
|
getDefinitions() {
|
|
|
- return [{ id: this.r.id }, { id: this.s.id }, { id: this.index + 1 }, { id: this.posX + 5 }, { id: this.posY - 5 }, { id: this.visible ? 1 : 0 }];
|
|
|
+ return [{ id: this.r.id }, { id: this.s.id }, { id: this.index + 1 }, { id: this.visible ? 1 : 0 }];
|
|
|
}
|
|
|
|
|
|
bind(posX, posY, label, r, s, visible, index) {
|
|
@@ -90,12 +91,21 @@ export class IntersectionModel extends PointModel {
|
|
|
const rId = map.get("param")[0];
|
|
|
const sId = map.get("param")[1];
|
|
|
const index = map.get("param")[2] - 1;
|
|
|
- const x = (map.get("param")[3]) - 5;
|
|
|
- const y = (map.get("param")[4]) + 5;
|
|
|
const visible = map.get("param")[5] == 1;
|
|
|
- const label = map.get("label");
|
|
|
+ const label = map.get("label")[0];
|
|
|
const r = list.find(x => x.id == rId);
|
|
|
const s = list.find(x => x.id == sId);
|
|
|
- return new IntersectionModel(x, y, label, r, s, visible, index, id);
|
|
|
+
|
|
|
+ const intersections = r.getIntersection(s);
|
|
|
+ if (intersections.length == 1) {
|
|
|
+ const i = intersections[0];
|
|
|
+ i.bind(i.posX, i.posY, label, r, s, true, index);
|
|
|
+ return i;
|
|
|
+ } else {
|
|
|
+ const i = intersections.find(x => x.index == index);
|
|
|
+ i.bind(i.posX, i.posY, label, r, s, true, index);
|
|
|
+ return i;
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|