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

import QtQuick          2.3
import QtLocation       5.3
import QtPositioning    5.3

import QGroundControl           1.0
import QGroundControl.Controls  1.0
import QGroundControl.FlightMap 1.0

18 19
// Adds visual items associated with the Flight Plan to the map.
// Currently only used by Fly View even though it's called PlanMapItems!
Don Gagne's avatar
Don Gagne committed
20 21 22
Item {
    id: _root

23 24 25 26
    property var    map                     ///< Map control to show items on
    property bool   largeMapView            ///< true: map takes up entire view, false: map is in small window
    property var    planMasterController    ///< Reference to PlanMasterController for vehicle
    property var    vehicle                 ///< Vehicle associated with these items
Don Gagne's avatar
Don Gagne committed
27 28

    property var    _map:                       map
29
    property var    _vehicle:                   vehicle
Don Gagne's avatar
Don Gagne committed
30 31 32
    property var    _missionController:         masterController.missionController
    property var    _geoFenceController:        masterController.geoFenceController
    property var    _rallyPointController:      masterController.rallyPointController
33
    property var    _guidedController:          globals.guidedControllerFlyView
Don Gagne's avatar
Don Gagne committed
34
    property var    _missionLineViewComponent
35 36 37
    property bool   _isActiveVehicle:           vehicle.active

    property string fmode: vehicle.flightMode
Don Gagne's avatar
Don Gagne committed
38 39 40

    // Add the mission item visuals to the map
    Repeater {
41
        model: _isActiveVehicle && largeMapView ? _missionController.visualItems : 0
Don Gagne's avatar
Don Gagne committed
42 43 44

        delegate: MissionItemMapVisual {
            map:        _map
45
            vehicle:    _vehicle
46
            onClicked:  _guidedController.confirmAction(_guidedController.actionSetWaypoint, Math.max(object.sequenceNumber, 1))
Don Gagne's avatar
Don Gagne committed
47 48 49
        }
    }

50 51 52 53 54 55
    Component.onCompleted: {
        _missionLineViewComponent = missionLineViewComponent.createObject(map)
        if (_missionLineViewComponent.status === Component.Error)
            console.log(_missionLineViewComponent.errorString())
        map.addMapItem(_missionLineViewComponent)
    }
Don Gagne's avatar
Don Gagne committed
56

57 58
    Component.onDestruction: {
        _missionLineViewComponent.destroy()
Don Gagne's avatar
Don Gagne committed
59 60 61 62 63 64 65 66 67
    }

    Component {
        id: missionLineViewComponent

        MapPolyline {
            line.width: 3
            line.color: "#be781c"                           // Hack, can't get palette to work in here
            z:          QGroundControl.zOrderWaypointLines
68
            path:       _missionController.waypointPath
Don Gagne's avatar
Don Gagne committed
69 70 71
        }
    }
}