PlanToolBar.qml 10.1 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 22 23 24 25 26 27
    visible:            false

    signal showFlyView

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

Donald Gagne's avatar
Donald Gagne committed
28 29 30 31 32
    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
33 34 35 36 37

    property var    _activeVehicle:             QGroundControl.multiVehicleManager.activeVehicle

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

    Connections {
        target: QGroundControl.settingsManager.appSettings.automaticMissionUpload
        onRawValueChanged: console.log("changed", QGroundControl.settingsManager.appSettings.automaticMissionUpload.rawValue)
    }
45

46 47 48
    property real   _largeValueWidth:           ScreenTools.defaultFontPixelWidth * 8
    property real   _smallValueWidth:           ScreenTools.defaultFontPixelWidth * 4
    property real   _labelToValueSpacing:       ScreenTools.defaultFontPixelWidth
49 50 51 52 53 54 55 56
    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
57 58 59 60 61 62 63
    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)
64 65 66
    property string _missionDistanceText:       isNaN(_missionDistance) ?       "-.-" : QGroundControl.metersToAppSettingsDistanceUnits(_missionDistance).toFixed(0) + " " + QGroundControl.appSettingsDistanceUnitsString
    property string _missionTimeText:           isNaN(_missionTime) ?           "-.-" : Number(_missionTime / 60).toFixed(0) + " min"
    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 }

Gus Grubba's avatar
Gus Grubba committed
74 75 76 77 78 79 80 81
    //-- 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; }
    }

82
    RowLayout {
83 84
        anchors.top:    parent.top
        anchors.bottom: parent.bottom
85 86
        anchors.left:   parent.left
        anchors.right:  uploadButton.visible ? uploadButton.left : uploadButton.right
87 88 89 90 91 92 93 94 95 96 97 98
        spacing:        ScreenTools.defaultFontPixelWidth * 2

        QGCToolBarButton {
            id:                 settingsButton
            anchors.top:        parent.top
            anchors.bottom:     parent.bottom
            source:             "/qmlimages/PaperPlane.svg"
            logo:               true
            checked:            false

            onClicked: {
                checked = false
99
                if (missionController.uploadOnSwitch()) {
100 101
                    showFlyView()
                }
102 103 104 105
            }
        }

        GridLayout {
106 107 108 109
            anchors.verticalCenter: parent.verticalCenter
            columns:                5
            rowSpacing:             0
            columnSpacing:          _labelToValueSpacing
110 111

            QGCLabel {
Donald Gagne's avatar
Donald Gagne committed
112 113 114
                text:               qsTr("Selected waypoint")
                Layout.columnSpan:  5
                font.pointSize:     ScreenTools.smallFontPointSize
115 116 117
            }

            QGCLabel { text: qsTr("Distance:") }
118 119 120 121 122
            QGCLabel {
                text:                   _distanceText
                Layout.minimumWidth:    _largeValueWidth
                horizontalAlignment:    Text.AlignRight
            }
123

Donald Gagne's avatar
Donald Gagne committed
124 125
            Item { width: 1; height: 1 }

126
            QGCLabel { text: qsTr("Gradient:") }
127 128 129 130 131
            QGCLabel {
                text:                   _gradientText
                Layout.minimumWidth:    _smallValueWidth
                horizontalAlignment:    Text.AlignRight
            }
132 133

            QGCLabel { text: qsTr("Alt diff:") }
134 135 136 137 138
            QGCLabel {
                text:                   _altDifferenceText
                Layout.minimumWidth:    _largeValueWidth
                horizontalAlignment:    Text.AlignRight
            }
139

Donald Gagne's avatar
Donald Gagne committed
140 141
            Item { width: 1; height: 1 }

142
            QGCLabel { text: qsTr("Azimuth:") }
143 144 145 146 147
            QGCLabel {
                text:                   _azimuthText
                Layout.minimumWidth:    _smallValueWidth
                horizontalAlignment:    Text.AlignRight
            }
148 149 150
        }

        GridLayout {
151 152 153 154
            anchors.verticalCenter: parent.verticalCenter
            columns:                5
            rowSpacing:             0
            columnSpacing:          _labelToValueSpacing
155 156

            QGCLabel {
Donald Gagne's avatar
Donald Gagne committed
157 158 159
                text:               qsTr("Total mission")
                Layout.columnSpan:  5
                font.pointSize:     ScreenTools.smallFontPointSize
160 161 162
            }

            QGCLabel { text: qsTr("Distance:") }
163 164 165 166 167
            QGCLabel {
                text:                   _missionDistanceText
                Layout.minimumWidth:    _largeValueWidth
                horizontalAlignment:    Text.AlignRight
            }
168

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

171
            QGCLabel { text: qsTr("Max telem dist:") }
172 173 174 175 176
            QGCLabel {
                text:                   _missionMaxTelemetryText
                Layout.minimumWidth:    _largeValueWidth
                horizontalAlignment:    Text.AlignRight
            }
177 178

            QGCLabel { text: qsTr("Time:") }
179 180 181 182 183
            QGCLabel {
                text:                   _missionTimeText
                Layout.minimumWidth:    _largeValueWidth
                horizontalAlignment:    Text.AlignRight
            }
184
        }
Donald Gagne's avatar
Donald Gagne committed
185 186

        GridLayout {
187 188 189 190
            anchors.verticalCenter: parent.verticalCenter
            columns:                3
            rowSpacing:             0
            columnSpacing:          _labelToValueSpacing
Donald Gagne's avatar
Donald Gagne committed
191 192 193 194 195 196 197 198

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

            QGCLabel { text: qsTr("Batteries required:") }
199 200 201 202 203
            QGCLabel {
                text:                   _batteriesRequiredText
                horizontalAlignment:    Text.AlignRight
                Layout.minimumWidth:    _smallValueWidth
            }
Donald Gagne's avatar
Donald Gagne committed
204 205 206 207

            Item { width: 1; height: 1 }

            QGCLabel { text: qsTr("Swap waypoint:") }
208 209 210 211 212
            QGCLabel {
                text:                   _batteryChangePointText
                horizontalAlignment:    Text.AlignRight
                Layout.minimumWidth:    _smallValueWidth
            }
Donald Gagne's avatar
Donald Gagne committed
213
        }
214
    }
215 216 217 218 219 220

    QGCButton {
        id:                     uploadButton
        anchors.rightMargin:    _margins
        anchors.right:          parent.right
        anchors.verticalCenter: parent.verticalCenter
221
        text:                   missionController ? (missionController.dirty ? qsTr("Upload Required") : qsTr("Upload")) : ""
222 223 224
        enabled:                _activeVehicle
        visible:                _manualUpload
        onClicked:              missionController.upload()
225
    }
226 227
}