QGCAttitudeWidget.qml 3.8 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.
 *
 ****************************************************************************/
dogmaphobic's avatar
dogmaphobic committed
9 10 11 12


/**
 * @file
13
 *   @brief QGC Attitude Instrument
dogmaphobic's avatar
dogmaphobic committed
14 15 16 17
 *   @author Gus Grubba <mavlink@grubba.com>
 */

import QtQuick 2.4
dogmaphobic's avatar
dogmaphobic committed
18 19
import QtGraphicalEffects 1.0

20
import QGroundControl.Controls 1.0
dogmaphobic's avatar
dogmaphobic committed
21

dogmaphobic's avatar
dogmaphobic committed
22
Item {
dogmaphobic's avatar
dogmaphobic committed
23
    id: root
24 25 26 27

    property bool active:       false  ///< true: actively connected to data provider, false: show inactive control
    property real rollAngle :   _defaultRollAngle
    property real pitchAngle:   _defaultPitchAngle
28 29
    property bool showPitch:    true
    property real size
dogmaphobic's avatar
dogmaphobic committed
30

31 32 33
    readonly property real _defaultRollAngle:   0
    readonly property real _defaultPitchAngle:  0

dogmaphobic's avatar
dogmaphobic committed
34
    property real _rollAngle:   active ? rollAngle  : _defaultRollAngle
35 36
    property real _pitchAngle:  active ? pitchAngle : _defaultPitchAngle

37 38 39
    width:  size
    height: size

dogmaphobic's avatar
dogmaphobic committed
40 41
    Item {
        id:             instrument
42
        anchors.fill:   parent
dogmaphobic's avatar
dogmaphobic committed
43 44 45 46 47
        visible:        false

        //----------------------------------------------------
        //-- Artificial Horizon
        QGCArtificialHorizon {
dogmaphobic's avatar
dogmaphobic committed
48 49 50
            rollAngle:          _rollAngle
            pitchAngle:         _pitchAngle
            anchors.fill:       parent
dogmaphobic's avatar
dogmaphobic committed
51 52 53 54
        }
        //----------------------------------------------------
        //-- Pointer
        Image {
dogmaphobic's avatar
dogmaphobic committed
55 56 57 58 59 60
            id:                 pointer
            source:             "/qmlimages/attitudePointer.svg"
            mipmap:             true
            fillMode:           Image.PreserveAspectFit
            anchors.fill:       parent
            sourceSize.height:  parent.height
dogmaphobic's avatar
dogmaphobic committed
61 62 63 64
        }
        //----------------------------------------------------
        //-- Instrument Dial
        Image {
dogmaphobic's avatar
dogmaphobic committed
65 66 67 68 69 70
            id:                 instrumentDial
            source:             "/qmlimages/attitudeDial.svg"
            mipmap:             true
            fillMode:           Image.PreserveAspectFit
            anchors.fill:       parent
            sourceSize.height:  parent.height
dogmaphobic's avatar
dogmaphobic committed
71
            transform: Rotation {
dogmaphobic's avatar
dogmaphobic committed
72 73 74
                origin.x:       root.width  / 2
                origin.y:       root.height / 2
                angle:          -_rollAngle
dogmaphobic's avatar
dogmaphobic committed
75 76 77 78 79 80 81
            }
        }
        //----------------------------------------------------
        //-- Pitch
        QGCPitchIndicator {
            id:                 pitchWidget
            visible:            root.showPitch
dogmaphobic's avatar
dogmaphobic committed
82
            size:               root.size * 0.5
dogmaphobic's avatar
dogmaphobic committed
83 84 85 86 87 88 89 90 91 92 93 94 95
            anchors.verticalCenter: parent.verticalCenter
            pitchAngle:         _pitchAngle
            rollAngle:          _rollAngle
            color:              Qt.rgba(0,0,0,0)
        }
        //----------------------------------------------------
        //-- Cross Hair
        Image {
            id:                 crossHair
            anchors.centerIn:   parent
            source:             "/qmlimages/crossHair.svg"
            mipmap:             true
            width:              size * 0.75
dogmaphobic's avatar
dogmaphobic committed
96
            sourceSize.width:   width
dogmaphobic's avatar
dogmaphobic committed
97
            fillMode:           Image.PreserveAspectFit
98
        }
dogmaphobic's avatar
dogmaphobic committed
99
    }
dogmaphobic's avatar
dogmaphobic committed
100 101 102 103 104 105 106

    Rectangle {
        id:             mask
        anchors.fill:   instrument
        radius:         width / 2
        color:          "black"
        visible:        false
107
    }
dogmaphobic's avatar
dogmaphobic committed
108 109 110 111 112

    OpacityMask {
        anchors.fill: instrument
        source: instrument
        maskSource: mask
113
    }
dogmaphobic's avatar
dogmaphobic committed
114 115 116

    Rectangle {
        id:             borderRect
117
        anchors.fill:   parent
dogmaphobic's avatar
dogmaphobic committed
118 119 120 121
        radius:         width / 2
        color:          Qt.rgba(0,0,0,0)
        border.color:   "black"
        border.width:   2
122
    }
dogmaphobic's avatar
dogmaphobic committed
123

dogmaphobic's avatar
dogmaphobic committed
124
}