display bbox width and height while resizing, moving and hovering over (#798)

shape.
This commit is contained in:
Tiger Nie 2021-10-11 15:04:40 -05:00 committed by GitHub
parent 7457d58249
commit 3f53dce960
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -178,11 +178,27 @@ class Canvas(QWidget):
self.bounded_move_vertex(pos)
self.shapeMoved.emit()
self.repaint()
# Display annotation width and height while moving vertex
point1 = self.h_shape[1]
point3 = self.h_shape[3]
current_width = abs(point1.x() - point3.x())
current_height = abs(point1.y() - point3.y())
self.parent().window().label_coordinates.setText(
'Width: %d, Height: %d / X: %d; Y: %d' % (current_width, current_height, pos.x(), pos.y()))
elif self.selected_shape and self.prev_point:
self.override_cursor(CURSOR_MOVE)
self.bounded_move_shape(self.selected_shape, pos)
self.shapeMoved.emit()
self.repaint()
# Display annotation width and height while moving shape
point1 = self.selected_shape[1]
point3 = self.selected_shape[3]
current_width = abs(point1.x() - point3.x())
current_height = abs(point1.y() - point3.y())
self.parent().window().label_coordinates.setText(
'Width: %d, Height: %d / X: %d; Y: %d' % (current_width, current_height, pos.x(), pos.y()))
else:
# pan
delta_x = pos.x() - self.pan_initial_pos.x()
@ -220,6 +236,14 @@ class Canvas(QWidget):
self.setStatusTip(self.toolTip())
self.override_cursor(CURSOR_GRAB)
self.update()
# Display annotation width and height while hovering inside
point1 = self.h_shape[1]
point3 = self.h_shape[3]
current_width = abs(point1.x() - point3.x())
current_height = abs(point1.y() - point3.y())
self.parent().window().label_coordinates.setText(
'Width: %d, Height: %d / X: %d; Y: %d' % (current_width, current_height, pos.x(), pos.y()))
break
else: # Nothing found, clear highlights, reset state.
if self.h_shape: