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.Viewer3D
16
17// This is the ui overlay layer for the widgets/tools for Fly View
18Item {
19 id: _root
20
21 property var parentToolInsets
22 property var totalToolInsets: _totalToolInsets
23 property var mapControl
24 property var viewer3DCameraController
25
26 property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
27 property var _planMasterController: globals.planMasterControllerFlyView
28 property var _missionController: _planMasterController.missionController
29 property var _geoFenceController: _planMasterController.geoFenceController
30 property var _rallyPointController: _planMasterController.rallyPointController
31 property var _guidedController: globals.guidedControllerFlyView
32 property real _margins: ScreenTools.defaultFontPixelWidth / 2
33 property real _toolsMargin: ScreenTools.defaultFontPixelWidth * 0.75
34 property rect _centerViewport: Qt.rect(0, 0, width, height)
35 property real _rightPanelWidth: ScreenTools.defaultFontPixelWidth * 30
36 property real _layoutMargin: ScreenTools.defaultFontPixelWidth * 0.75
37 property bool _layoutSpacing: ScreenTools.defaultFontPixelWidth
38 property bool _showSingleVehicleUI: true
39
40 QGCToolInsets {
41 id: _totalToolInsets
42 leftEdgeTopInset: toolStrip.leftEdgeTopInset
43 leftEdgeCenterInset: toolStrip.leftEdgeCenterInset
44 leftEdgeBottomInset: virtualJoystickMultiTouch.visible ? virtualJoystickMultiTouch.leftEdgeBottomInset : parentToolInsets.leftEdgeBottomInset
45 rightEdgeTopInset: topRightPanel.rightEdgeTopInset
46 rightEdgeCenterInset: topRightPanel.rightEdgeCenterInset
47 rightEdgeBottomInset: bottomRightRowLayout.rightEdgeBottomInset
48 topEdgeLeftInset: toolStrip.topEdgeLeftInset
49 topEdgeCenterInset: mapScale.topEdgeCenterInset
50 topEdgeRightInset: topRightPanel.topEdgeRightInset
51 bottomEdgeLeftInset: virtualJoystickMultiTouch.visible ? virtualJoystickMultiTouch.bottomEdgeLeftInset : parentToolInsets.bottomEdgeLeftInset
52 bottomEdgeCenterInset: bottomRightRowLayout.bottomEdgeCenterInset
53 bottomEdgeRightInset: virtualJoystickMultiTouch.visible ? virtualJoystickMultiTouch.bottomEdgeRightInset : bottomRightRowLayout.bottomEdgeRightInset
54 }
55
56 FlyViewTopRightPanel {
57 id: topRightPanel
58 anchors.top: parent.top
59 anchors.right: parent.right
60 maximumHeight: parent.height - (bottomRightRowLayout.height + _margins * 4)
61
62 property real topEdgeRightInset: height + _layoutMargin
63 property real rightEdgeTopInset: width + _layoutMargin
64 property real rightEdgeCenterInset: rightEdgeTopInset
65 }
66
67 FlyViewTopRightColumnLayout {
68 id: topRightColumnLayout
69 anchors.top: parent.top
70 anchors.right: parent.right
71 spacing: _layoutSpacing
72 visible: !topRightPanel.visible
73
74 property real topEdgeRightInset: childrenRect.height + _layoutMargin
75 property real rightEdgeTopInset: width + _layoutMargin
76 property real rightEdgeCenterInset: rightEdgeTopInset
77 }
78
79 FlyViewBottomRightRowLayout {
80 id: bottomRightRowLayout
81 anchors.bottom: parent.bottom
82 anchors.right: parent.right
83 spacing: _layoutSpacing
84
85 property real bottomEdgeRightInset: height + _layoutMargin
86 property real bottomEdgeCenterInset: bottomEdgeRightInset
87 property real rightEdgeBottomInset: width + _layoutMargin
88 }
89
90 FlyViewMissionCompleteDialog {
91 missionController: _missionController
92 geoFenceController: _geoFenceController
93 rallyPointController: _rallyPointController
94 }
95
96 // Prevent the map's PinchHandler from stealing touch grabs from the joystick pads (issue #13450)
97 Binding {
98 target: mapControl
99 property: "pinchZoomDisabledByVirtualJoysticks"
100 value: virtualJoystickMultiTouch.visible && virtualJoystickMultiTouch.item && virtualJoystickMultiTouch.item.stickActive
101 }
102
103 //-- Virtual Joystick
104 Loader {
105 id: virtualJoystickMultiTouch
106 z: QGroundControl.zOrderTopMost + 1
107 anchors.right: parent.right
108 anchors.rightMargin: anchors.leftMargin
109 height: Math.min(parent.height * 0.25, ScreenTools.defaultFontPixelWidth * 16)
110 visible: _virtualJoystickEnabled && !QGroundControl.videoManager.fullScreen && !(_activeVehicle ? _activeVehicle.usingHighLatencyLink : false)
111 anchors.bottom: parent.bottom
112 anchors.bottomMargin: bottomLoaderMargin
113 anchors.left: parent.left
114 anchors.leftMargin: ( y > toolStrip.y + toolStrip.height ? toolStrip.width / 2 : toolStrip.width * 1.05 + toolStrip.x)
115 source: "qrc:/qml/QGroundControl/FlyView/VirtualJoystick.qml"
116 active: _virtualJoystickEnabled && !(_activeVehicle ? _activeVehicle.usingHighLatencyLink : false)
117
118 property real bottomEdgeLeftInset: parent.height-y
119 property bool autoCenterThrottle: QGroundControl.settingsManager.appSettings.virtualJoystickAutoCenterThrottle.rawValue
120 property bool leftHandedMode: QGroundControl.settingsManager.appSettings.virtualJoystickLeftHandedMode.rawValue
121 property bool _virtualJoystickEnabled: QGroundControl.settingsManager.appSettings.virtualJoystick.rawValue
122 property real bottomEdgeRightInset: parent.height-y
123 property var _pipViewMargin: _pipView.visible ? parentToolInsets.bottomEdgeLeftInset + ScreenTools.defaultFontPixelHeight * 2 :
124 bottomRightRowLayout.height + ScreenTools.defaultFontPixelHeight * 1.5
125
126 property var bottomLoaderMargin: _pipViewMargin >= parent.height / 2 ? parent.height / 2 : _pipViewMargin
127
128 // Width is difficult to access directly hence this hack which may not work in all circumstances
129 property real leftEdgeBottomInset: visible ? bottomEdgeLeftInset + width/18 - ScreenTools.defaultFontPixelHeight*2 : 0
130 property real rightEdgeBottomInset: visible ? bottomEdgeRightInset + width/18 - ScreenTools.defaultFontPixelHeight*2 : 0
131 property real rootWidth: _root.width
132 property var itemX: virtualJoystickMultiTouch.x // real X on screen
133
134 onRootWidthChanged: virtualJoystickMultiTouch.status == Loader.Ready && visible ? virtualJoystickMultiTouch.item.uiTotalWidth = rootWidth : undefined
135 onItemXChanged: virtualJoystickMultiTouch.status == Loader.Ready && visible ? virtualJoystickMultiTouch.item.uiRealX = itemX : undefined
136
137 //Loader status logic
138 onLoaded: {
139 if (virtualJoystickMultiTouch.visible) {
140 virtualJoystickMultiTouch.item.calibration = true
141 virtualJoystickMultiTouch.item.uiTotalWidth = rootWidth
142 virtualJoystickMultiTouch.item.uiRealX = itemX
143 } else {
144 virtualJoystickMultiTouch.item.calibration = false
145 }
146 }
147 }
148
149 FlyViewToolStrip {
150 id: toolStrip
151 anchors.left: parent.left
152 anchors.top: parent.top
153 z: QGroundControl.zOrderWidgets
154 maxHeight: parent.height - y - parentToolInsets.bottomEdgeLeftInset - _toolsMargin
155 visible: !QGroundControl.videoManager.fullScreen
156
157 onDisplayPreFlightChecklist: {
158 if (!preFlightChecklistLoader.active) {
159 preFlightChecklistLoader.active = true
160 }
161 preFlightChecklistLoader.item.open()
162 }
163
164 property real topEdgeLeftInset: visible ? y + height : 0
165 property real leftEdgeTopInset: visible ? x + width : 0
166 property real leftEdgeCenterInset: leftEdgeTopInset
167 }
168
169 VehicleWarnings {
170 anchors.centerIn: parent
171 z: QGroundControl.zOrderTopMost
172 }
173
174 MapScale {
175 id: mapScale
176 anchors.left: toolStrip.right
177 anchors.leftMargin: _toolsMargin
178 anchors.top: parent.top
179 mapControl: _mapControl
180 autoHide: true
181 visible: !ScreenTools.isTinyScreen && QGroundControl.corePlugin.options.flyView.showMapScale && QGCViewer3DManager.displayMode !== QGCViewer3DManager.View3D && mapControl.pipState.state === mapControl.pipState.fullState
182
183 property real topEdgeCenterInset: visible ? y + height : 0
184 }
185
186 Viewer3DScaleBar {
187 objectName: "viewer3DScaleBar"
188 anchors.left: toolStrip.right
189 anchors.leftMargin: _toolsMargin
190 anchors.top: parent.top
191 controller: _root.viewer3DCameraController
192 autoHide: true
193 visible: !ScreenTools.isTinyScreen && QGroundControl.corePlugin.options.flyView.showMapScale && QGCViewer3DManager.displayMode === QGCViewer3DManager.View3D && !!_root.viewer3DCameraController
194 }
195
196 Loader {
197 id: preFlightChecklistLoader
198 sourceComponent: preFlightChecklistPopup
199 active: false
200 }
201
202 Component {
203 id: preFlightChecklistPopup
204 FlyViewPreFlightChecklistPopup {
205 }
206 }
207}