/* * ******************************************************************************************************************** * * :*$@@%$*: ;: ;; ;; * :@@%! :!@@%: %! ;%%@@%$ =@@@@@@@%; @%@@@%%%%@@@@@ * :@%; :$= %%$$$%$$ ;$$ ;$@= !@$ * =@! %! @ $=;% !@@@%: !$$$$$$$$$$$$$$= * =@* %! @ $= % %@= =%@! %= * *$%%! @@= ;=$%%%$*: %! @ $= % =%%%%%%@$ *%: =% * %@@!: !@@@%=$@@@@%! :*@@$: %! @ $= % $* ;@ @* :%* * ;@@! ;!!!;: ;@%: =======@%========* @ $$ % $%*****$@ :@$=*********=@$ * $@* ;@@@%=!: *@* * =@$ ;;;!=%@@@@=! =@! * %@$: =@%: :*@@@* %@= Copyright (c) 2016-2019. 北京上格云技术有限公司 * ;%@@$=$@@%* *@@@$=%@@%; * ::;:: ::;:: All rights reserved. * * ******************************************************************************************************************** */ import { SGraphyItem } from "@saga-web/graphy/lib"; import { SPainter, SPoint, SRect } from "@saga-web/draw/lib"; import { VirtualWall } from "../types/VirtualWall"; import { Opt } from "../types/Opt"; import { ItemOrder } from "../types/ItemOrder"; /** * 墙item * * @author 郝建龙 */ export class VirtualWallItem extends SGraphyItem { /** 虚拟墙数据 */ data: VirtualWall; /** X坐标最小值 */ private minX = 0; /** X坐标最大值 */ private maxX = 0; /** Y坐标最小值 */ private minY = 0; /** Y坐标最大值 */ private maxY = 0; /** 虚拟墙轮廓线坐标list */ private readonly pointArr: SPoint[][] = []; /** * 构造函数 * * @param parent 指向父对象 * @param data 虚拟墙数据 */ constructor(parent: SGraphyItem | null, data: VirtualWall) { super(parent); this.data = data; this.zOrder = ItemOrder.virtualWallOrder; let tempArr = this.data.OutLine; if (tempArr && tempArr.length) { this.minX = tempArr[0][0].X; this.maxX = this.minX; this.minY = -tempArr[0][0].Y; this.maxY = this.minY; this.pointArr = tempArr.map((t): SPoint[] => { return t.map( (it): SPoint => { let x = it.X, y = -it.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 SPoint(x, y); } ); }); } } // Constructor /** * Item对象边界区域 * * @return SRect */ boundingRect(): SRect { return new SRect( this.minX, this.minY, this.maxX - this.minX, this.maxY - this.minY ); } // Function boundingRect() /** * Item绘制操作 * * @param painter painter对象 */ onDraw(painter: SPainter): void { painter.pen.lineWidth = 100; painter.pen.color = Opt.virtualWallColor; painter.pen.lineDash = [200, 200]; this.pointArr.forEach((t): void => { painter.drawPolyline(t); }); } // Function onDraw() } // Class VirtualWall