mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-24 22:46:28 +02:00
Merge pull request #1897 from alicevision/dev/improveClearImages
[ui] Improve "Clear Images" action's behaviour and performance
This commit is contained in:
commit
ea323edb83
3 changed files with 66 additions and 21 deletions
|
@ -350,6 +350,31 @@ class ListAttributeRemoveCommand(GraphCommand):
|
||||||
listAttribute.insert(self.index, self.value)
|
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):
|
class MoveNodeCommand(GraphCommand):
|
||||||
""" Move a node to a given position. """
|
""" Move a node to a given position. """
|
||||||
def __init__(self, graph, node, position, parent=None):
|
def __init__(self, graph, node, position, parent=None):
|
||||||
|
|
|
@ -733,6 +733,16 @@ class UIGraph(QObject):
|
||||||
def removeAttribute(self, attribute):
|
def removeAttribute(self, attribute):
|
||||||
self.push(commands.ListAttributeRemoveCommand(self._graph, attribute))
|
self.push(commands.ListAttributeRemoveCommand(self._graph, attribute))
|
||||||
|
|
||||||
|
@Slot()
|
||||||
|
def clearImages(self):
|
||||||
|
with self.groupedGraphModification("Clear Images"):
|
||||||
|
self.push(commands.ClearImagesCommand(self._graph, [self.cameraInit]))
|
||||||
|
|
||||||
|
@Slot()
|
||||||
|
def clearAllImages(self):
|
||||||
|
with self.groupedGraphModification("Clear All Images"):
|
||||||
|
self.push(commands.ClearImagesCommand(self._graph, list(self.cameraInits)))
|
||||||
|
|
||||||
@Slot(Node)
|
@Slot(Node)
|
||||||
def appendSelection(self, node):
|
def appendSelection(self, node):
|
||||||
""" Append 'node' to the selection if it is not already part of the selection. """
|
""" Append 'node' to the selection if it is not already part of the selection. """
|
||||||
|
|
|
@ -427,6 +427,26 @@ ApplicationWindow {
|
||||||
uigraph: _reconstruction
|
uigraph: _reconstruction
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Action {
|
||||||
|
id: clearImagesAction
|
||||||
|
property string tooltip: "Clear images for the current CameraInit group"
|
||||||
|
text: "Clear Images"
|
||||||
|
onTriggered: {
|
||||||
|
_reconstruction.clearImages()
|
||||||
|
_reconstruction.selectedViewId = "-1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Action {
|
||||||
|
id: clearAllImagesAction
|
||||||
|
property string tooltip: "Clear all the images for all the CameraInit groups"
|
||||||
|
text: "Clear All Images"
|
||||||
|
onTriggered: {
|
||||||
|
_reconstruction.clearAllImages()
|
||||||
|
_reconstruction.selectedViewId = "-1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Action {
|
Action {
|
||||||
id: undoAction
|
id: undoAction
|
||||||
|
|
||||||
|
@ -638,28 +658,12 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Action {
|
MenuItem {
|
||||||
id: clearImagesAction
|
action: clearImagesAction
|
||||||
text: "Clear Images"
|
ToolTip.visible: hovered
|
||||||
onTriggered: {
|
ToolTip.text: clearImagesAction.tooltip
|
||||||
//Loop through all the camera inits
|
|
||||||
for(var i = 0 ; i < _reconstruction.cameraInits.count; i++){
|
|
||||||
var cameraInit = _reconstruction.cameraInits.at(i)
|
|
||||||
|
|
||||||
//Delete all viewpoints
|
|
||||||
var viewpoints = cameraInit.attribute('viewpoints')
|
|
||||||
for(var y = viewpoints.value.count - 1 ; y >= 0 ; y--){
|
|
||||||
_reconstruction.removeAttribute(viewpoints.value.at(y))
|
|
||||||
}
|
|
||||||
|
|
||||||
//Delete all intrinsics
|
|
||||||
var intrinsics = cameraInit.attribute('intrinsics')
|
|
||||||
for(var z = intrinsics.value.count - 1 ; z >= 0 ; z--){
|
|
||||||
_reconstruction.removeAttribute(intrinsics.value.at(z))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuSeparator { }
|
MenuSeparator { }
|
||||||
Menu {
|
Menu {
|
||||||
id: advancedMenu
|
id: advancedMenu
|
||||||
|
@ -692,6 +696,12 @@ ApplicationWindow {
|
||||||
importProjectDialog.open();
|
importProjectDialog.open();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MenuItem {
|
||||||
|
action: clearAllImagesAction
|
||||||
|
ToolTip.visible: hovered
|
||||||
|
ToolTip.text: clearAllImagesAction.tooltip
|
||||||
|
}
|
||||||
}
|
}
|
||||||
MenuSeparator { }
|
MenuSeparator { }
|
||||||
Action {
|
Action {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue