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.windowShadeDark
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 _showUTM: coordinateSystemCombo.currentIndex === 1
147 property bool _showMGRS: coordinateSystemCombo.currentIndex === 2
148 property bool _showVehicle: coordinateSystemCombo.currentIndex === 3
149
150 ColumnLayout {
151 Layout.fillWidth: true
152 spacing: 0
153
154 QGCLabel {
155 text: qsTr("Coordinate System")
156 }
157
158 QGCComboBox {
159 id: coordinateSystemCombo
160 Layout.fillWidth: true
161 model: globals.activeVehicle
162 ? [ qsTr("Geographic"), qsTr("Universal Transverse Mercator"), qsTr("Military Grid Reference"), qsTr("Vehicle Position") ]
163 : [ qsTr("Geographic"), qsTr("Universal Transverse Mercator"), qsTr("Military Grid Reference") ]
164 }
165 }
166
167 LabelledFactTextField {
168 id: latitudeField
169 label: qsTr("Latitude")
170 fact: positionController.latitude
171 textFieldPreferredWidth: _textFieldWidth
172 Layout.fillWidth: true
173 visible: repositionContent._showGeographic
174 }
175
176 LabelledFactTextField {
177 id: longitudeField
178 label: qsTr("Longitude")
179 fact: positionController.longitude
180 textFieldPreferredWidth: _textFieldWidth
181 Layout.fillWidth: true
182 visible: repositionContent._showGeographic
183 }
184
185 QGCButton {
186 Layout.alignment: Qt.AlignHCenter
187 text: qsTr("Move to Position")
188 enabled: _hasHome && !latitudeField.textField.validationError && !longitudeField.textField.validationError
189 visible: repositionContent._showGeographic
190 onClicked: {
191 positionController.setFromGeo()
192 _root.missionController.repositionMission(positionController.coordinate)
193 }
194 }
195
196 LabelledFactTextField {
197 id: zoneField
198 label: qsTr("Zone")
199 fact: positionController.zone
200 textFieldPreferredWidth: _textFieldWidth
201 Layout.fillWidth: true
202 visible: repositionContent._showUTM
203 }
204
205 LabelledFactComboBox {
206 label: qsTr("Hemisphere")
207 fact: positionController.hemisphere
208 indexModel: false
209 Layout.fillWidth: true
210 visible: repositionContent._showUTM
211 }
212
213 LabelledFactTextField {
214 id: eastingField
215 label: qsTr("Easting")
216 fact: positionController.easting
217 textFieldPreferredWidth: _textFieldWidth
218 Layout.fillWidth: true
219 visible: repositionContent._showUTM
220 }
221
222 LabelledFactTextField {
223 id: northingField
224 label: qsTr("Northing")
225 fact: positionController.northing
226 textFieldPreferredWidth: _textFieldWidth
227 Layout.fillWidth: true
228 visible: repositionContent._showUTM
229 }
230
231 QGCButton {
232 Layout.alignment: Qt.AlignHCenter
233 text: qsTr("Move to Position")
234 enabled: _hasHome && !zoneField.textField.validationError && !eastingField.textField.validationError && !northingField.textField.validationError
235 visible: repositionContent._showUTM
236 onClicked: {
237 positionController.setFromUTM()
238 _root.missionController.repositionMission(positionController.coordinate)
239 }
240 }
241
242 LabelledFactTextField {
243 id: mgrsField
244 label: qsTr("MGRS")
245 fact: positionController.mgrs
246 textFieldPreferredWidth: _textFieldWidth
247 Layout.fillWidth: true
248 visible: repositionContent._showMGRS
249 }
250
251 QGCButton {
252 Layout.alignment: Qt.AlignHCenter
253 text: qsTr("Move to Position")
254 enabled: _hasHome && !mgrsField.textField.validationError
255 visible: repositionContent._showMGRS
256 onClicked: {
257 positionController.setFromMGRS()
258 _root.missionController.repositionMission(positionController.coordinate)
259 }
260 }
261
262 QGCButton {
263 Layout.alignment: Qt.AlignHCenter
264 text: qsTr("Move to Vehicle Position")
265 enabled: _hasHome
266 visible: repositionContent._showVehicle
267 onClicked: {
268 positionController.setFromVehicle()
269 _root.missionController.repositionMission(positionController.coordinate)
270 }
271 }
272 }
273
274 // ── Rotate Mission ──
275 SectionHeader {
276 id: rotateSection
277 Layout.fillWidth: true
278 text: qsTr("Rotate Mission")
279 checked: false
280 }
281
282 ColumnLayout {
283 Layout.fillWidth: true
284 spacing: _margins
285 visible: rotateSection.checked
286
287 QGCLabel {
288 Layout.fillWidth: true
289 wrapMode: Text.WordWrap
290 font.pointSize: ScreenTools.smallFontPointSize
291 text: qsTr("Home position must be set to rotate the mission.")
292 visible: !_hasHome
293 }
294
295 LabelledFactTextField {
296 id: degreesCWField
297 label: qsTr("Clockwise")
298 fact: positionController.rotateDegreesCW
299 textFieldPreferredWidth: _textFieldWidth
300 Layout.fillWidth: true
301 }
302
303 QGCCheckBox {
304 id: rotateTakeoffCheck
305 text: qsTr("Also move takeoff items")
306 }
307
308 QGCCheckBox {
309 id: rotateLandingCheck
310 text: qsTr("Also move landing items")
311 }
312
313 QGCLabel {
314 Layout.fillWidth: true
315 Layout.maximumWidth: _labelWidth + _textFieldWidth
316 wrapMode: Text.WordWrap
317 font.pointSize: ScreenTools.smallFontPointSize
318 text: qsTr("Note: Complex items are rotated by moving their reference coordinate: their geometry and orientation are not changed.")
319 }
320
321 QGCButton {
322 Layout.alignment: Qt.AlignHCenter
323 text: qsTr("Apply Rotation")
324 enabled: _hasHome && !degreesCWField.textField.validationError
325
326 onClicked: {
327 _root.missionController.rotateMission(
328 positionController.rotateDegreesCW.rawValue,
329 rotateTakeoffCheck.checked,
330 rotateLandingCheck.checked
331 )
332 }
333 }
334 }
335 }
336}