Преглед изворни кода

添加类空间 item;修改遮罩item构造方式;添加业务空间高亮状态;发布新版本2.0.400

haojianlong пре 5 година
родитељ
комит
e522b1e558

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
     "name": "@saga-web/cad-engine",
-    "version": "2.0.388",
+    "version": "2.0.400",
     "description": "上格云 CAD图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",

+ 192 - 47
src/DivideFloorScene.ts

@@ -32,7 +32,8 @@ import { RectSelectItem } from "./items/RectSelectItem";
 // @ts-ignore
 import { intersect } from "polybooljs";
 import { ShadeItem } from "./items/ShadeItem";
-import { SGraphyItem } from "@saga-web/graphy/lib";
+import { Point } from "./types/Point";
+import { LikeSpaceItem } from "./items/LikeSpaceItem";
 
 /**
  * 划分业务空间
@@ -56,10 +57,16 @@ export class DivideFloorScene extends FloorScene {
     sceneMark: SceneMarkItem | null = null;
     /** 业务空间list   */
     zoneList: ZoneItem[] = [];
-
     /** 遮罩List  */
     shadeList: ShadeItem[] = [];
-
+    /** 划分item  */
+    cutItem: ShadeItem | null = null;
+    /** 类空间itemList */
+    likeSpaceList: LikeSpaceItem[] = [];
+    /** 高亮item  */
+    highLight: HighlightItem = new HighlightItem(null);
+    /** 是否开启切分  */
+    isCutting: boolean = false;
     /** 业务空间是否可选    */
     _isZoneSelectable: boolean = true;
     get isZoneSelectable(): boolean {
@@ -79,8 +86,6 @@ export class DivideFloorScene extends FloorScene {
         });
     } // Set isZoneSelectable
 
