123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.SZoneItem = void 0;
- const lib_1 = require("@persagy-web/draw/lib");
- const __1 = require("../..");
- const lib_2 = require("@persagy-web/graph/lib");
- class SZoneItem extends lib_2.SGraphItem {
- constructor(parent, data) {
- super(parent);
- this.pointArr = [];
- 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.pathList = [];
- this.selectColor = __1.ItemColor.selectColor;
- this.unselectColor = __1.ItemColor.zoneUnselectColor;
- this._highLightFlag = false;
- this._transparency = 20;
- this._isInfected = false;
- this.infectedColor = __1.ItemColor.zoneInfectedColor;
- this.infectedBorder = __1.ItemColor.zoneInfectedBorder;
- this.data = data;
- this.zOrder = __1.ItemOrder.zoneOrder;
- this.highLightFlag = data.HighLightFlag || false;
- this.transparency = data.Transparency || 20;
- this.isInfected = data.Infected || false;
- if (this.data.OutLine.length &&
- this.data.OutLine[0] &&
- this.data.OutLine[0].length) {
- let tempArr = this.data.OutLine;
- this.minX = tempArr[0][0][0].X;
- this.maxX = this.minX;
- this.minY = -tempArr[0][0][0].Y;
- this.maxY = this.minY;
- this.pointArr = tempArr.map((t) => {
- let sPath = new lib_1.SPath2D();
- let tempArr = t.map((it) => {
- let array = it.map((item) => {
- let x = item.X, y = -item.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(x, y);
- });
- sPath.polygon(array);
- return array;
- });
- this.pathList.push(sPath);
- return tempArr;
- });
- }
- }
- get highLightFlag() {
- return this._highLightFlag;
- }
- set highLightFlag(value) {
- this._highLightFlag = value;
- this.update();
- }
- get transparency() {
- return this._transparency;
- }
- set transparency(value) {
- this._transparency = value;
- this.update();
- }
- get isInfected() {
- return this._isInfected;
- }
- set isInfected(value) {
- this._isInfected = value;
- this.update();
- }
- boundingRect() {
- return new lib_1.SRect(this.minX, this.minY, this.maxX - this.minX, this.maxY - this.minY);
- }
- onMouseDown(event) {
- if (this.selectable) {
- this.selected = !this.selected;
- this.clickPoint = new lib_1.SPoint(event.x, event.y);
- }
- this.$emit("click", event);
- return true;
- }
- onMouseUp(event) {
- return false;
- }
- contains(x, y) {
- for (let j = 0; j < this.pointArr.length; j++) {
- let arr = this.pointArr[j];
- if (arr.length < 1 || !lib_1.SPolygonUtil.pointIn(x, y, arr[0])) {
- continue;
- }
- if (arr.length == 1) {
- return true;
- }
- let flag = false;
- for (let i = 1; i < arr.length; i++) {
- if (lib_1.SPolygonUtil.pointIn(x, y, arr[i])) {
- flag = true;
- break;
- }
- }
- if (flag) {
- continue;
- }
- return true;
- }
- return false;
- }
- onDraw(painter, rect) {
- painter.pen.color = lib_1.SColor.Transparent;
- if (!this.selectable) {
- painter.brush.color = this.unselectColor;
- }
- else {
- if (this.selected) {
- painter.brush.color = this.selectColor;
- }
- else if (this.highLightFlag) {
- painter.brush.color = new lib_1.SColor(this.data.Color);
- }
- else if (this.isInfected) {
- painter.brush.color = this.infectedColor;
- }
- else {
- painter.brush.color = new lib_1.SColor(`${this.data.Color}${__1.Transparency[this.transparency]}`);
- }
- }
- painter.pen.lineWidth = painter.toPx(1);
- this.pathList.forEach((t) => {
- painter.drawPath(t);
- });
- painter.brush.color = lib_1.SColor.Black;
- painter.font.size = painter.toPx(10);
- if (this.clickPoint) {
- painter.drawText(this.data.RoomLocalName, this.clickPoint.x, this.clickPoint.y);
- }
- }
- }
- exports.SZoneItem = SZoneItem;
|