|
@@ -131,7 +131,7 @@ export class DivideFloorScene extends FloorScene {
|
|
|
this.addItem(sceneMark);
|
|
|
this.sceneMark = sceneMark;
|
|
|
}
|
|
|
- } // Function addSceneMark
|
|
|
+ } // Function addSceneMark()
|
|
|
|
|
|
/**
|
|
|
* 清除蒙版
|
|
@@ -164,7 +164,7 @@ export class DivideFloorScene extends FloorScene {
|
|
|
*
|
|
|
* @param data 遮罩数据
|
|
|
*/
|
|
|
- addAllShade(data: SPoint[][]) {
|
|
|
+ addAllShade(data: SPoint[][]): void {
|
|
|
if (data.length) {
|
|
|
data.map(t => {
|
|
|
this.addShade(t);
|
|
@@ -177,7 +177,7 @@ export class DivideFloorScene extends FloorScene {
|
|
|
*
|
|
|
* @param data 遮罩数据
|
|
|
*/
|
|
|
- addShade(data: SPoint[]) {
|
|
|
+ addShade(data: SPoint[]): void {
|
|
|
let outLine = data.map(t => {
|
|
|
t.y = -t.y;
|
|
|
return t;
|
|
@@ -211,13 +211,13 @@ export class DivideFloorScene extends FloorScene {
|
|
|
item.selected = true;
|
|
|
this.likeSpaceList.push(item);
|
|
|
this.addItem(item);
|
|
|
- }
|
|
|
+ } // Function addLikeSpace()
|
|
|
|
|
|
/**
|
|
|
* 清除所有类空间item
|
|
|
*
|
|
|
*/
|
|
|
- clearLikeSpaces() {
|
|
|
+ clearLikeSpaces(): void {
|
|
|
if (this.likeSpaceList.length) {
|
|
|
this.likeSpaceList.map(t => {
|
|
|
this.removeItem(t);
|
|
@@ -253,6 +253,9 @@ export class DivideFloorScene extends FloorScene {
|
|
|
event.x = this.highLight.point.x;
|
|
|
event.y = this.highLight.point.y;
|
|
|
}
|
|
|
+ if (this.isPointInShade(event.x, event.y)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
if (this.sceneMark) {
|
|
|
this.sceneMark.onMouseDown(event);
|
|
|
} else {
|
|
@@ -268,6 +271,12 @@ export class DivideFloorScene extends FloorScene {
|
|
|
event.x = this.highLight.point.x;
|
|
|
event.y = this.highLight.point.y;
|
|
|
}
|
|
|
+ if (
|
|
|
+ this.sceneMark &&
|
|
|
+ this.sceneMark.contains(event.x, event.y)
|
|
|
+ ) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
if (this.cutItem) {
|
|
|
this.cutItem.onMouseDown(event);
|
|
|
} else {
|
|
@@ -326,10 +335,12 @@ export class DivideFloorScene extends FloorScene {
|
|
|
super.onMouseMove(event);
|
|
|
this.highLight.visible = false;
|
|
|
if (this.isAbsorbing) {
|
|
|
- this.absorbSpace(event);
|
|
|
+ if (!this.absorbShade(event)) {
|
|
|
+ this.absorbSpace(event);
|
|
|
+ }
|
|
|
}
|
|
|
return false;
|
|
|
- } // Function onMouseMove
|
|
|
+ } // Function onMouseMove()
|
|
|
|
|
|
/***
|
|
|
* 键盘弹起事件
|
|
@@ -407,28 +418,44 @@ export class DivideFloorScene extends FloorScene {
|
|
|
} // Function clearZoneSelection()
|
|
|
|
|
|
/**
|
|
|
+ * 删除所有业务空间
|
|
|
+ */
|
|
|
+ removeAllZone(): void {
|
|
|
+ if (this.zoneList.length) {
|
|
|
+ this.zoneList.map(t => {
|
|
|
+ this.removeItem(t);
|
|
|
+ });
|
|
|
+ this.zoneList = [];
|
|
|
+ }
|
|
|
+ } // Function removeAllZone()
|
|
|
+
|
|
|
+ /**
|
|
|
* 吸附空间
|
|
|
*
|
|
|
* @param event 鼠标事件对象
|
|
|
+ * @return boolean 是否找到吸附的对象
|
|
|
*/
|
|
|
- absorbSpace(event: SMouseEvent): void {
|
|
|
+ absorbSpace(event: SMouseEvent): boolean {
|
|
|
let absorbLen = 1000;
|
|
|
if (this.view) {
|
|
|
absorbLen = 10 / this.view.scale;
|
|
|
}
|
|
|
- let P = this.absorbPoint(event, absorbLen);
|
|
|
+ let P = this.absorbSpacePoint(event, absorbLen);
|
|
|
if (P.Point) {
|
|
|
this.highLight.distance = P.MinDis;
|
|
|
this.highLight.point = new SPoint(P.Point.X, -P.Point.Y);
|
|
|
this.highLight.visible = true;
|
|
|
+ return true;
|
|
|
} else {
|
|
|
- let L = this.absorbLine(event, absorbLen);
|
|
|
+ let L = this.absorbSpaceLine(event, absorbLen);
|
|
|
if (L.Line && L.Point) {
|
|
|
this.highLight.distance = L.MinDis;
|
|
|
this.highLight.point = L.Point;
|
|
|
this.highLight.line = L.Line;
|
|
|
this.highLight.visible = true;
|
|
|
+ return true;
|
|
|
}
|
|
|
+ return false;
|
|
|
}
|
|
|
} // Function absorbSpace()
|
|
|
|
|
@@ -458,13 +485,13 @@ export class DivideFloorScene extends FloorScene {
|
|
|
} // Function isPointInAbsorbArea()
|
|
|
|
|
|
/**
|
|
|
- * 吸附点
|
|
|
+ * 吸附空间点
|
|
|
*
|
|
|
* @param event 鼠标事件对象
|
|
|
* @param absorbLen 吸附距离
|
|
|
* @return MinDis 吸附的点
|
|
|
*/
|
|
|
- absorbPoint(event: SMouseEvent, absorbLen: number): MinDis {
|
|
|
+ absorbSpacePoint(event: SMouseEvent, absorbLen: number): MinDis {
|
|
|
let minPointDis = Number.MAX_SAFE_INTEGER;
|
|
|
let Point;
|
|
|
this.spaceList.map(space => {
|
|
@@ -498,16 +525,16 @@ export class DivideFloorScene extends FloorScene {
|
|
|
Point: Point
|
|
|
};
|
|
|
return minPoint;
|
|
|
- } // Function absorbPoint()
|
|
|
+ } // Function absorbSpacePoint()
|
|
|
|
|
|
/**
|
|
|
- * 吸附线
|
|
|
+ * 吸附空间线
|
|
|
*
|
|
|
* @param event 鼠标事件对象
|
|
|
* @param absorbLen 吸附距离
|
|
|
* @return PointToLine 吸附的线
|
|
|
*/
|
|
|
- absorbLine(event: SMouseEvent, absorbLen: number): PointToLine {
|
|
|
+ absorbSpaceLine(event: SMouseEvent, absorbLen: number): PointToLine {
|
|
|
let minPointDis = Number.MAX_SAFE_INTEGER;
|
|
|
let Point, Line;
|
|
|
this.spaceList.map(space => {
|
|
@@ -543,7 +570,107 @@ export class DivideFloorScene extends FloorScene {
|
|
|
Line: Line
|
|
|
};
|
|
|
return minPointLine;
|
|
|
- } // Function absorbLine()
|
|
|
+ } // Function absorbSpaceLine()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 吸附遮罩
|
|
|
+ *
|
|
|
+ * @param event 鼠标事件对象
|
|
|
+ * @return boolean 是否找到吸附的对象
|
|
|
+ */
|
|
|
+ absorbShade(event: SMouseEvent): boolean {
|
|
|
+ let absorbLen = 1000;
|
|
|
+ if (this.view) {
|
|
|
+ absorbLen = 10 / this.view.scale;
|
|
|
+ }
|
|
|
+ let P = this.absorbShadePoint(event, absorbLen);
|
|
|
+ if (P.Point) {
|
|
|
+ this.highLight.distance = P.MinDis;
|
|
|
+ this.highLight.point = new SPoint(P.Point.X, -P.Point.Y);
|
|
|
+ this.highLight.visible = true;
|
|
|
+ return true;
|
|
|
+ } else {
|
|
|
+ let L = this.absorbShadeLine(event, absorbLen);
|
|
|
+ if (L.Line && L.Point) {
|
|
|
+ this.highLight.distance = L.MinDis;
|
|
|
+ this.highLight.point = L.Point;
|
|
|
+ this.highLight.line = L.Line;
|
|
|
+ this.highLight.visible = true;
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ } // Function absorbSpace()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 吸附遮罩点
|
|
|
+ *
|
|
|
+ * @param event 鼠标事件对象
|
|
|
+ * @param absorbLen 吸附距离
|
|
|
+ * @return MinDis 吸附的点
|
|
|
+ */
|
|
|
+ absorbShadePoint(event: SMouseEvent, absorbLen: number): MinDis {
|
|
|
+ let minPointDis = Number.MAX_SAFE_INTEGER;
|
|
|
+ let Point;
|
|
|
+ this.shadeList.map(shade => {
|
|
|
+ let PointArr = shade.outLine.map(item => {
|
|
|
+ return { X: item.x, Y: -item.y, Z: 0 };
|
|
|
+ });
|
|
|
+ let minDis = SMathUtil.getMinDisPoint(
|
|
|
+ new SPoint(event.x, event.y),
|
|
|
+ PointArr
|
|
|
+ );
|
|
|
+ if (
|
|
|
+ minDis &&
|
|
|
+ minDis.MinDis < absorbLen &&
|
|
|
+ minDis.MinDis < minPointDis
|
|
|
+ ) {
|
|
|
+ minPointDis = minDis.MinDis;
|
|
|
+ Point = minDis.Point;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ let minPoint = {
|
|
|
+ MinDis: minPointDis,
|
|
|
+ Point: Point
|
|
|
+ };
|
|
|
+ return minPoint;
|
|
|
+ } // Function absorbSpacePoint()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 吸附遮罩线
|
|
|
+ *
|
|
|
+ * @param event 鼠标事件对象
|
|
|
+ * @param absorbLen 吸附距离
|
|
|
+ * @return PointToLine 吸附的线
|
|
|
+ */
|
|
|
+ absorbShadeLine(event: SMouseEvent, absorbLen: number): PointToLine {
|
|
|
+ let minPointDis = Number.MAX_SAFE_INTEGER;
|
|
|
+ let Point, Line;
|
|
|
+ this.shadeList.map(shade => {
|
|
|
+ let PointArr = shade.outLine.map(item => {
|
|
|
+ return { X: item.x, Y: -item.y, Z: 0 };
|
|
|
+ });
|
|
|
+ let minDisLine = SMathUtil.getMinDisLine(
|
|
|
+ new SPoint(event.x, event.y),
|
|
|
+ PointArr
|
|
|
+ );
|
|
|
+ if (
|
|
|
+ minDisLine &&
|
|
|
+ minDisLine.MinDis < absorbLen &&
|
|
|
+ minDisLine.MinDis < minPointDis
|
|
|
+ ) {
|
|
|
+ minPointDis = minDisLine.MinDis;
|
|
|
+ Point = minDisLine.Point;
|
|
|
+ Line = minDisLine.Line;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ let minPointLine = {
|
|
|
+ MinDis: minPointDis,
|
|
|
+ Point: Point,
|
|
|
+ Line: Line
|
|
|
+ };
|
|
|
+ return minPointLine;
|
|
|
+ } // Function absorbSpaceLine()
|
|
|
|
|
|
/**
|
|
|
* 计算绘制区域与选中空间交集
|
|
@@ -551,15 +678,22 @@ export class DivideFloorScene extends FloorScene {
|
|
|
*/
|
|
|
getIntersect(): SPoint[][] {
|
|
|
let arr: SPoint[][] = [];
|
|
|
+ let poly2 = {
|
|
|
+ regions: [],
|
|
|
+ inverted: false
|
|
|
+ };
|
|
|
if (this.cutItem) {
|
|
|
- let poly2 = {
|
|
|
- regions: [],
|
|
|
- inverted: false
|
|
|
- };
|
|
|
poly2.regions.push(
|
|
|
// @ts-ignore
|
|
|
SMathUtil.transferToArray(this.cutItem.outLine)
|
|
|
);
|
|
|
+ } else if (this.sceneMark) {
|
|
|
+ poly2.regions.push(
|
|
|
+ // @ts-ignore
|
|
|
+ SMathUtil.transferToArray(this.sceneMark.outLine)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if (poly2.regions.length) {
|
|
|
this.spaceList.map(t => {
|
|
|
if (t.selected) {
|
|
|
let poly1 = {
|
|
@@ -579,7 +713,6 @@ export class DivideFloorScene extends FloorScene {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- return arr;
|
|
|
}
|
|
|
return arr;
|
|
|
} // Function getIntersect()
|
|
@@ -590,15 +723,22 @@ export class DivideFloorScene extends FloorScene {
|
|
|
*/
|
|
|
getLikeIntersect(): SPoint[][] {
|
|
|
let arr: SPoint[][] = [];
|
|
|
+ let poly2 = {
|
|
|
+ regions: [],
|
|
|
+ inverted: false
|
|
|
+ };
|
|
|
if (this.cutItem) {
|
|
|
- let poly2 = {
|
|
|
- regions: [],
|
|
|
- inverted: false
|
|
|
- };
|
|
|
poly2.regions.push(
|
|
|
// @ts-ignore
|
|
|
SMathUtil.transferToArray(this.cutItem.outLine)
|
|
|
);
|
|
|
+ } else if (this.sceneMark) {
|
|
|
+ poly2.regions.push(
|
|
|
+ // @ts-ignore
|
|
|
+ SMathUtil.transferToArray(this.sceneMark.outLine)
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if (poly2.regions.length) {
|
|
|
this.likeSpaceList.map(t => {
|
|
|
if (t.selected) {
|
|
|
let poly1 = {
|
|
@@ -618,7 +758,6 @@ export class DivideFloorScene extends FloorScene {
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
- return arr;
|
|
|
}
|
|
|
return arr;
|
|
|
} // Function getIntersect()
|
|
@@ -655,4 +794,22 @@ export class DivideFloorScene extends FloorScene {
|
|
|
});
|
|
|
}
|
|
|
} // Function groupSelectSpace()
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断点是否在遮罩区域内
|
|
|
+ *
|
|
|
+ * @param x 点x坐标
|
|
|
+ * @param y 点y坐标
|
|
|
+ * @return boolean
|
|
|
+ */
|
|
|
+ isPointInShade(x: number, y: number): boolean {
|
|
|
+ if (this.shadeList.length) {
|
|
|
+ for (let i = 0; i < this.shadeList.length; i++) {
|
|
|
+ if (this.shadeList[i].contains(x, y)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ } // Function isPointInShade()
|
|
|
} // Class DivideFloorScene
|