QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GeoMapMissionLabel.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
10pragma ComponentBehavior: Bound
11
12import QtQuick
13import QtQuick3D
14
15import QGroundControl
16import QGroundControl.Controls
17import QGroundControl.GeoMap
18
19/// Point marker for complex mission item visuals: same colored dot that
20/// crossfades into a 3D sphere as GeoMapWaypointItem, plus an always-visible
21/// side text label (e.g. "Loiter", "Land").
22GeoMapItem {
23 id: root
24
25 property int index: -1 ///< Sequence number shown in the dot; < 0 shows none
26 property string label: ""
27 property bool checked: false
28 property real size: ScreenTools.defaultFontPixelHeight * 1.5
29
30 width: size
31 height: size
32 anchorPoint: Qt.point(width / 2, height / 2)
33 // altitudeMode defaults to ClampToGround (GeoMapItem); callers may override
34
35 QGCPalette { id: qgcPal; colorGroupEnabled: root.enabled }
36
37 // Same conventions as GeoMapWaypointItem / MissionItemIndexLabel:
38 // checked is "green" and grown, everything else the plain indicator color
39 readonly property color _markerColor: root.checked ? "green" : qgcPal.mapIndicator
40 readonly property real _indicatorSize: root.checked ? root.size : root.size * 0.75
41
42 readonly property var _camera: scene ? scene.camera : null
43
44 // Constant apparent size, same technique as GeoMapWaypointItem: scene
45 // units per screen pixel at the camera's look-at distance. Built-in
46 // QtQuick3D meshes are 100 units across.
47 readonly property real _modelScale: _camera
48 ? root._indicatorSize * _camera.distance * _camera.unitsPerPixelAtUnitDistance / 100
49 : 1
50
51 Rectangle {
52 anchors.centerIn: parent
53 width: root._indicatorSize
54 height: root._indicatorSize
55 radius: width / 2
56 color: root._markerColor
57 opacity: root.contentOpacity2D
58 }
59
60 QGCLabel {
61 anchors.centerIn: parent
62 // MissionItemIndexLabel convention: single-char label lives inside the dot
63 text: root.index >= 0 ? root.index : (root.label.length === 1 ? root.label : "")
64 color: "white"
65 font.bold: true
66 }
67
68 GeoMapDropShadow {
69 id: dropShadow
70 geoItem: root
71 indicatorSize: root._indicatorSize
72 }
73
74 Rectangle {
75 anchors.left: parent.right
76 anchors.leftMargin: ScreenTools.defaultFontPixelWidth / 2
77 anchors.verticalCenter: parent.verticalCenter
78 width: sideLabel.width + ScreenTools.defaultFontPixelWidth
79 height: sideLabel.height
80 radius: height / 2
81 color: root._markerColor
82 visible: root.label.length > 1
83
84 QGCLabel {
85 id: sideLabel
86 anchors.centerIn: parent
87 text: root.label
88 color: "white"
89 }
90 }
91
92 delegate3D: Component {
93 Node {
94 Node {
95 scale: Qt.vector3d(root._modelScale, root._modelScale, root._modelScale)
96
97 Model {
98 source: "#Sphere"
99
100 materials: PrincipledMaterial {
101 baseColor: root._markerColor
102 }
103 }
104 }
105
106 GeoMapDropLine {
107 dropLength: dropShadow.dropLength
108 lineScale: dropShadow.dropLineScale
109 lineColor: root._markerColor
110 }
111 }
112 }
113}