QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
QGCAttitudeWidget.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Effects
3
4import QGroundControl
5import QGroundControl.Controls
6
7Item {
8 id: root
9
10 property bool showPitch: true
11 property var vehicle: null
12 property real size
13 property bool showHeading: false
14
15 property real _rollAngle: vehicle ? vehicle.roll.rawValue : 0
16 property real _pitchAngle: vehicle ? vehicle.pitch.rawValue : 0
17
18 width: size
19 height: size
20
21 QGCPalette { id: qgcPal; colorGroupEnabled: enabled }
22
23 Item {
24 id: instrument
25 anchors.fill: parent
26 visible: false
27
28 //----------------------------------------------------
29 //-- Artificial Horizon
30 QGCArtificialHorizon {
31 rollAngle: _rollAngle
32 pitchAngle: _pitchAngle
33 anchors.fill: parent
34 }
35 //----------------------------------------------------
36 //-- Pointer
37 Image {
38 id: pointer
39 source: "/qmlimages/attitudePointer.svg"
40 mipmap: true
41 fillMode: Image.PreserveAspectFit
42 anchors.fill: parent
43 sourceSize.height: parent.height
44 }
45 //----------------------------------------------------
46 //-- Instrument Dial
47 Image {
48 id: instrumentDial
49 source: "/qmlimages/attitudeDial.svg"
50 mipmap: true
51 fillMode: Image.PreserveAspectFit
52 anchors.fill: parent
53 sourceSize.height: parent.height
54 transform: Rotation {
55 origin.x: root.width / 2
56 origin.y: root.height / 2
57 angle: -_rollAngle
58 }
59 }
60 //----------------------------------------------------
61 //-- Pitch
62 QGCPitchIndicator {
63 id: pitchWidget
64 visible: root.showPitch
65 size: root.size * 0.5
66 anchors.verticalCenter: parent.verticalCenter
67 pitchAngle: _pitchAngle
68 rollAngle: _rollAngle
69 color: Qt.rgba(0,0,0,0)
70 }
71 //----------------------------------------------------
72 //-- Cross Hair
73 Image {
74 id: crossHair
75 anchors.centerIn: parent
76 source: "/qmlimages/crossHair.svg"
77 mipmap: true
78 width: size * 0.75
79 sourceSize.width: width
80 fillMode: Image.PreserveAspectFit
81 }
82 }
83
84 MultiEffect {
85 source: instrument
86 anchors.fill: instrument
87 maskEnabled: true
88 maskSource: mask
89 }
90
91 Item {
92 id: mask
93 width: instrument.width
94 height: instrument.height
95 layer.enabled: true
96 visible: false
97
98 Rectangle {
99 width: parent.width
100 height: parent.height
101 radius: width/2
102 color: "black"
103 }
104 }
105
106 Rectangle {
107 id: borderRect
108 anchors.fill: parent
109 radius: width / 2
110 color: Qt.rgba(0,0,0,0)
111 border.color: qgcPal.text
112 border.width: 1
113 }
114
115 QGCLabel {
116 anchors.bottomMargin: Math.round(ScreenTools.defaultFontPixelHeight * .75)
117 anchors.bottom: parent.bottom
118 anchors.horizontalCenter: parent.horizontalCenter
119 text: _headingString3
120 color: "white"
121 visible: showHeading
122
123 property string _headingString: vehicle ? vehicle.heading.rawValue.toFixed(0) : "OFF"
124 property string _headingString2: _headingString.length === 1 ? "0" + _headingString : _headingString
125 property string _headingString3: _headingString2.length === 2 ? "0" + _headingString2 : _headingString2
126 }
127}