1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- from core import rotate_point_around_another
- from ezdxf import math as mt
- class GateDrawer:
- def __init__(self, msp, gap,center,route):
- self.msp = msp
- self.gap = gap
- self.center = center
- self.route = route
- def draw_gate(self):
- grid = 1.125 * self.gap
- rad = self.gap / 0.75
- point_center = self.center
- route = self.route
- # 计算第一个门的三个点
- gate1_circle_a = (point_center[0] - grid, point_center[1] + rad)
- gate1_circle_b = (point_center[0] - grid, point_center[1] - rad)
- gate1_circle_c = (point_center[0] - grid + rad, point_center[1])
- # 旋转这些点
- gate1_a = rotate_point_around_another(gate1_circle_a, point_center, route)
- gate1_b = rotate_point_around_another(gate1_circle_b, point_center, route)
- gate1_c = rotate_point_around_another(gate1_circle_c, point_center, route)
- # 创建和添加第一个门的弧和线
- self.add_gate_part(gate1_a, gate1_b, gate1_c)
- # 计算第二个门的三个点
- gate2_circle_a = (point_center[0] + grid, point_center[1] + rad)
- gate2_circle_b = (point_center[0] + grid, point_center[1] - rad)
- gate2_circle_c = (point_center[0] + grid - rad, point_center[1])
- # 旋转这些点
- gate2_a = rotate_point_around_another(gate2_circle_a, point_center, route)
- gate2_b = rotate_point_around_another(gate2_circle_b, point_center, route)
- gate2_c = rotate_point_around_another(gate2_circle_c, point_center, route)
- # 创建和添加第二个门的弧和线
- self.add_gate_part(gate2_a, gate2_b, gate2_c)
- def add_gate_part(self, start_point, end_point, def_point):
- carc = mt.arc.ConstructionArc() # 假设这是一个可用的类
- b = carc.from_3p(start_point=start_point, def_point=def_point, end_point=end_point)
- self.msp.add_arc(center=b.center, radius=b.radius, start_angle=b.start_angle, end_angle=b.end_angle)
- self.msp.add_line(start_point, end_point)
|