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
19 property var _missionItem: object
20 property var _mapPolygon: object.surveyAreaPolygon
21 property bool _currentItem: object.isCurrentItem
22 property var _transectPoints: _missionItem.visualTransectPoints
23 property int _transectCount: _transectPoints.length / (_hasTurnaround ? 4 : 2)
24 property bool _hasTurnaround: _missionItem.turnAroundDistance.rawValue !== 0
25 property int _firstTrueTransectIndex: _hasTurnaround ? 1 : 0
26 property int _lastTrueTransectIndex: _transectPoints.length - (_hasTurnaround ? 2 : 1)
27 property int _lastPointIndex: _transectPoints.length - 1
28 property bool _showPartialEntryExit: !_currentItem && _hasTurnaround &&_transectPoints.length >= 2
29 property var _fullTransectsComponent: null
30 property var _entryTransectsComponent: null
31 property var _exitTransectsComponent: null
32 property var _entryCoordinate
33 property var _exitCoordinate
35 signal clicked(int sequenceNumber)
37 function _addVisualElements() {
38 var toAdd = [ fullTransectsComponent, entryTransectComponent, exitTransectComponent, entryPointComponent, exitPointComponent,
39 entryArrow1Component, entryArrow2Component, exitArrow1Component, exitArrow2Component ]
40 objMgr.createObjects(toAdd, map, true /* parentObjectIsMap */)
43 function _destroyVisualElements() {
44 objMgr.destroyObjects()
47 Component.onCompleted: {
51 Component.onDestruction: {
52 _destroyVisualElements()
55 QGCDynamicObjectManager {
60 QGCMapPolygonVisuals {
63 mapPolygon: _mapPolygon
64 interactive: polygonInteractive && _missionItem.isCurrentItem && _root.interactive
67 interiorColor: QGroundControl.globalPalette.surveyPolygonInterior
68 altColor: QGroundControl.globalPalette.surveyPolygonTerrainCollision
69 interiorOpacity: 0.5 * _root.opacity
72 // Full set of transects lines. Shown when item is selected.
74 id: fullTransectsComponent
81 opacity: _root.opacity
85 // Entry and exit transect lines only. Used when item is not selected.
87 id: entryTransectComponent
92 path: _showPartialEntryExit ? [ _transectPoints[0], _transectPoints[1] ] : []
93 visible: _showPartialEntryExit
94 opacity: _root.opacity
98 id: exitTransectComponent
103 path: _showPartialEntryExit ? [ _transectPoints[_lastPointIndex - 1], _transectPoints[_lastPointIndex] ] : []
104 visible: _showPartialEntryExit
105 opacity: _root.opacity
111 id: entryPointComponent
114 anchorPoint.x: sourceItem.anchorPointX
115 anchorPoint.y: sourceItem.anchorPointY
116 z: QGroundControl.zOrderMapItems
117 coordinate: _missionItem.coordinate
118 visible: _missionItem.exitCoordinate.isValid
119 opacity: _root.opacity
121 sourceItem: MissionItemIndexLabel {
122 index: _missionItem.sequenceNumber
123 checked: _missionItem.isCurrentItem
124 onClicked: if(_root.interactive) _root.clicked(_missionItem.sequenceNumber)
130 id: entryArrow1Component
133 fromCoord: _transectPoints[_firstTrueTransectIndex]
134 toCoord: _transectPoints[_firstTrueTransectIndex + 1]
136 visible: _currentItem
137 opacity: _root.opacity
142 id: entryArrow2Component
145 fromCoord: _transectPoints[nextTrueTransectIndex]
146 toCoord: _transectPoints[nextTrueTransectIndex + 1]
148 visible: _currentItem && _transectCount > 3
149 opacity: _root.opacity
151 property int nextTrueTransectIndex: _firstTrueTransectIndex + (_hasTurnaround ? 4 : 2)
156 id: exitArrow1Component
159 fromCoord: _transectPoints[_lastTrueTransectIndex - 1]
160 toCoord: _transectPoints[_lastTrueTransectIndex]
162 visible: _currentItem
163 opacity: _root.opacity
168 id: exitArrow2Component
171 fromCoord: _transectPoints[prevTrueTransectIndex - 1]
172 toCoord: _transectPoints[prevTrueTransectIndex]
174 visible: _currentItem && _transectCount > 3
175 opacity: _root.opacity
177 property int prevTrueTransectIndex: _lastTrueTransectIndex - (_hasTurnaround ? 4 : 2)
183 id: exitPointComponent
186 anchorPoint.x: sourceItem.anchorPointX
187 anchorPoint.y: sourceItem.anchorPointY
188 z: QGroundControl.zOrderMapItems
189 coordinate: _missionItem.exitCoordinate
190 visible: _missionItem.exitCoordinate.isValid
191 opacity: _root.opacity
193 sourceItem: MissionItemIndexLabel {
194 index: _missionItem.lastSequenceNumber
195 checked: _missionItem.isCurrentItem
196 onClicked: if(_root.interactive) _root.clicked(_missionItem.sequenceNumber)