Skip to content

Commit 073efc2

Browse files
committed
Complete rework of preprocess and postprocess chunks
1 parent e23ee67 commit 073efc2

8 files changed

Lines changed: 222 additions & 99 deletions

File tree

meshroom/core/node.py

Lines changed: 93 additions & 80 deletions
Large diffs are not rendered by default.

meshroom/ui/graph.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,14 +435,18 @@ def onGraphUpdated(self):
435435
self.updateChunks()
436436

437437
def updateChunks(self):
438-
dfsNodes = self._graph.dfsOnFinish(None)[0]
438+
dfsNodes: list[Node] = self._graph.dfsOnFinish(None)[0]
439439
chunks = []
440440
for node in dfsNodes:
441+
if node._preprocessChunk:
442+
chunks.append(node._preprocessChunk)
441443
if node._chunksCreated:
442444
nodechunks = node.getChunks()
443445
chunks.extend(nodechunks)
444446
else:
445447
chunks.extend(node.chunkPlaceholder)
448+
if node._postprocessChunk:
449+
chunks.append(node._postprocessChunk)
446450
if self._sortedDFSChunks.objectList() == chunks:
447451
# Nothing has changed, return
448452
return

meshroom/ui/qml/Application.qml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1191,12 +1191,11 @@ Page {
11911191
spacing: 4
11921192

11931193
// "ProgressBar" reflecting status of all the chunks in the graph, in their process order
1194-
NodeChunks {
1194+
ApplicationChunks {
11951195
id: chunksListView
11961196
height: 6
11971197
Layout.fillWidth: true
11981198
model: _currentScene ? _currentScene.sortedDFSChunks : null
1199-
highlightChunks: false
12001199
}
12011200

12021201
MSplitView {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import QtQuick
2+
3+
import Utils 1.0
4+
5+
ListView {
6+
id: root
7+
interactive: false
8+
9+
SystemPalette { id: activePalette }
10+
11+
property color defaultColor: Qt.darker(activePalette.window, 1.1)
12+
property int modelSize: model ? model.count : 0
13+
property bool modelIsBig: (3 * modelSize >= width)
14+
property real chunkWidth: {
15+
if (modelSize == 0) return 0
16+
return (width / modelSize) - spacing
17+
}
18+
19+
orientation: ListView.Horizontal
20+
21+
// If we have enough space, add one pixel margin between chunks
22+
spacing: modelIsBig ? 0 : 1
23+
delegate: Rectangle {
24+
id: chunkDelegate
25+
height: root.height
26+
width: root.chunkWidth
27+
property var chunkColor: Colors.getChunkColor(object, { "NONE": root.defaultColor })
28+
color: {
29+
if (index % 2 == 0)
30+
return Qt.lighter(chunkColor, 1.1)
31+
else
32+
return Qt.darker(chunkColor, 1.1)
33+
}
34+
}
35+
}

meshroom/ui/qml/GraphEditor/ChunksListView.qml

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,25 @@ ColumnLayout {
1818
}
1919

2020
property var uigraph: null
21-
property variant chunks
21+
property variant chunks // Chunks model : list of NodeChunk
2222
property int currentIndex: 0
2323

2424
function getCurrentChunkIndex() {
25-
if ( currentIndex == undefined || !chunks || currentIndex == ChunksListView.IndexItems.NULL ) { return -1 }
26-
let hasPreprocess = chunks.some(function(chk) { return chk.chunkIndex == ChunksListView.IndexItems.PREPROCESS })
27-
let hasPostprocess = chunks.some(function(chk) { return chk.chunkIndex == ChunksListView.IndexItems.POSTPROCESS })
28-
if ( currentIndex == ChunksListView.IndexItems.PREPROCESS ) return hasPreprocess ? 0 : -1 // Preprocess chunk
29-
if ( currentIndex == ChunksListView.IndexItems.POSTPROCESS ) return hasPostprocess ? chunks.length - 1 : -1 // Postprocess chunk
30-
return currentIndex + (hasPreprocess ? 1 : 0) // Process Chunk
25+
if ( currentIndex == undefined || !chunks || currentIndex == ChunksListView.IndexItems.NULL ) {
26+
return -1
27+
}
28+
let hasPreprocess = chunks[0].chunkNode.hasPreprocessChunk
29+
let hasPostprocess = chunks[0].chunkNode.hasPostprocessChunk
30+
// Preprocess chunk
31+
if ( currentIndex == ChunksListView.IndexItems.PREPROCESS ) {
32+
return hasPreprocess ? 0 : -1
33+
}
34+
// Postprocess chunk
35+
if ( currentIndex == ChunksListView.IndexItems.POSTPROCESS ) {
36+
return hasPostprocess ? chunks.length - 1 : -1
37+
}
38+
// Process Chunk
39+
return currentIndex + (hasPreprocess ? 1 : 0)
3140
}
3241

3342
property int currentItemIndex: getCurrentChunkIndex()
@@ -87,8 +96,8 @@ ColumnLayout {
8796

8897
delegate: ItemDelegate {
8998
id: chunkDelegate
90-
property var chunk: modelData.chunk
91-
text: modelData.name
99+
property var chunk: modelData
100+
text: modelData.chunkIndexName
92101
highlighted: (currentItemIndex >= 0 && index == currentItemIndex)
93102
property int chunkIndex: modelData.chunkIndex
94103
width: ListView.view.width
@@ -109,7 +118,7 @@ ColumnLayout {
109118
target: _currentScene
110119
function onSelectedChunkChanged() {
111120
for (var i = 0; i < root.chunks.length; i++) {
112-
if (_currentScene.selectedChunk === root.chunks[i].chunk) {
121+
if (_currentScene.selectedChunk === root.chunks[i]) {
113122
root.currentIndex = i
114123
break;
115124
}

meshroom/ui/qml/GraphEditor/Node.qml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,7 @@ Item {
565565
defaultColor: Colors.sysPalette.mid
566566
implicitHeight: 3
567567
width: parent.width
568+
568569
model: {
569570
if (node && node.chunksCreated)
570571
return node.chunks
@@ -573,6 +574,8 @@ Item {
573574

574575
return undefined
575576
}
577+
preprocessChunk: node && node.hasPreprocessChunk ? node.preprocessChunk : null
578+
postprocessChunk: node && node.hasPostprocessChunk ? node.postprocessChunk : null
576579

577580
Rectangle {
578581
anchors.fill: parent

meshroom/ui/qml/GraphEditor/NodeChunks.qml

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,90 @@ ListView {
1111

1212
property var targetNode: null
1313

14+
// Pre/Post process chunk objects (single items)
15+
property var preprocessChunk: null
16+
property var postprocessChunk: null
17+
1418
property color defaultColor: Qt.darker(activePalette.window, 1.1)
1519
property real chunkHeight: height
1620
property int modelSize: model ? model.count : 0
17-
property bool modelIsBig: (3 * modelSize >= width)
21+
22+
// Account for header/footer in width calculations
23+
property bool hasHeader: preprocessChunk !== null
24+
property bool hasFooter: postprocessChunk !== null
25+
property int totalChunks: modelSize + (hasHeader ? 1 : 0) + (hasFooter ? 1 : 0)
26+
27+
property bool modelIsBig: (3 * totalChunks >= width)
1828
property real chunkWidth: {
19-
if (modelSize == 0) return 0
20-
return (width / modelSize) - spacing
29+
if (totalChunks == 0) return 0
30+
return (width / totalChunks) - spacing
2131
}
2232

2333
orientation: ListView.Horizontal
2434

2535
// If we have enough space, add one pixel margin between chunks
2636
spacing: modelIsBig ? 0 : 1
37+
38+
// Header: Preprocess chunk
39+
header: Loader {
40+
active: root.hasHeader
41+
visible: active
42+
43+
sourceComponent: Rectangle {
44+
height: root.chunkHeight
45+
width: root.chunkWidth
46+
47+
property var chunkColor: Colors.getChunkColor(root.preprocessChunk, { "NONE": root.defaultColor })
48+
color: {
49+
if (!root.highlightChunks || root.totalChunks == 1)
50+
return chunkColor
51+
// Index 0 for header
52+
return Qt.lighter(chunkColor, 1.1)
53+
}
54+
}
55+
}
56+
57+
// Main delegate for chunks list
2758
delegate: Rectangle {
2859
id: chunkDelegate
2960
height: root.chunkHeight
3061
width: root.chunkWidth
62+
3163
property var chunkColor: Colors.getChunkColor(object, { "NONE": root.defaultColor })
3264
color: {
33-
if (!highlightChunks || modelSize == 1)
65+
if (!root.highlightChunks || root.totalChunks == 1)
3466
return chunkColor
35-
if (index % 2 == 0)
67+
68+
// Offset index by 1 if we have a header for alternating colors
69+
var effectiveIndex = root.hasHeader ? index + 1 : index
70+
if (effectiveIndex % 2 == 0)
3671
return Qt.lighter(chunkColor, 1.1)
3772
else
3873
return Qt.darker(chunkColor, 1.1)
3974
}
4075
}
41-
}
76+
77+
// Footer: Postprocess chunk
78+
footer: Loader {
79+
active: root.hasFooter
80+
visible: active
81+
82+
sourceComponent: Rectangle {
83+
height: root.chunkHeight
84+
width: root.chunkWidth
85+
86+
property var chunkColor: Colors.getChunkColor(root.postprocessChunk, { "NONE": root.defaultColor })
87+
color: {
88+
if (!root.highlightChunks || root.totalChunks == 1)
89+
return chunkColor
90+
91+
// Calculate effective index for alternating colors
92+
var effectiveIndex = root.modelSize + (root.hasHeader ? 1 : 0)
93+
if (effectiveIndex % 2 == 0)
94+
return Qt.lighter(chunkColor, 1.1)
95+
else
96+
return Qt.darker(chunkColor, 1.1)
97+
}
98+
}
99+
}
100+
}

meshroom/ui/qml/GraphEditor/qmldir

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ GraphEditor 1.0 GraphEditor.qml
44
NodeEditor 1.0 NodeEditor.qml
55
Node 1.0 Node.qml
66
NodeChunks 1.0 NodeChunks.qml
7+
ApplicationChunks 1.0 ApplicationChunks.qml
78
Edge 1.0 Edge.qml
89
Backdrop 1.0 Backdrop.qml
910
AttributePin 1.0 AttributePin.qml

0 commit comments

Comments
 (0)