-    /** 高亮item  */
-    highLight: HighlightItem = new HighlightItem(null);
     /** 是否开启吸附  */
     private _isAbsorbing: boolean = false;
     get isAbsorbing(): boolean {
@@ -142,6 +147,19 @@ export class DivideFloorScene extends FloorScene {
     } // Function clearSceneMark()
 
     /**
+     * 清除划分区域
+     *
+     */
+    clearCut(): void {
+        if (this.cutItem) {
+            this.grabItem = null;
+            this.removeItem(this.cutItem);
+            this.cutItem = null;
+            this.isCutting = false;
+        }
+    } // Function clearCut()
+
+    /**
      * 添加所有遮罩层
      *
      * @param   data    遮罩数据
@@ -170,6 +188,58 @@ export class DivideFloorScene extends FloorScene {
     } // Function addShade()
 
     /**
+     * 添加所有类空间item
+     *
+     * @param   data    所有数据
+     */
+    addAllLikeSpace(data: Point[][][]): void {
+        if (data.length) {
+            data.map(t => {
+                this.addLikeSpace(t);
+            });
+        }
+    } // Function addAllLikeSpace()
+
+    /**
+     * 添加单个类空间item
+     *
+     * @param   data    单个类空间item数据
+     */
+    addLikeSpace(data: Point[][]): void {
+        let item = new LikeSpaceItem(null, data);
+        item.selectable = true;
+        item.selected = true;
+        this.likeSpaceList.push(item);
+        this.addItem(item);
+    }
+
+    /**
+     * 清除所有类空间item
+     *
+     */
+    clearLikeSpaces() {
+        if (this.likeSpaceList.length) {
+            this.likeSpaceList.map(t => {
+                this.removeItem(t);
+            });
+            this.likeSpaceList = [];
+        }
+    } // Function clearLikeSpaces()
+
+    /**
+     * 获取选中的类空间
+     */
+    getSelectedLikeSpace(): LikeSpaceItem[] {
+        let arr: LikeSpaceItem[] = [];
+        this.likeSpaceList.map(t => {
+            if (t.selected) {
+                arr.push(t);
+            }
+        });
+        return arr;
+    } // Function getSelectedLikeSpace()
+
+    /**
      * 鼠标按下事件
      *
      * @param   event   保存事件参数
@@ -192,6 +262,21 @@ export class DivideFloorScene extends FloorScene {
                     this.sceneMark = sceneMark;
                     this.grabItem = sceneMark;
                 }
+            } else if (this.isCutting) {
+                // 判断是否开启吸附,并且有吸附的点
+                if (this.isAbsorbing && this.highLight.visible) {
+                    event.x = this.highLight.point.x;
+                    event.y = this.highLight.point.y;
+                }
+                if (this.cutItem) {
+                    this.cutItem.onMouseDown(event);
+                } else {
+                    let point = new SPoint(event.x, event.y);
+                    let cut = new ShadeItem(null, point);
+                    this.addItem(cut);
+                    this.cutItem = cut;
+                    this.grabItem = cut;
+                }
             } else if (this.isRectSelection) {
                 if (this.rectSelectItem) {
                     this.isRectSelection = false;
@@ -221,7 +306,7 @@ export class DivideFloorScene extends FloorScene {
     onMouseUp(event: SMouseEvent): boolean {
         if (this.rectSelectItem) {
             this.isRectSelection = false;
-            this.getIntersect();
+            this.groupSelectSpace();
             this.removeItem(this.rectSelectItem);
             this.rectSelectItem = null;
         }
@@ -252,7 +337,7 @@ export class DivideFloorScene extends FloorScene {
      * @param      event   保存事件参数
      */
     onKeyUp(event: KeyboardEvent): void {
-        if (this.isMarking) {
+        if (this.isMarking || this.isCutting) {
             if (this.grabItem) {
                 this.grabItem.onKeyUp(event);
             }
@@ -285,7 +370,7 @@ export class DivideFloorScene extends FloorScene {
         zone.map(t => {
             this.addZone(t);
         });
-    } // Function addZoneList
+    } // Function addZoneList()
 
     /**
      *  添加业务空间到scene 中
@@ -297,7 +382,7 @@ export class DivideFloorScene extends FloorScene {
         item.selectable = this.isZoneSelectable;
         this.zoneList.push(item);
         this.addItem(item);
-    } // Function addZone
+    } // Function addZone()
 
     /**
      *  清空选中的空间
@@ -308,7 +393,7 @@ export class DivideFloorScene extends FloorScene {
             t.selected = false;
             return t;
         });
-    } // Function clearSpaceSelection
+    } // Function clearSpaceSelection()
 
     /**
      *  清空选中的业务空间
@@ -319,7 +404,7 @@ export class DivideFloorScene extends FloorScene {
             t.selected = false;
             return t;
         });
-    } // Function clearZoneSelection
+    } // Function clearZoneSelection()
 
     /**
      *  吸附空间
@@ -345,7 +430,7 @@ export class DivideFloorScene extends FloorScene {
                 this.highLight.visible = true;
             }
         }
-    } // Function absorbSpace
+    } // Function absorbSpace()
 
     /**
      *  点是否在吸附区域内
@@ -370,7 +455,7 @@ export class DivideFloorScene extends FloorScene {
             maxY - minY + 2000
         );
         return rect.contains(p.x, p.y);
-    } // Function isPointInAbsorbArea
+    } // Function isPointInAbsorbArea()
 
     /**
      *  吸附点
@@ -413,7 +498,7 @@ export class DivideFloorScene extends FloorScene {
             Point: Point
         };
         return minPoint;
-    } // Function absorbPoint
+    } // Function absorbPoint()
 
     /**
      *  吸附线
@@ -458,39 +543,104 @@ export class DivideFloorScene extends FloorScene {
             Line: Line
         };
         return minPointLine;
-    } // Function absorbLine
+    } // Function absorbLine()
 
-    /** */
-    getIntersect(): void {
-        if (this.sceneMark) {
+    /**
+     * 计算绘制区域与选中空间交集
+     *
+     */
+    getIntersect(): SPoint[][] {
+        let arr: SPoint[][] = [];
+        if (this.cutItem) {
             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
-                    //     ]
-                    // ]
-                ],
+                regions: [],
                 inverted: false
             };
             poly2.regions.push(
                 // @ts-ignore
-                SMathUtil.transferToArray(this.sceneMark.outLine)
+                SMathUtil.transferToArray(this.cutItem.outLine)
             );
-            console.log(poly2);
+            this.spaceList.map(t => {
+                if (t.selected) {
+                    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) {
+                        intersectObj.regions.map((t: number[][]) => {
+                            arr.push(SMathUtil.transferToSPoint(t));
+                        });
+                    }
+                }
+            });
+            return arr;
+        }
+        return arr;
+    } // Function getIntersect()
+
+    /**
+     * 计算绘制区域与选中类空间交集
+     *
+     */
+    getLikeIntersect(): SPoint[][] {
+        let arr: SPoint[][] = [];
+        if (this.cutItem) {
+            let poly2 = {
+                regions: [],
+                inverted: false
+            };
+            poly2.regions.push(
+                // @ts-ignore
+                SMathUtil.transferToArray(this.cutItem.outLine)
+            );
+            this.likeSpaceList.map(t => {
+                if (t.selected) {
+                    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) {
+                        intersectObj.regions.map((t: number[][]) => {
+                            arr.push(SMathUtil.transferToSPoint(t));
+                        });
+                    }
+                }
+            });
+            return arr;
+        }
+        return arr;
+    } // Function getIntersect()
+
+    /**
+     * 框选区域,选中与之相交的空间
+     *
+     */
+    groupSelectSpace(): void {
+        if (this.rectSelectItem) {
+            let item = this.rectSelectItem;
+            let poly2 = {
+                regions: [
+                    [
+                        [item.startPoint.x, item.startPoint.y],
+                        [item.startPoint.x, item.endPoint.y],
+                        [item.endPoint.x, item.endPoint.y],
+                        [item.endPoint.x, item.startPoint.y]
+                    ]
+                ],
+                inverted: false
+            };
             this.spaceList.map(t => {
                 let poly1 = {
                     regions: [],
@@ -500,14 +650,9 @@ export class DivideFloorScene extends FloorScene {
                 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;
-                }
+                t.selected = intersectObj.regions.length ? true : false;
             });
         }
-    }
+    } // Function groupSelectSpace()
 } // Class DivideFloorScene

