Skip to content

Commit ecf565e

Browse files
author
Eric Price
committed
fixes for latest Qt version
1 parent 58fdffb commit ecf565e

File tree

3 files changed

+17
-17
lines changed

3 files changed

+17
-17
lines changed

labelme/shape.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ def transform(self, T):
250250
tpoints=[]
251251
for p in self.points:
252252
tp = np.dot(T , [p.x(),p.y(), 1])
253-
qp = QtCore.QPoint(tp[0],tp[1])
253+
qp = QtCore.QPointF(tp[0],tp[1])
254254
tpoints.append(qp)
255255

256256
self.points = tpoints
@@ -302,4 +302,4 @@ def __getitem__(self, key):
302302
return self.points[key]
303303

304304
def __setitem__(self, key, value):
305-
self.points[key] = value
305+
self.points[key] = value

labelme/widgets/canvas.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ def calculateOffsets(self, shape, point):
518518
y1 = rect.y() - point.y()
519519
x2 = (rect.x() + rect.width() - 1) - point.x()
520520
y2 = (rect.y() + rect.height() - 1) - point.y()
521-
self.offsets = QtCore.QPoint(x1, y1), QtCore.QPoint(x2, y2)
521+
self.offsets = QtCore.QPointF(x1, y1), QtCore.QPointF(x2, y2)
522522

523523
def boundedMoveVertex(self, pos):
524524
index, shape = self.hVertex, self.hShape
@@ -532,10 +532,10 @@ def boundedMoveShapes(self, shapes, pos):
532532
return False # No need to move
533533
o1 = pos + self.offsets[0]
534534
if self.outOfPixmap(o1):
535-
pos -= QtCore.QPoint(min(0, o1.x()), min(0, o1.y()))
535+
pos -= QtCore.QPointF(min(0, o1.x()), min(0, o1.y()))
536536
o2 = pos + self.offsets[1]
537537
if self.outOfPixmap(o2):
538-
pos += QtCore.QPoint(min(0, self.pixmap.width() - o2.x()),
538+
pos += QtCore.QPointF(min(0, self.pixmap.width() - o2.x()),
539539
min(0, self.pixmap.height() - o2.y()))
540540
# XXX: The next line tracks the new position of the cursor
541541
# relative to the shape, but also results in making it
@@ -610,7 +610,7 @@ def boundedShiftShapes(self, shapes):
610610
# Try to move in one direction, and if it fails in another.
611611
# Give up if both fail.
612612
point = shapes[0][0]
613-
offset = QtCore.QPoint(2.0, 2.0)
613+
offset = QtCore.QPointF(2.0, 2.0)
614614
self.offsets = QtCore.QPoint(), QtCore.QPoint()
615615
self.prevPoint = point
616616
if not self.boundedMoveShapes(shapes, point - offset):
@@ -688,7 +688,7 @@ def offsetToCenter(self):
688688
aw, ah = area.width(), area.height()
689689
x = (aw - w) / (2 * s) if aw > w else 0
690690
y = (ah - h) / (2 * s) if ah > h else 0
691-
return QtCore.QPoint(x, y)
691+
return QtCore.QPointF(x, y)
692692

693693
def outOfPixmap(self, p):
694694
w, h = self.pixmap.width(), self.pixmap.height()
@@ -732,10 +732,10 @@ def intersectionPoint(self, p1, p2):
732732
if (x, y) == (x1, y1):
733733
# Handle cases where previous point is on one of the edges.
734734
if x3 == x4:
735-
return QtCore.QPoint(x3, min(max(0, y2), max(y3, y4)))
735+
return QtCore.QPointF(x3, min(max(0, y2), max(y3, y4)))
736736
else: # y3 == y4
737-
return QtCore.QPoint(min(max(0, x2), max(x3, x4)), y3)
738-
return QtCore.QPoint(x, y)
737+
return QtCore.QPointF(min(max(0, x2), max(x3, x4)), y3)
738+
return QtCore.QPointF(x, y)
739739

740740
def intersectingEdges(self, point1, point2, points):
741741
"""Find intersecting edges.
@@ -762,8 +762,8 @@ def intersectingEdges(self, point1, point2, points):
762762
if 0 <= ua <= 1 and 0 <= ub <= 1:
763763
x = x1 + ua * (x2 - x1)
764764
y = y1 + ua * (y2 - y1)
765-
m = QtCore.QPoint((x3 + x4) / 2, (y3 + y4) / 2)
766-
d = labelme.utils.distance(m - QtCore.QPoint(x2, y2))
765+
m = QtCore.QPointF((x3 + x4) / 2, (y3 + y4) / 2)
766+
d = labelme.utils.distance(m - QtCore.QPointF(x2, y2))
767767
yield d, i, (x, y)
768768

769769
# These two, along with a call to adjustSize are required for the

labelme/widgets/label_list_widget.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ def paint(self, painter, option, index):
4848
if index.column() != 0:
4949
textRect.adjust(5, 0, 0, 0)
5050

51-
thefuckyourshitup_constant = 4
51+
weird_constant = 4
5252
margin = (option.rect.height() - options.fontMetrics.height()) // 2
53-
margin = margin - thefuckyourshitup_constant
53+
margin = margin - weird_constant
5454
textRect.setTop(textRect.top() + margin)
5555

5656
painter.translate(textRect.topLeft())
@@ -60,10 +60,10 @@ def paint(self, painter, option, index):
6060
painter.restore()
6161

6262
def sizeHint(self, option, index):
63-
thefuckyourshitup_constant = 4
63+
weird_constant = 4
6464
return QtCore.QSize(
65-
self.doc.idealWidth(),
66-
self.doc.size().height() - thefuckyourshitup_constant,
65+
int(self.doc.idealWidth()),
66+
int(self.doc.size().height() - weird_constant),
6767
)
6868

6969

0 commit comments

Comments
 (0)