5import QGroundControl.Controls
13 signal clicked(point position)
15 property string label ///< Label to show to the side of the index indicator
16 property int index: 0 ///< Index to show in the indicator, 0 will show single char label instead, -1 first char of label in indicator full label to the side
17 property bool checked: false
18 property bool small: !checked
19 property bool medium: false
20 property bool child: false
21 property bool highlightSelected: false
22 property var color: checked ? "green" : (child ? qgcPal.mapIndicatorChild : qgcPal.mapIndicator)
23 property real anchorPointX: _height / 2
24 property real anchorPointY: _height / 2
25 property bool specifiesCoordinate: true
26 property real gimbalYaw
27 property real vehicleYaw
28 property bool showGimbalYaw: false
29 property bool showSequenceNumbers: true
30 property string indicatorSubText
31 property string supplementaryLabel
33 property real _width: showGimbalYaw ? Math.max(_gimbalYawWidth, labelControl.visible ? labelControl.width : indicator.width) : (labelControl.visible ? labelControl.width : indicator.width)
34 property real _height: showGimbalYaw ? _gimbalYawWidth : (labelControl.visible ? labelControl.height : indicator.height)
35 property real _gimbalYawRadius: ScreenTools.defaultFontPixelHeight
36 property real _gimbalYawWidth: _gimbalYawRadius * 2
37 property real _smallRadius: _oddCeil((ScreenTools.defaultFontPixelHeight * ScreenTools.smallFontPointRatio) / 2)
38 property real _largeRadius: _oddCeil(ScreenTools.defaultFontPixelHeight * 0.66)
39 property real _mediumRadius: _oddCeil(((_smallRadius * 2) + _largeRadius) / 3)
40 property real _indicatorRadius: small ? _smallRadius : (medium ? _mediumRadius : _largeRadius)
41 property real _gimbalRadians: degreesToRadians(vehicleYaw + gimbalYaw - 90)
42 property real _labelMargin: 2
43 property real _labelRadius: _indicatorRadius + _labelMargin
44 property string _label: supplementaryLabel !== "" ? supplementaryLabel : (label.length > 1 ? label : "")
45 property string _index: index === 0 || index === -1 ? label.charAt(0) : (showSequenceNumbers ? index : "")
47 onColorChanged: requestPaint()
48 onShowGimbalYawChanged: requestPaint()
49 onGimbalYawChanged: requestPaint()
50 onVehicleYawChanged: requestPaint()
52 QGCPalette { id: qgcPal }
54 function _oddCeil(value) {
55 const rounded = Math.ceil(value)
56 return rounded + (rounded % 2 === 0 ? 1 : 0)
59 function degreesToRadians(degrees) {
60 return (Math.PI/180)*degrees
63 function paintGimbalYaw(context) {
66 context.globalAlpha = 0.75
68 context.moveTo(anchorPointX, anchorPointY)
69 context.arc(anchorPointX, anchorPointY, _gimbalYawRadius, _gimbalRadians + degreesToRadians(45), _gimbalRadians + degreesToRadians(-45), true /* clockwise */)
71 context.fillStyle = "white"
78 var context = getContext("2d")
79 context.clearRect(0, 0, width, height)
80 paintGimbalYaw(context)
85 anchors.leftMargin: -((_labelMargin * 2) + indicator.width)
86 anchors.rightMargin: -(_labelMargin * 2)
87 anchors.fill: labelControlLabel
91 visible: _label.length !== 0 && !small
96 anchors.topMargin: -_labelMargin
97 anchors.bottomMargin: -_labelMargin
98 anchors.leftMargin: _labelMargin
99 anchors.left: indicator.right
100 anchors.top: indicator.top
101 anchors.bottom: indicator.bottom
104 verticalAlignment: Text.AlignVCenter
105 visible: labelControl.visible
110 anchors.horizontalCenter: parent.left
111 anchors.verticalCenter: parent.top
112 anchors.horizontalCenterOffset: anchorPointX
113 anchors.verticalCenterOffset: anchorPointY
114 width: _indicatorRadius * 2
117 radius: _indicatorRadius
122 horizontalAlignment: Text.AlignHCenter
123 verticalAlignment: Text.AlignVCenter
125 font.pointSize: ScreenTools.defaultFontPointSize
126 fontSizeMode: Text.Fit
132 horizontalCenter: indexLabel.horizontalCenter
133 baseline: indexLabel.baseline
134 baselineOffset: indexLabel.contentHeight / 5
136 width: indicator.width
137 height: indicator.height * 0.4
138 horizontalAlignment: Text.AlignHCenter
139 verticalAlignment: Text.AlignVCenter
141 font.pointSize: ScreenTools.smallFontPointSize
142 fontSizeMode: Text.Fit
143 text: root.indicatorSubText
148 // Extra circle to indicate selection
150 width: indicator.width * 2
153 color: Qt.rgba(0,0,0,0)
154 border.color: Qt.rgba(1,1,1,0.5)
156 visible: checked && highlightSelected
157 anchors.centerIn: indicator
160 // The mouse click area is always the size of a large indicator
163 anchors.margins: -(root._largeRadius - root._indicatorRadius)
164 anchors.fill: indicator
168 fillItem: mouseAreaFill
169 onClicked: (mouse) => {
171 parent.clicked(Qt.point(mouse.x, mouse.y))