QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
RallyPointMapVisuals.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtLocation
4import QtPositioning
5
6import QGroundControl
7import QGroundControl.Controls
8import QGroundControl.FlightMap
9
10/// Rally Point map visuals
11Item {
12 id: _root
13 z: QGroundControl.zOrderMapItems
14
15 property var map
16 property var myRallyPointController
17 property bool interactive: false ///< true: user can interact with items
18 property bool planView: false ///< true: visuals showing in plan view
19
20 property bool _interactive: interactive
21 property var _rallyPointsComponent
22 property bool _rallyPointsSupported: myRallyPointController.supported
23 property var _rallyPoints: myRallyPointController.points
24
25 Component.onCompleted: {
26 _rallyPointsComponent = rallyPointsComponent.createObject(map)
27 }
28
29 Component.onDestruction: {
30 _rallyPointsComponent.destroy()
31 }
32
33 Component {
34 id: dragAreaComponent
35
36 MissionItemIndicatorDrag {
37 mapControl: _root.map
38 itemCoordinate: rallyPointObject.coordinate
39 visible: rallyPointObject === myRallyPointController.currentRallyPoint && _root.interactive
40
41 property var rallyPointObject
42
43 onItemCoordinateChanged: rallyPointObject.coordinate = itemCoordinate
44 }
45 }
46
47 Component {
48 id: rallyPointComponent
49
50 MapQuickItem {
51 id: itemIndicator
52 anchorPoint.x: sourceItem.anchorPointX
53 anchorPoint.y: sourceItem.anchorPointY
54 z: QGroundControl.zOrderMapItems
55 opacity: _root.opacity
56
57 property var rallyPointObject
58
59 sourceItem: MissionItemIndexLabel {
60 id: itemIndexLabel
61 label: qsTr("R", "rally point map item label")
62 checked: _editingLayer == _layerRally ? rallyPointObject === myRallyPointController.currentRallyPoint : false
63 highlightSelected: true
64 onClicked: myRallyPointController.currentRallyPoint = rallyPointObject
65 }
66 }
67 }
68
69 // Add all rally points to the map
70 Component {
71 id: rallyPointsComponent
72
73 Repeater {
74 model: _rallyPoints
75
76 delegate: Item {
77 opacity: _root.opacity
78 property var _visuals: [ ]
79
80 Component.onCompleted: {
81 var rallyPointIndicator = rallyPointComponent.createObject(map)
82 rallyPointIndicator.coordinate = Qt.binding(function() { return object.coordinate })
83 rallyPointIndicator.rallyPointObject = Qt.binding(function() { return object })
84 map.addMapItem(rallyPointIndicator)
85 _visuals.push(rallyPointIndicator)
86
87 var dragArea = dragAreaComponent.createObject(map, { "itemIndicator": rallyPointIndicator, "rallyPointObject": object })
88 _visuals.push(dragArea)
89 }
90
91 Component.onDestruction: {
92 for (var i=0; i<_visuals.length; i++) {
93 _visuals[i].destroy()
94 }
95 _visuals = [ ]
96 }
97 }
98 }
99 }
100
101}