| 44 | self.update() |
| 45 | |
| 46 | def mouseMoveEvent(self, ev): |
| 47 | if self.drawEnable: |
| 48 | def in_end_range(curr, first): |
| 49 | return first.x() - 5 <= curr.x() <= first.x() + 5 and first.y() - 5 <= curr.y() <= first.y() + 5 |
| 50 | |
| 51 | if len(self.current_points) > 0 and in_end_range(ev.pos(), self.current_points[0]): |
| 52 | self.current_points.append(self.current_points[0]) |
| 53 | self.points.append(self.current_points) |
| 54 | self.current_points = [] |
| 55 | else: |
| 56 | self.current_points.append(ev.pos()) |
| 57 | elif len(self.current_points) > 0: |
| 58 | self.current_points.append(ev.pos()) |
| 59 | self.points.append(self.current_points) |
| 60 | self.current_points = [] |
| 61 | |
| 62 | self.update() |
| 63 | |
| 64 | def mousePressEvent(self, ev): |
| 65 | if Qt.LeftButton & ev.button(): |