7import QGroundControl.Controls
8import QGroundControl.FlightMap
10/// Base control for both Survey and Corridor Scan map visuals
14 property var map ///< Map control to place item in
15 property bool polygonInteractive: true
16 property bool interactive: true
18 property bool hideMapPolygon: false
20 property var _missionItem: object
21 property var _mapPolygon: object.surveyAreaPolygon
22 property bool _currentItem: object.isCurrentItem
23 property bool _vertexDrag: _mapPolygon.vertexDrag || hideMapPolygon
24 property var _transectPoints: _missionItem.visualTransectPoints
25 property int _transectCount: _transectPoints.length / (_hasTurnaround ? 4 : 2)
26 property bool _hasTurnaround: _missionItem.turnAroundDistance.rawValue !== 0
27 property int _firstTrueTransectIndex: _hasTurnaround ? 1 : 0
28 property int _lastTrueTransectIndex: _transectPoints.length - (_hasTurnaround ? 2 : 1)
29 property int _lastPointIndex: _transectPoints.length - 1
30 property bool _showPartialEntryExit: !_currentItem && _hasTurnaround &&_transectPoints.length >= 2
31 property var _fullTransectsComponent: null
32 property var _entryTransectsComponent: null
33 property var _exitTransectsComponent: null
34 property var _entryCoordinate
35 property var _exitCoordinate
37 signal clicked(int sequenceNumber)
39 function _addVisualElements() {
40 var toAdd = [ fullTransectsComponent, entryTransectComponent, exitTransectComponent, entryPointComponent, exitPointComponent,
41 entryArrow1Component, entryArrow2Component, exitArrow1Component, exitArrow2Component ]
42 objMgr.createObjects(toAdd, map, true /* parentObjectIsMap */)
45 function _destroyVisualElements() {
46 objMgr.destroyObjects()
49 Component.onCompleted: {
53 Component.onDestruction: {
54 _destroyVisualElements()
57 QGCDynamicObjectManager {
62 QGCMapPolygonVisuals {
65 mapPolygon: _mapPolygon
66 interactive: polygonInteractive && _missionItem.isCurrentItem && _root.interactive
69 interiorColor: QGroundControl.globalPalette.surveyPolygonInterior
70 altColor: QGroundControl.globalPalette.surveyPolygonTerrainCollision
71 interiorOpacity: 0.5 * _root.opacity
72 visible: !hideMapPolygon
75 // Full set of transects lines. Shown when item is selected.
77 id: fullTransectsComponent
83 visible: _currentItem && !_vertexDrag
84 opacity: _root.opacity
88 // Entry and exit transect lines only. Used when item is not selected.
90 id: entryTransectComponent
95 path: _showPartialEntryExit ? [ _transectPoints[0], _transectPoints[1] ] : []
96 visible: _showPartialEntryExit && !_vertexDrag
97 opacity: _root.opacity
101 id: exitTransectComponent
106 path: _showPartialEntryExit ? [ _transectPoints[_lastPointIndex - 1], _transectPoints[_lastPointIndex] ] : []
107 visible: _showPartialEntryExit && !_vertexDrag
108 opacity: _root.opacity
114 id: entryPointComponent
117 anchorPoint.x: sourceItem.anchorPointX
118 anchorPoint.y: sourceItem.anchorPointY
119 z: QGroundControl.zOrderMapItems
120 coordinate: _missionItem.coordinate
121 visible: _missionItem.exitCoordinate.isValid && !_vertexDrag
122 opacity: _root.opacity
124 sourceItem: MissionItemIndexLabel {
125 index: _missionItem.sequenceNumber
126 checked: _missionItem.isCurrentItem
127 onClicked: if(_root.interactive) _root.clicked(_missionItem.sequenceNumber)
133 id: entryArrow1Component
136 fromCoord: _transectPoints[_firstTrueTransectIndex]
137 toCoord: _transectPoints[_firstTrueTransectIndex + 1]
139 visible: _currentItem && !_vertexDrag
140 opacity: _root.opacity
145 id: entryArrow2Component
148 fromCoord: _transectPoints[nextTrueTransectIndex]
149 toCoord: _transectPoints[nextTrueTransectIndex + 1]
151 visible: _currentItem && _transectCount > 3 && !_vertexDrag
152 opacity: _root.opacity
154 property int nextTrueTransectIndex: _firstTrueTransectIndex + (_hasTurnaround ? 4 : 2)
159 id: exitArrow1Component
162 fromCoord: _transectPoints[_lastTrueTransectIndex - 1]
163 toCoord: _transectPoints[_lastTrueTransectIndex]
165 visible: _currentItem && !_vertexDrag
166 opacity: _root.opacity
171 id: exitArrow2Component
174 fromCoord: _transectPoints[prevTrueTransectIndex - 1]
175 toCoord: _transectPoints[prevTrueTransectIndex]
177 visible: _currentItem && _transectCount > 3 && !_vertexDrag
178 opacity: _root.opacity
180 property int prevTrueTransectIndex: _lastTrueTransectIndex - (_hasTurnaround ? 4 : 2)
186 id: exitPointComponent
189 anchorPoint.x: sourceItem.anchorPointX
190 anchorPoint.y: sourceItem.anchorPointY
191 z: QGroundControl.zOrderMapItems
192 coordinate: _missionItem.exitCoordinate
193 visible: _missionItem.exitCoordinate.isValid && !_vertexDrag
194 opacity: _root.opacity
196 sourceItem: MissionItemIndexLabel {
197 index: _missionItem.lastSequenceNumber
198 checked: _missionItem.isCurrentItem
199 onClicked: if(_root.interactive) _root.clicked(_missionItem.sequenceNumber)