1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- import { SPainter, SPoint, SRect } from "@persagy-web/draw/lib";
- import { SGraphItem } from "@persagy-web/graph/lib";
- import {VirtualWall} from "@persagy-web/big/lib/types/floor/VirtualWall";
- import {ItemColor, ItemOrder} from "@persagy-web/big/lib";
- /**
- * 墙item
- *
- * @author 郝建龙
- */
- export class SVirtualWallItem extends SGraphItem {
- /** 虚拟墙数据 */
- data: VirtualWall;
- /** X坐标最小值 */
- private minX = Number.MAX_SAFE_INTEGER;
- /** X坐标最大值 */
- private maxX = Number.MIN_SAFE_INTEGER;
- /** Y坐标最小值 */
- private minY = Number.MAX_SAFE_INTEGER;
- /** Y坐标最大值 */
- private maxY = Number.MIN_SAFE_INTEGER;
- /** 虚拟墙轮廓线坐标list */
- private readonly pointArr: SPoint[][] = [];
- /**
- * 构造函数
- *
- * @param parent 指向父对象
- * @param data 虚拟墙数据
- */
- constructor(parent: SGraphItem | 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 = painter.toPx(1);
- painter.pen.color = ItemColor.virtualWallColor;
- painter.pen.lineDash = [200, 100];
- this.pointArr.forEach((t): void => {
- painter.drawPolyline(t);
- });
- } // Function onDraw()
- } // Class SVirtualWallItem
|