QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GeoMapLandingPatternVisuals.qml
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * (c) 2009-2024 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 *
5 * QGroundControl is licensed according to the terms in the file
6 * COPYING.md in the root of the source code directory.
7 *
8 ****************************************************************************/
9
10import QtPositioning
11import QtQuick.Shapes
12
13import QGroundControl
14import QGroundControl.GeoMap
15
16/// Base visual shared by Fixed Wing and VTOL landing patterns on GeoMap:
17/// read-only GeoMap-native port of the common elements in
18/// src/PlanView/FWLandingPatternMapVisual.qml / VTOLLandingPatternMapVisual.qml
19/// (flight path, loiter ring, final-approach/landing markers). No
20/// drag-to-place code ports over — FlyView missions are already loaded and
21/// immutable; the markers are clickable only to change the current item.
22Item {
23 id: root
24
25 property var item ///< VisualMissionItem (LandingComplexItem)
26 property var scene
27 property var surfaceModel
28 // DEM-vs-home-AMSL bias, wired by GeoMapMissionItems (see GeoMapWaypointItem)
29 property real homeTerrainBias: 0
30 property string landingLabel: "" ///< Label for the landing-point marker (VTOL overrides to "Land")
31 property real node3DOpacity: 1 ///< Dimming of the markers' 3D nodes, see GeoMapItem.node3DOpacity
32 property bool pickable: true ///< The markers take clicks
33
34 signal clicked()
35
36 readonly property bool _useLoiterToAlt: item.useLoiterToAlt.rawValue
37 // Approach leg descends from the final-approach altitude to the landing
38 // altitude; project at those AMSL heights so the 3D view shows the slope
39 // instead of a ground-hugging line
40 readonly property real _approachAltAMSL: item.amslEntryAlt + homeTerrainBias
41 readonly property real _landAltAMSL: item.amslExitAlt + homeTerrainBias
42 readonly property var _flightPath: {
43 const from = _useLoiterToAlt ? item.slopeStartCoordinate : item.finalApproachCoordinate
44 return [QtPositioning.coordinate(from.latitude, from.longitude, _approachAltAMSL),
45 QtPositioning.coordinate(item.landingCoordinate.latitude, item.landingCoordinate.longitude, _landAltAMSL)]
46 }
47
48 GeoMapProjectedPath {
49 id: flightPathProjector
50 scene: root.scene
51 surfaceModel: root.surfaceModel
52 altitudeMode: GeoMapItem.Absolute
53 coordinates: root._flightPath
54 }
55
56 // Flight path (final approach/loiter exit -> landing point)
57 Shape {
58 visible: root.item.landingCoordSet && flightPathProjector.projected
59 ShapePath {
60 strokeColor: QGroundControl.globalPalette.mapMissionTrajectory
61 strokeWidth: 2
62 fillColor: "transparent"
63 PathPolyline { path: flightPathProjector.screenPoints }
64 }
65 }
66
67 GeoMapProjectedPath {
68 id: loiterPath
69 scene: root.scene
70 surfaceModel: root.surfaceModel
71 altitudeMode: GeoMapItem.Absolute
72 // Static invokables aren't callable via the QML type name; call
73 // through the instance instead. Ring altitude rides on the center
74 // coordinate (atDistanceAndAzimuth preserves it).
75 coordinates: root._useLoiterToAlt
76 ? loiterPath.circleCoordinates(QtPositioning.coordinate(root.item.finalApproachCoordinate.latitude,
77 root.item.finalApproachCoordinate.longitude,
78 root._approachAltAMSL),
79 root.item.loiterRadius.rawValue)
80 : []
81 }
82
83 // Loiter ring
84 Shape {
85 visible: root._useLoiterToAlt && loiterPath.projected
86 ShapePath {
87 strokeColor: "green"
88 strokeWidth: 2
89 fillColor: "transparent"
90 PathPolyline { path: loiterPath.screenPoints }
91 }
92 }
93
94 // Final approach / loiter point
95 GeoMapMissionLabel {
96 scene: root.scene
97 surfaceModel: root.surfaceModel
98 altitudeMode: GeoMapItem.Absolute
99 coordinate: QtPositioning.coordinate(root.item.finalApproachCoordinate.latitude,
100 root.item.finalApproachCoordinate.longitude,
101 root._approachAltAMSL)
102 index: root.item.sequenceNumber
103 label: root._useLoiterToAlt ? qsTr("Loiter") : qsTr("Approach")
104 checked: root.item.isCurrentItem
105 node3DOpacity: root.node3DOpacity
106 visible: root.item.landingCoordSet
107
108 MouseArea {
109 anchors.fill: parent
110 enabled: root.pickable
111 onClicked: root.clicked()
112 }
113 }
114
115 // Landing point
116 GeoMapMissionLabel {
117 scene: root.scene
118 surfaceModel: root.surfaceModel
119 altitudeMode: GeoMapItem.Absolute
120 coordinate: QtPositioning.coordinate(root.item.landingCoordinate.latitude,
121 root.item.landingCoordinate.longitude,
122 root._landAltAMSL)
123 index: root.item.lastSequenceNumber
124 label: root.landingLabel
125 checked: root.item.isCurrentItem
126 node3DOpacity: root.node3DOpacity
127 visible: root.item.landingCoordSet
128
129 MouseArea {
130 anchors.fill: parent
131 enabled: root.pickable
132 onClicked: root.clicked()
133 }
134 }
135}