7import QGroundControl.Controls
8import QGroundControl.FactControls
11 id: geoFenceEditorRect
12 height: geoFenceItems.y + geoFenceItems.height + (_margin * 2)
14 color: qgcPal.buttonHighlight
16 property var myGeoFenceController
17 property var flightMap
19 readonly property real _editFieldWidth: Math.min(width - _margin * 2, ScreenTools.defaultFontPixelWidth * 15)
20 readonly property real _margin: ScreenTools.defaultFontPixelWidth / 2
21 readonly property real _radius: ScreenTools.defaultFontPixelWidth / 2
25 anchors.margins: _margin
26 anchors.left: parent.left
27 anchors.top: parent.top
28 text: qsTr("GeoFence")
29 anchors.leftMargin: ScreenTools.defaultFontPixelWidth
34 anchors.margins: _margin
35 anchors.left: parent.left
36 anchors.right: parent.right
37 anchors.top: geoFenceLabel.bottom
38 height: fenceColumn.y + fenceColumn.height + (_margin * 2)
39 color: qgcPal.windowShadeDark
44 anchors.margins: _margin
45 anchors.top: parent.top
46 anchors.left: parent.left
47 anchors.right: parent.right
51 anchors.left: parent.left
52 anchors.right: parent.right
53 wrapMode: Text.WordWrap
54 font.pointSize: myGeoFenceController.supported ? ScreenTools.smallFontPointSize : ScreenTools.defaultFontPointSize
55 text: myGeoFenceController.supported ?
56 qsTr("GeoFencing allows you to set a virtual fence around the area you want to fly in.") :
57 qsTr("This vehicle does not support GeoFence.")
61 anchors.left: parent.left
62 anchors.right: parent.right
64 visible: myGeoFenceController.supported
67 model: myGeoFenceController.params
70 width: fenceColumn.width
71 height: textField.height
73 property bool showCombo: modelData.enumStrings.length > 0
77 anchors.baseline: textField.baseline
78 text: myGeoFenceController.paramLabels[index]
83 anchors.right: parent.right
84 width: _editFieldWidth
87 visible: !parent.showCombo
92 anchors.right: parent.right
93 width: _editFieldWidth
95 fact: showCombo ? modelData : _nullFact
96 visible: parent.showCombo
98 property var _nullFact: Fact { }
105 anchors.left: parent.left
106 anchors.right: parent.right
107 text: qsTr("Insert GeoFence")
111 Layout.fillWidth: true
112 text: qsTr("Polygon Fence")
115 var rect = Qt.rect(flightMap.centerViewport.x, flightMap.centerViewport.y, flightMap.centerViewport.width, flightMap.centerViewport.height)
116 var topLeftCoord = flightMap.toCoordinate(Qt.point(rect.x, rect.y), false /* clipToViewPort */)
117 var bottomRightCoord = flightMap.toCoordinate(Qt.point(rect.x + rect.width, rect.y + rect.height), false /* clipToViewPort */)
118 myGeoFenceController.addInclusionPolygon(topLeftCoord, bottomRightCoord)
123 Layout.fillWidth: true
124 text: qsTr("Circular Fence")
127 var rect = Qt.rect(flightMap.centerViewport.x, flightMap.centerViewport.y, flightMap.centerViewport.width, flightMap.centerViewport.height)
128 var topLeftCoord = flightMap.toCoordinate(Qt.point(rect.x, rect.y), false /* clipToViewPort */)
129 var bottomRightCoord = flightMap.toCoordinate(Qt.point(rect.x + rect.width, rect.y + rect.height), false /* clipToViewPort */)
130 myGeoFenceController.addInclusionCircle(topLeftCoord, bottomRightCoord)
136 anchors.left: parent.left
137 anchors.right: parent.right
138 text: qsTr("Polygon Fences")
143 visible: polygonSection.checked && myGeoFenceController.polygons.count === 0
147 Layout.fillWidth: true
149 flow: GridLayout.TopToBottom
150 visible: polygonSection.checked && myGeoFenceController.polygons.count > 0
153 text: qsTr("Inclusion")
155 Layout.alignment: Qt.AlignHCenter
159 model: myGeoFenceController.polygons
162 checked: object.inclusion
163 onClicked: object.inclusion = checked
164 Layout.alignment: Qt.AlignHCenter
171 Layout.alignment: Qt.AlignHCenter
175 model: myGeoFenceController.polygons
178 checked: _interactive
179 Layout.alignment: Qt.AlignHCenter
181 property bool _interactive: object.interactive
183 on_InteractiveChanged: checked = _interactive
186 myGeoFenceController.clearAllInteractive()
187 object.interactive = checked
195 Layout.alignment: Qt.AlignHCenter
199 model: myGeoFenceController.polygons
203 Layout.alignment: Qt.AlignHCenter
204 onClicked: myGeoFenceController.deletePolygon(index)
211 anchors.left: parent.left
212 anchors.right: parent.right
213 text: qsTr("Circular Fences")
218 visible: circleSection.checked && myGeoFenceController.circles.count === 0
222 anchors.left: parent.left
223 anchors.right: parent.right
225 flow: GridLayout.TopToBottom
226 visible: polygonSection.checked && myGeoFenceController.circles.count > 0
229 text: qsTr("Inclusion")
231 Layout.alignment: Qt.AlignHCenter
235 model: myGeoFenceController.circles
238 checked: object.inclusion
239 onClicked: object.inclusion = checked
240 Layout.alignment: Qt.AlignHCenter
247 Layout.alignment: Qt.AlignHCenter
251 model: myGeoFenceController.circles
254 checked: _interactive
255 Layout.alignment: Qt.AlignHCenter
257 property bool _interactive: object.interactive
259 on_InteractiveChanged: checked = _interactive
262 myGeoFenceController.clearAllInteractive()
263 object.interactive = checked
271 Layout.alignment: Qt.AlignHCenter
275 model: myGeoFenceController.circles
279 Layout.fillWidth: true
280 Layout.alignment: Qt.AlignHCenter
287 Layout.alignment: Qt.AlignHCenter
291 model: myGeoFenceController.circles
295 Layout.alignment: Qt.AlignHCenter
296 onClicked: myGeoFenceController.deleteCircle(index)
302 id: breachReturnSection
303 anchors.left: parent.left
304 anchors.right: parent.right
305 text: qsTr("Breach Return Point")
309 text: qsTr("Add Breach Return Point")
310 visible: breachReturnSection.visible && !myGeoFenceController.breachReturnPoint.isValid
311 anchors.left: parent.left
312 anchors.right: parent.right
314 onClicked: myGeoFenceController.breachReturnPoint = flightMap.center
318 text: qsTr("Remove Breach Return Point")
319 visible: breachReturnSection.visible && myGeoFenceController.breachReturnPoint.isValid
320 anchors.left: parent.left
321 anchors.right: parent.right
323 onClicked: myGeoFenceController.breachReturnPoint = QtPositioning.coordinate()
327 anchors.left: parent.left
328 anchors.right: parent.right
330 visible: breachReturnSection.visible && myGeoFenceController.breachReturnPoint.isValid
333 text: qsTr("Altitude")
337 fact: myGeoFenceController.breachReturnAltitude