[ui] Attribute: Attribute actually displayed in the 3dViewer are flagged with a visibility icon (eye)

This commit is contained in:
nicolas-lambert-tc 2025-05-09 18:11:38 +02:00
parent 4a67736d9e
commit cfd2b1e00a
7 changed files with 85 additions and 23 deletions

View file

@ -44,6 +44,9 @@ class Attribute(BaseObject):
"""
"""
stringIsLinkRe = re.compile(r'^\{[A-Za-z]+[A-Za-z0-9_.\[\]]*\}$')
VALID_IMAGE_SEMANTICS = ["image", "imageList", "sequence"]
VALID_3D_EXTENSIONS = ['.obj', '.stl', '.fbx', '.gltf', '.abc', '.ply']
def __init__(self, node, attributeDesc, isOutput, root=None, parent=None):
"""
@ -418,6 +421,28 @@ class Attribute(BaseObject):
# Emit if the enable status has changed
self.setEnabled(self.getEnabled())
def _is3D(self) -> bool:
""" Return True if the current attribute is considered as a 3d file """
# List of supported extensions, taken from Viewer3DSettings
if self.desc.semantic == "3d":
return True
# If the attribute is a File attribute, it is an instance of str and can be iterated over
hasSupportedExt = isinstance(self.value, str) and any(ext in self.value for ext in Attribute.VALID_3D_EXTENSIONS)
if hasSupportedExt:
return True
return False
def _is2D(self) -> bool:
""" Return True if the current attribute is considered as a 2d file """
if not self.desc.semantic:
return False
return next((imageSemantic for imageSemantic in Attribute.VALID_IMAGE_SEMANTICS if self.desc.semantic == imageSemantic), None) is not None
name = Property(str, getName, constant=True)
fullName = Property(str, getFullName, constant=True)
fullNameToNode = Property(str, getFullNameToNode, constant=True)
@ -430,6 +455,8 @@ class Attribute(BaseObject):
type = Property(str, getType, constant=True)
baseType = Property(str, getType, constant=True)
isReadOnly = Property(bool, _isReadOnly, constant=True)
is3D = Property(bool, _is3D, constant=True)
is2D = Property(bool, _is2D, constant=True)
# Description of the attribute
descriptionChanged = Signal()