mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-06-03 11:21:52 +02:00
[core] Propagate the onAttributeChanged notification to connected attributes
This commit is contained in:
parent
a82fe3927b
commit
3cc67fddfb
2 changed files with 23 additions and 2 deletions
|
@ -76,6 +76,8 @@ class Attribute(BaseObject):
|
||||||
self._value = None
|
self._value = None
|
||||||
self.initValue()
|
self.initValue()
|
||||||
|
|
||||||
|
self.valueChanged.connect(self.onChanged)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def node(self):
|
def node(self):
|
||||||
return self._node()
|
return self._node()
|
||||||
|
@ -187,6 +189,21 @@ class Attribute(BaseObject):
|
||||||
return self.getLinkParam().value
|
return self.getLinkParam().value
|
||||||
return self._value
|
return self._value
|
||||||
|
|
||||||
|
def onChanged(self):
|
||||||
|
""" Called when the attribute value has changed """
|
||||||
|
if self.node.isCompatibilityNode:
|
||||||
|
# We have no access to the node's implementation,
|
||||||
|
# so we cannot call the custom method.
|
||||||
|
return
|
||||||
|
if self.isOutput and not self.node.isInputNode:
|
||||||
|
# Ignore changes on output attributes for non-input nodes
|
||||||
|
# as they are updated during the node's computation.
|
||||||
|
# And we do not want notifications during the graph processing.
|
||||||
|
return
|
||||||
|
# notify the node that the attribute has changed
|
||||||
|
# this will call the node descriptor "onAttrNameChanged" method
|
||||||
|
self.node.onAttributeChanged(self)
|
||||||
|
|
||||||
def _set_value(self, value, emitSignals=True):
|
def _set_value(self, value, emitSignals=True):
|
||||||
if self._value == value:
|
if self._value == value:
|
||||||
return
|
return
|
||||||
|
@ -206,8 +223,6 @@ class Attribute(BaseObject):
|
||||||
if not emitSignals:
|
if not emitSignals:
|
||||||
return
|
return
|
||||||
|
|
||||||
if not self.node.isCompatibilityNode:
|
|
||||||
self.node.onAttributeChanged(self)
|
|
||||||
# Request graph update when input parameter value is set
|
# Request graph update when input parameter value is set
|
||||||
# and parent node belongs to a graph
|
# and parent node belongs to a graph
|
||||||
# Output attributes value are set internally during the update process,
|
# Output attributes value are set internally during the update process,
|
||||||
|
|
|
@ -920,6 +920,7 @@ class BaseNode(BaseObject):
|
||||||
Args:
|
Args:
|
||||||
attr (Attribute): attribute that has changed
|
attr (Attribute): attribute that has changed
|
||||||
"""
|
"""
|
||||||
|
# Call the specific function if it exists in the node implementation
|
||||||
paramName = attr.name[:1].upper() + attr.name[1:]
|
paramName = attr.name[:1].upper() + attr.name[1:]
|
||||||
methodName = f'on{paramName}Changed'
|
methodName = f'on{paramName}Changed'
|
||||||
if hasattr(self.nodeDesc, methodName):
|
if hasattr(self.nodeDesc, methodName):
|
||||||
|
@ -927,6 +928,11 @@ class BaseNode(BaseObject):
|
||||||
if callable(m):
|
if callable(m):
|
||||||
m(self)
|
m(self)
|
||||||
|
|
||||||
|
# Propage the notification to connected output attributes
|
||||||
|
outEdges = self.graph.outEdges(attr)
|
||||||
|
for edge in outEdges:
|
||||||
|
edge.dst.onChanged()
|
||||||
|
|
||||||
def onAttributeClicked(self, attr):
|
def onAttributeClicked(self, attr):
|
||||||
""" When an attribute is clicked, a specific function can be defined in the descriptor and be called.
|
""" When an attribute is clicked, a specific function can be defined in the descriptor and be called.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue