blob: ce282e873f7971c8231dc23007ed60ffa0df37d0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtCore
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick3D.Helpers
import QtQuick.Dialogs
import QtDataVisualization
import "."
Item {
id: mainView
width: 1280
height: 1024
TabBar {
id: tabBar
anchors.top: parent.top
anchors.right: panels.left
anchors.left: parent.left
contentHeight: 50
TabButton {
text: qsTr("Surface")
}
TabButton {
text: qsTr("Scatter")
}
TabButton {
text: qsTr("Bars")
}
}
Rectangle {
id: panels
anchors.top: parent.top
anchors.right: parent.right
anchors.bottom: parent.bottom
width: parent.width / 5
color: "green"
ColumnLayout {
id: buttonPanel
anchors.top: parent.top
width: parent.width
spacing: 10
visible: autoTest.finished
Button {
id: shadowToggle
property int shadowQuality: 0
property string qualityName: "None"
text: qsTr("Shadow Quality : %1").arg(qualityName)
Layout.fillWidth: true
Layout.preferredHeight: 50
Layout.margins: 10
Layout.alignment: Qt.AlignCenter
onClicked: {
var nextQuality = (shadowQuality + 1) % 7
surfaceGraph.shadowQuality = nextQuality
scatterGraph.shadowQuality = nextQuality
barGraph.shadowQuality = nextQuality
shadowQuality = nextQuality
qualityName = barGraph.shadowQuality.toString()
console.log("Set shadow quality to " + qualityName)
}
}
Button {
id: optimizationToggle
visible: tabBar.currentIndex > 0
property string optimization: "Default"
text: qsTr("Optimization: %1").arg(optimization)
Layout.fillWidth: true
Layout.preferredHeight: 50
Layout.margins: 10
Layout.alignment: Qt.AlignCenter
onClicked: {
if (optimization === "Static") {
scatterGraph.optimizationHints = AbstractGraph3D.OptimizationDefault
barGraph.optimizationHints = AbstractGraph3D.OptimizationDefault
optimization= "Default"
} else {
scatterGraph.optimizationHints = AbstractGraph3D.OptimizationStatic
barGraph.optimizationHints = AbstractGraph3D.OptimizationStatic
optimization = "Static"
}
console.log("Set optimization to " + optimization)
}
}
Button {
id: samplesButton
property list<int> samples: [0,2,4,8]
property int index: 0
text: qsTr("MSAA samples: %1").arg(samples[index])
Layout.fillWidth: true
Layout.preferredHeight: 50
Layout.margins: 10
Layout.alignment: Qt.AlignCenter
onClicked: {
index = (index + 1) % 4
surfaceGraph.msaaSamples = samples[index]
scatterGraph.msaaSamples = samples[index]
barGraph.msaaSamples = samples[index]
console.log("Set msaa samples to " + samples[index])
}
}
Button {
id: scatterMesh
visible: tabBar.currentIndex === 1
property string mesh: "Sphere"
text: qsTr("Mesh: %1").arg(mesh)
Layout.fillWidth: true
Layout.preferredHeight: 50
Layout.margins: 10
Layout.alignment: Qt.AlignCenter
onClicked: {
if (mesh === "Sphere") {
scatterSeries.mesh = Abstract3DSeries.MeshCube
mesh = "Cube"
} else if (mesh === "Cube") {
scatterSeries.mesh = Abstract3DSeries.MeshPyramid
mesh = "Pyramid"
} else if (mesh === "Pyramid") {
scatterSeries.mesh = Abstract3DSeries.MeshPoint
mesh = "Point"
} else {
scatterSeries.mesh = Abstract3DSeries.MeshSphere
mesh = "Sphere"
}
}
}
Button {
id: surfaceShadingToggle
visible: tabBar.currentIndex <= 2
text: qsTr("Flat shading: %1").arg(surfaceSeries.flatShadingEnabled.toString())
Layout.fillWidth: true
Layout.preferredHeight: 50
Layout.margins: 10
Layout.alignment: Qt.AlignCenter
onClicked: {
surfaceSeries.flatShadingEnabled =
!surfaceSeries.flatShadingEnabled
scatterSeries.meshSmooth = !scatterSeries.meshSmooth
}
}
Button {
id: gridToggle
visible: tabBar.currentIndex === 0
property bool gridEnabled
text: qsTr("Show grid: %1").arg(gridEnabled.toString())
Layout.fillWidth: true
Layout.preferredHeight: 50
Layout.margins: 10
Layout.alignment: Qt.AlignCenter
onClicked: {
if (surfaceSeries.drawMode & Surface3DSeries.DrawWireframe)
surfaceSeries.drawMode &= ~Surface3DSeries.DrawWireframe;
else
surfaceSeries.drawMode |= Surface3DSeries.DrawWireframe;
gridEnabled = surfaceSeries.drawMode & Surface3DSeries.DrawWireframe
}
}
ColumnLayout {
id: pointSetContainer
Layout.fillWidth: true
Layout.preferredHeight: 50
Layout.margins: 10
Layout.alignment: Qt.AlignCenter
Text {
id: spinboxTitle
text: "Side length"
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
}
SpinBox {
id: sizeField
from: 2
to: 500
stepSize: 20
value: 10
editable: true
Layout.preferredWidth: parent.width
}
Button {
id: pointSetButton
text: qsTr("Place points");
Layout.preferredWidth: parent.width
Layout.bottomMargin: 10
onClicked: {
switch (tabBar.currentIndex) {
case 0:
dataGenerator.generateSurfaceData(surfaceSeries, sizeField.value)
break;
case 1:
dataGenerator.generateScatterData(scatterSeries, sizeField.value)
break;
case 2:
dataGenerator.generateBarData(barSeries, sizeField.value)
break;
default:
break;
}
}
}
}
}
GridLayout {
id: checkBoxPanel
anchors.top: buttonPanel.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.margins: 10
visible: autoTest.finished
columns: 2
CheckBox {
id: liveDataCB
text: qsTr("Live Data")
Layout.fillWidth: true
Layout.margins: 10
Layout.alignment: Qt.AlignCenter
}
CheckBox {
id: rotateCB
text: qsTr("Rotation")
Layout.fillWidth: true
Layout.margins: 10
Layout.alignment: Qt.AlignCenter
}
ColumnLayout {
id: freqContainer
Layout.columnSpan: 2
Text {
text: qsTr("Frequency: %1").arg(frequencySlider.value)
Layout.fillWidth: true
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
}
Slider {
id: frequencySlider
from: 1
to: 60
stepSize: 1
value: 30
snapMode: Slider.SnapAlways
Layout.alignment: Qt.AlignCenter
}
}
}
AutoTest {
id: autoTest
width: parent.width
anchors.top: checkBoxPanel.bottom
anchors.left: parent.left
anchors.topMargin: 10
}
Tests {
id: tests
width: parent.width
anchors.top: autoTest.bottom
anchors.left: parent.left
buttonVisible: autoTest.finished
}
Button {
id: pathButton
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
text: "Set logfile path"
anchors.margins: 10
onClicked: folderDialog.open()
}
}
FolderDialog {
id: folderDialog
currentFolder: StandardPaths.standardLocations(StandardPaths.DocumentsLocation)[0]
onAccepted: dataGenerator.setFilePath(currentFolder)
}
Timer {
id: rotationTimer
interval: 15
running: rotateCB.checked
repeat: true
onTriggered: {
switch (tabBar.currentIndex) {
case 0:
if (++surfaceGraph.scene.activeCamera.xRotation == 360)
surfaceGraph.cameraXRotation = 0;
break
case 1:
if (++scatterGraph.scene.activeCamera.xRotation == 360)
scatterGraph.cameraXRotation = 0;
break
case 2:
if (++barGraph.scene.activeCamera.xRotation == 360)
barGraph.cameraXRotation = 0;
break
}
}
}
Timer {
id: updateTimer
interval: 1000 / frequencySlider.value
running: liveDataCB.checked
repeat: true
onTriggered: {
switch (tabBar.currentIndex) {
case 0:
dataGenerator.updateSurfaceData(surfaceSeries)
break
case 1:
dataGenerator.updateScatterData(scatterSeries)
break
case 2:
dataGenerator.updateBarData(barSeries)
break
}
}
}
StackLayout {
anchors.top: tabBar.bottom
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: panels.left
currentIndex: tabBar.currentIndex
Item {
id: surfaceTab
Surface3D {
id: surfaceGraph
anchors.fill: parent
shadowQuality: AbstractGraph3D.ShadowQualityNone
scene.activeCamera.yRotation: 45.0
measureFps: true
axisX.min: 0
axisX.max: 1
axisY.min: 0
axisY.max: 1
horizontalAspectRatio: 1.0
theme : Theme3D {
type: Theme3D.ThemeQt
colorStyle: Theme3D.ColorStyleRangeGradient
baseGradients: surfaceGradient
ColorGradient {
id: surfaceGradient
ColorGradientStop { position: 1.0; color: "red" }
ColorGradientStop { position: 0.0; color: "blue" }
}
}
Surface3DSeries {
id: surfaceSeries
dataProxy.onArrayReset: tests.dataPoints = dataProxy.columnCount * dataProxy.rowCount
}
onCurrentFpsChanged: {
tests.currentFps = currentFps
}
}
}
Item {
id: scatterTab
Scatter3D {
id: scatterGraph
anchors.fill: parent
shadowQuality: AbstractGraph3D.ShadowQualityNone
scene.activeCamera.yRotation: 45.0
aspectRatio: 1.0
horizontalAspectRatio: 1.0
axisY.min: -1
axisY.max: 1
axisX.min: -1
axisX.max: 1
axisZ.min: -1
axisZ.max: 1
measureFps: true
theme : Theme3D {
type: Theme3D.ThemeQt
colorStyle: Theme3D.ColorStyleRangeGradient
baseGradients: scatterGradient
ColorGradient {
id: scatterGradient
ColorGradientStop { position: 1.0; color: "yellow" }
ColorGradientStop { position: 0.6; color: "red" }
ColorGradientStop { position: 0.4; color: "blue" }
ColorGradientStop { position: 0.0; color: "green" }
}
}
Scatter3DSeries {
id: scatterSeries
dataProxy.onArrayReset: tests.dataPoints = dataProxy.itemCount
itemSize: 0.1
}
onCurrentFpsChanged: {
tests.currentFps = currentFps
}
}
}
Item {
id: barTab
Bars3D {
id: barGraph
anchors.fill: parent
shadowQuality: AbstractGraph3D.ShadowQualityNone
scene.activeCamera.yRotation: 45.0
measureFps: true
valueAxis.min: 0
valueAxis.max: 1
theme : Theme3D {
type: Theme3D.ThemeQt
colorStyle: Theme3D.ColorStyleRangeGradient
baseGradients: barGradient
ColorGradient{
id: barGradient
ColorGradientStop { position: 1.0; color: "red" }
ColorGradientStop { position: 0.0; color: "blue" }
}
}
Bar3DSeries {
id: barSeries
dataProxy.onArrayReset: tests.dataPoints
= dataProxy.colCount * dataProxy.rowCount
}
onCurrentFpsChanged: {
tests.currentFps = currentFps
}
}
}
}
}
|