diff --git a/meshroom/core/attribute.py b/meshroom/core/attribute.py index 43d7b4c7..5d205d87 100644 --- a/meshroom/core/attribute.py +++ b/meshroom/core/attribute.py @@ -31,6 +31,8 @@ def attributeFactory(description, value, isOutput, node, root=None, parent=None) cls = ListAttribute elif isinstance(description, desc.ChoiceParam): cls = ChoiceParam + elif isinstance(description, desc.PushButtonParam): + cls = PushButtonParam else: cls = Attribute attr = cls(node, description, isOutput, root, parent) @@ -398,6 +400,13 @@ def raiseIfLink(func): return func(attr, *args, **kwargs) return wrapper +class PushButtonParam(Attribute): + def __init__(self, node, attributeDesc, isOutput, root=None, parent=None): + super(PushButtonParam, self).__init__(node, attributeDesc, isOutput, root, parent) + + @Slot() + def clicked(self): + self.node.onAttributeClicked(self) class ChoiceParam(Attribute): diff --git a/meshroom/core/desc.py b/meshroom/core/desc.py index 359377e9..e0c1bba8 100644 --- a/meshroom/core/desc.py +++ b/meshroom/core/desc.py @@ -301,6 +301,15 @@ class FloatParam(Param): range = Property(VariantList, lambda self: self._range, constant=True) +class PushButtonParam(Param): + """ + """ + def __init__(self, name, label, description, uid, group='allParams', advanced=False, semantic='', enabled=True, visible=True): + super(PushButtonParam, self).__init__(name=name, label=label, description=description, value="", uid=uid, group=group, advanced=advanced, semantic=semantic, enabled=enabled, visible=visible) + def validateValue(self, value): + pass + def checkValueTypes(self): + pass class ChoiceParam(Param): """ diff --git a/meshroom/core/node.py b/meshroom/core/node.py index c7287a23..8f782e07 100644 --- a/meshroom/core/node.py +++ b/meshroom/core/node.py @@ -892,6 +892,19 @@ class BaseNode(BaseObject): if callable(m): m(self) + def onAttributeClicked(self, attr): + """ When an attribute is clicked, a specific function can be defined in the descriptor and be called. + + Args: + attr (Attribute): attribute that has been clicked + """ + paramName = attr.name[:1].upper() + attr.name[1:] + methodName = f'on{paramName}Clicked' + if hasattr(self.nodeDesc, methodName): + m = getattr(self.nodeDesc, methodName) + if callable(m): + m(self) + def updateInternals(self, cacheDir=None): """ Update Node's internal parameters and output attributes.