Polyline.cs 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. using FastReport.Export.Dxf.Utils;
  2. using System.Drawing;
  3. namespace FastReport.Export.Dxf.Sections.Entities
  4. {
  5. public class PolyLine : EntityBase
  6. {
  7. #region Private Fields
  8. private bool isClosedPolyline;
  9. private PointF[] points;
  10. private byte[] pointTypes;
  11. private Color polyLineColor;
  12. private LineStyle polyLineStyle;
  13. private float polyLineWidth;
  14. private float x;
  15. private float y;
  16. #endregion Private Fields
  17. #region Public Constructors
  18. public PolyLine(float x, float y, PointF[] points, byte[] pointTypes, Color polyLineColor, float polyLineWidth,
  19. LineStyle polyLineStyle, bool isClosedPolyline) : base()
  20. {
  21. this.points = points;
  22. this.pointTypes = pointTypes;
  23. this.polyLineColor = polyLineColor;
  24. this.polyLineWidth = polyLineWidth;
  25. this.polyLineStyle = polyLineStyle;
  26. this.x = x;
  27. this.y = y;
  28. this.isClosedPolyline = isClosedPolyline;
  29. InitGroups();
  30. }
  31. #endregion Public Constructors
  32. #region Private Methods
  33. private void AddVertex(PointF point)
  34. {
  35. AddTypeName("VERTEX");
  36. AddPrimary2DPoint(x + point.X, y + point.Y);
  37. AddGroup(70, 0);
  38. }
  39. private void InitGroups()
  40. {
  41. // 0
  42. // POLYLINE
  43. // 6
  44. // DashDot
  45. // 66
  46. // 1
  47. // 10
  48. // 0
  49. // 20
  50. // 0
  51. // 30
  52. // 0
  53. // 70
  54. // 8
  55. // 40
  56. // 0
  57. // 41
  58. // 0
  59. // 0
  60. // VERTEX
  61. // 5
  62. // 402
  63. // 8
  64. // 0
  65. // 10
  66. // 3.43302574065077
  67. // 20
  68. // 4.42831471588149
  69. // 30
  70. // 8.45677694538694E-18
  71. // 70
  72. // 0
  73. // 0
  74. // VERTEX
  75. // 5
  76. // 403
  77. // 8
  78. // 0
  79. // 10
  80. // 10.2413793103448
  81. // 20
  82. // - 0.677950461389022
  83. // 30
  84. // 8.45677694538694E-18
  85. // 70
  86. // 0
  87. AddTypeName("POLYLINE");
  88. AddGroup(8, "Layer_1");
  89. if (polyLineStyle != LineStyle.Solid)
  90. AddLineStyle(polyLineStyle);
  91. // "Entities follow" flag (fixed)
  92. AddGroup(66, 1);
  93. // DXF: always 0
  94. // APP: a "dummy" point; the X and Y values are always 0, and the Z
  95. // value is the polyline's elevation (in OCS when 2D, WCS when 3D)
  96. AddGroup(10, 0);
  97. // DXF: always 0
  98. AddGroup(20, 0);
  99. // DXF: polyline's elevation (in OCS when 2D, WCS when 3D)
  100. AddGroup(30, 0);
  101. // Polyline flag (bit-coded); default is 0
  102. // 8 = This is a 3D polyline. 1 - closed (polygon)
  103. if (isClosedPolyline)
  104. AddGroup(70, 1);
  105. else
  106. AddGroup(70, 8);
  107. // Default start width (optional; default = 0)
  108. AddGroup(40, 0);
  109. // Default end width (optional; default = 0)
  110. AddGroup(41, 0);
  111. byte aciColor = ACIDictionary.GetAciColor(polyLineColor);
  112. AddColor(aciColor);
  113. AddEntityThickness(polyLineWidth);
  114. // add VERTEX-es
  115. for (int i = 0; i < points.Length; i++)
  116. {
  117. PointF point = points[i];
  118. AddVertex(point);
  119. }
  120. AddTypeName("SEQEND");
  121. }
  122. #endregion Private Methods
  123. }
  124. }