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: 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;
- }
-
- loadUrl(url: string): Promise<void> {
- return getJsonz(url).then((res: any) => {
- this.addBaseMapItem(res)
- this.json = JSON.stringify(res);
- return res;
- })
- }
-
- 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);
- });
- }
- }
-
- 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);
- }
-
- addColumn(column: Column): void {
- let item = new SColumnItem(null, column);
- item.fillColor = ItemColor.columnColor;
- this.columnList.push(item);
- this.addItem(item);
- }
-
- addWall(wall: Wall): void {
- let item = new SWallItem(null, wall);
- item.fillColor = ItemColor.wallColor;
- this.wallList.push(item);
- this.addItem(item);
- }
-
- addVirtualWall(virtualWall: VirtualWall): void {
- let item = new SVirtualWallItem(null, virtualWall);
- this.virtualWallList.push(item);
- this.addItem(item);
- }
-
- addDoor(door: Door): void {
- let item = new SDoorItem(null, door);
- this.doorList.push(item);
- this.addItem(item);
- }
-
- addCasement(casement: Casement): void {
- let item = new SWindowItem(null, casement);
- this.casementList.push(item);
- this.addItem(item);
- }
- }
|