Skip to content

Commit 123ef97

Browse files
committed
[GraphEditor] Iterations of for loop visible in NodeEditor (only UI by now)
1 parent 89f0390 commit 123ef97

File tree

2 files changed

+57
-27
lines changed

2 files changed

+57
-27
lines changed

meshroom/ui/qml/GraphEditor/NodeEditor.qml

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,37 @@ Panel {
257257
Controls1.SplitView {
258258
anchors.fill: parent
259259

260+
// The list of iterations
261+
NodeEditorElementsListView {
262+
id: iterationsLV
263+
visible: root.node.countForLoop > 0
264+
elements: {
265+
if (root.node.countForLoop == 0)
266+
return []
267+
var elements = []
268+
for (let i = 0; i < node.attributes.count; ++i) {
269+
if (node.attributes.at(i).isLink) {
270+
var srcAttr = node.attributes.at(i).linkParam
271+
for (let j = 0; j < srcAttr.root.value.count; ++j) {
272+
elements.push(j)
273+
}
274+
return elements
275+
}
276+
}
277+
}
278+
279+
// TODO to remove when the elements would be correct
280+
currentElement: elements[0]
281+
282+
isChunk: false
283+
title: "Iterations"
284+
}
285+
260286
// The list of chunks
261-
ChunksListView {
287+
NodeEditorElementsListView {
262288
id: chunksLV
263289
visible: (tabBar.currentIndex >= 1 && tabBar.currentIndex <= 3)
264-
chunks: root.node.chunks
290+
elements: root.node.chunks
265291
}
266292

267293
StackLayout {
@@ -295,7 +321,7 @@ Panel {
295321
id: nodeLog
296322
node: root.node
297323
currentChunkIndex: chunksLV.currentIndex
298-
currentChunk: chunksLV.currentChunk
324+
currentChunk: chunksLV.currentElement
299325
}
300326
}
301327

@@ -310,7 +336,7 @@ Panel {
310336
Layout.fillWidth: true
311337
node: root.node
312338
currentChunkIndex: chunksLV.currentIndex
313-
currentChunk: chunksLV.currentChunk
339+
currentChunk: chunksLV.currentElement
314340
}
315341
}
316342

@@ -325,7 +351,7 @@ Panel {
325351
Layout.fillWidth: true
326352
node: root.node
327353
currentChunkIndex: chunksLV.currentIndex
328-
currentChunk: chunksLV.currentChunk
354+
currentChunk: chunksLV.currentElement
329355
}
330356
}
331357

meshroom/ui/qml/GraphEditor/ChunksListView.qml renamed to meshroom/ui/qml/GraphEditor/NodeEditorElementsListView.qml

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,52 +8,56 @@ import Controls 1.0
88
import "common.js" as Common
99

1010
/**
11-
* ChunkListView
11+
* NodeEditorElementsListView
1212
*/
1313
ColumnLayout {
1414
id: root
15-
property variant chunks
15+
property variant elements
1616
property int currentIndex: 0
17-
property variant currentChunk: (chunks && currentIndex >= 0) ? chunks.at(currentIndex) : undefined
17+
property bool isChunk: true
18+
property string title: "Chunks"
1819

19-
onChunksChanged: {
20+
// TODO : change to currentElement
21+
property variant currentElement: (elements && currentIndex >= 0) ? elements.at(currentIndex) : undefined
22+
23+
onElementsChanged: {
2024
// When the list changes, ensure the current index is in the new range
21-
if (currentIndex >= chunks.count)
22-
currentIndex = chunks.count-1
25+
if (currentIndex >= elements.count)
26+
currentIndex = elements.count-1
2327
}
2428

25-
// chunksSummary is in sync with allChunks button (but not directly accessible as it is in a Component)
26-
property bool chunksSummary: (currentIndex === -1)
29+
// elementsSummary is in sync with allElements button (but not directly accessible as it is in a Component)
30+
property bool elementsSummary: (currentIndex === -1)
2731

28-
width: 60
32+
width: 75
2933

3034
ListView {
31-
id: chunksLV
35+
id: elementsLV
3236
Layout.fillWidth: true
3337
Layout.fillHeight: true
3438

35-
model: root.chunks
39+
model: root.elements
3640

37-
highlightFollowsCurrentItem: (root.chunksSummary === false)
41+
highlightFollowsCurrentItem: (root.elementsSummary === false)
3842
keyNavigationEnabled: true
3943
focus: true
4044
currentIndex: root.currentIndex
4145
onCurrentIndexChanged: {
42-
if (chunksLV.currentIndex !== root.currentIndex) {
46+
if (elementsLV.currentIndex !== root.currentIndex) {
4347
// When the list is resized, the currentIndex is reset to 0.
4448
// So here we force it to keep the binding.
45-
chunksLV.currentIndex = Qt.binding(function() { return root.currentIndex })
49+
elementsLV.currentIndex = Qt.binding(function() { return root.currentIndex })
4650
}
4751
}
4852

4953
header: Component {
5054
Button {
51-
id: allChunks
52-
text: "Chunks"
55+
id: allElements
56+
text: title
5357
width: parent.width
5458
flat: true
5559
checkable: true
56-
property bool summaryEnabled: root.chunksSummary
60+
property bool summaryEnabled: root.elementsSummary
5761
checked: summaryEnabled
5862
onSummaryEnabledChanged: {
5963
checked = summaryEnabled
@@ -66,7 +70,7 @@ ColumnLayout {
6670
}
6771
highlight: Component {
6872
Rectangle {
69-
visible: true // !root.chunksSummary
73+
visible: true // !root.elementsSummary
7074
color: activePalette.highlight
7175
opacity: 0.3
7276
z: 2
@@ -76,19 +80,19 @@ ColumnLayout {
7680
highlightResizeDuration: 0
7781

7882
delegate: ItemDelegate {
79-
id: chunkDelegate
80-
property var chunk: object
83+
id: elementDelegate
84+
property var element: object
8185
text: index
8286
width: parent ? parent.width : 0
8387
leftPadding: 8
8488
onClicked: {
85-
chunksLV.forceActiveFocus()
89+
elementsLV.forceActiveFocus()
8690
root.currentIndex = index
8791
}
8892
Rectangle {
8993
width: 4
9094
height: parent.height
91-
color: Common.getChunkColor(parent.chunk)
95+
color: isChunk ? Common.getChunkColor(parent.element) : palette.mid
9296
}
9397
}
9498
}

0 commit comments

Comments
 (0)