forked from 3C-SCSU/Avatar
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBrainwaveReading.qml
More file actions
642 lines (594 loc) · 24.5 KB
/
Copy pathBrainwaveReading.qml
File metadata and controls
642 lines (594 loc) · 24.5 KB
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
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
import QtQuick.Dialogs
import Qt.labs.platform
import QtQuick 6.5
import QtQuick.Controls 6.4
import QtQuick.Layouts 1.15
import QtQuick.Window 2.15
import QtQuick3D 6.7
// Brainwave Reading view
Rectangle {
property string selectedModel: "Random Forest" // Can be "Random Forest", "GaussianNB", or "Deep Learning"
property string currentFramework: "PyTorch" // Can be "PyTorch", "TensorFlow", or "JAX"
color: "#718399"
Layout.fillWidth: true
Layout.fillHeight: true
Row {
anchors.fill: parent
spacing: width * 0.02
// Left Column
Column {
width: parent.width * 0.5
height: parent.height
spacing: height * 0.02
anchors.left: parent.left
// Control Mode
Row {
width: parent.width * 0.4
spacing: parent.width * 0.02
anchors.horizontalCenter: parent.horizontalCenter
Layout.alignment: Qt.AlignJustify // Ensures space between items
RadioButton {
id: manualControl
text: "Manual Control"
checked: true
font.pixelSize: parent.width * 0.05
contentItem: Text {
text: manualControl.text
color: "white"
font.pixelSize: manualControl.font.pixelSize
font.bold: true
verticalAlignment: Text.AlignVCenter
leftPadding: manualControl.indicator.width + manualControl.spacing
}
}
RadioButton {
id: autopilot
text: "Autopilot"
font.pixelSize: parent.width * 0.05
contentItem: Text {
text: autopilot.text
color: "white"
font.pixelSize: autopilot.font.pixelSize
font.bold: true
verticalAlignment: Text.AlignVCenter
leftPadding: autopilot.indicator.width + autopilot.spacing
}
}
}
// Brainwave Image with Transparent Button
Rectangle {
width: parent.width * 0.25
height: parent.height * 0.2
color: "#242c4d"
anchors.horizontalCenter: parent.horizontalCenter
Image {
source: "GUI_Pics/brain.png"
anchors.fill: parent
fillMode: Image.PreserveAspectFit
}
Button {
anchors.fill: parent
background: Item {
}
contentItem: Text {
text: "Read my mind..."
font.pixelSize: parent.width * 0.1
color: "white"
anchors.centerIn: parent
}
onClicked: backend.readMyMind()
}
}
// Model Prediction Section
Label {
text: "The model says ..."
color: "white"
font.pixelSize: parent.width * 0.03
anchors.horizontalCenter: parent.horizontalCenter
}
GroupBox {
width: parent.width * 0.4
height: parent.height * 0.15
anchors.horizontalCenter: parent.horizontalCenter
// Header with white background
Row {
width: parent.width
height: parent.height * 0.28
spacing: parent.width * 0.01
Rectangle {
color: "white"
width: parent.width * 0.5
height: parent.height
Text {
text: "Count"
font.bold: true
font.pixelSize: parent.width * 0.09
color: "black"
anchors.centerIn: parent
}
}
Rectangle {
color: "white"
width: parent.width * 0.5
height: parent.height
Text {
text: "Label"
font.bold: true
font.pixelSize: parent.width * 0.09
color: "black"
anchors.centerIn: parent
}
}
}
ListView {
id: predictionListView
Layout.fillWidth: true
Layout.fillHeight: true
model: ListModel {
}
delegate: RowLayout {
spacing: 150
Text {
text: model.count; font.bold: true; color: "white"; width: 80
}
Text {
text: model.label; font.bold: true; color: "white"; width: 80
}
}
}
}
// Action Buttons
Row {
width: parent.width * 0.6
height: parent.height * 0.08
spacing: parent.width * 0.02
anchors.horizontalCenter: parent.horizontalCenter
Button {
id: notThinking
text: "Not what I was thinking..."
font.pixelSize: parent.width * 0.03
width: parent.width * 0.5
height: parent.height
background: Rectangle {
color: "#242c4d"
}
contentItem: Text {
text: notThinking.text
color: "white"
font.pixelSize: notThinking.font.pixelSize
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
onClicked: backend.notWhatIWasThinking(manualInput.text)
}
Button {
id: executeBtn
text: "Action"
font.pixelSize: parent.width * 0.03
width: parent.width * 0.5
height: parent.height
background: Rectangle {
color: "#242c4d"
}
contentItem: Text {
text: executeBtn.text
color: "white"
font.pixelSize: executeBtn.font.pixelSize
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
onClicked: backend.executeAction()
}
}
// Manual Input and Keep Alive
Row {
width: parent.width * .8
height: parent.height * 0.03
spacing: parent.width * 0.01
anchors.horizontalCenter: parent.horizontalCenter
TextField {
id: manualInput
placeholderText: "Manual Command"
font.pixelSize: parent.width * 0.03
width: parent.width * 0.6
height: parent.height
}
Button {
width: parent.width * 0.3
height: parent.height
background: Rectangle {
color: "#242c4d"
}
contentItem: Text {
text: qsTr("Run")
color: "white"
font.pixelSize: parent.height * 0.5
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
anchors.fill: parent
}
onClicked: backend.keepDroneAlive()
}
}
// Flight Log
GroupBox {
title: "Flight Log"
width: parent.width * 0.5
height: parent.height * 0.2
anchors.horizontalCenter: parent.horizontalCenter
label: Text {
text: qsTr("Flight Log"); font.bold: true; color: "white"
}
Rectangle {
anchors.fill: parent
color: "white"
ListView {
id: flightLogView
anchors.fill: parent
model: ListModel {
}
delegate: Text {
text: log
font.pixelSize: parent.width * 0.03
font.bold: true
color: "white"
}
}
}
}
Connections {
target: backend // Now properly defined through context property function onImagesReady(imageData) {
function onImagesReady(imageData) {
imageModel.clear();
for (let item of imageData) {
imageModel.append(item);
}
}
function onLogMessage(message) {
var timestamp = new Date().toLocaleString()
consoleLog.append(message + " at " + timestamp)
}
}
// Connect Image with Transparent Button
Row {
width: parent.width
height: parent.height * 0.3
spacing: width * 0.02
anchors.horizontalCenter: parent.horizontalCenter
// Connect Button with Image
Rectangle {
width: parent.width * 0.2
height: parent.height * 0.5
color: "#242c4d"
Image {
source: "GUI_Pics/connect.png"
anchors.fill: parent
fillMode: Image.PreserveAspectFit
}
Button {
anchors.fill: parent
background: Item {
}
contentItem: Text {
text: "Connect"
font.pixelSize: parent.width * 0.1
color: "white"
anchors.centerIn: parent
}
onClicked: backend.connectDrone()
}
}
// Model Selection Buttons: Random Forest, GaussianNB, Deep Learning
Row {
width: parent.width * 0.5
height: parent.height * 0.3
spacing: height * 0.05
// Random Forest Button
Rectangle {
width: (parent.width - parent.spacing * 2) / 3
height: parent.height
color: "#2d7a4a"
radius: 5
border.color: selectedModel === "Random Forest" ? "yellow" : "#4a9d6f"
border.width: selectedModel === "Random Forest" ? 3 : 1
Text {
text: "Random\nForest"
font.pixelSize: parent.width * 0.12
font.bold: true
color: selectedModel === "Random Forest" ? "yellow" : "white"
anchors.centerIn: parent
horizontalAlignment: Text.AlignHCenter
}
MouseArea {
anchors.fill: parent
onClicked: {
selectedModel = "Random Forest";
backend.selectModel("Random Forest")
}
}
}
// GaussianNB Button
Rectangle {
width: (parent.width - parent.spacing * 2) / 3
height: parent.height
color: "#2d7a4a"
radius: 5
border.color: selectedModel === "GaussianNB" ? "yellow" : "#4a9d6f"
border.width: selectedModel === "GaussianNB" ? 3 : 1
Text {
text: "GaussianNB"
font.pixelSize: parent.width * 0.12
font.bold: true
color: selectedModel === "GaussianNB" ? "yellow" : "white"
anchors.centerIn: parent
horizontalAlignment: Text.AlignHCenter
}
MouseArea {
anchors.fill: parent
onClicked: {
selectedModel = "GaussianNB";
backend.selectModel("GaussianNB")
}
}
}
// Deep Learning Button
Rectangle {
width: (parent.width - parent.spacing * 2) / 3
height: parent.height
color: "#2d7a4a"
radius: 5
border.color: selectedModel === "Deep Learning" ? "yellow" : "#4a9d6f"
border.width: selectedModel === "Deep Learning" ? 3 : 1
Text {
text: "Deep\nLearning"
font.pixelSize: parent.width * 0.12
font.bold: true
color: selectedModel === "Deep Learning" ? "yellow" : "white"
anchors.centerIn: parent
horizontalAlignment: Text.AlignHCenter
}
MouseArea {
anchors.fill: parent
onClicked: {
selectedModel = "Deep Learning";
backend.selectModel("Deep Learning")
}
}
}
}
// Synthetic Data and Live Data Radio Buttons
Column {
width: parent.width * 0.2
height: parent.height
spacing: height * 0.01
RadioButton {
id: syntheticRadio
text: "Synthetic Data"
font.pixelSize: parent.width * 0.1
font.bold: true
checked: false
contentItem: Text {
text: syntheticRadio.text
color: "white"
font.pixelSize: syntheticRadio.font.pixelSize
font.bold: syntheticRadio.font.bold
verticalAlignment: Text.AlignVCenter
leftPadding: syntheticRadio.indicator.width + syntheticRadio.spacing
}
onClicked: backend.setDataMode("synthetic")
}
RadioButton {
id: liveRadio
text: "Live Data"
font.pixelSize: parent.width * 0.1
font.bold: true
checked: true
contentItem: Text {
text: liveRadio.text
color: "white"
font.pixelSize: liveRadio.font.pixelSize
font.bold: liveRadio.font.bold
verticalAlignment: Text.AlignVCenter
leftPadding: liveRadio.indicator.width + liveRadio.spacing
}
onClicked: backend.setDataMode("live")
}
}
// PyTorch and TensorFlow Framework Buttons
Row {
width: parent.width * 0.7
height: parent.height * 0.3
spacing: height * 0.1
//PyTorch Button
Rectangle {
width: parent.width * 0.33
height: parent.height
color: "#2d7a4a"
radius: 5
border.color: currentFramework === "PyTorch" ? "yellow" : "#4a9d6f"
border.width: currentFramework === "PyTorch" ? 3 : 1
Text {
text: "PyTorch"
font.pixelSize: parent.width * 0.08
font.bold: true
color: currentFramework === "PyTorch" ? "yellow" : "white"
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
currentFramework = "PyTorch"
backend.selectFramework("PyTorch")
}
}
}
//TensorFlow Button
Rectangle {
width: parent.width * 0.33
height: parent.height
color: "#2d7a4a"
radius: 5
border.color: currentFramework === "TensorFlow" ? "yellow" : "#4a9d6f"
border.width: currentFramework === "TensorFlow" ? 3 : 1
Text {
text: "TensorFlow"
font.pixelSize: parent.width * 0.08
font.bold: true
color: currentFramework === "TensorFlow" ? "yellow" : "white"
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
currentFramework = "TensorFlow"
backend.selectFramework("TensorFlow")
}
}
}
//JAX Button
Rectangle {
width: parent.width * 0.33
height: parent.height
color: "#2d7a4a"
radius: 5
border.color: currentFramework === "JAX" ? "yellow" : "#4a9d6f"
border.width: currentFramework === "JAX" ? 3 : 1
Text {
text: "JAX"
font.pixelSize: parent.width * 0.08
font.bold: true
color: currentFramework === "JAX" ? "yellow" : "white"
anchors.centerIn: parent
}
MouseArea {
anchors.fill: parent
onClicked: {
currentFramework = "JAX"
backend.selectFramework("JAX")
}
}
}
}
}
}
// Right Column (Prediction Table and Console Log)
Column {
width: parent.width * 0.45
height: parent.height
spacing: parent.height * 0.01
anchors.right: parent.right
// Predictions Table
GroupBox {
title: "Predictions Table"
width: parent.width * 0.8
height: parent.height * 0.4
label: Text {
text: qsTr("Predictions Table")
color: "white"
font.pixelSize: parent.width * 0.03
font.bold: true
anchors.left: parent.left
anchors.leftMargin: 10
anchors.top: parent.top
anchors.topMargin: 5
}
// Header with white background
Row {
width: parent.width
height: parent.height * 0.1
spacing: parent.width * 0.001
Rectangle {
color: "white"
width: parent.width * 0.33
height: parent.height
Text {
text: "Predictions Count"
font.bold: true
font.pixelSize: parent.width * 0.09
color: "black"
anchors.centerIn: parent
}
}
Rectangle {
color: "white"
width: parent.width * 0.33
height: parent.height
Text {
text: "Server Predictions"
font.bold: true
font.pixelSize: parent.width * 0.09
color: "black"
anchors.centerIn: parent
}
}
Rectangle {
color: "white"
width: parent.width * 0.33
height: parent.height
Text {
text: "Prediction Label"
font.bold: true
font.pixelSize: parent.width * 0.09
color: "black"
anchors.centerIn: parent
}
}
}
ListView {
Layout.preferredWidth: 700
Layout.preferredHeight: 550
model: ListModel {
ListElement {
count: "1"; server: "Prediction A"; label: "Label A"
}
ListElement {
count: "2"; server: "Prediction B"; label: "Label B"
}
}
delegate: Rectangle {
width: parent.width
height: 40
color: "white"
RowLayout {
anchors.fill: parent
spacing: 50
Text {
text: model.count; font.bold: true; color: "black"; width: 120
}
Text {
text: model.server; font.bold: true; color: "black"; width: 200
}
Text {
text: model.label; font.bold: true; color: "black"; width: 120
}
}
}
}
}
GroupBox {
title: "Console Log"
width: parent.width * 0.6
height: parent.height * 0.3
label: Text {
text: qsTr("Console Log");
font.bold: true;
color: "white"
}
ScrollView {
anchors.fill: parent
clip: true
TextArea {
id: consoleLog
wrapMode: Text.WrapAnywhere
readOnly: true
font.pixelSize: parent.width * 0.03
color: "black"
background: Rectangle { color: "white" }
}
}
}
}
}
}