Skip to content

Commit

Permalink
Merge pull request #732 from alicevision/dev/invalidationHooks
Browse files Browse the repository at this point in the history
Invalidation hooks
  • Loading branch information
fabiencastan authored Dec 13, 2019
2 parents 51ca2f3 + 2a28d1d commit a8894c8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
24 changes: 22 additions & 2 deletions meshroom/core/desc.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,14 @@ def __init__(self, param):

def computeSize(self, node):
param = node.attribute(self._param)
assert param.isInput
# Link: use linked node's size
if param.isLink:
return param.getLinkParam().node.size
# ListAttribute: use list size
if isinstance(param.desc, ListAttribute):
return len(param)
if isinstance(param.desc, IntParam):
return param.value
return 1


Expand Down Expand Up @@ -383,7 +384,26 @@ class Node(object):
def __init__(self):
pass

def updateInternals(self, node):
@classmethod
def update(cls, node):
""" Method call before node's internal update on invalidation.
Args:
node: the BaseNode instance being updated
See Also:
BaseNode.updateInternals
"""
pass

@classmethod
def postUpdate(cls, node):
""" Method call after node's internal update on invalidation.
Args:
node: the BaseNode instance being updated
See Also:
NodeBase.updateInternals
"""
pass

def stopProcess(self, chunk):
Expand Down
7 changes: 7 additions & 0 deletions meshroom/core/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,11 @@ def _buildCmdVars(self):
for name, attr in self._attributes.objects.items():
if attr.isInput:
continue # skip inputs

# Only consider File attributes for command output parameters
if not isinstance(attr.attributeDesc, desc.File):
continue

attr.value = attr.attributeDesc.value.format(**self._cmdVars)
attr._invalidationValue = attr.attributeDesc.value.format(**cmdVarsNoCache)
v = attr.getValueStr()
Expand Down Expand Up @@ -555,6 +560,7 @@ def updateInternals(self, cacheDir=None):
Args:
cacheDir (str): (optional) override graph's cache directory with custom path
"""
self.nodeDesc.update(self)
# Update chunks splitting
self._updateChunks()
# Retrieve current internal folder (if possible)
Expand All @@ -569,6 +575,7 @@ def updateInternals(self, cacheDir=None):
}
self._computeUids()
self._buildCmdVars()
self.nodeDesc.postUpdate(self)
# Notify internal folder change if needed
if self.internalFolder != folder:
self.internalFolderChanged.emit()
Expand Down
13 changes: 10 additions & 3 deletions meshroom/ui/qml/GraphEditor/Node.qml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ Item {
}
}

// Whether an attribute can be displayed as an attribute pin on the node
function isDisplayableAsPin(attribute) {
// ATM, only File attributes are meant to be connected
// TODO: review this if we want to connect something else
return attribute.type == "File"
|| (attribute.type == "ListAttribute" && attribute.desc.elementDesc.type == "File")
}

MouseArea {
width: parent.width
height: body.height
Expand Down Expand Up @@ -115,8 +123,7 @@ Item {
Repeater {
model: node.attributes
delegate: Loader {
active: !object.isOutput && object.type == "File"
|| (object.type == "ListAttribute" && object.desc.elementDesc.type == "File") // TODO: review this
active: !object.isOutput && isDisplayableAsPin(object)
width: inputs.width

sourceComponent: AttributePin {
Expand All @@ -142,7 +149,7 @@ Item {
model: node.attributes

delegate: Loader {
active: object.isOutput
active: object.isOutput && isDisplayableAsPin(object)
anchors.right: parent.right
width: outputs.width

Expand Down

0 comments on commit a8894c8

Please sign in to comment.