GasPolyLine.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**
  2. *
  3. * @author seagle
  4. * @date 2024-7-22
  5. * @Description 管路图元件对象封装
  6. */
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. namespace MECF.Framework.UI.Core.DxfScript
  13. {
  14. public class GasPolyLine:GasBaseShape
  15. {
  16. public List<GasLine> InnerLines { get; set; } = null;
  17. public GasPolyLine()
  18. {
  19. InnerLines = new List<GasLine>();
  20. }
  21. public void AddLine(GasLine line)
  22. {
  23. InnerLines.Add(line);
  24. }
  25. //PolyLine的Id取所有线段最左上坐标需要外部调用此函数设置
  26. public int CreateId()
  27. {
  28. double xMin = 1999;
  29. double yMax = -1999;
  30. foreach(GasLine line in InnerLines)
  31. {
  32. double xx, yy;
  33. xx = Math.Min(line.X1, line.X2);
  34. yy = Math.Max(line.Y1, line.Y2);
  35. if (xx < xMin)
  36. {
  37. xMin = xx;
  38. }
  39. if (yy > yMax)
  40. {
  41. yMax = yy;
  42. }
  43. }
  44. Id = CreateId(ShapeType.POLY, xMin, yMax);
  45. return Id;
  46. }
  47. public override bool Contains(double x, double y)
  48. {
  49. double xMin = 1999;
  50. double xMax = -1999;
  51. double yMin = 1999;
  52. double yMax = -1999;
  53. foreach (GasLine line in InnerLines)
  54. {
  55. double xxMin,xxMax,yyMin,yyMax;
  56. xxMin = Math.Min(line.X1, line.X2);
  57. xxMax = Math.Max(line.X1, line.X2);
  58. yyMin = Math.Min(line.Y1, line.Y2);
  59. yyMax = Math.Max(line.Y1, line.Y2);
  60. if (xxMin < xMin)
  61. {
  62. xMin = xxMin;
  63. }
  64. if (xxMax > xMax)
  65. {
  66. xMax = xxMax;
  67. }
  68. if (yyMin< yMin)
  69. {
  70. yMin = yyMin;
  71. }
  72. if (yyMax > yMax)
  73. {
  74. yMax = yyMax;
  75. }
  76. }
  77. if(x>=xMin-E && x<=xMax+E && y>=yMin-E && y <= yMax + E)
  78. {
  79. return true;
  80. }
  81. else
  82. {
  83. return false;
  84. }
  85. }
  86. public override void Move(double x, double y)
  87. {
  88. foreach(GasLine line in InnerLines)
  89. {
  90. line.Move(x, y);
  91. }
  92. }
  93. }
  94. }