5import QGroundControl.Controls
6import QGroundControl.FlightMap
7import QGroundControl.GeoMap
9/// GeoMap-engine drop-in for the QtLocation FlightMap of Plan View. GeoMapView provides the editorMap contract Plan
10/// View and its panels consume (center, zoomLevel, toCoordinate/fromCoordinate, setVisibleRegion, mapClicked, ...).
11/// The plan is displayed, and the current simple mission item and rally point can be dragged. Editing fence points
12/// and pattern items on this map is not supported yet.
16 property var planMasterController
17 property rect centerViewport: Qt.rect(0, 0, width, height) ///< Part of the map not covered by Plan View tools
18 property real missionOpacity: 1 ///< Dims the mission while another layer is edited
19 property bool missionInteractive: false ///< The current mission item can be dragged on the map
20 property real rallyOpacity: 1 ///< Dims the rally points while another layer is edited
21 property bool rallyInteractive: false ///< Rally points can be selected and the current one dragged
22 property real _nonInteractiveOpacity: 0.5 ///< Consumed by the Plan View panels
24 readonly property var _missionController: planMasterController ? planMasterController.missionController : null
25 readonly property var _rallyPointController: planMasterController ? planMasterController.rallyPointController : null
26 readonly property var _geoFenceController: planMasterController ? planMasterController.geoFenceController : null
27 readonly property var _plannedHomePosition: _missionController ? _missionController.plannedHomePosition : QtPositioning.coordinate()
29 property var _missionItemSelectionPanel: null
31 /// A mission item marker was picked on the map
32 signal itemSelected(int sequenceNumber)
34 function _closeMissionItemSelectionPanel() {
35 if (_missionItemSelectionPanel) {
36 _missionItemSelectionPanel.close()
40 allowGCSLocationCenter: true
41 allowVehicleLocationCenter: true
42 // The plan is edited away from the vehicle: only the one-time centering applies
43 followOffscreenVehicle: false
47 surfaceModel: root.surfaceModel
48 coordinate: root._plannedHomePosition
49 visible: root._plannedHomePosition.isValid
54 model: QGroundControl.multiVehicleManager.vehicles
58 surfaceModel: root.surfaceModel
64 objectName: "geoMapMissionPath"
66 surfaceModel: root.surfaceModel
67 missionController: root._missionController
68 vehicle: root.planMasterController ? root.planMasterController.controllerVehicle : null
69 plannedHomePosition: root._plannedHomePosition
70 opacity: root.missionOpacity
75 surfaceModel: root.surfaceModel
76 missionController: root._missionController
77 opacity: root.missionOpacity
78 interactive: root.missionInteractive
79 pickable: root.missionInteractive
80 onItemClicked: (item) => root.itemSelected(item.sequenceNumber)
81 // Dragging only moves the item horizontally: its altitude is kept apart from its coordinate
82 onItemDragged: (item, coordinate) => item.coordinate = QtPositioning.coordinate(coordinate.latitude, coordinate.longitude)
83 onGroupClicked: (items, marker) => {
84 root._closeMissionItemSelectionPanel()
85 const topLeft = marker.mapToItem(globals.parent, 0, 0)
86 root._missionItemSelectionPanel = missionItemSelectionPanelComponent.createObject(mainWindow, {
87 clickRect: Qt.rect(topLeft.x, topLeft.y, marker.width, marker.height),
90 if (root._missionItemSelectionPanel) {
91 root._missionItemSelectionPanel.open()
94 onGroupsInvalidated: root._closeMissionItemSelectionPanel()
97 GeoMapMissionDirectionArrows {
99 surfaceModel: root.surfaceModel
100 missionController: root._missionController
101 opacity: root.missionOpacity
104 GeoMapGeoFenceVisuals {
106 surfaceModel: root.surfaceModel
107 geoFenceController: root._geoFenceController
108 homePosition: root._plannedHomePosition
112 model: root._rallyPointController ? root._rallyPointController.points : undefined
116 surfaceModel: root.surfaceModel
118 vehicle: root.planMasterController ? root.planMasterController.controllerVehicle : null
119 homeAltitude: root._plannedHomePosition.altitude
120 checked: root.rallyInteractive && object === root._rallyPointController.currentRallyPoint
121 opacity: root.rallyOpacity
122 node3DOpacity: root.rallyOpacity
123 pickable: root.rallyInteractive
127 if (mainWindow.allowViewSwitch()) {
128 root._rallyPointController.currentRallyPoint = object
131 // The drag only moves the point horizontally, keeping its altitude
132 onDragged: (coordinate) => object.coordinate = QtPositioning.coordinate(coordinate.latitude, coordinate.longitude, object.coordinate.altitude)
133 // A PX4 AMSL altitude is the ground height under the point, so it is read again where the point lands
135 const vehicle = root.planMasterController.controllerVehicle
136 if (vehicle && vehicle.px4Firmware && object.altitudeFrame === QGroundControl.AltitudeFrameAbsolute) {
137 object.useTerrainAltitude()
144 id: missionItemSelectionPanelComponent
146 MissionItemSelectionPanel {
147 id: missionItemSelectionPanel
149 onItemSelected: (sequenceNumber) => root.itemSelected(sequenceNumber)
151 if (root._missionItemSelectionPanel === missionItemSelectionPanel) {
152 root._missionItemSelectionPanel = null
159 // The picker lists the old mission's items: close it when the mission is replaced
161 target: root._missionController
163 function onVisualItemsReset() {
164 root._closeMissionItemSelectionPanel()