PlanToolBar.qml 11.2 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.isMobile ? ScreenTools.smallFontPointSize : ScreenTools.defaultFontPointSize
43 44 45
    property real   _largeValueWidth:           ScreenTools.defaultFontPixelWidth * 8
    property real   _smallValueWidth:           ScreenTools.defaultFontPixelWidth * 4
    property real   _labelToValueSpacing:       ScreenTools.defaultFontPixelWidth
46
    property real   _rowSpacing:                ScreenTools.isMobile ? 1 : 0
47 48 49 50 51 52 53 54
    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
55 56 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
    property string _gradientText:              isNaN(_gradient) ?              "-.-" : _gradientPercent.toFixed(0) + "%"
    property string _azimuthText:               isNaN(_azimuth) ?               "-.-" : Math.round(_azimuth)
62 63
    property string _missionDistanceText:       isNaN(_missionDistance) ?       "-.-" : QGroundControl.metersToAppSettingsDistanceUnits(_missionDistance).toFixed(0) + " " + QGroundControl.appSettingsDistanceUnitsString
    property string _missionMaxTelemetryText:   isNaN(_missionMaxTelemetry) ?   "-.-" : QGroundControl.metersToAppSettingsDistanceUnits(_missionMaxTelemetry).toFixed(0) + " " + QGroundControl.appSettingsDistanceUnitsString
64 65
    property string _batteryChangePointText:    _batteryChangePoint < 0 ?       "N/A" : _batteryChangePoint
    property string _batteriesRequiredText:     _batteriesRequired < 0 ?        "N/A" : _batteriesRequired
66

Donald Gagne's avatar
Donald Gagne committed
67
    readonly property real _margins: ScreenTools.defaultFontPixelWidth
68 69 70

    QGCPalette { id: qgcPal }

71 72 73 74 75 76 77 78
    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
79 80 81 82 83 84 85 86
    //-- 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; }
    }

87 88
    //-- 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.
