QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
FlyViewMapClickDropPanel.qml
Go to the documentation of this file.
1/****************************************************************************
2 *
3 * (c) 2009-2024 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 *
5 * QGroundControl is licensed according to the terms in the file
6 * COPYING.md in the root of the source code directory.
7 *
8 ****************************************************************************/
9
10import QtQuick
11import QtQuick.Layouts
12
13import QGroundControl
14import QGroundControl.Controls
15
16/// Guided-action popup for a click on the fly view map (Go to / Orbit / ROI /
17/// Set home / Set Estimator Origin / Set Heading). Shared between the
18/// QtLocation FlyViewMap and the GeoMap engine adapter: the map indicator
19/// properties are optional, engines without those visuals still get the
20/// actions (confirmAction works without an indicator).
21DropPanel {
22 id: root
23
24 property var mapClickCoord
25
26 // Optional map indicators (QtLocation engine only)
27 property var gotoIndicator: null
28 property var orbitIndicator: null
29
30 readonly property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
31 readonly property var _guidedController: globals.guidedControllerFlyView
32 readonly property var _flyViewSettings: QGroundControl.settingsManager.flyViewSettings
33
34 // The available actions were evaluated against the vehicle the panel was
35 // opened for; close if that vehicle goes away or the active vehicle changes
36 on_ActiveVehicleChanged: close()
37
38 // Callers create the panel dynamically per map click; close() alone would leak it
39 onClosed: destroy()
40
41 sourceComponent: Component {
42 ColumnLayout {
43 spacing: ScreenTools.defaultFontPixelWidth / 2
44
45 QGCButton {
46 Layout.fillWidth: true
47 text: qsTr("Go to location")
48 visible: root._guidedController.showGotoLocation
49 onClicked: {
50 root.close()
51 if (!root._activeVehicle) {
52 return
53 }
54 if (root.gotoIndicator) {
55 root.gotoIndicator.show(root.mapClickCoord)
56 }
57
58 if ((root._activeVehicle.flightMode == root._activeVehicle.gotoFlightMode) && !root._flyViewSettings.goToLocationRequiresConfirmInGuided.value) {
59 const executed = root._guidedController.executeAction(root._guidedController.actionGoto, root.mapClickCoord)
60 if (root.gotoIndicator) {
61 if (executed) {
62 root.gotoIndicator.actionConfirmed() // Still need to call this to commit the new coordinate and radius
63 } else {
64 root.gotoIndicator.actionCancelled()
65 }
66 }
67 } else {
68 root._guidedController.confirmAction(root._guidedController.actionGoto, root.mapClickCoord, root.gotoIndicator)
69 }
70 }
71 }
72
73 QGCButton {
74 Layout.fillWidth: true
75 text: qsTr("Orbit at location")
76 visible: root._guidedController.showOrbit && (root.orbitIndicator !== null)
77 onClicked: {
78 root.close()
79 root.orbitIndicator.show(root.mapClickCoord)
80 root._guidedController.confirmAction(root._guidedController.actionOrbit, root.mapClickCoord, root.orbitIndicator)
81 }
82 }
83
84 QGCButton {
85 objectName: "mapClickROI"
86 Layout.fillWidth: true
87 text: qsTr("ROI at location")
88 visible: root._guidedController.showROI
89 onClicked: {
90 root.close()
91 root._guidedController.confirmAction(root._guidedController.actionROI, root.mapClickCoord)
92 }
93 }
94
95 QGCButton {
96 Layout.fillWidth: true
97 text: qsTr("Set home here")
98 visible: root._guidedController.showSetHome
99 onClicked: {
100 root.close()
101 root._guidedController.confirmAction(root._guidedController.actionSetHome, root.mapClickCoord)
102 }
103 }
104
105 QGCButton {
106 Layout.fillWidth: true
107 text: qsTr("Set Estimator Origin")
108 visible: root._guidedController.showSetEstimatorOrigin
109 onClicked: {
110 root.close()
111 root._guidedController.confirmAction(root._guidedController.actionSetEstimatorOrigin, root.mapClickCoord)
112 }
113 }
114
115 QGCButton {
116 Layout.fillWidth: true
117 text: qsTr("Set Heading")
118 visible: root._guidedController.showChangeHeading
119 onClicked: {
120 root.close()
121 root._guidedController.confirmAction(root._guidedController.actionChangeHeading, root.mapClickCoord)
122 }
123 }
124
125 ColumnLayout {
126 spacing: 0
127 QGCLabel { text: qsTr("Lat: %1").arg(root.mapClickCoord.latitude.toFixed(6)) }
128 QGCLabel { text: qsTr("Lon: %1").arg(root.mapClickCoord.longitude.toFixed(6)) }
129 }
130 }
131 }
132}