"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SDoorItem = void 0; const lib_1 = require("@persagy-web/draw/lib"); const SMathUtil_1 = require("../../utils/SMathUtil"); const __1 = require("../.."); const __2 = require("../.."); const lib_2 = require("@persagy-web/graph/lib"); class SDoorItem extends lib_2.SGraphItem { constructor(parent, data) { super(parent); this.pointArr = []; this.r = 0; this.ang = 0; this.p = new lib_1.SPoint(0, 0); this.startAng = -Math.PI / 2; this.minX = Number.MAX_SAFE_INTEGER; this.maxX = Number.MIN_SAFE_INTEGER; this.minY = Number.MAX_SAFE_INTEGER; this.maxY = Number.MIN_SAFE_INTEGER; this.data = data; this.zOrder = __1.ItemOrder.doorOrder; if (this.data.OutLine.length) { this.pointArr = this.data.OutLine[0].map((t) => { let x = t.X, y = -t.Y; if (x < this.minX) { this.minX = x; } if (y < this.minY) { this.minY = y; } if (x > this.maxX) { this.maxX = x; } if (y > this.maxY) { this.maxY = y; } return new lib_1.SPoint(t.X, -t.Y); }); let p1 = this.pointArr[0], p2 = this.pointArr[1]; this.p = p1; const HX = (this.data.HandDirection.X = Number(this.data.HandDirection.X.toFixed())); const HY = (this.data.HandDirection.Y = Number(this.data.HandDirection.Y.toFixed())); const FX = (this.data.FaceDirection.X = Number(this.data.FaceDirection.X.toFixed())); const FY = (this.data.FaceDirection.Y = Number(this.data.FaceDirection.Y.toFixed())); let dotProduct = (p2.x - p1.x) * HX + (p2.y - p1.y) * -HY; if (dotProduct > 0) { this.p = p2; p2 = p1; p1 = this.p; } this.r = SMathUtil_1.SMathUtil.pointDistance(p1.x, p1.y, p2.x, p2.y); let fo = Math.atan(-FY / FX); this.ang = FX > 0 ? fo : fo + Math.PI; let direction = (p2.x - p1.x) * -FY - (p2.y - p1.y) * FX; if (direction > 0) { this.startAng = 0; } } } boundingRect() { return new lib_1.SRect(this.minX, this.minY, this.maxX - this.minX, this.maxY - this.minY); } onDraw(painter) { painter.translate(this.p.x, this.p.y); painter.rotate(this.ang); painter.pen.lineWidth = 100; painter.pen.color = __2.ItemColor.doorColor; painter.drawLine(0, 0, this.r, 0); painter.pen.lineDash = [50, 100]; painter.pen.lineWidth = painter.toPx(1); } } exports.SDoorItem = SDoorItem;