mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-19 20:16:30 +02:00
[ui] Add a "Clear All Images" action and update "Clear Images"'s behaviour
"Clear Images" used to clear the intrinsics and viewpoints for all the existing CameraInit nodes in the graph. There was no-user friendly way to clear the images of a specific CameraInit node. This commit modifies the behaviour of "Clear Images" so that it only deletes the intrinsics and viewpoints of the current CameraInit. A new menu action, "Clear All Images", is added in the "Advanced" sub-menu, and deletes all the intrinsics and viewpoints for all the CameraInit nodes. The way images are cleared is also modified: instead of removing the intrinsics and viewpoints attributes, they are reset. To be undone properly, a corresponding "ClearImagesCommand" has been added. This offers a great performance increase (clearing 1000 images now takes 1s). Tooltips have been added to make the distinction clearer for users.
This commit is contained in:
parent
2987bf0617
commit
43f439be88
4 changed files with 66 additions and 26 deletions
|
@ -350,6 +350,31 @@ class ListAttributeRemoveCommand(GraphCommand):
|
|||
listAttribute.insert(self.index, self.value)
|
||||
|
||||
|
||||
class ClearImagesCommand(GraphCommand):
|
||||
def __init__(self, graph, cameraInitNodes, parent=None):
|
||||
super(ClearImagesCommand, 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.setText(self.title)
|
||||
|
||||
def redoImpl(self):
|
||||
for i in range(len(self.cameraInits)):
|
||||
# Reset viewpoints
|
||||
self.cameraInits[i].viewpoints.resetValue()
|
||||
self.cameraInits[i].viewpoints.valueChanged.emit()
|
||||
# Reset intrinsics
|
||||
self.cameraInits[i].intrinsics.resetValue()
|
||||
self.cameraInits[i].intrinsics.valueChanged.emit()
|
||||
|
||||
def undoImpl(self):
|
||||
for cameraInit in self.viewpoints:
|
||||
with GraphModification(self.graph):
|
||||
self.graph.node(cameraInit).viewpoints.value = self.viewpoints[cameraInit]
|
||||
self.graph.node(cameraInit).intrinsics.value = self.intrinsics[cameraInit]
|
||||
|
||||
|
||||
class MoveNodeCommand(GraphCommand):
|
||||
""" Move a node to a given position. """
|
||||
def __init__(self, graph, node, position, parent=None):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue