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(showMessages = false) {
55 toolbar.dropMainStatusIndicatorTool(showMessages);
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 topInset: toolbar.height
113 rightInset: mapHolder.width - (widgetLayer.x + _layerOccluders.topRight.x)
114 }
115
116 PipView {
117 id: _pipView
118 objectName: "flyViewPipView"
119 anchors.left: parent.left
120 anchors.bottom: parent.bottom
121 anchors.margins: _toolsMargin
122 item1IsFullSettingsKey: "MainFlyWindowIsMap"
123 item1: _mapControl
124 item2: QGroundControl.videoManager.hasVideo ? videoControl : null
125 show: QGroundControl.videoManager.hasVideo && !QGroundControl.videoManager.fullScreen &&
126 (videoControl.pipState.state === videoControl.pipState.pipState ||
127 (_mapControl && _mapControl.pipState.state === _mapControl.pipState.pipState))
128 z: QGroundControl.zOrderWidgets
129 }
130
131 FlyViewWidgetLayer {
132 id: widgetLayer
133 objectName: "flyViewWidgetLayer"
134 anchors.top: parent.top
135 anchors.bottom: parent.bottom
136 anchors.left: parent.left
137 anchors.right: guidedValueSlider.visible ? guidedValueSlider.left : parent.right
138 anchors.margins: _widgetMargin
139 anchors.topMargin: toolbar.height + _widgetMargin
140 z: _fullItemZorder + 2
141 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)
142 mapControl: _mapControl
143 viewer3DCameraController: viewer3DLoader.item ? viewer3DLoader.item.cameraController : null
144 visible: !QGroundControl.videoManager.fullScreen
145 }
146
147 FlyViewCustomLayer {
148 id: customOverlay
149 anchors.fill: widgetLayer
150 z: _fullItemZorder + 2
151 occluders: _layerOccluders
152 mapControl: _mapControl
153 visible: !QGroundControl.videoManager.fullScreen
154 }
155
156 // Development tool for visualizing the occluders, show if needed
157 FlyViewOccluderViewer {
158 id: occluderViewer
159 anchors.fill: widgetLayer
160 z: widgetLayer.z + 1
161 occluders: _layerOccluders
162 customOccluders: customOverlay.customOccluders
163 visible: false
164 }
165
166 GuidedActionsController {
167 id: guidedActionsController
168 missionController: _missionController
169 guidedValueSlider: _guidedValueSlider
170 }
171
172 //-- Guided value slider (e.g. altitude)
173 GuidedValueSlider {
174 id: guidedValueSlider
175 objectName: "guidedValueSlider"
176 anchors.right: parent.right
177 anchors.top: parent.top
178 anchors.bottom: parent.bottom
179 anchors.topMargin: toolbar.height
180 z: QGroundControl.zOrderTopMost
181 visible: false
182 }
183
184 Loader {
185 id: viewer3DLoader
186 z: 1
187 anchors.fill: parent
188 visible: _is3DMode
189 }
190
191 Connections {
192 target: QGCViewer3DManager
193 function onDisplayModeChanged() {
194 if (QGCViewer3DManager.displayMode === QGCViewer3DManager.View3D) {
195 if (!viewer3DLoader.item) {
196 viewer3DLoader.setSource("qrc:/qml/QGroundControl/Viewer3D/Models3D/Viewer3DModel.qml")
197 }
198 } else if (!_keepSceneAlive) {
199 viewer3DLoader.source = ""
200 }
201 }
202 }
203 }
204
205 FlyViewToolBar {
206 id: toolbar
207 guidedValueSlider: _guidedValueSlider
208 visible: !QGroundControl.videoManager.fullScreen
209 }
210}