QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
FlyView.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.Toolbar
16import QGroundControl.Viewer3D
17
18Item {
19 id: _root
20
21 readonly property bool _is3DMode: QGCViewer3DManager.displayMode === QGCViewer3DManager.View3D
22 readonly property bool _keepSceneAlive: QGroundControl.settingsManager.viewer3DSettings.keepSceneAlive.rawValue
23
24 // These should only be used by MainRootWindow
25 property var planController: _planController
26 property var guidedController: _guidedController
27
28 PlanMasterController {
29 id: _planController
30 flyView: true
31 Component.onCompleted: start()
32 }
33
34 property bool _mainWindowIsMap: _mapControl ? _mapControl.pipState.state === _mapControl.pipState.fullState : true
35 property bool _isFullWindowItemDark: _mainWindowIsMap ? (_mapControl ? _mapControl.isSatelliteMap : true) : true
36 property var _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle
37 property var _missionController: _planController.missionController
38 property var _geoFenceController: _planController.geoFenceController
39 property var _rallyPointController: _planController.rallyPointController
40 property real _margins: ScreenTools.defaultFontPixelWidth / 2
41 property var _guidedController: guidedActionsController
42 property var _guidedValueSlider: guidedValueSlider
43 property var _widgetLayer: widgetLayer
44 property real _toolsMargin: ScreenTools.defaultFontPixelWidth * 0.75
45 property real _rightPanelWidth: ScreenTools.defaultFontPixelWidth * 30
46 property var _mapControl: mapEngineLoader.item
47 property real _widgetMargin: ScreenTools.defaultFontPixelWidth * 0.75
48 property var _layerOccluders: widgetLayer.occluders
49 property var _mapOccluders: _layerOccluders.all.concat(customOverlay.customOccluders).map(r => Qt.rect(r.x + widgetLayer.x, r.y + widgetLayer.y, r.width, r.height))
50
51 property real _fullItemZorder: 0
52 property real _pipItemZorder: QGroundControl.zOrderWidgets
53
54 function dropMainStatusIndicatorTool() {
55 toolbar.dropMainStatusIndicatorTool();
56 }
57
58 Item {
59 id: mapHolder
60 anchors.fill: parent
61
62 // Map engine switch (issue #14901): QtLocation FlyViewMap or the
63 // experimental GeoMap engine, only one instantiated at a time. The
64 // loaded item is positioned/reparented by its PipState, not the Loader.
65 // Engine choice is snapshotted at startup (setting is
66 // qgcRebootRequired): a live swap would leave stale cross-map state
67 // (guided controller registrations, ROI coordinate).
68 Loader {
69 id: mapEngineLoader
70 Component.onCompleted: sourceComponent = QGroundControl.settingsManager.flyViewSettings.useGeoMapEngine.rawValue ? geoMapEngineComponent : qtLocationEngineComponent
71 }
72
73 Component {
74 id: qtLocationEngineComponent
75
76 FlyViewMap {
77 objectName: "flyViewMap"
78 planMasterController: _planController
79 rightPanelWidth: ScreenTools.defaultFontPixelHeight * 9
80 pipView: _pipView
81 pipMode: !_mainWindowIsMap
82 viewportRect: Qt.rect(widgetLayer.x, widgetLayer.y, widgetLayer.width, widgetLayer.height)
83 occluders: _mapOccluders
84 mapName: "FlightDisplayView"
85 enabled: !_is3DMode
86 visible: !_is3DMode
87 }
88 }
89
90 Component {
91 id: geoMapEngineComponent
92
93 FlyViewGeoMapAdapter {
94 objectName: "flyViewGeoMapAdapter"
95 planMasterController: _planController
96 rightPanelWidth: ScreenTools.defaultFontPixelHeight * 9
97 pipView: _pipView
98 pipMode: !_mainWindowIsMap
99 viewportRect: Qt.rect(widgetLayer.x, widgetLayer.y, widgetLayer.width, widgetLayer.height)
100 occluders: _mapOccluders
101 chromeTopMargin: widgetLayer.y + _layerOccluders.topRight.y + _layerOccluders.topRight.height + _widgetMargin
102 chromeBottomMargin: mapHolder.height - widgetLayer.y - Math.min(_layerOccluders.pipView.y, _layerOccluders.virtualJoystickLeft.y) + ScreenTools.defaultFontPixelWidth / 2
103 mapName: "FlightDisplayView"
104 enabled: !_is3DMode
105 visible: !_is3DMode
106 }
107 }
108
109 FlyViewVideo {
110 id: videoControl
111 pipView: _pipView
112 }
113
114 PipView {
115 id: _pipView
116 objectName: "flyViewPipView"
117 anchors.left: parent.left
118 anchors.bottom: parent.bottom
119 anchors.margins: _toolsMargin
120 item1IsFullSettingsKey: "MainFlyWindowIsMap"
121 item1: _mapControl
122 item2: QGroundControl.videoManager.hasVideo ? videoControl : null
123 show: QGroundControl.videoManager.hasVideo && !QGroundControl.videoManager.fullScreen &&
124 (videoControl.pipState.state === videoControl.pipState.pipState ||
125 (_mapControl && _mapControl.pipState.state === _mapControl.pipState.pipState))
126 z: QGroundControl.zOrderWidgets
127 }
128
129 FlyViewWidgetLayer {
130 id: widgetLayer
131 objectName: "flyViewWidgetLayer"
132 anchors.top: parent.top
133 anchors.bottom: parent.bottom
134 anchors.left: parent.left
135 anchors.right: guidedValueSlider.visible ? guidedValueSlider.left : parent.right
136 anchors.margins: _widgetMargin
137 anchors.topMargin: toolbar.height + _widgetMargin
138 z: _fullItemZorder + 2
139 pipViewRect: _pipView.visible ? Qt.rect(_pipView.x + _pipView.occupiedRect.x - x, _pipView.y + _pipView.occupiedRect.y - y, _pipView.occupiedRect.width, _pipView.occupiedRect.height) : Qt.rect(0, height, 0, 0)
140 mapControl: _mapControl
141 viewer3DCameraController: viewer3DLoader.item ? viewer3DLoader.item.cameraController : null
142 visible: !QGroundControl.videoManager.fullScreen
143 }
144
145 FlyViewCustomLayer {
146 id: customOverlay
147 anchors.fill: widgetLayer
148 z: _fullItemZorder + 2
149 occluders: _layerOccluders
150 mapControl: _mapControl
151 visible: !QGroundControl.videoManager.fullScreen
152 }
153
154 // Development tool for visualizing the occluders, show if needed
155 FlyViewOccluderViewer {
156 id: occluderViewer
157 anchors.fill: widgetLayer
158 z: widgetLayer.z + 1
159 occluders: _layerOccluders
160 customOccluders: customOverlay.customOccluders
161 visible: false
162 }
163
164 GuidedActionsController {
165 id: guidedActionsController
166 missionController: _missionController
167 guidedValueSlider: _guidedValueSlider
168 }
169
170 //-- Guided value slider (e.g. altitude)
171 GuidedValueSlider {
172 id: guidedValueSlider
173 objectName: "guidedValueSlider"
174 anchors.right: parent.right
175 anchors.top: parent.top
176 anchors.bottom: parent.bottom
177 anchors.topMargin: toolbar.height
178 z: QGroundControl.zOrderTopMost
179 visible: false
180 }
181
182 Loader {
183 id: viewer3DLoader
184 z: 1
185 anchors.fill: parent
186 visible: _is3DMode
187 }
188
189 Connections {
190 target: QGCViewer3DManager
191 function onDisplayModeChanged() {
192 if (QGCViewer3DManager.displayMode === QGCViewer3DManager.View3D) {
193 if (!viewer3DLoader.item) {
194 viewer3DLoader.setSource("qrc:/qml/QGroundControl/Viewer3D/Models3D/Viewer3DModel.qml")
195 }
196 } else if (!_keepSceneAlive) {
197 viewer3DLoader.source = ""
198 }
199 }
200 }
201 }
202
203 FlyViewToolBar {
204 id: toolbar
205 guidedValueSlider: _guidedValueSlider
206 visible: !QGroundControl.videoManager.fullScreen
207 }
208}