QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
CompassHeadingIndicator.qml
Go to the documentation of this file.
1import QtQuick
2
3import QGroundControl
4import QGroundControl.Controls
5
6Canvas {
7 id: control
8 anchors.centerIn: parent
9 width: compassSize * 1/3
10 height: width
11
12 property real compassSize
13 property real heading
14 property bool simplified: false
15
16 property var _qgcPal: QGroundControl.globalPalette
17
18 Connections {
19 target: _qgcPal
20 function onGlobalThemeChanged() { control.requestPaint() }
21 }
22
23 onPaint: {
24 var ctx = getContext("2d")
25 ctx.strokeStyle = simplified ? "#EE3424" : _qgcPal.text
26 ctx.fillStyle = "#EE3424"
27 ctx.lineWidth = 1
28 ctx.beginPath()
29 ctx.moveTo(width / 2, 0)
30 ctx.lineTo(width, height)
31 ctx.lineTo(width / 2, height * 0.75)
32 ctx.lineTo(width / 2, 0)
33 ctx.fill()
34 ctx.stroke()
35 ctx.fillStyle = "#C72B27"
36 ctx.beginPath()
37 ctx.moveTo(width / 2, 0)
38 ctx.lineTo(0, height)
39 ctx.lineTo(width / 2, height * 0.75)
40 ctx.lineTo(width / 2, 0)
41 ctx.fill()
42 ctx.stroke()
43 }
44
45 transform: Rotation {
46 origin.x: control.width / 2
47 origin.y: control.height / 2
48 angle: heading
49 }
50}