QGCCompassHUD.qml 2.75 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 Compass HUD
dogmaphobic's avatar
dogmaphobic committed
27 28 29 30
 *   @author Gus Grubba <mavlink@grubba.com>
 */

import QtQuick 2.4
31
import QGroundControl.Controls 1.0
32
import QGroundControl.ScreenTools 1.0
dogmaphobic's avatar
dogmaphobic committed
33 34 35

Item {
    id:    root
36 37 38 39 40 41 42 43

    property bool active:   false  ///< true: actively connected to data provider, false: show inactive control
    property real heading:  _defaultHeading

    readonly property real _defaultHeading:   0

    property real _heading: active ? heading : _defaultHeading

dogmaphobic's avatar
dogmaphobic committed
44
    Image {
45 46 47 48 49 50 51
        id:                 compass
        anchors.centerIn:   parent
        source:             "/qmlimages/compass.svg"
        mipmap:             true
        width:              root.width
        fillMode:           Image.PreserveAspectFit

dogmaphobic's avatar
dogmaphobic committed
52
        transform: Rotation {
53 54 55
            origin.x:   compass.width  / 2
            origin.y:   compass.height / 2
            angle:      -_heading
dogmaphobic's avatar
dogmaphobic committed
56 57
        }
    }
58

dogmaphobic's avatar
dogmaphobic committed
59
    Image {
60 61 62 63 64 65 66
        id:                         pointer
        anchors.bottom:             compass.top
        anchors.horizontalCenter:   root.horizontalCenter
        source:                     "/qmlimages/compassNeedle.svg"
        smooth:                     true
        width:                      compass.width * 0.1
        fillMode:                   Image.PreserveAspectFit
dogmaphobic's avatar
dogmaphobic committed
67
    }
68

dogmaphobic's avatar
dogmaphobic committed
69
    Rectangle {
70 71 72 73 74 75
        anchors.centerIn:   compass
        width:              ScreenTools.defaultFontPixelSize * (3.33)
        height:             ScreenTools.defaultFontPixelSize * (2.08)
        border.color:       Qt.rgba(1,1,1,0.15)
        color:              Qt.rgba(0,0,0,0.25)

76
        QGCLabel {
77 78 79 80 81
            text:               _heading.toFixed(0)
            font.weight:        Font.DemiBold
            color:              "white"
            anchors.centerIn:   parent
            visible:            active
dogmaphobic's avatar
dogmaphobic committed
82 83 84
        }
    }
}