PX4GeoFenceEditor.qml 3.25 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
import QtQuick          2.2
import QtQuick.Controls 1.2

import QGroundControl               1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Controls      1.0
import QGroundControl.FactControls  1.0
import QGroundControl.Palette       1.0
import QGroundControl.FlightMap     1.0
import QGroundControl.FactSystem    1.0
import QGroundControl.Controllers   1.0

Column {
    id:         editorColumn
    width:      availableWidth
    spacing:    _margin

    //property real availableWidth - Available width for control - Must be passed in from Loader

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

    property Fact _fenceAction:     factController.getParameterFact(-1, "GF_ACTION")
    property Fact _fenceRadius:     factController.getParameterFact(-1, "GF_MAX_HOR_DIST")
25
    property Fact _fenceMaxAlt:     factController.getParameterFact(-1, "GF_MAX_VER_DIST")
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82

    FactPanelController {
        id:         factController
        factPanel:  qgcView.viewPanel
    }

    QGCLabel { text: qsTr("Fence Settings:") }

    Rectangle {
        anchors.left:   parent.left
        anchors.right:  parent.right
        height:         1
        color:          qgcPal.text
    }

    QGCLabel { text: qsTr("Action on fence breach:") }
    FactComboBox {
        anchors.margins:    ScreenTools.defaultFontPixelWidth
        anchors.left:       parent.left
        width:              _editFieldWidth
        fact:               _fenceAction
        indexModel:         false
    }

    Item { width:  1; height: 1 }

    QGCCheckBox {
        id:                 circleFenceCheckBox
        text:               qsTr("Circular fence around home pos")
        checked:            _fenceRadius.value > 0
        onClicked:          _fenceRadius.value = checked ? 100 : 0
    }

    Row {
        anchors.margins:    ScreenTools.defaultFontPixelWidth
        anchors.left:       parent.left
        spacing:        _margin

        QGCLabel {
            anchors.baseline: fenceRadiusField.baseline
            text: qsTr("Radius:")
        }

        FactTextField {
            id:                 fenceRadiusField
            showUnits:          true
            fact:               _fenceRadius
            enabled:            circleFenceCheckBox.checked
            width:              _editFieldWidth
        }
    }

    Item { width:  1; height: 1 }

    QGCCheckBox {
        id:                 maxAltFenceCheckBox
        text:               qsTr("Maximum altitude fence")
83 84
        checked:            _fenceMaxAlt.value > 0
        onClicked:          _fenceMaxAlt.value = checked ? 100 : 0
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
    }

    Row {
        anchors.margins:    ScreenTools.defaultFontPixelWidth
        anchors.left:       parent.left
        spacing:            _margin

        QGCLabel {
            anchors.baseline: fenceAltMaxField.baseline
            text: qsTr("Altitude:")
        }

        FactTextField {
            id:                 fenceAltMaxField
            showUnits:          true
100
            fact:               _fenceMaxAlt
101 102 103 104 105
            enabled:            maxAltFenceCheckBox.checked
            width:              _editFieldWidth
        }
    }
}