mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-04-30 02:37:26 +02:00
Merge pull request #2052 from alicevision/dev/imageSemanticIcon3D
[ui] Display an icon on nodes that have viewable 3D outputs
This commit is contained in:
commit
73b9ccfac2
3 changed files with 28 additions and 13 deletions
|
@ -1124,11 +1124,27 @@ class BaseNode(BaseObject):
|
||||||
self.globalExecMode == "LOCAL" and self.statusInThisSession())
|
self.globalExecMode == "LOCAL" and self.statusInThisSession())
|
||||||
|
|
||||||
def hasImageOutputAttribute(self):
|
def hasImageOutputAttribute(self):
|
||||||
|
"""
|
||||||
|
Return True if at least one attribute has the 'image' semantic (and can thus be loaded in the 2D Viewer), False otherwise.
|
||||||
|
"""
|
||||||
for attr in self._attributes:
|
for attr in self._attributes:
|
||||||
if attr.enabled and attr.isOutput and attr.desc.semantic == "image":
|
if attr.enabled and attr.isOutput and attr.desc.semantic == "image":
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def has3DOutputAttribute(self):
|
||||||
|
"""
|
||||||
|
Return True if at least one attribute is a File that can be loaded in the 3D Viewer, False otherwise.
|
||||||
|
"""
|
||||||
|
# List of supported extensions, taken from Viewer3DSettings
|
||||||
|
supportedExts = ['.obj', '.stl', '.fbx', '.gltf', '.abc']
|
||||||
|
for attr in self._attributes:
|
||||||
|
# If the attribute is a File attribute, it is an instance of str and can be iterated over
|
||||||
|
hasSupportedExt = isinstance(attr.value, str) and any(ext in attr.value for ext in supportedExts)
|
||||||
|
if attr.enabled and attr.isOutput and hasSupportedExt:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
name = Property(str, getName, constant=True)
|
name = Property(str, getName, constant=True)
|
||||||
nodeType = Property(str, nodeType.fget, constant=True)
|
nodeType = Property(str, nodeType.fget, constant=True)
|
||||||
|
@ -1174,7 +1190,7 @@ class BaseNode(BaseObject):
|
||||||
|
|
||||||
outputAttrEnabledChanged = Signal()
|
outputAttrEnabledChanged = Signal()
|
||||||
hasImageOutput = Property(bool, hasImageOutputAttribute, notify=outputAttrEnabledChanged)
|
hasImageOutput = Property(bool, hasImageOutputAttribute, notify=outputAttrEnabledChanged)
|
||||||
|
has3DOutput = Property(bool, has3DOutputAttribute, notify=outputAttrEnabledChanged)
|
||||||
|
|
||||||
class Node(BaseNode):
|
class Node(BaseNode):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -308,7 +308,8 @@ Item {
|
||||||
|
|
||||||
MaterialLabel {
|
MaterialLabel {
|
||||||
id: nodeImageOutput
|
id: nodeImageOutput
|
||||||
visible: node.hasImageOutput && ["SUCCESS"].includes(node.globalStatus) && node.chunks.count > 0
|
visible: (node.hasImageOutput || node.has3DOutput)
|
||||||
|
&& ["SUCCESS"].includes(node.globalStatus) && node.chunks.count > 0
|
||||||
text: MaterialIcons.visibility
|
text: MaterialIcons.visibility
|
||||||
padding: 2
|
padding: 2
|
||||||
font.pointSize: 7
|
font.pointSize: 7
|
||||||
|
@ -317,8 +318,14 @@ Item {
|
||||||
id: nodeImageOutputTooltip
|
id: nodeImageOutputTooltip
|
||||||
parent: header
|
parent: header
|
||||||
visible: nodeImageOutputMA.containsMouse && nodeImageOutput.visible
|
visible: nodeImageOutputMA.containsMouse && nodeImageOutput.visible
|
||||||
text: "This node has at least one output that can be loaded in the 2D Viewer.\n" +
|
text: {
|
||||||
"Double-clicking on this node will load it in the 2D Viewer."
|
if (node.hasImageOutput && !node.has3DOutput)
|
||||||
|
return "Double-click on this node to load its outputs in the Image Viewer."
|
||||||
|
else if (node.has3DOutput && !node.hasImageOutput)
|
||||||
|
return "Double-click on this node to load its outputs in the 3D Viewer."
|
||||||
|
else // Handle case where a node might have both 2D and 3D outputs
|
||||||
|
return "Double-click on this node to load its outputs in the Image or 3D Viewer."
|
||||||
|
}
|
||||||
implicitWidth: 500
|
implicitWidth: 500
|
||||||
delay: 300
|
delay: 300
|
||||||
|
|
||||||
|
|
|
@ -181,15 +181,7 @@ FocusScope {
|
||||||
}
|
}
|
||||||
|
|
||||||
// node must have at least one output attribute with the image semantic
|
// node must have at least one output attribute with the image semantic
|
||||||
var hasImageOutputAttr = false;
|
if (!node.hasImageOutput) {
|
||||||
for (var i = 0; i < node.attributes.count; i++) {
|
|
||||||
var attr = node.attributes.at(i);
|
|
||||||
if (attr.isOutput && attr.desc.semantic === "image" && attr.enabled) {
|
|
||||||
hasImageOutputAttr = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!hasImageOutputAttr) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue