Skip to content

Commit

Permalink
[Feature] Add toggle for continuous drawing mode without automatic sw…
Browse files Browse the repository at this point in the history
…itch to edit mode
  • Loading branch information
CVHub520 committed Jul 22, 2024
1 parent 6f86f60 commit 7ba6458
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
2 changes: 2 additions & 0 deletions anylabeling/configs/xanylabeling_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ keep_prev_scale: false
keep_prev_brightness: false
keep_prev_contrast: false
auto_use_last_label: false
auto_switch_to_edit_mode: true
show_groups: true
show_texts: true
show_labels: true
Expand Down Expand Up @@ -74,6 +75,7 @@ canvas:
# None: do nothing
# close: close polygon
double_click: close
# change mode
# The max number of edits we can undo
num_backups: 10
crosshair:
Expand Down
7 changes: 4 additions & 3 deletions anylabeling/views/labeling/label_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,15 +262,16 @@ def __init__(
Qt.Horizontal: scroll_area.horizontalScrollBar(),
}
self.canvas.scroll_request.connect(self.scroll_request)
# [Feature] support for automatically switching to editing mode
# when the cursor moves over an object (commit cd84619)
# self.canvas.mode_changed.connect(self.set_edit_mode)
self.canvas.new_shape.connect(self.new_shape)
self.canvas.show_shape.connect(self.show_shape)
self.canvas.shape_moved.connect(self.set_dirty)
self.canvas.shape_rotated.connect(self.set_dirty)
self.canvas.selection_changed.connect(self.shape_selection_changed)
self.canvas.drawing_polygon.connect(self.toggle_drawing_sensitive)
# [Feature] support for automatically switching to editing mode
# when the cursor moves over an object
if self._config["auto_switch_to_edit_mode"]:
self.canvas.mode_changed.connect(self.set_edit_mode)

# Crosshair
self.crosshair_settings = self._config["canvas"]["crosshair"]
Expand Down
28 changes: 14 additions & 14 deletions anylabeling/views/labeling/widgets/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class Canvas(
zoom_request = QtCore.pyqtSignal(int, QtCore.QPoint)
scroll_request = QtCore.pyqtSignal(int, int)
# [Feature] support for automatically switching to editing mode
# when the cursor moves over an object (commit cd84619)
# mode_changed = QtCore.pyqtSignal()
# when the cursor moves over an object
mode_changed = QtCore.pyqtSignal()
new_shape = QtCore.pyqtSignal()
show_shape = QtCore.pyqtSignal(int, int, QtCore.QPointF)
selection_changed = QtCore.pyqtSignal(list)
Expand Down Expand Up @@ -455,11 +455,11 @@ def mouseMoveEvent(self, ev): # noqa: C901
)
self.setStatusTip(self.toolTip())
self.override_cursor(CURSOR_GRAB)
# [Feature] Automatically highlight shape when the mouse is moved inside it (commit eeb15c4)
# group_mode = int(ev.modifiers()) == QtCore.Qt.ControlModifier
# self.select_shape_point(
# pos, multiple_selection_mode=group_mode
# )
# [Feature] Automatically highlight shape when the mouse is moved inside it
group_mode = int(ev.modifiers()) == QtCore.Qt.ControlModifier
self.select_shape_point(
pos, multiple_selection_mode=group_mode
)
self.update()

if shape.shape_type == "rectangle":
Expand Down Expand Up @@ -554,13 +554,13 @@ def mousePressEvent(self, ev):
if int(ev.modifiers()) == QtCore.Qt.ControlModifier:
self.finalise()
# [Feature] support for automatically switching to editing mode
# when the cursor moves over an object (commit cd84619)
# if (
# self.create_mode
# in ["rectangle", "rotation", "circle", "line", "point"]
# and not self.is_auto_labeling
# ):
# self.mode_changed.emit()
# when the cursor moves over an object
if (
self.create_mode
in ["rectangle", "rotation", "circle", "line", "point"]
and not self.is_auto_labeling
):
self.mode_changed.emit()
elif not self.out_off_pixmap(pos):
# Create new shape.
self.current = Shape(shape_type=self.create_mode)
Expand Down

0 comments on commit 7ba6458

Please sign in to comment.