QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
PlanInfoEditor.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
9Rectangle {
10 id: _root
11
12 required property var planMasterController
13 required property var missionController
14 required property var editorMap
15
16 property var _controllerVehicle: planMasterController.controllerVehicle
17 property var _visualItems: missionController.visualItems
18 property bool _noMissionItemsAdded: _visualItems ? _visualItems.count <= 1 : true
19 property var _settingsItem: _visualItems && _visualItems.count > 0 ? _visualItems.get(0) : null
20 property bool _multipleFirmware: !QGroundControl.singleFirmwareSupport
21 property bool _multipleVehicleTypes: !QGroundControl.singleVehicleSupport
22 property bool _allowFWVehicleTypeSelection: _noMissionItemsAdded && !globals.activeVehicle
23 property bool _waypointsOnlyMode: QGroundControl.corePlugin.options.missionWaypointsOnly
24 property real _fieldWidth: ScreenTools.defaultFontPixelWidth * 16
25
26 width: parent ? parent.width : 0
27 height: mainColumn.height + ScreenTools.defaultFontPixelHeight
28 color: qgcPal.windowShadeDark
29
30 QGCPalette { id: qgcPal; colorGroupEnabled: _root.enabled }
31
32 ColumnLayout {
33 id: mainColumn
34 anchors.left: parent.left
35 anchors.right: parent.right
36 anchors.verticalCenter: parent.verticalCenter
37 anchors.margins: ScreenTools.defaultFontPixelWidth
38 spacing: ScreenTools.defaultFontPixelHeight * 0.25
39
40 ColumnLayout {
41 Layout.fillWidth: true
42 spacing: 0
43
44 QGCLabel {
45 text: qsTr("Plan File")
46 }
47
48 QGCLabel {
49 Layout.fillWidth: true
50 elide: Text.ElideMiddle
51 textFormat: Text.PlainText
52 enabled: _root.planMasterController.currentPlanFileName !== ""
53 text: _root.planMasterController.currentPlanFileName === "" ? qsTr("<Untitled>") : _root.planMasterController.currentPlanFileName
54 }
55 }
56
57 // ── Vehicle Info ──
58 SectionHeader {
59 id: vehicleInfoSectionHeader
60 Layout.fillWidth: true
61 text: qsTr("Vehicle Info")
62 visible: !_root._waypointsOnlyMode && (_root._multipleFirmware || _root._multipleVehicleTypes)
63 }
64
65 RowLayout {
66 Layout.fillWidth: true
67 spacing: ScreenTools.defaultFontPixelWidth
68 visible: vehicleInfoSectionHeader.visible && vehicleInfoSectionHeader.checked
69
70 FactComboBox {
71 objectName: "planInfo_firmwareCombo"
72 fact: QGroundControl.settingsManager.appSettings.offlineEditingFirmwareClass
73 indexModel: false
74 Layout.fillWidth: true
75 visible: _root._multipleFirmware && _root._allowFWVehicleTypeSelection
76 }
77 QGCLabel {
78 objectName: "planInfo_firmwareLabel"
79 text: _root._controllerVehicle ? _root._controllerVehicle.firmwareTypeString : ""
80 Layout.fillWidth: true
81 visible: _root._multipleFirmware && !_root._allowFWVehicleTypeSelection
82 }
83
84 FactComboBox {
85 objectName: "planInfo_vehicleTypeCombo"
86 fact: QGroundControl.settingsManager.appSettings.offlineEditingVehicleClass
87 indexModel: false
88 Layout.fillWidth: true
89 visible: _root._multipleVehicleTypes && _root._allowFWVehicleTypeSelection
90 }
91 QGCLabel {
92 objectName: "planInfo_vehicleTypeLabel"
93 text: _root._controllerVehicle ? _root._controllerVehicle.vehicleTypeString : ""
94 Layout.fillWidth: true
95 visible: _root._multipleVehicleTypes && !_root._allowFWVehicleTypeSelection
96 }
97 }
98
99 // ── Expected Home Position ──
100 SectionHeader {
101 id: plannedHomePositionSection
102 Layout.fillWidth: true
103 text: qsTr("Expected Home Position")
104 }
105
106 // Prompt to click map to set/move home position
107 ColumnLayout {
108 Layout.fillWidth: true
109 Layout.topMargin: ScreenTools.defaultFontPixelWidth / 2
110 spacing: ScreenTools.defaultFontPixelWidth / 2
111 visible: plannedHomePositionSection.checked && _root.planMasterController.showCreateFromTemplate
112
113 Image {
114 source: "qrc:///qmlimages/MapHome.svg"
115 Layout.alignment: Qt.AlignHCenter
116 Layout.preferredWidth: ScreenTools.defaultFontPixelHeight * 2
117 Layout.preferredHeight: Layout.preferredWidth
118 fillMode: Image.PreserveAspectFit
119 }
120
121 QGCLabel {
122 Layout.fillWidth: true
123 wrapMode: Text.WordWrap
124 horizontalAlignment: Text.AlignHCenter
125 text: qsTr("Click in map to set position")
126 visible: !_root.missionController.homePositionSet
127 }
128
129 QGCLabel {
130 Layout.fillWidth: true
131 wrapMode: Text.WordWrap
132 horizontalAlignment: Text.AlignHCenter
133 text: qsTr("Drag to move home position. Click to set new position.")
134 visible: _root.missionController.homePositionSet
135 }
136 }
137
138 // Normal home position controls (shown only when home is set)
139 GridLayout {
140 Layout.fillWidth: true
141 columnSpacing: ScreenTools.defaultFontPixelWidth
142 columns: 2
143 visible: plannedHomePositionSection.checked && _root.missionController.homePositionSet
144
145 QGCLabel {
146 text: qsTr("Altitude (AMSL)")
147 font.pointSize: ScreenTools.smallFontPointSize
148 }
149 FactTextField {
150 fact: _root._settingsItem ? _root._settingsItem.plannedHomePositionAltitude : null
151 Layout.fillWidth: true
152 font.pointSize: ScreenTools.smallFontPointSize
153 visible: _root._settingsItem && _root._settingsItem.terrainQueryFailed
154 }
155 QGCLabel {
156 text: _root._settingsItem ? _root._settingsItem.plannedHomePositionAltitude.valueString + " " + _root._settingsItem.plannedHomePositionAltitude.units : ""
157 Layout.fillWidth: true
158 font.pointSize: ScreenTools.smallFontPointSize
159 visible: !_root._settingsItem || !_root._settingsItem.terrainQueryFailed
160 }
161 }
162
163 QGCLabel {
164 Layout.fillWidth: true
165 wrapMode: Text.WordWrap
166 font.pointSize: ScreenTools.smallFontPointSize
167 text: qsTr("Actual position/alt set by vehicle at flight time.")
168 horizontalAlignment: Text.AlignHCenter
169 visible: plannedHomePositionSection.checked && _root.missionController.homePositionSet
170 }
171
172 // ── Plan Templates ──
173 SectionHeader {
174 id: planTemplateSectionHeader
175 objectName: "planInfo_templatesSection"
176 Layout.fillWidth: true
177 text: qsTr("Plan Templates")
178 visible: _root.planMasterController.showCreateFromTemplate
179 }
180
181 ColumnLayout {
182 objectName: "planInfo_templatesColumn"
183 Layout.fillWidth: true
184 spacing: ScreenTools.defaultFontPixelHeight / 2
185 visible: planTemplateSectionHeader.visible && planTemplateSectionHeader.checked
186 enabled: _root.missionController.homePositionSet
187 opacity: enabled ? 1.0 : 0.5
188
189 Repeater {
190 model: _root.planMasterController.planCreators
191
192 QGCButton {
193 objectName: "planCreator_" + object.name
194 Layout.fillWidth: true
195 text: object.name
196 onClicked: {
197 if (object.blankPlan) {
198 _root.planMasterController.userSelectedManualCreation = true
199 } else {
200 object.createPlan(_root.editorMap.center)
201 }
202 }
203 }
204 }
205 }
206 }
207}