Skip to content

Commit f7f2023

Browse files
committed
[ui/core] Count for loop added on nodes in graph
1 parent de54481 commit f7f2023

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

meshroom/core/graph.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -898,6 +898,7 @@ def addEdge(self, srcAttr, dstAttr):
898898
dstAttr.valueChanged.emit()
899899
dstAttr.isLinkChanged.emit()
900900
srcAttr.hasOutputConnectionsChanged.emit()
901+
dstAttr.node.countForLoopChanged.emit()
901902
return edge
902903

903904
def addEdges(self, *edges):

meshroom/core/node.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,6 +1320,23 @@ 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+
return count
1339+
13231340

13241341

13251342
name = Property(str, getName, constant=True)
@@ -1373,6 +1390,9 @@ def has3DOutputAttribute(self):
13731390
hasSequenceOutput = Property(bool, hasSequenceOutputAttribute, notify=outputAttrEnabledChanged)
13741391
has3DOutput = Property(bool, has3DOutputAttribute, notify=outputAttrEnabledChanged)
13751392

1393+
countForLoopChanged = Signal()
1394+
countForLoop = Property(int, _countForLoop, notify=countForLoopChanged)
1395+
13761396
class Node(BaseNode):
13771397
"""
13781398
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
@Slot(Edge)
781782
def collapseForLoop(self, currentEdge):

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)