QGCAttitudeHUD.qml 2.55 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
9 10 11 12


/**
 * @file
13
 *   @brief QGC Attitude Widget
14 15 16
 *   @author Gus Grubba <mavlink@grubba.com>
 */

17
import QtQuick 2.3
18
import QGroundControl.ScreenTools 1.0
19

20
Item {
21
    id: root
22 23 24 25

    property bool active:       false  ///< true: actively connected to data provider, false: show inactive control
    property real rollAngle :   _defaultRollAngle
    property real pitchAngle:   _defaultPitchAngle
26
    property bool showPitch:    true
27

28 29 30 31 32 33 34 35
    readonly property real _defaultRollAngle:   0
    readonly property real _defaultPitchAngle:  0

    property real _rollAngle:   active ? rollAngle : _defaultRollAngle
    property real _pitchAngle:  active ? pitchAngle : _defaultPitchAngle

    anchors.centerIn: parent

36
    Image {
37
        id: rollDial
dogmaphobic's avatar
dogmaphobic committed
38 39 40 41 42 43
        anchors { bottom: root.verticalCenter; horizontalCenter: parent.horizontalCenter }
        source:             "/qmlimages/rollDialWhite.svg"
        mipmap:             true
        width:              parent.width
        sourceSize.width:   width
        fillMode:           Image.PreserveAspectFit
44
        transform: Rotation {
dogmaphobic's avatar
dogmaphobic committed
45 46 47
            origin.x:       rollDial.width / 2
            origin.y:       rollDial.height
            angle:          -_rollAngle
48
        }
49
    }
50

51
    Image {
52
        id: pointer
dogmaphobic's avatar
dogmaphobic committed
53 54 55 56 57 58
        anchors { bottom: root.verticalCenter; horizontalCenter: parent.horizontalCenter }
        source:             "/qmlimages/rollPointerWhite.svg"
        mipmap:             true
        width:              rollDial.width
        sourceSize.width:   width
        fillMode:           Image.PreserveAspectFit
59
    }
60

61 62 63
    Image {
        id:                 crossHair
        anchors.centerIn:   parent
64
        source:             "/qmlimages/crossHair.svg"
65
        mipmap:             true
66
        width:              parent.width
dogmaphobic's avatar
dogmaphobic committed
67
        sourceSize.width:   width
68 69
        fillMode:           Image.PreserveAspectFit
    }
70 71 72 73

    QGCPitchIndicator {
        id:                 pitchIndicator
        anchors.verticalCenter: parent.verticalCenter
74 75 76
        visible:            showPitch
        pitchAngle:         _pitchAngle
        rollAngle:          _rollAngle
77
        color:              Qt.rgba(0,0,0,0)
78
        size:               ScreenTools.defaultFontPixelHeight * (10)
79 80
    }
}