Przeglądaj źródła

绘制底图功能

haojianlong 5 lat temu
rodzic
commit
59e04caad6

+ 13 - 33
package-lock.json

@@ -1,6 +1,6 @@
 {
     "name": "cad-engine",
-    "version": "2.0.1",
+    "version": "2.0.23",
     "lockfileVersion": 1,
     "requires": true,
     "dependencies": {
@@ -30,34 +30,20 @@
             "integrity": "sha512-cYHF8tm/uIwMHRKGp+whO6/juVCyarNqrUq4nsHL22iV8pFOe5lDI8duc4Glg9Ar5dLdzNOdTIoYilmctJOOhQ=="
         },
         "@sybotan-web/draw": {
-            "version": "2.0.109",
-            "resolved": "http://dev.dp.sagacloud.cn:8082/repository/npm-saga/@sybotan-web/draw/-/draw-2.0.109.tgz",
-            "integrity": "sha512-h7y81yrt4ZcOYqNED9wqvAdSD92SqwQDhA2vEsZ308A9W0y7gTCbrx5ZQp3SaHlwr0wP+LfHJebx4HY3bHvKuA==",
+            "version": "2.0.111",
+            "resolved": "http://dev.dp.sagacloud.cn:8082/repository/npm-saga/@sybotan-web/draw/-/draw-2.0.111.tgz",
+            "integrity": "sha512-8jAw7PbUU9D192NrEDzqn4q/Qgc7SxMVSn33TemL+icP3sSld8n2iUp8XnSEql0cnbm4nIT0dErx5bJeiyMQQw==",
             "requires": {
-                "@sybotan-web/base": "^2.0.53"
-            },
-            "dependencies": {
-                "@sybotan-web/base": {
-                    "version": "2.0.54",
-                    "resolved": "http://dev.dp.sagacloud.cn:8082/repository/npm-saga/@sybotan-web/base/-/base-2.0.54.tgz",
-                    "integrity": "sha512-cYHF8tm/uIwMHRKGp+whO6/juVCyarNqrUq4nsHL22iV8pFOe5lDI8duc4Glg9Ar5dLdzNOdTIoYilmctJOOhQ=="
-                }
+                "@sybotan-web/base": "^2.0.54"
             }
         },
         "@sybotan-web/graphy": {
-            "version": "2.0.86",
-            "resolved": "http://dev.dp.sagacloud.cn:8082/repository/npm-saga/@sybotan-web/graphy/-/graphy-2.0.86.tgz",
-            "integrity": "sha512-nAe6CyPW/X/VffZ+ApL3nUJEX15/c0CGR3jg1jOQkF0P4f/LslQOsEscfBIpzNlf47DuyPV12U9G9YKWWMHIFA==",
+            "version": "2.0.90",
+            "resolved": "http://dev.dp.sagacloud.cn:8082/repository/npm-saga/@sybotan-web/graphy/-/graphy-2.0.90.tgz",
+            "integrity": "sha512-4egeDHD5VGLWd4Mo4YDnkqhEp/tkKVpDlX8zT/8bOe9TCGTOVW3hQba6Keth69WTbhmfxav8vY4dbVzoqlkb6w==",
             "requires": {
-                "@sybotan-web/base": "^2.0.53",
-                "@sybotan-web/draw": "^2.0.109"
-            },
-            "dependencies": {
-                "@sybotan-web/base": {
-                    "version": "2.0.54",
-                    "resolved": "http://dev.dp.sagacloud.cn:8082/repository/npm-saga/@sybotan-web/base/-/base-2.0.54.tgz",
-                    "integrity": "sha512-cYHF8tm/uIwMHRKGp+whO6/juVCyarNqrUq4nsHL22iV8pFOe5lDI8duc4Glg9Ar5dLdzNOdTIoYilmctJOOhQ=="
-                }
+                "@sybotan-web/base": "^2.0.54",
+                "@sybotan-web/draw": "^2.0.111"
             }
         },
         "@types/eslint-visitor-keys": {
@@ -197,7 +183,6 @@
             "version": "0.18.1",
             "resolved": "http://dev.dp.sagacloud.cn:8082/repository/npm-saga/axios/-/axios-0.18.1.tgz",
             "integrity": "sha512-0BfJq4NSfQXd+SkFdrvFbG7addhYSBA2mQwISr46pD6E5iqkWg02RAs8vyTT/j0RTnoYmeXauBuSv1qKwR179g==",
-            "dev": true,
             "requires": {
                 "follow-redirects": "1.5.10",
                 "is-buffer": "^2.0.2"
@@ -569,7 +554,6 @@
             "version": "1.5.10",
             "resolved": "http://dev.dp.sagacloud.cn:8082/repository/npm-saga/follow-redirects/-/follow-redirects-1.5.10.tgz",
             "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
-            "dev": true,
             "requires": {
                 "debug": "=3.1.0"
             },
@@ -578,7 +562,6 @@
                     "version": "3.1.0",
                     "resolved": "http://dev.dp.sagacloud.cn:8082/repository/npm-saga/debug/-/debug-3.1.0.tgz",
                     "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
-                    "dev": true,
                     "requires": {
                         "ms": "2.0.0"
                     }
@@ -586,8 +569,7 @@
                 "ms": {
                     "version": "2.0.0",
                     "resolved": "http://dev.dp.sagacloud.cn:8082/repository/npm-saga/ms/-/ms-2.0.0.tgz",
-                    "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
-                    "dev": true
+                    "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
                 }
             }
         },
@@ -715,8 +697,7 @@
         "is-buffer": {
             "version": "2.0.3",
             "resolved": "http://dev.dp.sagacloud.cn:8082/repository/npm-saga/is-buffer/-/is-buffer-2.0.3.tgz",
-            "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==",
-            "dev": true
+            "integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw=="
         },
         "is-extglob": {
             "version": "2.1.1",
@@ -919,8 +900,7 @@
         "pako": {
             "version": "1.0.10",
             "resolved": "http://dev.dp.sagacloud.cn:8082/repository/npm-saga/pako/-/pako-1.0.10.tgz",
-            "integrity": "sha512-0DTvPVU3ed8+HNXOu5Bs+o//Mbdj9VNQMUOe9oKCwh8l0GNwpTDMKCWbRjgtD291AWnkAgkqA/LOnQS8AmS1tw==",
-            "dev": true
+            "integrity": "sha512-0DTvPVU3ed8+HNXOu5Bs+o//Mbdj9VNQMUOe9oKCwh8l0GNwpTDMKCWbRjgtD291AWnkAgkqA/LOnQS8AmS1tw=="
         },
         "parent-module": {
             "version": "1.0.1",

+ 8 - 8
package.json

@@ -1,6 +1,6 @@
 {
     "name": "cad-engine",
-    "version": "2.0.5",
+    "version": "2.0.30",
     "description": "上格云 CAD图形引擎。",
     "main": "lib/index.js",
     "types": "lib/index.d.js",
@@ -9,12 +9,12 @@
         "publish": "npm publish",
         "lint": "eslint src/**/*.{js,ts,tsx}",
         "test": "echo \"Error: no test specified\" && exit 1",
-        "typedoc": "typedoc --hideGenerator src ../sybotan-web-base/src ../sybotan-web-draw/src ../sybotan-web-graphy/src ../sybotan-web-graphy-item/src"
+        "typedoc": "typedoc --hideGenerator src"
     },
     "keywords": [
         "graphy"
     ],
-    "author": "庞利祥 (sybotan@126.com)",
+    "author": "郝建龙 (1061851420@qq.com)",
     "license": "ISC",
     "publishConfig": {
         "registry": "http://dev.dp.sagacloud.cn:8082/repository/npm-host/"
@@ -28,13 +28,13 @@
         "prettier": "^1.18.2",
         "@types/jest": "^24.0.15",
         "ts-jest": "^24.0.2",
-        "typescript": "^3.5.3",
-        "axios": "^0.18.0",
-        "pako": "^1.0.10"
+        "typescript": "^3.5.3"
     },
     "dependencies": {
         "@sybotan-web/base": "2.0.54",
-        "@sybotan-web/draw": "2.0.109",
-        "@sybotan-web/graphy": "2.0.86"
+        "@sybotan-web/draw": "2.0.111",
+        "@sybotan-web/graphy": "2.0.90",
+        "axios": "^0.18.0",
+        "pako": "^1.0.10"
     }
 }

+ 207 - 35
src/FloorScene.ts

@@ -19,16 +19,22 @@
  */
 
 import { SGraphyClockItem, SGraphyScene } from "@sybotan-web/graphy/lib";
-import Axios from "axios";
 // @ts-ignore
 import pako from "pako";
-import { JsonData } from "./types/JsonData";
+import { FloorData } from "./types/FloorData";
 import { Space } from "./types/Space";
 import { Column } from "./types/Column";
 import { Wall } from "./types/Wall";
 import { VirtualWall } from "./types/VirtualWall";
 import { Door } from "./types/Door";
 import { Casement } from "./types/Casement";
+import Axios from "axios";
+import { SpaceItem } from "./items/SpaceItem";
+import { WallItem } from "./items/WallItem";
+import { ColumnItem } from "./items/ColumnItem";
+import { VirtualWallItem } from "./items/VirtualWallItem";
+import { DoorItem } from "./items/DoorItem";
+import { WindowItem } from "./items/WindowItem";
 
 /**
  * 楼层场景
@@ -37,31 +43,129 @@ import { Casement } from "./types/Casement";
  */
 export class FloorScene extends SGraphyScene {
     /** item数据  */
-    data: JsonData | null = null;
+    data: FloorData | null = null;
     /** 是否显示空间  */
-    isShowSpace = true;
+    private _isShowSpace: boolean = true;
+    get isShowSpace(): boolean {
+        return this._isShowSpace;
+    } // Get isShowSpace
+    set isShowSpace(v: boolean) {
+        if (this._isShowSpace === v) {
+            return;
+        }
+        this._isShowSpace = v;
+        this.spaceList.map((t: SpaceItem) => {
+            t.visible = this._isShowSpace;
+            return t;
+        });
+    } // Set isShowSpace
+
+    /** 是否显示柱子  */
+    private _isShowColumn: boolean = true;
+    get isShowColumn(): boolean {
+        return this._isShowColumn;
+    } // Get isShowColumn
+    set isShowColumn(v: boolean) {
+        if (this._isShowColumn === v) {
+            return;
+        }
+        this._isShowColumn = v;
+        this.columnList.map((t: ColumnItem) => {
+            t.visible = this._isShowColumn;
+            return t;
+        });
+    } // Set isShowColumn
+
     /** 是否展示墙体  */
-    isShowWallList = true;
-    /** 是否展示设备  */
-    isShowEquipmentList = true;
+    private _isShowWall: boolean = true;
+    get isShowWall(): boolean {
+        return this._isShowWall;
+    } // Get isShowWall
+    set isShowWall(v: boolean) {
+        if (this._isShowWall === v) {
+            return;
+        }
+        this._isShowWall = v;
+        this.wallList.map((t: WallItem) => {
+            t.visible = this._isShowWall;
+            return t;
+        });
+    } // Set isShowWall
+
     /** 是否展示虚拟墙  */
-    isShowVrtualWallList = true;
+    _isShowVirtualWall: boolean = true;
+    get isShowVirtualWall(): boolean {
+        return this._isShowVirtualWall;
+    } // Get isShowVrtualWall
+    set isShowVirtualWall(v: boolean) {
+        if (this._isShowVirtualWall === v) {
+            return;
+        }
+        this._isShowVirtualWall = v;
+        this.virtualWallList.map((t: VirtualWallItem) => {
+            t.visible = this._isShowVirtualWall;
+            return t;
+        });
+    } // Set isShowVrtualWall
+
+    /** 是否展示门  */
+    _isShowDoor: boolean = true;
+    get isShowDoor(): boolean {
+        return this._isShowDoor;
+    } // Get isShowDoor
+    set isShowDoor(v: boolean) {
+        if (this._isShowDoor === v) {
+            return;
+        }
+        this._isShowDoor = v;
+        this.doorList.map((t: DoorItem) => {
+            t.visible = this._isShowDoor;
+            return t;
+        });
+    } // Set isShowDoor
+
+    /** 是否展示窗户  */
+    _isShowWindow: boolean = true;
+    get isShowWindow(): boolean {
+        return this._isShowWindow;
+    } // Get isShowWindow
+    set isShowWindow(v: boolean) {
+        if (this._isShowWindow === v) {
+            return;
+        }
+        this._isShowWindow = v;
+        this.casementList.map((t: WindowItem) => {
+            t.visible = this._isShowWindow;
+            return t;
+        });
+    } // Set isShowWindow
+
+    /** 墙list   */
+    wallList: WallItem[] = [];
+    /** 柱子list   */
+    columnList: ColumnItem[] = [];
+    /** 门list   */
+    doorList: DoorItem[] = [];
+    /** 窗list   */
+    casementList: WindowItem[] = [];
+    /** 虚拟墙list   */
+    virtualWallList: VirtualWallItem[] = [];
+    /** 空间list   */
+    spaceList: SpaceItem[] = [];
 
     /**
      *  @param  data    绘制空间地图得所有参数
      */
     constructor() {
         super();
-        let click = new SGraphyClockItem(null, 300, 300);
-        this.addItem(click);
     } // Constructor()
 
     /**
-     *  获取底图文件
+     *  获取底图压缩文件
      *
      *  @param  url     请求数据文件路径
      */
-    urlGetData(url: string) {
+    loadUrl(url: string) {
         let that = this;
         return new Promise((relove, reject) => {
             Axios({
@@ -72,28 +176,27 @@ export class FloorScene extends SGraphyScene {
             })
                 .then((res: any) => {
                     let blob = res.data;
-                    this.zipToJson(blob)
+                    this.unzip(blob)
                         .then((jsonData: any) => {
-                            that.addAllItems(jsonData);
+                            that.addBaseMapItem(jsonData);
                             relove();
                         })
                         .catch((error: any) => {
                             console.log(error);
                         });
-                    // console.log(reader)
                 })
                 .catch((res: any) => {
                     console.log(res);
                 });
         });
-    } // Function urlGetData
+    } // Function loadUrl
 
     /**
      *  解压数据
      *
      *  @param  blob     文件
      */
-    zipToJson(blob: any): any {
+    private unzip(blob: any): any {
         let reader = new FileReader();
         reader.readAsBinaryString(blob);
         let that = this;
@@ -103,67 +206,136 @@ export class FloorScene extends SGraphyScene {
                 //解压数据
                 let base64Data = btoa(binaryString);
                 let unGzipData = pako.unzip(base64Data);
-                that.data = unGzipData.EntityList.Elements;
+                that.data = unGzipData.EntityList[0].Elements;
                 resolve(unGzipData);
             };
         });
-    } // Function zipToJson
+    } // Function unzip
+
+    /**
+     *  获取楼层未压缩数据
+     *
+     *  @param  url     请求路径
+     */
+    getFloorData(url: string, data: { ModelId: string }) {
+        let that = this;
+        return new Promise((resolve, reject) => {
+            Axios({
+                method: "post",
+                url: url,
+                data: data
+            })
+                .then((res: any) => {
+                    let floordata = res.data.EntityList[0].Elements;
+                    that.addBaseMapItem(floordata);
+                    resolve(res.data);
+                })
+                .catch((res: any) => {
+                    console.log(res);
+                });
+        });
+    } // Function getFloorData
 
     /**
-     *  增添所有绘制item(地图);
+     *  增添所有底图item;
      *
      *  @param  data    itemList对象
      */
-    addAllItems(data: JsonData) {
-        this.addCasementItems(data.Casement);
-        this.addSpaceItems(data.Spaces);
-        this.addColumnItems(data.Columns);
-        this.addWallItems(data.Walls);
-        this.addVirtualWallItems(data.VirtualWalls);
-        this.addDoorItems(data.Doors);
-    } // Function addAllItemList
+    private addBaseMapItem(data: FloorData) {
+        data.Walls.map((t: Wall) => {
+            this.addWall(t);
+        });
+        data.Columns.map((t: Column) => {
+            this.addColumn(t);
+        });
+        data.Windows.map((t: Casement) => {
+            this.addCasement(t);
+        });
+        data.VirtualWalls.map((t: VirtualWall) => {
+            this.addVirtualWall(t);
+        });
+        data.Doors.map((t: Door) => {
+            this.addDoor(t);
+        });
+        data.Spaces.map((t: Space) => {
+            this.addSpace(t);
+        });
+    } // Function addBaseMapItem
 
     /**
      *  添加所有空间到scene 中
      *
      *  @param  space   空间list
      */
-    addSpaceItems(space: Space): void {} // Function addSpaceList
+    addSpace(space: Space): void {
+        let item = new SpaceItem(space);
+        item.zOrder = 2;
+        item.visible = this.isShowSpace;
+        this.spaceList.push(item);
+        this.addItem(item);
+    } // Function addSpace
 
     /**
      *  添加所有设备到scene 中
      *
      *  @param  column   柱子list
      */
-    addColumnItems(column: Column): void {} // Function addColumnListList
+    addColumn(column: Column): void {
+        let item = new ColumnItem(column);
+        item.visible = this.isShowColumn;
+        this.columnList.push(item);
+        this.addItem(item);
+    } // Function addColumn
 
     /**
      *  添加所有设备到scene 中
      *
      *  @param  wall   墙list
      */
-    addWallItems(wall: Wall): void {} // Function addWallList
+    addWall(wall: Wall): void {
+        let item = new WallItem(wall);
+        item.visible = this.isShowWall;
+        this.wallList.push(item);
+        this.addItem(item);
+    } // Function addWall
 
     /**
      *  添加所有虚拟墙到scene 中
      *
      *  @param  virtualWall   虚拟墙list
      */
-    addVirtualWallItems(virtualWall: VirtualWall): void {} // Function addVirtualWallList
+    addVirtualWall(virtualWall: VirtualWall): void {
+        let item = new VirtualWallItem(virtualWall);
+        item.visible = this.isShowVirtualWall;
+        this.virtualWallList.push(item);
+        this.addItem(item);
+    } // Function addVirtualWall
 
     /**
      *  添加所有位置标签到scene 中
      *
      *  @param  doors   门list
      */
-    addDoorItems(door: Door): void {} // Function addDoorList
+    addDoor(door: Door): void {
+        let item = new DoorItem(door);
+        item.zOrder = 1;
+        item.visible = this.isShowDoor;
+        this.doorList.push(item);
+        this.addItem(item);
+    } // Function addDoor
 
     /**
      *  添加所有位置标签到scene 中
      *
      *  @param  windows   窗户list
      */
-    addCasementItems(casement: Casement): void {} // Function addWindowList
+    addCasement(casement: Casement): void {
+        let item = new WindowItem(casement);
+        item.zOrder = 1;
+        item.visible = this.isShowWindow;
+        this.casementList.push(item);
+        this.addItem(item);
+    } // Function addCasement
     /**
      *  扩大数组中相应字段一定倍数
      *
@@ -188,5 +360,5 @@ export class FloorScene extends SGraphyScene {
             }
         });
         return data;
-    }
+    } // Function changeMap
 } // Class FloorScene

+ 31 - 148
src/items/ColumnItem.ts

@@ -20,7 +20,8 @@
 
 import { SGraphyItem, SMouseEvent } from "@sybotan-web/graphy/lib";
 import { SColor, SPainter, SPoint, SRect } from "@sybotan-web/draw/lib";
-import {Column} from "../types/Column";
+import { Column } from "../types/Column";
+import { Opt } from "../types/Opt";
 
 /**
  * 柱子item
@@ -28,151 +29,33 @@ import {Column} from "../types/Column";
  * @author  郝建龙
  */
 export class ColumnItem extends SGraphyItem {
-    // data
-    //
-    // /**
-    //  * 构造函数
-    //  *
-    //  * @param PolygonItemData
-    //  */
-    // constructor(PolygonItemData: Column) {
-    //     super(null);
-    //     // super(PolygonItemData.parent);
-    //     // // 修改绘制路径格式
-    //     // let newSpacePaths: SPoint[] = PolygonItemData.space.Paths[0].map(
-    //     //     (item: SPoint) => {
-    //     //         return new SPoint(item.x, item.y);
-    //     //     }
-    //     // );
-    //     // this.pointArr = newSpacePaths;
-    //     // // 填充色
-    //     // this.fillColor = PolygonItemData.space.fillColor
-    //     //     ? PolygonItemData.space.fillColor
-    //     //     : new SColor("#F2F6FC");
-    //     // // 边框色
-    //     // this.color = PolygonItemData.space.color
-    //     //     ? PolygonItemData.space.color
-    //     //     : SColor.Black;
-    //     // //边框宽度
-    //     // this.width = PolygonItemData.space.width
-    //     //     ? PolygonItemData.space.width
-    //     //     : 100;
-    //     // //中心点
-    //     // this.centerOfGravityPoint = {
-    //     //     x: PolygonItemData.space.LocationPoint.X,
-    //     //     y: -PolygonItemData.space.LocationPoint.Y
-    //     // };
-    //     // this.initName = PolygonItemData.space.Name;
-    //     // this.id = PolygonItemData.space.id;
-    //     // this.viewText = PolygonItemData.space.Name;
-    // }
-    //
-    // /**
-    //  * Item对象边界区域
-    //  *
-    //  * @return SRect
-    //  */
-    // boundingRect(): SRect {
-    //     let minX = this.pointArr[0].x;
-    //     let maxX = minX;
-    //     let minY = this.pointArr[0].y;
-    //     let maxY = minY;
-    //     for (let i = 1; i < this.pointArr.length; i++) {
-    //         if (this.pointArr[i].x < minX) {
-    //             minX = this.pointArr[i].x;
-    //         }
-    //         if (this.pointArr[i].y < minY) {
-    //             minY = this.pointArr[i].y;
-    //         }
-    //         if (this.pointArr[i].x > maxX) {
-    //             maxX = this.pointArr[i].x;
-    //         }
-    //         if (this.pointArr[i].y > maxY) {
-    //             maxY = this.pointArr[i].y;
-    //         }
-    //     }
-    //
-    //     return new SRect(minX, minY, maxX - minX, maxY - minY);
-    // } // Function boundingRect()
-    //
-    // /**
-    //  * 判断点是否在区域内
-    //  *
-    //  * @param x
-    //  * @param y
-    //  */
-    // contains(x: number, y: number): boolean {
-    //     let nCross = 0,
-    //         point = [x, y],
-    //         APoints = this.pointArr,
-    //         length = APoints.length,
-    //         p1,
-    //         p2,
-    //         i,
-    //         xinters;
-    //     p1 = APoints[0];
-    //     for (i = 1; i <= length; i++) {
-    //         p2 = APoints[i % length];
-    //         if (
-    //             point[0] > Math.min(p1.x, p2.x) &&
-    //             point[0] <= Math.max(p1.x, p2.x)
-    //         ) {
-    //             if (point[1] <= Math.max(p1.y, p2.y)) {
-    //                 if (p1.x != p2.x) {
-    //                     //计算位置信息
-    //                     xinters =
-    //                         ((point[0] - p1.x) * (p2.y - p1.y)) /
-    //                             (p2.x - p1.x) +
-    //                         p1.y;
-    //                     if (p1.y == p2.y || point[1] <= xinters) {
-    //                         nCross++;
-    //                     }
-    //                 }
-    //             }
-    //         }
-    //         p1 = p2;
-    //     }
-    //     return nCross % 2 === 1;
-    // }
-    //
-    // /**
-    //  *
-    //  * @param text 修改的文字
-    //  * @param centerOfGravityPoint 文字的坐标
-    //  */
-    // addText(text: string, centerOfGravityPoint?: { x: number; y: number }) {
-    //     this.viewText = text;
-    //     if (centerOfGravityPoint) {
-    //         this.centerOfGravityPoint = centerOfGravityPoint;
-    //     }
-    // }
-    //
-    // /**
-    //  * Item绘制操作
-    //  *
-    //  * @param   painter       painter对象
-    //  * @param   rect          绘制区域
-    //  */
-    // onDraw(painter: SPainter, rect?: SRect): void {
-    //     if (this.pointArr.length) {
-    //         painter.pen.color = this.color;
-    //         painter.brush.color = this.fillColor;
-    //         painter.pen.lineWidth = this.width;
-    //         painter.drawPolygon(this.pointArr);
-    //         // let text = ''
-    //         // if (this.businessName || this.businessId) {
-    //         // 	text = '👇   ' + this.businessName
-    //         // } else {
-    //         // 	text = '⬇️   ' + this.initName
-    //         // }
-    //         painter.font.size = this.scale * 200;
-    //         painter.brush.color = SColor.Black;
-    //         // painter.drawText(text,this.centerOfGravityPoint.x,this.centerOfGravityPoint.y)
-    //         painter.drawText(
-    //             this.viewText,
-    //             this.centerOfGravityPoint.x,
-    //             this.centerOfGravityPoint.y
-    //         );
-    //     }
-    // }
+    /** 柱子数据    */
+    data: Column;
+    /** 柱子轮廓线坐标list  */
+    private readonly pointArr: SPoint[];
+
+    /**
+     * 构造函数
+     *
+     * @param data
+     */
+    constructor(data: Column) {
+        super();
+        this.data = data;
+        this.pointArr = this.data.OutLine[0].map(t => {
+            return new SPoint(t.X, t.Y);
+        });
+    } // Constructor
+
+    /**
+     * Item绘制操作
+     *
+     * @param   painter       painter对象
+     * @param   rect          绘制区域
+     */
+    onDraw(painter: SPainter, rect?: SRect): void {
+        painter.pen.color = SColor.Transparent;
+        painter.brush.color = Opt.columnColor;
+        painter.drawPolygon(this.pointArr);
+    } // Function onDraw()
 } // Class ColumnItem

+ 44 - 179
src/items/DoorItem.ts

@@ -20,86 +20,32 @@
 
 import { SGraphyItem, SMouseEvent } from "@sybotan-web/graphy/lib";
 import { SColor, SPainter, SPoint, SRect } from "@sybotan-web/draw/lib";
-
-class PolygonItemInterface {
-    parent: SGraphyItem | undefined;
-    space: any;
-}
+import { Door } from "../types/Door";
+import { Opt } from "../types/Opt";
 
 /**
- * 窗户item
+ * 门item
  *
  * @author  郝建龙
  */
-export class WindowItem extends SGraphyItem {
-    /** 点坐标list */
-    pointArr: SPoint[];
-    /** 填充色 */
-    fillColor: SColor = new SColor("#F2F6FC");
-    /** 边框色 */
-    color: SColor = SColor.Black;
-    /** 边框宽度    */
-    width: number = 200;
-    /** 空间id  */
-    id: string;
-    /** 中心坐标    */
-    centerOfGravityPoint: { x: number; y: number };
-    /** 空间名称    */
-    initName: null | string | undefined;
-    /** 绘制文案    */
-    viewText: string = "";
-    /** 需要缓存的边框颜色   */
-    cacheColor: SColor = SColor.Black;
-    /** 需要缓存的填充色   */
-    cacheFillColor: SColor = new SColor("#F2F6FC");
-    /** 需要缓存的边框宽度   */
-    cacheWidth: number = 100;
-    /** 是否激活    */
-    actived: boolean = false;
+export class DoorItem extends SGraphyItem {
+    /** 门数据 */
+    data: Door;
+    /** 门轮廓线坐标list  */
+    private readonly pointArr: SPoint[];
 
     /**
      * 构造函数
      *
-     * @param pointArr                  点坐标list
-     * @param width                     边框的宽度
-     * @param color                     边框的颜色
-     * @param fillColor                 多边形填充的颜色
-     * @param businessId                空间id
-     * @param businessName              空间名称
-     * @param centerOfGravityPoint      中心点
-     * @param isBusiness                状态
-     * @param parent
+     * @param data
      */
-    constructor(PolygonItemData: PolygonItemInterface) {
-        super(PolygonItemData.parent);
-        // 修改绘制路径格式
-        let newSpacePaths: SPoint[] = PolygonItemData.space.Paths[0].map(
-            (item: SPoint) => {
-                return new SPoint(item.x, item.y);
-            }
-        );
-        this.pointArr = newSpacePaths;
-        // 填充色
-        this.fillColor = PolygonItemData.space.fillColor
-            ? PolygonItemData.space.fillColor
-            : new SColor("#F2F6FC");
-        // 边框色
-        this.color = PolygonItemData.space.color
-            ? PolygonItemData.space.color
-            : SColor.Black;
-        //边框宽度
-        this.width = PolygonItemData.space.width
-            ? PolygonItemData.space.width
-            : 100;
-        //中心点
-        this.centerOfGravityPoint = {
-            x: PolygonItemData.space.LocationPoint.X,
-            y: -PolygonItemData.space.LocationPoint.Y
-        };
-        this.initName = PolygonItemData.space.Name;
-        this.id = PolygonItemData.space.id;
-        this.viewText = PolygonItemData.space.Name;
-    }
+    constructor(data: Door) {
+        super();
+        this.data = data;
+        this.pointArr = this.data.OutLine[0].map(t => {
+            return new SPoint(t.X, t.Y);
+        });
+    } // Constructor
 
     /**
      * Item对象边界区域
@@ -107,22 +53,23 @@ export class WindowItem extends SGraphyItem {
      * @return SRect
      */
     boundingRect(): SRect {
-        let minX = this.pointArr[0].x;
+        let pointArr = this.data.OutLine[0];
+        let minX = pointArr[0].X;
         let maxX = minX;
-        let minY = this.pointArr[0].y;
+        let minY = pointArr[0].Y;
         let maxY = minY;
-        for (let i = 1; i < this.pointArr.length; i++) {
-            if (this.pointArr[i].x < minX) {
-                minX = this.pointArr[i].x;
+        for (let i = 1; i < pointArr.length; i++) {
+            if (pointArr[i].X < minX) {
+                minX = pointArr[i].Y;
             }
-            if (this.pointArr[i].y < minY) {
-                minY = this.pointArr[i].y;
+            if (pointArr[i].Y < minY) {
+                minY = pointArr[i].Y;
             }
-            if (this.pointArr[i].x > maxX) {
-                maxX = this.pointArr[i].x;
+            if (pointArr[i].X > maxX) {
+                maxX = pointArr[i].X;
             }
-            if (this.pointArr[i].y > maxY) {
-                maxY = this.pointArr[i].y;
+            if (pointArr[i].Y > maxY) {
+                maxY = pointArr[i].Y;
             }
         }
 
@@ -138,7 +85,7 @@ export class WindowItem extends SGraphyItem {
     contains(x: number, y: number): boolean {
         let nCross = 0,
             point = [x, y],
-            APoints = this.pointArr,
+            APoints = this.data.OutLine[0],
             length = APoints.length,
             p1,
             p2,
@@ -148,17 +95,17 @@ export class WindowItem extends SGraphyItem {
         for (i = 1; i <= length; i++) {
             p2 = APoints[i % length];
             if (
-                point[0] > Math.min(p1.x, p2.x) &&
-                point[0] <= Math.max(p1.x, p2.x)
+                point[0] > Math.min(p1.X, p2.X) &&
+                point[0] <= Math.max(p1.X, p2.X)
             ) {
-                if (point[1] <= Math.max(p1.y, p2.y)) {
-                    if (p1.x != p2.x) {
+                if (point[1] <= Math.max(p1.Y, p2.Y)) {
+                    if (p1.X != p2.X) {
                         //计算位置信息
                         xinters =
-                            ((point[0] - p1.x) * (p2.y - p1.y)) /
-                                (p2.x - p1.x) +
-                            p1.y;
-                        if (p1.y == p2.y || point[1] <= xinters) {
+                            ((point[0] - p1.X) * (p2.Y - p1.Y)) /
+                                (p2.X - p1.X) +
+                            p1.Y;
+                        if (p1.Y == p2.Y || point[1] <= xinters) {
                             nCross++;
                         }
                     }
@@ -167,18 +114,8 @@ export class WindowItem extends SGraphyItem {
             p1 = p2;
         }
         return nCross % 2 === 1;
-    }
-    /**
-     *
-     * @param text 修改的文字
-     * @param centerOfGravityPoint 文字的坐标
-     */
-    addText(text: string, centerOfGravityPoint?: { x: number; y: number }) {
-        this.viewText = text;
-        if (centerOfGravityPoint) {
-            this.centerOfGravityPoint = centerOfGravityPoint;
-        }
-    }
+    } // Function contains()
+
     /**
      * Item绘制操作
      *
@@ -186,80 +123,8 @@ export class WindowItem extends SGraphyItem {
      * @param   rect          绘制区域
      */
     onDraw(painter: SPainter, rect?: SRect): void {
-        if (this.pointArr.length) {
-            painter.pen.color = this.color;
-            painter.brush.color = this.fillColor;
-            painter.pen.lineWidth = this.width;
-            painter.drawPolygon(this.pointArr);
-            // let text = ''
-            // if (this.businessName || this.businessId) {
-            // 	text = '👇   ' + this.businessName
-            // } else {
-            // 	text = '⬇️   ' + this.initName
-            // }
-            painter.font.size = this.scale * 200;
-            painter.brush.color = SColor.Black;
-            // painter.drawText(text,this.centerOfGravityPoint.x,this.centerOfGravityPoint.y)
-            painter.drawText(
-                this.viewText,
-                this.centerOfGravityPoint.x,
-                this.centerOfGravityPoint.y
-            );
-        }
-    }
-
-    /**
-     * 鼠标单击事件
-     *
-     * @param   event   保存事件参数
-     * @return  boolean
-     */
-    onClick(event: SMouseEvent): boolean {
-        this.$emit("click", event);
-        return true;
-    } // Function onClick()
-
-    /**
-     * 鼠标双击事件
-     *
-     * @param   event   保存事件参数
-     * @return  boolean
-     */
-    onDoubleClick(event: SMouseEvent): boolean {
-        this.$emit("doubleClick", event);
-        return true;
-    } // Function onDoubleClick()
-
-    /**
-     * 鼠标按下事件
-     *
-     * @param   event   保存事件参数
-     * @return  boolean
-     */
-    onMouseDown(event: SMouseEvent): boolean {
-        this.$emit("mouseDown", event);
-        return true;
-    } // Function onMouseDown()
-
-    /**
-     * 鼠标移动事件
-     *
-     * @param   event   保存事件参数
-     * @return  boolean
-     */
-    onMouseMove(event: SMouseEvent): boolean {
-        this.$emit("mouseMove", event);
-        return true;
-    } // Function onMouseMove()
-
-    /**
-     * 释放鼠标事件
-     *
-     * @param   event   保存事件参数
-     * @return  boolean
-     */
-    onMouseUp(event: SMouseEvent): boolean {
-        this.$emit("mouseUp", event);
-        return true;
-    } // Function onMouseUp()
-} // Class WindowItem
+        painter.pen.color = Opt.doorColor;
+        painter.pen.lineWidth = 400;
+        painter.drawPolyline(this.pointArr);
+    } // Function onDraw()
+} // Class DoorItem

+ 42 - 167
src/items/SpaceItem.ts

@@ -20,11 +20,8 @@
 
 import { SGraphyItem, SMouseEvent } from "@sybotan-web/graphy/lib";
 import { SColor, SPainter, SPoint, SRect } from "@sybotan-web/draw/lib";
-
-class PolygonItemInterface {
-    parent: SGraphyItem | null | undefined;
-    space: any;
-}
+import { Space } from "../types/Space";
+import { Opt } from "../types/Opt";
 
 /**
  * 空间item
@@ -32,66 +29,23 @@ class PolygonItemInterface {
  * @author  郝建龙
  */
 export class SpaceItem extends SGraphyItem {
-    /** 点坐标list */
-    pointArr: SPoint[];
-    /** 填充色 */
-    fillColor: SColor = new SColor("#F2F6FC");
-    /** 边框色 */
-    color: SColor = SColor.Black;
-    /** 边框宽度    */
-    width: number = 200;
-    /** 空间id  */
-    id: string;
-    /** 中心坐标    */
-    centerOfGravityPoint: { x: number; y: number };
-    /** 空间名称    */
-    initName: null | string | undefined;
-    /** 绘制文案    */
-    viewText: string = "";
-    /** 需要缓存的边框颜色   */
-    cacheColor: SColor = SColor.Black;
-    /** 需要缓存的填充色   */
-    cacheFillColor: SColor = new SColor("#F2F6FC");
-    /** 需要缓存的边框宽度   */
-    cacheWidth: number = 100;
-    /** 是否激活    */
-    actived: boolean = false;
+    /** 空间所有数据  */
+    data: Space;
+    /** 空间轮廓线坐标list  */
+    private readonly pointArr: SPoint[];
 
     /**
      * 构造函数
      *
-     * @param PolygonItemData
+     * @param data
      */
-    constructor(PolygonItemData: PolygonItemInterface) {
-        super(PolygonItemData.parent);
-        // 修改绘制路径格式
-        let newSpacePaths: SPoint[] = PolygonItemData.space.Paths[0].map(
-            (item: SPoint) => {
-                return new SPoint(item.x, item.y);
-            }
-        );
-        this.pointArr = newSpacePaths;
-        // 填充色
-        this.fillColor = PolygonItemData.space.fillColor
-            ? PolygonItemData.space.fillColor
-            : new SColor("#F2F6FC");
-        // 边框色
-        this.color = PolygonItemData.space.color
-            ? PolygonItemData.space.color
-            : SColor.Black;
-        //边框宽度
-        this.width = PolygonItemData.space.width
-            ? PolygonItemData.space.width
-            : 100;
-        //中心点
-        this.centerOfGravityPoint = {
-            x: PolygonItemData.space.LocationPoint.X,
-            y: -PolygonItemData.space.LocationPoint.Y
-        };
-        this.initName = PolygonItemData.space.Name;
-        this.id = PolygonItemData.space.id;
-        this.viewText = PolygonItemData.space.Name;
-    }
+    constructor(data: Space) {
+        super();
+        this.data = data;
+        this.pointArr = this.data.OutLine[0].map(t => {
+            return new SPoint(t.X, t.Y);
+        });
+    } // Constructor
 
     /**
      * Item对象边界区域
@@ -99,22 +53,23 @@ export class SpaceItem extends SGraphyItem {
      * @return SRect
      */
     boundingRect(): SRect {
-        let minX = this.pointArr[0].x;
+        let pointArr = this.data.OutLine[0];
+        let minX = pointArr[0].X;
         let maxX = minX;
-        let minY = this.pointArr[0].y;
+        let minY = pointArr[0].Y;
         let maxY = minY;
-        for (let i = 1; i < this.pointArr.length; i++) {
-            if (this.pointArr[i].x < minX) {
-                minX = this.pointArr[i].x;
+        for (let i = 1; i < pointArr.length; i++) {
+            if (pointArr[i].X < minX) {
+                minX = pointArr[i].Y;
             }
-            if (this.pointArr[i].y < minY) {
-                minY = this.pointArr[i].y;
+            if (pointArr[i].Y < minY) {
+                minY = pointArr[i].Y;
             }
-            if (this.pointArr[i].x > maxX) {
-                maxX = this.pointArr[i].x;
+            if (pointArr[i].X > maxX) {
+                maxX = pointArr[i].X;
             }
-            if (this.pointArr[i].y > maxY) {
-                maxY = this.pointArr[i].y;
+            if (pointArr[i].Y > maxY) {
+                maxY = pointArr[i].Y;
             }
         }
 
@@ -130,7 +85,7 @@ export class SpaceItem extends SGraphyItem {
     contains(x: number, y: number): boolean {
         let nCross = 0,
             point = [x, y],
-            APoints = this.pointArr,
+            APoints = this.data.OutLine[0],
             length = APoints.length,
             p1,
             p2,
@@ -140,17 +95,17 @@ export class SpaceItem extends SGraphyItem {
         for (i = 1; i <= length; i++) {
             p2 = APoints[i % length];
             if (
-                point[0] > Math.min(p1.x, p2.x) &&
-                point[0] <= Math.max(p1.x, p2.x)
+                point[0] > Math.min(p1.X, p2.X) &&
+                point[0] <= Math.max(p1.X, p2.X)
             ) {
-                if (point[1] <= Math.max(p1.y, p2.y)) {
-                    if (p1.x != p2.x) {
+                if (point[1] <= Math.max(p1.Y, p2.Y)) {
+                    if (p1.X != p2.X) {
                         //计算位置信息
                         xinters =
-                            ((point[0] - p1.x) * (p2.y - p1.y)) /
-                                (p2.x - p1.x) +
-                            p1.y;
-                        if (p1.y == p2.y || point[1] <= xinters) {
+                            ((point[0] - p1.X) * (p2.Y - p1.Y)) /
+                                (p2.X - p1.X) +
+                            p1.Y;
+                        if (p1.Y == p2.Y || point[1] <= xinters) {
                             nCross++;
                         }
                     }
@@ -159,19 +114,8 @@ export class SpaceItem extends SGraphyItem {
             p1 = p2;
         }
         return nCross % 2 === 1;
-    }
-    /**
-     * 添加文本
-     *
-     * @param   text                    修改的文字
-     * @param   centerOfGravityPoint    文字的坐标
-     */
-    addText(text: string, centerOfGravityPoint?: { x: number; y: number }) {
-        this.viewText = text;
-        if (centerOfGravityPoint) {
-            this.centerOfGravityPoint = centerOfGravityPoint;
-        }
-    }
+    } // Function contains()
+
     /**
      * Item绘制操作
      *
@@ -179,80 +123,11 @@ export class SpaceItem extends SGraphyItem {
      * @param   rect          绘制区域
      */
     onDraw(painter: SPainter, rect?: SRect): void {
-        if (this.pointArr.length) {
-            painter.pen.color = this.color;
-            painter.brush.color = this.fillColor;
-            painter.pen.lineWidth = this.width;
+        if (this.visible) {
+            painter.pen.color = SColor.Transparent;
+            painter.brush.color = Opt.spaceColor;
+            painter.pen.lineWidth = 200;
             painter.drawPolygon(this.pointArr);
-            // let text = ''
-            // if (this.businessName || this.businessId) {
-            // 	text = '👇   ' + this.businessName
-            // } else {
-            // 	text = '⬇️   ' + this.initName
-            // }
-            painter.font.size = this.scale * 200;
-            painter.brush.color = SColor.Black;
-            // painter.drawText(text,this.centerOfGravityPoint.x,this.centerOfGravityPoint.y)
-            painter.drawText(
-                this.viewText,
-                this.centerOfGravityPoint.x,
-                this.centerOfGravityPoint.y
-            );
         }
-    }
-
-    /**
-     * 鼠标单击事件
-     *
-     * @param   event   保存事件参数
-     * @return  boolean
-     */
-    onClick(event: SMouseEvent): boolean {
-        this.$emit("click", event);
-        return true;
-    } // Function onClick()
-
-    /**
-     * 鼠标双击事件
-     *
-     * @param   event   保存事件参数
-     * @return  boolean
-     */
-    onDoubleClick(event: SMouseEvent): boolean {
-        this.$emit("doubleClick", event);
-        return true;
-    } // Function onDoubleClick()
-
-    /**
-     * 鼠标按下事件
-     *
-     * @param   event   保存事件参数
-     * @return  boolean
-     */
-    onMouseDown(event: SMouseEvent): boolean {
-        this.$emit("mouseDown", event);
-        return true;
-    } // Function onMouseDown()
-
-    /**
-     * 鼠标移动事件
-     *
-     * @param   event   保存事件参数
-     * @return  boolean
-     */
-    onMouseMove(event: SMouseEvent): boolean {
-        this.$emit("mouseMove", event);
-        return true;
-    } // Function onMouseMove()
-
-    /**
-     * 释放鼠标事件
-     *
-     * @param   event   保存事件参数
-     * @return  boolean
-     */
-    onMouseUp(event: SMouseEvent): boolean {
-        this.$emit("mouseUp", event);
-        return true;
-    } // Function onMouseUp()
+    } // Function onDraw()
 } // Class SpaceItem

+ 0 - 202
src/items/VirtualWall.ts

@@ -1,202 +0,0 @@
-/*
- * ********************************************************************************************************************
- *
- *                      :*$@@%$*:                         ;:                ;;    ;;
- *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
- *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
- *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
- *                   =@*                                  %!              @ $= % %@=   =%@!      %=
- *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
- *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
- *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
- *          $@*   ;@@@%=!:                *@*
- *          =@$    ;;;!=%@@@@=!           =@!
- *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
- *            ;%@@$=$@@%*       *@@@$=%@@%;
- *               ::;::             ::;::                                              All rights reserved.
- *
- * ********************************************************************************************************************
- */
-
-import { SGraphyItem, SMouseEvent } from "@sybotan-web/graphy/lib";
-import { SColor, SPainter, SPoint, SRect } from "@sybotan-web/draw/lib";
-
-class PolygonItemInterface {
-    space: any;
-    parent: SGraphyItem | undefined;
-}
-
-/**
- * 墙item
- *
- * @author  郝建龙
- */
-export class WallItem extends SGraphyItem {
-    /** 点坐标list */
-    pointArr: SPoint[];
-    /** 填充色 */
-    fillColor: SColor = new SColor("#F2F6FC");
-    /** 边框色 */
-    color: SColor = SColor.Black;
-    /** 边框宽度    */
-    width: number = 200;
-    /** 墙id  */
-    id: string;
-    /** 中心坐标    */
-    centerOfGravityPoint: { x: number; y: number };
-    /** 墙名称    */
-    initName: null | string | undefined;
-    /** 绘制文案    */
-    viewText: string = "";
-    /** 需要缓存的边框颜色   */
-    cacheColor: SColor = SColor.Black;
-    /** 需要缓存的填充色   */
-    cacheFillColor: SColor = new SColor("#F2F6FC");
-    /** 需要缓存的边框宽度   */
-    cacheWidth: number = 100;
-    /** 是否激活    */
-    actived: boolean = false;
-
-    /**
-     * 构造函数
-     *
-     * @param PolygonItemData
-     */
-    constructor(PolygonItemData: PolygonItemInterface) {
-        super(PolygonItemData.parent);
-        // 修改绘制路径格式
-        let newSpacePaths: SPoint[] = PolygonItemData.space.Paths[0].map(
-            (item: SPoint) => {
-                return new SPoint(item.x, item.y);
-            }
-        );
-        this.pointArr = newSpacePaths;
-        // 填充色
-        this.fillColor = PolygonItemData.space.fillColor
-            ? PolygonItemData.space.fillColor
-            : new SColor("#F2F6FC");
-        // 边框色
-        this.color = PolygonItemData.space.color
-            ? PolygonItemData.space.color
-            : SColor.Black;
-        //边框宽度
-        this.width = PolygonItemData.space.width
-            ? PolygonItemData.space.width
-            : 100;
-        //中心点
-        this.centerOfGravityPoint = {
-            x: PolygonItemData.space.LocationPoint.X,
-            y: -PolygonItemData.space.LocationPoint.Y
-        };
-        this.initName = PolygonItemData.space.Name;
-        this.id = PolygonItemData.space.id;
-        this.viewText = PolygonItemData.space.Name;
-    }
-
-    /**
-     * Item对象边界区域
-     *
-     * @return SRect
-     */
-    boundingRect(): SRect {
-        let minX = this.pointArr[0].x;
-        let maxX = minX;
-        let minY = this.pointArr[0].y;
-        let maxY = minY;
-        for (let i = 1; i < this.pointArr.length; i++) {
-            if (this.pointArr[i].x < minX) {
-                minX = this.pointArr[i].x;
-            }
-            if (this.pointArr[i].y < minY) {
-                minY = this.pointArr[i].y;
-            }
-            if (this.pointArr[i].x > maxX) {
-                maxX = this.pointArr[i].x;
-            }
-            if (this.pointArr[i].y > maxY) {
-                maxY = this.pointArr[i].y;
-            }
-        }
-
-        return new SRect(minX, minY, maxX - minX, maxY - minY);
-    } // Function boundingRect()
-
-    /**
-     * 判断点是否在区域内
-     *
-     * @param x
-     * @param y
-     */
-    contains(x: number, y: number): boolean {
-        let nCross = 0,
-            point = [x, y],
-            APoints = this.pointArr,
-            length = APoints.length,
-            p1,
-            p2,
-            i,
-            xinters;
-        p1 = APoints[0];
-        for (i = 1; i <= length; i++) {
-            p2 = APoints[i % length];
-            if (
-                point[0] > Math.min(p1.x, p2.x) &&
-                point[0] <= Math.max(p1.x, p2.x)
-            ) {
-                if (point[1] <= Math.max(p1.y, p2.y)) {
-                    if (p1.x != p2.x) {
-                        //计算位置信息
-                        xinters =
-                            ((point[0] - p1.x) * (p2.y - p1.y)) /
-                                (p2.x - p1.x) +
-                            p1.y;
-                        if (p1.y == p2.y || point[1] <= xinters) {
-                            nCross++;
-                        }
-                    }
-                }
-            }
-            p1 = p2;
-        }
-        return nCross % 2 === 1;
-    }
-    /**
-     *
-     * @param text                  修改的文字
-     * @param centerOfGravityPoint  文字的坐标
-     */
-    addText(text: string, centerOfGravityPoint?: { x: number; y: number }) {
-        this.viewText = text;
-        if (centerOfGravityPoint) {
-            this.centerOfGravityPoint = centerOfGravityPoint;
-        }
-    }
-    /**
-     * Item绘制操作
-     *
-     * @param   painter       painter对象
-     * @param   rect          绘制区域
-     */
-    onDraw(painter: SPainter, rect?: SRect): void {
-        if (this.pointArr.length) {
-            painter.pen.color = this.color;
-            painter.brush.color = this.fillColor;
-            painter.pen.lineWidth = this.width;
-            painter.drawPolygon(this.pointArr);
-            // let text = ''
-            // if (this.businessName || this.businessId) {
-            // 	text = '👇   ' + this.businessName
-            // } else {
-            // 	text = '⬇️   ' + this.initName
-            // }
-            painter.font.size = this.scale * 200;
-            painter.brush.color = SColor.Black;
-            // painter.drawText(text,this.centerOfGravityPoint.x,this.centerOfGravityPoint.y)
-            painter.drawText(
-                this.viewText,
-                this.centerOfGravityPoint.x,
-                this.centerOfGravityPoint.y
-            );
-        }
-    }
-} // Class WallItem

+ 61 - 0
src/items/VirtualWallItem.ts

@@ -0,0 +1,61 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+import { SGraphyItem, SMouseEvent } from "@sybotan-web/graphy/lib";
+import { SColor, SPainter, SPoint, SRect } from "@sybotan-web/draw/lib";
+import { VirtualWall } from "../types/VirtualWall";
+import { Opt } from "../types/Opt";
+
+/**
+ * 墙item
+ *
+ * @author  郝建龙
+ */
+export class VirtualWallItem extends SGraphyItem {
+    /** 虚拟墙数据   */
+    data: VirtualWall;
+    /** 虚拟墙轮廓线坐标list  */
+    private readonly pointArr: SPoint[];
+
+    /**
+     * 构造函数
+     *
+     * @param data
+     */
+    constructor(data: VirtualWall) {
+        super();
+        this.data = data;
+        this.pointArr = this.data.OutLine[0].map(t => {
+            return new SPoint(t.X, t.Y);
+        });
+    } // Constructor
+
+    /**
+     * Item绘制操作
+     *
+     * @param   painter       painter对象
+     * @param   rect          绘制区域
+     */
+    onDraw(painter: SPainter, rect?: SRect): void {
+        painter.pen.lineWidth = 100;
+        painter.pen.color = Opt.virtualWallColor;
+        painter.drawPolyline(this.pointArr);
+    } // Function onDraw()
+} // Class VirtualWall

+ 18 - 158
src/items/WallItem.ts

@@ -20,11 +20,8 @@
 
 import { SGraphyItem, SMouseEvent } from "@sybotan-web/graphy/lib";
 import { SColor, SPainter, SPoint, SRect } from "@sybotan-web/draw/lib";
-
-class PolygonItemInterface {
-    space: any;
-    parent: SGraphyItem | undefined;
-}
+import { Wall } from "../types/Wall";
+import { Opt } from "../types/Opt";
 
 /**
  * 墙item
@@ -32,171 +29,34 @@ class PolygonItemInterface {
  * @author  郝建龙
  */
 export class WallItem extends SGraphyItem {
-    /** 点坐标list */
-    pointArr: SPoint[];
-    /** 填充色 */
-    fillColor: SColor = new SColor("#F2F6FC");
-    /** 边框色 */
-    color: SColor = SColor.Black;
-    /** 边框宽度    */
-    width: number = 200;
-    /** 墙id  */
-    id: string;
-    /** 中心坐标    */
-    centerOfGravityPoint: { x: number; y: number };
-    /** 墙名称    */
-    initName: null | string | undefined;
-    /** 绘制文案    */
-    viewText: string = "";
-    /** 需要缓存的边框颜色   */
-    cacheColor: SColor = SColor.Black;
-    /** 需要缓存的填充色   */
-    cacheFillColor: SColor = new SColor("#F2F6FC");
-    /** 需要缓存的边框宽度   */
-    cacheWidth: number = 100;
-    /** 是否激活    */
-    actived: boolean = false;
+    /** 墙数据 */
+    data: Wall;
+    /** 墙轮廓线坐标list  */
+    private readonly pointArr: SPoint[];
 
     /**
      * 构造函数
      *
      * @param PolygonItemData
      */
-    constructor(PolygonItemData: PolygonItemInterface) {
-        super(PolygonItemData.parent);
-        // 修改绘制路径格式
-        let newSpacePaths: SPoint[] = PolygonItemData.space.Paths[0].map(
-            (item: SPoint) => {
-                return new SPoint(item.x, item.y);
-            }
-        );
-        this.pointArr = newSpacePaths;
-        // 填充色
-        this.fillColor = PolygonItemData.space.fillColor
-            ? PolygonItemData.space.fillColor
-            : new SColor("#F2F6FC");
-        // 边框色
-        this.color = PolygonItemData.space.color
-            ? PolygonItemData.space.color
-            : SColor.Black;
-        //边框宽度
-        this.width = PolygonItemData.space.width
-            ? PolygonItemData.space.width
-            : 100;
-        //中心点
-        this.centerOfGravityPoint = {
-            x: PolygonItemData.space.LocationPoint.X,
-            y: -PolygonItemData.space.LocationPoint.Y
-        };
-        this.initName = PolygonItemData.space.Name;
-        this.id = PolygonItemData.space.id;
-        this.viewText = PolygonItemData.space.Name;
-    }
-
-    /**
-     * Item对象边界区域
-     *
-     * @return SRect
-     */
-    boundingRect(): SRect {
-        let minX = this.pointArr[0].x;
-        let maxX = minX;
-        let minY = this.pointArr[0].y;
-        let maxY = minY;
-        for (let i = 1; i < this.pointArr.length; i++) {
-            if (this.pointArr[i].x < minX) {
-                minX = this.pointArr[i].x;
-            }
-            if (this.pointArr[i].y < minY) {
-                minY = this.pointArr[i].y;
-            }
-            if (this.pointArr[i].x > maxX) {
-                maxX = this.pointArr[i].x;
-            }
-            if (this.pointArr[i].y > maxY) {
-                maxY = this.pointArr[i].y;
-            }
-        }
-
-        return new SRect(minX, minY, maxX - minX, maxY - minY);
-    } // Function boundingRect()
+    constructor(data: Wall) {
+        super();
+        this.data = data;
+        this.pointArr = this.data.OutLine[0].map(t => {
+            return new SPoint(t.X, t.Y);
+        });
+    } // Constructor
 
     /**
-     * 判断点是否在区域内
-     *
-     * @param x
-     * @param y
-     */
-    contains(x: number, y: number): boolean {
-        let nCross = 0,
-            point = [x, y],
-            APoints = this.pointArr,
-            length = APoints.length,
-            p1,
-            p2,
-            i,
-            xinters;
-        p1 = APoints[0];
-        for (i = 1; i <= length; i++) {
-            p2 = APoints[i % length];
-            if (
-                point[0] > Math.min(p1.x, p2.x) &&
-                point[0] <= Math.max(p1.x, p2.x)
-            ) {
-                if (point[1] <= Math.max(p1.y, p2.y)) {
-                    if (p1.x != p2.x) {
-                        //计算位置信息
-                        xinters =
-                            ((point[0] - p1.x) * (p2.y - p1.y)) /
-                                (p2.x - p1.x) +
-                            p1.y;
-                        if (p1.y == p2.y || point[1] <= xinters) {
-                            nCross++;
-                        }
-                    }
-                }
-            }
-            p1 = p2;
-        }
-        return nCross % 2 === 1;
-    }
-    /**
-     *
-     * @param text                  修改的文字
-     * @param centerOfGravityPoint  文字的坐标
-     */
-    addText(text: string, centerOfGravityPoint?: { x: number; y: number }) {
-        this.viewText = text;
-        if (centerOfGravityPoint) {
-            this.centerOfGravityPoint = centerOfGravityPoint;
-        }
-    }
-    /**
      * Item绘制操作
      *
      * @param   painter       painter对象
      * @param   rect          绘制区域
      */
     onDraw(painter: SPainter, rect?: SRect): void {
-        if (this.pointArr.length) {
-            painter.pen.color = this.color;
-            painter.brush.color = this.fillColor;
-            painter.pen.lineWidth = this.width;
-            painter.drawPolygon(this.pointArr);
-            // let text = ''
-            // if (this.businessName || this.businessId) {
-            // 	text = '👇   ' + this.businessName
-            // } else {
-            // 	text = '⬇️   ' + this.initName
-            // }
-            painter.font.size = this.scale * 200;
-            painter.brush.color = SColor.Black;
-            // painter.drawText(text,this.centerOfGravityPoint.x,this.centerOfGravityPoint.y)
-            painter.drawText(
-                this.viewText,
-                this.centerOfGravityPoint.x,
-                this.centerOfGravityPoint.y
-            );
-        }
-    }
+        painter.pen.color = Opt.wallColor;
+        painter.pen.lineWidth = 4;
+        painter.brush.color = Opt.wallColor;
+        painter.drawPolygon(this.pointArr);
+    } // Function onDraw()
 } // Class WallItem

+ 41 - 176
src/items/WindowItem.ts

@@ -20,11 +20,8 @@
 
 import { SGraphyItem, SMouseEvent } from "@sybotan-web/graphy/lib";
 import { SColor, SPainter, SPoint, SRect } from "@sybotan-web/draw/lib";
-
-class PolygonItemInterface {
-    parent: SGraphyItem | undefined;
-    space: any;
-}
+import { Casement } from "../types/Casement";
+import { Opt } from "../types/Opt";
 
 /**
  * 窗户item
@@ -32,74 +29,23 @@ class PolygonItemInterface {
  * @author  郝建龙
  */
 export class WindowItem extends SGraphyItem {
-    /** 点坐标list */
-    pointArr: SPoint[];
-    /** 填充色 */
-    fillColor: SColor = new SColor("#F2F6FC");
-    /** 边框色 */
-    color: SColor = SColor.Black;
-    /** 边框宽度    */
-    width: number = 200;
-    /** 空间id  */
-    id: string;
-    /** 中心坐标    */
-    centerOfGravityPoint: { x: number; y: number };
-    /** 空间名称    */
-    initName: null | string | undefined;
-    /** 绘制文案    */
-    viewText: string = "";
-    /** 需要缓存的边框颜色   */
-    cacheColor: SColor = SColor.Black;
-    /** 需要缓存的填充色   */
-    cacheFillColor: SColor = new SColor("#F2F6FC");
-    /** 需要缓存的边框宽度   */
-    cacheWidth: number = 100;
-    /** 是否激活    */
-    actived: boolean = false;
+    /** 窗户数据    */
+    data: Casement;
+    /** 窗户轮廓线坐标list  */
+    private readonly pointArr: SPoint[];
 
     /**
      * 构造函数
      *
-     * @param pointArr                  点坐标list
-     * @param width                     边框的宽度
-     * @param color                     边框的颜色
-     * @param fillColor                 多边形填充的颜色
-     * @param businessId                空间id
-     * @param businessName              空间名称
-     * @param centerOfGravityPoint      中心点
-     * @param isBusiness                状态
-     * @param parent
+     * @param data
      */
-    constructor(PolygonItemData: PolygonItemInterface) {
-        super(PolygonItemData.parent);
-        // 修改绘制路径格式
-        let newSpacePaths: SPoint[] = PolygonItemData.space.Paths[0].map(
-            (item: SPoint) => {
-                return new SPoint(item.x, item.y);
-            }
-        );
-        this.pointArr = newSpacePaths;
-        // 填充色
-        this.fillColor = PolygonItemData.space.fillColor
-            ? PolygonItemData.space.fillColor
-            : new SColor("#F2F6FC");
-        // 边框色
-        this.color = PolygonItemData.space.color
-            ? PolygonItemData.space.color
-            : SColor.Black;
-        //边框宽度
-        this.width = PolygonItemData.space.width
-            ? PolygonItemData.space.width
-            : 100;
-        //中心点
-        this.centerOfGravityPoint = {
-            x: PolygonItemData.space.LocationPoint.X,
-            y: -PolygonItemData.space.LocationPoint.Y
-        };
-        this.initName = PolygonItemData.space.Name;
-        this.id = PolygonItemData.space.id;
-        this.viewText = PolygonItemData.space.Name;
-    }
+    constructor(data: Casement) {
+        super();
+        this.data = data;
+        this.pointArr = this.data.OutLine[0].map(t => {
+            return new SPoint(t.X, t.Y);
+        });
+    } // Constructor
 
     /**
      * Item对象边界区域
@@ -107,22 +53,23 @@ export class WindowItem extends SGraphyItem {
      * @return SRect
      */
     boundingRect(): SRect {
-        let minX = this.pointArr[0].x;
+        let pointArr = this.data.OutLine[0];
+        let minX = pointArr[0].X;
         let maxX = minX;
-        let minY = this.pointArr[0].y;
+        let minY = pointArr[0].Y;
         let maxY = minY;
-        for (let i = 1; i < this.pointArr.length; i++) {
-            if (this.pointArr[i].x < minX) {
-                minX = this.pointArr[i].x;
+        for (let i = 1; i < pointArr.length; i++) {
+            if (pointArr[i].X < minX) {
+                minX = pointArr[i].Y;
             }
-            if (this.pointArr[i].y < minY) {
-                minY = this.pointArr[i].y;
+            if (pointArr[i].Y < minY) {
+                minY = pointArr[i].Y;
             }
-            if (this.pointArr[i].x > maxX) {
-                maxX = this.pointArr[i].x;
+            if (pointArr[i].X > maxX) {
+                maxX = pointArr[i].X;
             }
-            if (this.pointArr[i].y > maxY) {
-                maxY = this.pointArr[i].y;
+            if (pointArr[i].Y > maxY) {
+                maxY = pointArr[i].Y;
             }
         }
 
@@ -138,7 +85,7 @@ export class WindowItem extends SGraphyItem {
     contains(x: number, y: number): boolean {
         let nCross = 0,
             point = [x, y],
-            APoints = this.pointArr,
+            APoints = this.data.OutLine[0],
             length = APoints.length,
             p1,
             p2,
@@ -148,17 +95,17 @@ export class WindowItem extends SGraphyItem {
         for (i = 1; i <= length; i++) {
             p2 = APoints[i % length];
             if (
-                point[0] > Math.min(p1.x, p2.x) &&
-                point[0] <= Math.max(p1.x, p2.x)
+                point[0] > Math.min(p1.X, p2.X) &&
+                point[0] <= Math.max(p1.X, p2.X)
             ) {
-                if (point[1] <= Math.max(p1.y, p2.y)) {
-                    if (p1.x != p2.x) {
+                if (point[1] <= Math.max(p1.Y, p2.Y)) {
+                    if (p1.X != p2.X) {
                         //计算位置信息
                         xinters =
-                            ((point[0] - p1.x) * (p2.y - p1.y)) /
-                                (p2.x - p1.x) +
-                            p1.y;
-                        if (p1.y == p2.y || point[1] <= xinters) {
+                            ((point[0] - p1.X) * (p2.Y - p1.Y)) /
+                                (p2.X - p1.X) +
+                            p1.Y;
+                        if (p1.Y == p2.Y || point[1] <= xinters) {
                             nCross++;
                         }
                     }
@@ -167,18 +114,8 @@ export class WindowItem extends SGraphyItem {
             p1 = p2;
         }
         return nCross % 2 === 1;
-    }
-    /**
-     *
-     * @param text 修改的文字
-     * @param centerOfGravityPoint 文字的坐标
-     */
-    addText(text: string, centerOfGravityPoint?: { x: number; y: number }) {
-        this.viewText = text;
-        if (centerOfGravityPoint) {
-            this.centerOfGravityPoint = centerOfGravityPoint;
-        }
-    }
+    } // Function contains()
+
     /**
      * Item绘制操作
      *
@@ -186,80 +123,8 @@ export class WindowItem extends SGraphyItem {
      * @param   rect          绘制区域
      */
     onDraw(painter: SPainter, rect?: SRect): void {
-        if (this.pointArr.length) {
-            painter.pen.color = this.color;
-            painter.brush.color = this.fillColor;
-            painter.pen.lineWidth = this.width;
-            painter.drawPolygon(this.pointArr);
-            // let text = ''
-            // if (this.businessName || this.businessId) {
-            // 	text = '👇   ' + this.businessName
-            // } else {
-            // 	text = '⬇️   ' + this.initName
-            // }
-            painter.font.size = this.scale * 200;
-            painter.brush.color = SColor.Black;
-            // painter.drawText(text,this.centerOfGravityPoint.x,this.centerOfGravityPoint.y)
-            painter.drawText(
-                this.viewText,
-                this.centerOfGravityPoint.x,
-                this.centerOfGravityPoint.y
-            );
-        }
-    }
-
-    /**
-     * 鼠标单击事件
-     *
-     * @param   event   保存事件参数
-     * @return  boolean
-     */
-    onClick(event: SMouseEvent): boolean {
-        this.$emit("click", event);
-        return true;
-    } // Function onClick()
-
-    /**
-     * 鼠标双击事件
-     *
-     * @param   event   保存事件参数
-     * @return  boolean
-     */
-    onDoubleClick(event: SMouseEvent): boolean {
-        this.$emit("doubleClick", event);
-        return true;
-    } // Function onDoubleClick()
-
-    /**
-     * 鼠标按下事件
-     *
-     * @param   event   保存事件参数
-     * @return  boolean
-     */
-    onMouseDown(event: SMouseEvent): boolean {
-        this.$emit("mouseDown", event);
-        return true;
-    } // Function onMouseDown()
-
-    /**
-     * 鼠标移动事件
-     *
-     * @param   event   保存事件参数
-     * @return  boolean
-     */
-    onMouseMove(event: SMouseEvent): boolean {
-        this.$emit("mouseMove", event);
-        return true;
-    } // Function onMouseMove()
-
-    /**
-     * 释放鼠标事件
-     *
-     * @param   event   保存事件参数
-     * @return  boolean
-     */
-    onMouseUp(event: SMouseEvent): boolean {
-        this.$emit("mouseUp", event);
-        return true;
-    } // Function onMouseUp()
+        painter.pen.color = Opt.windowColor;
+        painter.pen.lineWidth = 400;
+        painter.drawPolyline(this.pointArr);
+    } // Function onDraw()
 } // Class WindowItem

+ 8 - 8
src/types/JsonData.ts

@@ -30,11 +30,11 @@ import { Casement } from "./Casement";
  *
  * @author  郝建龙
  */
-export interface JsonData {
-    Columns: Column;
-    Doors: Door;
-    Spaces: Space;
-    VirtualWalls: VirtualWall;
-    Walls: Wall;
-    Casement: Casement;
-} // Interface JsonData
+export interface FloorData {
+    Columns: Column[];
+    Doors: Door[];
+    Spaces: Space[];
+    VirtualWalls: VirtualWall[];
+    Walls: Wall[];
+    Windows: Casement[];
+} // Interface FloorData

+ 41 - 0
src/types/Opt.ts

@@ -0,0 +1,41 @@
+/*
+ * ********************************************************************************************************************
+ *
+ *                      :*$@@%$*:                         ;:                ;;    ;;
+ *                    :@@%!  :!@@%:                       %!             ;%%@@%$ =@@@@@@@%;     @%@@@%%%%@@@@@
+ *                   :@%;       :$=                       %%$$$%$$         ;$$  ;$@=   !@$
+ *                   =@!                                  %!              @ $=;%   !@@@%:      !$$$$$$$$$$$$$$=
+ *                   =@*                                  %!              @ $= % %@=   =%@!      %=
+ *              *$%%! @@=        ;=$%%%$*:                %!              @ $= % =%%%%%%@$      *%:         =%
+ *            %@@!:    !@@@%=$@@@@%!  :*@@$:              %!              @ $= % $*     ;@      @*          :%*
+ *          ;@@!          ;!!!;:         ;@%:      =======@%========*     @ $$ % $%*****$@     :@$=*********=@$
+ *          $@*   ;@@@%=!:                *@*
+ *          =@$    ;;;!=%@@@@=!           =@!
+ *           %@$:      =@%: :*@@@*       %@=                    Copyright (c) 2016-2019.  北京上格云技术有限公司
+ *            ;%@@$=$@@%*       *@@@$=%@@%;
+ *               ::;::             ::;::                                              All rights reserved.
+ *
+ * ********************************************************************************************************************
+ */
+
+import { SColor } from "@sybotan-web/draw/lib";
+
+/**
+ * 接口
+ *
+ * @author  郝建龙
+ */
+export class Opt {
+    /** 墙颜色 */
+    static wallColor = new SColor("#FF000080");
+    /** 柱子颜色 */
+    static columnColor = SColor.Black;
+    /** 虚拟墙颜色 */
+    static virtualWallColor = SColor.Black;
+    /** 空间颜色 */
+    static spaceColor = new SColor("#cbe5ff");
+    /** 门颜色 */
+    static doorColor = new SColor("#f5b36f");
+    /** 窗户颜色 */
+    static windowColor = new SColor("#fcd6ff");
+} // Interface Opt