| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- /*
- * ********************************************************************************************************************
- *
- * :*$@@%$*: ;: ;; ;;
- * :@@%! :!@@%: %! ;%%@@%$ =@@@@@@@%; @%@@@%%%%@@@@@
- * :@%; :$= %%$$$%$$ ;$$ ;$@= !@$
- * =@! %! @ $=;% !@@@%: !$$$$$$$$$$$$$$=
- * =@* %! @ $= % %@= =%@! %=
- * *$%%! @@= ;=$%%%$*: %! @ $= % =%%%%%%@$ *%: =%
- * %@@!: !@@@%=$@@@@%! :*@@$: %! @ $= % $* ;@ @* :%*
- * ;@@! ;!!!;: ;@%: =======@%========* @ $$ % $%*****$@ :@$=*********=@$
- * $@* ;@@@%=!: *@*
- * =@$ ;;;!=%@@@@=! =@!
- * %@$: =@%: :*@@@* %@= Copyright (c) 2016-2019. 北京上格云技术有限公司
- * ;%@@$=$@@%* *@@@$=%@@%;
- * ::;:: ::;:: All rights reserved.
- *
- * ********************************************************************************************************************
- */
- import { SPainter, SPath, SPoint, SRect } from "@saga-web/draw/lib";
- import { Wall } from "../../types/floor/Wall";
- import { ItemOrder } from "../..";
- import { ItemColor } from "../..";
- import { SGraphItem } from "@saga-web/graph/lib";
- /**
- * 墙item
- *
- * @author 郝建龙
- */
- export class SWallItem extends SGraphItem {
- /** 墙数据 */
- data: Wall;
- /** 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[][] = [];
- /** 墙内轮廓线坐标list */
- private readonly holesArr: SPoint[][] = [];
- /** path对象 */
- private path = new SPath();
- /**
- * 构造函数
- *
- * @param parent 指向父对象
- * @param data 墙数据
- */
- constructor(parent: SGraphItem | null, data: Wall) {
- super(parent);
- this.data = data;
- this.zOrder = ItemOrder.wallOrder;
- let tempArr = this.data.OutLine;
- let holes = data.Holes;
- 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 = [];
- let WLine = tempArr[0].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);
- }
- );
- // 外轮廓
- this.path.polygon(WLine);
- // 外轮廓
- this.pointArr.push(WLine);
- // 内轮廓
- if (holes && holes.length) {
- this.holesArr = holes.map(t => {
- let temp = 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);
- }
- );
- this.path.polygon(temp);
- return temp;
- });
- }
- }
- } // 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.color = ItemColor.wallColor;
- painter.pen.lineWidth = painter.toPx(1);
- painter.brush.color = ItemColor.wallColor;
- painter.drawPath(this.path);
- } // Function onDraw()
- } // Class SWallItem
|