PlanToolBar.qml 10.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 42 43 44 45
    property bool   _manualUpload:              QGroundControl.settingsManager.appSettings.automaticMissionUpload.rawValue == 0

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

47 48 49
    property real   _largeValueWidth:           ScreenTools.defaultFontPixelWidth * 8
    property real   _smallValueWidth:           ScreenTools.defaultFontPixelWidth * 4
    property real   _labelToValueSpacing:       ScreenTools.defaultFontPixelWidth
50 51 52 53 54 55 56 57
    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
58 59 60 61 62 63 64
    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)
65 66 67
    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
68 69
    property string _batteryChangePointText:    _batteryChangePoint < 0 ?       "N/A" : _batteryChangePoint
    property string _batteriesRequiredText:     _batteriesRequired < 0 ?        "N/A" : _batteriesRequired
70

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

    QGCPalette { id: qgcPal }

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

83 84 85 86 87
    Row {
        anchors.bottomMargin:   1
        anchors.left:           parent.left
        anchors.top:            parent.top
        anchors.bottom:         parent.bottom
88 89 90 91 92 93 94 95 96
        QGCToolBarButton {
            id:                 settingsButton
            anchors.top:        parent.top
            anchors.bottom:     parent.bottom
            source:             "/qmlimages/PaperPlane.svg"
            logo:               true
            checked:            false
            onClicked: {
                checked = false
97
                if (missionController.uploadOnSwitch()) {
98 99
                    showFlyView()
                }
100 101
            }
        }
102 103 104 105 106 107 108 109
    }


    Row {
        anchors.top:        parent.top
        anchors.bottom:     parent.bottom
        spacing:            _margins * 2
        anchors.horizontalCenter: parent.horizontalCenter
110 111

        GridLayout {
112 113 114 115
            anchors.verticalCenter: parent.verticalCenter
            columns:                5
            rowSpacing:             0
            columnSpacing:          _labelToValueSpacing
116 117

            QGCLabel {
Donald Gagne's avatar
Donald Gagne committed
118 119 120
                text:               qsTr("Selected waypoint")
                Layout.columnSpan:  5
                font.pointSize:     ScreenTools.smallFontPointSize
121 122 123
            }

            QGCLabel { text: qsTr("Distance:") }
124 125 126 127 128
            QGCLabel {
                text:                   _distanceText
                Layout.minimumWidth:    _largeValueWidth
                horizontalAlignment:    Text.AlignRight
            }
129

Donald Gagne's avatar
Donald Gagne committed
130 131
            Item { width: 1; height: 1 }

132
            QGCLabel { text: qsTr("Gradient:") }
133 134 135 136 137
            QGCLabel {
                text:                   _gradientText
                Layout.minimumWidth:    _smallValueWidth
                horizontalAlignment:    Text.AlignRight
            }
138 139

            QGCLabel { text: qsTr("Alt diff:") }
140 141 142 143 144
            QGCLabel {
                text:                   _altDifferenceText
                Layout.minimumWidth:    _largeValueWidth
                horizontalAlignment:    Text.AlignRight
            }
145

Donald Gagne's avatar
Donald Gagne committed
146 147
            Item { width: 1; height: 1 }

148
            QGCLabel { text: qsTr("Azimuth:") }
149 150 151 152 153
            QGCLabel {
                text:                   _azimuthText
                Layout.minimumWidth:    _smallValueWidth
                horizontalAlignment:    Text.AlignRight
            }
154 155 156
        }

        GridLayout {
157 158 159 160
            anchors.verticalCenter: parent.verticalCenter
            columns:                5
            rowSpacing:             0
            columnSpacing:          _labelToValueSpacing
161 162

            QGCLabel {
Donald Gagne's avatar
Donald Gagne committed
163 164 165
                text:               qsTr("Total mission")
                Layout.columnSpan:  5
                font.pointSize:     ScreenTools.smallFontPointSize
166 167 168
            }

            QGCLabel { text: qsTr("Distance:") }
169 170 171 172 173
            QGCLabel {
                text:                   _missionDistanceText
                Layout.minimumWidth:    _largeValueWidth
                horizontalAlignment:    Text.AlignRight
            }
174

Donald Gagne's avatar
Donald Gagne committed
175 176
            Item { width: 1; height: 1 }

177
            QGCLabel { text: qsTr("Max telem dist:") }
178 179 180 181 182
            QGCLabel {
                text:                   _missionMaxTelemetryText
                Layout.minimumWidth:    _largeValueWidth
                horizontalAlignment:    Text.AlignRight
            }
183 184

            QGCLabel { text: qsTr("Time:") }
185 186 187 188 189
            QGCLabel {
                text:                   _missionTimeText
                Layout.minimumWidth:    _largeValueWidth
                horizontalAlignment:    Text.AlignRight
            }
190
        }
Donald Gagne's avatar
Donald Gagne committed
191 192

        GridLayout {
193 194 195 196
            anchors.verticalCenter: parent.verticalCenter
            columns:                3
            rowSpacing:             0
            columnSpacing:          _labelToValueSpacing
Donald Gagne's avatar
Donald Gagne committed
197 198 199 200 201 202 203 204

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

            QGCLabel { text: qsTr("Batteries required:") }
205 206 207 208 209
            QGCLabel {
                text:                   _batteriesRequiredText
                horizontalAlignment:    Text.AlignRight
                Layout.minimumWidth:    _smallValueWidth
            }
Donald Gagne's avatar
Donald Gagne committed
210 211 212 213

            Item { width: 1; height: 1 }

            QGCLabel { text: qsTr("Swap waypoint:") }
214 215 216 217 218
            QGCLabel {
                text:                   _batteryChangePointText
                horizontalAlignment:    Text.AlignRight
                Layout.minimumWidth:    _smallValueWidth
            }
Donald Gagne's avatar
Donald Gagne committed
219
        }
220
    }
221 222 223 224 225 226

    QGCButton {
        id:                     uploadButton
        anchors.rightMargin:    _margins
        anchors.right:          parent.right
        anchors.verticalCenter: parent.verticalCenter
227
        text:                   missionController ? (missionController.dirty ? qsTr("Upload Required") : qsTr("Upload")) : ""
228 229 230
        enabled:                _activeVehicle
        visible:                _manualUpload
        onClicked:              missionController.upload()
231
    }
232 233
}