|
@@ -18,7 +18,7 @@
|
|
* ********************************************************************************************************************
|
|
* ********************************************************************************************************************
|
|
*/
|
|
*/
|
|
|
|
|
|
-import { SPainter, SPoint, SRect } from "@saga-web/draw/lib";
|
|
|
|
|
|
+import { SPainter, SPath2D, SPoint, SRect } from "@saga-web/draw/lib";
|
|
import { Wall } from "../../types/floor/Wall";
|
|
import { Wall } from "../../types/floor/Wall";
|
|
import { ItemOrder } from "../..";
|
|
import { ItemOrder } from "../..";
|
|
import { ItemColor } from "../..";
|
|
import { ItemColor } from "../..";
|
|
@@ -42,6 +42,10 @@ export class SWallItem extends SGraphItem {
|
|
private maxY = Number.MIN_SAFE_INTEGER;
|
|
private maxY = Number.MIN_SAFE_INTEGER;
|
|
/** 墙轮廓线坐标list */
|
|
/** 墙轮廓线坐标list */
|
|
private readonly pointArr: SPoint[][] = [];
|
|
private readonly pointArr: SPoint[][] = [];
|
|
|
|
+ /** 墙内轮廓线坐标list */
|
|
|
|
+ private readonly holesArr: SPoint[][] = [];
|
|
|
|
+ /** path对象 */
|
|
|
|
+ private path = new SPath2D();
|
|
|
|
|
|
/**
|
|
/**
|
|
* 构造函数
|
|
* 构造函数
|
|
@@ -54,32 +58,62 @@ export class SWallItem extends SGraphItem {
|
|
this.data = data;
|
|
this.data = data;
|
|
this.zOrder = ItemOrder.wallOrder;
|
|
this.zOrder = ItemOrder.wallOrder;
|
|
let tempArr = this.data.OutLine;
|
|
let tempArr = this.data.OutLine;
|
|
|
|
+ let holes = data.Holes;
|
|
if (tempArr && tempArr.length) {
|
|
if (tempArr && tempArr.length) {
|
|
this.minX = tempArr[0][0].X;
|
|
this.minX = tempArr[0][0].X;
|
|
this.maxX = this.minX;
|
|
this.maxX = this.minX;
|
|
this.minY = -tempArr[0][0].Y;
|
|
this.minY = -tempArr[0][0].Y;
|
|
this.maxY = this.minY;
|
|
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);
|
|
|
|
|
|
+ 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
|
|
} // Constructor
|
|
|
|
|
|
@@ -106,8 +140,6 @@ export class SWallItem extends SGraphItem {
|
|
painter.pen.color = ItemColor.wallColor;
|
|
painter.pen.color = ItemColor.wallColor;
|
|
painter.pen.lineWidth = painter.toPx(1);
|
|
painter.pen.lineWidth = painter.toPx(1);
|
|
painter.brush.color = ItemColor.wallColor;
|
|
painter.brush.color = ItemColor.wallColor;
|
|
- this.pointArr.forEach((t): void => {
|
|
|
|
- painter.drawPolygon(t);
|
|
|
|
- });
|
|
|
|
|
|
+ painter.drawPath(this.path);
|
|
} // Function onDraw()
|
|
} // Function onDraw()
|
|
} // Class SWallItem
|
|
} // Class SWallItem
|