6import QGroundControl.Controls
7import QGroundControl.FactControls
9/// Plan tab: plan info, templates for a new plan, mission defaults and tools
13 required property var planMasterController
14 required property var editorMap
16 signal missionTabRequested
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
30 objectName: "planPanel_page_plan"
31 contentHeight: column.height + _margin * 2
32 flickableDirection: Flickable.VerticalFlick
35 QGCPalette { id: qgcPal }
37 QGCPopupDialogFactory {
38 id: transformDialogFactory
40 dialogComponent: transformDialogComponent
44 id: transformDialogComponent
47 title: qsTr("Transform Mission")
51 missionController: root._missionController
52 width: ScreenTools.defaultFontPixelWidth * 50
62 width: root.width - root._margin * 2
63 spacing: ScreenTools.defaultFontPixelHeight * 0.5
65 PlanPanelGroupHeader {
70 Layout.fillWidth: true
74 Layout.preferredWidth: root._labelWidth
76 color: qgcPal.textSecondary
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
89 Layout.fillWidth: true
91 visible: !root._waypointsOnlyMode && root._multipleFirmware
94 Layout.preferredWidth: root._labelWidth
95 text: qsTr("Firmware")
96 color: qgcPal.textSecondary
100 objectName: "planPanel_firmwareCombo"
101 Layout.fillWidth: true
102 fact: QGroundControl.settingsManager.appSettings.offlineEditingFirmwareClass
104 visible: root._allowVehicleSelection
108 objectName: "planPanel_firmwareLabel"
109 Layout.fillWidth: true
110 text: root._controllerVehicle ? root._controllerVehicle.firmwareTypeString : ""
111 visible: !root._allowVehicleSelection
116 Layout.fillWidth: true
117 spacing: root._margin
118 visible: !root._waypointsOnlyMode && root._multipleVehicleTypes
121 Layout.preferredWidth: root._labelWidth
122 text: qsTr("Vehicle")
123 color: qgcPal.textSecondary
127 objectName: "planPanel_vehicleTypeCombo"
128 Layout.fillWidth: true
129 fact: QGroundControl.settingsManager.appSettings.offlineEditingVehicleClass
131 visible: root._allowVehicleSelection
135 objectName: "planPanel_vehicleTypeLabel"
136 Layout.fillWidth: true
137 text: root._controllerVehicle ? root._controllerVehicle.vehicleTypeString : ""
138 visible: !root._allowVehicleSelection
143 Layout.fillWidth: true
144 spacing: root._margin
147 Layout.preferredWidth: root._labelWidth
149 color: qgcPal.textSecondary
153 Layout.preferredWidth: ScreenTools.defaultFontPixelHeight * 0.5
154 Layout.preferredHeight: Layout.preferredWidth
156 color: root._missionController.homePositionSet ? qgcPal.colorGreen : "transparent"
157 border.color: root._missionController.homePositionSet ? qgcPal.colorGreen : qgcPal.textSecondary
161 objectName: "planPanel_homeStatus"
162 Layout.fillWidth: true
163 wrapMode: Text.WordWrap
165 if (!root._missionController.homePositionSet) {
166 return qsTr("Not set. Click in the map to set it.")
168 if (root._settingsItem) {
169 if (root._settingsItem.terrainQueryFailed) {
170 return qsTr("Set, altitude (AMSL)")
172 return qsTr("Set, %1 %2 AMSL").arg(root._settingsItem.plannedHomePositionAltitude.valueString).arg(root._settingsItem.plannedHomePositionAltitude.units)
179 active: root._missionController.homePositionSet && root._settingsItem !== null && root._settingsItem.terrainQueryFailed
181 sourceComponent: FactTextField {
182 objectName: "planPanel_homeAltitude"
183 fact: root._settingsItem.plannedHomePositionAltitude
188 PlanPanelGroupHeader {
189 objectName: "planPanel_templatesHeader"
190 text: qsTr("Start from a template")
191 summary: qsTr("optional")
192 visible: root.planMasterController.showCreateFromTemplate
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
204 model: root.planMasterController.planCreators
207 required property var object
209 objectName: "planCreator_" + object.name
210 Layout.fillWidth: true
214 if (!mainWindow.allowViewSwitch()) {
217 if (object.blankPlan) {
218 root.planMasterController.userSelectedManualCreation = true
219 root.missionTabRequested()
221 object.createPlan(root.editorMap.center)
228 PlanPanelGroupHeader {
229 text: qsTr("Defaults")
233 Layout.fillWidth: true
234 Layout.preferredHeight: defaultsLoader.item ? defaultsLoader.item.height : 0
236 // Only the width is set so the editor keeps the height of its own content
241 active: root._settingsItem !== null
243 sourceComponent: MissionDefaultsEditor {
244 objectName: "planPanel_defaults"
245 missionController: root._missionController
246 planMasterController: root.planMasterController
251 PlanPanelGroupHeader {
256 objectName: "planPanel_transformButton"
257 Layout.fillWidth: true
258 text: qsTr("Transform mission...")
259 onClicked: transformDialogFactory.open()