SafeAreaMapVisual.qml 3.03 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 49 50 51
        z: 					QGroundControl.zOrderMapItems-1
        interiorOpacity:    0.3
    }

    Loader {
        id:depotLoader
        sourceComponent: depotComponent
52 53 54 55
    }

    // Depot Point.
    Component {
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
        id: depotComponent

        Item {
            id: depotMapItem

            MapQuickItem {
                id: mapItem


                coordinate:     _root.geoArea.depot
                anchorPoint.x:  sourceItem.anchorPointX
                anchorPoint.y:  sourceItem.anchorPointY
                visible:        true
                z:		        QGroundControl.zOrderMapItems

                Component.onCompleted: {
                    coordinate = Qt.binding(function(){return _root.geoArea.depot})
73 74
                }

75 76 77 78 79 80 81 82
                sourceItem:
                    MissionItemIndexLabel {
                    checked:            true
                    label:              qsTr("Depot")
                    highlightSelected:  true
                    onClicked:          _root.clicked(0)
                    visible:            mapItem.visible
                    z:				    mapItem.z
Valentin Platzgummer's avatar
Valentin Platzgummer committed
83
                }
84 85
            }

86 87 88 89
            ItemDragger {
                anchor:  mapItem
                z:				QGroundControl.zOrderMapItems+1
                draggable: _root.geoArea.interactive
90

91 92 93 94 95
                onDragStop:{
                    _root.geoArea.depot = mapItem.coordinate
                    mapItem.coordinate = Qt.binding(function(){return _root.geoArea.depot})
                }
            }
96

97 98 99
            Component.onCompleted: {
                _root.map.addMapItem(mapItem)
            }
100 101 102
        }
    }
}