SafeAreaMapVisual.qml 2.59 KB
Newer Older
Valentin Platzgummer's avatar
Valentin Platzgummer committed
1 2


3 4 5 6 7 8 9 10
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/
Valentin Platzgummer's avatar
Valentin Platzgummer committed
11
import QtQuick 2.3
12
import QtQuick.Controls 1.2
Valentin Platzgummer's avatar
Valentin Platzgummer committed
13 14
import QtLocation 5.3
import QtPositioning 5.3
15

Valentin Platzgummer's avatar
Valentin Platzgummer committed
16 17 18 19 20
import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.FlightMap 1.0
21 22 23 24

Item {
    id: _root

Valentin Platzgummer's avatar
Valentin Platzgummer committed
25 26
    property var map: undefined ///< Map control to place item in
    property var geoArea: undefined ///< GeoArea derived class.
27 28 29 30

    signal clicked(int sequenceNumber)

    Component.onCompleted: {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
31 32
        console.assert(map !== undefined, "please set the map property")
        console.assert(geoArea !== undefined, "please set the geoArea property")
33 34 35 36
    }

    // Area polygon
    QGCMapPolygonVisuals {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
37 38 39 40 41 42 43 44 45
        id: mapPolygonVisuals
        mapControl: map
        mapPolygon: geoArea
        interactive: geoArea.interactive
        borderWidth: 2
        interiorColor: "blue"
        altColor: QGroundControl.globalPalette.surveyPolygonTerrainCollision
        z: QGroundControl.zOrderMapItems - 3
        interiorOpacity: 0.2
46 47
    }

48 49
    Item {
        id: depotMapItem
50

51 52
        MapQuickItem {
            id: mapItem
53

Valentin Platzgummer's avatar
Valentin Platzgummer committed
54 55 56 57 58
            coordinate: _root.geoArea.depot
            anchorPoint.x: sourceItem.anchorPointX
            anchorPoint.y: sourceItem.anchorPointY
            visible: depotMapItem.visible
            z: QGroundControl.zOrderMapItems
59

60
            Component.onCompleted: {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
61 62 63
                coordinate = Qt.binding(function () {
                    return _root.geoArea.depot
                })
64
            }
65

Valentin Platzgummer's avatar
Valentin Platzgummer committed
66 67 68 69 70 71 72
            sourceItem: MissionItemIndexLabel {
                checked: true
                label: qsTr("Depot")
                highlightSelected: true
                onClicked: _root.clicked(0)
                visible: mapItem.visible
                z: mapItem.z
73
            }
74
        }
75

76
        ItemDragger {
Valentin Platzgummer's avatar
Valentin Platzgummer committed
77 78
            anchor: mapItem
            z: QGroundControl.zOrderMapItems + 1
79
            draggable: _root.geoArea.interactive
80

Valentin Platzgummer's avatar
Valentin Platzgummer committed
81
            onDragStop: {
82
                _root.geoArea.depot = mapItem.coordinate
Valentin Platzgummer's avatar
Valentin Platzgummer committed
83 84 85
                mapItem.coordinate = Qt.binding(function () {
                    return _root.geoArea.depot
                })
86
            }
87
        }
88

89 90
        Component.onCompleted: {
            _root.map.addMapItem(mapItem)
91 92 93
        }
    }
}