SurveyItemEditor.qml 25.2 KB
Newer Older
Don Gagne's avatar
Don Gagne committed
1 2 3 4
import QtQuick          2.2
import QtQuick.Controls 1.2
import QtQuick.Dialogs  1.2
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 217 218 219 220 221 222 223 224 225 226 227 228
    property bool _noCameraValueRecalc: false   ///< Prevents uneeded recalcs

    Connections {
        target: missionItem

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

    Connections {
        target: missionItem.gridAltitude

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

229 230
    QGCPalette { id: qgcPal; colorGroupEnabled: true }

Don Gagne's avatar
Don Gagne committed
231
    ExclusiveGroup {
Don Gagne's avatar
Don Gagne committed
232 233 234 235 236 237
        id: cameraOrientationGroup

        onCurrentChanged: {
            if (gridTypeCombo.currentIndex >= _gridTypeCustomCamera) {
                recalcFromCameraValues()
            }
238
        }
Don Gagne's avatar
Don Gagne committed
239 240
    }

Don Gagne's avatar
Don Gagne committed
241 242
    ExclusiveGroup { id: fixedValueGroup }

243 244 245 246 247
    Column {
        id:                 editorColumn
        anchors.margins:    _margin
        anchors.top:        parent.top
        anchors.left:       parent.left
248
        anchors.right:      parent.right
249 250
        spacing:            _margin

Don Gagne's avatar
Don Gagne committed
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
        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
                    }
269
                }
Don Gagne's avatar
Don Gagne committed
270
            }
271

Don Gagne's avatar
Don Gagne committed
272 273 274 275 276 277 278
            onActivated: {
                if (index == _gridTypeManual) {
                    missionItem.manualGrid = true
                } else {
                    missionItem.manualGrid = false
                    missionItem.camera = gridTypeCombo.textAt(index)
                    _noCameraValueRecalc = true
279 280 281
                    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
282
                    missionItem.cameraResolutionHeight.rawValue = cameraModelList.get(index).imageHeight
283
                    missionItem.cameraFocalLength.rawValue      = cameraModelList.get(index).focalLength
Don Gagne's avatar
Don Gagne committed
284 285
                    _noCameraValueRecalc = false
                    recalcFromCameraValues()
286 287 288 289
                }
            }
        }

290
        QGCLabel { text: qsTr("Camera"); visible: gridTypeCombo.currentIndex !== _gridTypeManual}
291 292 293 294 295 296 297 298 299

        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
300 301
        // Camera based grid ui
        Column {
Don Gagne's avatar
Don Gagne committed
302
            anchors.left:   parent.left
Don Gagne's avatar
Don Gagne committed
303 304 305
            anchors.right:  parent.right
            spacing:        _margin
            visible:        gridTypeCombo.currentIndex != _gridTypeManual
Don Gagne's avatar
Don Gagne committed
306

Don Gagne's avatar
Don Gagne committed
307 308
            Row {
                spacing: _margin
309
                anchors.horizontalCenter: parent.horizontalCenter
310

Don Gagne's avatar
Don Gagne committed
311 312 313 314 315 316 317
                QGCRadioButton {
                    id:             cameraOrientationLandscape
                    width:          _editFieldWidth
                    text:           "Landscape"
                    checked:        true
                    exclusiveGroup: cameraOrientationGroup
                }
318

Don Gagne's avatar
Don Gagne committed
319 320 321 322 323
                QGCRadioButton {
                    id:             cameraOrientationPortrait
                    text:           "Portrait"
                    exclusiveGroup: cameraOrientationGroup
                }
324 325
            }

Don Gagne's avatar
Don Gagne committed
326
            Column {
327
                id:             custCameraCol
Don Gagne's avatar
Don Gagne committed
328 329 330
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        _margin
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
                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
347

348 349 350 351 352
                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
353
                    FactTextField {
354
                        Layout.preferredWidth:  _root._fieldWidth
Don Gagne's avatar
Don Gagne committed
355 356 357
                        fact:                   missionItem.cameraSensorWidth
                    }
                    FactTextField {
358
                        Layout.preferredWidth:  _root._fieldWidth
Don Gagne's avatar
Don Gagne committed
359 360
                        fact:                   missionItem.cameraSensorHeight
                    }
361
                }
Don Gagne's avatar
Don Gagne committed
362

363 364 365 366 367
                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
368
                    FactTextField {
369
                        Layout.preferredWidth:  _root._fieldWidth
Don Gagne's avatar
Don Gagne committed
370 371 372
                        fact:                   missionItem.cameraResolutionWidth
                    }
                    FactTextField {
373
                        Layout.preferredWidth:  _root._fieldWidth
Don Gagne's avatar
Don Gagne committed
374 375 376 377
                        fact:                   missionItem.cameraResolutionHeight
                    }
                }

