Skip to content
SurveyItemEditor.qml 17.4 KiB
Newer Older
import QtQuick          2.3
import QtQuick.Controls 1.2
Don Gagne's avatar
Don Gagne committed
import QtQuick.Dialogs  1.2
import QtQuick.Extras   1.4
import QtQuick.Layouts  1.2
import QGroundControl               1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Vehicle       1.0
import QGroundControl.Controls      1.0
import QGroundControl.FactSystem    1.0
import QGroundControl.FactControls  1.0
import QGroundControl.Palette       1.0
import QGroundControl.FlightMap     1.0

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

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

    property real   _margin:                    ScreenTools.defaultFontPixelWidth / 2
    property real   _fieldWidth:                ScreenTools.defaultFontPixelWidth * 10.5
    property var    _vehicle:                   QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle : QGroundControl.multiVehicleManager.offlineEditingVehicle
DonLakeFlyer's avatar
 
DonLakeFlyer committed
    property real   _cameraMinTriggerInterval:  _missionItem.cameraCalc.minTriggerInterval.rawValue
DoinLakeFlyer's avatar
 
DoinLakeFlyer committed
    property bool   _polygonDone:               false
DoinLakeFlyer's avatar
 
DoinLakeFlyer committed
    property string _doneAdjusting:             qsTr("Done")
DonLakeFlyer's avatar
 
