|
@@ -19,16 +19,22 @@
|
|
*/
|
|
*/
|
|
|
|
|
|
import { SGraphyClockItem, SGraphyScene } from "@sybotan-web/graphy/lib";
|
|
import { SGraphyClockItem, SGraphyScene } from "@sybotan-web/graphy/lib";
|
|
-import Axios from "axios";
|
|
|
|
// @ts-ignore
|
|
// @ts-ignore
|
|
import pako from "pako";
|
|
import pako from "pako";
|
|
-import { JsonData } from "./types/JsonData";
|
|
|
|
|
|
+import { FloorData } from "./types/FloorData";
|
|
import { Space } from "./types/Space";
|
|
import { Space } from "./types/Space";
|
|
import { Column } from "./types/Column";
|
|
import { Column } from "./types/Column";
|
|
import { Wall } from "./types/Wall";
|
|
import { Wall } from "./types/Wall";
|
|
import { VirtualWall } from "./types/VirtualWall";
|
|
import { VirtualWall } from "./types/VirtualWall";
|
|
import { Door } from "./types/Door";
|
|
import { Door } from "./types/Door";
|
|
import { Casement } from "./types/Casement";
|
|
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 {
|
|
export class FloorScene extends SGraphyScene {
|
|
/** item数据 */
|
|
/** 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 绘制空间地图得所有参数
|
|
* @param data 绘制空间地图得所有参数
|
|
*/
|
|
*/
|
|
constructor() {
|
|
constructor() {
|
|
super();
|
|
super();
|
|
- let click = new SGraphyClockItem(null, 300, 300);
|
|
|
|
- this.addItem(click);
|
|
|
|
} // Constructor()
|
|
} // Constructor()
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 获取底图文件
|
|
|
|
|
|
+ * 获取底图压缩文件
|
|
*
|
|
*
|
|
* @param url 请求数据文件路径
|
|
* @param url 请求数据文件路径
|
|
*/
|
|
*/
|
|
- urlGetData(url: string) {
|
|
|
|
|
|
+ loadUrl(url: string) {
|
|
let that = this;
|
|
let that = this;
|
|
return new Promise((relove, reject) => {
|
|
return new Promise((relove, reject) => {
|
|
Axios({
|
|
Axios({
|
|
@@ -72,28 +176,27 @@ export class FloorScene extends SGraphyScene {
|
|
})
|
|
})
|
|
.then((res: any) => {
|
|
.then((res: any) => {
|
|
let blob = res.data;
|
|
let blob = res.data;
|
|
- this.zipToJson(blob)
|
|
|
|
|
|
+ this.unzip(blob)
|
|
.then((jsonData: any) => {
|
|
.then((jsonData: any) => {
|
|
- that.addAllItems(jsonData);
|
|
|
|
|
|
+ that.addBaseMapItem(jsonData);
|
|
relove();
|
|
relove();
|
|
})
|
|
})
|
|
.catch((error: any) => {
|
|
.catch((error: any) => {
|
|
console.log(error);
|
|
console.log(error);
|
|
});
|
|
});
|
|
- // console.log(reader)
|
|
|
|
})
|
|
})
|
|
.catch((res: any) => {
|
|
.catch((res: any) => {
|
|
console.log(res);
|
|
console.log(res);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
- } // Function urlGetData
|
|
|
|
|
|
+ } // Function loadUrl
|
|
|
|
|
|
/**
|
|
/**
|
|
* 解压数据
|
|
* 解压数据
|
|
*
|
|
*
|
|
* @param blob 文件
|
|
* @param blob 文件
|
|
*/
|
|
*/
|
|
- zipToJson(blob: any): any {
|
|
|
|
|
|
+ private unzip(blob: any): any {
|
|
let reader = new FileReader();
|
|
let reader = new FileReader();
|
|
reader.readAsBinaryString(blob);
|
|
reader.readAsBinaryString(blob);
|
|
let that = this;
|
|
let that = this;
|
|
@@ -103,67 +206,136 @@ export class FloorScene extends SGraphyScene {
|
|
//解压数据
|
|
//解压数据
|
|
let base64Data = btoa(binaryString);
|
|
let base64Data = btoa(binaryString);
|
|
let unGzipData = pako.unzip(base64Data);
|
|
let unGzipData = pako.unzip(base64Data);
|
|
- that.data = unGzipData.EntityList.Elements;
|
|
|
|
|
|
+ that.data = unGzipData.EntityList[0].Elements;
|
|
resolve(unGzipData);
|
|
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对象
|
|
* @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 中
|
|
* 添加所有空间到scene 中
|
|
*
|
|
*
|
|
* @param space 空间list
|
|
* @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 中
|
|
* 添加所有设备到scene 中
|
|
*
|
|
*
|
|
* @param column 柱子list
|
|
* @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 中
|
|
* 添加所有设备到scene 中
|
|
*
|
|
*
|
|
* @param wall 墙list
|
|
* @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 中
|
|
* 添加所有虚拟墙到scene 中
|
|
*
|
|
*
|
|
* @param virtualWall 虚拟墙list
|
|
* @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 中
|
|
* 添加所有位置标签到scene 中
|
|
*
|
|
*
|
|
* @param doors 门list
|
|
* @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 中
|
|
* 添加所有位置标签到scene 中
|
|
*
|
|
*
|
|
* @param windows 窗户list
|
|
* @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;
|
|
return data;
|
|
- }
|
|
|
|
|
|
+ } // Function changeMap
|
|
} // Class FloorScene
|
|
} // Class FloorScene
|