SurveyMapVisual.qml 2.95 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
/****************************************************************************
 *
 *   (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.2
import QtQuick.Controls 1.2
import QtLocation       5.3
import QtPositioning    5.2

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 79 80 81
            z:              QGroundControl.zOrderMapItems
            coordinate:     _missionItem.coordinate

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

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

    // Exit point
    Component {
        id: exitPointComponent

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

            sourceItem:
                MissionItemIndexLabel {
102 103 104 105
                label:      "Exit"
                checked:    _missionItem.isCurrentItem

                onClicked: setCurrentItem(_missionItem.sequenceNumber)
106
            }
107 108 109
        }
    }
}