From f53b9d177981936601d4fb297b4d7660efaf2c8c Mon Sep 17 00:00:00 2001 From: Aurore LAFAURIE Date: Mon, 26 Aug 2024 17:25:34 +0200 Subject: [PATCH] [ui] Value of current edge iteration and TaskManager protected --- meshroom/ui/graph.py | 10 ++++------ meshroom/ui/qml/GraphEditor/GraphEditor.qml | 13 ++++++++++++- meshroom/ui/qml/GraphEditor/TaskManager.qml | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/meshroom/ui/graph.py b/meshroom/ui/graph.py index bfef276654..7572078cca 100644 --- a/meshroom/ui/graph.py +++ b/meshroom/ui/graph.py @@ -759,24 +759,22 @@ def canExpandForLoop(self, currentEdge): return False return True - @Slot(Edge) + @Slot(Edge, result=Edge) def expandForLoop(self, currentEdge): """ Expand 'node' by creating all its output nodes. """ with self.groupedGraphModification("Expand For Loop Node"): listAttribute = currentEdge.src.root dst = currentEdge.dst - # First, replace the edge with the first element of the list - currentEdge = self.replaceEdge(currentEdge, listAttribute.at(0), dst) - - srcIndex = listAttribute.index(currentEdge.src) - dst = currentEdge.dst for i in range(1, len(listAttribute)): duplicates = self.duplicateNodesFrom(dst.node) newNode = duplicates[0] previousEdge = self.graph.edge(newNode.attribute(dst.name)) self.replaceEdge(previousEdge, listAttribute.at(i), previousEdge.dst) + # Last, replace the edge with the first element of the list + return self.replaceEdge(currentEdge, listAttribute.at(0), dst) + @Slot(Edge) def collapseForLoop(self, currentEdge): """ Collapse 'node' by removing all its output nodes. """ diff --git a/meshroom/ui/qml/GraphEditor/GraphEditor.qml b/meshroom/ui/qml/GraphEditor/GraphEditor.qml index 0bb9ca9a4b..1d8177eacc 100755 --- a/meshroom/ui/qml/GraphEditor/GraphEditor.qml +++ b/meshroom/ui/qml/GraphEditor/GraphEditor.qml @@ -389,11 +389,22 @@ Item { contentItem: Row { IntSelector { + id: loopIterationSelector tooltipText: "Iterations" visible: edgeMenu.currentEdge && edgeMenu.forLoop property var listAttr: edgeMenu.currentEdge ? edgeMenu.currentEdge.src.root : null + Connections { + target: edgeMenu + function onCurrentEdgeChanged() { + if (edgeMenu.currentEdge) { + loopIterationSelector.listAttr = edgeMenu.currentEdge.src.root + loopIterationSelector.value = loopIterationSelector.listAttr ? loopIterationSelector.listAttr.value.indexOf(edgeMenu.currentEdge.src) + 1 : 0 + } + } + } + // We add 1 to the index because of human readable index (starting at 1) value: listAttr ? listAttr.value.indexOf(edgeMenu.currentEdge.src) + 1 : 0 range: { "min": 1, "max": listAttr ? listAttr.value.count : 0 } @@ -436,7 +447,7 @@ Item { text: MaterialIcons.open_in_full onClicked: { - uigraph.expandForLoop(edgeMenu.currentEdge) + edgeMenu.currentEdge = uigraph.expandForLoop(edgeMenu.currentEdge) canExpand = false edgeMenu.close() } diff --git a/meshroom/ui/qml/GraphEditor/TaskManager.qml b/meshroom/ui/qml/GraphEditor/TaskManager.qml index bcdade1900..8d03b16987 100644 --- a/meshroom/ui/qml/GraphEditor/TaskManager.qml +++ b/meshroom/ui/qml/GraphEditor/TaskManager.qml @@ -264,7 +264,7 @@ Item { spacing: 3 delegate: Label { - width: (ListView.view.width / ListView.view.model.count) - 3 + width: ListView.view.model ? (ListView.view.width / ListView.view.model.count) - 3 : 0 height: ListView.view.height anchors.verticalCenter: parent.verticalCenter background: Rectangle {