Skip to content

Commit 32b0ed5

Browse files
committed
[ui/core] Count for loop added on nodes in graph
1 parent 91ebc16 commit 32b0ed5

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

meshroom/core/graph.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,7 @@ def addEdge(self, srcAttr, dstAttr):
899899
dstAttr.valueChanged.emit()
900900
dstAttr.isLinkChanged.emit()
901901
srcAttr.hasOutputConnectionsChanged.emit()
902+
dstAttr.node.countForLoopChanged.emit()
902903
return edge
903904

904905
def addEdges(self, *edges):
@@ -915,6 +916,7 @@ def removeEdge(self, dstAttr):
915916
dstAttr.valueChanged.emit()
916917
dstAttr.isLinkChanged.emit()
917918
edge.src.hasOutputConnectionsChanged.emit()
919+
dstAttr.node.countForLoopChanged.emit()
918920

919921
def getDepth(self, node, minimal=False):
920922
""" Return node's depth in this Graph.
@@ -1485,6 +1487,7 @@ def markNodesDirty(self, fromNode):
14851487
nodes, edges = self.dfsOnDiscover(startNodes=[fromNode], reverse=True)
14861488
for node in nodes:
14871489
node.dirty = True
1490+
node.countForLoopChanged.emit()
14881491

14891492
def stopExecution(self):
14901493
""" Request graph execution to be stopped by terminating running chunks"""

meshroom/core/node.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,25 @@ def has3DOutputAttribute(self):
13201320
if attr.enabled and attr.isOutput and hasSupportedExt:
13211321
return True
13221322
return False
1323+
1324+
def _countForLoop(self):
1325+
"""
1326+
Return in how many ForLoop nodes this node is.
1327+
"""
1328+
count = 0
1329+
# Access to the input attributes of the node
1330+
for attr in self._attributes:
1331+
if attr.isInput and attr.isLink:
1332+
# Access to the attribute connected to the input attribute
1333+
srcAttr = attr.getLinkParam()
1334+
# If the srcAttr is a ListAttribute, it means that the node is in a ForLoop
1335+
if isinstance(srcAttr.root, ListAttribute) and srcAttr.type == attr.type:
1336+
# Access the countForLoop of the node of the ListAttribute
1337+
count = srcAttr.root.node.countForLoop + 1
1338+
if srcAttr.root.isInput:
1339+
count = count - 1 if count > 1 else 1
1340+
return count
1341+
13231342

13241343

13251344
name = Property(str, getName, constant=True)
@@ -1373,6 +1392,9 @@ def has3DOutputAttribute(self):
13731392
hasSequenceOutput = Property(bool, hasSequenceOutputAttribute, notify=outputAttrEnabledChanged)
13741393
has3DOutput = Property(bool, has3DOutputAttribute, notify=outputAttrEnabledChanged)
13751394

1395+
countForLoopChanged = Signal()
1396+
countForLoop = Property(int, _countForLoop, notify=countForLoopChanged)
1397+
13761398
class Node(BaseNode):
13771399
"""
13781400
A standard Graph node based on a node type.

meshroom/ui/graph.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,7 @@ def expandForLoop(self, currentEdge):
776776
newNode = duplicates[0]
777777
previousEdge = self.graph.edge(newNode.attribute(dst.name))
778778
self.replaceEdge(previousEdge, listAttribute.at(i), previousEdge.dst)
779+
newNode.countForLoopChanged.emit()
779780

780781
# Last, replace the edge with the first element of the list
781782
return self.replaceEdge(currentEdge, listAttribute.at(0), dst)

meshroom/ui/qml/GraphEditor/Node.qml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,16 @@ Item {
276276
}
277277
}
278278

279+
// Is in for loop indicator
280+
MaterialLabel {
281+
visible: node.countForLoop > 0
282+
text: MaterialIcons.loop
283+
padding: 2
284+
font.pointSize: 7
285+
palette.text: Colors.sysPalette.text
286+
ToolTip.text: "Is in " + node.countForLoop + " for loop(s)"
287+
}
288+
279289
// Submitted externally indicator
280290
MaterialLabel {
281291
visible: ["SUBMITTED", "RUNNING"].includes(node.globalStatus) && node.chunks.count > 0 && node.isExternal

0 commit comments

Comments
 (0)