MissionSettingsEditor.qml 14.8 KB
Newer Older
1 2 3
import QtQuick          2.3
import QtQuick.Controls 1.2
import QtQuick.Layouts  1.2
4

5 6 7 8 9 10 11
import QGroundControl                   1.0
import QGroundControl.ScreenTools       1.0
import QGroundControl.Vehicle           1.0
import QGroundControl.Controls          1.0
import QGroundControl.FactControls      1.0
import QGroundControl.Palette           1.0
import QGroundControl.SettingsManager   1.0
DonLakeFlyer's avatar
DonLakeFlyer committed
12
import QGroundControl.Controllers       1.0
13 14 15 16 17

// Editor for Mission Settings
Rectangle {
    id:                 valuesRect
    width:              availableWidth
18
    height:             valuesColumn.height + (_margin * 2)
19 20 21 22
    color:              qgcPal.windowShadeDark
    visible:            missionItem.isCurrentItem
    radius:             _radius

23 24
    property var    _masterControler:               masterController
    property var    _missionController:             _masterControler.missionController
25 26 27 28 29 30
    property var    _controllerVehicle:             _masterControler.controllerVehicle
    property bool   _vehicleHasHomePosition:        _controllerVehicle.homePosition.isValid
    property bool   _showCruiseSpeed:               !_controllerVehicle.multiRotor
    property bool   _showHoverSpeed:                _controllerVehicle.multiRotor || _controllerVehicle.vtol
    property bool   _multipleFirmware:              !QGroundControl.singleFirmwareSupport
    property bool   _multipleVehicleTypes:          !QGroundControl.singleVehicleSupport
31 32 33 34 35 36
    property real   _fieldWidth:                    ScreenTools.defaultFontPixelWidth * 16
    property bool   _mobile:                        ScreenTools.isMobile
    property var    _savePath:                      QGroundControl.settingsManager.appSettings.missionSavePath
    property var    _fileExtension:                 QGroundControl.settingsManager.appSettings.missionFileExtension
    property var    _appSettings:                   QGroundControl.settingsManager.appSettings
    property bool   _waypointsOnlyMode:             QGroundControl.corePlugin.options.missionWaypointsOnly
37
    property bool   _showCameraSection:             (_waypointsOnlyMode || QGroundControl.corePlugin.showAdvancedUI) && !_controllerVehicle.apmFirmware
38
    property bool   _simpleMissionStart:            QGroundControl.corePlugin.options.showSimpleMissionStart
39 40
    property bool   _showFlightSpeed:               !_controllerVehicle.vtol && !_simpleMissionStart && !_controllerVehicle.apmFirmware
    property bool   _allowFWVehicleTypeSelection:   _noMissionItemsAdded && !globals.activeVehicle
DonLakeFlyer's avatar
DonLakeFlyer committed
41 42 43

    readonly property string _firmwareLabel:    qsTr("Firmware")
    readonly property string _vehicleLabel:     qsTr("Vehicle")
44
    readonly property real  _margin:            ScreenTools.defaultFontPixelWidth / 2
DonLakeFlyer's avatar
DonLakeFlyer committed
45 46

    QGCPalette { id: qgcPal }
47
    QGCFileDialogController { id: fileController }
DonLakeFlyer's avatar
DonLakeFlyer committed
48

49
    ColumnLayout {
50 51 52 53 54 55
        id:                 valuesColumn
        anchors.margins:    _margin
        anchors.left:       parent.left
        anchors.right:      parent.right
        anchors.top:        parent.top
        spacing:            _margin
56

57 58 59 60 61 62 63 64 65 66 67
        QGCLabel {
            text:           qsTr("All Altitudes")
            font.pointSize: ScreenTools.smallFontPointSize
        }
        QGCComboBox {
            id:                     altModeCombo
            model:                  enumStrings
            Layout.fillWidth:       true
            enabled:                _noMissionItemsAdded
            onActivated:            _missionController.globalAltitudeMode = enumValues[index]
            Component.onCompleted:  buildEnumStrings()
DonLakeFlyer's avatar
DonLakeFlyer committed
68

69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
            readonly property var enumStringsBase:   [ QGroundControl.altitudeModeShortDescription(QGroundControl.AltitudeModeRelative),
                QGroundControl.altitudeModeShortDescription(QGroundControl.AltitudeModeAbsolute),
                QGroundControl.altitudeModeShortDescription(QGroundControl.AltitudeModeAboveTerrain),
                QGroundControl.altitudeModeShortDescription(QGroundControl.AltitudeModeTerrainFrame),
                qsTr("Mixed Modes") ]
            readonly property var enumValuesBase:    [QGroundControl.AltitudeModeRelative, QGroundControl.AltitudeModeAbsolute, QGroundControl.AltitudeModeAboveTerrain, QGroundControl.AltitudeModeTerrainFrame, QGroundControl.AltitudeModeNone  ]

            property var enumStrings:   [ ]
            property var enumValues:    [ ]

            function buildEnumStrings() {
                var newEnumStrings = enumStringsBase.slice(0)
                var newEnumValues = enumValuesBase.slice(0)
                if (!_controllerVehicle.supportsTerrainFrame) {
                    // We need to find and pull out the QGroundControl.AltitudeModeTerrainFrame values
                    var deleteIndex = newEnumValues.lastIndexOf(QGroundControl.AltitudeModeTerrainFrame)
                    newEnumStrings.splice(deleteIndex, 1)
                    newEnumValues.splice(deleteIndex, 1)
                    if (_missionController.globalAltitudeMode == QGroundControl.AltitudeModeTerrainFrame) {
                        _missionController.globalAltitudeMode = QGroundControl.AltitudeModeAboveTerrain
                    }
                }
                enumStrings = newEnumStrings
                enumValues = newEnumValues
                currentIndex = enumValues.lastIndexOf(_missionController.globalAltitudeMode)
DonLakeFlyer's avatar
DonLakeFlyer committed
94
            }
95 96 97 98

            Connections {
                target:                         _controllerVehicle
                onSupportsTerrainFrameChanged:  altModeCombo.buildEnumStrings()
DonLakeFlyer's avatar
DonLakeFlyer committed
99
            }
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
        }
        QGCLabel {
            Layout.fillWidth:       true
            wrapMode:               Text.WordWrap
            horizontalAlignment:    Text.AlignHCenter
            font.pointSize:         ScreenTools.smallFontPointSize
            text:                   switch(_missionController.globalAltitudeMode) {
                                    case QGroundControl.AltitudeModeAboveTerrain:
                                        qsTr("Specified altitudes are distance above terrain. Actual altitudes sent to vehicle are calculated from terrain data and sent in AMSL")
                                        break
                                    case QGroundControl.AltitudeModeTerrainFrame:
                                        qsTr("Specified altitudes are distance above terrain. The actual altitude flown is controlled by the vehicle either from terrain height maps being sent to vehicle or a distance sensor.")
                                        break
                                    case QGroundControl.AltitudeModeNone:
                                        qsTr("The altitude mode can differ for each individual item.")
                                        break
                                    default:
                                        ""
                                        break
                                    }
            visible:                _missionController.globalAltitudeMode == QGroundControl.AltitudeModeAboveTerrain || _missionController.globalAltitudeMode == QGroundControl.AltitudeModeTerrainFrame || _missionController.globalAltitudeMode == QGroundControl.AltitudeModeNone
        }

        QGCLabel {
            text:           qsTr("Initial Waypoint Alt")
            font.pointSize: ScreenTools.smallFontPointSize
        }
        AltitudeFactTextField {
            fact:               QGroundControl.settingsManager.appSettings.defaultMissionItemAltitude
            altitudeMode:       _missionController.globalAltitudeModeDefault
            Layout.fillWidth:   true
        }

        GridLayout {
            Layout.fillWidth:   true
            columnSpacing:      ScreenTools.defaultFontPixelWidth
            rowSpacing:         columnSpacing
            columns:            2
DonLakeFlyer's avatar
DonLakeFlyer committed
138

139 140 141
            QGCCheckBox {
                id:         flightSpeedCheckBox
                text:       qsTr("Flight speed")
142
                visible:    _showFlightSpeed
143 144
                checked:    missionItem.speedSection.specifyFlightSpeed
                onClicked:   missionItem.speedSection.specifyFlightSpeed = checked
145 146 147
            }
            FactTextField {
                Layout.fillWidth:   true
148
                fact:               missionItem.speedSection.flightSpeed
149
                visible:            _showFlightSpeed
150
                enabled:            flightSpeedCheckBox.checked
DonLakeFlyer's avatar
DonLakeFlyer committed
151
            }
152
        }
DonLakeFlyer's avatar
DonLakeFlyer committed
153

154
        Column {
155 156 157
            Layout.fillWidth:   true
            spacing:            _margin
            visible:            !_simpleMissionStart
158 159 160

            CameraSection {
                id:         cameraSection
Don Gagne's avatar
Don Gagne committed
161
                checked:    !_waypointsOnlyMode && missionItem.cameraSection.settingsSpecified
162 163 164 165 166 167 168 169 170 171 172 173 174 175
                visible:    _showCameraSection
            }

            QGCLabel {
                anchors.left:           parent.left
                anchors.right:          parent.right
                text:                   qsTr("Above camera commands will take affect immediately upon mission start.")
                wrapMode:               Text.WordWrap
                horizontalAlignment:    Text.AlignHCenter
                font.pointSize:         ScreenTools.smallFontPointSize
                visible:                _showCameraSection && cameraSection.checked
            }

            SectionHeader {
176
                id:             vehicleInfoSectionHeader
177 178
                anchors.left:   parent.left
                anchors.right:  parent.right
179 180 181
                text:           qsTr("Vehicle Info")
                visible:        !_waypointsOnlyMode
                checked:        false
182
            }
DonLakeFlyer's avatar
DonLakeFlyer committed
183 184 185 186 187 188 189

            GridLayout {
                anchors.left:   parent.left
                anchors.right:  parent.right
                columnSpacing:  ScreenTools.defaultFontPixelWidth
                rowSpacing:     columnSpacing
                columns:        2
190
                visible:        vehicleInfoSectionHeader.visible && vehicleInfoSectionHeader.checked
DonLakeFlyer's avatar
DonLakeFlyer committed
191 192

                QGCLabel {
193 194
                    text:               _firmwareLabel
                    Layout.fillWidth:   true
195
                    visible:            _multipleFirmware
196 197
                }
                FactComboBox {
198
                    fact:                   QGroundControl.settingsManager.appSettings.offlineEditingFirmwareClass
199 200
                    indexModel:             false
                    Layout.preferredWidth:  _fieldWidth
201 202 203 204 205
                    visible:                _multipleFirmware && _allowFWVehicleTypeSelection
                }
                QGCLabel {
                    text:       _controllerVehicle.firmwareTypeString
                    visible:    _multipleFirmware && !_allowFWVehicleTypeSelection
206 207 208 209 210
                }

                QGCLabel {
                    text:               _vehicleLabel
                    Layout.fillWidth:   true
211
                    visible:            _multipleVehicleTypes
212 213
                }
                FactComboBox {
214
                    fact:                   QGroundControl.settingsManager.appSettings.offlineEditingVehicleClass
215 216
                    indexModel:             false
                    Layout.preferredWidth:  _fieldWidth
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231
                    visible:                _multipleVehicleTypes && _allowFWVehicleTypeSelection
                }
                QGCLabel {
                    text:       _controllerVehicle.vehicleTypeString
                    visible:    _multipleVehicleTypes && !_allowFWVehicleTypeSelection
                }

                QGCLabel {
                    Layout.columnSpan:      2
                    Layout.alignment:       Qt.AlignHCenter
                    Layout.fillWidth:       true
                    wrapMode:               Text.WordWrap
                    font.pointSize:         ScreenTools.smallFontPointSize
                    text:                   qsTr("The following speed values are used to calculate total mission time. They do not affect the flight speed for the mission.")
                    visible:                _showCruiseSpeed || _showHoverSpeed
232 233 234 235 236 237
                }

                QGCLabel {
                    text:               qsTr("Cruise speed")
                    visible:            _showCruiseSpeed
                    Layout.fillWidth:   true
DonLakeFlyer's avatar
DonLakeFlyer committed
238 239
                }
                FactTextField {
240 241 242 243 244 245 246 247
                    fact:                   QGroundControl.settingsManager.appSettings.offlineEditingCruiseSpeed
                    visible:                _showCruiseSpeed
                    Layout.preferredWidth:  _fieldWidth
                }

                QGCLabel {
                    text:               qsTr("Hover speed")
                    visible:            _showHoverSpeed
DonLakeFlyer's avatar
DonLakeFlyer committed
248 249
                    Layout.fillWidth:   true
                }
250 251 252 253 254 255
                FactTextField {
                    fact:                   QGroundControl.settingsManager.appSettings.offlineEditingHoverSpeed
                    visible:                _showHoverSpeed
                    Layout.preferredWidth:  _fieldWidth
                }
            } // GridLayout
DonLakeFlyer's avatar
DonLakeFlyer committed
256

257
            SectionHeader {
258 259 260 261 262 263
                id:             plannedHomePositionSection
                anchors.left:   parent.left
                anchors.right:  parent.right
                text:           qsTr("Launch Position")
                visible:        !_vehicleHasHomePosition
                checked:        false
264
            }
DonLakeFlyer's avatar
DonLakeFlyer committed
265

266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
            Column {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        _margin
                visible:        plannedHomePositionSection.checked && !_vehicleHasHomePosition

                GridLayout {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    columnSpacing:  ScreenTools.defaultFontPixelWidth
                    rowSpacing:     columnSpacing
                    columns:        2

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

                QGCLabel {
                    width:                  parent.width
                    wrapMode:               Text.WordWrap
                    font.pointSize:         ScreenTools.smallFontPointSize
                    text:                   qsTr("Actual position set by vehicle at flight time.")
                    horizontalAlignment:    Text.AlignHCenter
                }

                QGCButton {
297
                    text:                       qsTr("Set To Map Center")
298 299 300
                    onClicked:                  missionItem.coordinate = map.center
                    anchors.horizontalCenter:   parent.horizontalCenter
                }
DonLakeFlyer's avatar
DonLakeFlyer committed
301
            }
302
        } // Column
303
    } // Column
304
} // Rectangle