SurveyItemEditor.qml 24.4 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 29 30
    property real   _margin:                    ScreenTools.defaultFontPixelWidth / 2
    property real   _fieldWidth:                ScreenTools.defaultFontPixelWidth * 10.5
    property var    _vehicle:                   QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle : QGroundControl.multiVehicleManager.offlineEditingVehicle
    property real   _cameraMinTriggerInterval:  missionItem.cameraCalc.minTriggerInterval.rawValue
31
    property bool   _polygonDone:               false
DoinLakeFlyer's avatar
DoinLakeFlyer committed
32
    property string _doneAdjusting:             qsTr("Done")
33
    property bool   _presetsAvailable:          missionItem.presetNames.length !== 0
Don Gagne's avatar
Don Gagne committed
34

35
    function polygonCaptureStarted() {
Don Gagne's avatar
Don Gagne committed
36
        missionItem.clearPolygon()
37
    }
Don Gagne's avatar
Don Gagne committed
38

39 40 41
    function polygonCaptureFinished(coordinates) {
        for (var i=0; i<coordinates.length; i++) {
            missionItem.addPolygonCoordinate(coordinates[i])
Don Gagne's avatar
Don Gagne committed
42
        }
43
    }
Don Gagne's avatar
Don Gagne committed
44

45 46
    function polygonAdjustVertex(vertexIndex, vertexCoordinate) {
        missionItem.adjustPolygonCoordinate(vertexIndex, vertexCoordinate)
Don Gagne's avatar
Don Gagne committed
47 48
    }

49 50 51
    function polygonAdjustStarted() { }
    function polygonAdjustFinished() { }

52 53 54 55 56 57 58
    QGCPalette { id: qgcPal; colorGroupEnabled: true }

    Column {
        id:                 editorColumn
        anchors.margins:    _margin
        anchors.top:        parent.top
        anchors.left:       parent.left
59
        anchors.right:      parent.right
60

61
        ColumnLayout {
62
            id:             wizardColumn
63 64
            anchors.left:   parent.left
            anchors.right:  parent.right
65
            spacing:        _margin
66
            visible:        !missionItem.surveyAreaPolygon.isValid || missionItem.wizardMode
67

68
            ColumnLayout {
69
                Layout.fillWidth:   true
70 71 72 73 74 75 76 77 78 79
                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.")
                }

DoinLakeFlyer's avatar
DoinLakeFlyer committed
80 81
                /*
                  Trial of new "done" model so leaving for now in case it comes back
82 83 84
                QGCButton {
                    text:               qsTr("Done With Polygon")
                    Layout.fillWidth:   true
85
                    enabled:            missionItem.surveyAreaPolygon.isValid && !missionItem.surveyAreaPolygon.traceMode
86 87 88
                    onClicked: {
                        if (!_presetsAvailable) {
                            missionItem.wizardMode = false
DoinLakeFlyer's avatar
DoinLakeFlyer committed
89 90
                            // Trial of no auto select next item
                            //editorRoot.selectNextNotReadyItem()
91 92 93 94
                        }
                        _polygonDone = true
                    }
                }
DoinLakeFlyer's avatar
DoinLakeFlyer committed
95
                */
96
            }
97

DoinLakeFlyer's avatar
DoinLakeFlyer committed
98 99
            /*
            Trial of new "done" model so leaving for now in case it comes back
100
            ColumnLayout {
101
                Layout.fillWidth:   true
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 166 167 168 169 170 171 172 173 174
                spacing:            _margin
                visible:            _polygonDone

                QGCLabel {
                    Layout.fillWidth:       true
                    wrapMode:               Text.WordWrap
                    horizontalAlignment:    Text.AlignHCenter
                    text:                   qsTr("Apply a Preset or click %1 for manual setup.").arg(_doneAdjusting)
                }

                QGCComboBox {
                    id:                 wizardPresetCombo
                    Layout.fillWidth:   true
                    model:              missionItem.presetNames
                }

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

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

                GridLayout {
                    Layout.fillWidth:   true
                    columnSpacing:      _margin
                    rowSpacing:         _margin
                    columns:            2
                    visible:            wizardPresectsTransectsHeader.checked

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

                    QGCSlider {
                        id:                     wizardPresetsAngleSlider
                        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();
                    }
                }

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

                QGCButton {
                    text:               _doneAdjusting
                    Layout.fillWidth:   true
                    enabled:            missionItem.surveyAreaPolygon.isValid
                    onClicked: {
                        missionItem.wizardMode = false
DoinLakeFlyer's avatar
DoinLakeFlyer committed
175 176
                        // Trial of no auto select next item
                        //editorRoot.selectNextNotReadyItem()
177
                    }
178 179
                }
            }
DoinLakeFlyer's avatar
DoinLakeFlyer committed
180
            */
Don Gagne's avatar
Don Gagne committed
181 182
        }

