7import QGroundControl.Controls
8import QGroundControl.FlightMap
10/// Rally Point map visuals
13 z: QGroundControl.zOrderMapItems
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
20 property bool _interactive: interactive
21 property var _rallyPointsComponent
22 property bool _rallyPointsSupported: myRallyPointController.supported
23 property var _rallyPoints: myRallyPointController.points
25 Component.onCompleted: {
26 _rallyPointsComponent = rallyPointsComponent.createObject(map)
29 Component.onDestruction: {
30 _rallyPointsComponent.destroy()
36 MissionItemIndicatorDrag {
38 itemCoordinate: rallyPointObject.coordinate
39 visible: rallyPointObject === myRallyPointController.currentRallyPoint && _root.interactive
41 property var rallyPointObject
43 // The drag only moves the point. Its altitude is read live because the drag breaks the itemCoordinate binding
44 onItemCoordinateChanged: rallyPointObject.coordinate = QtPositioning.coordinate(itemCoordinate.latitude, itemCoordinate.longitude, rallyPointObject.coordinate.altitude)
46 // A PX4 AMSL altitude is the ground height under the point, so it is read again where the point lands
48 const vehicle = myRallyPointController.masterController.controllerVehicle
49 if (vehicle && vehicle.px4Firmware && rallyPointObject.altitudeFrame === QGroundControl.AltitudeFrameAbsolute) {
50 rallyPointObject.useTerrainAltitude()
57 id: rallyPointComponent
61 anchorPoint.x: sourceItem.anchorPointX
62 anchorPoint.y: sourceItem.anchorPointY
63 z: QGroundControl.zOrderMapItems
64 opacity: _root.opacity
66 property var rallyPointObject
68 sourceItem: MissionItemIndexLabel {
70 label: qsTr("R", "rally point map item label")
71 checked: _editingLayer == _layerRally ? rallyPointObject === myRallyPointController.currentRallyPoint : false
72 highlightSelected: true
74 if (mainWindow.allowViewSwitch()) {
75 myRallyPointController.currentRallyPoint = rallyPointObject
82 // Add all rally points to the map
84 id: rallyPointsComponent
90 opacity: _root.opacity
91 property var _visuals: [ ]
93 Component.onCompleted: {
94 var rallyPointIndicator = rallyPointComponent.createObject(map)
95 rallyPointIndicator.coordinate = Qt.binding(function() { return object.coordinate })
96 rallyPointIndicator.rallyPointObject = Qt.binding(function() { return object })
97 map.addMapItem(rallyPointIndicator)
98 _visuals.push(rallyPointIndicator)
100 var dragArea = dragAreaComponent.createObject(map, { "itemIndicator": rallyPointIndicator, "rallyPointObject": object })
101 _visuals.push(dragArea)
104 Component.onDestruction: {
105 for (var i=0; i<_visuals.length; i++) {
106 _visuals[i].destroy()