SurveyItemEditor.qml 25.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
    property real   _margin:        ScreenTools.defaultFontPixelWidth * 0.25
Don Gagne's avatar
Don Gagne committed
27
    property int    _cameraIndex:   1
28
    property real   _fieldWidth:    ScreenTools.defaultFontPixelWidth * 10.5
Don Gagne's avatar
Don Gagne committed
29 30 31 32 33

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

34
    ListModel {
Don Gagne's avatar
Don Gagne committed
35 36 37
        id: cameraModelList

        Component.onCompleted: {
38 39 40 41 42
            cameraModelList.setProperty(_gridTypeCustomCamera, "sensorWidth",   missionItem.cameraSensorWidth.rawValue)
            cameraModelList.setProperty(_gridTypeCustomCamera, "sensorHeight",  missionItem.cameraSensorHeight.rawValue)
            cameraModelList.setProperty(_gridTypeCustomCamera, "imageWidth",    missionItem.cameraResolutionWidth.rawValue)
            cameraModelList.setProperty(_gridTypeCustomCamera, "imageHeight",   missionItem.cameraResolutionHeight.rawValue)
            cameraModelList.setProperty(_gridTypeCustomCamera, "focalLength",   missionItem.cameraFocalLength.rawValue)
Don Gagne's avatar
Don Gagne committed
43 44 45 46 47 48 49 50
        }

        ListElement {
            text:           qsTr("Manual Grid (no camera specs)")
        }
        ListElement {
            text:           qsTr("Custom Camera Grid")
        }
51 52 53 54 55 56 57 58
        ListElement {
            text:           qsTr("Typhoon H CGO3+")
            sensorWidth:    6.264
            sensorHeight:   4.698
            imageWidth:     4000
            imageHeight:    3000
            focalLength:    14
        }
Don Gagne's avatar
Don Gagne committed
59 60 61 62 63 64 65 66 67 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 94 95 96 97 98 99
        ListElement {
            text:           qsTr("Sony ILCE-QX1") //http://www.sony.co.uk/electronics/interchangeable-lens-cameras/ilce-qx1-body-kit/specifications
            sensorWidth:    23.2                  //http://www.sony.com/electronics/camera-lenses/sel16f28/specifications
            sensorHeight:   15.4
            imageWidth:     5456
            imageHeight:    3632
            focalLength:    16
        }
        ListElement {
            text:           qsTr("Canon S100 PowerShot")
            sensorWidth:    7.6
            sensorHeight:   5.7
            imageWidth:     4000
            imageHeight:    3000
            focalLength:    5.2
        }
        ListElement {
            text:           qsTr("Canon SX260 HS PowerShot")
            sensorWidth:    6.17
            sensorHeight:   4.55
            imageWidth:     4000
            imageHeight:    3000
            focalLength:    4.5
        }
        ListElement {
            text:           qsTr("Canon EOS-M 22mm")
            sensorWidth:    22.3
            sensorHeight:   14.9
            imageWidth:     5184
            imageHeight:    3456
            focalLength:    22
        }
        ListElement {
            text:           qsTr("Sony a6000 16mm") //http://www.sony.co.uk/electronics/interchangeable-lens-cameras/ilce-6000-body-kit#product_details_default
            sensorWidth:    23.5
            sensorHeight:   15.6
            imageWidth:     6000
            imageHeight:    4000
            focalLength:    16
        }
    }
