SBoardItem.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /*
  2. * *********************************************************************************************************************
  3. *
  4. * !!
  5. * .F88X
  6. * X8888Y
  7. * .}888888N;
  8. * i888888N; .:! .I$WI:
  9. * R888888I .'N88~ i8}+8Y&8"l8i$8>8W~'>W8}8]KW+8IIN"8&
  10. * .R888888I .;N8888~ .X8' "8I.!,/8" !%NY8`"8I8~~8>,88I
  11. * +888888N; .8888888Y "&&8Y.}8,
  12. * ./888888N; .R888888Y .'}~ .>}'.`+> i}! "i' +/' .'i~ !11,.:">, .~]! .i}i
  13. * ~888888%: .I888888l .]88~`1/iY88Ii+1'.R$8$8]"888888888> Y8$ W8E X8E W8888'188Il}Y88$*
  14. * 18888888 E8888881 .]W%8$`R8X'&8%++N8i,8N%N8+l8%` .}8N:.R$RE%N88N%N$K$R 188,FE$8%~Y88I
  15. * .E888888I .i8888888' .:$8I;88+`E8R:/8N,.>881.`$8E/1/]N8X.Y8N`"KF&&FK!'88*."88K./$88%RN888+~
  16. * 8888888I .,N888888~ ~88i"8W,!N8*.I88.}888%F,i$88"F88" 888:E8X.>88!i88>`888*.}Fl1]*}1YKi'
  17. * i888888N' I888Y ]88;/EX*IFKFK88X K8R .l8W 88Y ~88}'88E&%8W.X8N``]88!.$8K .:W8I
  18. * .i888888N; I8Y .&8$ .X88! i881.:%888>I88 ;88] +88+.';;;;:.Y88X 18N.,88l .+88/
  19. * .:R888888I
  20. * .&888888I Copyright (c) 2016-2020. 博锐尚格科技股份有限公司
  21. * ~8888'
  22. * .!88~ All rights reserved.
  23. *
  24. * *********************************************************************************************************************
  25. */
  26. import { SPainter, SPath2D, SPoint, SColor } from "@persagy-web/draw/lib";
  27. import { Zone } from "../../types/floor/Zone";
  28. import { ItemColor, ItemOrder } from "../..";
  29. import { SGraphItem } from "@persagy-web/graph/lib";
  30. /**
  31. * 建築輪廓item
  32. *
  33. * @author 郝建龙
  34. */
  35. export class SBoardItem extends SGraphItem {
  36. /** 空间所有数据 */
  37. data: Zone;
  38. /** 空间轮廓线坐标list */
  39. readonly pointArr: SPoint[][][] = [];
  40. /** path */
  41. private pathList: SPath2D[] = [];
  42. /**
  43. * 构造函数
  44. *
  45. * @param parent 指向父对象
  46. * @param data 建築輪廓数据
  47. */
  48. constructor(parent: SGraphItem | null, data: Zone) {
  49. super(parent);
  50. this.data = data;
  51. this.zOrder = 0;
  52. if (
  53. this.data.OutLine.length &&
  54. this.data.OutLine[0] &&
  55. this.data.OutLine[0].length
  56. ) {
  57. let tempArr = this.data.OutLine;
  58. this.pointArr = tempArr.map((t): SPoint[][] => {
  59. let sPath = new SPath2D();
  60. let tempArr = t.map((it): SPoint[] => {
  61. let array = it.map(
  62. (item): SPoint => {
  63. let x = item.X,
  64. y = -item.Y;
  65. return new SPoint(x, y);
  66. }
  67. );
  68. sPath.polygon(array);
  69. return array;
  70. });
  71. this.pathList.push(sPath);
  72. return tempArr;
  73. });
  74. }
  75. } // Constructor
  76. /**
  77. * 判断点是否在区域内
  78. *
  79. * @param x
  80. * @param y
  81. */
  82. contains(x: number, y: number): boolean {
  83. return false;
  84. } // Function contains()
  85. /**
  86. * Item绘制操作
  87. *
  88. * @param painter painter对象
  89. */
  90. onDraw(painter: SPainter): void {
  91. painter.pen.lineWidth = painter.toPx(1);
  92. painter.brush.color = ItemColor.spaceColor;
  93. painter.pen.color = ItemColor.spaceBorderColor;
  94. this.pathList.forEach((t): void => {
  95. painter.drawPath(t);
  96. });
  97. } // Function onDraw()
  98. } // Class SBoardItem