183
        Column {
184 185 186
            anchors.left:   parent.left
            anchors.right:  parent.right
            spacing:        _margin
187
            visible:        !wizardColumn.visible
Don Gagne's avatar
Don Gagne committed
188

189 190
            QGCTabBar {
                id:             tabBar
191 192
                anchors.left:   parent.left
                anchors.right:  parent.right
Don Gagne's avatar
Don Gagne committed
193

194
                Component.onCompleted: currentIndex = QGroundControl.settingsManager.planViewSettings.displayPresetsTabFirst.rawValue ? 2 : 0
Don Gagne's avatar
Don Gagne committed
195

196 197 198
                QGCTabButton { text: qsTr("Grid") }
                QGCTabButton { text: qsTr("Camera") }
                QGCTabButton { text: qsTr("Presets") }
Don Gagne's avatar
Don Gagne committed
199 200
            }

201 202 203 204 205 206 207 208 209 210 211 212 213
            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
Don Gagne's avatar
Don Gagne committed
214 215
                }

216 217 218 219 220 221
                CameraCalcGrid {
                    cameraCalc:                     missionItem.cameraCalc
                    vehicleFlightIsFrontal:         true
                    distanceToSurfaceLabel:         qsTr("Altitude")
                    distanceToSurfaceAltitudeMode:  missionItem.followTerrain ?
                                                        QGroundControl.AltitudeModeAboveTerrain :
222
                                                        (missionItem.cameraCalc.distanceToSurfaceRelative ? QGroundControl.AltitudeModeRelative : QGroundControl.AltitudeModeAbsolute)
223 224
                    frontalDistanceLabel:           qsTr("Trigger Dist")
                    sideDistanceLabel:              qsTr("Spacing")
Don Gagne's avatar
Don Gagne committed
225 226
                }

227
                SectionHeader {
228 229 230 231
                    id:             transectsHeader
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    text:           qsTr("Transects")
232
                }
233 234 235 236 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 266 267 268 269

                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
                    }
270
                }
DonLakeFlyer's avatar
DonLakeFlyer committed
271

272 273 274 275
                QGCButton {
                    text:               qsTr("Rotate Entry Point")
                    onClicked:          missionItem.rotateEntryPoint();
                }
Don Gagne's avatar
Don Gagne committed
276