Don Gagne's avatar
Don Gagne committed
100 101

    function recalcFromCameraValues() {
102 103 104 105 106
        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
107

108 109 110 111
        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
112 113

        if (focalLength <= 0 || sensorWidth <= 0 || sensorHeight <= 0 || imageWidth <= 0 || imageHeight <= 0 || groundResolution <= 0) {
Don Gagne's avatar
Don Gagne committed
114 115 116
            return
        }

Don Gagne's avatar
Don Gagne committed
117 118
        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
119 120
        var gridSpacing
        var cameraTriggerDistance
121

Don Gagne's avatar
Don Gagne committed
122
        if (missionItem.fixedValueIsAltitude) {
123
            groundResolution = (altitude * sensorWidth * 100) / (imageWidth * focalLength)
Don Gagne's avatar
Don Gagne committed
124 125 126
        } else {
            altitude = (imageWidth * groundResolution * focalLength) / (sensorWidth * 100)
        }
127

Don Gagne's avatar
Don Gagne committed
128
        if (cameraOrientationLandscape.checked) {
129
            imageSizeSideGround  = (imageWidth  * groundResolution) / 100
Don Gagne's avatar
Don Gagne committed
130
            imageSizeFrontGround = (imageHeight * groundResolution) / 100
Don Gagne's avatar
Don Gagne committed
131
        } else {
132 133
            imageSizeSideGround  = (imageHeight * groundResolution) / 100
            imageSizeFrontGround = (imageWidth  * groundResolution) / 100
Don Gagne's avatar
Don Gagne committed
134 135
        }

136 137 138
        gridSpacing = imageSizeSideGround * ( (100-sideOverlap) / 100 )
        cameraTriggerDistance = imageSizeFrontGround * ( (100-frontalOverlap) / 100 )

Don Gagne's avatar
Don Gagne committed
139 140 141 142 143
        if (missionItem.fixedValueIsAltitude) {
            missionItem.groundResolution.rawValue = groundResolution
        } else {
            missionItem.gridAltitude.rawValue = altitude
        }
Don Gagne's avatar
Don Gagne committed
144 145 146 147
        missionItem.gridSpacing.rawValue = gridSpacing
        missionItem.cameraTriggerDistance.rawValue = cameraTriggerDistance
    }

Don Gagne's avatar
Don Gagne committed
148
    /*
149
    function recalcFromMissionValues() {
Don Gagne's avatar
Don Gagne committed
150 151 152 153 154
        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
155 156 157 158 159 160

        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
161 162 163
            missionItem.groundResolution.rawValue = 0
            missionItem.sideOverlap = 0
            missionItem.frontalOverlap = 0
164 165 166
            return
        }

Don Gagne's avatar
Don Gagne committed
167 168 169
        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
170

Don Gagne's avatar
Don Gagne committed
171
        groundResolution = (altitude * sensorWidth * 100) / (imageWidth * focalLength)
172 173 174 175 176 177 178 179 180 181 182 183

        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
184 185 186
        missionItem.groundResolution.rawValue = groundResolution
        missionItem.sideOverlap.rawValue = sideOverlap
        missionItem.frontalOverlap.rawValue = frontOverlap
187
    }
Don Gagne's avatar
Don Gagne committed
188
    */
189

190
    function polygonCaptureStarted() {
Don Gagne's avatar
Don Gagne committed
191
        missionItem.clearPolygon()
192
    }
Don Gagne's avatar
Don Gagne committed
193

194 195 196
    function polygonCaptureFinished(coordinates) {
        for (var i=0; i<coordinates.length; i++) {
            missionItem.addPolygonCoordinate(coordinates[i])
Don Gagne's avatar
Don Gagne committed
197
        }
198
    }
Don Gagne's avatar
Don Gagne committed
199

200 201
    function polygonAdjustVertex(vertexIndex, vertexCoordinate) {
        missionItem.adjustPolygonCoordinate(vertexIndex, vertexCoordinate)
Don Gagne's avatar
Don Gagne committed
202 203
    }

204 205 206
    function polygonAdjustStarted() { }
    function polygonAdjustFinished() { }

