123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- 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数据 */
- json: string | null = null;
- /** 墙list */
- wallList: SWallItem[] = [];
- /** 柱子list */
- columnList: SColumnItem[] = [];
- /** 门list */
- doorList: SDoorItem[] = [];
- /** 窗list */
- casementList: SWindowItem[] = [];
- /** 虚拟墙list */
- virtualWallList: SVirtualWallItem[] = [];
- /** 空间list */
- spaceList: SSpaceItem[] = [];
- /** 空间是否可选 */
- _isSpaceSelectable: boolean = true;
- get isSpaceSelectable(): boolean {
- return this._isSpaceSelectable;
- } // Get 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;
- }
- );
- } // Set isSpaceSelectable
- 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;
- })
- } // Function loadUrl()
- /**
- * 增添所有底图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);
- });
- }
- } // Function addBaseMapItem()
- /**
- * 添加空间到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);
- } // Function addSpace()
- /**
- * 添加柱子到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);
- } // Function addColumn()
- /**
- * 添加墙到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);
- } // Function addWall()
- /**
- * 添加所有虚拟墙到scene中
- *
- * @param virtualWall 虚拟墙item
- */
- addVirtualWall(virtualWall: VirtualWall): void {
- let item = new SVirtualWallItem(null, virtualWall);
- this.virtualWallList.push(item);
- this.addItem(item);
- } // Function addVirtualWall()
- /**
- * 添加门到scene 中
- *
- * @param door
- */
- addDoor(door: Door): void {
- let item = new SDoorItem(null, door);
- this.doorList.push(item);
- this.addItem(item);
- } // Function addDoor()
- /**
- * 添加窗户到scene 中
- *
- * @param casement
- */
- addCasement(casement: Casement): void {
- let item = new SWindowItem(null, casement);
- this.casementList.push(item);
- this.addItem(item);
- } // Function addCasement()
- }
|