SurveyItemEditor.qml 4.84 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
import QtQuick                  2.2
import QtQuick.Controls         1.2

import QGroundControl.ScreenTools   1.0
import QGroundControl.Vehicle       1.0
import QGroundControl.Controls      1.0
import QGroundControl.FactControls  1.0
import QGroundControl.Palette       1.0

// Editor for Survery mission items
Rectangle {
    id:         _root
13
    height:     visible ? (editorColumn.height + (_margin * 2)) : 0
14 15 16 17 18 19 20 21
    width:      availableWidth
    color:      qgcPal.windowShadeDark
    radius:     _radius

    // The following properties must be available up the hierachy chain
    //property real   availableWidth    ///< Width for control
    //property var    missionItem       ///< Mission Item for editor

Don Gagne's avatar
Don Gagne committed
22
    property real _margin: ScreenTools.defaultFontPixelWidth / 2
23 24 25 26 27 28 29 30

    QGCPalette { id: qgcPal; colorGroupEnabled: true }

    Column {
        id:                 editorColumn
        anchors.margins:    _margin
        anchors.top:        parent.top
        anchors.left:       parent.left
31
        anchors.right:      parent.right
32 33 34
        spacing:            _margin

        QGCLabel {
35 36 37
            wrapMode:       Text.WordWrap
            font.pointSize: ScreenTools.smallFontPointSize
            text:           qsTr("Work in progress, be careful!")
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
        Repeater {
            model: [ missionItem.gridAltitude, missionItem.gridAngle, missionItem.gridSpacing ]

            Item {
                anchors.left:   parent.left
                anchors.right:  parent.right
                height:         textField.height

                QGCLabel {
                    anchors.baseline:   textField.baseline
                    anchors.left:       parent.left
                    text:               modelData.name
                }

                FactTextField {
                    id:             textField
                    anchors.right:  parent.right
                    width:          _editFieldWidth
                    showUnits:      true
                    fact:           modelData
                }
            }
        }

Don Gagne's avatar
Don Gagne committed
64 65
        QGCCheckBox {
            anchors.left:   parent.left
66
            text:           qsTr("Relative altitude")
Don Gagne's avatar
Don Gagne committed
67 68 69 70
            checked:        missionItem.gridAltitudeRelative
            onClicked:      missionItem.gridAltitudeRelative = checked
        }

Don Gagne's avatar
Don Gagne committed
71 72 73
        QGCCheckBox {
            id:                 cameraTrigger
            anchors.left:       parent.left
74
            text:               qsTr("Camera trigger:")
Don Gagne's avatar
Don Gagne committed
75
            checked:            missionItem.cameraTrigger
Don Gagne's avatar
Don Gagne committed
76
            onClicked:          missionItem.cameraTrigger = checked
Don Gagne's avatar
Don Gagne committed
77 78 79 80 81 82 83 84 85 86 87 88
        }

        Item {
            id:             distanceItem
            anchors.left:   parent.left
            anchors.right:  parent.right
            height:         textField.height
            enabled:        cameraTrigger.checked

            QGCLabel {
                anchors.baseline:   textField.baseline
                anchors.left:       parent.left
89
                text:               qsTr("Distance:")
Don Gagne's avatar
Don Gagne committed
90 91 92 93 94 95 96 97 98 99 100
            }

            FactTextField {
                id:             textField
                anchors.right:  parent.right
                width:          _editFieldWidth
                showUnits:      true
                fact:           missionItem.cameraTriggerDistance
            }
        }

Don Gagne's avatar
Don Gagne committed
101 102 103
        Connections {
            target: editorMap.polygonDraw

104
            onPolygonCaptureStarted: {
Don Gagne's avatar
Don Gagne committed
105 106 107
                missionItem.clearPolygon()
            }

108
            onPolygonCaptureFinished: {
Don Gagne's avatar
Don Gagne committed
109 110 111 112
                for (var i=0; i<coordinates.length; i++) {
                    missionItem.addPolygonCoordinate(coordinates[i])
                }
            }
113 114

            onPolygonAdjustVertex: missionItem.adjustPolygonCoordinate(vertexIndex, vertexCoordinate)
Don Gagne's avatar
Don Gagne committed
115 116
        }

117
        QGCButton {
118 119 120
            text:       editorMap.polygonDraw.drawingPolygon ? qsTr("Finish Draw") : qsTr("Draw Polygon")
            enabled:    ((editorMap.polygonDraw.drawingPolygon && editorMap.polygonDraw.polygonReady) || !editorMap.polygonDraw.drawingPolygon) &&
                        !editorMap.polygonDraw.adjustingPolygon
Don Gagne's avatar
Don Gagne committed
121

122
            onClicked: {
Don Gagne's avatar
Don Gagne committed
123
                if (editorMap.polygonDraw.drawingPolygon) {
124 125 126 127 128 129 130 131 132 133 134 135 136 137
                    editorMap.polygonDraw.finishCapturePolygon()
                } else {
                    editorMap.polygonDraw.startCapturePolygon()
                }
            }
        }

        QGCButton {
            text:       editorMap.polygonDraw.adjustingPolygon ? qsTr("Finish Adjust") : qsTr("Adjust Polygon")
            enabled:    !editorMap.polygonDraw.drawingPolygon

            onClicked: {
                if (editorMap.polygonDraw.adjustingPolygon) {
                    editorMap.polygonDraw.finishAdjustPolygon()
138
                } else {
139
                    editorMap.polygonDraw.startAdjustPolygon(missionItem.polygonPath)
140 141 142 143 144
                }
            }
        }
    }
}