Don Gagne's avatar
Don Gagne committed
207 208 209 210 211 212 213 214 215 216
    property bool _noCameraValueRecalc: false   ///< Prevents uneeded recalcs

    Connections {
        target: missionItem

        onCameraValueChanged: {
            if (gridTypeCombo.currentIndex >= _gridTypeCustomCamera && !_noCameraValueRecalc) {
                recalcFromCameraValues()
            }
        }
217 218 219 220 221 222

        onIsCurrentItemChanged: {
            if (!missionItem.isCurrentItem) {
                polygonEditor.cancelPolygonEdit()
            }
        }
Don Gagne's avatar
Don Gagne committed
223 224 225 226 227 228 229 230 231 232 233 234
    }

    Connections {
        target: missionItem.gridAltitude

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

235 236
    QGCPalette { id: qgcPal; colorGroupEnabled: true }

Don Gagne's avatar
Don Gagne committed
237
    ExclusiveGroup {
Don Gagne's avatar
Don Gagne committed
238 239 240 241 242 243
        id: cameraOrientationGroup

        onCurrentChanged: {
            if (gridTypeCombo.currentIndex >= _gridTypeCustomCamera) {
                recalcFromCameraValues()
            }
244
        }
Don Gagne's avatar
Don Gagne committed
245 246
    }

Don Gagne's avatar
Don Gagne committed
247 248
    ExclusiveGroup { id: fixedValueGroup }

249 250 251 252 253
    Column {
        id:                 editorColumn
        anchors.margins:    _margin
        anchors.top:        parent.top
        anchors.left:       parent.left
254
        anchors.right:      parent.right
255 256
        spacing:            _margin

Don Gagne's avatar
Don Gagne committed
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
        QGCComboBox {
            id:             gridTypeCombo
            anchors.left:   parent.left
            anchors.right:  parent.right
            model:          cameraModelList
            currentIndex:   -1

            Component.onCompleted: {
                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
                    }
275
                }
Don Gagne's avatar
Don Gagne committed
276
            }
277

Don Gagne's avatar
Don Gagne committed
278 279 280 281 282 283 284
            onActivated: {
                if (index == _gridTypeManual) {
                    missionItem.manualGrid = true
                } else {
                    missionItem.manualGrid = false
                    missionItem.camera = gridTypeCombo.textAt(index)
                    _noCameraValueRecalc = true
285 286 287
                    missionItem.cameraSensorWidth.rawValue      = cameraModelList.get(index).sensorWidth
                    missionItem.cameraSensorHeight.rawValue     = cameraModelList.get(index).sensorHeight
                    missionItem.cameraResolutionWidth.rawValue  = cameraModelList.get(index).imageWidth
Don Gagne's avatar
Don Gagne committed
288
                    missionItem.cameraResolutionHeight.rawValue = cameraModelList.get(index).imageHeight
289
                    missionItem.cameraFocalLength.rawValue      = cameraModelList.get(index).focalLength
Don Gagne's avatar
Don Gagne committed
290 291
                    _noCameraValueRecalc = false
                    recalcFromCameraValues()
292 293 294 295
                }
            }
        }

296
        QGCLabel { text: qsTr("Camera"); visible: gridTypeCombo.currentIndex !== _gridTypeManual}
297 298 299 300 301 302 303 304 305

        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
306 307
        // Camera based grid ui
        Column {
Don Gagne's avatar
Don Gagne committed
308
            anchors.left:   parent.left
Don Gagne's avatar
Don Gagne committed
309 310 311
            anchors.right:  parent.right
            spacing:        _margin
            visible:        gridTypeCombo.currentIndex != _gridTypeManual
Don Gagne's avatar
Don Gagne committed
312

Don Gagne's avatar
Don Gagne committed
313 314
            Row {
                spacing: _margin
315
                anchors.horizontalCenter: parent.horizontalCenter
316

Don Gagne's avatar
Don Gagne committed
317 318 319 320 321 322 323
                QGCRadioButton {
                    id:             cameraOrientationLandscape
                    width:          _editFieldWidth
                    text:           "Landscape"
                    checked:        true
                    exclusiveGroup: cameraOrientationGroup
                }
324

Don Gagne's avatar
Don Gagne committed
325 326 327 328 329
                QGCRadioButton {
                    id:             cameraOrientationPortrait
                    text:           "Portrait"
                    exclusiveGroup: cameraOrientationGroup
                }
330 331
            }

Don Gagne's avatar
Don Gagne committed
332
            Column {
333
                id:             custCameraCol
Don Gagne's avatar
Don Gagne committed
334 335 336
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        _margin
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352
                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
353

354 355 356 357 358
                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
359
                    FactTextField {
360
                        Layout.preferredWidth:  _root._fieldWidth
Don Gagne's avatar
Don Gagne committed
361 362 363
                        fact:                   missionItem.cameraSensorWidth
                    }
                    FactTextField {
364
                        Layout.preferredWidth:  _root._fieldWidth
Don Gagne's avatar
Don Gagne committed
365 366
                        fact:                   missionItem.cameraSensorHeight
                    }
367
                }
Don Gagne's avatar
Don Gagne committed
368

369 370 371 372 373
                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
374
                    FactTextField {
375
                        Layout.preferredWidth:  _root._fieldWidth
Don Gagne's avatar
Don Gagne committed
376 377 378
                        fact:                   missionItem.cameraResolutionWidth
                    }
                    FactTextField {
379
                        Layout.preferredWidth:  _root._fieldWidth
Don Gagne's avatar
Don Gagne committed
380 381 382 383
                        fact:                   missionItem.cameraResolutionHeight
                    }
                }

