QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
CompassDial.qml
Go to the documentation of this file.
1import QtQuick
2
3import QGroundControl
4import QGroundControl.Controls
5
6/// This is the dial background for the compass
7
8Item {
9 id: control
10
11 property real offsetRadius: width / 2 - ScreenTools.defaultFontPixelHeight / 2
12
13 function translateCenterToAngleX(radius, angle) {
14 return radius * Math.sin(angle * (Math.PI / 180))
15 }
16
17 function translateCenterToAngleY(radius, angle) {
18 return -radius * Math.cos(angle * (Math.PI / 180))
19 }
20
21 QGCLabel {
22 anchors.centerIn: parent
23 text: "N"
24 rotation: _lockNoseUpCompass ? _heading : 0
25
26 transform: Translate {
27 x: translateCenterToAngleX(control.offsetRadius, 0)
28 y: translateCenterToAngleY(control.offsetRadius, 0)
29 }
30 }
31
32 QGCLabel {
33 anchors.centerIn: parent
34 text: "E"
35 rotation: _lockNoseUpCompass ? _heading : 0
36
37 transform: Translate {
38 x: translateCenterToAngleX(control.offsetRadius, 90)
39 y: translateCenterToAngleY(control.offsetRadius, 90)
40 }
41 }
42
43 QGCLabel {
44 anchors.centerIn: parent
45 text: "S"
46 rotation: _lockNoseUpCompass ? _heading : 0
47
48 transform: Translate {
49 x: translateCenterToAngleX(control.offsetRadius, 180)
50 y: translateCenterToAngleY(control.offsetRadius, 180)
51 }
52 }
53
54 QGCLabel {
55 anchors.centerIn: parent
56 text: "W"
57 rotation: _lockNoseUpCompass ? _heading : 0
58
59 transform: Translate {
60 x: translateCenterToAngleX(control.offsetRadius, 270)
61 y: translateCenterToAngleY(control.offsetRadius, 270)
62 }
63 }
64
65 // Major tick marks
66 Repeater {
67 model: 4
68
69 Rectangle {
70 x: size / 2
71 width: 1
72 height: ScreenTools.defaultFontPixelHeight * 0.5
73 color: qgcPal.text
74 antialiasing: true
75
76 transform: Rotation {
77 origin.x: 0
78 origin.y: size / 2
79 angle: 45 + (90 * index)
80 }
81 }
82 }
83
84 // Minor tick marks
85 Repeater {
86 model: 8
87
88 Rectangle {
89 x: size / 2
90 y: _margin
91 width: 1
92 height: _margin
93 color: qgcPal.text
94 antialiasing: true
95
96 property real _margin: ScreenTools.defaultFontPixelHeight * 0.25
97
98 transform: Rotation {
99 origin.x: 0
100 origin.y: size / 2 - _margin
101 angle: 45 / 2 + (45 * index)
102 }
103 }
104 }
105}