SafeAreaMapVisual.qml 2.73 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
/****************************************************************************
 *
 *   (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 QtQuick.Controls 1.2
import QtLocation       5.3
import QtPositioning    5.3

import QGroundControl               1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Palette       1.0
import QGroundControl.Controls      1.0
import QGroundControl.FlightMap     1.0

Item {
    id: _root

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

    signal clicked(int sequenceNumber)

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


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

48 49
    Item {
        id: depotMapItem
50

51 52
        MapQuickItem {
            id: mapItem
53 54


55 56 57 58 59
            coordinate:     _root.geoArea.depot
            anchorPoint.x:  sourceItem.anchorPointX
            anchorPoint.y:  sourceItem.anchorPointY
            visible:        depotMapItem.visible
            z:		        QGroundControl.zOrderMapItems
60

61 62 63
            Component.onCompleted: {
                coordinate = Qt.binding(function(){return _root.geoArea.depot})
            }
64

65 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 77 78 79
        ItemDragger {
            anchor:  mapItem
            z:				QGroundControl.zOrderMapItems+1
            draggable: _root.geoArea.interactive
80

81 82 83
            onDragStop:{
                _root.geoArea.depot = mapItem.coordinate
                mapItem.coordinate = Qt.binding(function(){return _root.geoArea.depot})
84
            }
85
        }
86

87 88
        Component.onCompleted: {
            _root.map.addMapItem(mapItem)
89 90 91
        }
    }
}