SurveyItemEditor.qml 14.1 KB
Newer Older
1 2
import QtQuick          2.3
import QtQuick.Controls 1.2
Don Gagne's avatar
Don Gagne committed
3
import QtQuick.Dialogs  1.2
4
import QtQuick.Extras   1.4
5
import QtQuick.Layouts  1.2
6

7
import QGroundControl               1.0
8 9 10
import QGroundControl.ScreenTools   1.0
import QGroundControl.Vehicle       1.0
import QGroundControl.Controls      1.0
11
import QGroundControl.FactSystem    1.0
12 13
import QGroundControl.FactControls  1.0
import QGroundControl.Palette       1.0
14
import QGroundControl.FlightMap     1.0
15 16 17

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

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

27 28 29 30
    property real   _margin:                    ScreenTools.defaultFontPixelWidth / 2
    property real   _fieldWidth:                ScreenTools.defaultFontPixelWidth * 10.5
    property var    _vehicle:                   QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle : QGroundControl.multiVehicleManager.offlineEditingVehicle
    property real   _cameraMinTriggerInterval:  missionItem.cameraCalc.minTriggerInterval.rawValue
Don Gagne's avatar
Don Gagne committed
31

32
    function polygonCaptureStarted() {
Don Gagne's avatar
Don Gagne committed
33
        missionItem.clearPolygon()
34
    }
Don Gagne's avatar
Don Gagne committed
35

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

42 43
    function polygonAdjustVertex(vertexIndex, vertexCoordinate) {
        missionItem.adjustPolygonCoordinate(vertexIndex, vertexCoordinate)
Don Gagne's avatar
Don Gagne committed
44 45
    }

46 47 48
    function polygonAdjustStarted() { }
    function polygonAdjustFinished() { }

