|
@@ -10,46 +10,49 @@
|
|
import { GeometricObject } from "../../../core/models/objects/geometric-object";
|
|
import { GeometricObject } from "../../../core/models/objects/geometric-object";
|
|
import { ELEMENTS_CLASS } from "../../../core/enums/elements-class-enum";
|
|
import { ELEMENTS_CLASS } from "../../../core/enums/elements-class-enum";
|
|
|
|
|
|
|
|
+// Point extends GeometricObject (app/core/models/objects/geometric-object.js)
|
|
export class PointModel extends GeometricObject {
|
|
export class PointModel extends GeometricObject {
|
|
|
|
|
|
|
|
+ // Construct one free Point
|
|
// @param {number } posX X Position ex: (38.5) float precision
|
|
// @param {number } posX X Position ex: (38.5) float precision
|
|
// @param {number } posY Y Position ex: (-38.5) float precision
|
|
// @param {number } posY Y Position ex: (-38.5) float precision
|
|
// @param {string } label Label ex: (P)
|
|
// @param {string } label Label ex: (P)
|
|
- constructor(posX, posY, label, id) {
|
|
|
|
|
|
+ constructor (posX, posY, label, id) {
|
|
super(id);
|
|
super(id);
|
|
- this.posX = posX;
|
|
|
|
- this.posY = posY;
|
|
|
|
- this.setLabel(label);
|
|
|
|
|
|
+ this.posX = posX; // initial X coord. of this point
|
|
|
|
+ this.posY = posY; // initial Y coord. of this point
|
|
|
|
+ this.setLabel(label); // label of this point
|
|
super.setClass(ELEMENTS_CLASS.POINT);
|
|
super.setClass(ELEMENTS_CLASS.POINT);
|
|
this.definitions = [{ id: this.posX + 5 }, { id: -this.posY - 5 }];
|
|
this.definitions = [{ id: this.posX + 5 }, { id: -this.posY - 5 }];
|
|
this.color = -16711936;
|
|
this.color = -16711936;
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ // Update this point (when its coord. is changed)
|
|
// @param {konvaObject } Object of Konva Library
|
|
// @param {konvaObject } Object of Konva Library
|
|
// @param {* } event
|
|
// @param {* } event
|
|
- update(konvaObject, event) {
|
|
|
|
|
|
+ update (konvaObject, event) {
|
|
this.posX = konvaObject.attrs.startPosX + event.target._lastPos.x;
|
|
this.posX = konvaObject.attrs.startPosX + event.target._lastPos.x;
|
|
this.posY = konvaObject.attrs.startPosY + event.target._lastPos.y;
|
|
this.posY = konvaObject.attrs.startPosY + event.target._lastPos.y;
|
|
this.definitions = [{ id: this.posX + 5 }, { id: -this.posY - 5 }];
|
|
this.definitions = [{ id: this.posX + 5 }, { id: -this.posY - 5 }];
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
- bind(posX, posY, label) {
|
|
|
|
|
|
+ bind (posX, posY, label) {
|
|
this.posX = posX;
|
|
this.posX = posX;
|
|
this.posY = posY;
|
|
this.posY = posY;
|
|
this.definitions = [{ id: this.posX + 5 }, { id: -this.posY - 5 }];
|
|
this.definitions = [{ id: this.posX + 5 }, { id: -this.posY - 5 }];
|
|
if (label != undefined)
|
|
if (label != undefined)
|
|
this.setLabel(label);
|
|
this.setLabel(label);
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
// Create new Intersection By Line of Script .geo
|
|
// Create new Intersection By Line of Script .geo
|
|
// @param {Map } map JavaScript Map
|
|
// @param {Map } map JavaScript Map
|
|
// @param {List } list List of Generic Objects
|
|
// @param {List } list List of Generic Objects
|
|
- static do(map, list) {
|
|
|
|
|
|
+ static do (map, list) {
|
|
const id = map.get("id");
|
|
const id = map.get("id");
|
|
const x = map.get("param")[0] - 5;
|
|
const x = map.get("param")[0] - 5;
|
|
const y = -map.get("param")[1] + 5;
|
|
const y = -map.get("param")[1] + 5;
|
|
const label = map.get("label")[0];
|
|
const label = map.get("label")[0];
|
|
return new PointModel(x, y, label, id);
|
|
return new PointModel(x, y, label, id);
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
|
|
-}
|
|
|
|
|
|
+ }
|