/**************************************************************************** * * (c) 2009-2016 QGROUNDCONTROL PROJECT * * 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 property var map: undefined ///< Map control to place item in property var geoArea: undefined ///< GeoArea derived class. property var _depotVisual: undefined property var _depotDrag: undefined property bool _showDepot: geoArea.interactive opacity: 0.3 signal clicked(int sequenceNumber) on_ShowDepotChanged: { if (_showDepot){ _addDepotVisual() _addDepotDrag() } else { _destroyDepotVisual() _destroyDepotDrag() } } Component.onCompleted: { if (_showDepot){ _addDepotVisual() _addDepotDrag() } console.assert(map !== undefined, "please set the map property") console.assert(geoArea !== undefined, "please set the geoArea property") } Component.onDestruction: { _destroyDepotVisual() } // Area polygon QGCMapPolygonVisuals { id: mapPolygonVisuals mapControl: map mapPolygon: geoArea interactive: geoArea.interactive borderWidth: 2 borderColor: "blue" interiorColor: "blue" altColor: QGroundControl.globalPalette.surveyPolygonTerrainCollision interiorOpacity: _root.opacity } // Depot Point. Component { id: depotPointComponent MapQuickItem { coordinate: _root.geoArea.depot anchorPoint.x: sourceItem.anchorPointX anchorPoint.y: sourceItem.anchorPointY visible: true sourceItem: MissionItemIndexLabel { checked: geoArea.interactive label: qsTr("Launch") highlightSelected: true onClicked: _root.clicked(0) visible: true } } } Component { id: depotDragComponent MissionItemIndicatorDrag { mapControl: _root.map itemIndicator: _depot itemCoordinate: geoArea.depot visible: geoArea.interactive property var depot: geoArea.depot onItemCoordinateChanged: { if (itemCoordinate.latitude !== depot.latitude || itemCoordinate.longitude !== depot.longitude){ if (_root.areaItem.containsCoordinate(itemCoordinate)){ _root.areaItem.depot = itemCoordinate } } itemCoordinate = Qt.binding(function(){return _root.geoArea.depot}) } } } function _addDepotVisual() { if (!_depotVisual){ _depotVisual = depotPointComponent.createObject(_root) map.addMapItem(_depotVisual) } } function _destroyDepotVisual() { if (_depotVisual){ map.removeMapItem(_depotVisual) _depotVisual.destroy() _depotVisual = undefined } } function _addDepotDrag() { if (!_depotDrag){ _depotDrag = depotDragComponent.createObject(_root) } } function _destroyDepotDrag() { if (_depotDrag){ _depotDrag.destroy() _depotDrag = undefined } } }