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
25 transform: Translate {
26 x: translateCenterToAngleX(control.offsetRadius, 0)
27 y: translateCenterToAngleY(control.offsetRadius, 0)
28 }
29 }
30
31 QGCLabel {
32 anchors.centerIn: parent
33 text: "E"
34
35 transform: Translate {
36 x: translateCenterToAngleX(control.offsetRadius, 90)
37 y: translateCenterToAngleY(control.offsetRadius, 90)
38 }
39 }
40
41 QGCLabel {
42 anchors.centerIn: parent
43 text: "S"
44
45 transform: Translate {
46 x: translateCenterToAngleX(control.offsetRadius, 180)
47 y: translateCenterToAngleY(control.offsetRadius, 180)
48 }
49 }
50
51 QGCLabel {
52 anchors.centerIn: parent
53 text: "W"
54
55 transform: Translate {
56 x: translateCenterToAngleX(control.offsetRadius, 270)
57 y: translateCenterToAngleY(control.offsetRadius, 270)
58 }
59 }
60
61 // Major tick marks
62 Repeater {
63 model: 4
64
65 Rectangle {
66 x: size / 2
67 width: 1
68 height: ScreenTools.defaultFontPixelHeight * 0.5
69 color: qgcPal.text
70 antialiasing: true
71
72 transform: Rotation {
73 origin.x: 0
74 origin.y: size / 2
75 angle: 45 + (90 * index)
76 }
77 }
78 }
79
80 // Minor tick marks
81 Repeater {
82 model: 8
83
84 Rectangle {
85 x: size / 2
86 y: _margin
87 width: 1
88 height: _margin
89 color: qgcPal.text
90 antialiasing: true
91
92 property real _margin: ScreenTools.defaultFontPixelHeight * 0.25
93
94 transform: Rotation {
95 origin.x: 0
96 origin.y: size / 2 - _margin
97 angle: 45 / 2 + (45 * index)
98 }
99 }
100 }
101}