MeshTemplateDrawer.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import core
  2. class MeshTemplateDrawer:
  3. def __init__(self, msp, grid, left_top, right_bottom, color):
  4. self.msp = msp
  5. self.grid = grid
  6. self.left_top = left_top
  7. self.right_bottom = right_bottom
  8. self.margin_left = 2876
  9. self.margin_bottom = 1847
  10. self.color = color
  11. def draw_mesh(self):
  12. left_edge = self.left_top[0]
  13. right_edge = self.right_bottom[0]
  14. top_edge = self.left_top[1]
  15. bottom_edge = self.right_bottom[1]
  16. left_index = left_edge - self.margin_left
  17. bottom_index = bottom_edge - self.margin_bottom
  18. top_list = []
  19. bottom_list = []
  20. left_list = []
  21. right_list = []
  22. while left_index < right_edge:
  23. # top_list.append(core.rotate_point_around_another((left_index,self.left_top[1]),(0,0),self.route))
  24. top_list.append((left_index, self.left_top[1]+self.margin_bottom))
  25. # bottom_list.append(core.rotate_point_around_another((left_index,self.right_bottom[1]),(0,0),self.route))
  26. bottom_list.append((left_index, self.right_bottom[1]-self.margin_bottom))
  27. left_index = left_index + self.grid
  28. while bottom_index < top_edge:
  29. # left_list.append(core.rotate_point_around_another((self.left_top[0], bottom_index), (0, 0), self.route))
  30. left_list.append((self.left_top[0], bottom_index))
  31. right_list.append((self.right_bottom[0], bottom_index))
  32. # right_list.append(
  33. # (core.rotate_point_around_another((self.right_bottom[0], bottom_index), (0, 0), self.route)))
  34. bottom_index = bottom_index + self.grid
  35. for top_element, bottom_element in zip(top_list, bottom_list):
  36. self.msp.add_line(top_element, bottom_element)
  37. for left_element, right_element in zip(left_list, right_list):
  38. self.msp.add_line(left_element, right_element)
  39. # def draw_graph_unit():