Skip to content

Commit

Permalink
Optimize crosshair
Browse files Browse the repository at this point in the history
  • Loading branch information
PairZhu authored and wkentaro committed Aug 2, 2024
1 parent 6764611 commit 5bd4d67
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
5 changes: 0 additions & 5 deletions labelme/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,6 @@ def paint(self, painter):
if self.mask is None and not self.points:
return

painter.save()
painter.scale(1 / self.scale, 1 / self.scale)

color = self.select_line_color if self.selected else self.line_color
pen = QtGui.QPen(color)
# Try using integer sizes for smoother drawing(?)
Expand Down Expand Up @@ -284,8 +281,6 @@ def paint(self, painter):
painter.drawPath(negative_vrtx_path)
painter.fillPath(negative_vrtx_path, QtGui.QColor(255, 0, 0, 255))

painter.restore()

def drawVertex(self, path, i):
d = self.point_size
shape = self.point_type
Expand Down
10 changes: 6 additions & 4 deletions labelme/widgets/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,8 @@ def paintEvent(self, event):

p.drawPixmap(0, 0, self.pixmap)

p.scale(1 / self.scale, 1 / self.scale)

# draw crosshair
if (
self._crosshair[self._createMode]
Expand All @@ -707,14 +709,14 @@ def paintEvent(self, event):
p.setPen(QtGui.QColor(0, 0, 0))
p.drawLine(
0,
int(self.prevMovePoint.y()),
int(self.prevMovePoint.y() * self.scale),
self.width() - 1,
int(self.prevMovePoint.y()),
int(self.prevMovePoint.y() * self.scale),
)
p.drawLine(
int(self.prevMovePoint.x()),
int(self.prevMovePoint.x() * self.scale),
0,
int(self.prevMovePoint.x()),
int(self.prevMovePoint.x() * self.scale),
self.height() - 1,
)

Expand Down

0 comments on commit 5bd4d67

Please sign in to comment.