QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
GeoMapPin.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 QtQuick
11import QtQuick.Shapes
12
13import QGroundControl
14import QGroundControl.Controls
15import QGroundControl.GeoMap
16
17/// Google Maps-style teardrop marker anchored at its tip. Shows an inner dot
18/// by default, or a short label when one is set.
19GeoMapItem {
20 id: root
21
22 property color color: qgcPal.mapIndicator
23 property alias label: labelText.text
24
25 readonly property real _headRadius: width / 2
26
27 // Tangent points where straight tail lines touch the head circle, so the
28 // arc flows into the tail without a corner. Clamped: height <= 2 * head
29 // radius has no tangent solution and would produce NaN geometry.
30 readonly property real _tangentAngle: Math.acos(Math.min(1, _headRadius / (height - _headRadius)))
31 readonly property real _tangentDX: _headRadius * Math.sin(_tangentAngle)
32 readonly property real _tangentY: _headRadius + _headRadius * Math.cos(_tangentAngle)
33
34 width: ScreenTools.defaultFontPixelHeight * 1.25
35 height: width * 1.4
36 anchorPoint: Qt.point(width / 2, height)
37
38 QGCPalette { id: qgcPal; colorGroupEnabled: root.enabled }
39
40 Shape {
41 anchors.fill: parent
42 preferredRendererType: Shape.CurveRenderer
43
44 ShapePath {
45 strokeWidth: -1
46 fillColor: root.color
47
48 startX: root.width / 2
49 startY: root.height
50
51 PathLine {
52 x: root.width / 2 - root._tangentDX
53 y: root._tangentY
54 }
55 PathArc {
56 x: root.width / 2 + root._tangentDX
57 y: root._tangentY
58 radiusX: root._headRadius
59 radiusY: root._headRadius
60 useLargeArc: true
61 direction: PathArc.Clockwise
62 }
63 PathLine {
64 x: root.width / 2
65 y: root.height
66 }
67 }
68 }
69
70 Rectangle {
71 anchors.horizontalCenter: parent.horizontalCenter
72 y: root._headRadius - height / 2
73 width: root._headRadius * 0.8
74 height: width
75 radius: width / 2
76 color: Qt.darker(root.color, 1.5)
77 visible: labelText.text === ""
78 }
79
80 QGCLabel {
81 id: labelText
82
83 anchors.horizontalCenter: parent.horizontalCenter
84 y: root._headRadius - height / 2
85 color: "white"
86 font.bold: true
87 }
88}