Skip to content

Commit

Permalink
[ui] Value of current edge iteration and TaskManager protected
Browse files Browse the repository at this point in the history
  • Loading branch information
Just-Kiel committed Aug 27, 2024
1 parent c821f64 commit f53b9d1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
10 changes: 4 additions & 6 deletions meshroom/ui/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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. """
Expand Down
13 changes: 12 additions & 1 deletion meshroom/ui/qml/GraphEditor/GraphEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion meshroom/ui/qml/GraphEditor/TaskManager.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f53b9d1

Please sign in to comment.