384 385 386 387 388 389 390 391 392 393 394 395
                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
396 397
                }

398
            } // Column - custom camera
Don Gagne's avatar
Don Gagne committed
399

400 401 402
            RowLayout {
                anchors.left:   parent.left
                anchors.right:  parent.right
Don Gagne's avatar
Don Gagne committed
403
                spacing:        _margin
404 405 406 407
                Item { Layout.fillWidth: true }
                QGCLabel {
                    Layout.preferredWidth:  _root._fieldWidth
                    text:                   qsTr("Frontal")
Don Gagne's avatar
Don Gagne committed
408 409
                }
                QGCLabel {
410 411
                    Layout.preferredWidth:  _root._fieldWidth
                    text:                   qsTr("Side")
Don Gagne's avatar
Don Gagne committed
412
                }
413
            }
Don Gagne's avatar
Don Gagne committed
414

415 416 417 418 419
            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
420
                FactTextField {
421 422
                    Layout.preferredWidth:  _root._fieldWidth
                    fact:                   missionItem.frontalOverlap
Don Gagne's avatar
Don Gagne committed
423 424
                }
                FactTextField {
425 426
                    Layout.preferredWidth:  _root._fieldWidth
                    fact:                   missionItem.sideOverlap
Don Gagne's avatar
Don Gagne committed
427
                }
Don Gagne's avatar
Don Gagne committed
428 429
            }

430
            QGCLabel { text: qsTr("Grid") }
Don Gagne's avatar
Don Gagne committed
431 432 433 434 435 436

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

439
            RowLayout {
Don Gagne's avatar
Don Gagne committed
440 441
                anchors.left:   parent.left
                anchors.right:  parent.right
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468
                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
469 470
            }

Don Gagne's avatar
Don Gagne committed
471 472 473 474 475 476
            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
477 478
            }

Don Gagne's avatar
Don Gagne committed
479 480 481 482 483 484
            RowLayout {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        _margin

                QGCRadioButton {
485 486 487 488 489 490 491
                    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
492
                }
493

Don Gagne's avatar
Don Gagne committed
494
                FactTextField {
495 496 497 498
                    fact:                   missionItem.gridAltitude
                    enabled:                fixedAltitudeRadio.checked
                    Layout.preferredWidth:  _root._fieldWidth
                    anchors.verticalCenter: parent.verticalCenter
499
                }
Don Gagne's avatar
Don Gagne committed
500
            }
Don Gagne's avatar
Don Gagne committed
501

Don Gagne's avatar
Don Gagne committed
502 503 504 505 506 507
            RowLayout {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        _margin

                QGCRadioButton {
508 509 510 511 512 513 514
                    id:                     fixedGroundResolutionRadio
                    text:                   qsTr("Ground res:")
                    checked:                !missionItem.fixedValueIsAltitude
                    exclusiveGroup:         fixedValueGroup
                    onClicked:              missionItem.fixedValueIsAltitude = false
                    Layout.fillWidth:       true
                    anchors.verticalCenter: parent.verticalCenter
515 516
                }

Don Gagne's avatar
Don Gagne committed
517
                FactTextField {
518 519 520 521
                    fact:                   missionItem.groundResolution
                    enabled:                fixedGroundResolutionRadio.checked
                    Layout.preferredWidth:  _root._fieldWidth
                    anchors.verticalCenter: parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
522 523 524 525 526
                }
            }
        }

        // Manual grid ui
