-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Expand file tree
/
Copy pathGimbalIndicator.qml
More file actions
335 lines (287 loc) · 13.5 KB
/
Copy pathGimbalIndicator.qml
File metadata and controls
335 lines (287 loc) · 13.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
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import QGroundControl
import QGroundControl.Controls
import QGroundControl.FactControls
Item {
id: control
anchors.top: parent.top
anchors.bottom: parent.bottom
width: gimbalIndicatorRow.width
property bool showIndicator: gimbalController.gimbals.count
property var activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
property var gimbalController: activeVehicle.gimbalController
property var gimbals: gimbalController.gimbals
property var activeGimbal: gimbalController.activeGimbal
property var multiGimbalSetup: gimbalController.gimbals.count > 1
property bool joystickButtonsAvailable: activeVehicle ? joystickManager.activeJoystickEnabledForActiveVehicle : false
property bool showAzimuth: QGroundControl.settingsManager.gimbalControllerSettings.toolbarIndicatorShowAzimuth.rawValue
property var margins: ScreenTools.defaultFontPixelWidth
property var panelRadius: ScreenTools.defaultFontPixelWidth * 0.5
property var buttonHeight: height * 1.6
property var squareButtonPadding: ScreenTools.defaultFontPixelWidth
property var separatorHeight: buttonHeight * 0.9
property var settingsPanelVisible: false
property var _gimbalControllerSettings: QGroundControl.settingsManager.gimbalControllerSettings
QGCPalette { id: qgcPal }
Row {
id: gimbalIndicatorRow
anchors.top: parent.top
anchors.bottom: parent.bottom
spacing: ScreenTools.defaultFontPixelWidth / 2
Column {
anchors.top: parent.top
anchors.bottom: parent.bottom
spacing: 0
QGCColoredImage {
id: gimbalIndicatorIcon
anchors.horizontalCenter: parent.horizontalCenter
width: height
height: multiGimbalSetup ? parent.height - gimbalIdLabel.contentHeight : parent.height
source: "/res/CameraGimbal.png"
fillMode: Image.PreserveAspectFit
sourceSize.height: height
color: qgcPal.text
}
QGCLabel {
id: gimbalIdLabel
anchors.horizontalCenter: parent.horizontalCenter
font.pointSize: ScreenTools.smallFontPointSize
text: activeGimbal ? activeGimbal.deviceId.rawValue : ""
color: qgcPal.text
visible: multiGimbalSetup
}
}
// Telemetry and status indicator
GridLayout {
anchors.verticalCenter: parent.verticalCenter
columns: 2
rows: 2
rowSpacing: 0
columnSpacing: margins / 2
QGCLabel {
id: statusLabel
font.pointSize: ScreenTools.smallFontPointSize
text: activeGimbal && activeGimbal.retracted ?
qsTr("Retracted") :
(activeGimbal && activeGimbal.yawLock ? qsTr("Yaw locked") : qsTr("Yaw follow"))
color: qgcPal.text
Layout.columnSpan: 2
Layout.alignment: Qt.AlignHCenter
}
QGCLabel {
id: pitchLabel
font.pointSize: ScreenTools.smallFontPointSize
text: activeGimbal ? qsTr("P: ") + activeGimbal.absolutePitch.valueString : ""
color: qgcPal.text
}
QGCLabel {
id: panLabel
font.pointSize: ScreenTools.smallFontPointSize
text: activeGimbal ?
(showAzimuth ?
(qsTr("Az: ") + activeGimbal.absoluteYaw.valueString) :
(qsTr("Y: ") + activeGimbal.bodyYaw.valueString)) :
""
color: qgcPal.text
}
}
}
MouseArea {
anchors.fill: parent
onClicked: mainWindow.showIndicatorDrawer(gimbalPopup, control)
}
Component {
id: gimbalPopup
ToolIndicatorPage {
showExpand: true
waitForParameters: false
contentComponent: gimbalContentComponent
expandedComponent: gimbalExpandedComponent
}
}
Component {
id: gimbalContentComponent
ColumnLayout {
spacing: ScreenTools.defaultFontPixelWidth / 2
SettingsGroupLayout {
heading: qsTr("Active Gimbal")
visible: multiGimbalSetup
QGCComboBox {
id: gimbalSelectorCombo
Layout.fillWidth: true
visible: multiGimbalSetup
onCurrentIndexChanged: gimbalController.activeGimbal = gimbalController.gimbals.get(currentIndex)
function _updateComboModel() {
let gimbalModel = []
let activeIndex = -1
for (var i = 0; i < gimbals.count; i++) {
var gimbal = gimbals.get(i)
gimbalModel.push(qsTr("Gimbal %1").arg(gimbal.deviceId.valueString))
if (gimbal === activeGimbal) {
activeIndex = i
}
}
gimbalSelectorCombo.model = gimbalModel
gimbalSelectorCombo.currentIndex = activeIndex
}
Component.onCompleted: _updateComboModel()
Connections {
target: gimbals
function onCountChanged(count) { _updateComboModel() }
}
}
}
SettingsGroupLayout {
heading: qsTr("Commands")
showDividers: false
QGCButton {
Layout.fillWidth: true
text: activeGimbal.yawLock ? qsTr("Yaw Follow") : qsTr("Yaw Lock")
visible: activeGimbal.supportsYawLock
onClicked: {
gimbalController.setGimbalYawLock(!activeGimbal.yawLock)
mainWindow.closeIndicatorDrawer()
}
}
QGCButton {
Layout.fillWidth: true
text: qsTr("Center")
onClicked: {
gimbalController.centerGimbal()
mainWindow.closeIndicatorDrawer()
}
}
QGCButton {
Layout.fillWidth: true
text: qsTr("Tilt 90")
onClicked: {
gimbalController.tilt90Gimbal()
mainWindow.closeIndicatorDrawer()
}
}
QGCButton {
Layout.fillWidth: true
text: qsTr("Point Home")
onClicked: {
activeVehicle.guidedModeROI(activeVehicle.homePosition)
mainWindow.closeIndicatorDrawer()
}
}
QGCButton {
Layout.fillWidth: true
text: qsTr("Retract")
visible: activeGimbal.supportsRetract
onClicked: {
gimbalController.setGimbalRetract(true)
mainWindow.closeIndicatorDrawer()
}
}
QGCButton {
Layout.fillWidth: true
text: activeGimbal.gimbalHaveControl ? qsTr("Release Control") : qsTr("Acquire Control")
visible: _gimbalControllerSettings.toolbarIndicatorShowAcquireReleaseControl.rawValue
onClicked: {
activeGimbal.gimbalHaveControl ? gimbalController.releaseGimbalControl() : gimbalController.acquireGimbalControl()
mainWindow.closeIndicatorDrawer()
}
}
}
}
}
Component {
id: gimbalExpandedComponent
ColumnLayout {
spacing: ScreenTools.defaultFontPixelWidth / 2
SettingsGroupLayout {
heading: qsTr("On-Screen Control")
showDividers: false
FactCheckBoxSlider {
id: enableOnScreenControlCheckbox
Layout.fillWidth: true
text: qsTr("Enabled")
fact: _gimbalControllerSettings.enableOnScreenControl
}
FactCheckBoxSlider {
Layout.fillWidth: true
text: qsTr("Click and drag")
fact: _gimbalControllerSettings.clickAndDrag
visible: enableOnScreenControlCheckbox.checked
}
LabelledFactTextField {
label: qsTr("Horizontal FOV")
fact: _gimbalControllerSettings.cameraHFov
visible: enableOnScreenControlCheckbox.checked && !_gimbalControllerSettings.clickAndDrag.rawValue
}
LabelledFactTextField {
label: qsTr("Vertical FOV")
fact: _gimbalControllerSettings.cameraVFov
visible: enableOnScreenControlCheckbox.checked && !_gimbalControllerSettings.clickAndDrag.rawValue
}
LabelledFactTextField {
label: qsTr("Max speed")
fact: _gimbalControllerSettings.cameraSlideSpeed
visible: enableOnScreenControlCheckbox.checked && _gimbalControllerSettings.clickAndDrag.rawValue
}
}
SettingsGroupLayout {
heading: qsTr("Zoom speed")
showDividers: false
LabelledFactTextField {
label: qsTr("Max speed (min zoom)")
fact: _gimbalControllerSettings.zoomMaxSpeed
}
LabelledFactTextField {
label: qsTr("Min speed (max zoom)")
fact: _gimbalControllerSettings.zoomMinSpeed
}
}
SettingsGroupLayout {
LabelledFactTextField {
label: qsTr("Joystick buttons speed:")
fact: _gimbalControllerSettings.joystickButtonsSpeed
enabled: joystickButtonsAvailable && _gimbalControllerSettings.visible
}
FactCheckBoxSlider {
Layout.fillWidth: true
text: qsTr("Show gimbal Azimuth indicator in map")
fact: _gimbalControllerSettings.showAzimuthIndicatorOnMap
}
FactCheckBoxSlider {
Layout.fillWidth: true
text: qsTr("Use Azimuth instead of local yaw on top toolbar indicator")
fact: _gimbalControllerSettings.toolbarIndicatorShowAzimuth
}
FactCheckBoxSlider {
Layout.fillWidth: true
text: qsTr("Show Acquire/Release control button")
fact: _gimbalControllerSettings.toolbarIndicatorShowAcquireReleaseControl
}
FactCheckBoxSlider {
Layout.fillWidth: true
text: qsTr("Preserve yaw lock status on tilt 90 and center commands, don't force yaw follow")
fact: _gimbalControllerSettings.preserveYawLockOnPositionCommands
}
}
}
}
Connections {
id: acquirePopupConnection
property bool isPopupOpen: false
target: gimbalController
function onShowAcquireGimbalControlPopup() {
if(!acquirePopupConnection.isPopupOpen){
acquirePopupConnection.isPopupOpen = true;
QGroundControl.showMessageDialog(
control,
"Request Gimbal Control?",
"Command not sent. Another user has control of the gimbal.",
Dialog.Yes | Dialog.No,
gimbalController.acquireGimbalControl,
function() { acquirePopupConnection.isPopupOpen = false }
)
}
}
}
}