QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
FlyViewWidgetLayer.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Dialogs
4import QtQuick.Layouts
5
6import QtLocation
7import QtPositioning
8import QtQuick.Window
9import QtQml.Models
10
11import QGroundControl
12import QGroundControl.Controls
13import QGroundControl.FlyView
14import QGroundControl.FlightMap
15import QGroundControl.GeoMap
16import QGroundControl.Viewer3D
17
18// This is the ui overlay layer for the widgets/tools for Fly View
19Item {
20 id: _root
21
22 property rect pipViewRect: Qt.rect(0, height, 0, 0)
23 property var occluders: _occluders
24 property var mapControl
25 property var viewer3DCameraController
26
27 property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
28 property var _planMasterController: globals.planMasterControllerFlyView
29 property var _missionController: _planMasterController.missionController
30 property var _geoFenceController: _planMasterController.geoFenceController
31 property var _rallyPointController: _planMasterController.rallyPointController
32 property var _guidedController: globals.guidedControllerFlyView
33 property real _margins: ScreenTools.defaultFontPixelWidth / 2
34 property real _toolsMargin: ScreenTools.defaultFontPixelWidth * 0.75
35 property real _rightPanelWidth: ScreenTools.defaultFontPixelWidth * 30
36 property bool _layoutSpacing: ScreenTools.defaultFontPixelWidth
37 property bool _showSingleVehicleUI: true
38
39 FlyViewOccluders {
40 id: _occluders
41 pipView: pipViewRect
42 toolStrip: toolStrip.visible ? Qt.rect(toolStrip.x, toolStrip.y, toolStrip.width, toolStrip.height) : Qt.rect(0, 0, 0, 0)
43 mapScale: mapScaleRow.coversMap ? Qt.rect(mapScaleRow.x, mapScaleRow.y, mapScaleRow.width, mapScaleRow.height) : Qt.rect(mapScaleRow.x, mapScaleRow.y, 0, 0)
44 topRight: {
45 if (topRightPanel.visible) {
46 return Qt.rect(topRightPanel.x, topRightPanel.y, topRightPanel.width, topRightPanel.height)
47 }
48 const column = topRightColumnLayout
49 return column.visible ? Qt.rect(column.x, column.y, column.width, column.childrenRect.height) : Qt.rect(_root.width, 0, 0, 0)
50 }
51 bottomRight: {
52 const row = bottomRightRowLayout
53 return row.visible ? Qt.rect(row.x, row.y, row.width, row.height) : Qt.rect(_root.width, _root.height, 0, 0)
54 }
55 // The loader spans the full width but only the stick pads at each end cover the map
56 virtualJoystickLeft: {
57 const vj = virtualJoystickMultiTouch
58 return vj.visible ? Qt.rect(vj.x, vj.y, vj.height, vj.height) : Qt.rect(0, _root.height, 0, 0)
59 }
60 virtualJoystickRight: {
61 const vj = virtualJoystickMultiTouch
62 return vj.visible ? Qt.rect(vj.x + vj.width - vj.height, vj.y, vj.height, vj.height) : Qt.rect(_root.width, _root.height, 0, 0)
63 }
64 }
65
66 FlyViewTopRightPanel {
67 id: topRightPanel
68 anchors.top: parent.top
69 anchors.right: parent.right
70 maximumHeight: parent.height - (bottomRightRowLayout.height + _margins * 4)
71 }
72
73 FlyViewTopRightColumnLayout {
74 id: topRightColumnLayout
75 anchors.top: parent.top
76 anchors.right: parent.right
77 spacing: _layoutSpacing
78 visible: !topRightPanel.visible
79 }
80
81 FlyViewBottomRightRowLayout {
82 id: bottomRightRowLayout
83 objectName: "flyViewBottomRightRowLayout"
84 anchors.bottom: parent.bottom
85 anchors.right: parent.right
86 spacing: _layoutSpacing
87 }
88
89 FlyViewMissionCompleteDialog {
90 missionController: _missionController
91 geoFenceController: _geoFenceController
92 rallyPointController: _rallyPointController
93 }
94
95 // Prevent the map's PinchHandler from stealing touch grabs from the joystick pads (issue #13450)
96 Binding {
97 target: mapControl
98 property: "pinchZoomDisabledByVirtualJoysticks"
99 value: virtualJoystickMultiTouch.visible && virtualJoystickMultiTouch.item && virtualJoystickMultiTouch.item.stickActive
100 }
101
102 //-- Virtual Joystick
103 Loader {
104 id: virtualJoystickMultiTouch
105 z: QGroundControl.zOrderTopMost + 1
106 anchors.right: parent.right
107 anchors.rightMargin: anchors.leftMargin
108 height: Math.min(parent.height * 0.25, ScreenTools.defaultFontPixelWidth * 16)
109 visible: _virtualJoystickEnabled && !QGroundControl.videoManager.fullScreen && !(_activeVehicle ? _activeVehicle.usingHighLatencyLink : false)
110 anchors.bottom: parent.bottom
111 anchors.bottomMargin: bottomLoaderMargin
112 anchors.left: parent.left
113 anchors.leftMargin: ( y > toolStrip.y + toolStrip.height ? toolStrip.width / 2 : toolStrip.width * 1.05 + toolStrip.x)
114 source: "qrc:/qml/QGroundControl/FlyView/VirtualJoystick.qml"
115 active: _virtualJoystickEnabled && !(_activeVehicle ? _activeVehicle.usingHighLatencyLink : false)
116
117 property bool autoCenterThrottle: QGroundControl.settingsManager.appSettings.virtualJoystickAutoCenterThrottle.rawValue
118 property bool leftHandedMode: QGroundControl.settingsManager.appSettings.virtualJoystickLeftHandedMode.rawValue
119 property bool _virtualJoystickEnabled: QGroundControl.settingsManager.appSettings.virtualJoystick.rawValue
120 property var _pipViewMargin: pipViewRect.height > 0 ? _root.height - pipViewRect.y + ScreenTools.defaultFontPixelHeight * 2 :
121 bottomRightRowLayout.height + ScreenTools.defaultFontPixelHeight * 1.5
122
123 property var bottomLoaderMargin: _pipViewMargin >= parent.height / 2 ? parent.height / 2 : _pipViewMargin
124
125 property real rootWidth: _root.width
126 property var itemX: virtualJoystickMultiTouch.x // real X on screen
127
128 onRootWidthChanged: virtualJoystickMultiTouch.status == Loader.Ready && visible ? virtualJoystickMultiTouch.item.uiTotalWidth = rootWidth : undefined
129 onItemXChanged: virtualJoystickMultiTouch.status == Loader.Ready && visible ? virtualJoystickMultiTouch.item.uiRealX = itemX : undefined
130
131 //Loader status logic
132 onLoaded: {
133 if (virtualJoystickMultiTouch.visible) {
134 virtualJoystickMultiTouch.item.calibration = true
135 virtualJoystickMultiTouch.item.uiTotalWidth = rootWidth
136 virtualJoystickMultiTouch.item.uiRealX = itemX
137 } else {
138 virtualJoystickMultiTouch.item.calibration = false
139 }
140 }
141 }
142
143 FlyViewToolStrip {
144 id: toolStrip
145 anchors.left: parent.left
146 anchors.top: parent.top
147 z: QGroundControl.zOrderWidgets
148 maxHeight: pipViewRect.y - y - _toolsMargin
149 visible: !QGroundControl.videoManager.fullScreen
150
151 onDisplayPreFlightChecklist: {
152 if (!preFlightChecklistLoader.active) {
153 preFlightChecklistLoader.active = true
154 }
155 preFlightChecklistLoader.item.open()
156 }
157 }
158
159 VehicleWarnings {
160 anchors.centerIn: parent
161 z: QGroundControl.zOrderTopMost
162 }
163
164 Row {
165 id: mapScaleRow
166 anchors.left: toolStrip.right
167 anchors.leftMargin: _toolsMargin
168 anchors.top: parent.top
169 spacing: _toolsMargin
170
171 // MapScale auto-hides by fading opacity, not visibility
172 property bool coversMap: geoMapControls.visible || (mapScale.visible && mapScale.opacity > 0)
173
174 // Google Earth-style camera controls, GeoMap engine only
175 FlyViewGeoMapControls {
176 id: geoMapControls
177 geoMap: mapControl && mapControl.geoMap ? mapControl.geoMap : null
178 visible: !!geoMap && !ScreenTools.isTinyScreen && QGCViewer3DManager.displayMode !== QGCViewer3DManager.View3D && mapControl.pipState.state === mapControl.pipState.fullState
179 }
180
181 MapScale {
182 id: mapScale
183 anchors.verticalCenter: parent.verticalCenter
184 mapControl: _mapControl
185 autoHide: true
186 // geoMap check: scale is ill-defined under the GeoMap engine's 3D
187 // tilt; isTopDown keeps it hidden until the 3D->2D tilt animation lands
188 visible: !ScreenTools.isTinyScreen && QGroundControl.corePlugin.options.flyView.showMapScale && QGCViewer3DManager.displayMode !== QGCViewer3DManager.View3D && mapControl && mapControl.pipState.state === mapControl.pipState.fullState &&
189 (!mapControl.geoMap || (mapControl.geoMap.camera.mode === GeoMapCamera.Mode2D && mapControl.geoMap.camera.isTopDown))
190 }
191 }
192
193 Viewer3DScaleBar {
194 objectName: "viewer3DScaleBar"
195 anchors.left: toolStrip.right
196 anchors.leftMargin: _toolsMargin
197 anchors.top: parent.top
198 controller: _root.viewer3DCameraController
199 autoHide: true
200 visible: !ScreenTools.isTinyScreen && QGroundControl.corePlugin.options.flyView.showMapScale && QGCViewer3DManager.displayMode === QGCViewer3DManager.View3D && !!_root.viewer3DCameraController
201 }
202
203 Loader {
204 id: preFlightChecklistLoader
205 sourceComponent: preFlightChecklistPopup
206 active: false
207 }
208
209 Component {
210 id: preFlightChecklistPopup
211 FlyViewPreFlightChecklistPopup {
212 }
213 }
214}