WindFlowDrawer.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import math
  2. import time
  3. import ezdxf
  4. import numpy as np
  5. from core import rotate_point_around_another, calculate_route, calculate_angle_with_x_axis
  6. class WindFlowDrawer:
  7. def __init__(self, msp, gap, center, route, type):
  8. self.msp = msp
  9. self.gap = gap
  10. self.center = center
  11. self.route = route
  12. self.type = type
  13. def draw_wind_flow(self):
  14. line_length = 2.55 * self.gap
  15. point_end = self.center[0] - line_length / 2, self.center[1]
  16. point_arrow = self.center[0] + line_length / 2, self.center[1]
  17. point_text = self.center[0] - 0.1 * line_length, self.center[1] + 0.0725 * line_length
  18. arrow = ezdxf.ARROWS.ez_arrow_filled
  19. color = str(self.type)
  20. point_end = rotate_point_around_another(point_end, self.center, self.route)
  21. point_arrow = rotate_point_around_another(point_arrow, self.center, self.route)
  22. point_text = rotate_point_around_another(point_text, self.center, self.route)
  23. angle = math.degrees(self.route)
  24. if self.type == 1:
  25. dxfattribs = {
  26. 'insert': point_text, 'style': 'LiberationSerif', 'color': color}
  27. self.msp.add_text(text="S", rotation=angle - 90, dxfattribs=dxfattribs)
  28. self.msp.add_line(point_end, point_arrow, {
  29. "color": color,
  30. })
  31. self.msp.add_arrow(arrow, point_arrow, 2, angle, {
  32. "color": color,
  33. })