mainScene.js 5.3 KB

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