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
32 signal clicked()
33
34 readonly property bool _useLoiterToAlt: item.useLoiterToAlt.rawValue
35 // Approach leg descends from the final-approach altitude to the landing
36 // altitude; project at those AMSL heights so the 3D view shows the slope
37 // instead of a ground-hugging line
38 readonly property real _approachAltAMSL: item.amslEntryAlt + homeTerrainBias
39 readonly property real _landAltAMSL: item.amslExitAlt + homeTerrainBias
40 readonly property var _flightPath: {
41 const from = _useLoiterToAlt ? item.slopeStartCoordinate : item.finalApproachCoordinate
42 return [QtPositioning.coordinate(from.latitude, from.longitude, _approachAltAMSL),
43 QtPositioning.coordinate(item.landingCoordinate.latitude, item.landingCoordinate.longitude, _landAltAMSL)]
44 }
45
46 GeoMapProjectedPath {
47 id: flightPathProjector
48 scene: root.scene
49 surfaceModel: root.surfaceModel
50 altitudeMode: GeoMapItem.Absolute
51 coordinates: root._flightPath
52 }
53
54 // Flight path (final approach/loiter exit -> landing point)
55 Shape {
56 visible: root.item.landingCoordSet && flightPathProjector.projected
57 ShapePath {
58 strokeColor: QGroundControl.globalPalette.mapMissionTrajectory
59 strokeWidth: 2
60 fillColor: "transparent"
61 PathPolyline { path: flightPathProjector.screenPoints }
62 }
63 }
64
65 GeoMapProjectedPath {
66 id: loiterPath
67 scene: root.scene
68 surfaceModel: root.surfaceModel
69 altitudeMode: GeoMapItem.Absolute
70 // Static invokables aren't callable via the QML type name; call
71 // through the instance instead. Ring altitude rides on the center
72 // coordinate (atDistanceAndAzimuth preserves it).
73 coordinates: root._useLoiterToAlt
74 ? loiterPath.circleCoordinates(QtPositioning.coordinate(root.item.finalApproachCoordinate.latitude,
75 root.item.finalApproachCoordinate.longitude,
76 root._approachAltAMSL),
77 root.item.loiterRadius.rawValue)
78 : []
79 }
80
81 // Loiter ring
82 Shape {
83 visible: root._useLoiterToAlt && loiterPath.projected
84 ShapePath {
85 strokeColor: "green"
86 strokeWidth: 2
87 fillColor: "transparent"
88 PathPolyline { path: loiterPath.screenPoints }
89 }
90 }
91
92 // Final approach / loiter point
93 GeoMapMissionLabel {
94 scene: root.scene
95 surfaceModel: root.surfaceModel
96 altitudeMode: GeoMapItem.Absolute
97 coordinate: QtPositioning.coordinate(root.item.finalApproachCoordinate.latitude,
98 root.item.finalApproachCoordinate.longitude,
99 root._approachAltAMSL)
100 index: root.item.sequenceNumber
101 label: root._useLoiterToAlt ? qsTr("Loiter") : qsTr("Approach")
102 checked: root.item.isCurrentItem
103 visible: root.item.landingCoordSet
104
105 MouseArea {
106 anchors.fill: parent
107 onClicked: root.clicked()
108 }
109 }
110
111 // Landing point
112 GeoMapMissionLabel {
113 scene: root.scene
114 surfaceModel: root.surfaceModel
115 altitudeMode: GeoMapItem.Absolute
116 coordinate: QtPositioning.coordinate(root.item.landingCoordinate.latitude,
117 root.item.landingCoordinate.longitude,
118 root._landAltAMSL)
119 index: root.item.lastSequenceNumber
120 label: root.landingLabel
121 checked: root.item.isCurrentItem
122 visible: root.item.landingCoordSet
123
124 MouseArea {
125 anchors.fill: parent
126 onClicked: root.clicked()
127 }
128 }
129}