MissionItemStatus.qml 10.5 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
9 10 11 12 13 14 15 16


import QtQuick          2.5
import QtQuick.Controls 1.3

import QGroundControl.ScreenTools   1.0
import QGroundControl.Controls      1.0
import QGroundControl.Palette       1.0
17
import QGroundControl               1.0
18 19
import QGroundControl.FactSystem    1.0
import QGroundControl.FactControls  1.0
20 21

Rectangle {
22 23
    readonly property var       _activeVehicle:     QGroundControl.multiVehicleManager.activeVehicle

24 25 26 27
    property Fact   _offlineEditingVehicleType:     QGroundControl.offlineEditingVehicleType
    property Fact   _offlineEditingCruiseSpeed:     QGroundControl.offlineEditingCruiseSpeed
    property Fact   _offlineEditingHoverSpeed:      QGroundControl.offlineEditingHoverSpeed

28 29 30
    property var    currentMissionItem          ///< Mission item to display status for
    property var    missionItems                ///< List of all available mission items
    property real   expandedWidth               ///< Width of control when expanded
31 32 33 34
    property real   missionDistance
    property real   missionMaxTelemetry
    property real   cruiseDistance
    property real   hoverDistance
35 36

    width:      _expanded ? expandedWidth : _collapsedWidth
37
    height:     Math.max(valueGrid.height, valueMissionGrid.height) + (_margins * 2)
38
    radius:     ScreenTools.defaultFontPixelWidth * 0.5
39 40 41 42 43 44
    color:      qgcPal.window
    opacity:    0.80
    clip:       true

    readonly property real margins: ScreenTools.defaultFontPixelWidth

Don Gagne's avatar
Don Gagne committed
45
    property real   _collapsedWidth:    valueGrid.width + (margins * 2)
46
    property bool   _expanded:          true
47

Don Gagne's avatar
Don Gagne committed
48 49
    property real   _distance:          _statusValid ? _currentMissionItem.distance : 0
    property real   _altDifference:     _statusValid ? _currentMissionItem.altDifference : 0
50
    property real   _gradient:          _statusValid && _currentMissionItem.distance > 0 ? Math.atan(_currentMissionItem.altDifference / _currentMissionItem.distance) : 0
Don Gagne's avatar
Don Gagne committed
51 52
    property real   _gradientPercent:   isNaN(_gradient) ? 0 : _gradient * 100
    property real   _azimuth:           _statusValid ? _currentMissionItem.azimuth : -1
53 54
    property int    _numberShots:       _currentSurvey ? _currentMissionItem.cameraShots : 0
    property real   _coveredArea:       _currentSurvey ? _currentMissionItem.coveredArea : 0
55 56 57 58 59 60 61
    property real   _missionDistance:   _missionValid ? missionDistance : 0
    property real   _missionMaxTelemetry: _missionValid ? missionMaxTelemetry : 0
    property real   _missionTime:       _missionValid && _missionSpeed > 0 ?  (_isVTOL ? _hoverTime + _cruiseTime : _missionDistance / _missionSpeed) : 0
    property real   _hoverDistance:    _missionValid ? hoverDistance : 0
    property real   _cruiseDistance:    _missionValid ? cruiseDistance : 0
    property real   _hoverTime:         _missionValid && _offlineEditingHoverSpeed.value > 0 ? _hoverDistance / _offlineEditingHoverSpeed.value : 0
    property real   _cruiseTime:        _missionValid && _offlineEditingCruiseSpeed.value > 0 ? _cruiseDistance / _offlineEditingCruiseSpeed.value : 0
62

Don Gagne's avatar
Don Gagne committed
63
    property bool   _statusValid:       currentMissionItem != undefined
64 65
    property bool   _vehicleValid:      _activeVehicle != undefined
    property bool   _missionValid:      missionItems != undefined
66 67 68
    property bool   _currentSurvey:     _statusValid ? _currentMissionItem.commandName == "Survey" : false
    property bool   _isVTOL:            _vehicleValid ? _activeVehicle.vtol : _offlineEditingVehicleType.enumStringValue == "VTOL" //hardcoded
    property real   _missionSpeed:      _offlineEditingVehicleType.enumStringValue == "Fixedwing" ? _offlineEditingCruiseSpeed.value : _offlineEditingHoverSpeed.value
69

70 71 72 73
    property string _distanceText:      _statusValid ? QGroundControl.metersToAppSettingsDistanceUnits(_distance).toFixed(2) + " " + QGroundControl.appSettingsDistanceUnitsString : " "
    property string _altText:           _statusValid ? QGroundControl.metersToAppSettingsDistanceUnits(_altDifference).toFixed(2) + " " + QGroundControl.appSettingsDistanceUnitsString : " "
    property string _gradientText:      _statusValid ? _gradientPercent.toFixed(0) + "%" : " "
    property string _azimuthText:       _statusValid ? Math.round(_azimuth) : " "
74 75
    property string _numberShotsText:   _currentSurvey ? _numberShots.toFixed(0) : " "
    property string _coveredAreaText:   _currentSurvey ? QGroundControl.squareMetersToAppSettingsAreaUnits(_coveredArea).toFixed(2) + " " + QGroundControl.appSettingsAreaUnitsString : " "
76 77 78 79 80 81 82
    property string _missionDistanceText: _missionValid ? QGroundControl.metersToAppSettingsDistanceUnits(_missionDistance).toFixed(2) + " " + QGroundControl.appSettingsDistanceUnitsString : " "
    property string _missionTimeText:     _missionValid ? _missionTime.toFixed(0) + "s" : " "
    property string _missionMaxTelemetryText:  _missionValid ? QGroundControl.metersToAppSettingsDistanceUnits(_missionMaxTelemetry).toFixed(2) + " " + QGroundControl.appSettingsDistanceUnitsString : " "
    property string _hoverDistanceText: _missionValid ? QGroundControl.metersToAppSettingsDistanceUnits(_hoverDistance).toFixed(2) + " " + QGroundControl.appSettingsDistanceUnitsString : " "
    property string _cruiseDistanceText: _missionValid ? QGroundControl.metersToAppSettingsDistanceUnits(_cruiseDistance).toFixed(2) + " " + QGroundControl.appSettingsDistanceUnitsString : " "
    property string _hoverTimeText:     _missionValid ? _hoverTime.toFixed(0) + "s" : " "
    property string _cruiseTimeText:    _missionValid ? _cruiseTime.toFixed(0) + "s" : " "
83 84 85 86 87 88 89 90

    readonly property real _margins:    ScreenTools.defaultFontPixelWidth

    MouseArea {
        anchors.fill:   parent
        onClicked:      _expanded = !_expanded
    }

91 92
    Row {
        anchors.fill:       parent
93
        anchors.margins:    _margins
94
        spacing:            _margins
95

96 97 98 99 100
        Grid {
            id:                 valueGrid
            columns:            2
            columnSpacing:      _margins
            anchors.verticalCenter: parent.verticalCenter
101

102 103 104
            QGCLabel { text: qsTr("Selected waypoint") }
            QGCLabel { text: qsTr(" ") }

105 106
            QGCLabel { text: qsTr("Distance:") }
            QGCLabel { text: _distanceText }
Don Gagne's avatar
Don Gagne committed
107

108 109
            QGCLabel { text: qsTr("Alt diff:") }
            QGCLabel { text: _altText }
110

111 112
            QGCLabel { text: qsTr("Gradient:") }
            QGCLabel { text: _gradientText }
113

114 115
            QGCLabel { text: qsTr("Azimuth:") }
            QGCLabel { text: _azimuthText }
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133

            QGCLabel {
                text: qsTr("# shots:")
                visible: _currentSurvey
            }
            QGCLabel {
                text: _numberShotsText
                visible: _currentSurvey
            }

            QGCLabel {
                text: qsTr("Covered area:")
                visible: _currentSurvey
            }
            QGCLabel {
                text: _coveredAreaText
                visible: _currentSurvey
            }
134
        }
135

136
        ListView {
137 138
            id:                     statusListView
            model:                  missionItems
139
            highlightMoveDuration:  250
140 141 142 143
            anchors.leftMargin:     _margins
            anchors.rightMargin:    _margins
            anchors.top:            parent.top
            anchors.bottom:         parent.bottom
144
            orientation:            ListView.Horizontal
145
            spacing:                0
146
            visible:                _expanded
147
            width:                  parent.width - valueGrid.width - valueMissionGrid.width - (_margins * 2)
148
            clip:                   true
149
            currentIndex:           _currentMissionIndex
150

151 152
            delegate: Item {
                height:     statusListView.height
153 154
                width:      display ? (indicator.width + spacing)  : 0
                visible:    display
155 156 157

                property real availableHeight:  height - indicator.height
                property bool graphAbsolute:    true
158 159
                readonly property bool display: object.specifiesCoordinate && !object.isStandaloneCoordinate
                readonly property real spacing: ScreenTools.defaultFontPixelWidth * ScreenTools.smallFontPointRatio
160 161 162 163 164 165 166 167 168 169

                MissionItemIndexLabel {
                    id:                         indicator
                    anchors.horizontalCenter:   parent.horizontalCenter
                    y:                          availableHeight - (availableHeight * object.altPercent)
                    small:                      true
                    isCurrentItem:              object.isCurrentItem
                    label:                      object.abbreviation
                    visible:                    object.relativeAltitude ? true : (object.homePosition || graphAbsolute)
                }
170 171
            }
        }
172 173 174 175 176 177 178

        Grid {
            id:                 valueMissionGrid
            columns:            2
            columnSpacing:      _margins
            anchors.verticalCenter: parent.verticalCenter

179
            QGCLabel { text: qsTr("Total mission") }
180 181 182
            QGCLabel { text: qsTr(" ") }

            QGCLabel { text: qsTr("Distance:") }
183
            QGCLabel { text: _missionDistanceText }
184 185

            QGCLabel { text: qsTr("Time:") }
186
            QGCLabel { text: _missionTimeText }
187 188

            QGCLabel { text: qsTr("Max telem dist:") }
189
            QGCLabel { text: _missionMaxTelemetryText }
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226

            QGCLabel {
                text: qsTr("Hover distance:")
                visible: _isVTOL
            }
            QGCLabel {
                text: _hoverDistanceText
                visible: _isVTOL
            }

            QGCLabel {
                text: qsTr("Cruise distance:")
                visible: _isVTOL
            }
            QGCLabel {
                text: _cruiseDistanceText
                visible: _isVTOL
            }

            QGCLabel {
                text: qsTr("Hover time:")
                visible: _isVTOL
            }
            QGCLabel {
                text: _hoverTimeText
                visible: _isVTOL
            }

            QGCLabel {
                text: qsTr("Cruise time:")
                visible: _isVTOL
            }
            QGCLabel {
                text: _cruiseTimeText
                visible: _isVTOL
            }
        }
227 228
    }
}