7import QGroundControl.Controls
8import QGroundControl.FactControls
12 title: qsTr("Edit Position")
15 property alias coordinate: controller.coordinate
16 property var altitudeFact: null
17 property int altitudeFrame: QGroundControl.AltitudeFrameNone
19 property real _margin: ScreenTools.defaultFontPixelWidth / 2
20 property real _textFieldWidth: ScreenTools.defaultFontPixelWidth * 20
21 property bool _showGeographic: coordinateSystemCombo.comboBox.currentIndex === 0
22 property bool _showUTM: coordinateSystemCombo.comboBox.currentIndex === 1
23 property bool _showMGRS: coordinateSystemCombo.comboBox.currentIndex === 2
24 property bool _showVehicle: coordinateSystemCombo.comboBox.currentIndex === 3
25 property bool _supportsAltitude: altitudeFact !== null
27 function _isFiniteAltitude(value) {
28 const numericValue = Number(value)
29 return !isNaN(numericValue) && isFinite(numericValue)
32 TransformPositionController {
35 Component.onCompleted: initValues()
42 id: coordinateSystemCombo
43 Layout.fillWidth: true
44 label: qsTr("Coordinate System")
45 model: globals.activeVehicle ?
46 [ qsTr("Geographic"), qsTr("Universal Transverse Mercator"), qsTr("Military Grid Reference"), qsTr("Vehicle Position") ] :
47 [ qsTr("Geographic"), qsTr("Universal Transverse Mercator"), qsTr("Military Grid Reference") ]
50 LabelledFactTextField {
51 label: qsTr("Latitude")
52 fact: controller.latitude
53 textFieldPreferredWidth: _textFieldWidth
54 Layout.fillWidth: true
55 visible: _showGeographic
58 LabelledFactTextField {
59 label: qsTr("Longitude")
60 fact: controller.longitude
61 textFieldPreferredWidth: _textFieldWidth
62 Layout.fillWidth: true
63 visible: _showGeographic
66 LabelledFactTextField {
69 textFieldPreferredWidth: _textFieldWidth
70 Layout.fillWidth: true
74 LabelledFactComboBox {
75 label: qsTr("Hemisphere")
76 fact: controller.hemisphere
78 Layout.fillWidth: true
82 LabelledFactTextField {
83 label: qsTr("Easting")
84 fact: controller.easting
85 textFieldPreferredWidth: _textFieldWidth
86 Layout.fillWidth: true
90 LabelledFactTextField {
91 label: qsTr("Northing")
92 fact: controller.northing
93 textFieldPreferredWidth: _textFieldWidth
94 Layout.fillWidth: true
98 LabelledFactTextField {
100 fact: controller.mgrs
102 textFieldPreferredWidth: _textFieldWidth
103 Layout.fillWidth: true
107 label: qsTr("Latitude")
108 labelText: globals.activeVehicle ? globals.activeVehicle.coordinate.latitude.toFixed(7) : ""
109 Layout.fillWidth: true
110 visible: _showVehicle
114 label: qsTr("Longitude")
115 labelText: globals.activeVehicle ? globals.activeVehicle.coordinate.longitude.toFixed(7) : ""
116 Layout.fillWidth: true
117 visible: _showVehicle
121 label: qsTr("Alt (AMSL)")
122 labelText: globals.activeVehicle ? globals.activeVehicle.altitudeAMSL.valueString + " " + globals.activeVehicle.altitudeAMSL.units : ""
123 Layout.fillWidth: true
124 visible: _showVehicle && _supportsAltitude && altitudeFrame === QGroundControl.AltitudeFrameAbsolute
128 label: qsTr("Alt (Rel)")
129 labelText: globals.activeVehicle ? globals.activeVehicle.altitudeRelative.valueString + " " + globals.activeVehicle.altitudeRelative.units : ""
130 Layout.fillWidth: true
131 visible: _showVehicle && _supportsAltitude && altitudeFrame === QGroundControl.AltitudeFrameRelative
135 label: qsTr("Alt (AGL)")
136 labelText: globals.activeVehicle ? globals.activeVehicle.altitudeAboveTerr.valueString + " " + globals.activeVehicle.altitudeAboveTerr.units : ""
137 Layout.fillWidth: true
138 visible: _showVehicle && _supportsAltitude && (altitudeFrame === QGroundControl.AltitudeFrameTerrain || altitudeFrame === QGroundControl.AltitudeFrameCalcAboveTerrain)
142 id: setPositionCheckBox
143 text: qsTr("Set position from vehicle")
145 visible: _showVehicle
149 id: setAltitudeCheckBox
150 text: qsTr("Set altitude from vehicle")
152 visible: _showVehicle && _supportsAltitude
156 label: qsTr("Set position")
157 buttonText: qsTr("Move")
160 controller.setFromGeo()
162 controller.setFromUTM()
164 controller.setFromMGRS()
165 else if (_showVehicle) {
166 if (setPositionCheckBox.checked)
167 controller.setFromVehicle()
168 if (setAltitudeCheckBox.checked && _supportsAltitude && globals.activeVehicle) {
169 let sourceAltitude = NaN
171 if (altitudeFrame === QGroundControl.AltitudeFrameRelative)
172 sourceAltitude = globals.activeVehicle.altitudeRelative.rawValue
173 else if (altitudeFrame === QGroundControl.AltitudeFrameAbsolute)
174 sourceAltitude = globals.activeVehicle.altitudeAMSL.rawValue
175 else if (altitudeFrame === QGroundControl.AltitudeFrameTerrain || altitudeFrame === QGroundControl.AltitudeFrameCalcAboveTerrain)
176 sourceAltitude = globals.activeVehicle.altitudeAboveTerr.rawValue
178 if (_isFiniteAltitude(sourceAltitude))
179 altitudeFact.rawValue = sourceAltitude