Newer
Older
import QtQuick 2.3
import QtQuick.Controls 1.2
import QtQuick.Layouts 1.2
import QGroundControl 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Controls 1.0
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
property var myGeoFenceController
property var flightMap
readonly property real _editFieldWidth: Math.min(width - _margin * 2, ScreenTools.defaultFontPixelWidth * 15)
readonly property real _margin: ScreenTools.defaultFontPixelWidth / 2
readonly property real _radius: ScreenTools.defaultFontPixelWidth / 2
anchors.left: parent.left
anchors.right: parent.right
height: geoFenceItems.y + geoFenceItems.height + (_margin * 2)
radius: _radius
color: qgcPal.missionItemEditor
QGCLabel {
id: geoFenceLabel
anchors.margins: _margin
anchors.left: parent.left
anchors.top: parent.top
text: qsTr("GeoFence")
anchors.leftMargin: ScreenTools.defaultFontPixelWidth
}
id: geoFenceItems
anchors.margins: _margin
anchors.left: parent.left
anchors.right: parent.right
anchors.top: geoFenceLabel.bottom
height: fenceColumn.y + fenceColumn.height + (_margin * 2)
color: qgcPal.windowShadeDark
radius: _radius
Column {
id: fenceColumn
anchors.margins: _margin
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.left: parent.left
anchors.right: parent.right
wrapMode: Text.WordWrap
font.pointSize: myGeoFenceController.supported ? ScreenTools.smallFontPointSize : ScreenTools.defaultFontPointSize
text: myGeoFenceController.supported ?
qsTr("GeoFencing allows you to set a virtual ‘fence’ around the area you want to fly in.") :
qsTr("This vehicle does not support GeoFence.")
}
anchors.left: parent.left
anchors.right: parent.right
spacing: _margin
visible: myGeoFenceController.supported
QGCLabel {
id: textFieldLabel
anchors.baseline: textField.baseline
text: myGeoFenceController.paramLabels[index]
}
FactTextField {
id: textField
anchors.right: parent.right
width: _editFieldWidth
showUnits: true
fact: modelData
visible: !parent.showCombo
}
FactComboBox {
id: comboField
anchors.right: parent.right
width: _editFieldWidth
indexModel: false
fact: showCombo ? modelData : _nullFact
visible: parent.showCombo
id: insertSection
anchors.left: parent.left
anchors.right: parent.right
text: qsTr("Insert GeoFence")
onClicked: {
var rect = Qt.rect(flightMap.centerViewport.x, flightMap.centerViewport.y, flightMap.centerViewport.width, flightMap.centerViewport.height)
var topLeftCoord = flightMap.toCoordinate(Qt.point(rect.x, rect.y), false /* clipToViewPort */)
var bottomRightCoord = flightMap.toCoordinate(Qt.point(rect.x + rect.width, rect.y + rect.height), false /* clipToViewPort */)
myGeoFenceController.addInclusionPolygon(topLeftCoord, bottomRightCoord)
onClicked: {
var rect = Qt.rect(flightMap.centerViewport.x, flightMap.centerViewport.y, flightMap.centerViewport.width, flightMap.centerViewport.height)
var topLeftCoord = flightMap.toCoordinate(Qt.point(rect.x, rect.y), false /* clipToViewPort */)
var bottomRightCoord = flightMap.toCoordinate(Qt.point(rect.x + rect.width, rect.y + rect.height), false /* clipToViewPort */)
myGeoFenceController.addInclusionCircle(topLeftCoord, bottomRightCoord)
id: polygonSection
anchors.left: parent.left
anchors.right: parent.right
text: qsTr("Polygon Fences")
}
QGCLabel {
text: qsTr("None")
visible: polygonSection.checked && myGeoFenceController.polygons.count === 0
}
GridLayout {
Layout.fillWidth: true
columns: 3
flow: GridLayout.TopToBottom
visible: polygonSection.checked && myGeoFenceController.polygons.count > 0
text: qsTr("Inclusion")
Layout.column: 0
Layout.alignment: Qt.AlignHCenter
QGCCheckBox {
checked: object.inclusion
onClicked: object.inclusion = checked
Layout.alignment: Qt.AlignHCenter
}
QGCLabel {
text: qsTr("Edit")
Layout.column: 1
Layout.alignment: Qt.AlignHCenter
}
Layout.alignment: Qt.AlignHCenter
onClicked: {
myGeoFenceController.clearAllInteractive()
object.interactive = checked
QGCLabel {
text: qsTr("Delete")
Layout.column: 2
Layout.alignment: Qt.AlignHCenter
}
QGCButton {
text: qsTr("Del")
Layout.alignment: Qt.AlignHCenter
onClicked: myGeoFenceController.deletePolygon(index)
}
}
} // GridLayout
id: circleSection
anchors.left: parent.left
anchors.right: parent.right
text: qsTr("Circular Fences")
QGCLabel {
text: qsTr("None")
visible: circleSection.checked && myGeoFenceController.circles.count === 0
}
anchors.left: parent.left
anchors.right: parent.right
columns: 4
flow: GridLayout.TopToBottom
visible: polygonSection.checked && myGeoFenceController.circles.count > 0
text: qsTr("Inclusion")
Layout.column: 0
Layout.alignment: Qt.AlignHCenter
QGCCheckBox {
checked: object.inclusion
onClicked: object.inclusion = checked
Layout.alignment: Qt.AlignHCenter
}
QGCLabel {
text: qsTr("Edit")
Layout.column: 1
Layout.alignment: Qt.AlignHCenter
}
Layout.alignment: Qt.AlignHCenter
onClicked: {
myGeoFenceController.clearAllInteractive()
object.interactive = checked
QGCLabel {
text: qsTr("Radius")
Layout.column: 2
Layout.alignment: Qt.AlignHCenter
}
Layout.alignment: Qt.AlignHCenter
}
QGCLabel {
text: qsTr("Delete")
Layout.column: 3
Layout.alignment: Qt.AlignHCenter
}
QGCButton {
text: qsTr("Del")
Layout.alignment: Qt.AlignHCenter
onClicked: myGeoFenceController.deleteCircle(index)
id: breachReturnSection
anchors.left: parent.left
anchors.right: parent.right
text: qsTr("Breach Return Point")
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
}
QGCButton {
text: qsTr("Add Breach Return Point")
visible: breachReturnSection.visible && !myGeoFenceController.breachReturnPoint.isValid
anchors.left: parent.left
anchors.right: parent.right
onClicked: myGeoFenceController.breachReturnPoint = flightMap.center
}
QGCButton {
text: qsTr("Remove Breach Return Point")
visible: breachReturnSection.visible && myGeoFenceController.breachReturnPoint.isValid
anchors.left: parent.left
anchors.right: parent.right
onClicked: myGeoFenceController.breachReturnPoint = QtPositioning.coordinate()
}
ColumnLayout {
anchors.left: parent.left
anchors.right: parent.right
spacing: _margin
visible: breachReturnSection.visible && myGeoFenceController.breachReturnPoint.isValid
QGCLabel {
text: qsTr("Altitude")
}
AltitudeFactTextField {
fact: myGeoFenceController.breachReturnAltitude
altitudeMode: QGroundControl.AltitudeModeRelative
}
}