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.pipState.state === mapControl.pipState.fullState
35 property bool _isFullWindowItemDark: _mainWindowIsMap ? mapControl.isSatelliteMap : 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 rect _centerViewport: Qt.rect(0, 0, width, height)
46 property real _rightPanelWidth: ScreenTools.defaultFontPixelWidth * 30
47 property var _mapControl: mapControl
48 property real _widgetMargin: ScreenTools.defaultFontPixelWidth * 0.75
49
50 property real _fullItemZorder: 0
51 property real _pipItemZorder: QGroundControl.zOrderWidgets
52
53 function _calcCenterViewPort() {
54 var newToolInset = Qt.rect(0, 0, width, height)
55 toolstrip.adjustToolInset(newToolInset)
56 }
57
58 function dropMainStatusIndicatorTool() {
59 toolbar.dropMainStatusIndicatorTool();
60 }
61
62 QGCToolInsets {
63 id: _toolInsets
64 topEdgeLeftInset: toolbar.height
65 topEdgeCenterInset: topEdgeLeftInset
66 topEdgeRightInset: topEdgeLeftInset
67 leftEdgeBottomInset: _pipView.leftEdgeBottomInset
68 bottomEdgeLeftInset: _pipView.bottomEdgeLeftInset
69 }
70
71 Item {
72 id: mapHolder
73 anchors.fill: parent
74
75 FlyViewMap {
76 id: mapControl
77 planMasterController: _planController
78 rightPanelWidth: ScreenTools.defaultFontPixelHeight * 9
79 pipView: _pipView
80 pipMode: !_mainWindowIsMap
81 toolInsets: customOverlay.totalToolInsets
82 mapName: "FlightDisplayView"
83 enabled: !_is3DMode
84 visible: !_is3DMode
85 }
86
87 FlyViewVideo {
88 id: videoControl
89 pipView: _pipView
90 }
91
92 PipView {
93 id: _pipView
94 anchors.left: parent.left
95 anchors.bottom: parent.bottom
96 anchors.margins: _toolsMargin
97 item1IsFullSettingsKey: "MainFlyWindowIsMap"
98 item1: mapControl
99 item2: QGroundControl.videoManager.hasVideo ? videoControl : null
100 show: QGroundControl.videoManager.hasVideo && !QGroundControl.videoManager.fullScreen &&
101 (videoControl.pipState.state === videoControl.pipState.pipState || mapControl.pipState.state === mapControl.pipState.pipState)
102 z: QGroundControl.zOrderWidgets
103
104 property real leftEdgeBottomInset: visible ? width + anchors.margins : 0
105 property real bottomEdgeLeftInset: visible ? height + anchors.margins : 0
106 }
107
108 FlyViewWidgetLayer {
109 id: widgetLayer
110 anchors.top: parent.top
111 anchors.bottom: parent.bottom
112 anchors.left: parent.left
113 anchors.right: guidedValueSlider.visible ? guidedValueSlider.left : parent.right
114 anchors.margins: _widgetMargin
115 anchors.topMargin: toolbar.height + _widgetMargin
116 z: _fullItemZorder + 2
117 parentToolInsets: _toolInsets
118 mapControl: _mapControl
119 visible: !QGroundControl.videoManager.fullScreen
120 }
121
122 FlyViewCustomLayer {
123 id: customOverlay
124 anchors.fill: widgetLayer
125 z: _fullItemZorder + 2
126 parentToolInsets: widgetLayer.totalToolInsets
127 mapControl: _mapControl
128 visible: !QGroundControl.videoManager.fullScreen
129 }
130
131 // Development tool for visualizing the insets for a paticular layer, show if needed
132 FlyViewInsetViewer {
133 id: widgetLayerInsetViewer
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 z: widgetLayer.z + 1
139 insetsToView: widgetLayer.totalToolInsets
140 visible: false
141 }
142
143 GuidedActionsController {
144 id: guidedActionsController
145 missionController: _missionController
146 guidedValueSlider: _guidedValueSlider
147 }
148
149 //-- Guided value slider (e.g. altitude)
150 GuidedValueSlider {
151 id: guidedValueSlider
152 anchors.right: parent.right
153 anchors.top: parent.top
154 anchors.bottom: parent.bottom
155 anchors.topMargin: toolbar.height
156 z: QGroundControl.zOrderTopMost
157 visible: false
158 }
159
160 Loader {
161 id: viewer3DLoader
162 z: 1
163 anchors.fill: parent
164 visible: _is3DMode
165 }
166
167 Connections {
168 target: QGCViewer3DManager
169 function onDisplayModeChanged() {
170 if (QGCViewer3DManager.displayMode === QGCViewer3DManager.View3D) {
171 if (!viewer3DLoader.item) {
172 viewer3DLoader.setSource(
173 "qrc:/qml/QGroundControl/Viewer3D/Models3D/Viewer3DModel.qml",
174 { missionController: Qt.binding(() => _missionController) }
175 )
176 }
177 } else if (!_keepSceneAlive) {
178 viewer3DLoader.source = ""
179 }
180 }
181 }
182 }
183
184 FlyViewToolBar {
185 id: toolbar
186 guidedValueSlider: _guidedValueSlider
187 visible: !QGroundControl.videoManager.fullScreen
188 }
189}