-
Notifications
You must be signed in to change notification settings - Fork 3.9k
/
Copy pathFWLandingPatternEditor.qml
358 lines (301 loc) · 13.3 KB
/
FWLandingPatternEditor.qml
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
/****************************************************************************
*
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
*
* QGroundControl is licensed according to the terms in the file
* COPYING.md in the root of the source code directory.
*
****************************************************************************/
import QtQuick
import QtQuick.Controls
import QtQuick.Dialogs
import QtQuick.Layouts
import QGroundControl
import QGroundControl.ScreenTools
import QGroundControl.Vehicle
import QGroundControl.Controls
import QGroundControl.FactSystem
import QGroundControl.FactControls
import QGroundControl.Palette
// Editor for Fixed Wing Landing Pattern complex mission item
Rectangle {
id: _root
height: visible ? ((editorColumn.visible ? editorColumn.height : editorColumnNeedLandingPoint.height) + (_margin * 2)) : 0
width: availableWidth
color: qgcPal.windowShadeDark
radius: _radius
// The following properties must be available up the hierarchy chain
//property real availableWidth ///< Width for control
//property var missionItem ///< Mission Item for editor
property var _masterControler: masterController
property var _missionController: _masterControler.missionController
property var _missionVehicle: _masterControler.controllerVehicle
property real _margin: ScreenTools.defaultFontPixelWidth / 2
property real _spacer: ScreenTools.defaultFontPixelWidth / 2
property string _setToVehicleHeadingStr: qsTr("Set to vehicle heading")
property string _setToVehicleLocationStr: qsTr("Set to vehicle location")
property bool _showCameraSection: !_missionVehicle.apmFirmware
property int _altitudeMode: missionItem.altitudesAreRelative ? QGroundControl.AltitudeModeRelative : QGroundControl.AltitudeModeAbsolute
property real _previousLoiterRadius: missionItem.loiterRadius.rawValue
Column {
id: editorColumn
anchors.margins: _margin
anchors.left: parent.left
anchors.right: parent.right
spacing: _margin
visible: !editorColumnNeedLandingPoint.visible
SectionHeader {
id: finalApproachSection
anchors.left: parent.left
anchors.right: parent.right
text: qsTr("Final approach")
}
Column {
anchors.left: parent.left
anchors.right: parent.right
spacing: _margin
visible: finalApproachSection.checked
Item { width: 1; height: _spacer }
FactCheckBox {
text: qsTr("Use loiter to altitude")
fact: missionItem.useLoiterToAlt
// When not using loiter to altitude, set radius to 0 to set the
// glide slope heading correctly
onCheckedChanged: {
if (checked) {
// Restore the previous loiter radius
missionItem.loiterRadius.rawValue = _previousLoiterRadius
} else {
_previousLoiterRadius = missionItem.loiterRadius.rawValue
missionItem.loiterRadius.rawValue = 0
}
}
}
GridLayout {
anchors.left: parent.left
anchors.right: parent.right
columns: 2
QGCLabel { text: qsTr("Altitude") }
AltitudeFactTextField {
Layout.fillWidth: true
fact: missionItem.finalApproachAltitude
altitudeMode: _altitudeMode
}
FactCheckBox {
id: flightSpeedCheckbox
text: qsTr("Flight Speed")
fact: missionItem.useDoChangeSpeed
}
FactTextField {
Layout.fillWidth: true
fact: missionItem.finalApproachSpeed
enabled: flightSpeedCheckbox.checked
}
QGCLabel {
text: qsTr("Radius")
visible: missionItem.useLoiterToAlt.rawValue
}
FactTextField {
Layout.fillWidth: true
fact: missionItem.loiterRadius
visible: missionItem.useLoiterToAlt.rawValue
}
}
Item { width: 1; height: _spacer }
FactCheckBox {
text: qsTr("Loiter clockwise")
fact: missionItem.loiterClockwise
visible: missionItem.useLoiterToAlt.rawValue
}
QGCButton {
text: _setToVehicleHeadingStr
visible: globals.activeVehicle
onClicked: missionItem.landingHeading.rawValue = globals.activeVehicle.heading.rawValue
}
}
SectionHeader {
id: landingPointSection
anchors.left: parent.left
anchors.right: parent.right
text: qsTr("Landing point")
}
Column {
anchors.left: parent.left
anchors.right: parent.right
spacing: _margin
visible: landingPointSection.checked
Item { width: 1; height: _spacer }
GridLayout {
anchors.left: parent.left
anchors.right: parent.right
columns: 2
QGCLabel { text: qsTr("Heading") }
FactTextField {
Layout.fillWidth: true
fact: missionItem.landingHeading
}
QGCLabel { text: qsTr("Altitude") }
AltitudeFactTextField {
Layout.fillWidth: true
fact: missionItem.landingAltitude
altitudeMode: _altitudeMode
}
QGCRadioButton {
id: specifyLandingDistance
text: qsTr("Distance")
checked: missionItem.valueSetIsDistance.rawValue
onClicked: missionItem.valueSetIsDistance.rawValue = checked
Layout.fillWidth: true
}
FactTextField {
fact: missionItem.landingDistance
enabled: specifyLandingDistance.checked
Layout.fillWidth: true
}
QGCRadioButton {
id: specifyGlideSlope
text: qsTr("Glide Slope")
checked: !missionItem.valueSetIsDistance.rawValue
onClicked: missionItem.valueSetIsDistance.rawValue = !checked
Layout.fillWidth: true
}
FactTextField {
fact: missionItem.glideSlope
enabled: specifyGlideSlope.checked
Layout.fillWidth: true
}
QGCButton {
text: _setToVehicleLocationStr
visible: globals.activeVehicle
Layout.columnSpan: 2
onClicked: missionItem.landingCoordinate = globals.activeVehicle.coordinate
}
}
}
Item { width: 1; height: _spacer }
QGCCheckBox {
anchors.right: parent.right
text: qsTr("Altitudes relative to launch")
checked: missionItem.altitudesAreRelative
visible: QGroundControl.corePlugin.options.showMissionAbsoluteAltitude || !missionItem.altitudesAreRelative
onClicked: missionItem.altitudesAreRelative = checked
}
SectionHeader {
id: cameraSection
anchors.left: parent.left
anchors.right: parent.right
text: qsTr("Camera")
visible: _showCameraSection
}
Column {
anchors.left: parent.left
anchors.right: parent.right
spacing: _margin
visible: _showCameraSection && cameraSection.checked
Item { width: 1; height: _spacer }
FactCheckBox {
text: _stopTakingPhotos.shortDescription
fact: _stopTakingPhotos
property Fact _stopTakingPhotos: missionItem.stopTakingPhotos
}
FactCheckBox {
text: _stopTakingVideo.shortDescription
fact: _stopTakingVideo
property Fact _stopTakingVideo: missionItem.stopTakingVideo
}
}
Column {
anchors.left: parent.left
anchors.right: parent.right
spacing: 0
QGCLabel {
anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.WordWrap
color: qgcPal.warningText
font.pointSize: ScreenTools.smallFontPointSize
text: qsTr("* Approximate glide slope altitudes.")
}
QGCLabel {
anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.WordWrap
color: qgcPal.warningText
font.pointSize: ScreenTools.smallFontPointSize
text: qsTr("* Actual flight path will vary.")
}
QGCLabel {
anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.WordWrap
color: qgcPal.warningText
font.pointSize: ScreenTools.smallFontPointSize
text: qsTr("* Avoid tailwind on landing.")
}
}
}
Column {
id: editorColumnNeedLandingPoint
anchors.margins: _margin
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
visible: !missionItem.landingCoordSet || missionItem.wizardMode
spacing: ScreenTools.defaultFontPixelHeight
Column {
id: landingCoordColumn
anchors.left: parent.left
anchors.right: parent.right
spacing: ScreenTools.defaultFontPixelHeight
visible: !missionItem.landingCoordSet
QGCLabel {
anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.WordWrap
horizontalAlignment: Text.AlignHCenter
text: qsTr("Click in map to set landing point.")
}
QGCLabel {
anchors.left: parent.left
anchors.right: parent.right
horizontalAlignment: Text.AlignHCenter
text: qsTr("- or -")
visible: globals.activeVehicle
}
QGCButton {
anchors.horizontalCenter: parent.horizontalCenter
text: _setToVehicleLocationStr
visible: globals.activeVehicle
onClicked: {
missionItem.landingCoordinate = globals.activeVehicle.coordinate
missionItem.landingHeading.rawValue = globals.activeVehicle.heading.rawValue
missionItem.setLandingHeadingToTakeoffHeading()
}
}
}
ColumnLayout {
anchors.left: parent.left
anchors.right: parent.right
spacing: ScreenTools.defaultFontPixelHeight
visible: !landingCoordColumn.visible
onVisibleChanged: {
if (visible) {
console.log(missionItem.landingDistance.rawValue)
}
}
QGCLabel {
Layout.fillWidth: true
wrapMode: Text.WordWrap
text: qsTr("Drag the loiter point to adjust landing direction for wind and obstacles.")
}
QGCButton {
text: qsTr("Done")
Layout.fillWidth: true
onClicked: {
missionItem.wizardMode = false
missionItem.landingDragAngleOnly = false
}
}
}
}
}