QGCAttitudeWidget.qml 3.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.
 *
 ****************************************************************************/
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          1.0
21
import QGroundControl.Controls 1.0
dogmaphobic's avatar
dogmaphobic committed
22

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

26
    property bool showPitch:    true
27
    property var  vehicle:      null
28
    property real size
dogmaphobic's avatar
dogmaphobic committed
29

30 31
    property real _rollAngle:   vehicle ? vehicle.roll.rawValue  : 0
    property real _pitchAngle:  vehicle ? vehicle.pitch.rawValue : 0
32

33 34 35
    width:  size
    height: size

dogmaphobic's avatar
dogmaphobic committed
36 37
    Item {
        id:             instrument
38
        anchors.fill:   parent
dogmaphobic's avatar
dogmaphobic committed
39 40 41 42 43
        visible:        false

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

    Rectangle {
        id:             mask
        anchors.fill:   instrument
        radius:         width / 2
        color:          "black"
        visible:        false
103
    }
dogmaphobic's avatar
dogmaphobic committed
104 105 106 107 108

    OpacityMask {
        anchors.fill: instrument
        source: instrument
        maskSource: mask
109
    }
dogmaphobic's avatar
dogmaphobic committed
110 111 112

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

dogmaphobic's avatar
dogmaphobic committed
120
}