var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); import { SPoint } from "@sybotan-web/base"; import { SGraphyPolygonItem } from './newItems/SGraphyPolygonItem.js'; import { SGraphyWallItem } from './newItems/SGraphyWallItem.js'; import { SGraphyImgItem } from './newItems/SGraphyImgItem.js'; import { SGraphyScene } from "@sybotan-web/graphy"; /** * @name mainScene * @time 2019-07.07; * 添加所有item的场景到scene中 */ var mainScene = /** @class */ (function (_super) { __extends(mainScene, _super); /** * @param data 绘制空间地图得所有参数 */ function mainScene(data) { var _this_1 = _super.call(this) || this; _this_1._isShowSpace = true; // 是否显示空间; _this_1._isShowWallList = true; //是否展示墙体; _this_1._isShowEquipmentList = true; //是否展示设备; _this_1._isShowVrtualWallList = true; //是否展示虚拟墙 _this_1.data = data; _this_1.addAllItemList(data); return _this_1; } Object.defineProperty(mainScene.prototype, "isShowSpace", { // 设置是否显示空间 get: function () { return this._isShowSpace; }, set: function (b) { this._isShowSpace = b; }, enumerable: true, configurable: true }); Object.defineProperty(mainScene.prototype, "isShowWallList", { // 设置是否显示墙 get: function () { return this._isShowWallList; }, set: function (b) { this._isShowWallList = b; }, enumerable: true, configurable: true }); Object.defineProperty(mainScene.prototype, "isShowEquipmentList", { // 设置是否显示设备 get: function () { return this._isShowEquipmentList; }, set: function (b) { this._isShowEquipmentList = b; }, enumerable: true, configurable: true }); Object.defineProperty(mainScene.prototype, "isShowVrtualWallList", { // 设置是否显示虚拟墙 get: function () { return this._isShowVrtualWallList; }, set: function (b) { this._isShowVrtualWallList = b; }, enumerable: true, configurable: true }); // 以下是绘制方法 /** * 增添所有绘制item(地图); */ mainScene.prototype.addAllItemList = function (data) { console.log(data); var space = data.SpaceList; this.addSpaceList(space); //绘制空间 var wall = data.WallList; this.addWallList(wall); var images = data.images; this.addImgList(images); }; /** * 添加所有空间到scene 中 * @param space 空间list */ mainScene.prototype.addSpaceList = function (space) { if (space && space.length) { for (var i = 0; i < space.length; i++) { if (space[i].Paths[1] && space[i].Paths[1].length >= 2) { space[i].isBusiness = 2; this.addItem(this.constructeItem({ parent: null, space: space[i] })); } if (space[i].Paths[0] && space[i].Paths[0].length >= 2 && !space[i].Paths[1]) { space[i].isBusiness = 2; this.addItem(this.constructeItem({ parent: null, space: space[i] })); } } } }; // 绘制墙体 mainScene.prototype.addWallList = function (wall) { var _this_1 = this; if (wall && wall.length) { wall.map(function (t) { var newArr = t.PointList.map(function (pa) { return new SPoint(pa.X, pa.Y); }); _this_1.addItem(new SGraphyWallItem(null, newArr)); }); } }; // 绘制设备 mainScene.prototype.addEquipmentList = function () { }; // 绘制柱体 mainScene.prototype.addColumnListList = function () { }; // 绘制虚拟墙 mainScene.prototype.addVrtualWallList = function () { }; // 绘制图片 -- todo mainScene.prototype.addImgList = function (images) { var _this_1 = this; if (images && images.length) { images.map(function (t) { _this_1.addItem(new SGraphyImgItem(null, t.img, t.X, t.Y, t.width, t.height)); }); } }; /** * 产生item实例 */ mainScene.prototype.constructeItem = function (PolygonItemInterfaceData) { return new SGraphyPolygonItem(PolygonItemInterfaceData); }; // 鼠标交互类事件 // 点击 mainScene.prototype.click = function (_this, fn) { this.root.children.forEach(function (item) { item.connect("click", _this, fn); }); }; // 双击 mainScene.prototype.dbclick = function (_this, fn) { this.root.children.forEach(function (item) { item.connect("doubleClick", _this, fn); }); }; // 按下 mainScene.prototype.mouseDown = function (_this, fn) { this.root.children.forEach(function (item) { item.connect("mouseDown", _this, fn); }); }; //移动 mainScene.prototype.mouseMove = function (_this, fn) { this.root.children.forEach(function (item) { item.connect("mouseMove", _this, fn); }); }; // 点解结束 mainScene.prototype.mouseUp = function (_this, fn) { this.root.children.forEach(function (item) { item.connect("mouseUp", _this, fn); }); }; return mainScene; }(SGraphyScene)); export default mainScene;