MissionItemStatus.qml 8.67 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

Rectangle {
20 21
    readonly property var       _activeVehicle:     QGroundControl.multiVehicleManager.activeVehicle

22 23 24 25 26
    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

    width:      _expanded ? expandedWidth : _collapsedWidth
27
    height:     Math.max(valueGrid.height, valueMissionGrid.height) + (_margins * 2)
28
    radius:     ScreenTools.defaultFontPixelWidth * 0.5
29 30 31 32 33 34
    color:      qgcPal.window
    opacity:    0.80
    clip:       true

    readonly property real margins: ScreenTools.defaultFontPixelWidth

Don Gagne's avatar
Don Gagne committed
35
    property real   _collapsedWidth:    valueGrid.width + (margins * 2)
36
    property bool   _expanded:          true
37

Don Gagne's avatar
Don Gagne committed
38 39
    property real   _distance:          _statusValid ? _currentMissionItem.distance : 0
    property real   _altDifference:     _statusValid ? _currentMissionItem.altDifference : 0
40
    property real   _gradient:          _statusValid || _currentMissionItem.distance == 0 ? Math.atan(_currentMissionItem.altDifference / _currentMissionItem.distance) : 0
Don Gagne's avatar
Don Gagne committed
41 42
    property real   _gradientPercent:   isNaN(_gradient) ? 0 : _gradient * 100
    property real   _azimuth:           _statusValid ? _currentMissionItem.azimuth : -1
43 44 45
    property int    _numberShots:       _currentSurvey ? _currentMissionItem.cameraShots : 0
    property real   _coveredArea:       _currentSurvey ? _currentMissionItem.coveredArea : 0

Don Gagne's avatar
Don Gagne committed
46
    property bool   _statusValid:       currentMissionItem != undefined
47 48 49
    property bool   _vehicleValid:      _activeVehicle != undefined
    property bool   _missionValid:      missionItems != undefined
    property bool   _currentSurvey:     _statusValid ? currentMissionItem.commandName == "Survey" : false
50 51
    property bool   _isVTOL:            _vehicleValid ? _activeVehicle.vtol : false

52 53 54 55
    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) : " "
56 57
    property string _numberShotsText:   _currentSurvey ? _numberShots.toFixed(0) : " "
    property string _coveredAreaText:   _currentSurvey ? QGroundControl.squareMetersToAppSettingsAreaUnits(_coveredArea).toFixed(2) + " " + QGroundControl.appSettingsAreaUnitsString : " "
58 59 60 61 62 63 64
    property string _totalDistanceText: _missionValid ? "30.91" + " " + QGroundControl.appSettingsDistanceUnitsString : " "
    property string _totalTimeText:     _missionValid ? "34min 23s" : " "
    property string _maxTelemDistText:  _missionValid ? "5.23" + " " + QGroundControl.appSettingsDistanceUnitsString : " "
    property string _hoverDistanceText: _missionValid ? "0.47" + " " + QGroundControl.appSettingsDistanceUnitsString : " "
    property string _cruiseDistanceText: _missionValid ? "30.44" + " " + QGroundControl.appSettingsDistanceUnitsString : " "
    property string _hoverTimeText:     _missionValid ? "4min 02s" : " "
    property string _cruiseTimeText:    _missionValid ? "34min 21s" : " "
65 66 67 68 69 70 71 72

    readonly property real _margins:    ScreenTools.defaultFontPixelWidth

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

73 74
    Row {
        anchors.fill:       parent
75
        anchors.margins:    _margins
76
        spacing:            _margins
77

78 79 80 81 82
        Grid {
            id:                 valueGrid
            columns:            2
            columnSpacing:      _margins
            anchors.verticalCenter: parent.verticalCenter
83

84 85 86
            QGCLabel { text: qsTr("Selected waypoint") }
            QGCLabel { text: qsTr(" ") }

87 88
            QGCLabel { text: qsTr("Distance:") }
            QGCLabel { text: _distanceText }
Don Gagne's avatar
Don Gagne committed
89

90 91
            QGCLabel { text: qsTr("Alt diff:") }
            QGCLabel { text: _altText }
92

93 94
            QGCLabel { text: qsTr("Gradient:") }
            QGCLabel { text: _gradientText }
95

96 97
            QGCLabel { text: qsTr("Azimuth:") }
            QGCLabel { text: _azimuthText }
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115

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

            QGCLabel {
                text: qsTr("Covered area:")
                visible: _currentSurvey
            }
            QGCLabel {
                text: _coveredAreaText
                visible: _currentSurvey
            }
116
        }
117

118
        ListView {
119 120
            id:                     statusListView
            model:                  missionItems
121
            highlightMoveDuration:  250
122 123 124 125
            anchors.leftMargin:     _margins
            anchors.rightMargin:    _margins
            anchors.top:            parent.top
            anchors.bottom:         parent.bottom
126
            orientation:            ListView.Horizontal
127
            spacing:                0
128
            visible:                _expanded
129
            width:                  parent.width - valueGrid.width - valueMissionGrid.width - (_margins * 2)
130
            clip:                   true
131
            currentIndex:           _currentMissionIndex
132

133 134
            delegate: Item {
                height:     statusListView.height
135 136
                width:      display ? (indicator.width + spacing)  : 0
                visible:    display
137 138 139

                property real availableHeight:  height - indicator.height
                property bool graphAbsolute:    true
140 141
                readonly property bool display: object.specifiesCoordinate && !object.isStandaloneCoordinate
                readonly property real spacing: ScreenTools.defaultFontPixelWidth * ScreenTools.smallFontPointRatio
142 143 144 145 146 147 148 149 150 151

                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)
                }
152 153
            }
        }
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208

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

            QGCLabel { text: qsTr("Total mission [WIP]") }
            QGCLabel { text: qsTr(" ") }

            QGCLabel { text: qsTr("Distance:") }
            QGCLabel { text: _totalDistanceText }

            QGCLabel { text: qsTr("Time:") }
            QGCLabel { text: _totalTimeText }

            QGCLabel { text: qsTr("Max telem dist:") }
            QGCLabel { text: _maxTelemDistText }

            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
            }
        }
209 210
    }
}