QGCAttitudeWidget.qml 4.4 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
        visible:        false

        //----------------------------------------------------
        //-- Artificial Horizon
        QGCArtificialHorizon {
dogmaphobic's avatar
dogmaphobic committed
61 62 63
            rollAngle:          _rollAngle
            pitchAngle:         _pitchAngle
            anchors.fill:       parent
dogmaphobic's avatar
dogmaphobic committed
64 65 66 67
        }
        //----------------------------------------------------
        //-- Pointer
        Image {
dogmaphobic's avatar
dogmaphobic committed
68 69 70 71 72 73
            id:                 pointer
            source:             "/qmlimages/attitudePointer.svg"
            mipmap:             true
            fillMode:           Image.PreserveAspectFit
            anchors.fill:       parent
            sourceSize.height:  parent.height
dogmaphobic's avatar
dogmaphobic committed
74 75 76 77
        }
        //----------------------------------------------------
        //-- Instrument Dial
        Image {
dogmaphobic's avatar
dogmaphobic committed
78 79 80 81 82 83
            id:                 instrumentDial
            source:             "/qmlimages/attitudeDial.svg"
            mipmap:             true
            fillMode:           Image.PreserveAspectFit
            anchors.fill:       parent
            sourceSize.height:  parent.height
dogmaphobic's avatar
dogmaphobic committed
84
            transform: Rotation {
dogmaphobic's avatar
dogmaphobic committed
85 86 87
                origin.x:       root.width  / 2
                origin.y:       root.height / 2
                angle:          -_rollAngle
dogmaphobic's avatar
dogmaphobic committed
88 89 90 91 92 93 94
            }
        }
        //----------------------------------------------------
        //-- Pitch
        QGCPitchIndicator {
            id:                 pitchWidget
            visible:            root.showPitch
dogmaphobic's avatar
dogmaphobic committed
95
            size:               root.size * 0.5
dogmaphobic's avatar
dogmaphobic committed
96 97 98 99 100 101 102 103 104 105 106 107 108
            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
109
            sourceSize.width:   width
dogmaphobic's avatar
dogmaphobic committed
110
            fillMode:           Image.PreserveAspectFit
111
        }
dogmaphobic's avatar
dogmaphobic committed
112
    }
dogmaphobic's avatar
dogmaphobic committed
113 114 115 116 117 118 119

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

    OpacityMask {
        anchors.fill: instrument
        source: instrument
        maskSource: mask
126
    }
dogmaphobic's avatar
dogmaphobic committed
127 128 129

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

dogmaphobic's avatar
dogmaphobic committed
137
}