SafeAreaMapVisual.qml 2.76 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 42
        mapPolygon:         geoArea
        interactive:        geoArea.interactive
        borderWidth:        2
        borderColor:        "blue"
43 44
        interiorColor:      "blue"
        altColor:           QGroundControl.globalPalette.surveyPolygonTerrainCollision
45 46 47 48
        z: 					QGroundControl.zOrderMapItems-1
        interiorOpacity:    0.3
    }

49 50
    Item {
        id: depotMapItem
51

52 53
        MapQuickItem {
            id: mapItem
54 55


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

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

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

77 78 79 80
        ItemDragger {
            anchor:  mapItem
            z:				QGroundControl.zOrderMapItems+1
            draggable: _root.geoArea.interactive
81

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

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