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


import QtQuick          2.5
import QtQuick.Controls 1.3
13
import QtQuick.Layouts  1.2
14 15 16 17

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

Rectangle {
    width:      _expanded ? expandedWidth : _collapsedWidth
24
    height:     Math.max(valueGrid.height, valueMissionGrid.height) + (_margins * 2)
25
    radius:     ScreenTools.defaultFontPixelWidth * 0.5
26 27 28 29
    color:      qgcPal.window
    opacity:    0.80
    clip:       true

30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
    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
    property real   missionDistance             ///< Total mission distance
    property real   missionTime                 ///< Total mission time
    property real   missionMaxTelemetry

    property real   _collapsedWidth:            valueGrid.width + (_margins * 2)
    property bool   _expanded:                  true

    property bool   _statusValid:               currentMissionItem != undefined
    property bool   _missionValid:              missionItems != undefined

    property real   _distance:                  _statusValid ? _currentMissionItem.distance : NaN
    property real   _altDifference:             _statusValid ? _currentMissionItem.altDifference : NaN
    property real   _gradient:                  _statusValid && _currentMissionItem.distance > 0 ? Math.atan(_currentMissionItem.altDifference / _currentMissionItem.distance) : NaN
    property real   _gradientPercent:           isNaN(_gradient) ? NaN : _gradient * 100
    property real   _azimuth:                   _statusValid ? _currentMissionItem.azimuth : NaN
    property real   _missionDistance:           _missionValid ? missionDistance : NaN
    property real   _missionMaxTelemetry:       _missionValid ? missionMaxTelemetry : NaN
    property real   _missionTime:               _missionValid ? missionTime : NaN

    property string _distanceText:              isNaN(_distance) ? "-.-" : QGroundControl.metersToAppSettingsDistanceUnits(_distance).toFixed(2) + " " + QGroundControl.appSettingsDistanceUnitsString
    property string _altDifferenceText:         isNaN(_altDifference) ? "-.-" : QGroundControl.metersToAppSettingsDistanceUnits(_altDifference).toFixed(2) + " " + QGroundControl.appSettingsDistanceUnitsString
    property string _gradientText:              isNaN(_gradient) ? "-.-" : _gradientPercent.toFixed(0) + "%"
    property string _azimuthText:               isNaN(_azimuth) ? "-.-" : Math.round(_azimuth)
    property string _missionDistanceText:       isNaN(_missionDistance) ? "-.-" : QGroundControl.metersToAppSettingsDistanceUnits(_missionDistance).toFixed(2) + " " + QGroundControl.appSettingsDistanceUnitsString
    property string _missionTimeText:           isNaN(_missionTime) ? "-.-" : Number(_missionTime / 60).toFixed(1) + " min"
    property string _missionMaxTelemetryText:   isNaN(_missionMaxTelemetry) ? "-.-" : QGroundControl.metersToAppSettingsDistanceUnits(_missionMaxTelemetry).toFixed(2) + " " + QGroundControl.appSettingsDistanceUnitsString
59 60 61 62 63 64 65 66

    readonly property real _margins:    ScreenTools.defaultFontPixelWidth

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

67 68
    Row {
        anchors.fill:       parent
69
        anchors.margins:    _margins
70
        spacing:            _margins
71

72 73 74 75 76
        GridLayout {
            id:                     valueGrid
            columns:                2
            rowSpacing:             0
            columnSpacing:          _margins
77
            anchors.verticalCenter: parent.verticalCenter
78

79
            QGCLabel { text: qsTr("Selected waypoint"); Layout.columnSpan: 2 }
80

81 82
            QGCLabel { text: qsTr("Distance:") }
            QGCLabel { text: _distanceText }
Don Gagne's avatar
Don Gagne committed
83

84
            QGCLabel { text: qsTr("Alt diff:") }
85
            QGCLabel { text: _altDifferenceText }
86

87 88
            QGCLabel { text: qsTr("Gradient:") }
            QGCLabel { text: _gradientText }
89

90 91 92
            QGCLabel { text: qsTr("Azimuth:") }
            QGCLabel { text: _azimuthText }
        }
93

Don Gagne's avatar
Don Gagne committed
94
        QGCListView {
95 96
            id:                     statusListView
            model:                  missionItems
97
            highlightMoveDuration:  250
98 99 100 101
            anchors.leftMargin:     _margins
            anchors.rightMargin:    _margins
            anchors.top:            parent.top
            anchors.bottom:         parent.bottom
102
            orientation:            ListView.Horizontal
103
            spacing:                0
104
            visible:                _expanded
105
            width:                  parent.width - valueGrid.width - valueMissionGrid.width - (_margins * 2)
106
            clip:                   true
107
            currentIndex:           _currentMissionIndex
108

109 110
            delegate: Item {
                height:     statusListView.height
111 112
                width:      display ? (indicator.width + spacing)  : 0
                visible:    display
113 114 115

                property real availableHeight:  height - indicator.height
                property bool graphAbsolute:    true
116 117
                readonly property bool display: object.specifiesCoordinate && !object.isStandaloneCoordinate
                readonly property real spacing: ScreenTools.defaultFontPixelWidth * ScreenTools.smallFontPointRatio
118 119 120 121 122 123

                MissionItemIndexLabel {
                    id:                         indicator
                    anchors.horizontalCenter:   parent.horizontalCenter
                    y:                          availableHeight - (availableHeight * object.altPercent)
                    small:                      true
124
                    checked:                    object.isCurrentItem
125 126 127
                    label:                      object.abbreviation
                    visible:                    object.relativeAltitude ? true : (object.homePosition || graphAbsolute)
                }
128 129
            }
        }
130 131 132 133 134 135 136

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

137
            QGCLabel { text: qsTr("Total mission") }
138 139 140
            QGCLabel { text: qsTr(" ") }

            QGCLabel { text: qsTr("Distance:") }
141
            QGCLabel { text: _missionDistanceText }
142 143

            QGCLabel { text: qsTr("Time:") }
144
            QGCLabel { text: _missionTimeText }
145 146

            QGCLabel { text: qsTr("Max telem dist:") }
147
            QGCLabel { text: _missionMaxTelemetryText }
148
        }
149 150
    }
}