FlightDisplayWimaMenu.qml 10 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
import QtQuick                  2.3
import QtQuick.Controls         1.2
import QtQuick.Controls.Styles  1.4
import QtQuick.Dialogs          1.2
import QtLocation               5.3
import QtPositioning            5.3
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
22
    height: 700
23 24
    width:  300

25
    property var wimaController // must be provided by the user
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
    property var planMasterController // must be provided by the user

    property bool   _controllerValid:           planMasterController !== undefined
    property real   _controllerProgressPct:     _controllerValid ? planMasterController.missionController.progressPct : 0

    // Progress bar visibility
    on_ControllerProgressPctChanged: {
        if (_controllerProgressPct === 1) {
            uploadCompleteText.visible  = true
            progressBar.visible         = false
        } else if (_controllerProgressPct > 0) {
            progressBar.visible         = true
            uploadCompleteText.visible  = false
        }
    }
41

42 43 44 45 46 47 48 49 50
    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')
    }

51
    // box containing all items
52
    Rectangle {
53 54
        anchors.left:   parent.left
        anchors.bottom: parent.bottom
55 56 57 58 59 60 61 62
        height:         enableWima.enableWimaBoolean ? parent.height : enableWima.height
        width:          enableWima.enableWimaBoolean ? parent.width : enableWima.width
        color:          enableWima.enableWimaBoolean ? qgcPal.window : "transparent"
        radius:         ScreenTools.defaultFontPixelHeight / 4
        anchors.topMargin:      ScreenTools.defaultFontPixelHeight * 0.5
        anchors.bottomMargin:   ScreenTools.defaultFontPixelHeight * 0.5
        anchors.rightMargin:    ScreenTools.defaultFontPixelHeight * 0.5
        anchors.leftMargin:     ScreenTools.defaultFontPixelHeight * 0.5
63

64
        // checkbox to enable/ disable wima
65
        SliderSwitch {
66
            id: enableWima
67
            anchors.horizontalCenter: parent.horizontalCenter
68
            anchors.topMargin:      ScreenTools.defaultFontPixelHeight * 0.25
69
            anchors.top: parent.top
70
            confirmText: enableWimaBoolean ? qsTr("disable WiMA") : qsTr("enable WiMA")
71

72 73
            property var enableWimaFact:        wimaController.enableWimaController
            property bool enableWimaBoolean:    enableWimaFact.value
74

75 76 77 78 79 80 81
            onAccept: {
                if (enableWimaBoolean) {
                    enableWimaFact.value = false
                } else {
                    enableWimaFact.value = true
                }
            }
82 83
        }

84 85 86 87 88 89 90 91 92 93 94 95 96
        Column {
            id: mainColumn
            anchors.top:        enableWima.bottom
            anchors.left:       parent.left
            anchors.right:      parent.right
            anchors.bottom:     parent.bottom
            anchors.margins:    ScreenTools.defaultFontPixelHeight * 0.4
            spacing:            ScreenTools.defaultFontPixelHeight * 0.25


            SectionHeader {
                id: settingsHeader
                text: qsTr("Settings")
97
            }
98 99
            GridLayout {
                columns: 2
100 101 102 103 104 105
                rowSpacing:         ScreenTools.defaultFontPixelHeight * 0.5
                columnSpacing:      ScreenTools.defaultFontPixelHeight * 0.5
                anchors.topMargin:  ScreenTools.defaultFontPixelHeight * 0.5
                anchors.left:       parent.left
                anchors.right:      parent.right
                visible:            settingsHeader.checked
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124

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

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

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

126 127 128 129 130 131 132 133 134 135 136 137 138
                FactCheckBox {
                    text:       qsTr("Show All")
                    fact:       wimaController.showAllMissionItems
                }

                FactCheckBox {
                    text:       qsTr("Show Current")
                    fact:       wimaController.showCurrentMissionItems
                }

            }

            SectionHeader{
139 140
                id: missionHeader
                text: qsTr("Mission")
141
            }
142
            GridLayout {
143 144 145 146 147 148 149
                columns:            2
                rowSpacing:         ScreenTools.defaultFontPixelHeight * 0.5
                columnSpacing:      ScreenTools.defaultFontPixelHeight * 0.5
                anchors.topMargin:  ScreenTools.defaultFontPixelHeight * 0.5
                anchors.left:       parent.left
                anchors.right:      parent.right
                visible:            missionHeader.checked
150

151 152 153 154 155 156 157 158 159 160 161 162
                QGCLabel { text: qsTr("Speed") }
                FactTextField {
                    fact:               wimaController.flightSpeed
                    Layout.fillWidth:   true
                }

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

163 164
                // Buttons
                QGCButton {
165
                    id: buttonPreviousMissionPhase
166 167
                    text:               qsTr("Reverse")
                    onClicked:          wimaController.previousPhase();
168 169 170 171
                    Layout.fillWidth:   true
                }

                QGCButton {
172
                    id: buttonNextMissionPhase
173 174
                    text:               qsTr("Forward")
                    onClicked:          wimaController.nextPhase();
175 176 177 178 179
                    Layout.fillWidth:   true
                }

                QGCButton {
                    id: buttonResetPhase
180 181
                    text:               qsTr("Reset Phase")
                    onClicked:          wimaController.resetPhase();
182
                    Layout.fillWidth:   true
183
                    Layout.rowSpan:     2
184 185
                }

186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201

            }

            SectionHeader{
                id: vehicleHeader
                text: qsTr("Vehicle")
            }
            GridLayout {
                columns: 2
                rowSpacing:         ScreenTools.defaultFontPixelHeight * 0.5
                columnSpacing:      ScreenTools.defaultFontPixelHeight * 0.5
                anchors.topMargin:  ScreenTools.defaultFontPixelHeight * 0.5
                anchors.left:       parent.left
                anchors.right:      parent.right
                visible:            vehicleHeader.checked

202 203
                QGCButton {
                    id: buttonUpload
204 205
                    text:               qsTr("Upload")
                    onClicked:          wimaController.uploadToVehicle();
206 207
                    Layout.fillWidth:   true
                }
208

209 210
                QGCButton {
                    id: buttonRemoveFromVehicle
211 212
                    text:               qsTr("Remove")
                    onClicked:          wimaController.removeFromVehicle();
213 214
                    Layout.fillWidth:   true
                }
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234

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

                QGCLabel {
                    id:                     uploadCompleteText
                    font.pointSize:         ScreenTools.largeFontPointSize
                    Layout.columnSpan:      2
                    horizontalAlignment:    Text.AlignHCenter
                    verticalAlignment:      Text.AlignVCenter
                    text:                   "Done"
                    visible:                false
                }

235
            }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251

            SectionHeader {
                id: statsHeader
                text: qsTr("Statistics")
            }
            GridLayout {
                columns: 2
                rowSpacing: ScreenTools.defaultFontPixelHeight * 0.5
                anchors.topMargin: ScreenTools.defaultFontPixelHeight * 0.25
                visible: statsHeader.checked

                QGCLabel {
                    text:           qsTr("Phase Length: ")
                    wrapMode:       Text.WordWrap
                    font.pointSize: ScreenTools.smallFontPointSize
                }
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
                QGCLabel {
                    text:           wimaController.phaseDistance >= 0 ? wimaController.phaseDistance.toFixed(2) + " m": ""
                    wrapMode:       Text.WordWrap
                    font.pointSize: ScreenTools.smallFontPointSize
                }

                QGCLabel {
                    text:           qsTr("Phase Duration: ")
                    wrapMode:       Text.WordWrap
                    font.pointSize: ScreenTools.smallFontPointSize
                }
                QGCLabel {
                    text:           wimaController.phaseDuration >= 0 ? getTime(wimaController.phaseDuration) : ""
                    wrapMode:       Text.WordWrap
                    font.pointSize: ScreenTools.smallFontPointSize
                }
Valentin Platzgummer's avatar
Valentin Platzgummer committed
268
            }
269
        }
270 271
    }
}