QGCInstrumentWidget.qml 7.11 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
dogmaphobic's avatar
dogmaphobic committed
26
 *   @brief QGC Fly View Widgets
dogmaphobic's avatar
dogmaphobic committed
27 28 29 30 31 32 33 34 35 36 37 38
 *   @author Gus Grubba <mavlink@grubba.com>
 */

import QtQuick 2.4

import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0

Item {
    id:     root
    height: size

dogmaphobic's avatar
dogmaphobic committed
39 40
    signal clicked

41 42 43
    property alias  heading:        compass.heading
    property alias  rollAngle:      attitude.rollAngle
    property alias  pitchAngle:     attitude.pitchAngle
dogmaphobic's avatar
dogmaphobic committed
44 45 46
    property real   altitude:       0
    property real   groundSpeed:    0
    property real   airSpeed:       0
dogmaphobic's avatar
dogmaphobic committed
47
    property real   size:           _defaultSize
48 49 50
    property bool   isSatellite:    false
    property bool   active:         false

dogmaphobic's avatar
dogmaphobic committed
51 52 53 54 55 56
    property real   _defaultSize:   ScreenTools.defaultFontPixelSize * (9)

    property real   _sizeRatio:     ScreenTools.isTinyScreen ? (size / _defaultSize) * 0.5 : size / _defaultSize
    property real   _bigFontSize:   ScreenTools.defaultFontPixelSize * 2.5  * _sizeRatio
    property real   _normalFontSize:ScreenTools.defaultFontPixelSize * 1.5  * _sizeRatio
    property real   _labelFontSize: ScreenTools.defaultFontPixelSize * 0.75 * _sizeRatio
57

dogmaphobic's avatar
dogmaphobic committed
58
    //-- Instrument Panel
dogmaphobic's avatar
dogmaphobic committed
59
    Rectangle {
dogmaphobic's avatar
dogmaphobic committed
60
        id:                     instrumentPanel
dogmaphobic's avatar
dogmaphobic committed
61
        height:                 instruments.height + (size * 0.05)
62 63 64 65 66
        width:                  root.size
        radius:                 root.size / 2
        color:                  isSatellite ? Qt.rgba(1,1,1,0.75) : Qt.rgba(0,0,0,0.75)
        anchors.right:          parent.right
        anchors.verticalCenter: parent.verticalCenter
dogmaphobic's avatar
dogmaphobic committed
67
        Column {
dogmaphobic's avatar
dogmaphobic committed
68
            id:                 instruments
dogmaphobic's avatar
dogmaphobic committed
69 70 71 72
            width:              parent.width
            spacing:            ScreenTools.defaultFontPixelSize * 0.33
            anchors.verticalCenter: parent.verticalCenter
            //-- Attitude Indicator
dogmaphobic's avatar
dogmaphobic committed
73 74
            QGCAttitudeWidget {
                id:             attitude
dogmaphobic's avatar
dogmaphobic committed
75
                size:           parent.width * 0.95
76
                active:         root.active
dogmaphobic's avatar
dogmaphobic committed
77 78 79 80 81 82 83 84 85
                anchors.horizontalCenter: parent.horizontalCenter
            }
            //-- Altitude
            Rectangle {
                height:         1
                width:          parent.width * 0.9
                color:          isSatellite ? Qt.rgba(0,0,0,0.25) : Qt.rgba(1,1,1,0.25)
                anchors.horizontalCenter: parent.horizontalCenter
            }
86
            QGCLabel {
dogmaphobic's avatar
dogmaphobic committed
87 88
                text:           "Altitude (m)"
                font.pixelSize: _labelFontSize
89
                width:          parent.width
dogmaphobic's avatar
dogmaphobic committed
90
                height:         _labelFontSize
91 92 93 94 95
                color:          isSatellite ? "black" : "white"
                horizontalAlignment: TextEdit.AlignHCenter
            }
            QGCLabel {
                text:           altitude < 10000 ? altitude.toFixed(1) : altitude.toFixed(0)
dogmaphobic's avatar
dogmaphobic committed
96
                font.pixelSize: _bigFontSize
97 98 99 100
                font.weight:    Font.DemiBold
                width:          parent.width
                color:          isSatellite ? "black" : "white"
                horizontalAlignment: TextEdit.AlignHCenter
dogmaphobic's avatar
dogmaphobic committed
101 102 103 104 105 106 107
            }
            //-- Ground Speed
            Rectangle {
                height:         1
                width:          parent.width * 0.9
                color:          isSatellite ? Qt.rgba(0,0,0,0.25) : Qt.rgba(1,1,1,0.25)
                anchors.horizontalCenter: parent.horizontalCenter
dogmaphobic's avatar
dogmaphobic committed
108
                visible:        airSpeed <= 0 && !ScreenTools.isTinyScreen
dogmaphobic's avatar
dogmaphobic committed
109
            }
110
            QGCLabel {
dogmaphobic's avatar
dogmaphobic committed
111 112
                text:           "Ground Speed (km/h)"
                font.pixelSize: _labelFontSize
113
                width:          parent.width
dogmaphobic's avatar
dogmaphobic committed
114
                height:         _labelFontSize
115 116
                color:          isSatellite ? "black" : "white"
                horizontalAlignment: TextEdit.AlignHCenter
dogmaphobic's avatar
dogmaphobic committed
117
                visible:        airSpeed <= 0 && !ScreenTools.isTinyScreen
118 119
            }
            QGCLabel {
dogmaphobic's avatar
dogmaphobic committed
120 121
                text:           (groundSpeed * 3.6).toFixed(1)
                font.pixelSize: _normalFontSize
122 123 124 125
                font.weight:    Font.DemiBold
                width:          parent.width
                color:          isSatellite ? "black" : "white"
                horizontalAlignment: TextEdit.AlignHCenter
dogmaphobic's avatar
dogmaphobic committed
126
                visible:        airSpeed <= 0 && !ScreenTools.isTinyScreen
dogmaphobic's avatar
dogmaphobic committed
127 128 129 130 131 132 133
            }
            //-- Air Speed
            Rectangle {
                height:         1
                width:          parent.width * 0.9
                color:          isSatellite ? Qt.rgba(0,0,0,0.25) : Qt.rgba(1,1,1,0.25)
                anchors.horizontalCenter: parent.horizontalCenter
dogmaphobic's avatar
dogmaphobic committed
134
                visible:        airSpeed > 0 && !ScreenTools.isTinyScreen
dogmaphobic's avatar
dogmaphobic committed
135
            }
136
            QGCLabel {
dogmaphobic's avatar
dogmaphobic committed
137 138
                text:           "Air Speed (km/h)"
                font.pixelSize: _labelFontSize
139
                width:          parent.width
dogmaphobic's avatar
dogmaphobic committed
140
                height:         _labelFontSize
141
                color:          isSatellite ? "black" : "white"
dogmaphobic's avatar
dogmaphobic committed
142
                visible:        airSpeed > 0 && !ScreenTools.isTinyScreen
143
                horizontalAlignment: TextEdit.AlignHCenter
dogmaphobic's avatar
dogmaphobic committed
144
            }
145
            QGCLabel {
dogmaphobic's avatar
dogmaphobic committed
146 147
                text:           (airSpeed * 3.6).toFixed(1)
                font.pixelSize: _normalFontSize
148 149 150
                font.weight:    Font.DemiBold
                width:          parent.width
                color:          isSatellite ? "black" : "white"
dogmaphobic's avatar
dogmaphobic committed
151
                visible:        airSpeed > 0 && !ScreenTools.isTinyScreen
152
                horizontalAlignment: TextEdit.AlignHCenter
dogmaphobic's avatar
dogmaphobic committed
153 154 155 156 157 158 159
            }
            //-- Compass
            Rectangle {
                height:         1
                width:          parent.width * 0.9
                color:          isSatellite ? Qt.rgba(0,0,0,0.25) : Qt.rgba(1,1,1,0.25)
                anchors.horizontalCenter: parent.horizontalCenter
dogmaphobic's avatar
dogmaphobic committed
160 161 162
            }
            QGCCompassWidget {
                id:             compass
dogmaphobic's avatar
dogmaphobic committed
163
                size:           parent.width * 0.95
164
                active:         root.active
dogmaphobic's avatar
dogmaphobic committed
165
                anchors.horizontalCenter: parent.horizontalCenter
dogmaphobic's avatar
dogmaphobic committed
166 167
            }
        }
168 169 170
        MouseArea {
            anchors.fill: parent
            onClicked: {
dogmaphobic's avatar
dogmaphobic committed
171
                onClicked: root.clicked()
172 173 174
            }
        }
    }
dogmaphobic's avatar
dogmaphobic committed
175
}