WimaPlanMapItems.qml 3.91 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * 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

// Adds visual items generated by wima planer to the map.
Item {
    id: _root

22 23 24 25 26 27 28
    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        wimaController
    property string     mIColor: "#B4808080" // Mission Items Color, gray with alpha 0.7 #AARRGGBB
    property string     mIlineColor: mIColor
    property string     cMIColor: "orangered" // Current Mission Items Color
    property string     cMIlineColor: cMIColor
29

30
    property var    _map: map
31
    property var    _missionLineViewComponent
32
    property var    _currentMissionLineViewComponent
33

34 35
    property bool _showAllItems:        wimaController.showAllMissionItems.value
    property bool _showCurrentItems:    wimaController.showCurrentMissionItems.value
36
    property bool _wimaEnabled:         wimaController.enableWimaController.value
37

38
    // Add the mission item visuals to the map
39
    Repeater {        
40
        model: largeMapView ? (_showAllItems ? (_wimaEnabled ? wimaController.missionItems : 0) : 0) : 0
41
        z:          QGroundControl.zOrderWaypointIndicators-2
42

43
        delegate: WimaMissionItemMapVisual {
44
            map:        _map
45
            color:     _root.mIColor
46 47 48 49 50 51
//            onClicked: {
//                if (isActiveVehicle) {
//                    // Only active vehicle supports click to change current mission item
//                    guidedActionsController.confirmAction(guidedActionsController.actionSetWaypoint, Math.max(object.sequenceNumber, 1))
//                }
//            }
52 53 54
        }
    }

55 56
    // Add the current mission item visuals to the map
    Repeater {
57
        model: largeMapView ? (_showCurrentItems ? (_wimaEnabled ? wimaController.currentMissionItems :0 ) : 0) : 0
58
        z:          QGroundControl.zOrderWaypointIndicators-1
59 60 61 62 63 64 65

        delegate: WimaMissionItemMapVisual {
            map:        _map
            color:     _root.cMIColor
        }
    }

66

67 68 69 70 71
    Component.onCompleted: {
        _missionLineViewComponent = missionLineViewComponent.createObject(map)
        if (_missionLineViewComponent.status === Component.Error)
            console.log(_missionLineViewComponent.errorString())
        map.addMapItem(_missionLineViewComponent)
72 73 74 75 76

        _currentMissionLineViewComponent = currentMissionLineViewComponent.createObject(map)
        if (_currentMissionLineViewComponent.status === Component.Error)
            console.log(_currentMissionLineViewComponent.errorString())
        map.addMapItem(_currentMissionLineViewComponent)
77 78 79 80
    }

    Component.onDestruction: {
        _missionLineViewComponent.destroy()
81
        _currentMissionLineViewComponent.destroy()
82 83 84 85 86 87 88
    }

    Component {
        id: missionLineViewComponent

        MapPolyline {
            line.width: 3
89
            line.color: _showAllItems ? (_wimaEnabled ? mIlineColor  : "transparent"): "transparent"
90
            z:          QGroundControl.zOrderWaypointLines-2
91
            path:       wimaController.waypointPath
92 93
        }
    }
94 95 96 97 98 99

    Component {
        id: currentMissionLineViewComponent

        MapPolyline {
            line.width: 3
100
            line.color: _showCurrentItems ? (_wimaEnabled ? cMIlineColor : "transparent") : "transparent"
101
            z:          QGroundControl.zOrderWaypointLines-1
102 103 104
            path:       wimaController.currentWaypointPath
        }
    }
105
}