527
        Column {
Don Gagne's avatar
Don Gagne committed
528 529 530 531
            anchors.left:   parent.left
            anchors.right:  parent.right
            spacing:        _margin
            visible:        gridTypeCombo.currentIndex == _gridTypeManual
532

533
            QGCLabel { text: qsTr("Grid") }
534

Don Gagne's avatar
Don Gagne committed
535 536 537 538 539
            Rectangle {
                anchors.left:   parent.left
                anchors.right:  parent.right
                height:         1
                color:          qgcPal.text
Don Gagne's avatar
Don Gagne committed
540 541
            }

Don Gagne's avatar
Don Gagne committed
542 543 544
            FactTextFieldGrid {
                anchors.left:   parent.left
                anchors.right:  parent.right
545
                columnSpacing:  _margin * 10
Don Gagne's avatar
Don Gagne committed
546 547 548
                rowSpacing:     _margin
                factList:       [ missionItem.gridAngle, missionItem.gridSpacing, missionItem.gridAltitude, missionItem.turnaroundDist ]
            }
Don Gagne's avatar
Don Gagne committed
549

Don Gagne's avatar
Don Gagne committed
550 551 552 553 554 555
            QGCCheckBox {
                anchors.left:   parent.left
                text:           qsTr("Relative altitude")
                checked:        missionItem.gridAltitudeRelative
                onClicked:      missionItem.gridAltitudeRelative = checked
            }
556

557
            QGCLabel { text: qsTr("Camera") }
558

Don Gagne's avatar
Don Gagne committed
559 560 561 562 563
            Rectangle {
                anchors.left:   parent.left
                anchors.right:  parent.right
                height:         1
                color:          qgcPal.text
Don Gagne's avatar
Don Gagne committed
564 565
            }

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

Don Gagne's avatar
Don Gagne committed
579 580 581 582 583 584
                FactTextField {
                    id:                 cameraTriggerDistanceField
                    Layout.fillWidth:   true
                    fact:               missionItem.cameraTriggerDistance
                    enabled:            missionItem.cameraTrigger
                }
Don Gagne's avatar
Don Gagne committed
585 586 587
            }
        }

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

590 591 592 593 594 595 596 597 598
        Rectangle {
            anchors.left:   parent.left
            anchors.right:  parent.right
            height:         1
            color:          qgcPal.text
        }

        Row {
            spacing: ScreenTools.defaultFontPixelWidth
599
            anchors.horizontalCenter: parent.horizontalCenter
600 601

            QGCButton {
602
                width:      _root.width * 0.45
603 604 605
                text:       polygonEditor.drawingPolygon ? qsTr("Finish Draw") : qsTr("Draw")
                visible:    !polygonEditor .adjustingPolygon
                enabled:    ((polygonEditor.drawingPolygon && polygonEditor.polygonReady) || !polygonEditor.drawingPolygon)
606 607

                onClicked: {
608 609
                    if (polygonEditor.drawingPolygon) {
                        polygonEditor.finishCapturePolygon()
610
                    } else {
611
                        polygonEditor.startCapturePolygon()
612
                    }
613 614 615
                }
            }

616
            QGCButton {
617
                width:      _root.width * 0.4
618 619
                text:       polygonEditor.adjustingPolygon ? qsTr("Finish Adjust") : qsTr("Adjust")
                visible:    missionItem.polygonPath.length > 0 && !polygonEditor.drawingPolygon
620

621
                onClicked: {
622 623
                    if (polygonEditor.adjustingPolygon) {
                        polygonEditor.finishAdjustPolygon()
624
                    } else {
625
                        polygonEditor.startAdjustPolygon(missionItem.polygonPath)
626
                    }
627 628 629
                }
            }
        }
630

631
        QGCLabel { text: qsTr("Statistics") }
632 633 634 635 636 637 638 639 640

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

        Grid {
641 642
            columns:        2
            columnSpacing:  ScreenTools.defaultFontPixelWidth
643 644 645 646

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

647
            QGCLabel { text: qsTr("Photo count:") }
648
            QGCLabel { text: missionItem.cameraShots }
649

650 651 652 653 654 655 656 657 658 659
            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")
                }
            }
660
        }
661
    }
662 663 664 665 666 667

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