GeoFenceEditor.qml 4.65 KB
Newer Older
1 2
import QtQuick          2.3
import QtQuick.Controls 1.2
3 4 5 6

import QGroundControl               1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Controls      1.0
7 8
import QGroundControl.FactSystem    1.0
import QGroundControl.FactControls  1.0
9 10 11 12 13 14 15 16

QGCFlickable {
    id:             root
    width:          availableWidth
    height:         Math.min(availableHeight, geoFenceEditorRect.height)
    contentHeight:  geoFenceEditorRect.height
    clip:           true

17 18 19 20 21
    property real   availableWidth
    property real   availableHeight
    property var    myGeoFenceController
    property var    flightMap

22
    readonly property real  _editFieldWidth:    Math.min(width - _margin * 2, ScreenTools.defaultFontPixelWidth * 15)
23 24 25
    readonly property real  _margin:            ScreenTools.defaultFontPixelWidth / 2
    readonly property real  _radius:            ScreenTools.defaultFontPixelWidth / 2

26
    property var polygon: myGeoFenceController.polygon
27 28 29 30 31 32

    Rectangle {
        id:     geoFenceEditorRect
        width:  parent.width
        height: geoFenceItems.y + geoFenceItems.height + (_margin * 2)
        radius: _radius
Don Gagne's avatar
Don Gagne committed
33
        color:  qgcPal.missionItemEditor
34 35 36 37 38 39

        QGCLabel {
            id:                 geoFenceLabel
            anchors.margins:    _margin
            anchors.left:       parent.left
            anchors.top:        parent.top
Don Gagne's avatar
Don Gagne committed
40
            text:               qsTr("GeoFence")
41 42 43 44 45 46 47 48 49
            color:              "black"
        }

        Rectangle {
            id:                 geoFenceItems
            anchors.margins:    _margin
            anchors.left:       parent.left
            anchors.right:      parent.right
            anchors.top:        geoFenceLabel.bottom
50
            height:             fenceColumn.y + fenceColumn.height + (_margin * 2)
51 52 53
            color:              qgcPal.windowShadeDark
            radius:             _radius

54 55
            Column {
                id:                 fenceColumn
56 57 58
                anchors.margins:    _margin
                anchors.left:       parent.left
                anchors.right:      parent.right
59
                spacing:            ScreenTools.defaultFontPixelHeight / 2
60

61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
                QGCLabel {
                    id:                 geoLabel
                    anchors.left:       parent.left
                    anchors.right:      parent.right
                    wrapMode:           Text.WordWrap
                    font.pointSize:     ScreenTools.smallFontPointSize
                    text:               qsTr("GeoFencing allows you to set a virtual ‘fence’ around the area you want to fly in.")
                }

                Repeater {
                    model: myGeoFenceController.params

                    Item {
                        width:  fenceColumn.width
                        height: textField.height

                        property bool showCombo: modelData.enumStrings.length > 0

                        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

                            property var _nullFact: Fact { }
                        }
                    }
                }

                QGCButton {
                    text:       qsTr("Add fence polygon")
                    visible:    myGeoFenceController.polygonSupported && myGeoFenceController.mapPolygon.count === 0
                    onClicked:  myGeoFenceController.addPolygon()
                }
112

113 114 115 116 117
                QGCButton {
                    text:       qsTr("Remove fence polygon")
                    visible:    myGeoFenceController.polygonSupported && myGeoFenceController.mapPolygon.count > 0
                    onClicked:  myGeoFenceController.removePolygon()
                }
118 119 120 121
            }
        }
    }
}