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 && QGroundControl.settingsManager.appSettings.preferredFirmwareClass.rawValue === 0
21 property bool _multipleVehicleTypes: !QGroundControl.singleVehicleSupport && QGroundControl.settingsManager.appSettings.preferredVehicleClass.rawValue === 0
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 QGCTextField {
49 id: planNameField
50 placeholderText: qsTr("Untitled")
51 Layout.fillWidth: true
52
53 Component.onCompleted: text = _root.planMasterController.currentPlanFileName
54
55 Connections {
56 target: _root.planMasterController
57 function onCurrentPlanFileNameChanged() {
58 if (!planNameField.activeFocus) {
59 planNameField.text = _root.planMasterController.currentPlanFileName
60 }
61 }
62 }
63
64 onEditingFinished: _root.planMasterController.currentPlanFileName = text
65 }
66 }
67
68 // ── Vehicle Info ──
69 SectionHeader {
70 id: vehicleInfoSectionHeader
71 Layout.fillWidth: true
72 text: qsTr("Vehicle Info")
73 visible: !_root._waypointsOnlyMode && (_root._multipleFirmware || _root._multipleVehicleTypes)
74 }
75
76 RowLayout {
77 Layout.fillWidth: true
78 spacing: ScreenTools.defaultFontPixelWidth
79 visible: vehicleInfoSectionHeader.visible && vehicleInfoSectionHeader.checked
80
81 FactComboBox {
82 fact: QGroundControl.settingsManager.appSettings.offlineEditingFirmwareClass
83 indexModel: false
84 Layout.fillWidth: true
85 visible: _root._multipleFirmware && _root._allowFWVehicleTypeSelection
86 }
87 QGCLabel {
88 text: _root._controllerVehicle ? _root._controllerVehicle.firmwareTypeString : ""
89 Layout.fillWidth: true
90 visible: _root._multipleFirmware && !_root._allowFWVehicleTypeSelection
91 }
92
93 FactComboBox {
94 fact: QGroundControl.settingsManager.appSettings.offlineEditingVehicleClass
95 indexModel: false
96 Layout.fillWidth: true
97 visible: _root._multipleVehicleTypes && _root._allowFWVehicleTypeSelection
98 }
99 QGCLabel {
100 text: _root._controllerVehicle ? _root._controllerVehicle.vehicleTypeString : ""
101 Layout.fillWidth: true
102 visible: _root._multipleVehicleTypes && !_root._allowFWVehicleTypeSelection
103 }
104 }
105
106 // ── Expected Home Position ──
107 SectionHeader {
108 id: plannedHomePositionSection
109 Layout.fillWidth: true
110 text: qsTr("Expected Home Position")
111 }
112
113 // Prompt to click map to set/move home position
114 ColumnLayout {
115 Layout.fillWidth: true
116 Layout.topMargin: ScreenTools.defaultFontPixelWidth / 2
117 spacing: ScreenTools.defaultFontPixelWidth / 2
118 visible: plannedHomePositionSection.checked && _root.planMasterController.showCreateFromTemplate
119
120 Image {
121 source: "qrc:///qmlimages/MapHome.svg"
122 Layout.alignment: Qt.AlignHCenter
123 Layout.preferredWidth: ScreenTools.defaultFontPixelHeight * 2
124 Layout.preferredHeight: Layout.preferredWidth
125 fillMode: Image.PreserveAspectFit
126 }
127
128 QGCLabel {
129 Layout.fillWidth: true
130 wrapMode: Text.WordWrap
131 horizontalAlignment: Text.AlignHCenter
132 text: qsTr("Click in map to set position")
133 visible: !_root.missionController.homePositionSet
134 }
135
136 QGCLabel {
137 Layout.fillWidth: true
138 wrapMode: Text.WordWrap
139 horizontalAlignment: Text.AlignHCenter
140 text: qsTr("Drag to move home position. Click to set new position.")
141 visible: _root.missionController.homePositionSet
142 }
143 }
144
145 // Normal home position controls (shown only when home is set)
146 GridLayout {
147 Layout.fillWidth: true
148 columnSpacing: ScreenTools.defaultFontPixelWidth
149 columns: 2
150 visible: plannedHomePositionSection.checked && _root.missionController.homePositionSet
151
152 QGCLabel {
153 text: qsTr("Altitude (AMSL)")
154 font.pointSize: ScreenTools.smallFontPointSize
155 }
156 FactTextField {
157 fact: _root._settingsItem ? _root._settingsItem.plannedHomePositionAltitude : null
158 Layout.fillWidth: true
159 font.pointSize: ScreenTools.smallFontPointSize
160 visible: _root._settingsItem && _root._settingsItem.terrainQueryFailed
161 }
162 QGCLabel {
163 text: _root._settingsItem ? _root._settingsItem.plannedHomePositionAltitude.valueString + " " + _root._settingsItem.plannedHomePositionAltitude.units : ""
164 Layout.fillWidth: true
165 font.pointSize: ScreenTools.smallFontPointSize
166 visible: !_root._settingsItem || !_root._settingsItem.terrainQueryFailed
167 }
168 }
169
170 QGCLabel {
171 Layout.fillWidth: true
172 wrapMode: Text.WordWrap
173 font.pointSize: ScreenTools.smallFontPointSize
174 text: qsTr("Actual position/alt set by vehicle at flight time.")
175 horizontalAlignment: Text.AlignHCenter
176 visible: plannedHomePositionSection.checked && _root.missionController.homePositionSet
177 }
178
179 // ── Plan Templates ──
180 SectionHeader {
181 id: planTemplateSectionHeader
182 Layout.fillWidth: true
183 text: qsTr("Plan Templates")
184 visible: _root.planMasterController.showCreateFromTemplate
185 }
186
187 ColumnLayout {
188 Layout.fillWidth: true
189 spacing: ScreenTools.defaultFontPixelHeight / 2
190 visible: planTemplateSectionHeader.visible && planTemplateSectionHeader.checked
191 enabled: _root.missionController.homePositionSet
192 opacity: enabled ? 1.0 : 0.5
193
194 Repeater {
195 model: _root.planMasterController.planCreators
196
197 QGCButton {
198 Layout.fillWidth: true
199 text: object.name
200 onClicked: {
201 if (object.blankPlan) {
202 _root.planMasterController.userSelectedManualCreation = true
203 } else {
204 object.createPlan(_root.editorMap.center)
205 }
206 }
207 }
208 }
209 }
210 }
211}