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

import QtQuick 2.4

Don Gagne's avatar
Don Gagne committed
32 33 34
import QGroundControl.Controls      1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.FactSystem    1.0
dogmaphobic's avatar
dogmaphobic committed
35 36 37 38 39

Item {
    id:     root
    height: size

dogmaphobic's avatar
dogmaphobic committed
40 41
    signal clicked

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

Don Gagne's avatar
Don Gagne committed
49 50 51 52 53
    property Fact   _emptyFact:         Fact { }
    property Fact   groundSpeedFact:    _emptyFact
    property Fact   airSpeedFact:       _emptyFact
    property Fact   altitudeFact:       _emptyFact

dogmaphobic's avatar
dogmaphobic committed
54 55 56 57 58 59
    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
60

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