PlanToolBar.qml 11.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
import QtQuick          2.3
import QtQuick.Controls 1.2
import QtQuick.Layouts  1.2
import QtQuick.Dialogs  1.2

import QGroundControl                   1.0
import QGroundControl.ScreenTools       1.0
import QGroundControl.Controls          1.0
import QGroundControl.FactControls      1.0
import QGroundControl.Palette           1.0

// Toolbar for Plan View
Rectangle {
    id:                 _root
    height:             ScreenTools.toolbarHeight
    anchors.left:       parent.left
    anchors.right:      parent.right
    anchors.top:        parent.top
    z:                  toolBar.z + 1
Gus Grubba's avatar
Gus Grubba committed
20
    color:              qgcPal.globalTheme === QGCPalette.Light ? Qt.rgba(1,1,1,0.8) : Qt.rgba(0,0,0,0.75)
21
    visible:            false
22
    anchors.bottomMargin: 1
23 24 25 26 27 28

    signal showFlyView

    property var    missionController
    property var    currentMissionItem          ///< Mission item to display status for

Donald Gagne's avatar
Donald Gagne committed
29 30 31 32 33
    property var    missionItems:               _controllerValid ? missionController.visualItems : undefined
    property real   missionDistance:            _controllerValid ? missionController.missionDistance : NaN
    property real   missionTime:                _controllerValid ? missionController.missionTime : NaN
    property real   missionMaxTelemetry:        _controllerValid ? missionController.missionMaxTelemetry : NaN
    property bool   missionDirty:               _controllerValid ? missionController.dirty : false
34 35 36 37 38

    property var    _activeVehicle:             QGroundControl.multiVehicleManager.activeVehicle

    property bool   _statusValid:               currentMissionItem != undefined
    property bool   _missionValid:              missionItems != undefined
Donald Gagne's avatar
Donald Gagne committed
39
    property bool   _controllerValid:           missionController != undefined
40 41
    property bool   _manualUpload:              QGroundControl.settingsManager.appSettings.automaticMissionUpload.rawValue == 0

42
    property real   _dataFontSize:              ScreenTools.defaultFontPointSize
43
    property real   _largeValueWidth:           ScreenTools.defaultFontPixelWidth * 8
44 45
    property real   _mediumValueWidth:          ScreenTools.defaultFontPixelWidth * 4
    property real   _smallValueWidth:           ScreenTools.defaultFontPixelWidth * 3
46
    property real   _labelToValueSpacing:       ScreenTools.defaultFontPixelWidth
47
    property real   _rowSpacing:                ScreenTools.isMobile ? 1 : 0
48 49 50 51 52
    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
53
    property real   _heading:                   _statusValid ? currentMissionItem.missionVehicleYaw : NaN
54 55 56
    property real   _missionDistance:           _missionValid ? missionDistance : NaN
    property real   _missionMaxTelemetry:       _missionValid ? missionMaxTelemetry : NaN
    property real   _missionTime:               _missionValid ? missionTime : NaN
57 58 59 60 61
    property int    _batteryChangePoint:        _controllerValid ? missionController.batteryChangePoint : -1
    property int    _batteriesRequired:         _controllerValid ? missionController.batteriesRequired : -1

    property string _distanceText:              isNaN(_distance) ?              "-.-" : QGroundControl.metersToAppSettingsDistanceUnits(_distance).toFixed(1) + " " + QGroundControl.appSettingsDistanceUnitsString
    property string _altDifferenceText:         isNaN(_altDifference) ?         "-.-" : QGroundControl.metersToAppSettingsDistanceUnits(_altDifference).toFixed(1) + " " + QGroundControl.appSettingsDistanceUnitsString
62
    property string _gradientText:              isNaN(_gradient) ?              "-.-" : _gradientPercent.toFixed(0) + " %"
63
    property string _azimuthText:               isNaN(_azimuth) ?               "-.-" : Math.round(_azimuth)
64
    property string _headingText:               isNaN(_azimuth) ?               "-.-" : Math.round(_heading)
65 66
    property string _missionDistanceText:       isNaN(_missionDistance) ?       "-.-" : QGroundControl.metersToAppSettingsDistanceUnits(_missionDistance).toFixed(0) + " " + QGroundControl.appSettingsDistanceUnitsString
    property string _missionMaxTelemetryText:   isNaN(_missionMaxTelemetry) ?   "-.-" : QGroundControl.metersToAppSettingsDistanceUnits(_missionMaxTelemetry).toFixed(0) + " " + QGroundControl.appSettingsDistanceUnitsString
67 68
    property string _batteryChangePointText:    _batteryChangePoint < 0 ?       "N/A" : _batteryChangePoint
    property string _batteriesRequiredText:     _batteriesRequired < 0 ?        "N/A" : _batteriesRequired
69

Donald Gagne's avatar
Donald Gagne committed
70
    readonly property real _margins: ScreenTools.defaultFontPixelWidth
71 72 73

    QGCPalette { id: qgcPal }

74 75 76 77 78 79 80 81
    function getMissionTime() {
        if(isNaN(_missionTime)) {
            return "00:00:00"
        }
        var t = new Date(0, 0, 0, 0, 0, Number(_missionTime))
        return Qt.formatTime(t, 'hh:mm:ss')
    }

Gus Grubba's avatar
Gus Grubba committed
82 83 84 85 86 87 88 89
    //-- Eat mouse events, preventing them from reaching toolbar, which is underneath us.
    MouseArea {
        anchors.fill:   parent
        onWheel:        { wheel.accepted = true; }
        onPressed:      { mouse.accepted = true; }
        onReleased:     { mouse.accepted = true; }
    }

90 91
    //-- The reason for this Row to be here is so the Logo (Home) button is in the same
    //   location as the one in the main toolbar.
92
    Row {
93
        id:                     logoRow
94 95 96 97
        anchors.bottomMargin:   1
        anchors.left:           parent.left
        anchors.top:            parent.top
        anchors.bottom:         parent.bottom
98 99 100 101 102 103 104 105 106
        QGCToolBarButton {
            id:                 settingsButton
            anchors.top:        parent.top
            anchors.bottom:     parent.bottom
            source:             "/qmlimages/PaperPlane.svg"
            logo:               true
            checked:            false
            onClicked: {
                checked = false
107
                if (missionController.uploadOnSwitch()) {
108 109
                    showFlyView()
                }
110 111
            }
        }
112 113 114
    }


115 116 117 118 119 120 121 122
    RowLayout {
        anchors.top:            parent.top
        anchors.bottom:         parent.bottom
        spacing:                _margins * 2
        anchors.left:           logoRow.right
        anchors.leftMargin:     _margins * 4
        anchors.right:          uploadButton.visible ? uploadButton.left : parent.right
        anchors.rightMargin:    _margins
123 124

        GridLayout {
125
            anchors.verticalCenter: parent.verticalCenter
126
            columns:                8
127
            rowSpacing:             _rowSpacing
128
            columnSpacing:          _labelToValueSpacing
129 130

            QGCLabel {
131
                text:               qsTr("Selected Waypoint")
132
                Layout.columnSpan:  8
Donald Gagne's avatar
Donald Gagne committed
133
                font.pointSize:     ScreenTools.smallFontPointSize
134 135
            }

136
            QGCLabel { text: qsTr("Alt diff:"); font.pointSize: _dataFontSize; }
137
            QGCLabel {
138
                text:                   _altDifferenceText
139
                font.pointSize:         _dataFontSize
140
                Layout.minimumWidth:    _mediumValueWidth
141
            }
142

Donald Gagne's avatar
Donald Gagne committed
143 144
            Item { width: 1; height: 1 }

145
            QGCLabel { text: qsTr("Azimuth:"); font.pointSize: _dataFontSize; }
146
            QGCLabel {
147
                text:                   _azimuthText
148
                font.pointSize:         _dataFontSize
149 150
                Layout.minimumWidth:    _smallValueWidth
            }
151

152 153 154
            Item { width: 1; height: 1 }

            QGCLabel { text: qsTr("Distance:"); font.pointSize: _dataFontSize; }
155
            QGCLabel {
156
                text:                   _distanceText
157
                font.pointSize:         _dataFontSize
158
                Layout.minimumWidth:    _largeValueWidth
159 160 161 162 163 164 165
            }

            QGCLabel { text: qsTr("Gradient:"); font.pointSize: _dataFontSize; }
            QGCLabel {
                text:                   _gradientText
                font.pointSize:         _dataFontSize
                Layout.minimumWidth:    _mediumValueWidth
166
            }
167

Donald Gagne's avatar
Donald Gagne committed
168 169
            Item { width: 1; height: 1 }

170
            QGCLabel { text: qsTr("Heading:"); font.pointSize: _dataFontSize; }
171
            QGCLabel {
172
                text:                   _headingText
173
                font.pointSize:         _dataFontSize
174 175
                Layout.minimumWidth:    _smallValueWidth
            }
176 177 178
        }

        GridLayout {
179 180
            anchors.verticalCenter: parent.verticalCenter
            columns:                5
181
            rowSpacing:             _rowSpacing
182
            columnSpacing:          _labelToValueSpacing
183 184

            QGCLabel {
185
                text:               qsTr("Total Mission")
Donald Gagne's avatar
Donald Gagne committed
186 187
                Layout.columnSpan:  5
                font.pointSize:     ScreenTools.smallFontPointSize
188 189
            }

190
            QGCLabel { text: qsTr("Distance:"); font.pointSize: _dataFontSize; }
191 192
            QGCLabel {
                text:                   _missionDistanceText
193
                font.pointSize:         _dataFontSize
194 195
                Layout.minimumWidth:    _largeValueWidth
            }
196

Donald Gagne's avatar
Donald Gagne committed
197 198
            Item { width: 1; height: 1 }

199
            QGCLabel { text: qsTr("Max telem dist:"); font.pointSize: _dataFontSize; }
200 201
            QGCLabel {
                text:                   _missionMaxTelemetryText
202
                font.pointSize:         _dataFontSize
203 204
                Layout.minimumWidth:    _largeValueWidth
            }
205

206
            QGCLabel { text: qsTr("Time:"); font.pointSize: _dataFontSize; }
207
            QGCLabel {
208 209
                text:                   getMissionTime()
                font.pointSize:         _dataFontSize
210 211
                Layout.minimumWidth:    _largeValueWidth
            }
212
        }
Donald Gagne's avatar
Donald Gagne committed
213 214

        GridLayout {
215 216
            anchors.verticalCenter: parent.verticalCenter
            columns:                3
217
            rowSpacing:             _rowSpacing
218
            columnSpacing:          _labelToValueSpacing
Donald Gagne's avatar
Donald Gagne committed
219 220 221 222 223 224 225

            QGCLabel {
                text:               qsTr("Battery")
                Layout.columnSpan:  3
                font.pointSize:     ScreenTools.smallFontPointSize
            }

226
            QGCLabel { text: qsTr("Batteries required:"); font.pointSize: _dataFontSize; }
227 228
            QGCLabel {
                text:                   _batteriesRequiredText
229
                font.pointSize:         _dataFontSize
230
                Layout.minimumWidth:    _mediumValueWidth
231
            }
Donald Gagne's avatar
Donald Gagne committed
232 233 234

            Item { width: 1; height: 1 }

235
            QGCLabel { text: qsTr("Swap waypoint:"); font.pointSize: _dataFontSize; }
236 237
            QGCLabel {
                text:                   _batteryChangePointText
238
                font.pointSize:         _dataFontSize
239
                Layout.minimumWidth:    _mediumValueWidth
240
            }
Donald Gagne's avatar
Donald Gagne committed
241
        }
242
    }
243 244 245 246 247 248

    QGCButton {
        id:                     uploadButton
        anchors.rightMargin:    _margins
        anchors.right:          parent.right
        anchors.verticalCenter: parent.verticalCenter
249
        text:                   missionController ? (missionController.dirty ? qsTr("Upload Required") : qsTr("Upload")) : ""
250
        enabled:                _activeVehicle
251
        visible:                _activeVehicle && _manualUpload
252
        onClicked:              missionController.upload()
253 254 255 256 257 258 259 260 261 262

        PropertyAnimation on opacity {
            easing.type:    Easing.OutQuart
            from:           0.5
            to:             1
            loops:          Animation.Infinite
            running:        missionController ? missionController.dirty : false
            alwaysRunToEnd: true
            duration:       2000
        }
263
    }
264 265
}