mainScene.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. var __extends = (this && this.__extends) || (function () {
  2. var extendStatics = function (d, b) {
  3. extendStatics = Object.setPrototypeOf ||
  4. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6. return extendStatics(d, b);
  7. };
  8. return function (d, b) {
  9. extendStatics(d, b);
  10. function __() { this.constructor = d; }
  11. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  12. };
  13. })();
  14. import { SPoint } from "@sybotan-web/base";
  15. import { SGraphyPolygonItem } from './newItems/SGraphyPolygonItem.js';
  16. import { SGraphyWallItem } from './newItems/SGraphyWallItem.js';
  17. import { SGraphyImgItem } from './newItems/SGraphyImgItem.js';
  18. import { SGraphyScene } from "@sybotan-web/graphy";
  19. /**
  20. * @name mainScene
  21. * @time 2019-07.07;
  22. * 添加所有item的场景到scene中
  23. */
  24. var mainScene = /** @class */ (function (_super) {
  25. __extends(mainScene, _super);
  26. /**
  27. * @param data 绘制空间地图得所有参数
  28. */
  29. function mainScene(data) {
  30. var _this_1 = _super.call(this) || this;
  31. _this_1._isShowSpace = true; // 是否显示空间;
  32. _this_1._isShowWallList = true; //是否展示墙体;
  33. _this_1._isShowEquipmentList = true; //是否展示设备;
  34. _this_1._isShowVrtualWallList = true; //是否展示虚拟墙
  35. _this_1.data = data;
  36. _this_1.addAllItemList(data);
  37. return _this_1;
  38. }
  39. Object.defineProperty(mainScene.prototype, "isShowSpace", {
  40. // 设置是否显示空间
  41. get: function () {
  42. return this._isShowSpace;
  43. },
  44. set: function (b) {
  45. this._isShowSpace = b;
  46. },
  47. enumerable: true,
  48. configurable: true
  49. });
  50. Object.defineProperty(mainScene.prototype, "isShowWallList", {
  51. // 设置是否显示墙
  52. get: function () {
  53. return this._isShowWallList;
  54. },
  55. set: function (b) {
  56. this._isShowWallList = b;
  57. },
  58. enumerable: true,
  59. configurable: true
  60. });
  61. Object.defineProperty(mainScene.prototype, "isShowEquipmentList", {
  62. // 设置是否显示设备
  63. get: function () {
  64. return this._isShowEquipmentList;
  65. },
  66. set: function (b) {
  67. this._isShowEquipmentList = b;
  68. },
  69. enumerable: true,
  70. configurable: true
  71. });
  72. Object.defineProperty(mainScene.prototype, "isShowVrtualWallList", {
  73. // 设置是否显示虚拟墙
  74. get: function () {
  75. return this._isShowVrtualWallList;
  76. },
  77. set: function (b) {
  78. this._isShowVrtualWallList = b;
  79. },
  80. enumerable: true,
  81. configurable: true
  82. });
  83. // 以下是绘制方法
  84. /**
  85. * 增添所有绘制item(地图);
  86. */
  87. mainScene.prototype.addAllItemList = function (data) {
  88. console.log(data);
  89. var space = data.SpaceList;
  90. this.addSpaceList(space); //绘制空间
  91. var wall = data.WallList;
  92. this.addWallList(wall);
  93. var images = data.images;
  94. this.addImgList(images);
  95. };
  96. /**
  97. * 添加所有空间到scene 中
  98. * @param space 空间list
  99. */
  100. mainScene.prototype.addSpaceList = function (space) {
  101. if (space && space.length) {
  102. for (var i = 0; i < space.length; i++) {
  103. if (space[i].Paths[1] && space[i].Paths[1].length >= 2) {
  104. space[i].isBusiness = 2;
  105. this.addItem(this.constructeItem({
  106. parent: null,
  107. space: space[i]
  108. }));
  109. }
  110. if (space[i].Paths[0] && space[i].Paths[0].length >= 2 && !space[i].Paths[1]) {
  111. space[i].isBusiness = 2;
  112. this.addItem(this.constructeItem({
  113. parent: null,
  114. space: space[i]
  115. }));
  116. }
  117. }
  118. }
  119. };
  120. // 绘制墙体
  121. mainScene.prototype.addWallList = function (wall) {
  122. var _this_1 = this;
  123. if (wall && wall.length) {
  124. wall.map(function (t) {
  125. var newArr = t.PointList.map(function (pa) {
  126. return new SPoint(pa.X, pa.Y);
  127. });
  128. _this_1.addItem(new SGraphyWallItem(null, newArr));
  129. });
  130. }
  131. };
  132. // 绘制设备
  133. mainScene.prototype.addEquipmentList = function () {
  134. };
  135. // 绘制柱体
  136. mainScene.prototype.addColumnListList = function () {
  137. };
  138. // 绘制虚拟墙
  139. mainScene.prototype.addVrtualWallList = function () {
  140. };
  141. // 绘制图片 -- todo
  142. mainScene.prototype.addImgList = function (images) {
  143. var _this_1 = this;
  144. if (images && images.length) {
  145. images.map(function (t) {
  146. _this_1.addItem(new SGraphyImgItem(null, t.img, t.X, t.Y, t.width, t.height));
  147. });
  148. }
  149. };
  150. /**
  151. * 产生item实例
  152. */
  153. mainScene.prototype.constructeItem = function (PolygonItemInterfaceData) {
  154. return new SGraphyPolygonItem(PolygonItemInterfaceData);
  155. };
  156. // 鼠标交互类事件
  157. // 点击
  158. mainScene.prototype.click = function (_this, fn) {
  159. this.root.children.forEach(function (item) {
  160. item.connect("click", _this, fn);
  161. });
  162. };
  163. // 双击
  164. mainScene.prototype.dbclick = function (_this, fn) {
  165. this.root.children.forEach(function (item) {
  166. item.connect("doubleClick", _this, fn);
  167. });
  168. };
  169. // 按下
  170. mainScene.prototype.mouseDown = function (_this, fn) {
  171. this.root.children.forEach(function (item) {
  172. item.connect("mouseDown", _this, fn);
  173. });
  174. };
  175. //移动
  176. mainScene.prototype.mouseMove = function (_this, fn) {
  177. this.root.children.forEach(function (item) {
  178. item.connect("mouseMove", _this, fn);
  179. });
  180. };
  181. // 点解结束
  182. mainScene.prototype.mouseUp = function (_this, fn) {
  183. this.root.children.forEach(function (item) {
  184. item.connect("mouseUp", _this, fn);
  185. });
  186. };
  187. return mainScene;
  188. }(SGraphyScene));
  189. export default mainScene;