49 50 51 52 53 54 55
    QGCPalette { id: qgcPal; colorGroupEnabled: true }

    Column {
        id:                 editorColumn
        anchors.margins:    _margin
        anchors.top:        parent.top
        anchors.left:       parent.left
56
        anchors.right:      parent.right
57 58
        spacing:            _margin

59 60
        QGCTabBar {
            id:             tabBar
61 62
            anchors.left:   parent.left
            anchors.right:  parent.right
63

64 65 66 67 68
            Component.onCompleted: currentIndex = 0

            QGCTabButton { text: qsTr("Grid") }
            QGCTabButton { text: qsTr("Camera") }
            QGCTabButton { text: qsTr("Presets") }
Don Gagne's avatar
Don Gagne committed
69 70
        }

71
        Column {
Don Gagne's avatar
Don Gagne committed
72 73
            anchors.left:       parent.left
            anchors.right:      parent.right
74 75
            spacing:            _margin
            visible:            tabBar.currentIndex == 0
Don Gagne's avatar
Don Gagne committed
76

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

86 87 88 89 90 91 92 93 94
            CameraCalcGrid {
                cameraCalc:                     missionItem.cameraCalc
                vehicleFlightIsFrontal:         true
                distanceToSurfaceLabel:         qsTr("Altitude")
                distanceToSurfaceAltitudeMode:  missionItem.followTerrain ?
                                                    QGroundControl.AltitudeModeAboveTerrain :
                                                    missionItem.cameraCalc.distanceToSurfaceRelative
                frontalDistanceLabel:           qsTr("Trigger Dist")
                sideDistanceLabel:              qsTr("Spacing")
Don Gagne's avatar
Don Gagne committed
95 96
            }

97 98 99
            SectionHeader {
                id:     transectsHeader
                text:   qsTr("Transects")
Don Gagne's avatar
Don Gagne committed
100 101
            }

102 103 104 105 106 107 108
            GridLayout {
                anchors.left:   parent.left
                anchors.right:  parent.right
                columnSpacing:  _margin
                rowSpacing:     _margin
                columns:        2
                visible:        transectsHeader.checked
Don Gagne's avatar
Don Gagne committed
109

110 111 112 113 114
                QGCLabel { text: qsTr("Angle") }
                FactTextField {
                    fact:                   missionItem.gridAngle
                    Layout.fillWidth:       true
                    onUpdated:              angleSlider.value = missionItem.gridAngle.value
Don Gagne's avatar
Don Gagne committed
115 116
                }

117 118 119 120 121 122 123 124 125 126 127 128
                QGCSlider {
                    id:                     angleSlider
                    minimumValue:           0
                    maximumValue:           359
                    stepSize:               1
                    tickmarksEnabled:       false
                    Layout.fillWidth:       true
                    Layout.columnSpan:      2
                    Layout.preferredHeight: ScreenTools.defaultFontPixelHeight * 1.5
                    onValueChanged:         missionItem.gridAngle.value = value
                    Component.onCompleted:  value = missionItem.gridAngle.value
                    updateValueWhileDragging: true
Don Gagne's avatar
Don Gagne committed
129 130
                }

131 132 133 134 135 136 137
                QGCLabel {
                    text:       qsTr("Turnaround dist")
                }
                FactTextField {
                    fact:               missionItem.turnAroundDistance
                    Layout.fillWidth:   true
                }
DonLakeFlyer's avatar
DonLakeFlyer committed
138 139
            }

140 141 142
            QGCButton {
                text:               qsTr("Rotate Entry Point")
                onClicked:          missionItem.rotateEntryPoint();
Don Gagne's avatar
Don Gagne committed
143 144
            }

145 146 147 148
            ColumnLayout {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        _margin
Don Gagne's avatar
Don Gagne committed
149
                visible:        transectsHeader.checked
DonLakeFlyer's avatar
DonLakeFlyer committed
150

151
                /*
152
              Temporarily removed due to bug https://github.com/mavlink/qgroundcontrol/issues/7005
153 154 155 156
            FactCheckBox {
                text:       qsTr("Split concave polygons")
                fact:       _splitConcave
                visible:    _splitConcave.visible
157
                property Fact _splitConcave: missionItem.splitConcavePolygons
158
            }
159
            */
160

161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
                QGCOptionsComboBox {
                    Layout.fillWidth: true

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

                    onItemClicked: {
                        if (index == 4) {
                            missionItem.cameraCalc.distanceToSurfaceRelative = !missionItem.cameraCalc.distanceToSurfaceRelative
                            console.log(missionItem.cameraCalc.distanceToSurfaceRelative)
                        }
202
                    }
203 204
                }
            }
205

206 207 208
            SectionHeader {
                id:         terrainHeader
                text:       qsTr("Terrain")
209 210
                checked:    missionItem.followTerrain
            }
211

212 213 214 215
            ColumnLayout {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        _margin
Don Gagne's avatar
Don Gagne committed
216
                visible:        terrainHeader.checked
217 218


219 220 221 222 223
                QGCCheckBox {
                    id:         followsTerrainCheckBox
                    text:       qsTr("Vehicle follows terrain")
                    checked:    missionItem.followTerrain
                    onClicked:  missionItem.followTerrain = checked
224
                }
225

226
                GridLayout {
227
                    Layout.fillWidth:   true
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
                    columnSpacing:      _margin
                    rowSpacing:         _margin
                    columns:            2
                    visible:            followsTerrainCheckBox.checked

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

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

                    QGCLabel { text: qsTr("Max Descent Rate") }
                    FactTextField {
                        fact:               missionItem.terrainAdjustMaxDescentRate
                        Layout.fillWidth:   true
                    }
250
                }
251
            }
252

253 254 255 256
            SectionHeader {
                id:     statsHeader
                text:   qsTr("Statistics")
            }
257

258 259
            TransectStyleComplexItemStats { }
        } // Grid Column
Don Gagne's avatar
Don Gagne committed
260

261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277
        Column {
            anchors.left:       parent.left
            anchors.right:      parent.right
            spacing:            _margin
            visible:            tabBar.currentIndex == 1

            CameraCalcCamera {
                cameraCalc:                     missionItem.cameraCalc
                vehicleFlightIsFrontal:         true
                distanceToSurfaceLabel:         qsTr("Altitude")
                distanceToSurfaceAltitudeMode:  missionItem.followTerrain ?
                                                    QGroundControl.AltitudeModeAboveTerrain :
                                                    missionItem.cameraCalc.distanceToSurfaceRelative
                frontalDistanceLabel:           qsTr("Trigger Dist")
                sideDistanceLabel:              qsTr("Spacing")
            }
        } // Camera Column
Don Gagne's avatar
Don Gagne committed
278

Don Gagne's avatar
Don Gagne committed
279
        ColumnLayout {
280 281 282 283 284
            anchors.left:       parent.left
            anchors.right:      parent.right
            spacing:            _margin
            visible:            tabBar.currentIndex == 2

Don Gagne's avatar
Don Gagne committed
285 286 287 288 289 290
            QGCLabel {
                Layout.fillWidth:   true
                text:               qsTr("Presets")
                wrapMode:           Text.WordWrap
            }

291 292
            QGCComboBox {
                id:                 presetCombo
Don Gagne's avatar
Don Gagne committed
293 294 295
                Layout.fillWidth:   true
                model:              missionItem.presetNames
            }
296

Don Gagne's avatar
Don Gagne committed
297 298
            RowLayout {
                Layout.fillWidth:   true
299

Don Gagne's avatar
Don Gagne committed
300 301 302 303 304
                QGCButton {
                    Layout.fillWidth:   true
                    text:               qsTr("Apply Preset")
                    enabled:            missionItem.presetNames.length != 0
                    onClicked:          missionItem.loadPreset(presetCombo.textAt(presetCombo.currentIndex))
Don Gagne's avatar
Don Gagne committed
305 306
                }

Don Gagne's avatar
Don Gagne committed
307 308 309 310 311
                QGCButton {
                    Layout.fillWidth:   true
                    text:               qsTr("Delete Preset")
                    enabled:            missionItem.presetNames.length != 0
                    onClicked:          missionItem.deletePreset(presetCombo.textAt(presetCombo.currentIndex))
Don Gagne's avatar
Don Gagne committed
312 313
                }

Don Gagne's avatar
Don Gagne committed
314
            }
315

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

Don Gagne's avatar
Don Gagne committed
318 319 320 321 322
            QGCButton {
                Layout.alignment:   Qt.AlignCenter
                Layout.fillWidth:   true
                text:               qsTr("Save Settings As New Preset")
                onClicked:          mainWindow.showComponentDialog(savePresetDialog, qsTr("Save Preset"), mainWindow.showDialogDefaultWidth, StandardButton.Save | StandardButton.Cancel)
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355
            }
        } // Camera Column

        Component {
            id: savePresetDialog

            QGCViewDialog {
                function accept() {
                    if (presetNameField.text != "") {
                        missionItem.savePreset(presetNameField.text)
                        hideDialog()
                    }
                }

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

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

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

                    QGCTextField {
                        id:                 presetNameField
                        Layout.fillWidth:   true
                    }
Don Gagne's avatar
Don Gagne committed
356 357 358 359
                }
            }
        }
    }
360
} // Rectangle