89 90 91 92 93
    Row {
        anchors.bottomMargin:   1
        anchors.left:           parent.left
        anchors.top:            parent.top
        anchors.bottom:         parent.bottom
94 95 96 97 98 99 100 101 102
        QGCToolBarButton {
            id:                 settingsButton
            anchors.top:        parent.top
            anchors.bottom:     parent.bottom
            source:             "/qmlimages/PaperPlane.svg"
            logo:               true
            checked:            false
            onClicked: {
                checked = false
103
                if (missionController.uploadOnSwitch()) {
104 105
                    showFlyView()
                }
106 107
            }
        }
108 109 110 111 112 113
    }


    Row {
        anchors.top:        parent.top
        anchors.bottom:     parent.bottom
114
        spacing:            _margins * 8
115
        anchors.horizontalCenter: parent.horizontalCenter
116 117

        GridLayout {
118 119
            anchors.verticalCenter: parent.verticalCenter
            columns:                5
120
            rowSpacing:             _rowSpacing
121
            columnSpacing:          _labelToValueSpacing
122 123

            QGCLabel {
124
                text:               qsTr("Selected Waypoint")
Donald Gagne's avatar
Donald Gagne committed
125 126
                Layout.columnSpan:  5
                font.pointSize:     ScreenTools.smallFontPointSize
127 128
            }

129
            QGCLabel { text: qsTr("Distance:"); font.pointSize: _dataFontSize; }
130 131
            QGCLabel {
                text:                   _distanceText
132
                font.pointSize:         _dataFontSize
133 134 135
                Layout.minimumWidth:    _largeValueWidth
                horizontalAlignment:    Text.AlignRight
            }
136

Donald Gagne's avatar
Donald Gagne committed
137 138
            Item { width: 1; height: 1 }

139
            QGCLabel { text: qsTr("Gradient:"); font.pointSize: _dataFontSize; }
140 141
            QGCLabel {
                text:                   _gradientText
142
                font.pointSize:         _dataFontSize
143 144 145
                Layout.minimumWidth:    _smallValueWidth
                horizontalAlignment:    Text.AlignRight
            }
146

147
            QGCLabel { text: qsTr("Alt diff:"); font.pointSize: _dataFontSize; }
148 149
            QGCLabel {
                text:                   _altDifferenceText
150
                font.pointSize:         _dataFontSize
151 152 153
                Layout.minimumWidth:    _largeValueWidth
                horizontalAlignment:    Text.AlignRight
            }
154

Donald Gagne's avatar
Donald Gagne committed
155 156
            Item { width: 1; height: 1 }

157
            QGCLabel { text: qsTr("Azimuth:"); font.pointSize: _dataFontSize; }
158 159
            QGCLabel {
                text:                   _azimuthText
160
                font.pointSize:         _dataFontSize
161 162 163
                Layout.minimumWidth:    _smallValueWidth
                horizontalAlignment:    Text.AlignRight
            }
164 165 166
        }

        GridLayout {
167 168
            anchors.verticalCenter: parent.verticalCenter
            columns:                5
169
            rowSpacing:             _rowSpacing
170
            columnSpacing:          _labelToValueSpacing
171 172

            QGCLabel {
173
                text:               qsTr("Total Mission")
Donald Gagne's avatar
Donald Gagne committed
174 175
                Layout.columnSpan:  5
                font.pointSize:     ScreenTools.smallFontPointSize
176 177
            }

178
            QGCLabel { text: qsTr("Distance:"); font.pointSize: _dataFontSize; }
179 180
            QGCLabel {
                text:                   _missionDistanceText
181
                font.pointSize:         _dataFontSize
182 183 184
                Layout.minimumWidth:    _largeValueWidth
                horizontalAlignment:    Text.AlignRight
            }
185

Donald Gagne's avatar
Donald Gagne committed
186 187
            Item { width: 1; height: 1 }

188
            QGCLabel { text: qsTr("Max telem dist:"); font.pointSize: _dataFontSize; }
189 190
            QGCLabel {
                text:                   _missionMaxTelemetryText
191
                font.pointSize:         _dataFontSize
192 193 194
                Layout.minimumWidth:    _largeValueWidth
                horizontalAlignment:    Text.AlignRight
            }
195

196
            QGCLabel { text: qsTr("Time:"); font.pointSize: _dataFontSize; }
197
            QGCLabel {
198 199
                text:                   getMissionTime()
                font.pointSize:         _dataFontSize
200 201 202
                Layout.minimumWidth:    _largeValueWidth
                horizontalAlignment:    Text.AlignRight
            }
203
        }
Donald Gagne's avatar
Donald Gagne committed
204 205

        GridLayout {
206 207
            anchors.verticalCenter: parent.verticalCenter
            columns:                3
208
            rowSpacing:             _rowSpacing
209
            columnSpacing:          _labelToValueSpacing
Donald Gagne's avatar
Donald Gagne committed
210 211 212 213 214 215 216

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

217
            QGCLabel { text: qsTr("Batteries required:"); font.pointSize: _dataFontSize; }
218 219
            QGCLabel {
                text:                   _batteriesRequiredText
220
                font.pointSize:         _dataFontSize
221 222 223
                horizontalAlignment:    Text.AlignRight
                Layout.minimumWidth:    _smallValueWidth
            }
Donald Gagne's avatar
Donald Gagne committed
224 225 226

            Item { width: 1; height: 1 }

227
            QGCLabel { text: qsTr("Swap waypoint:"); font.pointSize: _dataFontSize; }
228 229
            QGCLabel {
                text:                   _batteryChangePointText
230
                font.pointSize:         _dataFontSize
231 232 233
                horizontalAlignment:    Text.AlignRight
                Layout.minimumWidth:    _smallValueWidth
            }
Donald Gagne's avatar
Donald Gagne committed
234
        }
235
    }
236 237 238 239 240 241

    QGCButton {
        id:                     uploadButton
        anchors.rightMargin:    _margins
        anchors.right:          parent.right
        anchors.verticalCenter: parent.verticalCenter
242
        text:                   missionController ? (missionController.dirty ? qsTr("Upload Required") : qsTr("Upload")) : ""
243 244 245
        enabled:                _activeVehicle
        visible:                _manualUpload
        onClicked:              missionController.upload()
246
    }
247 248
}