QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
PlanTabPage.qml
Go to the documentation of this file.
1import QtQuick
2import QtQuick.Controls
3import QtQuick.Layouts
4
5import QGroundControl
6import QGroundControl.Controls
7import QGroundControl.FactControls
8
9/// Plan tab: plan info, templates for a new plan, mission defaults and tools
10QGCFlickable {
11 id: root
12
13 required property var planMasterController
14 required property var editorMap
15
16 signal missionTabRequested
17
18 readonly property var _missionController: planMasterController.missionController
19 readonly property var _visualItems: _missionController.visualItems
20 readonly property var _settingsItem: _visualItems && _visualItems.count > 0 ? _visualItems.get(0) : null
21 readonly property var _controllerVehicle: planMasterController.controllerVehicle
22 readonly property bool _noMissionItemsAdded: _visualItems ? _visualItems.count <= 1 : true
23 readonly property bool _waypointsOnlyMode: QGroundControl.corePlugin.options.missionWaypointsOnly
24 readonly property bool _multipleFirmware: !QGroundControl.singleFirmwareSupport
25 readonly property bool _multipleVehicleTypes: !QGroundControl.singleVehicleSupport
26 readonly property bool _allowVehicleSelection: _noMissionItemsAdded && !globals.activeVehicle
27 readonly property real _margin: ScreenTools.defaultFontPixelWidth
28 readonly property real _labelWidth: ScreenTools.defaultFontPixelWidth * 12
29
30 objectName: "planPanel_page_plan"
31 contentHeight: column.height + _margin * 2
32 flickableDirection: Flickable.VerticalFlick
33 clip: true
34
35 QGCPalette { id: qgcPal }
36
37 QGCPopupDialogFactory {
38 id: transformDialogFactory
39
40 dialogComponent: transformDialogComponent
41 }
42
43 Component {
44 id: transformDialogComponent
45
46 QGCPopupDialog {
47 title: qsTr("Transform Mission")
48 buttons: Dialog.Close
49
50 TransformEditor {
51 missionController: root._missionController
52 width: ScreenTools.defaultFontPixelWidth * 50
53 }
54 }
55 }
56
57 ColumnLayout {
58 id: column
59
60 x: root._margin
61 y: root._margin
62 width: root.width - root._margin * 2
63 spacing: ScreenTools.defaultFontPixelHeight * 0.5
64
65 PlanPanelGroupHeader {
66 text: qsTr("Plan")
67 }
68
69 RowLayout {
70 Layout.fillWidth: true
71 spacing: root._margin
72
73 QGCLabel {
74 Layout.preferredWidth: root._labelWidth
75 text: qsTr("File")
76 color: qgcPal.textSecondary
77 }
78
79 QGCLabel {
80 objectName: "planPanel_planFileName"
81 Layout.fillWidth: true
82 text: root.planMasterController.currentPlanFileName === "" ? qsTr("<Untitled>") : root.planMasterController.currentPlanFileName
83 textFormat: Text.PlainText
84 elide: Text.ElideMiddle
85 }
86 }
87
88 RowLayout {
89 Layout.fillWidth: true
90 spacing: root._margin
91 visible: !root._waypointsOnlyMode && root._multipleFirmware
92
93 QGCLabel {
94 Layout.preferredWidth: root._labelWidth
95 text: qsTr("Firmware")
96 color: qgcPal.textSecondary
97 }
98
99 FactComboBox {
100 objectName: "planPanel_firmwareCombo"
101 Layout.fillWidth: true
102 fact: QGroundControl.settingsManager.appSettings.offlineEditingFirmwareClass
103 indexModel: false
104 visible: root._allowVehicleSelection
105 }
106
107 QGCLabel {
108 objectName: "planPanel_firmwareLabel"
109 Layout.fillWidth: true
110 text: root._controllerVehicle ? root._controllerVehicle.firmwareTypeString : ""
111 visible: !root._allowVehicleSelection
112 }
113 }
114
115 RowLayout {
116 Layout.fillWidth: true
117 spacing: root._margin
118 visible: !root._waypointsOnlyMode && root._multipleVehicleTypes
119
120 QGCLabel {
121 Layout.preferredWidth: root._labelWidth
122 text: qsTr("Vehicle")
123 color: qgcPal.textSecondary
124 }
125
126 FactComboBox {
127 objectName: "planPanel_vehicleTypeCombo"
128 Layout.fillWidth: true
129 fact: QGroundControl.settingsManager.appSettings.offlineEditingVehicleClass
130 indexModel: false
131 visible: root._allowVehicleSelection
132 }
133
134 QGCLabel {
135 objectName: "planPanel_vehicleTypeLabel"
136 Layout.fillWidth: true
137 text: root._controllerVehicle ? root._controllerVehicle.vehicleTypeString : ""
138 visible: !root._allowVehicleSelection
139 }
140 }
141
142 RowLayout {
143 Layout.fillWidth: true
144 spacing: root._margin
145
146 QGCLabel {
147 Layout.preferredWidth: root._labelWidth
148 text: qsTr("Home")
149 color: qgcPal.textSecondary
150 }
151
152 Rectangle {
153 Layout.preferredWidth: ScreenTools.defaultFontPixelHeight * 0.5
154 Layout.preferredHeight: Layout.preferredWidth
155 radius: width / 2
156 color: root._missionController.homePositionSet ? qgcPal.colorGreen : "transparent"
157 border.color: root._missionController.homePositionSet ? qgcPal.colorGreen : qgcPal.textSecondary
158 }
159
160 QGCLabel {
161 objectName: "planPanel_homeStatus"
162 Layout.fillWidth: true
163 wrapMode: Text.WordWrap
164 text: {
165 if (!root._missionController.homePositionSet) {
166 return qsTr("Not set. Click in the map to set it.")
167 }
168 if (root._settingsItem) {
169 if (root._settingsItem.terrainQueryFailed) {
170 return qsTr("Set, altitude (AMSL)")
171 }
172 return qsTr("Set, %1 %2 AMSL").arg(root._settingsItem.plannedHomePositionAltitude.valueString).arg(root._settingsItem.plannedHomePositionAltitude.units)
173 }
174 return qsTr("Set")
175 }
176 }
177
178 Loader {
179 active: root._missionController.homePositionSet && root._settingsItem !== null && root._settingsItem.terrainQueryFailed
180
181 sourceComponent: FactTextField {
182 objectName: "planPanel_homeAltitude"
183 fact: root._settingsItem.plannedHomePositionAltitude
184 }
185 }
186 }
187
188 PlanPanelGroupHeader {
189 objectName: "planPanel_templatesHeader"
190 text: qsTr("Start from a template")
191 summary: qsTr("optional")
192 visible: root.planMasterController.showCreateFromTemplate
193 }
194
195 ColumnLayout {
196 objectName: "planPanel_templatesColumn"
197 Layout.fillWidth: true
198 spacing: ScreenTools.defaultFontPixelHeight * 0.5
199 visible: root.planMasterController.showCreateFromTemplate
200 enabled: root._missionController.homePositionSet
201 opacity: enabled ? 1.0 : 0.5
202
203 Repeater {
204 model: root.planMasterController.planCreators
205
206 QGCButton {
207 required property var object
208
209 objectName: "planCreator_" + object.name
210 Layout.fillWidth: true
211 text: object.name
212
213 onClicked: {
214 if (!mainWindow.allowViewSwitch()) {
215 return
216 }
217 if (object.blankPlan) {
218 root.planMasterController.userSelectedManualCreation = true
219 root.missionTabRequested()
220 } else {
221 object.createPlan(root.editorMap.center)
222 }
223 }
224 }
225 }
226 }
227
228 PlanPanelGroupHeader {
229 text: qsTr("Defaults")
230 }
231
232 Item {
233 Layout.fillWidth: true
234 Layout.preferredHeight: defaultsLoader.item ? defaultsLoader.item.height : 0
235
236 // Only the width is set so the editor keeps the height of its own content
237 Loader {
238 id: defaultsLoader
239
240 width: parent.width
241 active: root._settingsItem !== null
242
243 sourceComponent: MissionDefaultsEditor {
244 objectName: "planPanel_defaults"
245 missionController: root._missionController
246 planMasterController: root.planMasterController
247 }
248 }
249 }
250
251 PlanPanelGroupHeader {
252 text: qsTr("Tools")
253 }
254
255 QGCButton {
256 objectName: "planPanel_transformButton"
257 Layout.fillWidth: true
258 text: qsTr("Transform mission...")
259 onClicked: transformDialogFactory.open()
260 }
261 }
262}