forked from UAVGCSTeam/GCS
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTelemetryPanel.qml
More file actions
203 lines (180 loc) · 7.97 KB
/
TelemetryPanel.qml
File metadata and controls
203 lines (180 loc) · 7.97 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
import QtQuick 2.15
import QtQuick.Layouts 1.15
import QtQuick.Controls 2.15
import "qrc:/gcsStyle" as GcsStyle
Rectangle {
// This is the container element
id: telemetryPanel
height: isExpanded ? 199 : 90 // 2.21 : 1
width: Math.min(parent.width * 0.5, 400)
color: GcsStyle.PanelStyle.isLightTheme ? "#80FFFFFF" : "#80000000"
radius: GcsStyle.PanelStyle.cornerRadius
anchors.horizontalCenter: parent.horizontalCenter
anchors.bottom: parent.bottom
anchors.bottomMargin: 8
property color borderColor: GcsStyle.PanelStyle.defaultBorderColor
property var activeDrone: null
property bool isExpanded: false
property var fieldRows: [
/*
This is used to determine which piece of drone data to pull from the DroneClass object.
(The DroneClass object is stored in the activeDrone var)
*/
[
{ label: "SYS ID", unit: "" },
{ label: "COMP ID", unit: "" },
{ label: "Flight Time", unit: "" },
],
[
{ label: "Yaw", unit: "°" },
{ label: "Pitch", unit: "°" },
{ label: "Roll", unit: "°" }
],
[
{ label: "Status", unit: "" },
{ label: "Mode", unit: "" },
{ label: "Fail Safe", unit: "" }
],
[
{ label: "Latitude", unit: "" },
{ label: "Longitude", unit: "" },
{ label: "Altitude", unit: "m" }
],
[
{ label: "Dist GCS", unit: "m" },
{ label: "Air Speed", unit: "m/s" },
{ label: "Gnd Speed", unit: "m/s" }
]
]
function setAttitudeWidth(w) {
attitudeWidth = w
}
MouseArea {
anchors.fill: parent
onClicked: {
isExpanded = !isExpanded
}
cursorShape: Qt.PointingHandCursor
}
ColumnLayout {
anchors.fill: parent
anchors.margins: 8
spacing: 4
// Top edge of panel
Rectangle {
Layout.fillWidth: true
height: 1
color: borderColor
}
// Repeater for each row
Repeater {
model: telemetryPanel.fieldRows.length
ColumnLayout {
Layout.fillWidth: true
Layout.fillHeight: true
visible: index > 2 || isExpanded // permanently leave last 2 rows visible
spacing: 4
property var rowFields: telemetryPanel.fieldRows[index]
RowLayout {
Layout.fillWidth: true
Layout.fillHeight: true
spacing: 0
Item {
// Using an Item so that we can use the anchor
// system on the Rectangle. This also matches the vertical
// bars on the right side
Layout.fillHeight: true
width: 1
Rectangle {
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.topMargin: -4
anchors.bottomMargin: -4
width: 1
color: borderColor
}
}
// Repeater for each field in row
Repeater {
model: rowFields
delegate: Item {
Layout.fillWidth: true
Layout.fillHeight: true
RowLayout {
anchors.centerIn: parent
spacing: 6
Text {
text: modelData.label
color: GcsStyle.PanelStyle.textPrimaryColor
font.pixelSize: GcsStyle.PanelStyle.fontSizeXS
font.family: GcsStyle.PanelStyle.fontFamily
Layout.alignment: Qt.AlignHCenter
}
Text {
text: {
if (activeDrone) {
if (modelData.label === "Latitude") { activeDrone.latitude.toFixed(3) }
else if (modelData.label === "Longitude") { activeDrone.longitude.toFixed(3) }
// sysID and compID are no longer implemented. might be implemented in the future
// else if (modelData.label === "SYS ID") { activeDrone.sysID }
// else if (modelData.label === "COMP ID") { activeDrone.compID }
else if (modelData.label === "Flight Time") { "---" }
else if (modelData.label === "Yaw") { activeDrone.orientation.z.toFixed(3) }
else if (modelData.label === "Pitch") { activeDrone.orientation.y.toFixed(3) }
else if (modelData.label === "Roll") { activeDrone.orientation.x.toFixed(3) }
else if (modelData.label === "Fail Safe") { "---" }
else if (modelData.label === "Status") { "---" }
else if (modelData.label === "Mode") { "---" }
else if (modelData.label === "Altitude") { activeDrone.altitude }
else if (modelData.label === "Dist GCS") { "---" }
else if (modelData.label === "Air Speed") { "---" }
else if (modelData.label === "Gnd Speed") { "---" }
else { "---" }
} else { "---" }
}
color: GcsStyle.PanelStyle.textPrimaryColor
font.pixelSize: GcsStyle.PanelStyle.fontSizeSmall
font.family: GcsStyle.PanelStyle.fontFamily
font.bold: true
}
Text {
text: modelData.unit || ""
color: GcsStyle.PanelStyle.textPrimaryColor
font.pixelSize: GcsStyle.PanelStyle.fontSizeSmall
font.family: GcsStyle.PanelStyle.fontFamily
visible: !!modelData.unit
}
}
// Separator between columns
Rectangle {
width: 1
anchors.right: parent.right
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.topMargin: -4
anchors.bottomMargin: -4
color: borderColor
}
}
}
}
// Divider between rows
Rectangle {
Layout.fillWidth: true
height: 1
color: borderColor
}
}
}
}
onActiveDroneChanged: {
if (activeDrone === null) {
telemetryPanel.visible = false;
} else {
telemetryPanel.visible = true;
}
}
function toggleExpanded() {
isExpanded = !isExpanded
}
}