|
@@ -0,0 +1,181 @@
|
|
|
+import { getJsonz, ItemColor } from "@persagy-web/big/lib";
|
|
|
+import { SColumnItem } from "@persagy-web/big/lib/items/floor/SColumnItem";
|
|
|
+import { SDoorItem } from "@persagy-web/big/lib/items/floor/SDoorItem";
|
|
|
+import { SSpaceItem } from "@persagy-web/big/lib/items/floor/SSpaceItem";
|
|
|
+import { SVirtualWallItem } from "@persagy-web/big/lib/items/floor/SVirtualWallItem";
|
|
|
+import { SWallItem } from "@persagy-web/big/lib/items/floor/SWallItem";
|
|
|
+import { SWindowItem } from "@persagy-web/big/lib/items/floor/SWindowItem";
|
|
|
+import { Casement } from "@persagy-web/big/lib/types/floor/Casement";
|
|
|
+import { Column } from "@persagy-web/big/lib/types/floor/Column";
|
|
|
+import { Door } from "@persagy-web/big/lib/types/floor/Door";
|
|
|
+import { Space } from "@persagy-web/big/lib/types/floor/Space";
|
|
|
+import { VirtualWall } from "@persagy-web/big/lib/types/floor/VirtualWall";
|
|
|
+import { Wall } from "@persagy-web/big/lib/types/floor/Wall";
|
|
|
+import { FloorData } from "@persagy-web/big/lib/types/FloorData";
|
|
|
+import { SGraphScene } from "@persagy-web/graph/lib";
|
|
|
+
|
|
|
+
|
|
|
+ * 楼层平面图
|
|
|
+ */
|
|
|
+export class FloorScene extends SGraphScene {
|
|
|
+
|
|
|
+ json: string | null = null;
|
|
|
+
|
|
|
+ wallList: SWallItem[] = [];
|
|
|
+
|
|
|
+ columnList: SColumnItem[] = [];
|
|
|
+
|
|
|
+ doorList: SDoorItem[] = [];
|
|
|
+
|
|
|
+ casementList: SWindowItem[] = [];
|
|
|
+
|
|
|
+ virtualWallList: SVirtualWallItem[] = [];
|
|
|
+
|
|
|
+ spaceList: SSpaceItem[] = [];
|
|
|
+
|
|
|
+
|
|
|
+ _isSpaceSelectable: boolean = true;
|
|
|
+ get isSpaceSelectable(): boolean {
|
|
|
+ return this._isSpaceSelectable;
|
|
|
+ }
|
|
|
+ set isSpaceSelectable(v: boolean) {
|
|
|
+ if (this._isSpaceSelectable === v) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this._isSpaceSelectable = v;
|
|
|
+ this.spaceList.map(
|
|
|
+ (t: SSpaceItem): SSpaceItem => {
|
|
|
+ t.selectable = this._isSpaceSelectable;
|
|
|
+ return t;
|
|
|
+ }
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ constructor() {
|
|
|
+ super()
|
|
|
+
|
|
|
+ this.selectContainer.showSelect = false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 获取底图压缩文件
|
|
|
+ *
|
|
|
+ * @param url 请求数据文件路径
|
|
|
+ */
|
|
|
+ loadUrl(url: string): Promise<void> {
|
|
|
+ return getJsonz(url).then((res: any) => {
|
|
|
+ this.addBaseMapItem(res)
|
|
|
+ this.json = JSON.stringify(res);
|
|
|
+ return res;
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 增添所有底图item;
|
|
|
+ *
|
|
|
+ * @param data itemList对象
|
|
|
+ */
|
|
|
+ private addBaseMapItem(data: FloorData): void {
|
|
|
+ if (data.Walls) {
|
|
|
+ data.Walls.forEach((t: Wall): void => {
|
|
|
+ this.addWall(t);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (data.Columns) {
|
|
|
+ data.Columns.forEach((t: Column): void => {
|
|
|
+ this.addColumn(t);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (data.Windows) {
|
|
|
+ data.Windows.forEach((t: Casement): void => {
|
|
|
+ this.addCasement(t);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (data.VirtualWalls) {
|
|
|
+ data.VirtualWalls.forEach((t: VirtualWall): void => {
|
|
|
+ this.addVirtualWall(t);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (data.Doors) {
|
|
|
+ data.Doors.forEach((t: Door): void => {
|
|
|
+ this.addDoor(t);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if (data.Spaces) {
|
|
|
+ data.Spaces.forEach((t: Space): void => {
|
|
|
+ this.addSpace(t);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 添加空间到scene 中
|
|
|
+ *
|
|
|
+ * @param space 空间item
|
|
|
+ */
|
|
|
+ addSpace(space: Space): void {
|
|
|
+ let item = new SSpaceItem(null, space);
|
|
|
+ item.selectable = this.isSpaceSelectable;
|
|
|
+ item.fillColor = ItemColor.spaceColor;
|
|
|
+ item.strokeColor = ItemColor.spaceBorderColor;
|
|
|
+ this.spaceList.push(item);
|
|
|
+ this.addItem(item);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 添加柱子到scene 中
|
|
|
+ *
|
|
|
+ * @param column 柱子item
|
|
|
+ */
|
|
|
+ addColumn(column: Column): void {
|
|
|
+ let item = new SColumnItem(null, column);
|
|
|
+ item.fillColor = ItemColor.columnColor;
|
|
|
+ this.columnList.push(item);
|
|
|
+ this.addItem(item);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 添加墙到scene 中
|
|
|
+ *
|
|
|
+ * @param wall 墙item
|
|
|
+ */
|
|
|
+ addWall(wall: Wall): void {
|
|
|
+ let item = new SWallItem(null, wall);
|
|
|
+ item.fillColor = ItemColor.wallColor;
|
|
|
+ this.wallList.push(item);
|
|
|
+ this.addItem(item);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 添加所有虚拟墙到scene中
|
|
|
+ *
|
|
|
+ * @param virtualWall 虚拟墙item
|
|
|
+ */
|
|
|
+ addVirtualWall(virtualWall: VirtualWall): void {
|
|
|
+ let item = new SVirtualWallItem(null, virtualWall);
|
|
|
+ this.virtualWallList.push(item);
|
|
|
+ this.addItem(item);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 添加门到scene 中
|
|
|
+ *
|
|
|
+ * @param door
|
|
|
+ */
|
|
|
+ addDoor(door: Door): void {
|
|
|
+ let item = new SDoorItem(null, door);
|
|
|
+ this.doorList.push(item);
|
|
|
+ this.addItem(item);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 添加窗户到scene 中
|
|
|
+ *
|
|
|
+ * @param casement
|
|
|
+ */
|
|
|
+ addCasement(casement: Casement): void {
|
|
|
+ let item = new SWindowItem(null, casement);
|
|
|
+ this.casementList.push(item);
|
|
|
+ this.addItem(item);
|
|
|
+ }
|
|
|
+}
|