DonLakeFlyer committed
    property var    _missionItem:               missionItem
    property bool   _presetsAvailable:          _missionItem.presetNames.length !== 0
    function polygonCaptureStarted() {
DonLakeFlyer's avatar
 
DonLakeFlyer committed
        _missionItem.clearPolygon()
Don Gagne's avatar
Don Gagne committed

    function polygonCaptureFinished(coordinates) {
        for (var i=0; i<coordinates.length; i++) {
DonLakeFlyer's avatar
 
DonLakeFlyer committed
            _missionItem.addPolygonCoordinate(coordinates[i])
Don Gagne's avatar
Don Gagne committed
        }
Don Gagne's avatar
Don Gagne committed

    function polygonAdjustVertex(vertexIndex, vertexCoordinate) {
DonLakeFlyer's avatar
 
DonLakeFlyer committed
        _missionItem.adjustPolygonCoordinate(vertexIndex, vertexCoordinate)
    function polygonAdjustStarted() { }
    function polygonAdjustFinished() { }

    QGCPalette { id: qgcPal; colorGroupEnabled: true }

    Column {
        id:                 editorColumn
        anchors.margins:    _margin
        anchors.top:        parent.top
        anchors.left:       parent.left
        anchors.right:      parent.right
Don Gagne's avatar
 
Don Gagne committed
        ColumnLayout {
DonLakeFlyer's avatar
 
DonLakeFlyer committed
            id:             wizardColumn
            anchors.left:   parent.left
            anchors.right:  parent.right
Don Gagne's avatar
 
Don Gagne committed
            spacing:        _margin
DonLakeFlyer's avatar
 
DonLakeFlyer committed
            visible:        !_missionItem.surveyAreaPolygon.isValid || _missionItem.wizardMode
DoinLakeFlyer's avatar
 
DoinLakeFlyer committed
            ColumnLayout {
Don Gagne's avatar
 
Don Gagne committed
                Layout.fillWidth:   true
DoinLakeFlyer's avatar
 
DoinLakeFlyer committed
                spacing:             _margin
                visible:            !_polygonDone

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

Don Gagne's avatar
 
Don Gagne committed
        Column {
Don Gagne's avatar
 
Don Gagne committed
            anchors.left:   parent.left
            anchors.right:  parent.right
            spacing:        _margin
DonLakeFlyer's avatar
 
DonLakeFlyer committed
            visible:        !wizardColumn.visible
Don Gagne's avatar
 
Don Gagne committed

DonLakeFlyer's avatar
 
DonLakeFlyer committed
            TransectStyleComplexItemTabBar {
Don Gagne's avatar
 
Don Gagne committed
                id:             tabBar
Don Gagne's avatar
 
Don Gagne committed
                anchors.left:   parent.left
                anchors.right:  parent.right
Don Gagne's avatar
 
Don Gagne committed
            }

DonLakeFlyer's avatar
 
DonLakeFlyer committed
            // Grid tab
Don Gagne's avatar
 
Don Gagne committed
            Column {
                anchors.left:       parent.left
                anchors.right:      parent.right
                spacing:            _margin
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                visible:            tabBar.currentIndex === 0
Don Gagne's avatar
 
Don Gagne committed

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

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

Don Gagne's avatar
 
Don Gagne committed
                SectionHeader {
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                    id:             transectsHeader
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    text:           qsTr("Transects")
Don Gagne's avatar
 
Don Gagne committed
                }
Don Gagne's avatar
 
Don Gagne committed

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

                    QGCLabel { text: qsTr("Angle") }
                    FactTextField {
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                        fact:                   _missionItem.gridAngle
Don Gagne's avatar
 
Don Gagne committed
                        Layout.fillWidth:       true
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                        onUpdated:              angleSlider.value = _missionItem.gridAngle.value
Don Gagne's avatar
 
Don Gagne committed
                    }

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

                    QGCLabel {
                        text:       qsTr("Turnaround dist")
                    }
                    FactTextField {
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                        fact:               _missionItem.turnAroundDistance
Don Gagne's avatar
 
Don Gagne committed
                        Layout.fillWidth:   true
                    }
Don Gagne's avatar
 
Don Gagne committed
                }
DonLakeFlyer's avatar
DonLakeFlyer committed

Don Gagne's avatar
 
Don Gagne committed
                QGCButton {
                    text:               qsTr("Rotate Entry Point")
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                    onClicked:          _missionItem.rotateEntryPoint();
Don Gagne's avatar
 
Don Gagne committed
                }
Don Gagne's avatar
 
Don Gagne committed

Don Gagne's avatar
 
Don Gagne committed
                ColumnLayout {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    spacing:        _margin
                    visible:        transectsHeader.checked
Don Gagne's avatar
 
Don Gagne committed
                    QGCOptionsComboBox {
                        Layout.fillWidth: true

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

                        onItemClicked: {
                            if (index == 4) {
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                                _missionItem.cameraCalc.distanceToSurfaceRelative = !_missionItem.cameraCalc.distanceToSurfaceRelative
                                console.log(_missionItem.cameraCalc.distanceToSurfaceRelative)
Don Gagne's avatar
 
Don Gagne committed
                            }
Don Gagne's avatar
 
Don Gagne committed
                        }
Don Gagne's avatar
 
Don Gagne committed
                    }
                }
Don Gagne's avatar
 
Don Gagne committed

Don Gagne's avatar
 
Don Gagne committed
                SectionHeader {
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                    id:             statsHeader
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    text:           qsTr("Statistics")
Don Gagne's avatar
 
Don Gagne committed
                }

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

DonLakeFlyer's avatar
 
DonLakeFlyer committed
            // Camera Tab
Don Gagne's avatar
 
Don Gagne committed
            Column {
                anchors.left:       parent.left
                anchors.right:      parent.right
                spacing:            _margin
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                visible:            tabBar.currentIndex === 1
Don Gagne's avatar
 
Don Gagne committed

                CameraCalcCamera {
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                    cameraCalc: _missionItem.cameraCalc
Don Gagne's avatar
 
Don Gagne committed
                }
            } // Camera Column
DonLakeFlyer's avatar
 
DonLakeFlyer committed
            // Terrain Tab
            TransectStyleComplexItemTerrainFollow {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        _margin
                visible:        tabBar.currentIndex === 2
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                missionItem:    _missionItem
DonLakeFlyer's avatar
 
DonLakeFlyer committed
            }

            // Presets Tab
Don Gagne's avatar
 
Don Gagne committed
            ColumnLayout {
Don Gagne's avatar
 
Don Gagne committed
                anchors.left:       parent.left
                anchors.right:      parent.right
                spacing:            _margin
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                visible:            tabBar.currentIndex === 3
Don Gagne's avatar
 
Don Gagne committed
                QGCLabel {
                    Layout.fillWidth:   true
                    text:               qsTr("Presets")
                    wrapMode:           Text.WordWrap
                }
Don Gagne's avatar
 
Don Gagne committed
                QGCComboBox {
                    id:                 presetCombo
                    Layout.fillWidth:   true
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                    model:              _missionItem.presetNames
Don Gagne's avatar
 
Don Gagne committed
                RowLayout {
Don Gagne's avatar
 
Don Gagne committed

Don Gagne's avatar
 
Don Gagne committed
                    QGCButton {
Don Gagne's avatar
 
Don Gagne committed
                        Layout.fillWidth:   true
Don Gagne's avatar
 
Don Gagne committed
                        text:               qsTr("Apply Preset")
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                        enabled:            _missionItem.presetNames.length != 0
                        onClicked:          _missionItem.loadPreset(presetCombo.textAt(presetCombo.currentIndex))
Don Gagne's avatar
 
Don Gagne committed
                    }

Don Gagne's avatar
 
Don Gagne committed
                    QGCButton {
Don Gagne's avatar
 
Don Gagne committed
                        Layout.fillWidth:   true
Don Gagne's avatar
 
Don Gagne committed
                        text:               qsTr("Delete Preset")
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                        enabled:            _missionItem.presetNames.length != 0
DoinLakeFlyer's avatar
 
DoinLakeFlyer committed
                        onClicked:          mainWindow.showComponentDialog(deletePresetMessage, qsTr("Delete Preset"), mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.No)

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

Don Gagne's avatar
 
Don Gagne committed
                Item { height: ScreenTools.defaultFontPixelHeight; width: 1 }
Don Gagne's avatar
 
Don Gagne committed

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

Don Gagne's avatar
 
Don Gagne committed
                SectionHeader {
                    id:                 presectsTransectsHeader
Don Gagne's avatar
 
Don Gagne committed
                    Layout.fillWidth:   true
Don Gagne's avatar
 
Don Gagne committed
                    text:               qsTr("Transects")
Don Gagne's avatar
 
Don Gagne committed
                }

Don Gagne's avatar
 
Don Gagne committed
                GridLayout {
                    Layout.fillWidth:   true
                    columnSpacing:      _margin
                    rowSpacing:         _margin
                    columns:            2
                    visible:            presectsTransectsHeader.checked
Don Gagne's avatar
 
Don Gagne committed

Don Gagne's avatar
 
Don Gagne committed
                    QGCLabel { text: qsTr("Angle") }
                    FactTextField {
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                        fact:                   _missionItem.gridAngle
Don Gagne's avatar
 
Don Gagne committed
                        Layout.fillWidth:       true
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                        onUpdated:              presetsAngleSlider.value = _missionItem.gridAngle.value
Don Gagne's avatar
 
Don Gagne committed
                    }
Don Gagne's avatar
 
Don Gagne committed

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

Don Gagne's avatar
 
Don Gagne committed
                    QGCButton {
                        Layout.columnSpan:  2
                        Layout.fillWidth:   true
                        text:               qsTr("Rotate Entry Point")
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                        onClicked:          _missionItem.rotateEntryPoint();
Don Gagne's avatar
 
Don Gagne committed
                    }
Don Gagne's avatar
 
Don Gagne committed
                }

Don Gagne's avatar
 
Don Gagne committed
                SectionHeader {
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                    id:                 presetsStatsHeader
Don Gagne's avatar
 
Don Gagne committed
                    Layout.fillWidth:   true
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                    text:               qsTr("Statistics")
Don Gagne's avatar
 
Don Gagne committed
                }

Don Gagne's avatar
 
Don Gagne committed
                TransectStyleComplexItemStats {
Don Gagne's avatar
 
Don Gagne committed
                    Layout.fillWidth:   true
Don Gagne's avatar
 
Don Gagne committed
                    visible:            presetsStatsHeader.checked
Don Gagne's avatar
 
Don Gagne committed
                }
Don Gagne's avatar
 
Don Gagne committed
            } // Main editing column
        } // Top level  Column
Don Gagne's avatar
 
Don Gagne committed

        Component {
            id: savePresetDialog

            QGCViewDialog {
                function accept() {
                    if (presetNameField.text != "") {
DonLakeFlyer's avatar
 
DonLakeFlyer committed
                        _missionItem.savePreset(presetNameField.text)
Don Gagne's avatar
 
Don Gagne committed
                        hideDialog()
                    }
                }

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

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

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

                    QGCTextField {
                        id:                 presetNameField
                        Layout.fillWidth:   true
                    }
Don Gagne's avatar
 
Don Gagne committed
                }
            }
        }
    }
Don Gagne's avatar
 
Don Gagne committed

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

        onAcceptedForLoad: {
DonLakeFlyer's avatar
 
DonLakeFlyer committed
            _missionItem.surveyAreaPolygon.loadKMLOrSHPFile(file)
            _missionItem.resetState = false
            //editorMap.mapFitFunctions.fitMapViewportTo_missionItems()
Don Gagne's avatar
 
Don Gagne committed
            close()
        }
    }