SurveyItemEditor.qml 17.5 KB
Newer Older
1 2
import QtQuick          2.3
import QtQuick.Controls 1.2
Don Gagne's avatar
Don Gagne committed
3
import QtQuick.Dialogs  1.2
4
import QtQuick.Extras   1.4
5
import QtQuick.Layouts  1.2
6

7
import QGroundControl               1.0
8 9 10
import QGroundControl.ScreenTools   1.0
import QGroundControl.Vehicle       1.0
import QGroundControl.Controls      1.0
11
import QGroundControl.FactSystem    1.0
12 13
import QGroundControl.FactControls  1.0
import QGroundControl.Palette       1.0
14
import QGroundControl.FlightMap     1.0
15 16 17

Rectangle {
    id:         _root
18
    height:     visible ? (editorColumn.height + (_margin * 2)) : 0
19 20 21 22
    width:      availableWidth
    color:      qgcPal.windowShadeDark
    radius:     _radius

Ricardo de Almeida Gonzaga's avatar
Ricardo de Almeida Gonzaga committed
23
    // The following properties must be available up the hierarchy chain
24 25 26
    //property real   availableWidth    ///< Width for control
    //property var    missionItem       ///< Mission Item for editor

27 28
    property real   _margin:                    ScreenTools.defaultFontPixelWidth / 2
    property real   _fieldWidth:                ScreenTools.defaultFontPixelWidth * 10.5
29 30 31
    property var    _vehicle:                   QGroundControl.multiVehicleManager.activeVehicle ?
                                                    QGroundControl.multiVehicleManager.activeVehicle :
                                                    QGroundControl.multiVehicleManager.offlineEditingVehicle
32 33 34 35 36
    property real   _cameraMinTriggerInterval:  _missionItem.cameraCalc.minTriggerInterval.rawValue
    property bool   _polygonDone:               false
    property string _doneAdjusting:             qsTr("Done")
    property var    _missionItem:               missionItem
    property bool   _presetsAvailable:          _missionItem.presetNames.length !== 0
Don Gagne's avatar
Don Gagne committed
37

38
    function polygonCaptureStarted() {
39
        _missionItem.clearPolygon()
40
    }
Don Gagne's avatar
Don Gagne committed
41

42 43
    function polygonCaptureFinished(coordinates) {
        for (var i=0; i<coordinates.length; i++) {
44
            _missionItem.addPolygonCoordinate(coordinates[i])
Don Gagne's avatar
Don Gagne committed
45
        }
46
    }
Don Gagne's avatar
Don Gagne committed
47

48
    function polygonAdjustVertex(vertexIndex, vertexCoordinate) {
49
        _missionItem.adjustPolygonCoordinate(vertexIndex, vertexCoordinate)
Don Gagne's avatar
Don Gagne committed
50 51
    }

52 53 54
    function polygonAdjustStarted() { }
    function polygonAdjustFinished() { }

55 56 57 58 59 60 61
    QGCPalette { id: qgcPal; colorGroupEnabled: true }

    Column {
        id:                 editorColumn
        anchors.margins:    _margin
        anchors.top:        parent.top
        anchors.left:       parent.left
62
        anchors.right:      parent.right
63

64 65
        ColumnLayout {
            id:             wizardColumn
Don Gagne's avatar
Don Gagne committed
66 67
            anchors.left:   parent.left
            anchors.right:  parent.right
68 69
            spacing:        _margin
            visible:        !_missionItem.surveyAreaPolygon.isValid || _missionItem.wizardMode
DonLakeFlyer's avatar
DonLakeFlyer committed
70

71
            ColumnLayout {
Don Gagne's avatar
Don Gagne committed
72
                Layout.fillWidth:   true
73 74 75 76 77 78 79 80 81
                spacing:             _margin
                visible:            !_polygonDone

                QGCLabel {
                    Layout.fillWidth:       true
                    wrapMode:               Text.WordWrap
                    horizontalAlignment:    Text.AlignHCenter
                    text:                   qsTr("Use the Polygon Tools to create the polygon which outlines your survey area.")
                }
Don Gagne's avatar
Don Gagne committed
82
            }
Don Gagne's avatar
Don Gagne committed
83 84
        }

85
        Column {
Don Gagne's avatar
Don Gagne committed
86 87 88
            anchors.left:   parent.left
            anchors.right:  parent.right
            spacing:        _margin
89
            visible:        !wizardColumn.visible
90

91 92 93 94
            TransectStyleComplexItemTabBar {
                id:             tabBar
                anchors.left:   parent.left
                anchors.right:  parent.right
DonLakeFlyer's avatar
DonLakeFlyer committed
95 96
            }

97 98 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 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
            // Grid tab
            Column {
                anchors.left:       parent.left
                anchors.right:      parent.right
                spacing:            _margin
                visible:            tabBar.currentIndex === 0

                QGCLabel {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    text:           qsTr("WARNING: Photo interval is below minimum interval (%1 secs) supported by camera.").arg(_cameraMinTriggerInterval.toFixed(1))
                    wrapMode:       Text.WordWrap
                    color:          qgcPal.warningText
                    visible:        _missionItem.cameraShots > 0 && _cameraMinTriggerInterval !== 0 && _cameraMinTriggerInterval > _missionItem.timeBetweenShots
                }

                CameraCalcGrid {
                    cameraCalc:                     _missionItem.cameraCalc
                    vehicleFlightIsFrontal:         true
                    distanceToSurfaceLabel:         qsTr("Altitude")
                    distanceToSurfaceAltitudeMode:  _missionItem.followTerrain ?
                                                        QGroundControl.AltitudeModeAboveTerrain :
                                                        (_missionItem.cameraCalc.distanceToSurfaceRelative ? QGroundControl.AltitudeModeRelative : QGroundControl.AltitudeModeAbsolute)
                    frontalDistanceLabel:           qsTr("Trigger Dist")
                    sideDistanceLabel:              qsTr("Spacing")
                }

                SectionHeader {
                    id:             transectsHeader
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    text:           qsTr("Transects")
                }

                GridLayout {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    columnSpacing:  _margin
                    rowSpacing:     _margin
                    columns:        2
                    visible:        transectsHeader.checked

                    QGCLabel { text: qsTr("Angle") }
                    FactTextField {
                        fact:                   _missionItem.gridAngle
                        Layout.fillWidth:       true
                        onUpdated:              angleSlider.value = _missionItem.gridAngle.value
                    }

                    QGCSlider {
                        id:                     angleSlider
                        minimumValue:           0
                        maximumValue:           359
                        stepSize:               1
                        tickmarksEnabled:       false
                        Layout.fillWidth:       true
                        Layout.columnSpan:      2
                        Layout.preferredHeight: ScreenTools.defaultFontPixelHeight * 1.5
                        onValueChanged:         _missionItem.gridAngle.value = value
                        Component.onCompleted:  value = _missionItem.gridAngle.value
                        updateValueWhileDragging: true
                    }

                    QGCLabel {
                        text:       qsTr("Turnaround dist")
                    }
                    FactTextField {
                        fact:               _missionItem.turnAroundDistance
                        Layout.fillWidth:   true
166 167 168
                    }
                }

169 170 171 172
                QGCButton {
                    text:               qsTr("Rotate Entry Point")
                    onClicked:          _missionItem.rotateEntryPoint();
                }
Don Gagne's avatar
Don Gagne committed
173

174 175 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 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223
                ColumnLayout {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    spacing:        _margin
                    visible:        transectsHeader.checked

                    QGCOptionsComboBox {
                        Layout.fillWidth: true

                        model: [
                            {
                                text:       qsTr("Hover and capture image"),
                                fact:       _missionItem.hoverAndCapture,
                                enabled:    !_missionItem.followTerrain,
                                visible:    _missionItem.hoverAndCaptureAllowed
                            },
                            {
                                text:       qsTr("Refly at 90 deg offset"),
                                fact:       _missionItem.refly90Degrees,
                                enabled:    !_missionItem.followTerrain,
                                visible:    true
                            },
                            {
                                text:       qsTr("Images in turnarounds"),
                                fact:       _missionItem.cameraTriggerInTurnAround,
                                enabled:    _missionItem.hoverAndCaptureAllowed ? !_missionItem.hoverAndCapture.rawValue : true,
                                visible:    true
                            },
                            {
                                text:       qsTr("Fly alternate transects"),
                                fact:       _missionItem.flyAlternateTransects,
                                enabled:    true,
                                visible:    _vehicle ? (_vehicle.fixedWing || _vehicle.vtol) : false
                            },
                            {
                                text:       qsTr("Relative altitude"),
                                enabled:    _missionItem.cameraCalc.isManualCamera && !_missionItem.followTerrain,
                                visible:    QGroundControl.corePlugin.options.showMissionAbsoluteAltitude || (!_missionItem.cameraCalc.distanceToSurfaceRelative && !_missionItem.followTerrain),
                                checked:    _missionItem.cameraCalc.distanceToSurfaceRelative
                            }
                        ]

                        onItemClicked: {
                            if (index == 4) {
                                _missionItem.cameraCalc.distanceToSurfaceRelative = !_missionItem.cameraCalc.distanceToSurfaceRelative
                                console.log(_missionItem.cameraCalc.distanceToSurfaceRelative)
                            }
                        }
                    }
                }
224

225 226 227 228 229 230 231 232 233 234 235 236 237
                SectionHeader {
                    id:             statsHeader
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    text:           qsTr("Statistics")
                }

                TransectStyleComplexItemStats {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    visible:        statsHeader.checked
                }
            } // Grid Column
238

239 240 241 242 243 244
            // Camera Tab
            Column {
                anchors.left:       parent.left
                anchors.right:      parent.right
                spacing:            _margin
                visible:            tabBar.currentIndex === 1
Don Gagne's avatar
Don Gagne committed
245

246 247
                CameraCalcCamera {
                    cameraCalc: _missionItem.cameraCalc
248
                }
249 250 251 252 253 254 255 256 257
            } // Camera Column

            // Terrain Tab
            TransectStyleComplexItemTerrainFollow {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        _margin
                visible:        tabBar.currentIndex === 2
                missionItem:    _missionItem
258
            }
259

260 261 262 263 264 265
            // Presets Tab
            ColumnLayout {
                anchors.left:       parent.left
                anchors.right:      parent.right
                spacing:            _margin
                visible:            tabBar.currentIndex === 3
266

267 268 269 270 271
                QGCLabel {
                    Layout.fillWidth:   true
                    text:               qsTr("Presets")
                    wrapMode:           Text.WordWrap
                }
272

273 274 275 276 277
                QGCComboBox {
                    id:                 presetCombo
                    Layout.fillWidth:   true
                    model:              _missionItem.presetNames
                }
278

279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
                RowLayout {
                    Layout.fillWidth:   true

                    QGCButton {
                        Layout.fillWidth:   true
                        text:               qsTr("Apply Preset")
                        enabled:            _missionItem.presetNames.length != 0
                        onClicked:          _missionItem.loadPreset(presetCombo.textAt(presetCombo.currentIndex))
                    }

                    QGCButton {
                        Layout.fillWidth:   true
                        text:               qsTr("Delete Preset")
                        enabled:            _missionItem.presetNames.length != 0
                        onClicked:          mainWindow.showComponentDialog(deletePresetMessage, qsTr("Delete Preset"), mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.No)

                        Component {
                            id: deletePresetMessage
                            QGCViewMessage {
                                message: qsTr("Are you sure you want to delete '%1' preset?").arg(presetName)
                                property string presetName: presetCombo.textAt(presetCombo.currentIndex)
                                function accept() {
                                    _missionItem.deletePreset(presetName)
                                    hideDialog()
                                }
                            }
                        }
                    }
                }

                Item { height: ScreenTools.defaultFontPixelHeight; width: 1 }

                QGCButton {
                    Layout.alignment:   Qt.AlignCenter
                    Layout.fillWidth:   true
                    text:               qsTr("Save Settings As New Preset")
                    onClicked:          mainWindow.showComponentDialog(savePresetDialog, qsTr("Save Preset"), mainWindow.showDialogDefaultWidth, StandardButton.Save | StandardButton.Cancel)
                }

                SectionHeader {
                    id:                 presectsTransectsHeader
                    Layout.fillWidth:   true
                    text:               qsTr("Transects")
                }

                GridLayout {
325
                    Layout.fillWidth:   true
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
                    columnSpacing:      _margin
                    rowSpacing:         _margin
                    columns:            2
                    visible:            presectsTransectsHeader.checked

                    QGCLabel { text: qsTr("Angle") }
                    FactTextField {
                        fact:                   _missionItem.gridAngle
                        Layout.fillWidth:       true
                        onUpdated:              presetsAngleSlider.value = _missionItem.gridAngle.value
                    }

                    QGCSlider {
                        id:                     presetsAngleSlider
                        minimumValue:           0
                        maximumValue:           359
                        stepSize:               1
                        tickmarksEnabled:       false
                        Layout.fillWidth:       true
                        Layout.columnSpan:      2
                        Layout.preferredHeight: ScreenTools.defaultFontPixelHeight * 1.5
                        onValueChanged:         _missionItem.gridAngle.value = value
                        Component.onCompleted:  value = _missionItem.gridAngle.value
                        updateValueWhileDragging: true
                    }

                    QGCButton {
                        Layout.columnSpan:  2
                        Layout.fillWidth:   true
                        text:               qsTr("Rotate Entry Point")
                        onClicked:          _missionItem.rotateEntryPoint();
                    }
358
                }
359

360 361
                SectionHeader {
                    id:                 presetsStatsHeader
362
                    Layout.fillWidth:   true
363
                    text:               qsTr("Statistics")
364
                }
365

366
                TransectStyleComplexItemStats {
367
                    Layout.fillWidth:   true
368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402
                    visible:            presetsStatsHeader.checked
                }
            } // Main editing column
        } // Top level  Column

        Component {
            id: savePresetDialog

            QGCViewDialog {
                function accept() {
                    if (presetNameField.text != "") {
                        _missionItem.savePreset(presetNameField.text)
                        hideDialog()
                    }
                }

                ColumnLayout {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    spacing:        ScreenTools.defaultFontPixelHeight

                    QGCLabel {
                        Layout.fillWidth:   true
                        text:               qsTr("Save the current settings as a named preset.")
                        wrapMode:           Text.WordWrap
                    }

                    QGCLabel {
                        text: qsTr("Preset Name")
                    }

                    QGCTextField {
                        id:                 presetNameField
                        Layout.fillWidth:   true
                    }
403
                }
404
            }
405
        }
406
    }
407

408 409 410 411
    KMLOrSHPFileDialog {
        id:             kmlOrSHPLoadDialog
        title:          qsTr("Select Polygon File")
        selectExisting: true
412

413 414 415 416 417 418 419
        onAcceptedForLoad: {
            _missionItem.surveyAreaPolygon.loadKMLOrSHPFile(file)
            _missionItem.resetState = false
            //editorMap.mapFitFunctions.fitMapViewportTo_missionItems()
            close()
        }
    }
420
} // Rectangle