mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-05-14 17:46:58 +02:00
[core] add enabled property on attributes
The new property "enabled" allows to define a lambda to dynamically enable/disable parameters. Disabled parameters are not used in the uid, not exported to the command line and not visible in the interface.
This commit is contained in:
parent
f7b6b27a5a
commit
2d953d7319
4 changed files with 53 additions and 28 deletions
|
@ -58,6 +58,7 @@ class Attribute(BaseObject):
|
|||
self._isOutput = isOutput
|
||||
self._value = copy.copy(attributeDesc.value)
|
||||
self._label = attributeDesc.label
|
||||
self._enabled = True
|
||||
|
||||
# invalidation value for output attributes
|
||||
self._invalidationValue = ""
|
||||
|
@ -95,6 +96,15 @@ class Attribute(BaseObject):
|
|||
def getLabel(self):
|
||||
return self._label
|
||||
|
||||
def getEnabled(self):
|
||||
return self._enabled
|
||||
|
||||
def setEnabled(self, v):
|
||||
if self._enabled == v:
|
||||
return
|
||||
self._enabled = v
|
||||
self.enabledChanged.emit()
|
||||
|
||||
def _get_value(self):
|
||||
return self.getLinkParam().value if self.isLink else self._value
|
||||
|
||||
|
@ -224,6 +234,12 @@ class Attribute(BaseObject):
|
|||
def getPrimitiveValue(self, exportDefault=True):
|
||||
return self._value
|
||||
|
||||
def updateInternals(self):
|
||||
if isinstance(self.desc.enabled, types.FunctionType):
|
||||
self.setEnabled(self.desc.enabled(self.node))
|
||||
else:
|
||||
self.setEnabled(self.attributeDesc.enabled)
|
||||
|
||||
name = Property(str, getName, constant=True)
|
||||
fullName = Property(str, getFullName, constant=True)
|
||||
label = Property(str, getLabel, constant=True)
|
||||
|
@ -237,6 +253,8 @@ class Attribute(BaseObject):
|
|||
isDefault = Property(bool, _isDefault, notify=valueChanged)
|
||||
linkParam = Property(BaseObject, getLinkParam, notify=isLinkChanged)
|
||||
node = Property(BaseObject, node.fget, constant=True)
|
||||
enabledChanged = Signal()
|
||||
enabled = Property(bool, getEnabled, setEnabled, notify=enabledChanged)
|
||||
|
||||
|
||||
def raiseIfLink(func):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue