QGCPitchIndicator.qml 3.25 KB
Newer Older
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
dogmaphobic's avatar
dogmaphobic committed
9 10 11 12 13


/**
 * @file
 *   @brief QGC Pitch Indicator
Gus Grubba's avatar
Gus Grubba committed
14
 *   @author Gus Grubba <gus@auterion.com>
dogmaphobic's avatar
dogmaphobic committed
15 16
 */

17
import QtQuick 2.3
18
import QGroundControl.ScreenTools 1.0
19
import QGroundControl.Controls 1.0
dogmaphobic's avatar
dogmaphobic committed
20 21

Rectangle {
22 23
    property real pitchAngle:       0
    property real rollAngle:        0
Gus Grubba's avatar
Gus Grubba committed
24
    property real size:             ScreenTools.isAndroid ? 300 : 100
25 26 27
    property real _reticleHeight:   1
    property real _reticleSpacing:  size * 0.15
    property real _reticleSlot:     _reticleSpacing + _reticleHeight
Gus Grubba's avatar
Gus Grubba committed
28
    property real _longDash:        size * 0.35
29
    property real _shortDash:       size * 0.25
Gus Grubba's avatar
Gus Grubba committed
30
    property real _fontSize:        ScreenTools.defaultFontPointSize * 0.75
dogmaphobic's avatar
dogmaphobic committed
31

dogmaphobic's avatar
dogmaphobic committed
32
    height: size
33
    width:  size
dogmaphobic's avatar
dogmaphobic committed
34 35 36 37 38 39 40 41
    anchors.horizontalCenter: parent.horizontalCenter
    anchors.verticalCenter:   parent.verticalCenter
    clip: true
    Item {
        height: parent.height
        width:  parent.width
        Column{
            anchors.horizontalCenter: parent.horizontalCenter
dogmaphobic's avatar
dogmaphobic committed
42
            anchors.verticalCenter:   parent.verticalCenter
dogmaphobic's avatar
dogmaphobic committed
43 44 45 46
            spacing: _reticleSpacing
            Repeater {
                model: 36
                Rectangle {
dogmaphobic's avatar
dogmaphobic committed
47
                    property int _pitch: -(modelData * 5 - 90)
dogmaphobic's avatar
dogmaphobic committed
48
                    anchors.horizontalCenter: parent.horizontalCenter
49
                    width: (_pitch % 10) === 0 ? _longDash : _shortDash
dogmaphobic's avatar
dogmaphobic committed
50 51 52 53
                    height: _reticleHeight
                    color: "white"
                    antialiasing: true
                    smooth: true
54
                    QGCLabel {
dogmaphobic's avatar
dogmaphobic committed
55
                        anchors.horizontalCenter: parent.horizontalCenter
Gus Grubba's avatar
Gus Grubba committed
56
                        anchors.horizontalCenterOffset: -(_longDash)
dogmaphobic's avatar
dogmaphobic committed
57 58
                        anchors.verticalCenter: parent.verticalCenter
                        smooth: true
59
                        font.family: ScreenTools.demiboldFontFamily
Gus Grubba's avatar
Gus Grubba committed
60
                        font.pointSize: _fontSize
dogmaphobic's avatar
dogmaphobic committed
61
                        text: _pitch
dogmaphobic's avatar
dogmaphobic committed
62
                        color: "white"
dogmaphobic's avatar
dogmaphobic committed
63
                        visible: (_pitch != 0) && ((_pitch % 10) === 0)
dogmaphobic's avatar
dogmaphobic committed
64
                    }
65
                    QGCLabel {
dogmaphobic's avatar
dogmaphobic committed
66
                        anchors.horizontalCenter: parent.horizontalCenter
Gus Grubba's avatar
Gus Grubba committed
67
                        anchors.horizontalCenterOffset: (_longDash)
dogmaphobic's avatar
dogmaphobic committed
68 69
                        anchors.verticalCenter: parent.verticalCenter
                        smooth: true
70
                        font.family: ScreenTools.demiboldFontFamily
Gus Grubba's avatar
Gus Grubba committed
71
                        font.pointSize: _fontSize
dogmaphobic's avatar
dogmaphobic committed
72
                        text: _pitch
dogmaphobic's avatar
dogmaphobic committed
73
                        color: "white"
dogmaphobic's avatar
dogmaphobic committed
74
                        visible: (_pitch != 0) && ((_pitch % 10) === 0)
dogmaphobic's avatar
dogmaphobic committed
75 76 77 78 79 80 81 82 83 84
                    }
                }
            }
        }
        transform: [ Translate {
                y: (pitchAngle * _reticleSlot / 5) - (_reticleSlot / 2)
                }]
    }
    transform: [
        Rotation {
85
            origin.x: width  / 2
dogmaphobic's avatar
dogmaphobic committed
86 87 88 89 90
            origin.y: height / 2
            angle:    -rollAngle
            }
    ]
}