277 278 279 280 281
                ColumnLayout {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    spacing:        _margin
                    visible:        transectsHeader.checked
DonLakeFlyer's avatar
DonLakeFlyer committed
282

283
                    /*
284
              Temporarily removed due to bug https://github.com/mavlink/qgroundcontrol/issues/7005
285 286 287 288
            FactCheckBox {
                text:       qsTr("Split concave polygons")
                fact:       _splitConcave
                visible:    _splitConcave.visible
289
                property Fact _splitConcave: missionItem.splitConcavePolygons
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 325 326 327 328 329 330 331 332 333
                    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)
                            }
334
                        }
335 336
                    }
                }
337

338
                SectionHeader {
339 340 341 342 343
                    id:             terrainHeader
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    text:           qsTr("Terrain")
                    checked:        missionItem.followTerrain
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382
                }

                ColumnLayout {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    spacing:        _margin
                    visible:        terrainHeader.checked


                    QGCCheckBox {
                        id:         followsTerrainCheckBox
                        text:       qsTr("Vehicle follows terrain")
                        checked:    missionItem.followTerrain
                        onClicked:  missionItem.followTerrain = checked
                    }

                    GridLayout {
                        Layout.fillWidth:   true
                        columnSpacing:      _margin
                        rowSpacing:         _margin
                        columns:            2
                        visible:            followsTerrainCheckBox.checked

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

                        QGCLabel { text: qsTr("Max Climb Rate") }
                        FactTextField {
                            fact:               missionItem.terrainAdjustMaxClimbRate
                            Layout.fillWidth:   true
                        }

                        QGCLabel { text: qsTr("Max Descent Rate") }
                        FactTextField {
                            fact:               missionItem.terrainAdjustMaxDescentRate
                            Layout.fillWidth:   true
383
                        }
384
                    }
385
                }
386

387
                SectionHeader {
388 389 390 391
                    id:             statsHeader
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    text:           qsTr("Statistics")
392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417
                }

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

            Column {
                anchors.left:       parent.left
                anchors.right:      parent.right
                spacing:            _margin
                visible:            tabBar.currentIndex == 1

                CameraCalcCamera {
                    cameraCalc:                     missionItem.cameraCalc
                    vehicleFlightIsFrontal:         true
                    distanceToSurfaceLabel:         qsTr("Altitude")
                    distanceToSurfaceAltitudeMode:  missionItem.followTerrain ?
                                                        QGroundControl.AltitudeModeAboveTerrain :
                                                        missionItem.cameraCalc.distanceToSurfaceRelative
                    frontalDistanceLabel:           qsTr("Trigger Dist")
                    sideDistanceLabel:              qsTr("Spacing")
                }
            } // Camera Column
418

419
            ColumnLayout {
420 421 422 423
                anchors.left:       parent.left
                anchors.right:      parent.right
                spacing:            _margin
                visible:            tabBar.currentIndex == 2
424

425 426 427 428 429
                QGCLabel {
                    Layout.fillWidth:   true
                    text:               qsTr("Presets")
                    wrapMode:           Text.WordWrap
                }
430

431 432 433 434
                QGCComboBox {
                    id:                 presetCombo
                    Layout.fillWidth:   true
                    model:              missionItem.presetNames
435
                }
436

437
                RowLayout {
438
                    Layout.fillWidth:   true
439

440
                    QGCButton {
441
                        Layout.fillWidth:   true
442 443 444
                        text:               qsTr("Apply Preset")
                        enabled:            missionItem.presetNames.length != 0
                        onClicked:          missionItem.loadPreset(presetCombo.textAt(presetCombo.currentIndex))
445 446
                    }

447
                    QGCButton {
448
                        Layout.fillWidth:   true
449 450
                        text:               qsTr("Delete Preset")
                        enabled:            missionItem.presetNames.length != 0
451 452 453 454 455 456 457 458 459 460 461 462 463
                        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()
                                }
                            }
                        }
464 465
                    }

466
                }
467

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

Don Gagne's avatar
Don Gagne committed
470
                QGCButton {
471
                    Layout.alignment:   Qt.AlignCenter
Don Gagne's avatar
Don Gagne committed
472
                    Layout.fillWidth:   true
473 474
                    text:               qsTr("Save Settings As New Preset")
                    onClicked:          mainWindow.showComponentDialog(savePresetDialog, qsTr("Save Preset"), mainWindow.showDialogDefaultWidth, StandardButton.Save | StandardButton.Cancel)
Don Gagne's avatar
Don Gagne committed
475 476
                }

477 478
                SectionHeader {
                    id:                 presectsTransectsHeader
Don Gagne's avatar
Don Gagne committed
479
                    Layout.fillWidth:   true
480
                    text:               qsTr("Transects")
Don Gagne's avatar
Don Gagne committed
481 482
                }

483 484 485 486 487 488
                GridLayout {
                    Layout.fillWidth:   true
                    columnSpacing:      _margin
                    rowSpacing:         _margin
                    columns:            2
                    visible:            presectsTransectsHeader.checked
489

490 491 492 493 494 495
                    QGCLabel { text: qsTr("Angle") }
                    FactTextField {
                        fact:                   missionItem.gridAngle
                        Layout.fillWidth:       true
                        onUpdated:              presetsAngleSlider.value = missionItem.gridAngle.value
                    }
496

497 498 499 500 501 502 503 504 505 506 507 508 509
                    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
                    }
510

511 512 513 514 515 516
                    QGCButton {
                        Layout.columnSpan:  2
                        Layout.fillWidth:   true
                        text:               qsTr("Rotate Entry Point")
                        onClicked:          missionItem.rotateEntryPoint();
                    }
517 518
                }

519
                SectionHeader {
520
                    id:                 presetsStatsHeader
521
                    Layout.fillWidth:   true
522
                    text:               qsTr("Statistics")
523 524
                }

525
                TransectStyleComplexItemStats {
526
                    Layout.fillWidth:   true
527
                    visible:            presetsStatsHeader.checked
528
                }
529 530
            } // Main editing column
        } // Top level  Column
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561

        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
                    }
Don Gagne's avatar
Don Gagne committed
562 563 564 565
                }
            }
        }
    }
566 567 568 569 570 571 572 573 574 575 576 577 578

    KMLOrSHPFileDialog {
        id:             kmlOrSHPLoadDialog
        title:          qsTr("Select Polygon File")
        selectExisting: true

        onAcceptedForLoad: {
            missionItem.surveyAreaPolygon.loadKMLOrSHPFile(file)
            missionItem.resetState = false
            //editorMap.mapFitFunctions.fitMapViewportToMissionItems()
            close()
        }
    }
579
} // Rectangle