SWallItem.js 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.SWallItem = void 0;
  4. const lib_1 = require("@persagy-web/draw/lib");
  5. const __1 = require("../..");
  6. const __2 = require("../..");
  7. const lib_2 = require("@persagy-web/graph/lib");
  8. class SWallItem extends lib_2.SGraphItem {
  9. constructor(parent, data) {
  10. super(parent);
  11. this.minX = Number.MAX_SAFE_INTEGER;
  12. this.maxX = Number.MIN_SAFE_INTEGER;
  13. this.minY = Number.MAX_SAFE_INTEGER;
  14. this.maxY = Number.MIN_SAFE_INTEGER;
  15. this.pointArr = [];
  16. this.holesArr = [];
  17. this.path = new lib_1.SPath2D();
  18. this.data = data;
  19. this.zOrder = __1.ItemOrder.wallOrder;
  20. let tempArr = this.data.OutLine;
  21. let holes = data.Holes;
  22. if (tempArr && tempArr.length) {
  23. this.minX = tempArr[0][0].X;
  24. this.maxX = this.minX;
  25. this.minY = -tempArr[0][0].Y;
  26. this.maxY = this.minY;
  27. this.pointArr = [];
  28. let WLine = tempArr[0].map((it) => {
  29. let x = it.X, y = -it.Y;
  30. if (x < this.minX) {
  31. this.minX = x;
  32. }
  33. if (y < this.minY) {
  34. this.minY = y;
  35. }
  36. if (x > this.maxX) {
  37. this.maxX = x;
  38. }
  39. if (y > this.maxY) {
  40. this.maxY = y;
  41. }
  42. return new lib_1.SPoint(x, y);
  43. });
  44. this.path.polygon(WLine);
  45. this.pointArr.push(WLine);
  46. if (holes && holes.length) {
  47. this.holesArr = holes.map(t => {
  48. let temp = t.map((it) => {
  49. let x = it.X, y = -it.Y;
  50. if (x < this.minX) {
  51. this.minX = x;
  52. }
  53. if (y < this.minY) {
  54. this.minY = y;
  55. }
  56. if (x > this.maxX) {
  57. this.maxX = x;
  58. }
  59. if (y > this.maxY) {
  60. this.maxY = y;
  61. }
  62. return new lib_1.SPoint(x, y);
  63. });
  64. this.path.polygon(temp);
  65. return temp;
  66. });
  67. }
  68. }
  69. }
  70. boundingRect() {
  71. return new lib_1.SRect(this.minX, this.minY, this.maxX - this.minX, this.maxY - this.minY);
  72. }
  73. onDraw(painter) {
  74. painter.pen.color = __2.ItemColor.wallColor;
  75. painter.pen.lineWidth = painter.toPx(1);
  76. painter.brush.color = __2.ItemColor.wallColor;
  77. painter.drawPath(this.path);
  78. }
  79. }
  80. exports.SWallItem = SWallItem;