QGCInstrumentWidget.qml 9.23 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 26 27 28 29 30 31 32 33 34 35 36 37 38
/*=====================================================================

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
 *   @brief QGC Compass Widget
 *   @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

39 40 41
    property alias  heading:        compass.heading
    property alias  rollAngle:      attitude.rollAngle
    property alias  pitchAngle:     attitude.pitchAngle
dogmaphobic's avatar
dogmaphobic committed
42 43 44 45
    property real   altitude:       0
    property real   groundSpeed:    0
    property real   airSpeed:       0
    property real   climbRate:      0
46 47 48 49 50 51 52
    property real   size:           ScreenTools.defaultFontPixelSize * (10)
    property bool   isSatellite:    false
    property bool   active:         false

    property bool   _isVisible:     true

    //-- Instrument Pannel
dogmaphobic's avatar
dogmaphobic committed
53
    Rectangle {
54 55 56 57 58 59 60 61
        id:                     instrumentPannel
        height:                 instruments.height + ScreenTools.defaultFontPixelSize
        width:                  root.size
        radius:                 root.size / 2
        visible:                _isVisible
        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
62
        Column {
dogmaphobic's avatar
dogmaphobic committed
63
            id:                 instruments
dogmaphobic's avatar
dogmaphobic committed
64 65 66 67
            width:              parent.width
            spacing:            ScreenTools.defaultFontPixelSize * 0.33
            anchors.verticalCenter: parent.verticalCenter
            //-- Attitude Indicator
dogmaphobic's avatar
dogmaphobic committed
68 69
            QGCAttitudeWidget {
                id:             attitude
dogmaphobic's avatar
dogmaphobic committed
70
                size:           parent.width * 0.9
71
                active:         root.active
dogmaphobic's avatar
dogmaphobic committed
72 73 74 75 76 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
            }
            Row {
                width: root.size * 0.8
                anchors.horizontalCenter: parent.horizontalCenter
                QGCLabel {
                    text:           "H"
86
                    font.pixelSize: ScreenTools.defaultFontPixelSize * 1.25
dogmaphobic's avatar
dogmaphobic committed
87 88 89 90 91
                    width:          parent.width * 0.45
                    color:          isSatellite ? "black" : "white"
                    horizontalAlignment: TextEdit.AlignHCenter
                }
                QGCLabel {
92
                    text:           altitude.toFixed(1)
93
                    font.pixelSize: ScreenTools.defaultFontPixelSize * 1.25
dogmaphobic's avatar
dogmaphobic committed
94
                    font.weight:    Font.DemiBold
95
                    width:          parent.width * 0.549
dogmaphobic's avatar
dogmaphobic committed
96
                    color:          isSatellite ? "black" : "white"
97
                    horizontalAlignment: TextEdit.AlignHCenter
dogmaphobic's avatar
dogmaphobic committed
98 99 100 101 102 103 104 105 106 107 108 109 110 111
                }
            }
            //-- 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
            }
            Row {
                width: root.size * 0.8
                anchors.horizontalCenter: parent.horizontalCenter
                QGCLabel {
                    text:           "GS"
112
                    font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75
dogmaphobic's avatar
dogmaphobic committed
113 114 115 116 117
                    width:          parent.width * 0.45
                    color:          isSatellite ? "black" : "white"
                    horizontalAlignment: TextEdit.AlignHCenter
                }
                QGCLabel {
118
                    text:           groundSpeed.toFixed(1)
119
                    font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75
dogmaphobic's avatar
dogmaphobic committed
120
                    font.weight:    Font.DemiBold
121
                    width:          parent.width * 0.549
dogmaphobic's avatar
dogmaphobic committed
122
                    color:          isSatellite ? "black" : "white"
123
                    horizontalAlignment: TextEdit.AlignHCenter
dogmaphobic's avatar
dogmaphobic committed
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
                }
            }
            //-- 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
                visible:        airSpeed > 0
            }
            Row {
                width: root.size * 0.8
                anchors.horizontalCenter: parent.horizontalCenter
                visible:        airSpeed > 0
                QGCLabel {
                    text:           "AS"
140
                    font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75
dogmaphobic's avatar
dogmaphobic committed
141 142 143 144 145
                    width:          parent.width * 0.45
                    color:          isSatellite ? "black" : "white"
                    horizontalAlignment: TextEdit.AlignHCenter
                }
                QGCLabel {
146
                    text:           airSpeed.toFixed(1)
147
                    font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75
dogmaphobic's avatar
dogmaphobic committed
148
                    font.weight:    Font.DemiBold
149
                    width:          parent.width * 0.549
dogmaphobic's avatar
dogmaphobic committed
150
                    color:          isSatellite ? "black" : "white"
151
                    horizontalAlignment: TextEdit.AlignHCenter
dogmaphobic's avatar
dogmaphobic committed
152 153 154 155 156 157 158 159 160 161 162 163 164 165
                }
            }
            //-- Climb Rate
            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
            }
            Row {
                width: root.size * 0.8
                anchors.horizontalCenter: parent.horizontalCenter
                QGCLabel {
                    text:           "VS"
166
                    font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75
dogmaphobic's avatar
dogmaphobic committed
167 168 169 170 171
                    width:          parent.width * 0.45
                    color:          isSatellite ? "black" : "white"
                    horizontalAlignment: TextEdit.AlignHCenter
                }
                QGCLabel {
172
                    text:           climbRate.toFixed(1)
173
                    font.pixelSize: ScreenTools.defaultFontPixelSize * 0.75
dogmaphobic's avatar
dogmaphobic committed
174
                    font.weight:    Font.DemiBold
175
                    width:          parent.width * 0.549
dogmaphobic's avatar
dogmaphobic committed
176
                    color:          isSatellite ? "black" : "white"
177
                    horizontalAlignment: TextEdit.AlignHCenter
dogmaphobic's avatar
dogmaphobic committed
178 179 180 181 182 183 184 185
                }
            }
            //-- 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
186 187 188
            }
            QGCCompassWidget {
                id:             compass
dogmaphobic's avatar
dogmaphobic committed
189
                size:           parent.width * 0.9
190
                active:         root.active
dogmaphobic's avatar
dogmaphobic committed
191
                anchors.horizontalCenter: parent.horizontalCenter
dogmaphobic's avatar
dogmaphobic committed
192 193
            }
        }
194 195 196 197 198 199 200
        MouseArea {
            anchors.fill: parent
            onClicked: {
                _isVisible = !_isVisible
            }
        }
    }
dogmaphobic's avatar
dogmaphobic committed
201

202 203
    //-- Show Instruments
    Rectangle {
204 205 206 207 208 209 210 211
        id:                     openButton
        anchors.right:          parent.right
        anchors.verticalCenter: parent.verticalCenter
        height:                 ScreenTools.defaultFontPixelSize * 2
        width:                  ScreenTools.defaultFontPixelSize * 2
        radius:                 ScreenTools.defaultFontPixelSize / 3
        visible:                !_isVisible
        color:                  isSatellite ? Qt.rgba(1,1,1,0.5) : Qt.rgba(0,0,0,0.5)
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
        Image {
            width:              parent.width  * 0.75
            height:             parent.height * 0.75
            source:             "/qmlimages/buttonLeft.svg"
            mipmap:             true
            fillMode:           Image.PreserveAspectFit
            anchors.verticalCenter:     parent.verticalCenter
            anchors.horizontalCenter:   parent.horizontalCenter
        }
        MouseArea {
            anchors.fill: parent
            onClicked: {
                _isVisible = !_isVisible
            }
        }
dogmaphobic's avatar
dogmaphobic committed
227
    }
228

dogmaphobic's avatar
dogmaphobic committed
229
}