mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-30 09:26:32 +02:00
[core] Add property to know if node's outputs can be loaded in 3D Viewer
This commit is contained in:
parent
7e6ce90234
commit
0c22bbb097
1 changed files with 17 additions and 1 deletions
|
@ -1124,11 +1124,27 @@ class BaseNode(BaseObject):
|
|||
self.globalExecMode == "LOCAL" and self.statusInThisSession())
|
||||
|
||||
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:
|
||||
if attr.enabled and attr.isOutput and attr.desc.semantic == "image":
|
||||
return True
|
||||
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)
|
||||
nodeType = Property(str, nodeType.fget, constant=True)
|
||||
|
@ -1174,7 +1190,7 @@ class BaseNode(BaseObject):
|
|||
|
||||
outputAttrEnabledChanged = Signal()
|
||||
hasImageOutput = Property(bool, hasImageOutputAttribute, notify=outputAttrEnabledChanged)
|
||||
|
||||
has3DOutput = Property(bool, has3DOutputAttribute, notify=outputAttrEnabledChanged)
|
||||
|
||||
class Node(BaseNode):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue