QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
TransformEditor.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 missionController
13
14 width: parent ? parent.width : 0
15 height: mainColumn.height + (_margins * 2)
16 color: QGroundControl.globalPalette.windowPanel
17
18 property real _margins: ScreenTools.defaultFontPixelWidth / 2
19 property real _textFieldWidth: ScreenTools.defaultFontPixelWidth * 20
20 property real _labelWidth: ScreenTools.defaultFontPixelWidth * 14
21 property bool _hasHome: missionController ? missionController.plannedHomePosition.isValid : false
22
23 TransformPositionController {
24 id: positionController
25 Component.onCompleted: {
26 if (_hasHome) {
27 coordinate = _root.missionController.plannedHomePosition
28 initValues()
29 }
30 }
31 }
32
33 Connections {
34 target: _root.missionController
35 function onPlannedHomePositionChanged() {
36 positionController.coordinate = _root.missionController.plannedHomePosition
37 positionController.initValues()
38 }
39 }
40
41 ColumnLayout {
42 id: mainColumn
43 anchors.left: parent.left
44 anchors.right: parent.right
45 anchors.top: parent.top
46 anchors.margins: _margins
47 spacing: ScreenTools.defaultFontPixelHeight * 0.5
48
49 // ── Offset Mission ──
50 SectionHeader {
51 id: offsetSection
52 Layout.fillWidth: true
53 text: qsTr("Offset Mission")
54 checked: false
55 }
56
57 ColumnLayout {
58 Layout.fillWidth: true
59 spacing: _margins
60 visible: offsetSection.checked
61
62 LabelledFactTextField {
63 id: eastField
64 label: qsTr("East")
65 fact: positionController.offsetEast
66 textFieldPreferredWidth: _textFieldWidth
67 Layout.fillWidth: true
68 }
69
70 LabelledFactTextField {
71 id: northField
72 label: qsTr("North")
73 fact: positionController.offsetNorth
74 textFieldPreferredWidth: _textFieldWidth
75 Layout.fillWidth: true
76 }
77
78 LabelledFactTextField {
79 id: upField
80 label: qsTr("Up")
81 fact: positionController.offsetUp
82 textFieldPreferredWidth: _textFieldWidth
83 Layout.fillWidth: true
84 }
85
86 QGCCheckBox {
87 id: offsetTakeoffCheck
88 text: qsTr("Also move takeoff items")
89 }
90
91 QGCCheckBox {
92 id: offsetLandingCheck
93 text: qsTr("Also move landing items")
94 }
95
96 QGCLabel {
97 Layout.fillWidth: true
98 Layout.maximumWidth: _labelWidth + _textFieldWidth
99 wrapMode: Text.WordWrap
100 font.pointSize: ScreenTools.smallFontPointSize
101 text: qsTr("Note: Home altitude is not modified.")
102 }
103
104 QGCButton {
105 Layout.alignment: Qt.AlignHCenter
106 text: qsTr("Apply Offset")
107 enabled: !eastField.textField.validationError
108 && !northField.textField.validationError
109 && !upField.textField.validationError
110
111 onClicked: {
112 _root.missionController.offsetMission(
113 positionController.offsetEast.rawValue,
114 positionController.offsetNorth.rawValue,
115 positionController.offsetUp.rawValue,
116 offsetTakeoffCheck.checked,
117 offsetLandingCheck.checked
118 )
119 }
120 }
121 }
122
123 // ── Reposition Mission ──
124 SectionHeader {
125 id: repositionSection
126 Layout.fillWidth: true
127 text: qsTr("Reposition Mission")
128 checked: false
129 }
130
131 ColumnLayout {
132 id: repositionContent
133 Layout.fillWidth: true
134 spacing: _margins
135 visible: repositionSection.checked
136
137 QGCLabel {
138 Layout.fillWidth: true
139 wrapMode: Text.WordWrap
140 font.pointSize: ScreenTools.smallFontPointSize
141 text: qsTr("Home position must be set to reposition the mission.")
142 visible: !_hasHome
143 }
144
145 property bool _showGeographic: coordinateSystemCombo.currentIndex === 0
146 property bool _showDMS: coordinateSystemCombo.currentIndex === 1
147 property bool _showUTM: coordinateSystemCombo.currentIndex === 2
148 property bool _showMGRS: coordinateSystemCombo.currentIndex === 3
149 property bool _showVehicle: coordinateSystemCombo.currentIndex === 4
150
151 ColumnLayout {
152 Layout.fillWidth: true
153 spacing: 0
154
155 QGCLabel {
156 text: qsTr("Coordinate System")
157 }
158
159 QGCComboBox {
160 id: coordinateSystemCombo
161 Layout.fillWidth: true
162 model: globals.activeVehicle
163 ? [ qsTr("Geographic"), qsTr("Degrees Minutes Seconds"), qsTr("Universal Transverse Mercator"), qsTr("Military Grid Reference"), qsTr("Vehicle Position") ]
164 : [ qsTr("Geographic"), qsTr("Degrees Minutes Seconds"), qsTr("Universal Transverse Mercator"), qsTr("Military Grid Reference") ]
165
166 Component.onCompleted: currentIndex = positionController.defaultCoordinateSystem
167 }
168 }
169
170 LabelledFactTextField {
171 id: latitudeField
172 label: qsTr("Latitude")
173 fact: positionController.latitude
174 textFieldPreferredWidth: _textFieldWidth
175 Layout.fillWidth: true
176 visible: repositionContent._showGeographic
177 }
178
179 LabelledFactTextField {
180 id: longitudeField
181 label: qsTr("Longitude")
182 fact: positionController.longitude
183 textFieldPreferredWidth: _textFieldWidth
184 Layout.fillWidth: true
185 visible: repositionContent._showGeographic
186 }
187
188 QGCButton {
189 Layout.alignment: Qt.AlignHCenter
190 text: qsTr("Move to Position")
191 enabled: _hasHome && !latitudeField.textField.validationError && !longitudeField.textField.validationError
192 visible: repositionContent._showGeographic
193 onClicked: {
194 positionController.setFromGeo()
195 _root.missionController.repositionMission(positionController.coordinate)
196 }
197 }
198
199 LabelledFactTextField {
200 id: latitudeDMSField
201 label: qsTr("Latitude")
202 fact: positionController.latitudeDMS
203 textFieldPreferredWidth: _textFieldWidth
204 Layout.fillWidth: true
205 visible: repositionContent._showDMS
206 }
207
208 LabelledFactTextField {
209 id: longitudeDMSField
210 label: qsTr("Longitude")
211 fact: positionController.longitudeDMS
212 textFieldPreferredWidth: _textFieldWidth
213 Layout.fillWidth: true
214 visible: repositionContent._showDMS
215 }
216
217 QGCButton {
218 Layout.alignment: Qt.AlignHCenter
219 text: qsTr("Move to Position")
220 enabled: _hasHome
221 visible: repositionContent._showDMS
222 onClicked: {
223 if (positionController.setFromDMS())
224 _root.missionController.repositionMission(positionController.coordinate)
225 else
226 QGroundControl.showMessageDialog(_root, qsTr("Move to Position"), qsTr("Invalid coordinate. Check the entered values and try again."))
227 }
228 }
229
230 LabelledFactTextField {
231 id: zoneField
232 label: qsTr("Zone")
233 fact: positionController.zone
234 textFieldPreferredWidth: _textFieldWidth
235 Layout.fillWidth: true
236 visible: repositionContent._showUTM
237 }
238
239 LabelledFactComboBox {
240 label: qsTr("Hemisphere")
241 fact: positionController.hemisphere
242 indexModel: false
243 Layout.fillWidth: true
244 visible: repositionContent._showUTM
245 }
246
247 LabelledFactTextField {
248 id: eastingField
249 label: qsTr("Easting")
250 fact: positionController.easting
251 textFieldPreferredWidth: _textFieldWidth
252 Layout.fillWidth: true
253 visible: repositionContent._showUTM
254 }
255
256 LabelledFactTextField {
257 id: northingField
258 label: qsTr("Northing")
259 fact: positionController.northing
260 textFieldPreferredWidth: _textFieldWidth
261 Layout.fillWidth: true
262 visible: repositionContent._showUTM
263 }
264
265 QGCButton {
266 Layout.alignment: Qt.AlignHCenter
267 text: qsTr("Move to Position")
268 enabled: _hasHome && !zoneField.textField.validationError && !eastingField.textField.validationError && !northingField.textField.validationError
269 visible: repositionContent._showUTM
270 onClicked: {
271 if (positionController.setFromUTM())
272 _root.missionController.repositionMission(positionController.coordinate)
273 else
274 QGroundControl.showMessageDialog(_root, qsTr("Move to Position"), qsTr("Invalid coordinate. Check the entered values and try again."))
275 }
276 }
277
278 LabelledFactTextField {
279 id: mgrsField
280 label: qsTr("MGRS")
281 fact: positionController.mgrs
282 textFieldPreferredWidth: _textFieldWidth
283 Layout.fillWidth: true
284 visible: repositionContent._showMGRS
285 }
286
287 QGCButton {
288 Layout.alignment: Qt.AlignHCenter
289 text: qsTr("Move to Position")
290 enabled: _hasHome && !mgrsField.textField.validationError
291 visible: repositionContent._showMGRS
292 onClicked: {
293 if (positionController.setFromMGRS())
294 _root.missionController.repositionMission(positionController.coordinate)
295 else
296 QGroundControl.showMessageDialog(_root, qsTr("Move to Position"), qsTr("Invalid coordinate. Check the entered values and try again."))
297 }
298 }
299
300 QGCButton {
301 Layout.alignment: Qt.AlignHCenter
302 text: qsTr("Move to Vehicle Position")
303 enabled: _hasHome
304 visible: repositionContent._showVehicle
305 onClicked: {
306 positionController.setFromVehicle()
307 _root.missionController.repositionMission(positionController.coordinate)
308 }
309 }
310 }
311
312 // ── Rotate Mission ──
313 SectionHeader {
314 id: rotateSection
315 Layout.fillWidth: true
316 text: qsTr("Rotate Mission")
317 checked: false
318 }
319
320 ColumnLayout {
321 Layout.fillWidth: true
322 spacing: _margins
323 visible: rotateSection.checked
324
325 QGCLabel {
326 Layout.fillWidth: true
327 wrapMode: Text.WordWrap
328 font.pointSize: ScreenTools.smallFontPointSize
329 text: qsTr("Home position must be set to rotate the mission.")
330 visible: !_hasHome
331 }
332
333 LabelledFactTextField {
334 id: degreesCWField
335 label: qsTr("Clockwise")
336 fact: positionController.rotateDegreesCW
337 textFieldPreferredWidth: _textFieldWidth
338 Layout.fillWidth: true
339 }
340
341 QGCCheckBox {
342 id: rotateTakeoffCheck
343 text: qsTr("Also move takeoff items")
344 }
345
346 QGCCheckBox {
347 id: rotateLandingCheck
348 text: qsTr("Also move landing items")
349 }
350
351 QGCLabel {
352 Layout.fillWidth: true
353 Layout.maximumWidth: _labelWidth + _textFieldWidth
354 wrapMode: Text.WordWrap
355 font.pointSize: ScreenTools.smallFontPointSize
356 text: qsTr("Note: Complex items are rotated by moving their reference coordinate: their geometry and orientation are not changed.")
357 }
358
359 QGCButton {
360 Layout.alignment: Qt.AlignHCenter
361 text: qsTr("Apply Rotation")
362 enabled: _hasHome && !degreesCWField.textField.validationError
363
364 onClicked: {
365 _root.missionController.rotateMission(
366 positionController.rotateDegreesCW.rawValue,
367 rotateTakeoffCheck.checked,
368 rotateLandingCheck.checked
369 )
370 }
371 }
372 }
373 }
374}