123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- import math
- import time
- import ezdxf
- import numpy as np
- from core import rotate_point_around_another, calculate_route, calculate_angle_with_x_axis
- class WindFlowDrawer:
- def __init__(self, msp,layer, gap, center, route, type):
- self.layer = layer
- self.msp = msp
- self.gap = gap
- self.center = center
- self.route = route
- self.type = type
- def draw_wind_flow(self):
- line_length = 2.55 * self.gap
- point_end = self.center[0] - line_length / 2, self.center[1]
- point_arrow = self.center[0] + line_length / 2, self.center[1]
- point_text = self.center[0] - 0.5 * line_length, self.center[1] + 0.1 * line_length
- arrow = ezdxf.ARROWS.ez_arrow_filled
- color = str(self.type)
- point_end = rotate_point_around_another(point_end, self.center, self.route)
- point_arrow = rotate_point_around_another(point_arrow, self.center, self.route)
- point_text = rotate_point_around_another(point_text, self.center, self.route)
- angle = math.degrees(self.route)
- # 用风类型 0:未指定 1:进风 2: 用风 3:回风
- # 0、1 是绿色箭头, 2、3是红色箭头
- if self.type == '2' or self.type == '3':
- dxfattribs = {
- 'insert': point_text, 'style': 'LiberationSerif', 'color': '1', "layer":f"图层{self.layer}"}
- self.msp.add_text(text="S", rotation=angle - 90, dxfattribs=dxfattribs)
- self.msp.add_line(point_end, point_arrow, {
- "color": self.get_color(),
- "layer":f"图层{self.layer}"
- })
- self.msp.add_arrow(arrow, point_arrow, 2, angle, {
- "color": self.get_color(),
- "layer": f"图层{self.layer}"
- })
- def get_color(self):
- if self.type == '2' or self.type == '3':
- return '1'
- else:
- return '3'
|