378 379 380 381 382 383 384 385 386 387 388 389
                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
390 391
                }

392
            } // Column - custom camera
Don Gagne's avatar
Don Gagne committed
393

394 395 396
            RowLayout {
                anchors.left:   parent.left
                anchors.right:  parent.right
Don Gagne's avatar
Don Gagne committed
397
                spacing:        _margin
398 399 400 401
                Item { Layout.fillWidth: true }
                QGCLabel {
                    Layout.preferredWidth:  _root._fieldWidth
                    text:                   qsTr("Frontal")
Don Gagne's avatar
Don Gagne committed
402 403
                }
                QGCLabel {
404 405
                    Layout.preferredWidth:  _root._fieldWidth
                    text:                   qsTr("Side")
Don Gagne's avatar
Don Gagne committed
406
                }
407
            }
Don Gagne's avatar
Don Gagne committed
408

409 410 411 412 413
            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
414
                FactTextField {
415 416
                    Layout.preferredWidth:  _root._fieldWidth
                    fact:                   missionItem.frontalOverlap
Don Gagne's avatar
Don Gagne committed
417 418
                }
                FactTextField {
419 420
                    Layout.preferredWidth:  _root._fieldWidth
                    fact:                   missionItem.sideOverlap
Don Gagne's avatar
Don Gagne committed
421
                }
Don Gagne's avatar
Don Gagne committed
422 423
            }

424
            QGCLabel { text: qsTr("Grid") }
Don Gagne's avatar
Don Gagne committed
425 426 427 428 429 430

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

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

Don Gagne's avatar
Don Gagne committed
465 466 467 468 469 470
            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
471 472
            }

Don Gagne's avatar
Don Gagne committed
473 474 475 476 477 478
            RowLayout {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        _margin

                QGCRadioButton {
479 480 481 482 483 484 485
                    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
486
                }
487

Don Gagne's avatar
Don Gagne committed
488
                FactTextField {
489 490 491 492
                    fact:                   missionItem.gridAltitude
                    enabled:                fixedAltitudeRadio.checked
                    Layout.preferredWidth:  _root._fieldWidth
                    anchors.verticalCenter: parent.verticalCenter
493
                }
Don Gagne's avatar
Don Gagne committed
494
            }
Don Gagne's avatar
Don Gagne committed
495

Don Gagne's avatar
Don Gagne committed
496 497 498 499 500 501
            RowLayout {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        _margin

                QGCRadioButton {
502 503 504 505 506 507 508
                    id:                     fixedGroundResolutionRadio
                    text:                   qsTr("Ground res:")
                    checked:                !missionItem.fixedValueIsAltitude
                    exclusiveGroup:         fixedValueGroup
                    onClicked:              missionItem.fixedValueIsAltitude = false
                    Layout.fillWidth:       true
                    anchors.verticalCenter: parent.verticalCenter
509 510
                }

Don Gagne's avatar
Don Gagne committed
511
                FactTextField {
512 513 514 515
                    fact:                   missionItem.groundResolution
                    enabled:                fixedGroundResolutionRadio.checked
                    Layout.preferredWidth:  _root._fieldWidth
                    anchors.verticalCenter: parent.verticalCenter
Don Gagne's avatar
Don Gagne committed
516 517 518 519 520
                }
            }
        }

        // Manual grid ui
