From 2b232b0c85d832796b0846d1856ceef8432f074e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Candice=20Bent=C3=A9jac?= Date: Tue, 7 Mar 2023 09:19:50 +0100 Subject: [PATCH] Viewer2D: Update list of loaded node's outputs when they are en/dis-abled When a node with viewable output attributes is loaded, the combo box of the 2D Viewer lists these attributes. As some of these attributes are enabled or disabled, they need to be added or removed from that list, without needing to load another node first, or to unload the node. This commit connects the signal that is emitted when an output attribute with a viewable output is enabled or disabled to the slot that reloads the currently loaded node (and thus updates the list). --- meshroom/core/node.py | 4 ++++ meshroom/ui/qml/Viewer/Viewer2D.qml | 10 +++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/meshroom/core/node.py b/meshroom/core/node.py index 7e5999f6..aedb6e17 100644 --- a/meshroom/core/node.py +++ b/meshroom/core/node.py @@ -1166,6 +1166,8 @@ class BaseNode(BaseObject): hasDuplicatesChanged = Signal() hasDuplicates = Property(bool, lambda self: self._hasDuplicates, notify=hasDuplicatesChanged) + outputAttrEnabledChanged = Signal() + class Node(BaseNode): """ @@ -1192,6 +1194,8 @@ class Node(BaseNode): # List attributes per uid for attr in self._attributes: + if attr.isOutput and attr.desc.semantic == "image": + attr.enabledChanged.connect(self.outputAttrEnabledChanged) for uidIndex in attr.attributeDesc.uid: self.attributesPerUid[uidIndex].add(attr) diff --git a/meshroom/ui/qml/Viewer/Viewer2D.qml b/meshroom/ui/qml/Viewer/Viewer2D.qml index 7c437ba4..9b12d83a 100644 --- a/meshroom/ui/qml/Viewer/Viewer2D.qml +++ b/meshroom/ui/qml/Viewer/Viewer2D.qml @@ -184,7 +184,7 @@ FocusScope { var hasImageOutputAttr = false; for (var i = 0; i < node.attributes.count; i++) { var attr = node.attributes.at(i); - if (attr.isOutput && attr.desc.semantic == "image") { + if (attr.isOutput && attr.desc.semantic === "image" && attr.enabled) { hasImageOutputAttr = true; break; } @@ -280,7 +280,7 @@ FocusScope { // store attr name for output attributes that represent images for (var i = 0; i < displayedNode.attributes.count; i++) { var attr = displayedNode.attributes.at(i); - if (attr.isOutput && attr.desc.semantic == "image") { + if (attr.isOutput && attr.desc.semantic === "image" && attr.enabled) { names.push(attr.name); } } @@ -300,6 +300,10 @@ FocusScope { } } + Connections { + target: displayedNode + onOutputAttrEnabledChanged: tryLoadNode(displayedNode) + } // context menu property Component contextMenu: Menu { MenuItem { @@ -1193,7 +1197,7 @@ FocusScope { property var names: ["gallery"] property string name: names[currentIndex] - model: names.map(n => (n == "gallery") ? "Image Gallery" : displayedNode.attributes.get(n).label) + model: names.map(n => (n === "gallery") ? "Image Gallery" : displayedNode.attributes.get(n).label) enabled: count > 1 FontMetrics {