FlightDisplayWimaMenu.qml 19.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
32 33 34

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

37

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

42 43 44
    // Progress bar visibility
    on_ControllerProgressPctChanged: {
        if (_controllerProgressPct === 1) {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
45 46
            uploadCompleteText.visible      = true
            progressBar.visible             = false
47
        } else if (_controllerProgressPct > 0) {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
48 49
            progressBar.visible             = true
            uploadCompleteText.visible      = false
50 51
        }
    }
52

53 54 55 56 57 58 59 60 61
    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
62 63 64

    QGCPalette { id: qgcPal }

65
    // box containing all items
Valentin Platzgummer's avatar
Valentin Platzgummer committed
66
    Rectangle { // maybe replace with column and remove anchors => dynamic height:
67
        id: mainFrame
68
        height:     enableWima.height + flickable.height + _margins*2
69 70 71 72 73 74
        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
75

76
        // checkbox to enable/ disable wima
77
        SliderSwitch {
78
            id: enableWima
79 80
            anchors.horizontalCenter:   flickable.horizontalCenter
            anchors.bottom:             flickable.top
81
            anchors.bottomMargin:       _margins
82
            confirmText:                enableWimaBoolean ? qsTr("disable WiMA") : qsTr("enable WiMA")
83

Valentin Platzgummer's avatar
Valentin Platzgummer committed
84

85 86
            property var enableWimaFact:        wimaController.enableWimaController
            property bool enableWimaBoolean:    enableWimaFact.value
87

88 89 90
            onAccept: {
                if (enableWimaBoolean) {
                    enableWimaFact.value = false
91 92
                    enableWimaMouseArea.enabled = true
                    timer.start()
93 94
                } else {
                    enableWimaFact.value = true
95 96
                    enableWimaMouseArea.enabled = false
                    timer.stop()
97 98
                }
            }
99 100
        }

101 102
        MouseArea {
            id: enableWimaMouseArea
Valentin Platzgummer's avatar
Valentin Platzgummer committed
103 104 105 106 107 108 109 110
            anchors.fill: enableWima

            hoverEnabled: true

            property var  enableWimaFact:        wimaController.enableWimaController
            property bool enableWimaBoolean:    enableWimaFact.value
            onEntered: {
                enableWima.visible = true
111 112
                enabled = false
                timer.start()
Valentin Platzgummer's avatar
Valentin Platzgummer committed
113 114 115 116 117 118
            }

        }

        Timer {
                id: timer
119
                interval: 3000
Valentin Platzgummer's avatar
Valentin Platzgummer committed
120 121
                running: false
                repeat: false
122 123 124 125 126 127 128 129 130 131 132 133 134
                onTriggered: triggerHandler()

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

                Component.onCompleted: {
                        start()
                }
        }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
135 136 137 138


        QGCFlickable {
            id: flickable
139 140
            clip:               true
            visible:            enableWima.enableWimaBoolean
141
            anchors.left:       parent.left
142
            anchors.bottom:     parent.bottom
143 144 145 146 147 148
            width:              enableWima.enableWimaBoolean ?
                                    Math.min(contentWidth, maxWidth)
                                  : enableWima.width
            height:             enableWima.enableWimaBoolean ?
                                    Math.min(contentHeight, maxHeight)
                                  : 0
149 150
            contentHeight:      columnWrapper.height
            contentWidth:       columnWrapper.width
Valentin Platzgummer's avatar
Valentin Platzgummer committed
151

152 153 154 155 156
            Row {
                id: columnWrapper
                Item{ // spacer
                    width: 6
                    height: 1
Valentin Platzgummer's avatar
Valentin Platzgummer committed
157 158
                }

159
                Column {
160 161
                    id:         mainColumn
                    spacing:    ScreenTools.defaultFontPixelHeight * 0.3
Valentin Platzgummer's avatar
Valentin Platzgummer committed
162

Valentin Platzgummer's avatar
Valentin Platzgummer committed
163 164 165 166 167
                    SectionHeader{
                        id: snakeHeader
                        text: qsTr("Snake Settings")
                    }

168 169 170
                    Column {
                        visible: snakeHeader.checked
                        spacing: ScreenTools.defaultFontPixelHeight * 0.5
Valentin Platzgummer's avatar
Valentin Platzgummer committed
171 172

                        FactCheckBox {
173 174 175
                            text:       wimaController.enableSnake.value ?
                                            qsTr("Disable Snake")
                                          : qsTr("Enable Snake")
Valentin Platzgummer's avatar
Valentin Platzgummer committed
176 177 178
                            fact:       wimaController.enableSnake
                        }

179 180 181
                        // Spacer
                        Item {
                            height: 1
Valentin Platzgummer's avatar
Valentin Platzgummer committed
182 183
                        }

184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
                        // Snake status and settings column.
                        GridLayout {
                            columns: 2
                            rowSpacing:         ScreenTools.defaultFontPixelHeight * 0.5
                            columnSpacing:      ScreenTools.defaultFontPixelHeight * 0.5
                            visible:            wimaController.enableSnake.value

                            // Snake connection status.
                            QGCLabel {
                                property int _connectionStatus: wimaController.snakeConnectionStatus
                                text: _connectionStatus === 1 ?
                                          qsTr("Status: Connected")
                                        : qsTr("Status: Not Connected")
                                Layout.fillWidth: true
                            }

                            // Snake calculation status.
                            QGCLabel {
                                property bool _calcInProgress: wimaController.snakeCalcInProgress
                                text: _calcInProgress === true ?
                                          qsTr("Calculation: In Progress")
                                        : qsTr("Calculation: Idle")
                                Layout.fillWidth: true
                            }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
208 209 210 211
                        }
                    }


212 213


214
                    SectionHeader{
Valentin Platzgummer's avatar
Valentin Platzgummer committed
215
                        id: missionHeader
Valentin Platzgummer's avatar
Valentin Platzgummer committed
216
                        text: qsTr("Phase Settings")
Valentin Platzgummer's avatar
Valentin Platzgummer committed
217
                    }
218 219 220 221
                    GridLayout {
                        columns: 2
                        rowSpacing:         ScreenTools.defaultFontPixelHeight * 0.5
                        columnSpacing:      ScreenTools.defaultFontPixelHeight * 0.5
Valentin Platzgummer's avatar
Valentin Platzgummer committed
222
                        visible:            missionHeader.checked
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251

                        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
252
                            text:                   qsTr("Measurement Speed")
253 254 255 256 257 258 259
                            Layout.fillWidth: true
                        }
                        FactTextField {
                            fact:               wimaController.flightSpeed
                            Layout.fillWidth: true
                        }

260
                        QGCLabel {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
261
                            text:                   qsTr("AaR Speed")
262 263 264 265 266 267 268
                            Layout.fillWidth: true
                        }
                        FactTextField {
                            fact:               wimaController.arrivalReturnSpeed
                            Layout.fillWidth: true
                        }

269 270 271 272 273 274 275 276
                        QGCLabel {
                            text: qsTr("Altitude")
                            Layout.fillWidth: true
                        }
                        FactTextField {
                            fact:               wimaController.altitude
                            Layout.fillWidth: true
                        }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
277

Valentin Platzgummer's avatar
Valentin Platzgummer committed
278
                        FactCheckBox {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
279
                            text:       qsTr("Show Mission")
Valentin Platzgummer's avatar
Valentin Platzgummer committed
280 281 282 283 284
                            fact:       wimaController.showAllMissionItems
                            Layout.fillWidth: true
                        }

                        FactCheckBox {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
285
                            text:       qsTr("Show Phase")
Valentin Platzgummer's avatar
Valentin Platzgummer committed
286 287 288 289 290
                            fact:       wimaController.showCurrentMissionItems
                            Layout.fillWidth: true
                        }

                        FactCheckBox {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
291
                            text:       qsTr("Invert Phase")
Valentin Platzgummer's avatar
Valentin Platzgummer committed
292 293 294 295
                            fact:       wimaController.reverse
                            Layout.fillWidth: true
                        }

Valentin Platzgummer's avatar
Valentin Platzgummer committed
296 297
                    }

Valentin Platzgummer's avatar
Valentin Platzgummer committed
298 299 300 301 302
                    SectionHeader{
                        id: navigateHeader
                        text: qsTr("Navigate")
                    }

Valentin Platzgummer's avatar
Valentin Platzgummer committed
303 304
                    GridLayout {// Buttons
                        columns: 2
305 306
                        rowSpacing:         ScreenTools.defaultFontPixelHeight * 0.5
                        columnSpacing:      ScreenTools.defaultFontPixelHeight * 0.5
Valentin Platzgummer's avatar
Valentin Platzgummer committed
307
                        visible:            navigateHeader.checked
Valentin Platzgummer's avatar
Valentin Platzgummer committed
308 309
                        width:              missionHeader.width

310 311
                        QGCButton {
                            id: buttonPreviousMissionPhase
Valentin Platzgummer's avatar
Valentin Platzgummer committed
312
                            text:                   qsTr("Go Reverse")
313 314 315 316 317 318
                            onClicked:              wimaController.previousPhase()
                            Layout.fillWidth: true
                        }

                        QGCButton {
                            id: buttonNextMissionPhase
Valentin Platzgummer's avatar
Valentin Platzgummer committed
319
                            text:               qsTr("Go Forward")
320 321 322
                            onClicked:          wimaController.nextPhase()
                            Layout.fillWidth: true
                        }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
323 324 325 326 327 328 329 330

                        QGCButton {
                            id: buttonResetPhase
                            text:               qsTr("Reset Phase")
                            onClicked:          wimaController.resetPhase();
                            Layout.columnSpan:  2
                            Layout.fillWidth: true
                        }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
331
                    } // Grid Buttons
332 333 334 335

                    SectionHeader{
                        id: vehicleHeader
                        text: qsTr("Vehicle")
Valentin Platzgummer's avatar
Valentin Platzgummer committed
336
                    }
337 338 339 340 341 342 343 344 345 346
                    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
347 348 349 350 351
                            onClicked: {
                                if (!planMasterController.offline) {
                                    wimaController.uploadToVehicle()
                                }
                            }
352 353 354 355 356 357 358 359 360 361 362 363 364
                            Layout.fillWidth: true
                        }

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

                        QGCButton {
                            id: buttonSmartRTL
                            text:               qsTr("Smart RTL")
365
                            onClicked:          wimaController.initSmartRTL();
366 367
                            Layout.columnSpan:  2
                            Layout.fillWidth: true
368 369 370 371 372 373 374 375
                        }

                        QGCButton {
                            id: buttonRemoveTrajectoryHistory
                            text:               qsTr("Clear Trajectory")
                            onClicked:          wimaController.removeVehicleTrajectoryHistory()
                            Layout.columnSpan:  2
                            Layout.fillWidth: true
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399
                        }


                        // 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
400 401
                    }

402 403 404
                    SectionHeader {
                        id: statsHeader
                        text: qsTr("Statistics")
Valentin Platzgummer's avatar
Valentin Platzgummer committed
405
                    }
406 407 408 409 410 411 412 413 414 415 416 417
                    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 {
418 419 420 421

                            property var phaseDistance:         wimaController.phaseDistance

                            text:               phaseDistance >= 0 ? phaseDistance.toFixed(2) + " m": "-.-"
422 423 424 425 426 427 428 429 430 431
                            wrapMode:           Text.WordWrap
                            Layout.fillWidth:   true
                        }

                        QGCLabel {
                            text:               qsTr("Phase Duration: ")
                            wrapMode:           Text.WordWrap
                            Layout.fillWidth: true
                        }
                        QGCLabel {
432 433 434
                            property var phaseDuration:         wimaController.phaseDuration

                            text:               phaseDuration >= 0 ? getTime(phaseDuration) : "-.-"
435 436 437
                            wrapMode:           Text.WordWrap
                            Layout.fillWidth: true
                        }
438

439
                        QGCLabel {
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477
                            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
478 479 480
                            text:               ""
                            Layout.columnSpan:  2
                        }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
481
                    }
482
                } // settingsColumn
Valentin Platzgummer's avatar
Valentin Platzgummer committed
483

484 485
                Item { // spacer
                    width: 6
486
                    height: 5
Valentin Platzgummer's avatar
Valentin Platzgummer committed
487
                }
488
            }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
489 490 491


        } // QGCFlickable
492 493
    }
}