521
        Column {
Don Gagne's avatar
Don Gagne committed
522 523 524 525
            anchors.left:   parent.left
            anchors.right:  parent.right
            spacing:        _margin
            visible:        gridTypeCombo.currentIndex == _gridTypeManual
526

527
            QGCLabel { text: qsTr("Grid") }
528

Don Gagne's avatar
Don Gagne committed
529 530 531 532 533
            Rectangle {
                anchors.left:   parent.left
                anchors.right:  parent.right
                height:         1
                color:          qgcPal.text
Don Gagne's avatar
Don Gagne committed
534 535
            }

Don Gagne's avatar
Don Gagne committed
536 537 538
            FactTextFieldGrid {
                anchors.left:   parent.left
                anchors.right:  parent.right
539
                columnSpacing:  _margin * 10
Don Gagne's avatar
Don Gagne committed
540 541 542
                rowSpacing:     _margin
                factList:       [ missionItem.gridAngle, missionItem.gridSpacing, missionItem.gridAltitude, missionItem.turnaroundDist ]
            }
Don Gagne's avatar
Don Gagne committed
543

Don Gagne's avatar
Don Gagne committed
544 545 546 547 548 549
            QGCCheckBox {
                anchors.left:   parent.left
                text:           qsTr("Relative altitude")
                checked:        missionItem.gridAltitudeRelative
                onClicked:      missionItem.gridAltitudeRelative = checked
            }
550

551
            QGCLabel { text: qsTr("Camera") }
552

Don Gagne's avatar
Don Gagne committed
553 554 555 556 557
            Rectangle {
                anchors.left:   parent.left
                anchors.right:  parent.right
                height:         1
                color:          qgcPal.text
Don Gagne's avatar
Don Gagne committed
558 559
            }

Don Gagne's avatar
Don Gagne committed
560 561 562 563 564 565 566 567 568 569 570 571
            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
572

Don Gagne's avatar
Don Gagne committed
573 574 575 576 577 578
                FactTextField {
                    id:                 cameraTriggerDistanceField
                    Layout.fillWidth:   true
                    fact:               missionItem.cameraTriggerDistance
                    enabled:            missionItem.cameraTrigger
                }
Don Gagne's avatar
Don Gagne committed
579 580 581
            }
        }

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

584 585 586 587 588 589 590 591 592
        Rectangle {
            anchors.left:   parent.left
            anchors.right:  parent.right
            height:         1
            color:          qgcPal.text
        }

        Row {
            spacing: ScreenTools.defaultFontPixelWidth
593
            anchors.horizontalCenter: parent.horizontalCenter
594 595

            QGCButton {
596
                width:      _root.width * 0.45
597 598 599
                text:       polygonEditor.drawingPolygon ? qsTr("Finish Draw") : qsTr("Draw")
                visible:    !polygonEditor .adjustingPolygon
                enabled:    ((polygonEditor.drawingPolygon && polygonEditor.polygonReady) || !polygonEditor.drawingPolygon)
600 601

                onClicked: {
602 603
                    if (polygonEditor.drawingPolygon) {
                        polygonEditor.finishCapturePolygon()
604
                    } else {
605
                        polygonEditor.startCapturePolygon()
606
                    }
607 608 609
                }
            }

610
            QGCButton {
611
                width:      _root.width * 0.4
612 613
                text:       polygonEditor.adjustingPolygon ? qsTr("Finish Adjust") : qsTr("Adjust")
                visible:    missionItem.polygonPath.length > 0 && !polygonEditor.drawingPolygon
614

615
                onClicked: {
616 617
                    if (polygonEditor.adjustingPolygon) {
                        polygonEditor.finishAdjustPolygon()
618
                    } else {
619
                        polygonEditor.startAdjustPolygon(missionItem.polygonPath)
620
                    }
621 622 623
                }
            }
        }
624

625
        QGCLabel { text: qsTr("Statistics") }
626 627 628 629 630 631 632 633 634

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

        Grid {
635 636
            columns:        2
            columnSpacing:  ScreenTools.defaultFontPixelWidth
637 638 639 640

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

641
            QGCLabel { text: qsTr("Photo count:") }
642
            QGCLabel { text: missionItem.cameraShots }
643

644 645 646 647 648 649 650 651 652 653
            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")
                }
            }
654
        }
655
    }
656 657 658 659 660 661

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