SurveyItemEditor.qml 23.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.Layouts  1.2
5

6
import QGroundControl               1.0
7 8 9 10 11
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
12
import QGroundControl.FlightMap     1.0
13 14 15 16

// Editor for Survery mission items
Rectangle {
    id:         _root
17
    height:     visible ? (editorColumn.height + (_margin * 2)) : 0
18 19 20 21
    width:      availableWidth
    color:      qgcPal.windowShadeDark
    radius:     _radius

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

26 27 28 29 30 31
    property real   _margin:            ScreenTools.defaultFontPixelWidth * 0.25
    property int    _cameraIndex:       1
    property real   _fieldWidth:        ScreenTools.defaultFontPixelWidth * 10.5
    property var    _cameraList:        [ qsTr("Manual Grid (no camera specs)"), qsTr("Custom Camera Grid") ]
    property var    _vehicle:           QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle : QGroundControl.multiVehicleManager.offlineEditingVehicle
    property var    _vehicleCameraList: _vehicle.cameraList
Don Gagne's avatar
Don Gagne committed
32 33 34 35 36

    readonly property int _gridTypeManual:          0
    readonly property int _gridTypeCustomCamera:    1
    readonly property int _gridTypeCamera:          2

37 38 39
    Component.onCompleted: {
        for (var i=0; i<_vehicle.cameraList.length; i++) {
            _cameraList.push(_vehicle.cameraList[i].name)
Don Gagne's avatar
Don Gagne committed
40
        }
41 42 43 44 45 46 47 48 49 50 51
        gridTypeCombo.model = _cameraList
        if (missionItem.manualGrid) {
            gridTypeCombo.currentIndex = _gridTypeManual
        } else {
            var index = gridTypeCombo.find(missionItem.camera)
            if (index == -1) {
                console.log("Couldn't find camera", missionItem.camera)
                gridTypeCombo.currentIndex = _gridTypeManual
            } else {
                gridTypeCombo.currentIndex = index
            }
Don Gagne's avatar
Don Gagne committed
52 53
        }
    }
Don Gagne's avatar
Don Gagne committed
54 55

    function recalcFromCameraValues() {
56 57 58 59 60
        var focalLength     = missionItem.cameraFocalLength.rawValue
        var sensorWidth     = missionItem.cameraSensorWidth.rawValue
        var sensorHeight    = missionItem.cameraSensorHeight.rawValue
        var imageWidth      = missionItem.cameraResolutionWidth.rawValue
        var imageHeight     = missionItem.cameraResolutionHeight.rawValue
Don Gagne's avatar
Don Gagne committed
61

62 63 64 65
        var altitude        = missionItem.gridAltitude.rawValue
        var groundResolution= missionItem.groundResolution.rawValue
        var frontalOverlap  = missionItem.frontalOverlap.rawValue
        var sideOverlap     = missionItem.sideOverlap.rawValue
Don Gagne's avatar
Don Gagne committed
66 67

        if (focalLength <= 0 || sensorWidth <= 0 || sensorHeight <= 0 || imageWidth <= 0 || imageHeight <= 0 || groundResolution <= 0) {
Don Gagne's avatar
Don Gagne committed
68 69 70
            return
        }

Don Gagne's avatar
Don Gagne committed
71 72
        var imageSizeSideGround     //size in side (non flying) direction of the image on the ground
        var imageSizeFrontGround    //size in front (flying) direction of the image on the ground
Don Gagne's avatar
Don Gagne committed
73 74
        var gridSpacing
        var cameraTriggerDistance
75

Don Gagne's avatar
Don Gagne committed
76
        if (missionItem.fixedValueIsAltitude) {
77
            groundResolution = (altitude * sensorWidth * 100) / (imageWidth * focalLength)
Don Gagne's avatar
Don Gagne committed
78 79 80
        } else {
            altitude = (imageWidth * groundResolution * focalLength) / (sensorWidth * 100)
        }
81

Don Gagne's avatar
Don Gagne committed
82
        if (cameraOrientationLandscape.checked) {
83
            imageSizeSideGround  = (imageWidth  * groundResolution) / 100
Don Gagne's avatar
Don Gagne committed
84
            imageSizeFrontGround = (imageHeight * groundResolution) / 100
Don Gagne's avatar
Don Gagne committed
85
        } else {
86 87
            imageSizeSideGround  = (imageHeight * groundResolution) / 100
            imageSizeFrontGround = (imageWidth  * groundResolution) / 100
Don Gagne's avatar
Don Gagne committed
88 89
        }

90 91 92
        gridSpacing = imageSizeSideGround * ( (100-sideOverlap) / 100 )
        cameraTriggerDistance = imageSizeFrontGround * ( (100-frontalOverlap) / 100 )

Don Gagne's avatar
Don Gagne committed
93 94 95 96 97
        if (missionItem.fixedValueIsAltitude) {
            missionItem.groundResolution.rawValue = groundResolution
        } else {
            missionItem.gridAltitude.rawValue = altitude
        }
Don Gagne's avatar
Don Gagne committed
98 99 100 101
        missionItem.gridSpacing.rawValue = gridSpacing
        missionItem.cameraTriggerDistance.rawValue = cameraTriggerDistance
    }

Don Gagne's avatar
Don Gagne committed
102
    /*
103
    function recalcFromMissionValues() {
Don Gagne's avatar
Don Gagne committed
104 105 106 107 108
        var focalLength = missionItem.cameraFocalLength.rawValue
        var sensorWidth = missionItem.cameraSensorWidth.rawValue
        var sensorHeight = missionItem.cameraSensorHeight.rawValue
        var imageWidth = missionItem.cameraResolutionWidth.rawValue
        var imageHeight = missionItem.cameraResolutionHeight.rawValue
109 110 111 112 113 114

        var altitude = missionItem.gridAltitude.rawValue
        var gridSpacing = missionItem.gridSpacing.rawValue
        var cameraTriggerDistance = missionItem.cameraTriggerDistance.rawValue

        if (focalLength <= 0.0 || sensorWidth <= 0.0 || sensorHeight <= 0.0 || imageWidth < 0 || imageHeight < 0 || altitude < 0.0 || gridSpacing < 0.0 || cameraTriggerDistance < 0.0) {
Don Gagne's avatar
Don Gagne committed
115 116 117
            missionItem.groundResolution.rawValue = 0
            missionItem.sideOverlap = 0
            missionItem.frontalOverlap = 0
118 119 120
            return
        }

Don Gagne's avatar
Don Gagne committed
121 122 123
        var groundResolution
        var imageSizeSideGround     //size in side (non flying) direction of the image on the ground
        var imageSizeFrontGround    //size in front (flying) direction of the image on the ground
124

Don Gagne's avatar
Don Gagne committed
125
        groundResolution = (altitude * sensorWidth * 100) / (imageWidth * focalLength)
126 127 128 129 130 131 132 133 134 135 136 137

        if (cameraOrientationLandscape.checked) {
            imageSizeSideGround = (imageWidth * gsd) / 100
            imageSizeFrontGround = (imageHeight * gsd) / 100
        } else {
            imageSizeSideGround = (imageHeight * gsd) / 100
            imageSizeFrontGround = (imageWidth * gsd) / 100
        }

        var sideOverlap = (imageSizeSideGround == 0 ? 0 : 100 - (gridSpacing*100 / imageSizeSideGround))
        var frontOverlap = (imageSizeFrontGround == 0 ? 0 : 100 - (cameraTriggerDistance*100 / imageSizeFrontGround))

Don Gagne's avatar
Don Gagne committed
138 139 140
        missionItem.groundResolution.rawValue = groundResolution
        missionItem.sideOverlap.rawValue = sideOverlap
        missionItem.frontalOverlap.rawValue = frontOverlap
141
    }
Don Gagne's avatar
Don Gagne committed
142
    */
143

144
    function polygonCaptureStarted() {
Don Gagne's avatar
Don Gagne committed
145
        missionItem.clearPolygon()
146
    }
Don Gagne's avatar
Don Gagne committed
147

148 149 150
    function polygonCaptureFinished(coordinates) {
        for (var i=0; i<coordinates.length; i++) {
            missionItem.addPolygonCoordinate(coordinates[i])
Don Gagne's avatar
Don Gagne committed
151
        }
152
    }
Don Gagne's avatar
Don Gagne committed
153

154 155
    function polygonAdjustVertex(vertexIndex, vertexCoordinate) {
        missionItem.adjustPolygonCoordinate(vertexIndex, vertexCoordinate)
Don Gagne's avatar
Don Gagne committed
156 157
    }

158 159 160
    function polygonAdjustStarted() { }
    function polygonAdjustFinished() { }

Don Gagne's avatar
Don Gagne committed
161 162 163 164 165 166 167 168 169 170
    property bool _noCameraValueRecalc: false   ///< Prevents uneeded recalcs

    Connections {
        target: missionItem

        onCameraValueChanged: {
            if (gridTypeCombo.currentIndex >= _gridTypeCustomCamera && !_noCameraValueRecalc) {
                recalcFromCameraValues()
            }
        }
171 172 173 174 175 176

        onIsCurrentItemChanged: {
            if (!missionItem.isCurrentItem) {
                polygonEditor.cancelPolygonEdit()
            }
        }
Don Gagne's avatar
Don Gagne committed
177 178 179 180 181 182 183 184 185 186 187 188
    }

    Connections {
        target: missionItem.gridAltitude

        onValueChanged: {
            if (gridTypeCombo.currentIndex >= _gridTypeCustomCamera && missionItem.fixedValueIsAltitude && !_noCameraValueRecalc) {
                recalcFromCameraValues()
            }
        }
    }

189 190
    QGCPalette { id: qgcPal; colorGroupEnabled: true }

Don Gagne's avatar
Don Gagne committed
191
    ExclusiveGroup {
Don Gagne's avatar
Don Gagne committed
192 193 194 195 196 197
        id: cameraOrientationGroup

        onCurrentChanged: {
            if (gridTypeCombo.currentIndex >= _gridTypeCustomCamera) {
                recalcFromCameraValues()
            }
198
        }
Don Gagne's avatar
Don Gagne committed
199 200
    }

Don Gagne's avatar
Don Gagne committed
201 202
    ExclusiveGroup { id: fixedValueGroup }

203 204 205 206 207
    Column {
        id:                 editorColumn
        anchors.margins:    _margin
        anchors.top:        parent.top
        anchors.left:       parent.left
208
        anchors.right:      parent.right
209 210
        spacing:            _margin

Don Gagne's avatar
Don Gagne committed
211 212 213 214
        QGCComboBox {
            id:             gridTypeCombo
            anchors.left:   parent.left
            anchors.right:  parent.right
215
            model:          _cameraList
Don Gagne's avatar
Don Gagne committed
216 217 218 219 220
            currentIndex:   -1

            onActivated: {
                if (index == _gridTypeManual) {
                    missionItem.manualGrid = true
221 222 223
                } else if (index == _gridTypeCustomCamera) {
                    missionItem.manualGrid = false
                    missionItem.camera = gridTypeCombo.textAt(index)
Don Gagne's avatar
Don Gagne committed
224 225 226 227
                } else {
                    missionItem.manualGrid = false
                    missionItem.camera = gridTypeCombo.textAt(index)
                    _noCameraValueRecalc = true
228 229 230 231 232 233
                    var listIndex = index - _gridTypeCamera
                    missionItem.cameraSensorWidth.rawValue      = _vehicleCameraList[listIndex].sensorWidth
                    missionItem.cameraSensorHeight.rawValue     = _vehicleCameraList[listIndex].sensorHeight
                    missionItem.cameraResolutionWidth.rawValue  = _vehicleCameraList[listIndex].imageWidth
                    missionItem.cameraResolutionHeight.rawValue = _vehicleCameraList[listIndex].imageHeight
                    missionItem.cameraFocalLength.rawValue      = _vehicleCameraList[listIndex].focalLength
Don Gagne's avatar
Don Gagne committed
234 235
                    _noCameraValueRecalc = false
                    recalcFromCameraValues()
236 237 238 239
                }
            }
        }

240
        QGCLabel { text: qsTr("Camera"); visible: gridTypeCombo.currentIndex !== _gridTypeManual}
241 242 243 244 245 246 247 248 249

        Rectangle {
            anchors.left:   parent.left
            anchors.right:  parent.right
            height:         1
            color:          qgcPal.text
            visible:        gridTypeCombo.currentIndex !== _gridTypeManual
        }

Don Gagne's avatar
Don Gagne committed
250 251
        // Camera based grid ui
        Column {
Don Gagne's avatar
Don Gagne committed
252
            anchors.left:   parent.left
Don Gagne's avatar
Don Gagne committed
253 254 255
            anchors.right:  parent.right
            spacing:        _margin
            visible:        gridTypeCombo.currentIndex != _gridTypeManual
Don Gagne's avatar
Don Gagne committed
256

Don Gagne's avatar
Don Gagne committed
257 258
            Row {
                spacing: _margin
259
                anchors.horizontalCenter: parent.horizontalCenter
260

Don Gagne's avatar
Don Gagne committed
261 262 263 264 265 266 267
                QGCRadioButton {
                    id:             cameraOrientationLandscape
                    width:          _editFieldWidth
                    text:           "Landscape"
                    checked:        true
                    exclusiveGroup: cameraOrientationGroup
                }
268

Don Gagne's avatar
Don Gagne committed
269 270 271 272 273
                QGCRadioButton {
                    id:             cameraOrientationPortrait
                    text:           "Portrait"
                    exclusiveGroup: cameraOrientationGroup
                }
274 275
            }

Don Gagne's avatar
Don Gagne committed
276
            Column {
277
                id:             custCameraCol
Don Gagne's avatar
Don Gagne committed
278 279 280
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        _margin
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
                visible:        gridTypeCombo.currentIndex === _gridTypeCustomCamera

                RowLayout {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    spacing:        _margin
                    Item { Layout.fillWidth: true }
                    QGCLabel {
                        Layout.preferredWidth:  _root._fieldWidth
                        text:                   qsTr("Width")
                    }
                    QGCLabel {
                        Layout.preferredWidth:  _root._fieldWidth
                        text:                   qsTr("Height")
                    }
                }
Don Gagne's avatar
Don Gagne committed
297

298 299 300 301 302
                RowLayout {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    spacing:        _margin
                    QGCLabel { text: qsTr("Sensor:"); Layout.fillWidth: true }
Don Gagne's avatar
Don Gagne committed
303
                    FactTextField {
304
                        Layout.preferredWidth:  _root._fieldWidth
Don Gagne's avatar
Don Gagne committed
305 306 307
                        fact:                   missionItem.cameraSensorWidth
                    }
                    FactTextField {
308
                        Layout.preferredWidth:  _root._fieldWidth
Don Gagne's avatar
Don Gagne committed
309 310
                        fact:                   missionItem.cameraSensorHeight
                    }
311
                }
Don Gagne's avatar
Don Gagne committed
312

313 314 315 316 317
                RowLayout {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    spacing:        _margin
                    QGCLabel { text: qsTr("Image:"); Layout.fillWidth: true }
Don Gagne's avatar
Don Gagne committed
318
                    FactTextField {
319
                        Layout.preferredWidth:  _root._fieldWidth
Don Gagne's avatar
Don Gagne committed
320 321 322
                        fact:                   missionItem.cameraResolutionWidth
                    }
                    FactTextField {
323
                        Layout.preferredWidth:  _root._fieldWidth
Don Gagne's avatar
Don Gagne committed
324 325 326 327
                        fact:                   missionItem.cameraResolutionHeight
                    }
                }

328 329 330 331 332 333 334 335 336 337 338 339
                RowLayout {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    spacing:        _margin
                    QGCLabel {
                        text:                   missionItem.cameraFocalLength.name + ":"
                        Layout.fillWidth:       true
                    }
                    FactTextField {
                        Layout.preferredWidth:  _root._fieldWidth
                        fact:                   missionItem.cameraFocalLength
                    }
Don Gagne's avatar
Don Gagne committed
340 341
                }

342
            } // Column - custom camera
Don Gagne's avatar
Don Gagne committed
343

344 345 346
            RowLayout {
                anchors.left:   parent.left
                anchors.right:  parent.right
Don Gagne's avatar
Don Gagne committed
347
                spacing:        _margin
348 349 350 351
                Item { Layout.fillWidth: true }
                QGCLabel {
                    Layout.preferredWidth:  _root._fieldWidth
                    text:                   qsTr("Frontal")
Don Gagne's avatar
Don Gagne committed
352 353
                }
                QGCLabel {
354 355
                    Layout.preferredWidth:  _root._fieldWidth
                    text:                   qsTr("Side")
Don Gagne's avatar
Don Gagne committed
356
                }
357
            }
Don Gagne's avatar
Don Gagne committed
358

359 360 361 362 363
            RowLayout {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        _margin
                QGCLabel { text: qsTr("Overlap:"); Layout.fillWidth: true }
Don Gagne's avatar
Don Gagne committed
364
                FactTextField {
365 366
                    Layout.preferredWidth:  _root._fieldWidth
                    fact:                   missionItem.frontalOverlap
Don Gagne's avatar
Don Gagne committed
367 368
                }
                FactTextField {
369 370
                    Layout.preferredWidth:  _root._fieldWidth
                    fact:                   missionItem.sideOverlap
Don Gagne's avatar
Don Gagne committed
371
                }
Don Gagne's avatar
Don Gagne committed
372 373
            }

374
            QGCLabel { text: qsTr("Grid") }
Don Gagne's avatar
Don Gagne committed
375 376 377 378 379 380

            Rectangle {
                anchors.left:   parent.left
                anchors.right:  parent.right
                height:         1
                color:          qgcPal.text
Don Gagne's avatar
Don Gagne committed
381 382
            }

383
            RowLayout {
Don Gagne's avatar
Don Gagne committed
384 385
                anchors.left:   parent.left
                anchors.right:  parent.right
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
                spacing:        _margin
                QGCLabel {
                    text:                   missionItem.gridAngle.name + ":"
                    Layout.fillWidth:       true
                    anchors.verticalCenter: parent.verticalCenter
                }
                FactTextField {
                    fact:                   missionItem.gridAngle
                    anchors.verticalCenter: parent.verticalCenter
                    Layout.preferredWidth:  _root._fieldWidth
                }
            }

            RowLayout {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        _margin
                QGCLabel {
                    text:                   missionItem.turnaroundDist.name + ":"
                    Layout.fillWidth:       true
                    anchors.verticalCenter: parent.verticalCenter
                }
                FactTextField {
                    fact:                   missionItem.turnaroundDist
                    anchors.verticalCenter: parent.verticalCenter
                    Layout.preferredWidth:  _root._fieldWidth
                }
Don Gagne's avatar
Don Gagne committed
413 414
            }

Don Gagne's avatar
Don Gagne committed
415 416 417 418 419 420
            QGCLabel {
                anchors.left:   parent.left
                anchors.right:  parent.right
                wrapMode:       Text.WordWrap
                font.pointSize: ScreenTools.smallFontPointSize
                text:           qsTr("Which value would you like to keep constant as you adjust other settings:")
Don Gagne's avatar
Don Gagne committed
421 422
            }

Don Gagne's avatar
Don Gagne committed
423 424 425 426 427 428
            RowLayout {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        _margin

                QGCRadioButton {
429 430 431 432 433 434 435
                    id:                     fixedAltitudeRadio
                    text:                   qsTr("Altitude:")
                    checked:                missionItem.fixedValueIsAltitude
                    exclusiveGroup:         fixedValueGroup
                    onClicked:              missionItem.fixedValueIsAltitude = true
                    Layout.fillWidth:       true
                    anchors.verticalCenter: parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
436
                }
437

Don Gagne's avatar
Don Gagne committed
438
                FactTextField {
439 440 441 442
                    fact:                   missionItem.gridAltitude
                    enabled:                fixedAltitudeRadio.checked
                    Layout.preferredWidth:  _root._fieldWidth
                    anchors.verticalCenter: parent.verticalCenter
443
                }
Don Gagne's avatar
Don Gagne committed
444
            }
Don Gagne's avatar
Don Gagne committed
445

Don Gagne's avatar
Don Gagne committed
446 447 448 449 450 451
            RowLayout {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        _margin

                QGCRadioButton {
452 453 454 455 456 457 458
                    id:                     fixedGroundResolutionRadio
                    text:                   qsTr("Ground res:")
                    checked:                !missionItem.fixedValueIsAltitude
                    exclusiveGroup:         fixedValueGroup
                    onClicked:              missionItem.fixedValueIsAltitude = false
                    Layout.fillWidth:       true
                    anchors.verticalCenter: parent.verticalCenter
459 460
                }

Don Gagne's avatar
Don Gagne committed
461
                FactTextField {
462 463 464 465
                    fact:                   missionItem.groundResolution
                    enabled:                fixedGroundResolutionRadio.checked
                    Layout.preferredWidth:  _root._fieldWidth
                    anchors.verticalCenter: parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
466 467 468 469 470
                }
            }
        }

        // Manual grid ui
471
        Column {
Don Gagne's avatar
Don Gagne committed
472 473 474 475
            anchors.left:   parent.left
            anchors.right:  parent.right
            spacing:        _margin
            visible:        gridTypeCombo.currentIndex == _gridTypeManual
476

477
            QGCLabel { text: qsTr("Grid") }
478

Don Gagne's avatar
Don Gagne committed
479 480 481 482 483
            Rectangle {
                anchors.left:   parent.left
                anchors.right:  parent.right
                height:         1
                color:          qgcPal.text
Don Gagne's avatar
Don Gagne committed
484 485
            }

Don Gagne's avatar
Don Gagne committed
486 487 488
            FactTextFieldGrid {
                anchors.left:   parent.left
                anchors.right:  parent.right
489
                columnSpacing:  _margin * 10
Don Gagne's avatar
Don Gagne committed
490 491 492
                rowSpacing:     _margin
                factList:       [ missionItem.gridAngle, missionItem.gridSpacing, missionItem.gridAltitude, missionItem.turnaroundDist ]
            }
Don Gagne's avatar
Don Gagne committed
493

Don Gagne's avatar
Don Gagne committed
494 495 496 497 498 499
            QGCCheckBox {
                anchors.left:   parent.left
                text:           qsTr("Relative altitude")
                checked:        missionItem.gridAltitudeRelative
                onClicked:      missionItem.gridAltitudeRelative = checked
            }
500

501
            QGCLabel { text: qsTr("Camera") }
502

Don Gagne's avatar
Don Gagne committed
503 504 505 506 507
            Rectangle {
                anchors.left:   parent.left
                anchors.right:  parent.right
                height:         1
                color:          qgcPal.text
Don Gagne's avatar
Don Gagne committed
508 509
            }

Don Gagne's avatar
Don Gagne committed
510 511 512 513 514 515 516 517 518 519 520 521
            RowLayout {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        _margin

                QGCCheckBox {
                    id:                 cameraTrigger
                    anchors.baseline:   cameraTriggerDistanceField.baseline
                    text:               qsTr("Trigger Distance:")
                    checked:            missionItem.cameraTrigger
                    onClicked:          missionItem.cameraTrigger = checked
                }
Don Gagne's avatar
Don Gagne committed
522

Don Gagne's avatar
Don Gagne committed
523 524 525 526 527 528
                FactTextField {
                    id:                 cameraTriggerDistanceField
                    Layout.fillWidth:   true
                    fact:               missionItem.cameraTriggerDistance
                    enabled:            missionItem.cameraTrigger
                }
Don Gagne's avatar
Don Gagne committed
529 530 531
            }
        }

532
        QGCLabel { text: qsTr("Polygon") }
Don Gagne's avatar
Don Gagne committed
533

534 535 536 537 538 539 540 541 542
        Rectangle {
            anchors.left:   parent.left
            anchors.right:  parent.right
            height:         1
            color:          qgcPal.text
        }

        Row {
            spacing: ScreenTools.defaultFontPixelWidth
543
            anchors.horizontalCenter: parent.horizontalCenter
544 545

            QGCButton {
546
                width:      _root.width * 0.45
547 548 549
                text:       polygonEditor.drawingPolygon ? qsTr("Finish Draw") : qsTr("Draw")
                visible:    !polygonEditor .adjustingPolygon
                enabled:    ((polygonEditor.drawingPolygon && polygonEditor.polygonReady) || !polygonEditor.drawingPolygon)
550 551

                onClicked: {
552 553
                    if (polygonEditor.drawingPolygon) {
                        polygonEditor.finishCapturePolygon()
554
                    } else {
555
                        polygonEditor.startCapturePolygon()
556
                    }
557 558 559
                }
            }

560
            QGCButton {
561
                width:      _root.width * 0.4
562 563
                text:       polygonEditor.adjustingPolygon ? qsTr("Finish Adjust") : qsTr("Adjust")
                visible:    missionItem.polygonPath.length > 0 && !polygonEditor.drawingPolygon
564

565
                onClicked: {
566 567
                    if (polygonEditor.adjustingPolygon) {
                        polygonEditor.finishAdjustPolygon()
568
                    } else {
569
                        polygonEditor.startAdjustPolygon(missionItem.polygonPath)
570
                    }
571 572 573
                }
            }
        }
574

575
        QGCLabel { text: qsTr("Statistics") }
576 577 578 579 580 581 582 583 584

        Rectangle {
            anchors.left:   parent.left
            anchors.right:  parent.right
            height:         1
            color:          qgcPal.text
        }

        Grid {
585 586
            columns:        2
            columnSpacing:  ScreenTools.defaultFontPixelWidth
587 588 589 590

            QGCLabel { text: qsTr("Survey area:") }
            QGCLabel { text: QGroundControl.squareMetersToAppSettingsAreaUnits(missionItem.coveredArea).toFixed(2) + " " + QGroundControl.appSettingsAreaUnitsString }

591
            QGCLabel { text: qsTr("Photo count:") }
592
            QGCLabel { text: missionItem.cameraShots }
593

594 595 596 597 598 599 600 601 602 603
            QGCLabel { text: qsTr("Photo interval:") }
            QGCLabel {
                text: {
                    var timeVal = missionItem.timeBetweenShots
                    if(!isFinite(timeVal) || missionItem.cameraShots === 0) {
                        return qsTr("N/A")
                    }
                    return timeVal.toFixed(1) + " " + qsTr("secs")
                }
            }
604
        }
605
    }
606 607 608 609 610 611

    PolygonEditor {
        id:             polygonEditor
        map:            editorMap
        callbackObject: parent
    }
612
}