PlanView.qml 53.6 KB
Newer Older
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
Don Gagne's avatar
Don Gagne committed
9

10 11
import QtQuick          2.3
import QtQuick.Controls 1.2
Don Gagne's avatar
Don Gagne committed
12
import QtQuick.Dialogs  1.2
13 14 15
import QtLocation       5.3
import QtPositioning    5.3
import QtQuick.Layouts  1.2
16
import QtQuick.Window   2.2
Don Gagne's avatar
Don Gagne committed
17

18 19 20 21 22 23 24 25 26 27 28
import QGroundControl                   1.0
import QGroundControl.FlightMap         1.0
import QGroundControl.ScreenTools       1.0
import QGroundControl.Controls          1.0
import QGroundControl.FactSystem        1.0
import QGroundControl.FactControls      1.0
import QGroundControl.Palette           1.0
import QGroundControl.Controllers       1.0
import QGroundControl.ShapeFileHelper   1.0
import QGroundControl.Airspace          1.0
import QGroundControl.Airmap            1.0
Don Gagne's avatar
Don Gagne committed
29

30
Item {
31
    id: _root
32

Gus Grubba's avatar
Gus Grubba committed
33 34
    property bool planControlColapsed: false

35 36
    readonly property int   _decimalPlaces:             8
    readonly property real  _margin:                    ScreenTools.defaultFontPixelHeight * 0.5
37
    readonly property real  _toolsMargin:               ScreenTools.defaultFontPixelWidth * 0.75
Gus Grubba's avatar
Gus Grubba committed
38
    readonly property real  _radius:                    ScreenTools.defaultFontPixelWidth  * 0.5
39 40 41
    readonly property real  _rightPanelWidth:           Math.min(parent.width / 3, ScreenTools.defaultFontPixelWidth * 30)
    readonly property var   _defaultVehicleCoordinate:  QtPositioning.coordinate(37.803784, -122.462276)
    readonly property bool  _waypointsOnlyMode:         QGroundControl.corePlugin.options.missionWaypointsOnly
42

Gus Grubba's avatar
Gus Grubba committed
43
    property bool   _airspaceEnabled:                    QGroundControl.airmapSupported ? (QGroundControl.settingsManager.airMapSettings.enableAirMap.rawValue && QGroundControl.airspaceManager.connected): false
Gus Grubba's avatar
Gus Grubba committed
44 45 46 47 48 49 50 51
    property var    _missionController:                 _planMasterController.missionController
    property var    _geoFenceController:                _planMasterController.geoFenceController
    property var    _rallyPointController:              _planMasterController.rallyPointController
    property var    _visualItems:                       _missionController.visualItems
    property bool   _lightWidgetBorders:                editorMap.isSatelliteMap
    property bool   _addWaypointOnClick:                false
    property bool   _addROIOnClick:                     false
    property bool   _singleComplexItem:                 _missionController.complexMissionItemNames.length === 1
Gus Grubba's avatar
Gus Grubba committed
52
    property int    _editingLayer:                      bar.currentIndex ? _layers[bar.currentIndex] : _layerMission
Gus Grubba's avatar
Gus Grubba committed
53
    property int    _toolStripBottom:                   toolStrip.height + toolStrip.y
54
    property var    _appSettings:                       QGroundControl.settingsManager.appSettings
55
    property var    _planViewSettings:                  QGroundControl.settingsManager.planViewSettings
56

Gus Grubba's avatar
Gus Grubba committed
57 58
    readonly property var       _layers:                [_layerMission, _layerGeoFence, _layerRallyPoints]

59 60 61 62
    readonly property int       _layerMission:              1
    readonly property int       _layerGeoFence:             2
    readonly property int       _layerRallyPoints:          3
    readonly property string    _armedVehicleUploadPrompt:  qsTr("Vehicle is currently armed. Do you want to upload the mission to the vehicle?")
63

64
    function mapCenter() {
65
        var coordinate = editorMap.center
66
        coordinate.latitude  = coordinate.latitude.toFixed(_decimalPlaces)
67
        coordinate.longitude = coordinate.longitude.toFixed(_decimalPlaces)
68
        coordinate.altitude  = coordinate.altitude.toFixed(_decimalPlaces)
69 70 71
        return coordinate
    }

72
    function updateAirspace(reset) {
73 74 75 76
        if(_airspaceEnabled) {
            var coordinateNW = editorMap.toCoordinate(Qt.point(0,0), false /* clipToViewPort */)
            var coordinateSE = editorMap.toCoordinate(Qt.point(width,height), false /* clipToViewPort */)
            if(coordinateNW.isValid && coordinateSE.isValid) {
77
                QGroundControl.airspaceManager.setROI(coordinateNW, coordinateSE, true /*planView*/, reset)
78 79 80 81
            }
        }
    }

82 83 84 85 86
    property bool _firstMissionLoadComplete:    false
    property bool _firstFenceLoadComplete:      false
    property bool _firstRallyLoadComplete:      false
    property bool _firstLoadComplete:           false

87
    MapFitFunctions {
88
        id:                         mapFitFunctions  // The name for this id cannot be changed without breaking references outside of this code. Beware!
89 90
        map:                        editorMap
        usePlannedHomePosition:     true
91
        planMasterController:       _planMasterController
92 93
    }

94
    on_AirspaceEnabledChanged: {
95
        if(QGroundControl.airmapSupported) {
96 97
            if(_airspaceEnabled) {
                planControlColapsed = QGroundControl.airspaceManager.airspaceVisible
98
                updateAirspace(true)
99 100 101
            } else {
                planControlColapsed = false
            }
102
        } else {
Gus Grubba's avatar
Gus Grubba committed
103 104 105 106
            planControlColapsed = false
        }
    }

107
    onVisibleChanged: {
108 109 110 111 112 113
        if(visible) {
            editorMap.zoomLevel = QGroundControl.flightMapZoom
            editorMap.center    = QGroundControl.flightMapPosition
            if (!_planMasterController.containsItems) {
                toolStrip.simulateClick(toolStrip.fileButtonIndex)
            }
114 115 116
        }
    }

DonLakeFlyer's avatar
DonLakeFlyer committed
117
    Connections {
Gus Grubba's avatar
Gus Grubba committed
118
        target: _appSettings ? _appSettings.defaultMissionItemAltitude : null
DonLakeFlyer's avatar
DonLakeFlyer committed
119 120
        onRawValueChanged: {
            if (_visualItems.count > 1) {
121
                mainWindow.showComponentDialog(applyNewAltitude, qsTr("Apply new alititude"), mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.No)
DonLakeFlyer's avatar
DonLakeFlyer committed
122 123 124 125 126 127 128 129 130 131
            }
        }
    }

    Component {
        id: applyNewAltitude
        QGCViewMessage {
            message:    qsTr("You have changed the default altitude for mission items. Would you like to apply that altitude to all the items in the current mission?")
            function accept() {
                hideDialog()
132
                _missionController.applyDefaultMissionAltitude()
DonLakeFlyer's avatar
DonLakeFlyer committed
133 134 135 136
            }
        }
    }

137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
    Component {
        id: activeMissionUploadDialogComponent
        QGCViewDialog {
            Column {
                anchors.fill:   parent
                spacing:        ScreenTools.defaultFontPixelHeight
                QGCLabel {
                    width:      parent.width
                    wrapMode:   Text.WordWrap
                    text:       qsTr("Your vehicle is currently flying a mission. In order to upload a new or modified mission the current mission will be paused.")
                }
                QGCLabel {
                    width:      parent.width
                    wrapMode:   Text.WordWrap
                    text:       qsTr("After the mission is uploaded you can adjust the current waypoint and start the mission.")
                }
                QGCButton {
                    text:       qsTr("Pause and Upload")
                    onClicked: {
Gus Grubba's avatar
Gus Grubba committed
156
                        activeVehicle.flightMode = activeVehicle.pauseFlightMode
157
                        _planMasterController.sendToVehicle()
158
                        hideDialog()
159 160 161 162 163 164
                    }
                }
            }
        }
    }

Gus Grubba's avatar
Gus Grubba committed
165
    Connections {
166
        target: QGroundControl.airspaceManager
167
        onAirspaceVisibleChanged: {
168
            planControlColapsed = QGroundControl.airspaceManager.airspaceVisible
Gus Grubba's avatar
Gus Grubba committed
169 170 171
        }
    }

172 173 174 175 176 177 178
    Component {
        id: noItemForKML
        QGCViewMessage {
            message:    qsTr("You need at least one item to create a KML.")
        }
    }

179
    PlanMasterController {
Gus Grubba's avatar
Gus Grubba committed
180
        id: _planMasterController
181

182
        Component.onCompleted: {
183
            _planMasterController.start(false /* flyView */)
184
            _missionController.setCurrentPlanViewSeqNum(0, true)
Gus Grubba's avatar
Gus Grubba committed
185
            mainWindow.planMasterControllerPlan = _planMasterController
186 187
        }

188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
        function waitingOnIncompleteDataMessage(save) {
            var saveOrUpload = save ? qsTr("Save") : qsTr("Upload")
            mainWindow.showMessageDialog(qsTr("Unable to %1").arg(saveOrUpload), qsTr("Plan has incomplete items. Complete all items and %1 again.").arg(saveOrUpload))
        }

        function waitingOnTerrainDataMessage(save) {
            var saveOrUpload = save ? qsTr("Save") : qsTr("Upload")
            mainWindow.showMessageDialog(qsTr("Unable to %1").arg(saveOrUpload), qsTr("Plan is waiting on terrain data from server for correct altitude values."))
        }

        function checkReadyForSaveUpload(save) {
            if (readyForSaveState() == VisualMissionItem.NotReadyForSaveData) {
                waitingOnIncompleteDataMessage(save)
                return false
            } else if (readyForSaveState() == VisualMissionItem.NotReadyForSaveTerrain) {
                waitingOnTerrainDataMessage(save)
                return false
            }
            return true
207 208
        }

209
        function upload() {
210
            if (!checkReadyForSaveUpload(false /* save */)) {
211 212
                return
            }
Gus Grubba's avatar
Gus Grubba committed
213
            if (activeVehicle && activeVehicle.armed && activeVehicle.flightMode === activeVehicle.missionFlightMode) {
214
                mainWindow.showComponentDialog(activeMissionUploadDialogComponent, qsTr("Plan Upload"), mainWindow.showDialogDefaultWidth, StandardButton.Cancel)
215
            } else {
216 217
                sendToVehicle()
            }
DonLakeFlyer's avatar
DonLakeFlyer committed
218 219
        }

220
        function loadFromSelectedFile() {
221
            fileDialog.title =          qsTr("Select Plan File")
DonLakeFlyer's avatar
DonLakeFlyer committed
222
            fileDialog.planFiles =      true
223
            fileDialog.selectExisting = true
Gus Grubba's avatar
Gus Grubba committed
224
            fileDialog.nameFilters =    _planMasterController.loadNameFilters
225 226
            fileDialog.fileExtension =  _appSettings.planFileExtension
            fileDialog.fileExtension2 = _appSettings.missionFileExtension
227
            fileDialog.openForLoad()
228 229 230
        }

        function saveToSelectedFile() {
231
            if (!checkReadyForSaveUpload(true /* save */)) {
232 233
                return
            }
234
            fileDialog.title =          qsTr("Save Plan")
235
            fileDialog.planFiles =      true
236
            fileDialog.selectExisting = false
Gus Grubba's avatar
Gus Grubba committed
237
            fileDialog.nameFilters =    _planMasterController.saveNameFilters
238 239
            fileDialog.fileExtension =  _appSettings.planFileExtension
            fileDialog.fileExtension2 = _appSettings.missionFileExtension
240
            fileDialog.openForSave()
241 242
        }

243
        function fitViewportToItems() {
244
            mapFitFunctions.fitMapViewportToMissionItems()
245
        }
246 247

        function saveKmlToSelectedFile() {
248
            if (!checkReadyForSaveUpload(true /* save */)) {
249 250
                return
            }
251
            fileDialog.title =          qsTr("Save KML")
252
            fileDialog.planFiles =      false
253
            fileDialog.selectExisting = false
254 255
            fileDialog.nameFilters =    ShapeFileHelper.fileDialogKMLFilters
            fileDialog.fileExtension =  _appSettings.kmlFileExtension
256
            fileDialog.fileExtension2 = ""
257 258
            fileDialog.openForSave()
        }
259
    }
260

261 262
    Connections {
        target: _missionController
263

264
        onNewItemsFromVehicle: {
Gus Grubba's avatar
Gus Grubba committed
265
            if (_visualItems && _visualItems.count !== 1) {
266 267
                mapFitFunctions.fitMapViewportToMissionItems()
            }
268
            _missionController.setCurrentPlanViewSeqNum(0, true)
269 270
        }
    }
271

272 273 274 275 276 277 278 279 280
    function insertSimpleItemAfterCurrent(coordinate) {
        var nextIndex = _missionController.currentPlanViewVIIndex + 1
        _missionController.insertSimpleMissionItem(coordinate, nextIndex, true /* makeCurrentItem */)
    }

    function insertROIAfterCurrent(coordinate) {
        var nextIndex = _missionController.currentPlanViewVIIndex + 1
        _missionController.insertROIMissionItem(coordinate, nextIndex, true /* makeCurrentItem */)
        _addROIOnClick = false
281 282
    }

283 284 285
    function insertCancelROIAfterCurrent() {
        var nextIndex = _missionController.currentPlanViewVIIndex + 1
        _missionController.insertCancelROIMissionItem(nextIndex, true /* makeCurrentItem */)
286 287 288
        _addROIOnClick = false
    }

289 290 291 292 293
    function insertComplexItemAfterCurrent(complexItemName) {
        var nextIndex = _missionController.currentPlanViewVIIndex + 1
        _missionController.insertComplexMissionItem(complexItemName, mapCenter(), nextIndex, true /* makeCurrentItem */)
    }

294 295 296 297 298 299 300 301 302 303 304
    function insertTakeItemAfterCurrent() {
        var nextIndex = _missionController.currentPlanViewVIIndex + 1
        _missionController.insertTakeoffItem(mapCenter(), nextIndex, true /* makeCurrentItem */)
    }

    function insertLandItemAfterCurrent() {
        var nextIndex = _missionController.currentPlanViewVIIndex + 1
        _missionController.insertLandItem(mapCenter(), nextIndex, true /* makeCurrentItem */)
    }


305 306 307 308 309
    function selectNextNotReady() {
        var foundCurrent = false
        for (var i=0; i<_missionController.visualItems.count; i++) {
            var vmi = _missionController.visualItems.get(i)
            if (vmi.readyForSaveState === VisualMissionItem.NotReadyForSaveData) {
310
                _missionController.setCurrentPlanViewSeqNum(vmi.sequenceNumber, true)
311 312 313 314 315
                break
            }
        }
    }

316 317
    property int _moveDialogMissionItemIndex

318 319
    QGCFileDialog {
        id:             fileDialog
Gus Grubba's avatar
Gus Grubba committed
320
        folder:         _appSettings ? _appSettings.missionSavePath : ""
321

322 323
        property bool planFiles: true    ///< true: working with plan files, false: working with kml file

324
        onAcceptedForSave: {
325
            if (planFiles) {
Gus Grubba's avatar
Gus Grubba committed
326
                _planMasterController.saveToFile(file)
327
            } else {
Gus Grubba's avatar
Gus Grubba committed
328
                _planMasterController.saveToKml(file)
329
            }
330
            close()
331 332
        }

333
        onAcceptedForLoad: {
334 335 336
            _planMasterController.loadFromFile(file)
            _planMasterController.fitViewportToItems()
            _missionController.setCurrentPlanViewSeqNum(0, true)
337
            close()
338 339 340
        }
    }

341 342 343 344 345
    Component {
        id: moveDialog
        QGCViewDialog {
            function accept() {
                var toIndex = toCombo.currentIndex
Gus Grubba's avatar
Gus Grubba committed
346
                if (toIndex === 0) {
347 348
                    toIndex = 1
                }
349
                _missionController.moveMissionItem(_moveDialogMissionItemIndex, toIndex)
350 351 352 353 354 355 356 357 358 359 360
                hideDialog()
            }
            Column {
                anchors.left:   parent.left
                anchors.right:  parent.right
                spacing:        ScreenTools.defaultFontPixelHeight

                QGCLabel {
                    anchors.left:   parent.left
                    anchors.right:  parent.right
                    wrapMode:       Text.WordWrap
361
                    text:           qsTr("Move the selected mission item to the be after following mission item:")
362 363 364 365
                }

                QGCComboBox {
                    id:             toCombo
366
                    model:          _visualItems.count
367 368 369 370 371 372
                    currentIndex:   _moveDialogMissionItemIndex
                }
            }
        }
    }

373
    Item {
Don Gagne's avatar
Don Gagne committed
374
        id:             panel
375
        anchors.fill:   parent
Don Gagne's avatar
Don Gagne committed
376

377
        FlightMap {
378 379 380 381 382
            id:                         editorMap
            anchors.fill:               parent
            mapName:                    "MissionEditor"
            allowGCSLocationCenter:     true
            allowVehicleLocationCenter: true
383
            planView:                   true
Don Gagne's avatar
Don Gagne committed
384

385 386 387
            zoomLevel:                  QGroundControl.flightMapZoom
            center:                     QGroundControl.flightMapPosition

388
            // This is the center rectangle of the map which is not obscured by tools
389
            property rect centerViewport:   Qt.rect(_leftToolWidth + _margin, _toolsMargin, editorMap.width - _leftToolWidth - _rightToolWidth - (_margin * 2), mapScale.y - _margin - _toolsMargin)
390

391 392
            property real _leftToolWidth:       toolStrip.x + toolStrip.width
            property real _rightToolWidth:      rightPanel.width + rightPanel.anchors.rightMargin
393

394 395
            // Initial map position duplicates Fly view position
            Component.onCompleted: editorMap.center = QGroundControl.flightMapPosition
396

397 398
            QGCMapPalette { id: mapPal; lightColors: editorMap.isSatelliteMap }

399 400 401 402 403 404 405 406
            onZoomLevelChanged: {
                QGroundControl.flightMapZoom = zoomLevel
                updateAirspace(false)
            }
            onCenterChanged: {
                QGroundControl.flightMapPosition = center
                updateAirspace(false)
            }
407

408 409 410
            MouseArea {
                anchors.fill: parent
                onClicked: {
411 412
                    // Take focus to close any previous editing
                    editorMap.focus = true
413 414 415 416
                    var coordinate = editorMap.toCoordinate(Qt.point(mouse.x, mouse.y), false /* clipToViewPort */)
                    coordinate.latitude = coordinate.latitude.toFixed(_decimalPlaces)
                    coordinate.longitude = coordinate.longitude.toFixed(_decimalPlaces)
                    coordinate.altitude = coordinate.altitude.toFixed(_decimalPlaces)
417

418 419 420
                    switch (_editingLayer) {
                    case _layerMission:
                        if (_addWaypointOnClick) {
421
                            insertSimpleItemAfterCurrent(coordinate)
422 423
                        } else if (_addROIOnClick) {
                            _addROIOnClick = false
424
                            insertROIAfterCurrent(coordinate)
425
                        }
426

427 428
                        break
                    case _layerRallyPoints:
Gus Grubba's avatar
Gus Grubba committed
429
                        if (_rallyPointController.supported && _addWaypointOnClick) {
430
                            _rallyPointController.addPoint(coordinate)
431
                        }
432
                        break
Don Gagne's avatar
Don Gagne committed
433
                    }
Don Gagne's avatar
Don Gagne committed
434
                }
435
            }
Don Gagne's avatar
Don Gagne committed
436

437 438
            // Add the mission item visuals to the map
            Repeater {
439
                model: _editingLayer == _layerMission ? _missionController.visualItems : undefined
440 441
                delegate: MissionItemMapVisual {
                    map:        editorMap
442
                    onClicked:  _missionController.setCurrentPlanViewSeqNum(sequenceNumber, false)
443
                    visible:    _editingLayer == _layerMission
444
                }
445
            }
446

447 448
            // Add lines between waypoints
            MissionLineView {
449 450
                showSpecialVisual:  _missionController.isROIBeginCurrentItem
                model:              _editingLayer == _layerMission ? _missionController.waypointLines : undefined
451
            }
452

453
            // Direction arrows in waypoint lines
454 455 456 457 458 459
            MapItemView {
                model: _editingLayer == _layerMission ? _missionController.directionArrows : undefined

                delegate: MapLineArrow {
                    fromCoord:      object ? object.coordinate1 : undefined
                    toCoord:        object ? object.coordinate2 : undefined
460 461 462 463
                    arrowPosition:  3
                    z:              QGroundControl.zOrderWaypointLines + 1
                }
            }
464 465 466 467 468 469 470 471 472 473 474 475

            // Incomplete segment lines
            MapItemView {
                model: _editingLayer == _layerMission ? _missionController.incompleteComplexItemLines : undefined

                delegate: MapPolyline {
                    path:       [ object.coordinate1, object.coordinate2 ]
                    line.width: 1
                    line.color: "red"
                    z:          QGroundControl.zOrderWaypointLines
                }
            }
476 477 478 479 480 481 482

            // UI for splitting the current segment
            MapQuickItem {
                id:             splitSegmentItem
                anchorPoint.x:  sourceItem.width / 2
                anchorPoint.y:  sourceItem.height / 2
                z:              QGroundControl.zOrderWaypointLines + 1
483
                visible:        _editingLayer == _layerMission
484 485

                sourceItem: SplitIndicator {
486 487 488
                    onClicked:  _missionController.insertSimpleMissionItem(splitSegmentItem.coordinate,
                                                                           _missionController.currentPlanViewVIIndex,
                                                                           true /* makeCurrentItem */)
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509
                }

                function _updateSplitCoord() {
                    if (_missionController.splitSegment) {
                        var distance = _missionController.splitSegment.coordinate1.distanceTo(_missionController.splitSegment.coordinate2)
                        var azimuth = _missionController.splitSegment.coordinate1.azimuthTo(_missionController.splitSegment.coordinate2)
                        splitSegmentItem.coordinate = _missionController.splitSegment.coordinate1.atDistanceAndAzimuth(distance / 2, azimuth)
                    } else {
                        coordinate = QtPositioning.coordinate()
                    }
                }

                Connections {
                    target:                 _missionController
                    onSplitSegmentChanged:  splitSegmentItem._updateSplitCoord()
                }

                Connections {
                    target:                 _missionController.splitSegment
                    onCoordinate1Changed:   splitSegmentItem._updateSplitCoord()
                    onCoordinate2Changed:   splitSegmentItem._updateSplitCoord()
510 511 512
                }
            }

513 514 515 516 517 518 519
            // Add the vehicles to the map
            MapItemView {
                model: QGroundControl.multiVehicleManager.vehicles
                delegate:
                    VehicleMapItem {
                    vehicle:        object
                    coordinate:     object.coordinate
520
                    map:            editorMap
521 522
                    size:           ScreenTools.defaultFontPixelHeight * 3
                    z:              QGroundControl.zOrderMapItems - 1
523
                }
524
            }
525

526 527
            GeoFenceMapVisuals {
                map:                    editorMap
528
                myGeoFenceController:   _geoFenceController
529
                interactive:            _editingLayer == _layerGeoFence
530
                homePosition:           _missionController.plannedHomePosition
531 532
                planView:               true
            }
533

534 535
            RallyPointMapVisuals {
                map:                    editorMap
536
                myRallyPointController: _rallyPointController
537 538
                interactive:            _editingLayer == _layerRallyPoints
                planView:               true
539
            }
540

541 542
            // Airspace overlap support
            MapItemView {
543
                model:              _airspaceEnabled && QGroundControl.airspaceManager.airspaceVisible ? QGroundControl.airspaceManager.airspaces.circles : []
544 545 546
                delegate: MapCircle {
                    center:         object.center
                    radius:         object.radius
547
                    color:          object.color
Gus Grubba's avatar
Gus Grubba committed
548 549
                    border.color:   object.lineColor
                    border.width:   object.lineWidth
550 551 552 553
                }
            }

            MapItemView {
554
                model:              _airspaceEnabled && QGroundControl.airspaceManager.airspaceVisible ? QGroundControl.airspaceManager.airspaces.polygons : []
555 556
                delegate: MapPolygon {
                    path:           object.polygon
557
                    color:          object.color
Gus Grubba's avatar
Gus Grubba committed
558 559
                    border.color:   object.lineColor
                    border.width:   object.lineWidth
560 561
                }
            }
562
        }
563

564 565
        //-----------------------------------------------------------
        // Left tool strip
Gus Grubba's avatar
Gus Grubba committed
566
        ToolStrip {
567
            id:                 toolStrip
568
            anchors.margins:    _toolsMargin
569 570 571
            anchors.left:       parent.left
            anchors.top:        parent.top
            z:                  QGroundControl.zOrderWidgets
572
            maxHeight:          parent.height - toolStrip.y
573
            title:              qsTr("Plan")
574

575 576 577 578 579 580 581 582
            //readonly property int flyButtonIndex:       0
            readonly property int fileButtonIndex:      0
            readonly property int takeoffButtonIndex:   1
            readonly property int waypointButtonIndex:  2
            readonly property int roiButtonIndex:       3
            readonly property int patternButtonIndex:   4
            readonly property int landButtonIndex:      5
            readonly property int centerButtonIndex:    6
583

584 585
            property bool _isRallyLayer:    _editingLayer == _layerRallyPoints
            property bool _isMissionLayer:  _editingLayer == _layerMission
586

Gus Grubba's avatar
Gus Grubba committed
587
            model: [
588
                /*{
Gus Grubba's avatar
Gus Grubba committed
589 590 591 592
                    name:               qsTr("Fly"),
                    iconSource:         "/qmlimages/PaperPlane.svg",
                    buttonEnabled:      true,
                    buttonVisible:      true,
593
                },*/
594
                {
Gus Grubba's avatar
Gus Grubba committed
595 596 597 598 599 600 601 602
                    name:               qsTr("File"),
                    iconSource:         "/qmlimages/MapSync.svg",
                    buttonEnabled:      !_planMasterController.syncInProgress,
                    buttonVisible:      true,
                    showAlternateIcon:  _planMasterController.dirty,
                    alternateIconSource:"/qmlimages/MapSyncChanged.svg",
                    dropPanelComponent: syncDropPanel
                },
603 604 605 606
                {
                    name:               qsTr("Takeoff"),
                    iconSource:         "/res/takeoff.svg",
                    buttonEnabled:      _missionController.isInsertTakeoffValid,
607
                    buttonVisible:      _isMissionLayer
608
                },
Gus Grubba's avatar
Gus Grubba committed
609 610 611
                {
                    name:               _editingLayer == _layerRallyPoints ? qsTr("Rally Point") : qsTr("Waypoint"),
                    iconSource:         "/qmlimages/MapAddMission.svg",
612 613
                    buttonEnabled:      _isRallyLayer ? true : _missionController.flyThroughCommandsAllowed,
                    buttonVisible:      _isRallyLayer || _isMissionLayer,
Gus Grubba's avatar
Gus Grubba committed
614 615 616 617
                    toggle:             true,
                    checked:            _addWaypointOnClick
                },
                {
618
                    name:               _missionController.isROIActive ? qsTr("Cancel ROI") : qsTr("ROI"),
Gus Grubba's avatar
Gus Grubba committed
619
                    iconSource:         "/qmlimages/MapAddMission.svg",
620
                    buttonEnabled:      !_missionController.onlyInsertTakeoffValid,
621
                    buttonVisible:      _isMissionLayer && _planMasterController.controllerVehicle.roiModeSupported,
622
                    toggle:             !_missionController.isROIActive
Gus Grubba's avatar
Gus Grubba committed
623 624 625 626
                },
                {
                    name:               _singleComplexItem ? _missionController.complexMissionItemNames[0] : qsTr("Pattern"),
                    iconSource:         "/qmlimages/MapDrawShape.svg",
627 628
                    buttonEnabled:      _missionController.flyThroughCommandsAllowed,
                    buttonVisible:      _isMissionLayer,
Gus Grubba's avatar
Gus Grubba committed
629 630
                    dropPanelComponent: _singleComplexItem ? undefined : patternDropPanel
                },
631 632 633 634
                {
                    name:               _planMasterController.controllerVehicle.fixedWing ? qsTr("Land") : qsTr("Return"),
                    iconSource:         "/res/rtl.svg",
                    buttonEnabled:      _missionController.isInsertLandValid,
635
                    buttonVisible:      _isMissionLayer
636
                },
Gus Grubba's avatar
Gus Grubba committed
637 638 639 640 641 642 643 644
                {
                    name:               qsTr("Center"),
                    iconSource:         "/qmlimages/MapCenter.svg",
                    buttonEnabled:      true,
                    buttonVisible:      true,
                    dropPanelComponent: centerMapDropPanel
                }
            ]
645

646 647 648 649 650
            function allAddClickBoolsOff() {
                _addROIOnClick =        false
                _addWaypointOnClick =   false
            }

Gus Grubba's avatar
Gus Grubba committed
651 652
            onClicked: {
                switch (index) {
653
                /*case flyButtonIndex:
654
                    mainWindow.showFlyView()
655
                    break*/
656
                case takeoffButtonIndex:
657
                    allAddClickBoolsOff()
658
                    insertTakeItemAfterCurrent()
659 660
                    break
                case waypointButtonIndex:
661 662
                    if (_addWaypointOnClick) {
                        allAddClickBoolsOff()
Gus Grubba's avatar
Gus Grubba committed
663 664
                        setChecked(index, false)
                    } else {
665
                        allAddClickBoolsOff()
666
                        _addWaypointOnClick = checked
Gus Grubba's avatar
Gus Grubba committed
667 668
                    }
                    break
669
                case roiButtonIndex:
670 671 672
                    if (_addROIOnClick) {
                        allAddClickBoolsOff()
                        setChecked(index, false)
673
                    } else {
674 675 676 677 678 679
                        allAddClickBoolsOff()
                        if (_missionController.isROIActive) {
                            insertCancelROIAfterCurrent()
                        } else {
                            _addROIOnClick = checked
                        }
680
                    }
Gus Grubba's avatar
Gus Grubba committed
681
                    break
682
                case patternButtonIndex:
683
                    allAddClickBoolsOff()
Gus Grubba's avatar
Gus Grubba committed
684
                    if (_singleComplexItem) {
685
                        insertComplexItemAfterCurrent(_missionController.complexMissionItemNames[0])
Gus Grubba's avatar
Gus Grubba committed
686 687
                    }
                    break
688
                case landButtonIndex:
689
                    allAddClickBoolsOff()
690
                    insertLandItemAfterCurrent()
691
                    break
692 693
                }
            }
694 695 696 697

            onDropped: {
                allAddClickBoolsOff()
            }
Gus Grubba's avatar
Gus Grubba committed
698
        }
699

Gus Grubba's avatar
Gus Grubba committed
700
        //-----------------------------------------------------------
701 702 703
        // Right pane for mission editing controls
        Rectangle {
            id:                 rightPanel
704
            height:             parent.height
705 706
            width:              _rightPanelWidth
            color:              qgcPal.window
707
            opacity:            planExpanded.visible ? 0.2 : 0
Gus Grubba's avatar
Gus Grubba committed
708 709
            anchors.bottom:     parent.bottom
            anchors.right:      parent.right
710
            anchors.rightMargin: _toolsMargin
711
        }
Gus Grubba's avatar
Gus Grubba committed
712 713
        //-------------------------------------------------------
        // Right Panel Controls
714
        Item {
Gus Grubba's avatar
Gus Grubba committed
715
            anchors.fill:           rightPanel
716
            anchors.topMargin:      _toolsMargin
Gus Grubba's avatar
Gus Grubba committed
717 718 719
            DeadMouseArea {
                anchors.fill:   parent
            }
Gus Grubba's avatar
Gus Grubba committed
720 721
            Column {
                id:                 rightControls
Gus Grubba's avatar
Gus Grubba committed
722
                spacing:            ScreenTools.defaultFontPixelHeight * 0.5
723 724
                anchors.left:       parent.left
                anchors.right:      parent.right
Gus Grubba's avatar
Gus Grubba committed
725 726 727 728
                anchors.top:        parent.top
                //-------------------------------------------------------
                // Airmap Airspace Control
                AirspaceControl {
Gus Grubba's avatar
Gus Grubba committed
729 730
                    id:             airspaceControl
                    width:          parent.width
731
                    visible:        _airspaceEnabled
732
                    planView:       true
733
                    showColapse:    true
734
                }
Gus Grubba's avatar
Gus Grubba committed
735 736 737 738
                //-------------------------------------------------------
                // Mission Controls (Colapsed)
                Rectangle {
                    width:      parent.width
Gus Grubba's avatar
Gus Grubba committed
739
                    height:     planControlColapsed ? colapsedRow.height + ScreenTools.defaultFontPixelHeight : 0
Gus Grubba's avatar
Gus Grubba committed
740 741
                    color:      qgcPal.missionItemEditor
                    radius:     _radius
742
                    visible:    planControlColapsed && _airspaceEnabled
Gus Grubba's avatar
Gus Grubba committed
743 744 745 746 747 748 749
                    Row {
                        id:                     colapsedRow
                        spacing:                ScreenTools.defaultFontPixelWidth
                        anchors.left:           parent.left
                        anchors.leftMargin:     ScreenTools.defaultFontPixelWidth
                        anchors.verticalCenter: parent.verticalCenter
                        QGCColoredImage {
750 751 752 753 754
                            width:              height
                            height:             ScreenTools.defaultFontPixelWidth * 2.5
                            sourceSize.height:  height
                            source:             "qrc:/res/waypoint.svg"
                            color:              qgcPal.text
Gus Grubba's avatar
Gus Grubba committed
755 756 757
                            anchors.verticalCenter: parent.verticalCenter
                        }
                        QGCLabel {
758 759
                            text:               qsTr("Plan")
                            color:              qgcPal.text
Gus Grubba's avatar
Gus Grubba committed
760
                            anchors.verticalCenter: parent.verticalCenter
761 762
                        }
                    }
Gus Grubba's avatar
Gus Grubba committed
763 764 765 766
                    QGCColoredImage {
                        width:                  height
                        height:                 ScreenTools.defaultFontPixelWidth * 2.5
                        sourceSize.height:      height
767
                        source:                 QGroundControl.airmapSupported ? "qrc:/airmap/expand.svg" : ""
768
                        color:                  "white"
769
                        visible:                QGroundControl.airmapSupported
Gus Grubba's avatar
Gus Grubba committed
770 771 772 773 774 775
                        anchors.right:          parent.right
                        anchors.rightMargin:    ScreenTools.defaultFontPixelWidth
                        anchors.verticalCenter: parent.verticalCenter
                    }
                    MouseArea {
                        anchors.fill:   parent
776
                        enabled:        QGroundControl.airmapSupported
Gus Grubba's avatar
Gus Grubba committed
777
                        onClicked: {
778
                            QGroundControl.airspaceManager.airspaceVisible = false
Gus Grubba's avatar
Gus Grubba committed
779 780
                        }
                    }
Gus Grubba's avatar
Gus Grubba committed
781
                }
Gus Grubba's avatar
Gus Grubba committed
782 783 784 785 786
                //-------------------------------------------------------
                // Mission Controls (Expanded)
                Rectangle {
                    id:         planExpanded
                    width:      parent.width
Gus Grubba's avatar
Gus Grubba committed
787
                    height:     (!planControlColapsed || !_airspaceEnabled) ? bar.height + ScreenTools.defaultFontPixelHeight : 0
Gus Grubba's avatar
Gus Grubba committed
788 789
                    color:      qgcPal.missionItemEditor
                    radius:     _radius
Gus Grubba's avatar
Gus Grubba committed
790
                    visible:    (!planControlColapsed || !_airspaceEnabled) && QGroundControl.corePlugin.options.enablePlanViewSelector
Gus Grubba's avatar
Gus Grubba committed
791
                    Item {
Gus Grubba's avatar
Gus Grubba committed
792
                        height:             bar.height
Gus Grubba's avatar
Gus Grubba committed
793 794
                        anchors.left:       parent.left
                        anchors.right:      parent.right
Gus Grubba's avatar
Gus Grubba committed
795
                        anchors.margins:    ScreenTools.defaultFontPixelWidth
Gus Grubba's avatar
Gus Grubba committed
796
                        anchors.verticalCenter: parent.verticalCenter
Gus Grubba's avatar
Gus Grubba committed
797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813
                        QGCTabBar {
                            id:             bar
                            width:          parent.width
                            anchors.centerIn: parent
                            Component.onCompleted: {
                                currentIndex = 0
                            }
                            QGCTabButton {
                                text:       qsTr("Mission")
                            }
                            QGCTabButton {
                                text:       qsTr("Fence")
                                enabled:    _geoFenceController.supported
                            }
                            QGCTabButton {
                                text:       qsTr("Rally")
                                enabled:    _rallyPointController.supported
Gus Grubba's avatar
Gus Grubba committed
814 815 816 817 818 819 820 821 822 823 824 825
                            }
                        }
                    }
                }
            }
            //-------------------------------------------------------
            // Mission Item Editor
            Item {
                id:                     missionItemEditor
                anchors.left:           parent.left
                anchors.right:          parent.right
                anchors.top:            rightControls.bottom
Gus Grubba's avatar
Gus Grubba committed
826
                anchors.topMargin:      ScreenTools.defaultFontPixelHeight * 0.25
Gus Grubba's avatar
Gus Grubba committed
827 828 829 830
                anchors.bottom:         parent.bottom
                anchors.bottomMargin:   ScreenTools.defaultFontPixelHeight * 0.25
                visible:                _editingLayer == _layerMission && !planControlColapsed
                QGCListView {
Gus Grubba's avatar
Gus Grubba committed
831 832 833 834 835 836 837
                    id:                 missionItemEditorListView
                    anchors.fill:       parent
                    spacing:            ScreenTools.defaultFontPixelHeight / 4
                    orientation:        ListView.Vertical
                    model:              _missionController.visualItems
                    cacheBuffer:        Math.max(height * 2, 0)
                    clip:               true
838
                    currentIndex:       _missionController.currentPlanViewSeqNum
Gus Grubba's avatar
Gus Grubba committed
839
                    highlightMoveDuration: 250
Gus Grubba's avatar
Gus Grubba committed
840
                    visible:            _editingLayer == _layerMission && !planControlColapsed
Gus Grubba's avatar
Gus Grubba committed
841 842
                    //-- List Elements
                    delegate: MissionItemEditor {
Gus Grubba's avatar
Gus Grubba committed
843
                        map:            editorMap
Gus Grubba's avatar
Gus Grubba committed
844
                        masterController:  _planMasterController
Gus Grubba's avatar
Gus Grubba committed
845 846 847
                        missionItem:    object
                        width:          parent.width
                        readOnly:       false
848
                        onClicked:      _missionController.setCurrentPlanViewSeqNum(object.sequenceNumber, false)
Gus Grubba's avatar
Gus Grubba committed
849
                        onRemove: {
850 851 852 853
                            var removeVIIndex = index
                            _missionController.removeMissionItem(removeVIIndex)
                            if (removeVIIndex >= _missionController.visualItems.count) {
                                removeVIIndex--
Gus Grubba's avatar
Gus Grubba committed
854 855
                            }
                        }
856
                        onSelectNextNotReadyItem:   selectNextNotReady()
Gus Grubba's avatar
Gus Grubba committed
857 858 859 860 861 862
                    }
                }
            }
            // GeoFence Editor
            GeoFenceEditor {
                anchors.top:            rightControls.bottom
Gus Grubba's avatar
Gus Grubba committed
863
                anchors.topMargin:      ScreenTools.defaultFontPixelHeight * 0.25
Don Gagne's avatar
Don Gagne committed
864
                anchors.bottom:         parent.bottom
Gus Grubba's avatar
Gus Grubba committed
865 866 867 868 869 870 871 872 873 874
                anchors.left:           parent.left
                anchors.right:          parent.right
                myGeoFenceController:   _geoFenceController
                flightMap:              editorMap
                visible:                _editingLayer == _layerGeoFence
            }
            // Rally Point Editor
            RallyPointEditorHeader {
                id:                     rallyPointHeader
                anchors.top:            rightControls.bottom
Gus Grubba's avatar
Gus Grubba committed
875
                anchors.topMargin:      ScreenTools.defaultFontPixelHeight * 0.25
Gus Grubba's avatar
Gus Grubba committed
876 877 878 879 880 881 882 883
                anchors.left:           parent.left
                anchors.right:          parent.right
                visible:                _editingLayer == _layerRallyPoints
                controller:             _rallyPointController
            }
            RallyPointItemEditor {
                id:                     rallyPointEditor
                anchors.top:            rallyPointHeader.bottom
Gus Grubba's avatar
Gus Grubba committed
884
                anchors.topMargin:      ScreenTools.defaultFontPixelHeight * 0.25
Gus Grubba's avatar
Gus Grubba committed
885 886 887 888 889
                anchors.left:           parent.left
                anchors.right:          parent.right
                visible:                _editingLayer == _layerRallyPoints && _rallyPointController.points.count
                rallyPoint:             _rallyPointController.currentRallyPoint
                controller:             _rallyPointController
890
            }
Gus Grubba's avatar
Gus Grubba committed
891
        }
892 893 894

        MissionItemStatus {
            id:                 waypointValuesDisplay
895 896 897
            anchors.margins:    _toolsMargin
            anchors.left:       toolStrip.right
            anchors.bottom:     mapScale.top
898
            height:             ScreenTools.defaultFontPixelHeight * 7
899
            maxWidth:           rightPanel.x - x - anchors.margins
900
            missionItems:       _missionController.visualItems
901
            visible:            _internalVisible && _editingLayer === _layerMission && QGroundControl.corePlugin.options.showMissionStatus
902

903 904
            onSetCurrentSeqNum: _missionController.setCurrentPlanViewSeqNum(seqNum, true)

905
            property bool _internalVisible: _planViewSettings.showMissionItemStatus.rawValue
906 907 908

            function toggleVisible() {
                _internalVisible = !_internalVisible
909
                _planViewSettings.showMissionItemStatus.rawValue = _internalVisible
910
            }
911
        }
912 913 914 915 916 917 918 919 920 921 922 923 924


        MapScale {
            id:                     mapScale
            anchors.margins:        _toolsMargin
            anchors.bottom:         parent.bottom
            anchors.left:           toolStrip.right
            mapControl:             editorMap
            buttonsOnLeft:          true
            terrainButtonVisible:   _editingLayer === _layerMission
            terrainButtonChecked:   waypointValuesDisplay.visible
            onTerrainButtonClicked: waypointValuesDisplay.toggleVisible()
        }
Gus Grubba's avatar
Gus Grubba committed
925
    }
926

927 928 929 930
    Component {
        id: syncLoadFromVehicleOverwrite
        QGCViewMessage {
            id:         syncLoadFromVehicleCheck
Don Gagne's avatar
Don Gagne committed
931
            message:   qsTr("You have unsaved/unsent changes. Loading from the Vehicle will lose these changes. Are you sure you want to load from the Vehicle?")
932 933
            function accept() {
                hideDialog()
Gus Grubba's avatar
Gus Grubba committed
934
                _planMasterController.loadFromVehicle()
935 936 937 938 939 940 941 942
            }
        }
    }

    Component {
        id: syncLoadFromFileOverwrite
        QGCViewMessage {
            id:         syncLoadFromVehicleCheck
DonLakeFlyer's avatar
DonLakeFlyer committed
943
            message:   qsTr("You have unsaved/unsent changes. Loading from a file will lose these changes. Are you sure you want to load from a file?")
944 945
            function accept() {
                hideDialog()
Gus Grubba's avatar
Gus Grubba committed
946
                _planMasterController.loadFromSelectedFile()
947 948 949 950
            }
        }
    }

951 952
    property var createPlanRemoveAllPromptDialogMapCenter
    property var createPlanRemoveAllPromptDialogPlanCreator
953
    Component {
954
        id: createPlanRemoveAllPromptDialog
955
        QGCViewMessage {
956
            message: qsTr("Are you sure you want to remove current plan and create a new plan? ")
957
            function accept() {
958
                createPlanRemoveAllPromptDialogPlanCreator.createPlan(createPlanRemoveAllPromptDialogMapCenter)
959 960 961 962 963
                hideDialog()
            }
        }
    }

964 965 966 967 968
    Component {
        id: clearVehicleMissionDialog
        QGCViewMessage {
            message: qsTr("Are you sure you want to remove all mission items and clear the mission from the vehicle?")
            function accept() {
Gus Grubba's avatar
Gus Grubba committed
969
                _planMasterController.removeAllFromVehicle()
970
                _missionController.setCurrentPlanViewSeqNum(0, true)
971 972 973 974 975
                hideDialog()
            }
        }
    }

976 977 978 979 980 981 982 983 984 985 986
    //- ToolStrip DropPanel Components

    Component {
        id: centerMapDropPanel

        CenterMapDropPanel {
            map:            editorMap
            fitFunctions:   mapFitFunctions
        }
    }

987 988 989 990 991 992 993 994 995
    Component {
        id: patternDropPanel

        ColumnLayout {
            spacing:    ScreenTools.defaultFontPixelWidth * 0.5

            QGCLabel { text: qsTr("Create complex pattern:") }

            Repeater {
996
                model: _missionController.complexMissionItemNames
997 998 999 1000 1001 1002

                QGCButton {
                    text:               modelData
                    Layout.fillWidth:   true

                    onClicked: {
1003
                        insertComplexItemAfterCurrent(modelData)
1004 1005 1006 1007 1008 1009
                        dropPanel.hide()
                    }
                }
            }
        } // Column
    }
1010 1011

    Component {
1012
        id: syncDropPanel
1013

1014
        ColumnLayout {
1015 1016
            id:         columnHolder
            spacing:    _margin
1017

1018
            property string _overwriteText: (_editingLayer == _layerMission) ? qsTr("Mission overwrite") : ((_editingLayer == _layerGeoFence) ? qsTr("GeoFence overwrite") : qsTr("Rally Points overwrite"))
1019

1020
            QGCLabel {
1021
                id:                 unsavedChangedLabel
1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033
                Layout.fillWidth:   true
                wrapMode:           Text.WordWrap
                text:               activeVehicle ?
                                        qsTr("You have unsaved changes. You should upload to your vehicle, or save to a file.") :
                                        qsTr("You have unsaved changes.")
                visible:            _planMasterController.dirty
            }

            SectionHeader {
                id:                 createSection
                Layout.fillWidth:   true
                text:               qsTr("Create Plan")
1034
                showSpacer:         false
1035 1036
            }

1037 1038
            GridLayout {
                columns:            2
1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108
                columnSpacing:      _margin
                rowSpacing:         _margin
                Layout.fillWidth:   true
                visible:            createSection.visible

                Repeater {
                    model: _planMasterController.planCreators

                    Rectangle {
                        id:     button
                        width:  ScreenTools.defaultFontPixelHeight * 7
                        height: planCreatorNameLabel.y + planCreatorNameLabel.height
                        color:  button.pressed || button.highlighted ? qgcPal.buttonHighlight : qgcPal.button

                        property bool highlighted: mouseArea.containsMouse
                        property bool pressed:     mouseArea.pressed

                        Image {
                            id:                 planCreatorImage
                            anchors.left:       parent.left
                            anchors.right:      parent.right
                            source:             object.imageResource
                            sourceSize.width:   width
                            fillMode:           Image.PreserveAspectFit
                            mipmap:             true
                        }

                        QGCLabel {
                            id:                     planCreatorNameLabel
                            anchors.top:            planCreatorImage.bottom
                            anchors.left:           parent.left
                            anchors.right:          parent.right
                            horizontalAlignment:    Text.AlignHCenter
                            text:                   object.name
                            color:                  button.pressed || button.highlighted ? qgcPal.buttonHighlightText : qgcPal.buttonText
                        }

                        QGCMouseArea {
                            id:                 mouseArea
                            anchors.fill:       parent
                            hoverEnabled:       true
                            preventStealing:    true
                            onClicked:          {
                                if (_planMasterController.containsItems) {
                                    createPlanRemoveAllPromptDialogMapCenter = _mapCenter()
                                    createPlanRemoveAllPromptDialogPlanCreator = object
                                    mainWindow.showComponentDialog(createPlanRemoveAllPromptDialog, qsTr("Create Plan"), mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.No)
                                } else {
                                    object.createPlan(_mapCenter())
                                }
                                dropPanel.hide()
                            }

                            function _mapCenter() {
                                var centerPoint = Qt.point(editorMap.centerViewport.left + (editorMap.centerViewport.width / 2), editorMap.centerViewport.top + (editorMap.centerViewport.height / 2))
                                return editorMap.toCoordinate(centerPoint, false /* clipToViewPort */)
                            }
                        }
                    }
                }
            }

            SectionHeader {
                id:                 storageSection
                Layout.fillWidth:   true
                text:               qsTr("Storage")
            }

            GridLayout {
                columns:            3
1109 1110
                rowSpacing:         _margin
                columnSpacing:      ScreenTools.defaultFontPixelWidth
1111
                visible:            storageSection.visible
1112

1113
                /*QGCButton {
1114
                    text:               qsTr("New...")
1115
                    Layout.fillWidth:   true
1116
                    onClicked:  {
1117
                        dropPanel.hide()
1118 1119 1120
                        if (_planMasterController.containsItems) {
                            mainWindow.showComponentDialog(removeAllPromptDialog, qsTr("New Plan"), mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.No)
                        }
1121
                    }
1122
                }*/
1123

1124
                QGCButton {
1125
                    text:               qsTr("Open...")
1126
                    Layout.fillWidth:   true
Gus Grubba's avatar
Gus Grubba committed
1127
                    enabled:            !_planMasterController.syncInProgress
1128 1129
                    onClicked: {
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1130
                        if (_planMasterController.dirty) {
1131
                            mainWindow.showComponentDialog(syncLoadFromFileOverwrite, columnHolder._overwriteText, mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.Cancel)
1132
                        } else {
Gus Grubba's avatar
Gus Grubba committed
1133
                            _planMasterController.loadFromSelectedFile()
1134 1135 1136
                        }
                    }
                }
1137

1138
                QGCButton {
1139
                    text:               qsTr("Save")
1140
                    Layout.fillWidth:   true
Gus Grubba's avatar
Gus Grubba committed
1141
                    enabled:            !_planMasterController.syncInProgress && _planMasterController.currentPlanFile !== ""
1142 1143
                    onClicked: {
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1144 1145
                        if(_planMasterController.currentPlanFile !== "") {
                            _planMasterController.saveToCurrent()
1146
                        } else {
Gus Grubba's avatar
Gus Grubba committed
1147
                            _planMasterController.saveToSelectedFile()
1148
                        }
1149 1150 1151 1152
                    }
                }

                QGCButton {
1153
                    text:               qsTr("Save As...")
1154
                    Layout.fillWidth:   true
1155
                    enabled:            !_planMasterController.syncInProgress && _planMasterController.containsItems
1156 1157
                    onClicked: {
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1158
                        _planMasterController.saveToSelectedFile()
1159 1160 1161 1162
                    }
                }

                QGCButton {
1163 1164
                    Layout.columnSpan:  3
                    Layout.fillWidth:   true
1165
                    text:               qsTr("Save Mission Waypoints As KML...")
Gus Grubba's avatar
Gus Grubba committed
1166
                    enabled:            !_planMasterController.syncInProgress && _visualItems.count > 1
1167
                    onClicked: {
1168
                        // First point does not count
1169
                        if (_visualItems.count < 2) {
1170
                            mainWindow.showComponentDialog(noItemForKML, qsTr("KML"), mainWindow.showDialogDefaultWidth, StandardButton.Cancel)
1171 1172
                            return
                        }
1173
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1174
                        _planMasterController.saveKmlToSelectedFile()
1175 1176
                    }
                }
1177
            }
1178

1179 1180 1181 1182 1183 1184 1185 1186 1187 1188
            SectionHeader {
                id:                 vehicleSection
                Layout.fillWidth:   true
                text:               qsTr("Vehicle")
            }

            RowLayout {
                Layout.fillWidth:   true
                spacing:            _margin
                visible:            vehicleSection.visible
1189

1190
                QGCButton {
1191
                    text:               qsTr("Upload")
1192
                    Layout.fillWidth:   true
1193
                    enabled:            !_planMasterController.offline && !_planMasterController.syncInProgress && _planMasterController.containsItems
1194 1195
                    visible:            !QGroundControl.corePlugin.options.disableVehicleConnection
                    onClicked: {
1196
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1197
                        _planMasterController.upload()
1198 1199
                    }
                }
1200 1201 1202 1203

                QGCButton {
                    text:               qsTr("Download")
                    Layout.fillWidth:   true
Gus Grubba's avatar
Gus Grubba committed
1204
                    enabled:            !_planMasterController.offline && !_planMasterController.syncInProgress
1205 1206 1207
                    visible:            !QGroundControl.corePlugin.options.disableVehicleConnection
                    onClicked: {
                        dropPanel.hide()
Gus Grubba's avatar
Gus Grubba committed
1208
                        if (_planMasterController.dirty) {
1209
                            mainWindow.showComponentDialog(syncLoadFromVehicleOverwrite, columnHolder._overwriteText, mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.Cancel)
1210
                        } else {
Gus Grubba's avatar
Gus Grubba committed
1211
                            _planMasterController.loadFromVehicle()
1212 1213 1214 1215 1216
                        }
                    }
                }

                QGCButton {
1217
                    text:               qsTr("Clear")
1218 1219
                    Layout.fillWidth:   true
                    Layout.columnSpan:  2
Gus Grubba's avatar
Gus Grubba committed
1220
                    enabled:            !_planMasterController.offline && !_planMasterController.syncInProgress
1221 1222 1223
                    visible:            !QGroundControl.corePlugin.options.disableVehicleConnection
                    onClicked: {
                        dropPanel.hide()
1224
                        mainWindow.showComponentDialog(clearVehicleMissionDialog, text, mainWindow.showDialogDefaultWidth, StandardButton.Yes | StandardButton.Cancel)
1225 1226
                    }
                }
1227
            }
1228 1229
        }
    }
Gus Grubba's avatar
Gus Grubba committed
1230
}