Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toggle all polygons menu with shortcuts #1381

Merged
merged 3 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
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
18 changes: 16 additions & 2 deletions labelme/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,17 +460,27 @@ def __init__(
hideAll = action(
self.tr("&Hide\nPolygons"),
functools.partial(self.togglePolygons, False),
shortcuts["hide_all_polygons"],
icon="eye",
tip=self.tr("Hide all polygons"),
enabled=False,
)
showAll = action(
self.tr("&Show\nPolygons"),
functools.partial(self.togglePolygons, True),
shortcuts["show_all_polygons"],
icon="eye",
tip=self.tr("Show all polygons"),
enabled=False,
)
toggleAll = action(
self.tr("&Toggle\nPolygons"),
functools.partial(self.togglePolygons, None),
shortcuts["toggle_all_polygons"],
icon="eye",
tip=self.tr("Toggle all polygons"),
enabled=False,
)

help = action(
self.tr("&Tutorial"),
Expand Down Expand Up @@ -692,7 +702,7 @@ def __init__(
editMode,
brightnessContrast,
),
onShapesPresent=(saveAs, hideAll, showAll),
onShapesPresent=(saveAs, hideAll, showAll, toggleAll),
)

self.canvas.vertexSelected.connect(self.actions.removePoint.setEnabled)
Expand Down Expand Up @@ -738,6 +748,7 @@ def __init__(
None,
hideAll,
showAll,
toggleAll,
None,
zoomIn,
zoomOut,
Expand Down Expand Up @@ -1496,8 +1507,11 @@ def brightnessContrast(self, value):
self.brightnessContrast_values[self.filename] = (brightness, contrast)

def togglePolygons(self, value):
flag = value
for item in self.labelList:
item.setCheckState(Qt.Checked if value else Qt.Unchecked)
if value is None:
flag = item.checkState() == Qt.Unchecked
item.setCheckState(Qt.Checked if flag else Qt.Unchecked)

def loadFile(self, filename=None):
"""Load the specified file, or the last opened file if None."""
Expand Down
4 changes: 4 additions & 0 deletions labelme/config/default_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,7 @@ shortcuts:
edit_label: Ctrl+E
toggle_keep_prev_mode: Ctrl+P
remove_selected_point: [Meta+H, Backspace]

show_all_polygons: null
hide_all_polygons: null
toggle_all_polygons: T
11 changes: 11 additions & 0 deletions labelme/translate/empty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,17 @@ Polygons</source>
<source>Show all polygons</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../app.py" line="329"/>
<source>&amp;Toggle
Polygons</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../app.py" line="329"/>
<source>Toggle all polygons</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../app.py" line="331"/>
<source>&amp;Tutorial</source>
Expand Down
11 changes: 11 additions & 0 deletions labelme/translate/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,17 @@ Polygons</source>
<source>Show all polygons</source>
<translation>显示所有多边形</translation>
</message>
<message>
<location filename="../app.py" line="329"/>
<source>&amp;Toggle
Polygons</source>
<translation>开关多边形(&amp;S)</translation>
</message>
<message>
<location filename="../app.py" line="329"/>
<source>Toggle all polygons</source>
<translation>开关所有多边形</translation>
</message>
<message>
<location filename="../app.py" line="331"/>
<source>&amp;Tutorial</source>
Expand Down
Loading