/**************************************************************************** * * (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 /// Survey Complex Mission Item visuals Item { id: _root property var map ///< Map control to place item in property var qgcView ///< QGCView to use for popping dialogs property var _missionItem: object property var _transectsComponent property var _entryCoordinate property var _exitCoordinate signal clicked(int sequenceNumber) function _addTransectsComponent(){ if (!_transectsComponent){ _transectsComponent = visualTransectsComponent.createObject(_root) map.addMapItem(_transectsComponent) } } function _addExitCoordinate(){ if (!_exitCoordinate){ _exitCoordinate = exitPointComponent.createObject(_root) map.addMapItem(_exitCoordinate) } } function _addEntryCoordinate(){ if (!_entryCoordinate){ _entryCoordinate = entryPointComponent.createObject(_root) map.addMapItem(_entryCoordinate) } } function _destroyEntryCoordinate(){ if (_entryCoordinate){ map.removeMapItem(_entryCoordinate) _entryCoordinate.destroy() _entryCoordinate = undefined } } function _destroyExitCoordinate(){ if (_exitCoordinate){ map.removeMapItem(_exitCoordinate) _exitCoordinate.destroy() _exitCoordinate = undefined } } function _destroyTransectsComponent(){ if (_transectsComponent){ map.removeMapItem(_transectsComponent) _transectsComponent.destroy() _transectsComponent = undefined } } Component.onCompleted: { _addEntryCoordinate() _addExitCoordinate() _addTransectsComponent() } Component.onDestruction: { _destroyEntryCoordinate() _destroyExitCoordinate() _destroyTransectsComponent() } // Transect lines Component { id: visualTransectsComponent MapPolyline { property var transects: _missionItem.visualTransectPoints line.color: "white" line.width: 2 path: transects.length > 0 ? transects : [] } } // Entry point Component { id: entryPointComponent MapQuickItem { anchorPoint.x: sourceItem.anchorPointX anchorPoint.y: sourceItem.anchorPointY z: QGroundControl.zOrderMapItems coordinate: _missionItem.coordinate visible: _missionItem.exitCoordinate.isValid sourceItem: MissionItemIndexLabel { index: _missionItem.sequenceNumber label: "Entry" checked: _missionItem.isCurrentItem onClicked: _root.clicked(_missionItem.sequenceNumber) } } } // Exit point Component { id: exitPointComponent MapQuickItem { anchorPoint.x: sourceItem.anchorPointX anchorPoint.y: sourceItem.anchorPointY z: QGroundControl.zOrderMapItems coordinate: _missionItem.exitCoordinate visible: _missionItem.exitCoordinate.isValid sourceItem: MissionItemIndexLabel { index: _missionItem.lastSequenceNumber label: "Exit" checked: _missionItem.isCurrentItem onClicked: _root.clicked(_missionItem.sequenceNumber) } } } }