Skip to content

Commit 193d5b5

Browse files
committed
[ui] Value of current edge iteration and TaskManager protected
1 parent b4f5bef commit 193d5b5

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
@@ -764,24 +764,22 @@ def canExpandForLoop(self, currentEdge):
764764
return False
765765
return True
766766

767-
@Slot(Edge)
767+
@Slot(Edge, result=Edge)
768768
def expandForLoop(self, currentEdge):
769769
""" Expand 'node' by creating all its output nodes. """
770770
with self.groupedGraphModification("Expand For Loop Node"):
771771
listAttribute = currentEdge.src.root
772772
dst = currentEdge.dst
773773

774-
# First, replace the edge with the first element of the list
775-
currentEdge = self.replaceEdge(currentEdge, listAttribute.at(0), dst)
776-
777-
srcIndex = listAttribute.index(currentEdge.src)
778-
dst = currentEdge.dst
779774
for i in range(1, len(listAttribute)):
780775
duplicates = self.duplicateNodesFrom(dst.node)
781776
newNode = duplicates[0]
782777
previousEdge = self.graph.edge(newNode.attribute(dst.name))
783778
self.replaceEdge(previousEdge, listAttribute.at(i), previousEdge.dst)
784779

780+
# Last, replace the edge with the first element of the list
781+
return self.replaceEdge(currentEdge, listAttribute.at(0), dst)
782+
785783
@Slot(Edge)
786784
def collapseForLoop(self, currentEdge):
787785
""" 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
@@ -390,11 +390,22 @@ Item {
390390

391391
contentItem: Row {
392392
IntSelector {
393+
id: loopIterationSelector
393394
tooltipText: "Iterations"
394395
visible: edgeMenu.currentEdge && edgeMenu.forLoop
395396

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

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

439450
onClicked: {
440-
uigraph.expandForLoop(edgeMenu.currentEdge)
451+
edgeMenu.currentEdge = uigraph.expandForLoop(edgeMenu.currentEdge)
441452
canExpand = false
442453
edgeMenu.close()
443454
}

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)