FlightDisplayWimaMenu.qml 17.3 KB
Newer Older
1 2 3 4 5
import QtQuick                  2.3
import QtQuick.Controls.Styles  1.4
import QtQuick.Dialogs          1.2
import QtLocation               5.3
import QtPositioning            5.3
Valentin Platzgummer's avatar
Valentin Platzgummer committed
6
import QtQuick.Controls         2.4
7 8 9 10 11 12 13 14 15 16
import QtQuick.Layouts          1.2

import QGroundControl               1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Controls      1.0
import QGroundControl.Palette       1.0
import QGroundControl.Vehicle       1.0
import QGroundControl.FlightMap     1.0
import QGroundControl.Airspace      1.0
import QGroundControl.Airmap        1.0
17 18
import QGroundControl.FactSystem    1.0
import QGroundControl.FactControls  1.0
19 20

Item {
21
    id:     _root
Valentin Platzgummer's avatar
Valentin Platzgummer committed
22 23
    height: mainFrame.height
    width:  mainFrame.width
24
    clip:   true
25 26 27 28

    property int maxHeight: 500
    property int maxWidth:  300

29
    property var wimaController // must be provided by the user
30
    property var planMasterController // must be provided by the user
31
    property var missionController // must be provided by the user
Valentin Platzgummer's avatar
Valentin Platzgummer committed
32
    readonly property alias missionReadyForStart: _private.missionReadyForStart
33 34 35

    property bool   _controllerValid:           planMasterController !== undefined
    property real   _controllerProgressPct:     _controllerValid ? planMasterController.missionController.progressPct : 0
36
    property real   _margins:                   ScreenTools.defaultFontPixelWidth / 2
37

38

39 40 41 42
    DeadMouseArea {
        anchors.fill: parent
    }

Valentin Platzgummer's avatar
Valentin Platzgummer committed
43 44 45 46 47
    Item {
        id: _private
        property bool missionReadyForStart: true
    }

48 49 50
    // Progress bar visibility
    on_ControllerProgressPctChanged: {
        if (_controllerProgressPct === 1) {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
51 52 53
            uploadCompleteText.visible      = true
            progressBar.visible             = false
            _private.missionReadyForStart   = true
54
        } else if (_controllerProgressPct > 0) {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
55 56 57
            progressBar.visible             = true
            uploadCompleteText.visible      = false
            _private.missionReadyForStart   = false
58 59
        }
    }
60

61 62 63 64 65 66 67 68 69
    function getTime(time) {
        // time is a double
        if(isNaN(time)) {
            return "00:00:00"
        }
        var t = new Date(0, 0, 0, 0, 0, Number(time))
        return Qt.formatTime(t, 'hh:mm:ss')
    }

Valentin Platzgummer's avatar
Valentin Platzgummer committed
70 71 72

    QGCPalette { id: qgcPal }

73
    // box containing all items
Valentin Platzgummer's avatar
Valentin Platzgummer committed
74
    Rectangle { // maybe replace with column and remove anchors => dynamic height:
75
        id: mainFrame
76
        height:     enableWima.height + flickable.height + _margins*2
77 78 79 80 81 82
        width:      Math.max(enableWima.width, flickable.width)
        color:      enableWima.enableWimaBoolean ? qgcPal.window : "transparent"
        radius:     Math.min(height, width)/50
        clip:       true

        property real _margins:       _root._margins
Valentin Platzgummer's avatar
Valentin Platzgummer committed
83

84
        // checkbox to enable/ disable wima
85
        SliderSwitch {
86
            id: enableWima
87 88
            anchors.horizontalCenter:   flickable.horizontalCenter
            anchors.bottom:             flickable.top
89
            anchors.bottomMargin:       _margins
90
            confirmText:                enableWimaBoolean ? qsTr("disable WiMA") : qsTr("enable WiMA")
91

Valentin Platzgummer's avatar
Valentin Platzgummer committed
92

93 94
            property var enableWimaFact:        wimaController.enableWimaController
            property bool enableWimaBoolean:    enableWimaFact.value
95

96 97 98
            onAccept: {
                if (enableWimaBoolean) {
                    enableWimaFact.value = false
99 100
                    enableWimaMouseArea.enabled = true
                    timer.start()
101 102
                } else {
                    enableWimaFact.value = true
103 104
                    enableWimaMouseArea.enabled = false
                    timer.stop()
105 106
                }
            }
107 108
        }

109 110
        MouseArea {
            id: enableWimaMouseArea
Valentin Platzgummer's avatar
Valentin Platzgummer committed
111 112 113 114 115 116 117 118
            anchors.fill: enableWima

            hoverEnabled: true

            property var  enableWimaFact:        wimaController.enableWimaController
            property bool enableWimaBoolean:    enableWimaFact.value
            onEntered: {
                enableWima.visible = true
119 120
                enabled = false
                timer.start()
Valentin Platzgummer's avatar
Valentin Platzgummer committed
121 122 123 124 125 126
            }

        }

        Timer {
                id: timer
127
                interval: 3000
Valentin Platzgummer's avatar
Valentin Platzgummer committed
128 129
                running: false
                repeat: false
130 131 132 133 134 135 136 137 138 139 140 141 142
                onTriggered: triggerHandler()

                function triggerHandler() {
                    if (enableWima.enableWimaBoolean === false) {
                        enableWima.visible = false
                        enableWimaMouseArea.enabled = true
                    }
                }

                Component.onCompleted: {
                        start()
                }
        }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
143 144 145 146


        QGCFlickable {
            id: flickable
147 148
            clip:               true
            visible:            enableWima.enableWimaBoolean
149
            anchors.left:       parent.left
150 151 152 153 154
            anchors.bottom:     parent.bottom
            width:              enableWima.enableWimaBoolean ? Math.min(contentWidth, maxWidth) : enableWima.width
            height:             enableWima.enableWimaBoolean ? Math.min(contentHeight, maxHeight) : 0
            contentHeight:      columnWrapper.height
            contentWidth:       columnWrapper.width
Valentin Platzgummer's avatar
Valentin Platzgummer committed
155

156 157 158 159 160
            Row {
                id: columnWrapper
                Item{ // spacer
                    width: 6
                    height: 1
Valentin Platzgummer's avatar
Valentin Platzgummer committed
161 162
                }

163 164 165
                Column {
                    id:                         mainColumn
                    spacing:                    ScreenTools.defaultFontPixelHeight * 0.3
Valentin Platzgummer's avatar
Valentin Platzgummer committed
166

167
                    SectionHeader{
Valentin Platzgummer's avatar
Valentin Platzgummer committed
168
                        id: missionHeader
Valentin Platzgummer's avatar
Valentin Platzgummer committed
169
                        text: qsTr("Phase Settings")
Valentin Platzgummer's avatar
Valentin Platzgummer committed
170
                    }
171 172 173 174
                    GridLayout {
                        columns: 2
                        rowSpacing:         ScreenTools.defaultFontPixelHeight * 0.5
                        columnSpacing:      ScreenTools.defaultFontPixelHeight * 0.5
Valentin Platzgummer's avatar
Valentin Platzgummer committed
175
                        visible:            missionHeader.checked
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204

                        QGCLabel {
                            text: qsTr("Next Waypoint")
                            Layout.fillWidth: true
                        }
                        FactTextField {
                            fact:               wimaController.startWaypointIndex
                            Layout.fillWidth:   true
                        }

                        QGCLabel {
                            text: qsTr("Max Waypoints")
                            Layout.fillWidth: true
                        }
                        FactTextField {
                            fact:               wimaController.maxWaypointsPerPhase
                            Layout.fillWidth: true
                        }

                        QGCLabel {
                            text: qsTr("Overlap")
                            Layout.fillWidth: true
                        }
                        FactTextField {
                            fact:               wimaController.overlapWaypoints
                            Layout.fillWidth: true
                        }

                        QGCLabel {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
205
                            text:                   qsTr("Measurement Speed")
206 207 208 209 210 211 212
                            Layout.fillWidth: true
                        }
                        FactTextField {
                            fact:               wimaController.flightSpeed
                            Layout.fillWidth: true
                        }

213
                        QGCLabel {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
214
                            text:                   qsTr("AaR Speed")
215 216 217 218 219 220 221
                            Layout.fillWidth: true
                        }
                        FactTextField {
                            fact:               wimaController.arrivalReturnSpeed
                            Layout.fillWidth: true
                        }

222 223 224 225 226 227 228 229
                        QGCLabel {
                            text: qsTr("Altitude")
                            Layout.fillWidth: true
                        }
                        FactTextField {
                            fact:               wimaController.altitude
                            Layout.fillWidth: true
                        }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
230

Valentin Platzgummer's avatar
Valentin Platzgummer committed
231
                        FactCheckBox {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
232
                            text:       qsTr("Show Mission")
Valentin Platzgummer's avatar
Valentin Platzgummer committed
233 234 235 236 237
                            fact:       wimaController.showAllMissionItems
                            Layout.fillWidth: true
                        }

                        FactCheckBox {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
238
                            text:       qsTr("Show Phase")
Valentin Platzgummer's avatar
Valentin Platzgummer committed
239 240 241 242 243
                            fact:       wimaController.showCurrentMissionItems
                            Layout.fillWidth: true
                        }

                        FactCheckBox {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
244
                            text:       qsTr("Invert Phase")
Valentin Platzgummer's avatar
Valentin Platzgummer committed
245 246 247 248
                            fact:       wimaController.reverse
                            Layout.fillWidth: true
                        }

Valentin Platzgummer's avatar
Valentin Platzgummer committed
249 250
                    }

Valentin Platzgummer's avatar
Valentin Platzgummer committed
251 252 253 254 255
                    SectionHeader{
                        id: navigateHeader
                        text: qsTr("Navigate")
                    }

Valentin Platzgummer's avatar
Valentin Platzgummer committed
256 257
                    GridLayout {// Buttons
                        columns: 2
258 259
                        rowSpacing:         ScreenTools.defaultFontPixelHeight * 0.5
                        columnSpacing:      ScreenTools.defaultFontPixelHeight * 0.5
Valentin Platzgummer's avatar
Valentin Platzgummer committed
260
                        visible:            navigateHeader.checked
Valentin Platzgummer's avatar
Valentin Platzgummer committed
261 262
                        width:              missionHeader.width

263 264
                        QGCButton {
                            id: buttonPreviousMissionPhase
Valentin Platzgummer's avatar
Valentin Platzgummer committed
265
                            text:                   qsTr("Go Reverse")
266 267 268 269 270 271
                            onClicked:              wimaController.previousPhase()
                            Layout.fillWidth: true
                        }

                        QGCButton {
                            id: buttonNextMissionPhase
Valentin Platzgummer's avatar
Valentin Platzgummer committed
272
                            text:               qsTr("Go Forward")
273 274 275
                            onClicked:          wimaController.nextPhase()
                            Layout.fillWidth: true
                        }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
276 277 278 279 280 281 282 283

                        QGCButton {
                            id: buttonResetPhase
                            text:               qsTr("Reset Phase")
                            onClicked:          wimaController.resetPhase();
                            Layout.columnSpan:  2
                            Layout.fillWidth: true
                        }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
284
                    } // Grid Buttons
285 286 287 288

                    SectionHeader{
                        id: vehicleHeader
                        text: qsTr("Vehicle")
Valentin Platzgummer's avatar
Valentin Platzgummer committed
289
                    }
290 291 292 293 294 295 296 297 298 299
                    GridLayout {
                        columns: 2
                        rowSpacing:         ScreenTools.defaultFontPixelHeight * 0.5
                        columnSpacing:      ScreenTools.defaultFontPixelHeight * 0.5
                        visible:            vehicleHeader.checked
                        width:              parent.width

                        QGCButton {
                            id: buttonUpload
                            text:               qsTr("Upload")
Valentin Platzgummer's avatar
Valentin Platzgummer committed
300 301 302 303 304
                            onClicked: {
                                if (!planMasterController.offline) {
                                    wimaController.uploadToVehicle()
                                }
                            }
305 306 307 308 309 310 311 312 313 314 315 316 317
                            Layout.fillWidth: true
                        }

                        QGCButton {
                            id: buttonRemoveFromVehicle
                            text:               qsTr("Remove")
                            onClicked:          wimaController.removeFromVehicle()
                            Layout.fillWidth: true
                        }

                        QGCButton {
                            id: buttonSmartRTL
                            text:               qsTr("Smart RTL")
318
                            onClicked:          wimaController.initSmartRTL();
319 320
                            Layout.columnSpan:  2
                            Layout.fillWidth: true
321 322 323 324 325 326 327 328
                        }

                        QGCButton {
                            id: buttonRemoveTrajectoryHistory
                            text:               qsTr("Clear Trajectory")
                            onClicked:          wimaController.removeVehicleTrajectoryHistory()
                            Layout.columnSpan:  2
                            Layout.fillWidth: true
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352
                        }


                        // progess bar
                        Rectangle {
                            id:                 progressBar
                            height:             4
                            width:              _controllerProgressPct * parent.width
                            color:              qgcPal.colorGreen
                            visible:            false
                            Layout.columnSpan:  2
                            Layout.fillWidth:   true
                        }

                        QGCLabel {
                            id:                     uploadCompleteText
                            font.pointSize:         ScreenTools.largeFontPointSize
                            Layout.columnSpan:      2
                            horizontalAlignment:    Text.AlignHCenter
                            verticalAlignment:      Text.AlignVCenter
                            text:                   "Done"
                            visible:                false
                            Layout.fillWidth:       true
                        }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
353 354
                    }

355 356 357
                    SectionHeader {
                        id: statsHeader
                        text: qsTr("Statistics")
Valentin Platzgummer's avatar
Valentin Platzgummer committed
358
                    }
359 360 361 362 363 364 365 366 367 368 369 370
                    GridLayout {
                        columns: 2
                        rowSpacing: ScreenTools.defaultFontPixelHeight * 0.5
                        anchors.topMargin: ScreenTools.defaultFontPixelHeight * 0.5
                        visible: statsHeader.checked

                        QGCLabel {
                            text:               qsTr("Phase Length: ")
                            wrapMode:           Text.WordWrap
                            Layout.fillWidth: true
                        }
                        QGCLabel {
371 372 373 374

                            property var phaseDistance:         wimaController.phaseDistance

                            text:               phaseDistance >= 0 ? phaseDistance.toFixed(2) + " m": "-.-"
375 376 377 378 379 380 381 382 383 384
                            wrapMode:           Text.WordWrap
                            Layout.fillWidth:   true
                        }

                        QGCLabel {
                            text:               qsTr("Phase Duration: ")
                            wrapMode:           Text.WordWrap
                            Layout.fillWidth: true
                        }
                        QGCLabel {
385 386 387
                            property var phaseDuration:         wimaController.phaseDuration

                            text:               phaseDuration >= 0 ? getTime(phaseDuration) : "-.-"
388 389 390
                            wrapMode:           Text.WordWrap
                            Layout.fillWidth: true
                        }
391

392
                        QGCLabel {
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
                            text:               qsTr("Current Waypoint: ")
                            wrapMode:           Text.WordWrap
                            Layout.fillWidth:   true
                        }
                        QGCLabel {
                            property var currentMissionIndex:   missionController.currentMissionIndex

                            text:               currentMissionIndex > 0 ? currentMissionIndex : "-.-"
                            wrapMode:           Text.WordWrap
                            Layout.fillWidth:   true
                        }

                        QGCLabel {
                            text:               qsTr("Remaining Distance: ")
                            wrapMode:           Text.WordWrap
                            Layout.fillWidth:   true
                        }
                        QGCLabel {
                            property var remainingDistance:     missionController.remainingDistance

                            text:               remainingDistance >= 0 ? remainingDistance.toFixed(2) + " m" : "-.-"
                            wrapMode:           Text.WordWrap
                            Layout.fillWidth:   true
                        }

                        QGCLabel {
                            text:               qsTr("Remaining Time: ")
                            wrapMode:           Text.WordWrap
                            Layout.fillWidth:   true
                        }
                        QGCLabel {
                            property var remainingTime:         missionController.remainingTime

                            text:               remainingTime >= 0 ? getTime(remainingTime) : "-.-"
                            wrapMode:           Text.WordWrap
                            Layout.fillWidth:   true
                        }
                        QGCLabel { // space
431 432 433
                            text:               ""
                            Layout.columnSpan:  2
                        }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
434
                    }
435
                } // settingsColumn
Valentin Platzgummer's avatar
Valentin Platzgummer committed
436

437 438
                Item { // spacer
                    width: 6
439
                    height: 5
Valentin Platzgummer's avatar
Valentin Platzgummer committed
440
                }
441
            }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
442 443 444


        } // QGCFlickable
445 446
    }
}