LocationPointScene.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. * ********************************************************************************************************************
  3. *
  4. * :*$@@%$*: ;: ;; ;;
  5. * :@@%! :!@@%: %! ;%%@@%$ =@@@@@@@%; @%@@@%%%%@@@@@
  6. * :@%; :$= %%$$$%$$ ;$$ ;$@= !@$
  7. * =@! %! @ $=;% !@@@%: !$$$$$$$$$$$$$$=
  8. * =@* %! @ $= % %@= =%@! %=
  9. * *$%%! @@= ;=$%%%$*: %! @ $= % =%%%%%%@$ *%: =%
  10. * %@@!: !@@@%=$@@@@%! :*@@$: %! @ $= % $* ;@ @* :%*
  11. * ;@@! ;!!!;: ;@%: =======@%========* @ $$ % $%*****$@ :@$=*********=@$
  12. * $@* ;@@@%=!: *@*
  13. * =@$ ;;;!=%@@@@=! =@!
  14. * %@$: =@%: :*@@@* %@= Copyright (c) 2016-2019. 北京上格云技术有限公司
  15. * ;%@@$=$@@%* *@@@$=%@@%;
  16. * ::;:: ::;:: All rights reserved.
  17. *
  18. * ********************************************************************************************************************
  19. */
  20. import { FloorScene } from "./FloorScene";
  21. import { MarkerItem } from "./items/MarkItem";
  22. import { Marker } from "./types/Marker";
  23. import { IconTextItem } from "./items/IconTextItem";
  24. /**
  25. * 位置标签绘制标志
  26. *
  27. * @author 郝建龙
  28. */
  29. export class LocationPointScene extends FloorScene {
  30. /** 标志list */
  31. markerList: MarkerItem[] = [];
  32. /** 标志是否可选 */
  33. _isMarkSelectable: boolean = true;
  34. get isMarkSelectable(): boolean {
  35. return this._isMarkSelectable;
  36. } // Get isMarkSelectable
  37. set isMarkSelectable(v: boolean) {
  38. if (this._isMarkSelectable === v) {
  39. return;
  40. }
  41. this._isMarkSelectable = v;
  42. this.markerList.map((t: MarkerItem) => {
  43. t.selectable = this._isMarkSelectable;
  44. return t;
  45. });
  46. } // Set isMarkSelectable
  47. /** 标志list */
  48. iconList: IconTextItem[] = [];
  49. /** 标志是否可选 */
  50. _isIconSelectable: boolean = true;
  51. get isIconSelectable(): boolean {
  52. return this._isIconSelectable;
  53. } // Get isMarkSelectable
  54. set isIconSelectable(v: boolean) {
  55. if (this._isIconSelectable === v) {
  56. return;
  57. }
  58. this._isIconSelectable = v;
  59. this.iconList.map((t: IconTextItem) => {
  60. t.selectable = this._isIconSelectable;
  61. return t;
  62. });
  63. } // Set isMarkSelectable
  64. /**
  65. * 构造函数
  66. */
  67. constructor() {
  68. super();
  69. } // Constructor
  70. /**
  71. * 添加标志list至scene中
  72. *
  73. * @param markerList 标志对象list
  74. */
  75. addMarkerList(markerList: Marker[]): void {
  76. markerList.map(t => {
  77. this.addMarker(t);
  78. });
  79. } // Function addMarkerList()
  80. /**
  81. * 添加标志到scene中
  82. *
  83. * @param marker 标志对象
  84. */
  85. addMarker(marker: Marker): void {
  86. let mark = new MarkerItem(null, marker);
  87. mark.moveTo(marker.X, marker.Y);
  88. mark.selectable = this.isMarkSelectable;
  89. this.markerList.push(mark);
  90. this.addItem(mark);
  91. } // Function addMarker()
  92. /**
  93. * 添加设备带文字item
  94. *
  95. * @param iconTextList item列表
  96. */
  97. addIconTextList(iconTextList: IconTextItem[]): void {
  98. iconTextList.map(t => {
  99. this.addIconText(t);
  100. });
  101. }
  102. /**
  103. * 添加单个设备
  104. *
  105. * @param iconText item 数据
  106. */
  107. addIconText(iconText: any): void {
  108. const icon = new IconTextItem(null, iconText);
  109. if (iconText.X && iconText.Y) {
  110. icon.moveTo(iconText.X, iconText.Y);
  111. }
  112. this.iconList.push(icon);
  113. this.addItem(icon);
  114. }
  115. /**
  116. * 标志的点击事件
  117. *
  118. * @param _this 接收者
  119. * @param fn 处理函数
  120. */
  121. markerClick(_this: any, fn: Function): void {
  122. this.markerList.map(m => {
  123. m.connect("click", _this, fn);
  124. });
  125. } // Function markerClick()
  126. /**
  127. * 空间的点击事件
  128. *
  129. * @param _this 接收者
  130. * @param fn 处理函数
  131. */
  132. spaceClick(_this: any, fn: Function): void {
  133. this.spaceList.map(m => {
  134. m.connect("click", _this, fn);
  135. });
  136. this.imgList.map(m => {
  137. m.connect("click", _this, fn);
  138. });
  139. } // Function spaceClick()
  140. /**
  141. * 清空所有设备 icon
  142. */
  143. clearIcon(): void {
  144. this.iconList.forEach(t => {
  145. this.removeItem(t);
  146. });
  147. this.iconList = [];
  148. }
  149. /**
  150. * 设备 icon 绑定点击事件和文本修改事件
  151. */
  152. iconChangeText(_this: any, fn: Function): void {
  153. this.iconList.forEach(t => {
  154. t.connect("changeText", _this, fn);
  155. });
  156. }
  157. /**
  158. * 设备 icon 绑定移动事件
  159. */
  160. iconMove(_this: any, fn: Function): void {
  161. this.iconList.forEach(t => {
  162. t.connect("onMove", _this, fn);
  163. });
  164. }
  165. } // Class LocationPointScene