Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions anylabeling/views/labeling/widgets/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,21 +623,26 @@ def bounded_move_vertex(self, pos):
index, shape = self.h_vertex, self.h_hape
point = shape[index]
if self.out_off_pixmap(pos):
pos = self.intersection_point(point, pos)
shape.move_vertex_by(index, pos - point)
ip = self.intersection_point(point, pos)
# intersection_point returns QPoint, convert to QPointF for subtraction
pos = QtCore.QPointF(float(ip.x()), float(ip.y()))
offset = QtCore.QPointF(pos) - QtCore.QPointF(point)
shape.move_vertex_by(index, offset)

def bounded_move_shapes(self, shapes, pos):
"""Move shapes. Adjust position to be bounded by pixmap border"""
if self.out_off_pixmap(pos):
return False # No need to move
o1 = pos + self.offsets[0]
if self.out_off_pixmap(o1):
pos -= QtCore.QPoint(min(0, int(o1.x())), min(0, int(o1.y())))
pos -= QtCore.QPointF(
float(min(0, int(o1.x()))), float(min(0, int(o1.y())))
)
o2 = pos + self.offsets[1]
if self.out_off_pixmap(o2):
pos += QtCore.QPoint(
min(0, int(self.pixmap.width() - o2.x())),
min(0, int(self.pixmap.height() - o2.y())),
pos += QtCore.QPointF(
float(min(0, int(self.pixmap.width() - o2.x()))),
float(min(0, int(self.pixmap.height() - o2.y()))),
)
# XXX: The next line tracks the new position of the cursor
# relative to the shape, but also results in making it
Expand Down