SurveyMapVisual.qml 3.08 KB
Newer Older
1 2 3 4 5 6 7 8 9
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/

10 11 12 13
import QtQuick          2.3
import QtQuick.Controls 1.2
import QtLocation       5.3
import QtPositioning    5.3
14

15
import QGroundControl               1.0
16 17 18 19 20 21 22 23
import QGroundControl.ScreenTools   1.0
import QGroundControl.Palette       1.0
import QGroundControl.Controls      1.0

/// Survey Complex Mission Item visuals
Item {
    property var map    ///< Map control to place item in

24
    property var _missionItem:  object
25 26
    property var _polygon
    property var _grid
27 28
    property var _entryCoordinate
    property var _exitCoordinate
29 30 31 32

    Component.onCompleted: {
        _polygon = polygonComponent.createObject(map)
        _grid = gridComponent.createObject(map)
33 34
        _entryCoordinate = entryPointComponent.createObject(map)
        _exitCoordinate = exitPointComponent.createObject(map)
35 36
        map.addMapItem(_polygon)
        map.addMapItem(_grid)
37 38
        map.addMapItem(_entryCoordinate)
        map.addMapItem(_exitCoordinate)
39 40 41 42 43
    }

    Component.onDestruction: {
        _polygon.destroy()
        _grid.destroy()
44 45
        _entryCoordinate.destroy()
        _exitCoordinate.destroy()
46 47 48 49 50 51 52 53 54
    }

    // Survey area polygon
    Component {
        id: polygonComponent

        MapPolygon {
            color: "green"
            opacity:    0.5
55
            path:       _missionItem.polygonPath
56 57 58 59 60 61 62 63 64 65
        }
    }

    // Survey grid lines
    Component {
        id: gridComponent

        MapPolyline {
            line.color: "white"
            line.width: 2
66 67 68 69 70 71 72 73 74
            path:       _missionItem.gridPoints
        }
    }

    // Entry point
    Component {
        id: entryPointComponent

        MapQuickItem {
75 76
            anchorPoint.x:  sourceItem.anchorPointX
            anchorPoint.y:  sourceItem.anchorPointY
77 78
            z:              QGroundControl.zOrderMapItems
            coordinate:     _missionItem.coordinate
79
            visible:        _missionItem.exitCoordinate.isValid
80 81 82

            sourceItem:
                MissionItemIndexLabel {
83 84 85 86
                label:      "Entry"
                checked:    _missionItem.isCurrentItem

                onClicked: setCurrentItem(_missionItem.sequenceNumber)
87 88 89 90 91 92 93 94 95
            }
        }
    }

    // Exit point
    Component {
        id: exitPointComponent

        MapQuickItem {
96 97
            anchorPoint.x:  sourceItem.anchorPointX
            anchorPoint.y:  sourceItem.anchorPointY
98 99
            z:              QGroundControl.zOrderMapItems
            coordinate:     _missionItem.exitCoordinate
100
            visible:        _missionItem.exitCoordinate.isValid
101 102 103

            sourceItem:
                MissionItemIndexLabel {
104 105 106 107
                label:      "Exit"
                checked:    _missionItem.isCurrentItem

                onClicked: setCurrentItem(_missionItem.sequenceNumber)
108
            }
109 110 111
        }
    }
}