5import QGroundControl.Controls
6import QGroundControl.FactControls
8/// Altitude, altitude frame and firmware specific help of a rally point
12 required property var rallyPoint
13 required property var vehicle
15 readonly property bool _px4: vehicle ? vehicle.px4Firmware : false
16 readonly property bool _apm: vehicle ? vehicle.apmFirmware : false
17 readonly property var _frames: {
19 { text: QGroundControl.altitudeFrameExtraUnits(QGroundControl.AltitudeFrameRelative), value: QGroundControl.AltitudeFrameRelative },
20 { text: QGroundControl.altitudeFrameExtraUnits(QGroundControl.AltitudeFrameAbsolute), value: QGroundControl.AltitudeFrameAbsolute }
22 if (rallyPoint.altitudeFrame === QGroundControl.AltitudeFrameTerrain || (vehicle && vehicle.supports.terrainFrame)) {
23 frames.push({ text: QGroundControl.altitudeFrameExtraUnits(QGroundControl.AltitudeFrameTerrain), value: QGroundControl.AltitudeFrameTerrain })
27 readonly property int _frameIndex: _frames.findIndex(frame => frame.value === rallyPoint.altitudeFrame)
28 readonly property string _helpText: {
30 return qsTr("Ground altitude at this point. Return and descent altitudes are measured from it.")
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.")
34 return qsTr("Altitude of this point. How it is used depends on the vehicle firmware.")
37 spacing: ScreenTools.defaultFontPixelHeight * 0.25
39 QGCPalette { id: qgcPal }
42 Layout.fillWidth: true
43 spacing: ScreenTools.defaultFontPixelWidth
45 LabelledFactTextField {
46 objectName: "rallyPointAltitudeField"
47 Layout.fillWidth: true
48 label: qsTr("Altitude")
49 fact: root.rallyPoint.altitude
53 objectName: "rallyPointAltitudeFrameCombo"
56 currentIndex: root._frameIndex
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)
70 objectName: "rallyPointAltitudeHelp"
71 Layout.fillWidth: true
72 wrapMode: Text.WordWrap
73 font.pointSize: ScreenTools.smallFontPointSize
74 color: qgcPal.textSecondary
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