4import QGroundControl.Controls
12 border.color: qgcPal.text
13 border.width: usedByMultipleVehicleList ? 1 : 0
14 opacity: vehicle && usedByMultipleVehicleList && !vehicle.armed ? 0.5 : 1
16 property real size: _defaultSize
17 property var vehicle: null
18 property bool usedByMultipleVehicleList: false
20 property real _defaultSize: usedByMultipleVehicleList ? ScreenTools.defaultFontPixelHeight * 3 : ScreenTools.defaultFontPixelHeight * 10
21 property real _sizeRatio: (usedByMultipleVehicleList || ScreenTools.isTinyScreen) ? (size / _defaultSize) * 0.5 : size / _defaultSize
22 property int _fontSize: ScreenTools.defaultFontPointSize * _sizeRatio < 8 ? 8 : ScreenTools.defaultFontPointSize * _sizeRatio
23 property real _heading: vehicle ? vehicle.heading.rawValue : 0
24 property real _headingToHome: vehicle ? vehicle.headingToHome.rawValue : 0
25 property real _groundSpeed: vehicle ? vehicle.groundSpeed.rawValue : 0
26 property real _headingToNextWP: vehicle ? vehicle.headingToNextWP.rawValue : 0
27 property real _courseOverGround: vehicle ? vehicle.gps.courseOverGround.rawValue : 0
28 property var _flyViewSettings: QGroundControl.settingsManager.flyViewSettings
29 property bool _showAdditionalIndicators: _flyViewSettings.showAdditionalIndicatorsCompass.value && !usedByMultipleVehicleList
30 property bool _lockNoseUpCompass: _flyViewSettings.lockNoseUpCompass.value && !usedByMultipleVehicleList
33 if (_groundSpeed < 0.5) {
36 return vehicle && _showAdditionalIndicators
40 function showHeadingHome() {
41 return vehicle && _showAdditionalIndicators && !isNaN(_headingToHome)
44 function showHeadingToNextWP() {
45 return vehicle && _showAdditionalIndicators && !isNaN(_headingToNextWP)
48 function translateCenterToAngleX(radius, angle) {
49 return radius * Math.sin(angle * (Math.PI / 180))
52 function translateCenterToAngleY(radius, angle) {
53 return -radius * Math.cos(angle * (Math.PI / 180))
56 QGCPalette { id: qgcPal; colorGroupEnabled: enabled }
61 rotation: _lockNoseUpCompass ? -_heading : 0
65 visible: !usedByMultipleVehicleList
68 CompassHeadingIndicator {
71 simplified: usedByMultipleVehicleList
76 source: "/qmlimages/cOGPointer.svg"
78 fillMode: Image.PreserveAspectFit
80 sourceSize.height: parent.height
82 rotation: _courseOverGround
87 source: "/qmlimages/compassDottedLine.svg"
89 fillMode: Image.PreserveAspectFit
91 sourceSize.height: parent.height
92 visible: showHeadingToNextWP()
93 rotation: _headingToNextWP
96 // Launch location indicator
98 width: Math.max(label.contentWidth, label.contentHeight)
100 color: qgcPal.mapIndicator
102 anchors.centerIn: parent
103 visible: showHeadingHome()
110 anchors.centerIn: parent
111 rotation: _lockNoseUpCompass ? _heading : 0
114 transform: Translate {
115 property double _angle: _headingToHome
116 property real _labelOffset: root.width / 2 + ScreenTools.defaultFontPixelHeight / 2
118 x: translateCenterToAngleX(_labelOffset, _angle)
119 y: translateCenterToAngleY(_labelOffset, _angle)
125 anchors.horizontalCenter: parent.horizontalCenter
127 text: vehicle && !usedByMultipleVehicleList ? _heading.toFixed(0) + "°" : ""
128 horizontalAlignment: Text.AlignHCenter