+ 9 - 1
src/index.ts

@@ -11,6 +11,10 @@ import { WallItem } from "./items/WallItem";
 import { VirtualWallItem } from "./items/VirtualWallItem";
 import { SceneMarkItem } from "./items/SceneMarkItem";
 import { MarkerItem } from "./items/MarkItem";
+import { HighlightItem } from "./items/HighlightItem";
+import { ShadeItem } from "./items/ShadeItem";
+import { RectSelectItem } from "./items/RectSelectItem";
+import { LikeSpaceItem } from "./items/LikeSpaceItem";
 
 export { FloorScene, LocationPointScene, DivideFloorScene, FloorView };
 
@@ -23,5 +27,9 @@ export {
     VirtualWallItem,
     WallItem,
     WindowItem,
-    ZoneItem
+    ZoneItem,
+    HighlightItem,
+    ShadeItem,
+    RectSelectItem,
+    LikeSpaceItem
 };

+ 178 - 0
src/items/LikeSpaceItem.ts

@@ -0,0 +1,178 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+import { SGraphyItem } from "@saga-web/graphy/lib";
+import {
+    SColor,
+    SPainter,
+    SPath2D,
+    SPoint,
+    SPolygonUtil,
+    SRect
+} from "@saga-web/draw/lib";
+import { Opt } from "../types/Opt";
+import { SMouseEvent } from "@saga-web/base/lib";
+import { ItemOrder } from "../types/ItemOrder";
+import { Point } from "../types/Point";
+
+/**
+ * 类似模型空间item
+ *
+ * @author  郝建龙
+ */
+export class LikeSpaceItem extends SGraphyItem {
+    /** 类似空间所有数据  */
+    data: Point[][];
+    /** 空间轮廓线坐标list  */
+    readonly pointArr: SPoint[][] = [];
+    /** X坐标最小值  */
+    minX = 0;
+    /** X坐标最大值  */
+    maxX = 0;
+    /** Y坐标最小值  */
+    minY = 0;
+    /** Y坐标最大值  */
+    maxY = 0;
+    /** path对象      */
+    private path = new SPath2D();
+    /** 高亮状态    */
+    private _highLightFlag: boolean = false;
+    get highLightFlag(): boolean {
+        return this._highLightFlag;
+    } // Get highLightFlag
+    set highLightFlag(value: boolean) {
+        this._highLightFlag = value;
+    } // Set highLightFlag
+
+    /**
+     * 构造函数
+     *
+     * @param parent    指向父对象
+     * @param data      空间数据
+     */
+    constructor(parent: SGraphyItem | null, data: Point[][]) {
+        super(parent);
+        this.data = data;
+        this.zOrder = ItemOrder.likeSpaceOrder;
+        let tempArr = this.data;
+        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 => {
+                let temp = t.map(it => {
+                    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()
+
+    /**
+     * 鼠标单击事件
+     *
+     * @param	event         事件参数
+     * @return	boolean
+     */
+    onClick(event: SMouseEvent): boolean {
+        if (this.selectable) {
+            this.selected = !this.selected;
+        }
+        this.$emit("click", event);
+        return true;
+    } // Function onClick()
+
+    /**
+     * 鼠标移动事件
+     *
+     * @param event 事件参数
+     */
+    onMouseMove(event: SMouseEvent): boolean {
+        return false;
+    }
+
+    /**
+     * 判断点是否在区域内
+     *
+     * @param x
+     * @param y
+     */
+    contains(x: number, y: number): boolean {
+        let arr = this.pointArr;
+        if (arr.length < 1 || !SPolygonUtil.pointIn(x, y, arr[0])) {
+            return false;
+        }
+
+        for (let i = 1; i < arr.length; i++) {
+            if (SPolygonUtil.pointIn(x, y, arr[i])) {
+                return false;
+            }
+        }
+        return true;
+    } // Function contains()
+
+    /**
+     * Item绘制操作
+     *
+     * @param   painter       painter对象
+     */
+    onDraw(painter: SPainter): void {
+        painter.pen.color = SColor.Transparent;
+        if (this.selected) {
+            painter.brush.color = Opt.selectColor;
+        } else if (this.highLightFlag) {
+            painter.brush.color = Opt.spaceHighColor;
+        } else {
+            painter.brush.color = Opt.spaceColor;
+        }
+        painter.pen.lineWidth = 200;
+        painter.drawPath(this.path);
+    } // Function onDraw()
+} // Class SpaceItem

+ 0 - 1
src/items/RectSelectItem.ts

@@ -34,7 +34,6 @@ export class RectSelectItem extends SGraphyItem {
     startPoint: SPoint = new SPoint();
     /** 终点  */
     endPoint: SPoint = new SPoint();
-    /** 轮廓线 */
 
     /**
      * 构造函数

+ 92 - 23
src/items/ShadeItem.ts

@@ -1,5 +1,5 @@
-// eslint-disable-next-line max-len
-/* * ********************************************************************************************************************
+/*
+ * ********************************************************************************************************************
  *
  *                      :*$@@%$*:                         ;:                ;;    ;;
  *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
@@ -20,7 +20,14 @@
 
 import { Opt } from "../types/Opt";
 import { SGraphyItem } from "@saga-web/graphy/lib";
-import { SColor, SPainter, SPoint, SPolygonUtil } from "@saga-web/draw/lib";
+import {
+    SColor,
+    SLineCapStyle,
+    SPainter,
+    SPath2D,
+    SPoint,
+    SPolygonUtil
+} from "@saga-web/draw/lib";
 import { SMouseEvent } from "@saga-web/base/lib";
 import { ItemOrder } from "../types/ItemOrder";
 
@@ -32,43 +39,95 @@ import { ItemOrder } from "../types/ItemOrder";
 export class ShadeItem extends SGraphyItem {
     /** 轮廓线坐标  */
     outLine: SPoint[] = [];
+    /** 是否闭合    */
+    closeFlag = false;
+    /** 鼠标移动点  */
+    private lastPoint = new SPoint();
+
+    /**
+     * 构造函数
+     *
+     * @param parent    指向父对象
+     * @param data      遮罩起点数据
+     */
+    constructor(parent: SGraphyItem | null, data: SPoint); // Constructor
+
+    /**
+     * 构造函数
+     *
+     * @param parent    指向父对象
+     * @param data      遮罩轮廓线数据
+     */
+    constructor(parent: SGraphyItem | null, data: SPoint[]); // Constructor
 
     /**
      * 构造函数
      *
      * @param parent    指向父对象
-     * @param data      遮罩数据
+     * @param data      遮罩起点数据 | 遮罩轮廓线数据
      */
-    constructor(parent: SGraphyItem | null, data: SPoint[]) {
+    constructor(parent: SGraphyItem | null, data: SPoint[] | SPoint) {
         super(parent);
-        this.outLine = data;
+        if (data instanceof Array) {
+            this.outLine = data;
+            this.createMask();
+        } else {
+            this.outLine.push(data);
+            this.lastPoint = data;
+        }
         this.zOrder = ItemOrder.shadeOrder;
     } // Constructor
 
     /**
-     * 判断点是否在区域内
+     * 鼠标按下事件
      *
-     * @param x
-     * @param y
+     * @param	event         事件参数
+     * @return	boolean
      */
-    contains(x: number, y: number): boolean {
-        let arr = this.outLine;
-        if (SPolygonUtil.pointIn(x, y, arr)) {
-            return true;
+    onMouseDown(event: SMouseEvent): boolean {
+        if (!this.closeFlag && event.buttons == 1) {
+            let p = new SPoint(event.x, event.y);
+            this.lastPoint.x = p.x;
+            this.lastPoint.y = p.y;
+            this.outLine.push(p);
         }
-        return false;
-    } // Function contains()
+        return true;
+    } // Function onMouseDown()
 
     /**
-     * 鼠标点击事件
+     * 鼠标移动事件
      *
      * @param	event         事件参数
      * @return	boolean
      */
-    onMouseDown(event: SMouseEvent): boolean {
-        this.$emit("mouseDown");
+    onMouseMove(event: SMouseEvent): boolean {
+        if (!this.closeFlag) {
+            this.lastPoint = new SPoint(event.x, event.y);
+        }
         return true;
-    }
+    } // Function onMouseMove()
+
+    /***
+     * 键盘按键弹起事件
+     *
+     * @param	event         事件参数
+     */
+    onKeyUp(event: KeyboardEvent): void {
+        if (event.keyCode == 13 && this.outLine.length >= 3) {
+            this.createMask();
+        }
+    } // Function onKeyUp()
+
+    /**
+     * 创建蒙版
+     *
+     */
+    createMask(): void {
+        this.closeFlag = true;
+        if (this.scene) {
+            this.scene.grabItem = null;
+        }
+    } // Function createMask()
 
     /**
      * Item绘制操作
@@ -77,9 +136,19 @@ export class ShadeItem extends SGraphyItem {
      * @param   rect          绘制区域
      */
     onDraw(painter: SPainter): void {
-        painter.pen.color = SColor.Transparent;
-        painter.pen.lineWidth = 10;
-        painter.brush.color = Opt.sceneMarkColor;
-        painter.drawPolygon(this.outLine);
+        painter.pen.lineCapStyle = SLineCapStyle.Square;
+        if (this.closeFlag) {
+            painter.pen.color = SColor.Transparent;
+            painter.brush.color = Opt.sceneMarkColor;
+            painter.drawPolygon(this.outLine);
+        } else {
+            painter.pen.color = new SColor("#ff0000");
+            painter.pen.lineWidth = painter.toPx(3);
+            painter.drawPolyline(this.outLine);
+            painter.drawLine(
+                this.outLine[this.outLine.length - 1],
+                this.lastPoint
+            );
+        }
     } // Function onDraw()
 } // Class SceneMarkItem

+ 1 - 0
src/items/SpaceItem.ts

@@ -61,6 +61,7 @@ export class SpaceItem extends SGraphyItem {
     set highLightFlag(value: boolean) {
         this._highLightFlag = value;
     } // Set highLightFlag
+
     /**
      * 构造函数
      *

+ 19 - 6
src/items/ZoneItem.ts

@@ -30,6 +30,7 @@ import {
 import { Zone } from "../types/Zone";
 import { SMouseEvent } from "@saga-web/base/lib";
 import { ItemOrder } from "../types/ItemOrder";
+import { Opt } from "../types/Opt";
 
 /**
  * 业务空间item
@@ -54,9 +55,17 @@ export class ZoneItem extends SGraphyItem {
     /** 点击位置坐标  */
     private clickPoint: SPoint | undefined;
     /** 选中时的颜色  */
-    private selectColor = new SColor("#1abc9c");
+    private selectColor = Opt.selectColor;
     /** 不可选时的颜色  */
-    private unselectColor = new SColor("#cecece");
+    private unselectColor = Opt.zoneUnselectColor;
+    /** 高亮状态    */
+    private _highLightFlag: boolean = false;
+    get highLightFlag(): boolean {
+        return this._highLightFlag;
+    } // Get highLightFlag
+    set highLightFlag(value: boolean) {
+        this._highLightFlag = value;
+    } // Set highLightFlag
 
     /**
      * 构造函数
@@ -132,8 +141,8 @@ export class ZoneItem extends SGraphyItem {
         if (this.selectable) {
             this.selected = !this.selected;
             this.clickPoint = new SPoint(event.x, event.y);
-            this.$emit("click", event);
         }
+        this.$emit("click", event);
         return true;
     } // Function onClick()
 
@@ -179,9 +188,13 @@ export class ZoneItem extends SGraphyItem {
         if (!this.selectable) {
             painter.brush.color = this.unselectColor;
         } else {
-            painter.brush.color = this.selected
-                ? this.selectColor
-                : this.data.Color;
+            if (this.selected) {
+                painter.brush.color = this.selectColor;
+            } else if (this.highLightFlag) {
+                painter.brush.color = new SColor(this.data.Color);
+            } else {
+                painter.brush.color = new SColor(`${this.data.Color}4d`);
+            }
         }
         painter.pen.lineWidth = 200;
         this.pathList.map(t => {

+ 2 - 0
src/types/ItemOrder.ts

@@ -28,6 +28,8 @@ export class ItemOrder {
     static spaceOrder = 2;
     /** 业务空间层级 */
     static zoneOrder = 8;
+    /** 类空间层级 */
+    static likeSpaceOrder = 10;
     /** 柱子层级 */
     static columnOrder = 12;
     /** 墙层级 */

+ 4 - 0
src/types/Opt.ts

@@ -40,6 +40,8 @@ export class Opt {
     static windowColor = new SColor("#fcd6ff");
     /** 蒙版颜色    */
     static sceneMarkColor = new SColor("#00000080");
+    /** 遮罩颜色    */
+    static shadeColor = new SColor("#00000080");
     /** 高亮item吸附点颜色    */
     static highLightPointColor = new SColor("#ff8d00");
     /** 高亮item吸附线颜色    */
@@ -52,4 +54,6 @@ export class Opt {
     static selectColor = new SColor("#1abc9c");
     /** 空间高亮颜色 */
     static spaceHighColor = new SColor("#fbb029");
+    /** 业务空间不可选中颜色 */
+    static zoneUnselectColor = new SColor("#cecece");
 } // Interface Opt

+ 31 - 0
src/types/Poly.ts

@@ -0,0 +1,31 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+/**
+ * 多边形接口
+ *
+ * @author  郝建龙
+ */
+export interface Poly {
+    /** 多边形点坐标集合    */
+    regions: number[][][];
+    /** 翻转标志    */
+    inverted: boolean;
+} // Interface Poly

+ 1 - 2
src/types/Zone.ts

@@ -19,7 +19,6 @@
  */
 
 import { Point } from "./Point";
-import { SColor } from "@saga-web/draw/lib";
 
 /**
  * 业务空间item接口
@@ -34,7 +33,7 @@ export interface Zone {
     /** 业务空间id  */
     RoomID: string;
     /** 颜色  */
-    Color: SColor;
+    Color: string;
     /** 高度  */
     Height: number;
 } // Interface Space

+ 2 - 91
src/utils/SMathUtil.ts

@@ -18,7 +18,7 @@
  * ********************************************************************************************************************
  */
 
-import { SLine, SPoint, SPolygonUtil, SRect } from "@saga-web/draw/lib";
+import { SLine, SPoint, SRect } from "@saga-web/draw/lib";
 import { MinDis } from "../types/MinDis";
 import { Point } from "../types/Point";
 import { PointToLine } from "../types/PointToLine";
@@ -215,99 +215,10 @@ export class SMathUtil {
      * @param   arr number[][]
      * @return  SP  SPoint[]
      */
-    transferToSPoint(arr: number[][]): SPoint[] {
+    static transferToSPoint(arr: number[][]): SPoint[] {
         let Arr = arr.map(t => {
             return new SPoint(t[0], t[1]);
         });
         return Arr;
     } // Function transferToSPoint()
-
-    /**
-     * 计算多边形交集
-     *
-     * @param
-     */
-    getPolygonOutline() {
-        let arr = [
-            { x: 0, y: 0 },
-            { x: 100, y: 0 },
-            { x: 100, y: 100 },
-            { x: 0, y: 100 }
-        ];
-        arr = arr.map(t => {
-            return new SPoint(t.x, t.y);
-        });
-        let brr = [
-            { x: 50, y: 50 },
-            { x: 150, y: 50 },
-            { x: 150, y: 150 },
-            { x: 50, y: 150 }
-        ];
-        brr = brr.map(t => {
-            return new SPoint(t.x, t.y);
-        });
-        let arrIndex = 0,
-            brrIndex = 0,
-            ARRAY = [];
-        for (let i = 0; i < arr.length; i++) {
-            let firstLine = new SLine(
-                // @ts-ignore
-                arr[i],
-                arr[i + 1 == arr.length ? 0 : i + 1]
-            );
-            for (let j = 0; j < brr.length; j++) {
-                let secondLine = new SLine(
-                    // @ts-ignore
-                    brr[j],
-                    brr[j + 1 == brr.length ? 0 : j + 1]
-                );
-                let jiaodian = SMathUtil.lineIntersection(
-                    firstLine,
-                    secondLine
-                );
-                if (jiaodian) {
-                    arrIndex = i;
-                    brrIndex = j;
-                    ARRAY.push(jiaodian);
-                    break;
-                }
-            }
-        }
-        // @ts-ignore
-        if (SPolygonUtil.pointIn(brr[brrIndex].x, brr[brrIndex].y, arr)) {
-            ARRAY.push(brr[brrIndex]);
-            for (let k = brrIndex - 1; k > 0; k--) {
-                // @ts-ignore
-                if (SPolygonUtil.pointIn(brr[k].x, brr[k].y, arr)) {
-                    ARRAY.push(brr[k]);
-                    continue;
-                }
-
-                let firstLine = new SLine(
-                    // @ts-ignore
-                    brr[k],
-                    brr[k == 0 ? brr.length - 1 : k - 1]
-                );
-
-                for (let q = 0; q < arr.length; q++) {
-                    let secondLine = new SLine(
-                        // @ts-ignore
-                        arr[q],
-                        arr[q + 1 == arr.length ? 0 : q + 1]
-                    );
-                    let jiaodian = SMathUtil.lineIntersection(
-                        firstLine,
-                        secondLine
-                    );
-                    if (jiaodian) {
-                        arrIndex = q;
-                        brrIndex = k;
-                        ARRAY.push(jiaodian);
-                    }
-                }
-            }
-        } else {
-            ARRAY.push(brr[brrIndex + 1 == brr.length ? 0 : brrIndex + 1]);
-        }
-    } // Function getPolygonOutline()
 } // Class SMathUtil