Skip to content

Commit f53b9d1

Browse files
committed
[ui] Value of current edge iteration and TaskManager protected
1 parent c821f64 commit f53b9d1

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

meshroom/ui/graph.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -759,24 +759,22 @@ def canExpandForLoop(self, currentEdge):
759759
return False
760760
return True
761761

762-
@Slot(Edge)
762+
@Slot(Edge, result=Edge)
763763
def expandForLoop(self, currentEdge):
764764
""" Expand 'node' by creating all its output nodes. """
765765
with self.groupedGraphModification("Expand For Loop Node"):
766766
listAttribute = currentEdge.src.root
767767
dst = currentEdge.dst
768768

769-
# First, replace the edge with the first element of the list
770-
currentEdge = self.replaceEdge(currentEdge, listAttribute.at(0), dst)
771-
772-
srcIndex = listAttribute.index(currentEdge.src)
773-
dst = currentEdge.dst
774769
for i in range(1, len(listAttribute)):
775770
duplicates = self.duplicateNodesFrom(dst.node)
776771
newNode = duplicates[0]
777772
previousEdge = self.graph.edge(newNode.attribute(dst.name))
778773
self.replaceEdge(previousEdge, listAttribute.at(i), previousEdge.dst)
779774

775+
# Last, replace the edge with the first element of the list
776+
return self.replaceEdge(currentEdge, listAttribute.at(0), dst)
777+
780778
@Slot(Edge)
781779
def collapseForLoop(self, currentEdge):
782780
""" Collapse 'node' by removing all its output nodes. """

meshroom/ui/qml/GraphEditor/GraphEditor.qml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,11 +389,22 @@ Item {
389389

390390
contentItem: Row {
391391
IntSelector {
392+
id: loopIterationSelector
392393
tooltipText: "Iterations"
393394
visible: edgeMenu.currentEdge && edgeMenu.forLoop
394395

395396
property var listAttr: edgeMenu.currentEdge ? edgeMenu.currentEdge.src.root : null
396397

398+
Connections {
399+
target: edgeMenu
400+
function onCurrentEdgeChanged() {
401+
if (edgeMenu.currentEdge) {
402+
loopIterationSelector.listAttr = edgeMenu.currentEdge.src.root
403+
loopIterationSelector.value = loopIterationSelector.listAttr ? loopIterationSelector.listAttr.value.indexOf(edgeMenu.currentEdge.src) + 1 : 0
404+
}
405+
}
406+
}
407+
397408
// We add 1 to the index because of human readable index (starting at 1)
398409
value: listAttr ? listAttr.value.indexOf(edgeMenu.currentEdge.src) + 1 : 0
399410
range: { "min": 1, "max": listAttr ? listAttr.value.count : 0 }
@@ -436,7 +447,7 @@ Item {
436447
text: MaterialIcons.open_in_full
437448

438449
onClicked: {
439-
uigraph.expandForLoop(edgeMenu.currentEdge)
450+
edgeMenu.currentEdge = uigraph.expandForLoop(edgeMenu.currentEdge)
440451
canExpand = false
441452
edgeMenu.close()
442453
}

meshroom/ui/qml/GraphEditor/TaskManager.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ Item {
264264
spacing: 3
265265

266266
delegate: Label {
267-
width: (ListView.view.width / ListView.view.model.count) - 3
267+
width: ListView.view.model ? (ListView.view.width / ListView.view.model.count) - 3 : 0
268268
height: ListView.view.height
269269
anchors.verticalCenter: parent.verticalCenter
270270
background: Rectangle {

0 commit comments

Comments
 (0)