1/****************************************************************************
3 * (c) 2009-2024 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
5 * QGroundControl is licensed according to the terms in the file
6 * COPYING.md in the root of the source code directory.
8 ****************************************************************************/
15import QGroundControl.Controls
16import QGroundControl.GeoMap
18/// Simple-mission waypoint marker for the GeoMap: a colored dot that
19/// crossfades into a 3D sphere, with an always-visible sequence-number label.
20/// Marker color matches the existing 2D FlyView convention (MissionItemIndexLabel):
21/// current item highlighted, everything else a plain indicator color.
22/// Renders nothing for complex mission items, the home item, or items with
23/// no real coordinate (e.g. RTL, which flies to home dynamically rather than
24/// a mission-encoded lat/lon) — see visible.
28 property var item ///< VisualMissionItem for this marker
29 // DEM-vs-home-AMSL bias (see GeoMapVehicleItem), computed once by the
30 // consumer for the active vehicle and shared across every marker instead
31 // of each one re-sampling the same DEM lookup independently
32 property real homeTerrainBias: 0
33 property real size: ScreenTools.defaultFontPixelHeight * 1.5
34 property bool collapsed: false ///< Drawn by another marker of its overlap group (see GeoMapMissionItems)
35 property bool grouped: false ///< Stands for an overlap group: shows a "…" badge
37 readonly property bool hasMarker: item ? item.isSimpleItem && item.specifiesCoordinate : false
38 readonly property real smallIndicatorSize: size * 0.75
42 objectName: "geoMapWaypointMarker"
45 anchorPoint: Qt.point(width / 2, height / 2)
46 altitudeMode: GeoMapItem.Absolute
47 // item.amslEntryAlt is AMSL per QGC's own terrain-query pipeline, which
48 // can disagree with GeoMap's own DEM tiles; bias-corrected the same way
49 // GeoMapVehicleItem aligns the vehicle marker to the rendered mesh
50 coordinate: item ? QtPositioning.coordinate(item.coordinate.latitude,
51 item.coordinate.longitude,
52 item.amslEntryAlt + homeTerrainBias)
53 : QtPositioning.coordinate()
54 visible: hasMarker && !collapsed
56 QGCPalette { id: qgcPal; colorGroupEnabled: root.enabled }
58 // Matches MissionItemIndicator.qml's _isCurrentItem exactly: current item
59 // (or a complex item with a current child) is highlighted
60 readonly property bool _isCurrentItem: item ? (item.isCurrentItem || item.hasCurrentChildItem) : false
62 // Matches MissionItemIndexLabel.qml's existing convention: current item
63 // is "green", everything else is the plain map indicator color
64 readonly property color _markerColor: root._isCurrentItem ? "green" : qgcPal.mapIndicator
66 // MissionItemIndexLabel also grows the indicator for the current item
67 // (small: !checked) and for a group; mirrored here for both the 2D dot and 3D sphere
68 readonly property real _indicatorSize: (root._isCurrentItem || root.grouped) ? root.size : root.smallIndicatorSize
70 readonly property var _camera: scene ? scene.camera : null
72 // Constant apparent size, same technique as GeoMapVehicleItem: scene
73 // units per screen pixel at the camera's look-at distance. Built-in
74 // QtQuick3D meshes are 100 units across.
75 readonly property real _modelScale: _camera
76 ? root._indicatorSize * _camera.distance * _camera.unitsPerPixelAtUnitDistance / 100
80 anchors.centerIn: parent
81 width: root._indicatorSize
82 height: root._indicatorSize
84 color: root._markerColor
85 opacity: root.contentOpacity2D
88 // Matches MissionItemIndicator.qml's "extra circle to indicate selection"
90 anchors.centerIn: parent
91 width: root._indicatorSize * 1.4
95 border.color: Qt.rgba(1, 1, 1, 0.5)
97 opacity: root.contentOpacity2D
98 visible: root._isCurrentItem
102 anchors.centerIn: parent
103 text: root.item ? root.item.sequenceNumber : ""
109 anchors.horizontalCenter: parent.horizontalCenter
110 anchors.bottom: parent.bottom
113 font.pointSize: ScreenTools.smallFontPointSize
114 visible: root.grouped
117 // The item itself tracks the projected marker position at any tilt, so
118 // this hit target follows the 3D sphere through the 2D<->3D crossfade
121 onClicked: root.clicked()
127 indicatorSize: root._indicatorSize
130 delegate3D: Component {
133 scale: Qt.vector3d(root._modelScale, root._modelScale, root._modelScale)
138 materials: PrincipledMaterial {
139 baseColor: root._markerColor
145 dropLength: dropShadow.dropLength
146 lineScale: dropShadow.dropLineScale
147 lineColor: root._markerColor