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
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
Valentin Platzgummer's avatar
Valentin Platzgummer committed
15
import QGroundControl.FlightDisplay 1.0
16 17
import QGroundControl.Airspace      1.0
import QGroundControl.Airmap        1.0
18 19
import QGroundControl.FactSystem    1.0
import QGroundControl.FactControls  1.0
20

Valentin Platzgummer's avatar
Valentin Platzgummer committed
21 22 23

import Qt.labs.settings             1.0

24
Item {
25
    id:     _root
Valentin Platzgummer's avatar
Valentin Platzgummer committed
26 27
    height: mainFrame.height
    width:  mainFrame.width
28
    clip:   true
29 30 31 32

    property int maxHeight: 500
    property int maxWidth:  300

33
    property var wimaController // must be provided by the user
34
    property var planMasterController // must be provided by the user
35
    property var missionController // must be provided by the user
36 37 38

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

41

Valentin Platzgummer's avatar
Valentin Platzgummer committed
42
    // Disabels map scrolling when cursor on this menu.
43 44 45 46
    DeadMouseArea {
        anchors.fill: parent
    }

Valentin Platzgummer's avatar
Valentin Platzgummer committed
47 48 49 50 51 52 53 54 55
    // Use Settings to store menu appearance through different sessions.
    Settings {
        property alias snakeHeaderChecker:      snakeHeader.checked
        property alias missionHeaderChecker:    missionHeader.checked
        property alias navigateHeaderChecker:   navigateHeader.checked
        property alias vehicleHeaderChecker:    vehicleHeader.checked
        property alias statsHeaderChecker:      statsHeader.checked
    }

56 57 58
    // Progress bar visibility
    on_ControllerProgressPctChanged: {
        if (_controllerProgressPct === 1) {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
59 60
            uploadCompleteText.visible      = true
            progressBar.visible             = false
61
        } else if (_controllerProgressPct > 0) {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
62 63
            progressBar.visible             = true
            uploadCompleteText.visible      = false
64 65
        }
    }
66

67 68 69 70 71 72 73 74 75
    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
76 77 78

    QGCPalette { id: qgcPal }

79
    // box containing all items
Valentin Platzgummer's avatar
Valentin Platzgummer committed
80
    Rectangle { // maybe replace with column and remove anchors => dynamic height:
81
        id: mainFrame
82
        height:     enableWima.height + flickable.height + _margins*2
83 84 85 86 87 88
        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
89

90
        // checkbox to enable/ disable wima
91
        SliderSwitch {
92
            id: enableWima
93 94
            anchors.horizontalCenter:   flickable.horizontalCenter
            anchors.bottom:             flickable.top
95
            anchors.bottomMargin:       _margins
96
            confirmText:                enableWimaBoolean ? qsTr("disable WiMA") : qsTr("enable WiMA")
97

Valentin Platzgummer's avatar
Valentin Platzgummer committed
98

99 100
            property var enableWimaFact:        wimaController.enableWimaController
            property bool enableWimaBoolean:    enableWimaFact.value
101

102 103 104
            onAccept: {
                if (enableWimaBoolean) {
                    enableWimaFact.value = false
105 106
                    enableWimaMouseArea.enabled = true
                    timer.start()
107 108
                } else {
                    enableWimaFact.value = true
109 110
                    enableWimaMouseArea.enabled = false
                    timer.stop()
111 112
                }
            }
113 114
        }

115 116
        MouseArea {
            id: enableWimaMouseArea
Valentin Platzgummer's avatar
Valentin Platzgummer committed
117 118 119 120 121 122 123 124
            anchors.fill: enableWima

            hoverEnabled: true

            property var  enableWimaFact:        wimaController.enableWimaController
            property bool enableWimaBoolean:    enableWimaFact.value
            onEntered: {
                enableWima.visible = true
125 126
                enabled = false
                timer.start()
Valentin Platzgummer's avatar
Valentin Platzgummer committed
127 128 129 130 131 132
            }

        }

        Timer {
                id: timer
133
                interval: 3000
Valentin Platzgummer's avatar
Valentin Platzgummer committed
134 135
                running: false
                repeat: false
136 137 138 139 140 141 142 143 144 145 146 147 148
                onTriggered: triggerHandler()

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

                Component.onCompleted: {
                        start()
                }
        }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
149 150 151 152


        QGCFlickable {
            id: flickable
153 154
            clip:               true
            visible:            enableWima.enableWimaBoolean
155
            anchors.left:       parent.left
156
            anchors.bottom:     parent.bottom
157 158 159 160 161 162
            width:              enableWima.enableWimaBoolean ?
                                    Math.min(contentWidth, maxWidth)
                                  : enableWima.width
            height:             enableWima.enableWimaBoolean ?
                                    Math.min(contentHeight, maxHeight)
                                  : 0
163 164
            contentHeight:      columnWrapper.height
            contentWidth:       columnWrapper.width
Valentin Platzgummer's avatar
Valentin Platzgummer committed
165

166 167 168 169 170
            Row {
                id: columnWrapper
                Item{ // spacer
                    width: 6
                    height: 1
Valentin Platzgummer's avatar
Valentin Platzgummer committed
171 172
                }

173
                Column {
174 175
                    id:         mainColumn
                    spacing:    ScreenTools.defaultFontPixelHeight * 0.3
Valentin Platzgummer's avatar
Valentin Platzgummer committed
176

Valentin Platzgummer's avatar
Valentin Platzgummer committed
177 178 179 180 181
                    SectionHeader{
                        id: snakeHeader
                        text: qsTr("Snake Settings")
                    }

182 183 184
                    Column {
                        visible: snakeHeader.checked
                        spacing: ScreenTools.defaultFontPixelHeight * 0.5
Valentin Platzgummer's avatar
Valentin Platzgummer committed
185 186

                        FactCheckBox {
187 188 189
                            text:       wimaController.enableSnake.value ?
                                            qsTr("Disable Snake")
                                          : qsTr("Enable Snake")
Valentin Platzgummer's avatar
Valentin Platzgummer committed
190 191 192
                            fact:       wimaController.enableSnake
                        }

193 194 195
                        // Spacer
                        Item {
                            height: 1
Valentin Platzgummer's avatar
Valentin Platzgummer committed
196 197
                        }

198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
                        // 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
222 223 224 225
                        }
                    }


226 227


228
                    SectionHeader{
Valentin Platzgummer's avatar
Valentin Platzgummer committed
229
                        id: missionHeader
Valentin Platzgummer's avatar
Valentin Platzgummer committed
230
                        text: qsTr("Phase Settings")
Valentin Platzgummer's avatar
Valentin Platzgummer committed
231
                    }
232 233 234 235
                    GridLayout {
                        columns: 2
                        rowSpacing:         ScreenTools.defaultFontPixelHeight * 0.5
                        columnSpacing:      ScreenTools.defaultFontPixelHeight * 0.5
Valentin Platzgummer's avatar
Valentin Platzgummer committed
236
                        visible:            missionHeader.checked
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265

                        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
266
                            text:                   qsTr("Measurement Speed")
267 268 269 270 271 272 273
                            Layout.fillWidth: true
                        }
                        FactTextField {
                            fact:               wimaController.flightSpeed
                            Layout.fillWidth: true
                        }

274
                        QGCLabel {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
275
                            text:                   qsTr("AaR Speed")
276 277 278 279 280 281 282
                            Layout.fillWidth: true
                        }
                        FactTextField {
                            fact:               wimaController.arrivalReturnSpeed
                            Layout.fillWidth: true
                        }

283 284 285 286 287 288 289 290
                        QGCLabel {
                            text: qsTr("Altitude")
                            Layout.fillWidth: true
                        }
                        FactTextField {
                            fact:               wimaController.altitude
                            Layout.fillWidth: true
                        }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
291

Valentin Platzgummer's avatar
Valentin Platzgummer committed
292
                        FactCheckBox {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
293
                            text:       qsTr("Show Mission")
Valentin Platzgummer's avatar
Valentin Platzgummer committed
294 295 296 297 298
                            fact:       wimaController.showAllMissionItems
                            Layout.fillWidth: true
                        }

                        FactCheckBox {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
299
                            text:       qsTr("Show Phase")
Valentin Platzgummer's avatar
Valentin Platzgummer committed
300 301 302 303 304
                            fact:       wimaController.showCurrentMissionItems
                            Layout.fillWidth: true
                        }

                        FactCheckBox {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
305
                            text:       qsTr("Invert Phase")
Valentin Platzgummer's avatar
Valentin Platzgummer committed
306 307 308 309
                            fact:       wimaController.reverse
                            Layout.fillWidth: true
                        }

Valentin Platzgummer's avatar
Valentin Platzgummer committed
310 311
                    }

Valentin Platzgummer's avatar
Valentin Platzgummer committed
312 313 314 315 316
                    SectionHeader{
                        id: navigateHeader
                        text: qsTr("Navigate")
                    }

Valentin Platzgummer's avatar
Valentin Platzgummer committed
317 318
                    GridLayout {// Buttons
                        columns: 2
319 320
                        rowSpacing:         ScreenTools.defaultFontPixelHeight * 0.5
                        columnSpacing:      ScreenTools.defaultFontPixelHeight * 0.5
Valentin Platzgummer's avatar
Valentin Platzgummer committed
321
                        visible:            navigateHeader.checked
Valentin Platzgummer's avatar
Valentin Platzgummer committed
322 323
                        width:              missionHeader.width

324 325
                        QGCButton {
                            id: buttonPreviousMissionPhase
Valentin Platzgummer's avatar
Valentin Platzgummer committed
326
                            text:                   qsTr("Go Reverse")
327 328 329 330 331 332
                            onClicked:              wimaController.previousPhase()
                            Layout.fillWidth: true
                        }

                        QGCButton {
                            id: buttonNextMissionPhase
Valentin Platzgummer's avatar
Valentin Platzgummer committed
333
                            text:               qsTr("Go Forward")
334 335 336
                            onClicked:          wimaController.nextPhase()
                            Layout.fillWidth: true
                        }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
337 338 339 340 341 342 343 344

                        QGCButton {
                            id: buttonResetPhase
                            text:               qsTr("Reset Phase")
                            onClicked:          wimaController.resetPhase();
                            Layout.columnSpan:  2
                            Layout.fillWidth: true
                        }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
345
                    } // Grid Buttons
346 347 348 349

                    SectionHeader{
                        id: vehicleHeader
                        text: qsTr("Vehicle")
Valentin Platzgummer's avatar
Valentin Platzgummer committed
350
                    }
351 352 353 354 355 356 357 358 359 360
                    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
361 362 363 364 365
                            onClicked: {
                                if (!planMasterController.offline) {
                                    wimaController.uploadToVehicle()
                                }
                            }
366 367 368 369 370 371 372 373 374 375 376 377 378
                            Layout.fillWidth: true
                        }

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

                        QGCButton {
                            id: buttonSmartRTL
                            text:               qsTr("Smart RTL")
379
                            onClicked:          wimaController.initSmartRTL();
380 381
                            Layout.columnSpan:  2
                            Layout.fillWidth: true
382 383 384 385 386 387 388 389
                        }

                        QGCButton {
                            id: buttonRemoveTrajectoryHistory
                            text:               qsTr("Clear Trajectory")
                            onClicked:          wimaController.removeVehicleTrajectoryHistory()
                            Layout.columnSpan:  2
                            Layout.fillWidth: true
390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413
                        }


                        // 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
414 415
                    }

416 417 418
                    SectionHeader {
                        id: statsHeader
                        text: qsTr("Statistics")
Valentin Platzgummer's avatar
Valentin Platzgummer committed
419
                    }
420
                    GridLayout {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
421
                        columns: 3
422 423 424 425
                        rowSpacing: ScreenTools.defaultFontPixelHeight * 0.5
                        anchors.topMargin: ScreenTools.defaultFontPixelHeight * 0.5
                        visible: statsHeader.checked

Valentin Platzgummer's avatar
Valentin Platzgummer committed
426 427 428 429 430 431
                        Item {
                            id: widthItem

                            Layout.fillWidth:   true
                            Layout.columnSpan:  parent.columns
                            height:             0
432
                        }
433

Valentin Platzgummer's avatar
Valentin Platzgummer committed
434
                        SmallValue {
435 436
                            property var phaseDistance:         wimaController.phaseDistance

Valentin Platzgummer's avatar
Valentin Platzgummer committed
437 438 439 440
                            shortDescription: qsTr("Phase Length")
                            value:            phaseDistance >= 0 ? phaseDistance.toFixed(2): "-.-"
                            unit:             "m"
                            //width:            widthItem.width*0.49
441 442
                        }

Valentin Platzgummer's avatar
Valentin Platzgummer committed
443
                        SmallValue {
444 445
                            property var phaseDuration:         wimaController.phaseDuration

Valentin Platzgummer's avatar
Valentin Platzgummer committed
446 447 448 449
                            shortDescription: qsTr("Phase Duration")
                            value:            phaseDuration >= 0 ? getTime(phaseDuration) : "-.-"
                            //unit:             "m"
                            //width:            widthItem.width*0.49
450
                        }
451

Valentin Platzgummer's avatar
Valentin Platzgummer committed
452
                        SmallValue {
453 454
                            property var currentMissionIndex:   missionController.currentMissionIndex

Valentin Platzgummer's avatar
Valentin Platzgummer committed
455 456 457 458
                            shortDescription: qsTr("Current Waypoint")
                            value:               currentMissionIndex > 0 ? currentMissionIndex : "-.-"
                            //unit:             "m"
                            //width:            widthItem.width*0.49
459 460
                        }

Valentin Platzgummer's avatar
Valentin Platzgummer committed
461
                        SmallValue {
462 463
                            property var remainingDistance:     missionController.remainingDistance

Valentin Platzgummer's avatar
Valentin Platzgummer committed
464 465 466 467
                            shortDescription: qsTr("Remaining Distance")
                            value:            remainingDistance >= 0 ? remainingDistance.toFixed(2) : "-.-"
                            unit:             "m"
                            //width:            widthItem.width*0.49
468 469
                        }

Valentin Platzgummer's avatar
Valentin Platzgummer committed
470
                        SmallValue {
471 472
                            property var remainingTime:         missionController.remainingTime

Valentin Platzgummer's avatar
Valentin Platzgummer committed
473 474 475 476
                            shortDescription: qsTr("Remaining Time")
                            value:               remainingTime >= 0 ? getTime(remainingTime) : "-.-"
                            //unit:             "m"
                            //width:            widthItem.width*0.49
477
                        }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
478 479 480 481

                        Item { // spacer
                            height: 5
                            Layout.columnSpan:  parent.columns
482
                        }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
483
                    } // GridLayout
484
                } // settingsColumn
Valentin Platzgummer's avatar
Valentin Platzgummer committed
485

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


        } // QGCFlickable
494 495
    }
}