|
@@ -20,101 +20,106 @@ export class IntersectionModel extends PointModel {
|
|
|
|
|
|
|
|
|
|
|
|
- constructor (posX, posY, label, og1, og2, visible, index, id) { try{
|
|
|
- super(posX, posY, label, id);
|
|
|
- this.og1 = og1;
|
|
|
- this.og2 = og2;
|
|
|
- super.setClass(ELEMENTS_CLASS.INTERSECTION_POINT);
|
|
|
- this.visible = visible;
|
|
|
- this.index = index;
|
|
|
- this.color = -65536;
|
|
|
- this.definitions = this.getDefinitions();
|
|
|
+ constructor(posX, posY, label, og1, og2, visible, index, id) {
|
|
|
+ try {
|
|
|
+ super(posX, posY, label, id);
|
|
|
+ this.og1 = og1;
|
|
|
+ this.og2 = og2;
|
|
|
+ super.setClass(ELEMENTS_CLASS.INTERSECTION_POINT);
|
|
|
+ this.visible = visible;
|
|
|
+ this.index = index;
|
|
|
+ this.color = -65536;
|
|
|
+ this.definitions = this.getDefinitions();
|
|
|
} catch (e) { console.log("app/components/intersection-component/models/intersection-model.js: constructor(.): erro!\n" + e.stack); }
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- update (aggregator, event) { try {
|
|
|
- const intersections = this.og1.getIntersection(this.og2);
|
|
|
- if (intersections.length == 1) {
|
|
|
- this.visible = true;
|
|
|
- const intersection = intersections[0];
|
|
|
- this.posX = parseFloat(intersection.posX.toFixed(2));
|
|
|
- this.posY = parseFloat(intersection.posY.toFixed(2));
|
|
|
-
|
|
|
- if (!this.og1.insideSegment(this.posX, this.posY)) {
|
|
|
- this.posX = Number.MAX_SAFE_INTEGER;
|
|
|
- this.posY = Number.MAX_SAFE_INTEGER;
|
|
|
- this.visible = false;
|
|
|
- this.definitions = this.getDefinitions();
|
|
|
- return;
|
|
|
+ update(aggregator, event) {
|
|
|
+ try {
|
|
|
+ const intersections = this.og1.getIntersection(this.og2);
|
|
|
+ if (intersections.length == 1) {
|
|
|
+ this.visible = true;
|
|
|
+ const intersection = intersections[0];
|
|
|
+ this.posX = parseFloat(intersection.posX.toFixed(2));
|
|
|
+ this.posY = parseFloat(intersection.posY.toFixed(2));
|
|
|
+
|
|
|
+ if (!this.og1.insideSegment(this.posX, this.posY)) {
|
|
|
+ this.posX = Number.MAX_SAFE_INTEGER;
|
|
|
+ this.posY = Number.MAX_SAFE_INTEGER;
|
|
|
+ this.visible = false;
|
|
|
+ this.definitions = this.getDefinitions();
|
|
|
+ return;
|
|
|
}
|
|
|
- if (!this.og2.insideSegment(this.posX, this.posY)) {
|
|
|
- this.posX = Number.MAX_SAFE_INTEGER;
|
|
|
- this.posY = Number.MAX_SAFE_INTEGER;
|
|
|
- this.visible = false;
|
|
|
- this.definitions = this.getDefinitions();
|
|
|
- return;
|
|
|
+ if (!this.og2.insideSegment(this.posX, this.posY)) {
|
|
|
+ this.posX = Number.MAX_SAFE_INTEGER;
|
|
|
+ this.posY = Number.MAX_SAFE_INTEGER;
|
|
|
+ this.visible = false;
|
|
|
+ this.definitions = this.getDefinitions();
|
|
|
+ return;
|
|
|
}
|
|
|
- return;
|
|
|
+ return;
|
|
|
}
|
|
|
- if (intersections.length > 1) {
|
|
|
- for (let index = 0; index < intersections.length; index++) {
|
|
|
- const intersection = intersections[index];
|
|
|
- if (this.index == index) {
|
|
|
- this.posX = parseFloat(intersection.posX.toFixed(2));
|
|
|
- this.posY = parseFloat(intersection.posY.toFixed(2));
|
|
|
- this.visible = intersection.visible;
|
|
|
+ if (intersections.length > 1) {
|
|
|
+ for (let index = 0; index < intersections.length; index++) {
|
|
|
+ const intersection = intersections[index];
|
|
|
+ if (this.index == index) {
|
|
|
+ this.posX = parseFloat(intersection.posX.toFixed(2));
|
|
|
+ this.posY = parseFloat(intersection.posY.toFixed(2));
|
|
|
+ this.visible = intersection.visible;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- this.definitions = this.getDefinitions();
|
|
|
+ this.definitions = this.getDefinitions();
|
|
|
} catch (e) { console.log("app/components/intersection-component/models/intersection-model.js: update(aggregator, event): erro!"); }
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- getDefinitions () { try{
|
|
|
- return [{ id: this.og1.id }, { id: this.og2.id }, { id: this.index + 1 }, { id: this.visible ? 1 : 0 }];
|
|
|
+ getDefinitions() {
|
|
|
+ try {
|
|
|
+ return [{ id: this.og1.id }, { id: this.og2.id }, { id: this.index + 1 }, { id: this.visible ? 1 : 0 }];
|
|
|
} catch (e) { console.log("app/components/intersection-component/models/intersection-model.js: getDefinitions(): erro!"); }
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- bind (posX, posY, label, og1, og2, visible, index) { try{
|
|
|
- super.bind(posX, posY, label);
|
|
|
- this.og1 = og1;
|
|
|
- this.og2 = og2;
|
|
|
- this.visible = visible;
|
|
|
- this.index = index;
|
|
|
- this.color = -65536;
|
|
|
- this.definitions = this.getDefinitions();
|
|
|
- super.setClass(ELEMENTS_CLASS.INTERSECTION_POINT);
|
|
|
+ bind(posX, posY, label, og1, og2, visible, index) {
|
|
|
+ try {
|
|
|
+ super.bind(posX, posY, label);
|
|
|
+ this.og1 = og1;
|
|
|
+ this.og2 = og2;
|
|
|
+ this.visible = visible;
|
|
|
+ this.index = index;
|
|
|
+ this.color = -65536;
|
|
|
+ this.definitions = this.getDefinitions();
|
|
|
+ super.setClass(ELEMENTS_CLASS.INTERSECTION_POINT);
|
|
|
} catch (e) { console.log("app/components/intersection-component/models/intersection-model.js: bind(.): erro!\n" + e.stack); }
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- static do (map, list) { try{
|
|
|
- const id = map.get("id");
|
|
|
- const og1_Id = map.get("param")[0];
|
|
|
- const og2_Id = map.get("param")[1];
|
|
|
- const index = map.get("param")[2] - 1;
|
|
|
- const visible = map.get("param")[5] == 1;
|
|
|
- const label = map.get("label")[0];
|
|
|
- const og1 = list.find(x => x.id == og1_Id);
|
|
|
- const og2 = list.find(x => x.id == og2_Id);
|
|
|
+ static do(map, list) {
|
|
|
+ try {
|
|
|
+ const id = map.get("id");
|
|
|
+ const og1_Id = map.get("param")[0];
|
|
|
+ const og2_Id = map.get("param")[1];
|
|
|
+ const index = map.get("param")[2] - 1;
|
|
|
+ const visible = map.get("param")[5] == 1;
|
|
|
+ const label = map.get("label")[0];
|
|
|
+ const og1 = list.find(x => x.id == og1_Id);
|
|
|
+ const og2 = list.find(x => x.id == og2_Id);
|
|
|
|
|
|
- const intersections = og1.getIntersection(og2);
|
|
|
+ const intersections = og1.getIntersection(og2);
|
|
|
|
|
|
- if (intersections.length == 1) {
|
|
|
- const i = intersections[0];
|
|
|
- i.bind(i.posX, i.posY, label, og1, og2, true, index);
|
|
|
- return i;
|
|
|
- } else {
|
|
|
- const i = intersections.find(x => x.index == index);
|
|
|
- i.bind(i.posX, i.posY, label, og1, og2, true, index);
|
|
|
- return i;
|
|
|
+ if (intersections.length == 1) {
|
|
|
+ const i = intersections[0];
|
|
|
+ i.bind(i.posX, i.posY, label, og1, og2, true, index);
|
|
|
+ return i;
|
|
|
+ } else {
|
|
|
+ const i = intersections.find(x => x.index == index);
|
|
|
+ i.bind(i.posX, i.posY, label, og1, og2, true, index);
|
|
|
+ return i;
|
|
|
}
|
|
|
} catch (e) { console.log("app/components/intersection-component/models/intersection-model.js: do(.): erro!"); }
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+}
|