Commit f1e3b187 authored by Don Gagne's avatar Don Gagne

parent fe691f5c
...@@ -10,13 +10,9 @@ import QGroundControl.FactControls 1.0 ...@@ -10,13 +10,9 @@ import QGroundControl.FactControls 1.0
QGCFlickable { QGCFlickable {
id: root id: root
width: availableWidth contentHeight: geoFenceEditorRect.height
height: availableHeight
contentHeight: editorColumn.height
clip: true clip: true
property real availableWidth
property real availableHeight
property var myGeoFenceController property var myGeoFenceController
property var flightMap property var flightMap
...@@ -24,317 +20,290 @@ QGCFlickable { ...@@ -24,317 +20,290 @@ QGCFlickable {
readonly property real _margin: ScreenTools.defaultFontPixelWidth / 2 readonly property real _margin: ScreenTools.defaultFontPixelWidth / 2
readonly property real _radius: ScreenTools.defaultFontPixelWidth / 2 readonly property real _radius: ScreenTools.defaultFontPixelWidth / 2
Column { Rectangle {
id: editorColumn id: geoFenceEditorRect
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right 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
}
Rectangle { Rectangle {
id: geoFenceEditorRect id: geoFenceItems
width: parent.width anchors.margins: _margin
height: geoFenceItems.y + geoFenceItems.height + (_margin * 2) anchors.left: parent.left
radius: _radius anchors.right: parent.right
color: qgcPal.missionItemEditor anchors.top: geoFenceLabel.bottom
height: fenceColumn.y + fenceColumn.height + (_margin * 2)
QGCLabel { color: qgcPal.windowShadeDark
id: geoFenceLabel radius: _radius
Column {
id: fenceColumn
anchors.margins: _margin anchors.margins: _margin
anchors.left: parent.left
anchors.top: parent.top anchors.top: parent.top
text: qsTr("GeoFence")
anchors.leftMargin: ScreenTools.defaultFontPixelWidth
}
Rectangle {
id: geoFenceItems
anchors.margins: _margin
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.top: geoFenceLabel.bottom spacing: ScreenTools.defaultFontPixelHeight / 2
height: fenceColumn.y + fenceColumn.height + (_margin * 2)
color: qgcPal.windowShadeDark
radius: _radius
Column { QGCLabel {
id: fenceColumn
anchors.margins: _margin
anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
spacing: ScreenTools.defaultFontPixelHeight / 2 wrapMode: Text.WordWrap
font.pointSize: myGeoFenceController.supported ? ScreenTools.smallFontPointSize : ScreenTools.defaultFontPointSize
QGCLabel { text: myGeoFenceController.supported ?
anchors.left: parent.left qsTr("GeoFencing allows you to set a virtual ‘fence’ around the area you want to fly in.") :
anchors.right: parent.right qsTr("This vehicle does not support GeoFence.")
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.")
}
Column { Column {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
spacing: ScreenTools.defaultFontPixelHeight / 2 spacing: ScreenTools.defaultFontPixelHeight / 2
visible: myGeoFenceController.supported visible: myGeoFenceController.supported
Repeater { Repeater {
model: myGeoFenceController.params model: myGeoFenceController.params
Item { Item {
width: fenceColumn.width width: fenceColumn.width
height: textField.height height: textField.height
property bool showCombo: modelData.enumStrings.length > 0 property bool showCombo: modelData.enumStrings.length > 0
QGCLabel { QGCLabel {
id: textFieldLabel id: textFieldLabel
anchors.baseline: textField.baseline anchors.baseline: textField.baseline
text: myGeoFenceController.paramLabels[index] text: myGeoFenceController.paramLabels[index]
} }
FactTextField { FactTextField {
id: textField id: textField
anchors.right: parent.right anchors.right: parent.right
width: _editFieldWidth width: _editFieldWidth
showUnits: true showUnits: true
fact: modelData fact: modelData
visible: !parent.showCombo visible: !parent.showCombo
} }
FactComboBox { FactComboBox {
id: comboField id: comboField
anchors.right: parent.right anchors.right: parent.right
width: _editFieldWidth width: _editFieldWidth
indexModel: false indexModel: false
fact: showCombo ? modelData : _nullFact fact: showCombo ? modelData : _nullFact
visible: parent.showCombo visible: parent.showCombo
property var _nullFact: Fact { } property var _nullFact: Fact { }
}
} }
} }
}
SectionHeader { SectionHeader {
id: insertSection id: insertSection
text: qsTr("Insert GeoFence") text: qsTr("Insert GeoFence")
} }
QGCButton { QGCButton {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
text: qsTr("Polygon Fence") text: qsTr("Polygon Fence")
onClicked: { onClicked: {
var rect = Qt.rect(flightMap.centerViewport.x, flightMap.centerViewport.y, flightMap.centerViewport.width, flightMap.centerViewport.height) 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 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 */) var bottomRightCoord = flightMap.toCoordinate(Qt.point(rect.x + rect.width, rect.y + rect.height), false /* clipToViewPort */)
myGeoFenceController.addInclusionPolygon(topLeftCoord, bottomRightCoord) myGeoFenceController.addInclusionPolygon(topLeftCoord, bottomRightCoord)
}
} }
}
QGCButton { QGCButton {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
text: qsTr("Circular Fence") text: qsTr("Circular Fence")
onClicked: { onClicked: {
var rect = Qt.rect(flightMap.centerViewport.x, flightMap.centerViewport.y, flightMap.centerViewport.width, flightMap.centerViewport.height) 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 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 */) var bottomRightCoord = flightMap.toCoordinate(Qt.point(rect.x + rect.width, rect.y + rect.height), false /* clipToViewPort */)
myGeoFenceController.addInclusionCircle(topLeftCoord, bottomRightCoord) myGeoFenceController.addInclusionCircle(topLeftCoord, bottomRightCoord)
}
} }
}
SectionHeader { SectionHeader {
id: polygonSection id: polygonSection
text: qsTr("Polygon Fences") text: qsTr("Polygon Fences")
} }
QGCLabel {
text: qsTr("None")
visible: polygonSection.checked && myGeoFenceController.polygons.count === 0
}
GridLayout {
anchors.left: parent.left
anchors.right: parent.right
columns: 3
flow: GridLayout.TopToBottom
visible: polygonSection.checked && myGeoFenceController.polygons.count > 0
QGCLabel { QGCLabel {
text: qsTr("None") text: qsTr("Inclusion")
visible: polygonSection.checked && myGeoFenceController.polygons.count === 0 Layout.column: 0
Layout.alignment: Qt.AlignHCenter
} }
GridLayout { Repeater {
anchors.left: parent.left model: myGeoFenceController.polygons
anchors.right: parent.right
columns: 3
flow: GridLayout.TopToBottom
visible: polygonSection.checked && myGeoFenceController.polygons.count > 0
QGCLabel { QGCCheckBox {
text: qsTr("Inclusion") checked: object.inclusion
Layout.column: 0 onClicked: object.inclusion = checked
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
} }
}
Repeater { QGCLabel {
model: myGeoFenceController.polygons text: qsTr("Edit")
Layout.column: 1
Layout.alignment: Qt.AlignHCenter
}
QGCCheckBox { Repeater {
checked: object.inclusion model: myGeoFenceController.polygons
onClicked: object.inclusion = checked
Layout.alignment: Qt.AlignHCenter
}
}
QGCLabel { QGCRadioButton {
text: qsTr("Edit") checked: _interactive
Layout.column: 1
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
}
Repeater {
model: myGeoFenceController.polygons
QGCRadioButton {
checked: _interactive
Layout.alignment: Qt.AlignHCenter
property bool _interactive: object.interactive property bool _interactive: object.interactive
on_InteractiveChanged: checked = _interactive on_InteractiveChanged: checked = _interactive
onClicked: { onClicked: {
myGeoFenceController.clearAllInteractive() myGeoFenceController.clearAllInteractive()
object.interactive = checked object.interactive = checked
}
} }
} }
}
QGCLabel { QGCLabel {
text: qsTr("Delete") text: qsTr("Delete")
Layout.column: 2 Layout.column: 2
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
} }
Repeater { Repeater {
model: myGeoFenceController.polygons model: myGeoFenceController.polygons
QGCColoredImage { QGCButton {
width: ScreenTools.defaultFontPixelHeight text: qsTr("Del")
height: width Layout.alignment: Qt.AlignHCenter
sourceSize.height: width onClicked: myGeoFenceController.deletePolygon(index)
source: "/res/XDelete.svg" }
fillMode: Image.PreserveAspectFit }
color: qgcPal.text } // GridLayout
Layout.alignment: Qt.AlignHCenter
property int _polygonIndex: index SectionHeader {
id: circleSection
text: qsTr("Circular Fences")
}
QGCMouseArea { QGCLabel {
fillItem: parent text: qsTr("None")
onClicked: myGeoFenceController.deletePolygon(parent._polygonIndex) visible: circleSection.checked && myGeoFenceController.circles.count === 0
} }
}
}
} // GridLayout
SectionHeader { GridLayout {
id: circleSection anchors.left: parent.left
text: qsTr("Circular Fences") anchors.right: parent.right
} columns: 4
flow: GridLayout.TopToBottom
visible: polygonSection.checked && myGeoFenceController.circles.count > 0
QGCLabel { QGCLabel {
text: qsTr("None") text: qsTr("Inclusion")
visible: circleSection.checked && myGeoFenceController.circles.count === 0 Layout.column: 0
Layout.alignment: Qt.AlignHCenter
} }
GridLayout { Repeater {
anchors.left: parent.left model: myGeoFenceController.circles
anchors.right: parent.right
columns: 4
flow: GridLayout.TopToBottom
visible: polygonSection.checked && myGeoFenceController.circles.count > 0
QGCLabel { QGCCheckBox {
text: qsTr("Inclusion") checked: object.inclusion
Layout.column: 0 onClicked: object.inclusion = checked
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
} }
}
Repeater { QGCLabel {
model: myGeoFenceController.circles text: qsTr("Edit")
Layout.column: 1
Layout.alignment: Qt.AlignHCenter
}
QGCCheckBox { Repeater {
checked: object.inclusion model: myGeoFenceController.circles
onClicked: object.inclusion = checked
Layout.alignment: Qt.AlignHCenter
}
}
QGCLabel { QGCRadioButton {
text: qsTr("Edit") checked: _interactive
Layout.column: 1
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
}
Repeater {
model: myGeoFenceController.circles
QGCRadioButton { property bool _interactive: object.interactive
checked: _interactive
Layout.alignment: Qt.AlignHCenter
property bool _interactive: object.interactive on_InteractiveChanged: checked = _interactive
on_InteractiveChanged: checked = _interactive onClicked: {
myGeoFenceController.clearAllInteractive()
onClicked: { object.interactive = checked
myGeoFenceController.clearAllInteractive()
object.interactive = checked
}
} }
} }
}
QGCLabel { QGCLabel {
text: qsTr("Radius") text: qsTr("Radius")
Layout.column: 2 Layout.column: 2
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
} }
Repeater {
model: myGeoFenceController.circles
FactTextField { Repeater {
fact: object.radius model: myGeoFenceController.circles
Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter
}
}
QGCLabel { FactTextField {
text: qsTr("Delete") fact: object.radius
Layout.column: 3 Layout.fillWidth: true
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
} }
}
Repeater { QGCLabel {
model: myGeoFenceController.circles text: qsTr("Delete")
Layout.column: 3
QGCColoredImage { Layout.alignment: Qt.AlignHCenter
width: ScreenTools.defaultFontPixelHeight }
height: width
sourceSize.height: width
source: "/res/XDelete.svg"
fillMode: Image.PreserveAspectFit
color: qgcPal.text
Layout.alignment: Qt.AlignHCenter
property int _circleIndex: index Repeater {
model: myGeoFenceController.circles
QGCMouseArea { QGCButton {
fillItem: parent text: qsTr("Del")
onClicked: myGeoFenceController.deleteCircle(parent._polygonIndex) Layout.alignment: Qt.AlignHCenter
} onClicked: myGeoFenceController.deleteCircle(index)
}
} }
} // GridLayout }
} } // GridLayout
} }
} }
} // Rectangle }
} } // Rectangle
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment