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

[ui] ImageGallery: Add "Remove All Images" menu to clear all images #2221

Merged
merged 2 commits into from
Oct 11, 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
6 changes: 3 additions & 3 deletions meshroom/ui/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,13 @@ def undoImpl(self):
listAttribute.insert(self.index, self.value)


class ClearImagesCommand(GraphCommand):
class RemoveImagesCommand(GraphCommand):
def __init__(self, graph, cameraInitNodes, parent=None):
super(ClearImagesCommand, self).__init__(graph, parent)
super(RemoveImagesCommand, self).__init__(graph, parent)
self.cameraInits = cameraInitNodes
self.viewpoints = { cameraInit.name: cameraInit.attribute("viewpoints").getExportValue() for cameraInit in self.cameraInits }
self.intrinsics = { cameraInit.name: cameraInit.attribute("intrinsics").getExportValue() for cameraInit in self.cameraInits }
self.title = "Clear{}Images".format(" " if len(self.cameraInits) == 1 else " All ")
self.title = "Remove{}Images".format(" " if len(self.cameraInits) == 1 else " All ")
self.setText(self.title)

def redoImpl(self):
Expand Down
12 changes: 6 additions & 6 deletions meshroom/ui/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@

def onGraphUpdated(self):
""" Callback to any kind of attribute modification. """
# TODO: handle this with a better granularity

Check notice on line 391 in meshroom/ui/graph.py

View check run for this annotation

codefactor.io / CodeFactor

meshroom/ui/graph.py#L391

unresolved comment '# TODO: handle this with a better granularity' (C100)
self.updateChunks()

def updateChunks(self):
Expand Down Expand Up @@ -813,14 +813,14 @@
self.push(commands.ListAttributeRemoveCommand(self._graph, attribute))

@Slot()
def clearImages(self):
with self.groupedGraphModification("Clear Images"):
self.push(commands.ClearImagesCommand(self._graph, [self.cameraInit]))
def removeAllImages(self):
with self.groupedGraphModification("Remove All Images"):
self.push(commands.RemoveImagesCommand(self._graph, [self.cameraInit]))

@Slot()
def clearAllImages(self):
with self.groupedGraphModification("Clear All Images"):
self.push(commands.ClearImagesCommand(self._graph, list(self.cameraInits)))
def removeImagesFromAllGroups(self):
with self.groupedGraphModification("Remove Images From All CameraInit Nodes"):
self.push(commands.RemoveImagesCommand(self._graph, list(self.cameraInits)))

@Slot(Node)
def appendSelection(self, node):
Expand Down
6 changes: 6 additions & 0 deletions meshroom/ui/qml/ImageGallery/ImageDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Item {

signal pressed(var mouse)
signal removeRequest()
signal removeAllImagesRequest()

default property alias children: imageMA.children

Expand Down Expand Up @@ -78,6 +79,11 @@ Item {
enabled: !root.readOnly
onClicked: removeRequest()
}
MenuItem {
text: "Remove All Images"
cbentejac marked this conversation as resolved.
Show resolved Hide resolved
enabled: !root.readOnly
onClicked: removeAllImagesRequest()
}
MenuItem {
text: "Define As Center Image"
property var activeNode: _reconstruction ? _reconstruction.activeNodes.get("SfMTransform").node : null
Expand Down
16 changes: 15 additions & 1 deletion meshroom/ui/qml/ImageGallery/ImageGallery.qml
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,22 @@ Panel {
}
}

function removeAllImages() {
_reconstruction.removeAllImages()
_reconstruction.selectedViewId = "-1"
}

onRemoveRequest: sendRemoveRequest()
Keys.onDeletePressed: sendRemoveRequest()
Keys.onPressed: (event) => {
if (event.key === Qt.Key_Delete && event.modifiers === Qt.ShiftModifier) {
removeAllImages()
} else if (event.key === Qt.Key_Delete) {
sendRemoveRequest()
}
}
onRemoveAllImagesRequest: {
removeAllImages()
}

RowLayout {
anchors.top: parent.top
Expand Down
2 changes: 1 addition & 1 deletion meshroom/ui/qml/WorkspaceView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Item {
tempCameraInit: reconstruction ? reconstruction.tempCameraInit : null
cameraInitIndex: reconstruction ? reconstruction.cameraInitIndex : -1
onRemoveImageRequest: reconstruction.removeAttribute(attribute)
onAllViewpointsCleared: { reconstruction.clearImages(); reconstruction.selectedViewId = "-1" }
onAllViewpointsCleared: { reconstruction.removeAllImages(); reconstruction.selectedViewId = "-1" }
onFilesDropped: reconstruction.handleFilesDrop(drop, augmentSfm ? null : cameraInit)
}
LiveSfmView {
Expand Down
25 changes: 13 additions & 12 deletions meshroom/ui/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -477,21 +477,21 @@ ApplicationWindow {
}

Action {
id: clearImagesAction
property string tooltip: "Clear images for the current CameraInit group"
text: "Clear Images"
id: removeAllImagesAction
property string tooltip: "Remove all the images from the current CameraInit group"
text: "Remove All Images"
onTriggered: {
_reconstruction.clearImages()
_reconstruction.removeAllImages()
_reconstruction.selectedViewId = "-1"
}
}

Action {
id: clearAllImagesAction
property string tooltip: "Clear all the images for all the CameraInit groups"
text: "Clear All Images"
id: removeImagesFromAllGroupsAction
property string tooltip: "Remove all the images from all the CameraInit groups"
text: "Remove Images From All CameraInit Nodes"
onTriggered: {
_reconstruction.clearAllImages()
_reconstruction.removeImagesFromAllGroups()
_reconstruction.selectedViewId = "-1"
}
}
Expand Down Expand Up @@ -723,15 +723,16 @@ ApplicationWindow {
}

MenuItem {
action: clearImagesAction
action: removeAllImagesAction
ToolTip.visible: hovered
ToolTip.text: clearImagesAction.tooltip
ToolTip.text: removeAllImagesAction.tooltip
}

MenuSeparator { }
Menu {
id: advancedMenu
title: "Advanced"
implicitWidth: 300

Action {
id: saveAsTemplateAction
Expand Down Expand Up @@ -768,9 +769,9 @@ ApplicationWindow {
}

MenuItem {
action: clearAllImagesAction
action: removeImagesFromAllGroupsAction
ToolTip.visible: hovered
ToolTip.text: clearAllImagesAction.tooltip
ToolTip.text: removeImagesFromAllGroupsAction.tooltip
}
}
MenuSeparator { }
Expand Down