QGCAttitudeWidget.qml 4.16 KB
Newer Older
dogmaphobic's avatar
dogmaphobic committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/*=====================================================================

QGroundControl Open Source Ground Control Station

(c) 2009, 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>

This file is part of the QGROUNDCONTROL project

    QGROUNDCONTROL is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    QGROUNDCONTROL is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.

======================================================================*/

/**
 * @file
26
 *   @brief QGC Attitude Instrument
dogmaphobic's avatar
dogmaphobic committed
27 28 29 30
 *   @author Gus Grubba <mavlink@grubba.com>
 */

import QtQuick 2.4
dogmaphobic's avatar
dogmaphobic committed
31 32
import QtGraphicalEffects 1.0

33
import QGroundControl.Controls 1.0
dogmaphobic's avatar
dogmaphobic committed
34

dogmaphobic's avatar
dogmaphobic committed
35
Item {
dogmaphobic's avatar
dogmaphobic committed
36
    id: root
37 38 39 40

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

44 45 46
    readonly property real _defaultRollAngle:   0
    readonly property real _defaultPitchAngle:  0

dogmaphobic's avatar
dogmaphobic committed
47
    property real _rollAngle:   active ? rollAngle  : _defaultRollAngle
48 49
    property real _pitchAngle:  active ? pitchAngle : _defaultPitchAngle

50 51 52
    width:  size
    height: size

dogmaphobic's avatar
dogmaphobic committed
53 54
    Item {
        id:             instrument
55
        anchors.fill:   parent
dogmaphobic's avatar
dogmaphobic committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
        visible:        false

        //----------------------------------------------------
        //-- Artificial Horizon
        QGCArtificialHorizon {
            rollAngle:      _rollAngle
            pitchAngle:     _pitchAngle
            anchors.fill:   parent
        }
        //----------------------------------------------------
        //-- Pointer
        Image {
            id:         pointer
            source:     "/qmlimages/attitudePointer.svg"
            mipmap:     true
            fillMode:   Image.PreserveAspectFit
            anchors.fill: parent
        }
        //----------------------------------------------------
        //-- Instrument Dial
        Image {
            id:         instrumentDial
            source:     "/qmlimages/attitudeDial.svg"
            mipmap:     true
            fillMode:   Image.PreserveAspectFit
            anchors.fill: parent
            transform: Rotation {
                origin.x: root.width  / 2
                origin.y: root.height / 2
                angle: -_rollAngle
            }
        }
        //----------------------------------------------------
        //-- Pitch
        QGCPitchIndicator {
            id:                 pitchWidget
            visible:            root.showPitch
dogmaphobic's avatar
dogmaphobic committed
93
            size:               root.size * 0.5
dogmaphobic's avatar
dogmaphobic committed
94 95 96 97 98 99 100 101 102 103 104 105 106 107
            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
            fillMode:           Image.PreserveAspectFit
108
        }
dogmaphobic's avatar
dogmaphobic committed
109
    }
dogmaphobic's avatar
dogmaphobic committed
110 111 112 113 114 115 116

    Rectangle {
        id:             mask
        anchors.fill:   instrument
        radius:         width / 2
        color:          "black"
        visible:        false
117
    }
dogmaphobic's avatar
dogmaphobic committed
118 119 120 121 122

    OpacityMask {
        anchors.fill: instrument
        source: instrument
        maskSource: mask
123
    }
dogmaphobic's avatar
dogmaphobic committed
124 125 126

    Rectangle {
        id:             borderRect
127
        anchors.fill:   parent
dogmaphobic's avatar
dogmaphobic committed
128 129 130 131
        radius:         width / 2
        color:          Qt.rgba(0,0,0,0)
        border.color:   "black"
        border.width:   2
132
    }
dogmaphobic's avatar
dogmaphobic committed
133

dogmaphobic's avatar
dogmaphobic committed
134
}