From 3155906644513ce014e6b7be7a7ed1922ddee449 Mon Sep 17 00:00:00 2001 From: Yann Lanthony Date: Fri, 13 Dec 2019 18:02:52 +0100 Subject: [PATCH 1/3] [core] desc.Node: add update/postUpdate hooks Enable node descriptions to react before/after the invalidation of a node instance. --- meshroom/core/desc.py | 21 ++++++++++++++++++++- meshroom/core/node.py | 7 +++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/meshroom/core/desc.py b/meshroom/core/desc.py index a9a96a1051..356ca1e706 100755 --- a/meshroom/core/desc.py +++ b/meshroom/core/desc.py @@ -383,7 +383,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): diff --git a/meshroom/core/node.py b/meshroom/core/node.py index f2e98a2de3..107c773940 100644 --- a/meshroom/core/node.py +++ b/meshroom/core/node.py @@ -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() @@ -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) @@ -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() From 411e1f0de07614f91ef200a0e83674ba6bea5941 Mon Sep 17 00:00:00 2001 From: Yann Lanthony Date: Fri, 13 Dec 2019 17:41:59 +0100 Subject: [PATCH 2/3] [core] desc.Node: allow usage of DynamicNodeSize on output attributes Also consider IntParam value as node size. --- meshroom/core/desc.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/meshroom/core/desc.py b/meshroom/core/desc.py index 356ca1e706..be6f52e589 100755 --- a/meshroom/core/desc.py +++ b/meshroom/core/desc.py @@ -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 From 2a28d1d7d22d016e4d72da5fd5c9297aa83620ef Mon Sep 17 00:00:00 2001 From: Yann Lanthony Date: Fri, 13 Dec 2019 17:42:38 +0100 Subject: [PATCH 3/3] [ui] Node: only display File attributes as pins --- meshroom/ui/qml/GraphEditor/Node.qml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/meshroom/ui/qml/GraphEditor/Node.qml b/meshroom/ui/qml/GraphEditor/Node.qml index babf307823..b2c8e24907 100755 --- a/meshroom/ui/qml/GraphEditor/Node.qml +++ b/meshroom/ui/qml/GraphEditor/Node.qml @@ -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 @@ -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 { @@ -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