|
@@ -24,12 +24,15 @@ import { SceneMarkItem } from "./items/SceneMarkItem";
|
|
import { ZoneItem } from "./items/ZoneItem";
|
|
import { ZoneItem } from "./items/ZoneItem";
|
|
import { Zone } from "./types/Zone";
|
|
import { Zone } from "./types/Zone";
|
|
import { SMouseEvent } from "@saga-web/base/lib";
|
|
import { SMouseEvent } from "@saga-web/base/lib";
|
|
-import { SGraphyItem } from "@saga-web/graphy/lib";
|
|
|
|
import { HighlightItem } from "./items/HighlightItem";
|
|
import { HighlightItem } from "./items/HighlightItem";
|
|
import { SMathUtil } from "./utils/SMathUtil";
|
|
import { SMathUtil } from "./utils/SMathUtil";
|
|
import { MinDis } from "./types/MinDis";
|
|
import { MinDis } from "./types/MinDis";
|
|
import { PointToLine } from "./types/PointToLine";
|
|
import { PointToLine } from "./types/PointToLine";
|
|
import { RectSelectItem } from "./items/RectSelectItem";
|
|
import { RectSelectItem } from "./items/RectSelectItem";
|
|
|
|
+// @ts-ignore
|
|
|
|
+import { intersect } from "polybooljs";
|
|
|
|
+import { ShadeItem } from "./items/ShadeItem";
|
|
|
|
+import { SGraphyItem } from "@saga-web/graphy/lib";
|
|
|
|
|
|
/**
|
|
/**
|
|
* 划分业务空间
|
|
* 划分业务空间
|
|
@@ -50,10 +53,13 @@ export class DivideFloorScene extends FloorScene {
|
|
} // Set isMarking
|
|
} // Set isMarking
|
|
|
|
|
|
/** 蒙版item */
|
|
/** 蒙版item */
|
|
- sceneMark: SGraphyItem | null = null;
|
|
|
|
|
|
+ sceneMark: SceneMarkItem | null = null;
|
|
/** 业务空间list */
|
|
/** 业务空间list */
|
|
zoneList: ZoneItem[] = [];
|
|
zoneList: ZoneItem[] = [];
|
|
|
|
|
|
|
|
+ /** 遮罩List */
|
|
|
|
+ shadeList: ShadeItem[] = [];
|
|
|
|
+
|
|
/** 业务空间是否可选 */
|
|
/** 业务空间是否可选 */
|
|
_isZoneSelectable: boolean = true;
|
|
_isZoneSelectable: boolean = true;
|
|
get isZoneSelectable(): boolean {
|
|
get isZoneSelectable(): boolean {
|
|
@@ -112,7 +118,11 @@ export class DivideFloorScene extends FloorScene {
|
|
*/
|
|
*/
|
|
addSceneMark(data: SPoint[]): void {
|
|
addSceneMark(data: SPoint[]): void {
|
|
if (data.length) {
|
|
if (data.length) {
|
|
- let sceneMark = new SceneMarkItem(null, data);
|
|
|
|
|
|
+ let outline = data.map(t => {
|
|
|
|
+ t.y = -t.y;
|
|
|
|
+ return t;
|
|
|
|
+ });
|
|
|
|
+ let sceneMark = new SceneMarkItem(null, outline);
|
|
this.addItem(sceneMark);
|
|
this.addItem(sceneMark);
|
|
this.sceneMark = sceneMark;
|
|
this.sceneMark = sceneMark;
|
|
}
|
|
}
|
|
@@ -132,6 +142,34 @@ export class DivideFloorScene extends FloorScene {
|
|
} // Function clearSceneMark()
|
|
} // Function clearSceneMark()
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
+ * 添加所有遮罩层
|
|
|
|
+ *
|
|
|
|
+ * @param data 遮罩数据
|
|
|
|
+ */
|
|
|
|
+ addAllShade(data: SPoint[][]) {
|
|
|
|
+ if (data.length) {
|
|
|
|
+ data.map(t => {
|
|
|
|
+ this.addShade(t);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ } // Function addAllShade()
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 添加单个遮罩
|
|
|
|
+ *
|
|
|
|
+ * @param data 遮罩数据
|
|
|
|
+ */
|
|
|
|
+ addShade(data: SPoint[]) {
|
|
|
|
+ let outLine = data.map(t => {
|
|
|
|
+ t.y = -t.y;
|
|
|
|
+ return t;
|
|
|
|
+ });
|
|
|
|
+ let item = new ShadeItem(null, outLine);
|
|
|
|
+ this.shadeList.push(item);
|
|
|
|
+ this.addItem(item);
|
|
|
|
+ } // Function addShade()
|
|
|
|
+
|
|
|
|
+ /**
|
|
* 鼠标按下事件
|
|
* 鼠标按下事件
|
|
*
|
|
*
|
|
* @param event 保存事件参数
|
|
* @param event 保存事件参数
|
|
@@ -183,6 +221,7 @@ export class DivideFloorScene extends FloorScene {
|
|
onMouseUp(event: SMouseEvent): boolean {
|
|
onMouseUp(event: SMouseEvent): boolean {
|
|
if (this.rectSelectItem) {
|
|
if (this.rectSelectItem) {
|
|
this.isRectSelection = false;
|
|
this.isRectSelection = false;
|
|
|
|
+ this.getIntersect();
|
|
this.removeItem(this.rectSelectItem);
|
|
this.removeItem(this.rectSelectItem);
|
|
this.rectSelectItem = null;
|
|
this.rectSelectItem = null;
|
|
}
|
|
}
|
|
@@ -208,7 +247,7 @@ export class DivideFloorScene extends FloorScene {
|
|
} // Function onMouseMove
|
|
} // Function onMouseMove
|
|
|
|
|
|
/***
|
|
/***
|
|
- * 键盘按下事件
|
|
|
|
|
|
+ * 键盘弹起事件
|
|
*
|
|
*
|
|
* @param event 保存事件参数
|
|
* @param event 保存事件参数
|
|
*/
|
|
*/
|
|
@@ -422,4 +461,53 @@ export class DivideFloorScene extends FloorScene {
|
|
} // Function absorbLine
|
|
} // Function absorbLine
|
|
|
|
|
|
/** */
|
|
/** */
|
|
|
|
+ getIntersect(): void {
|
|
|
|
+ if (this.sceneMark) {
|
|
|
|
+ let poly2 = {
|
|
|
|
+ regions: [
|
|
|
|
+ // [
|
|
|
|
+ // [
|
|
|
|
+ // this.rectSelectItem.startPoint.x,
|
|
|
|
+ // this.rectSelectItem.startPoint.y
|
|
|
|
+ // ],
|
|
|
|
+ // [
|
|
|
|
+ // this.rectSelectItem.startPoint.x,
|
|
|
|
+ // this.rectSelectItem.endPoint.y
|
|
|
|
+ // ],
|
|
|
|
+ // [
|
|
|
|
+ // this.rectSelectItem.endPoint.x,
|
|
|
|
+ // this.rectSelectItem.endPoint.y
|
|
|
|
+ // ],
|
|
|
|
+ // [
|
|
|
|
+ // this.rectSelectItem.endPoint.x,
|
|
|
|
+ // this.rectSelectItem.startPoint.y
|
|
|
|
+ // ]
|
|
|
|
+ // ]
|
|
|
|
+ ],
|
|
|
|
+ inverted: false
|
|
|
|
+ };
|
|
|
|
+ poly2.regions.push(
|
|
|
|
+ // @ts-ignore
|
|
|
|
+ SMathUtil.transferToArray(this.sceneMark.outLine)
|
|
|
|
+ );
|
|
|
|
+ console.log(poly2);
|
|
|
|
+ this.spaceList.map(t => {
|
|
|
|
+ let poly1 = {
|
|
|
|
+ regions: [],
|
|
|
|
+ inverted: false
|
|
|
|
+ };
|
|
|
|
+ // @ts-ignore
|
|
|
|
+ poly1.regions = t.pointArr.map(item => {
|
|
|
|
+ return SMathUtil.transferToArray(item);
|
|
|
|
+ });
|
|
|
|
+ console.log(poly1);
|
|
|
|
+ let intersectObj = intersect(poly1, poly2);
|
|
|
|
+ if (intersectObj.regions.length) {
|
|
|
|
+ t.selected = true;
|
|
|
|
+ } else {
|
|
|
|
+ t.selected = false;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
} // Class DivideFloorScene
|
|
} // Class DivideFloorScene
|