QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
RallyPointAltitudeEditor.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Layouts
3
4import QGroundControl
5import QGroundControl.Controls
6import QGroundControl.FactControls
7
8/// Altitude, altitude frame and firmware specific help of a rally point
9ColumnLayout {
10 id: root
11
12 required property var rallyPoint
13 required property var vehicle
14
15 readonly property bool _px4: vehicle ? vehicle.px4Firmware : false
16 readonly property bool _apm: vehicle ? vehicle.apmFirmware : false
17 readonly property var _frames: {
18 const frames = [
19 { text: QGroundControl.altitudeFrameExtraUnits(QGroundControl.AltitudeFrameRelative), value: QGroundControl.AltitudeFrameRelative },
20 { text: QGroundControl.altitudeFrameExtraUnits(QGroundControl.AltitudeFrameAbsolute), value: QGroundControl.AltitudeFrameAbsolute }
21 ]
22 if (rallyPoint.altitudeFrame === QGroundControl.AltitudeFrameTerrain || (vehicle && vehicle.supports.terrainFrame)) {
23 frames.push({ text: QGroundControl.altitudeFrameExtraUnits(QGroundControl.AltitudeFrameTerrain), value: QGroundControl.AltitudeFrameTerrain })
24 }
25 return frames
26 }
27 readonly property int _frameIndex: _frames.findIndex(frame => frame.value === rallyPoint.altitudeFrame)
28 readonly property string _helpText: {
29 if (_px4) {
30 return qsTr("Ground altitude at this point. Return and descent altitudes are measured from it.")
31 } else if (_apm) {
32 return qsTr("Flight altitude at this point. Plane flies to this altitude and loiters there. Copter returns at the higher of this altitude and RTL_ALT, then lands. Set it high enough to clear terrain and obstacles.")
33 }
34 return qsTr("Altitude of this point. How it is used depends on the vehicle firmware.")
35 }
36
37 spacing: ScreenTools.defaultFontPixelHeight * 0.25
38
39 QGCPalette { id: qgcPal }
40
41 RowLayout {
42 Layout.fillWidth: true
43 spacing: ScreenTools.defaultFontPixelWidth
44
45 LabelledFactTextField {
46 objectName: "rallyPointAltitudeField"
47 Layout.fillWidth: true
48 label: qsTr("Altitude")
49 fact: root.rallyPoint.altitude
50 }
51
52 QGCComboBox {
53 objectName: "rallyPointAltitudeFrameCombo"
54 model: root._frames
55 textRole: "text"
56 currentIndex: root._frameIndex
57
58 onActivated: (index) => {
59 // ArduPilot altitudes are flight altitudes, so a frame change starts from the default mission altitude
60 const seedAltitude = root._apm ? QGroundControl.settingsManager.appSettings.defaultMissionItemAltitude.rawValue : 0
61 // PX4 AMSL is the ground elevation, ArduPilot AMSL is a flight altitude that terrain data does not give
62 root.rallyPoint.changeAltitudeFrame(root._frames[index].value, seedAltitude, root._px4)
63 // Activation breaks the binding. For PX4 AMSL the frame changes once the terrain query answers.
64 currentIndex = Qt.binding(() => root._frameIndex)
65 }
66 }
67 }
68
69 QGCLabel {
70 objectName: "rallyPointAltitudeHelp"
71 Layout.fillWidth: true
72 wrapMode: Text.WordWrap
73 font.pointSize: ScreenTools.smallFontPointSize
74 color: qgcPal.textSecondary
75 text: root._helpText
76 }
77
78 QGCLabel {
79 objectName: "rallyPointTerrainFailed"
80 Layout.fillWidth: true
81 wrapMode: Text.WordWrap
82 font.pointSize: ScreenTools.smallFontPointSize
83 color: qgcPal.warningText
84 text: root.rallyPoint.altitudeFrame === QGroundControl.AltitudeFrameAbsolute
85 ? qsTr("Terrain elevation is unavailable. Enter the AMSL altitude manually.")
86 : qsTr("Terrain elevation is unavailable. Select AMSL to enter the altitude manually.")
87 visible: root.rallyPoint.terrainQueryFailed
88 }
89}