SurveyItemEditor.qml 5.93 KB
Newer Older
1 2 3
import QtQuick                  2.2
import QtQuick.Controls         1.2

4
import QGroundControl               1.0
5 6 7 8 9 10 11 12 13
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
14
    height:     visible ? (editorColumn.height + (_margin * 2)) : 0
15 16 17 18 19 20 21 22
    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
23
    property real _margin: ScreenTools.defaultFontPixelWidth / 2
24 25 26 27 28 29 30 31

    QGCPalette { id: qgcPal; colorGroupEnabled: true }

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

        QGCLabel {
36 37 38
            wrapMode:       Text.WordWrap
            font.pointSize: ScreenTools.smallFontPointSize
            text:           qsTr("Work in progress, be careful!")
39 40
        }

41
        Repeater {
42
            model: [ missionItem.gridAngle, missionItem.gridSpacing, missionItem.gridAltitude ]
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

            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
65 66
        QGCCheckBox {
            anchors.left:   parent.left
67
            text:           qsTr("Relative altitude")
Don Gagne's avatar
Don Gagne committed
68 69 70 71
            checked:        missionItem.gridAltitudeRelative
            onClicked:      missionItem.gridAltitudeRelative = checked
        }

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

        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
90
                text:               qsTr("Distance:")
Don Gagne's avatar
Don Gagne committed
91 92 93 94 95 96 97 98 99 100 101
            }

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

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

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

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

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

118
        QGCLabel { text: qsTr("Polygon:") }
Don Gagne's avatar
Don Gagne committed
119

120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
        Rectangle {
            anchors.left:   parent.left
            anchors.right:  parent.right
            height:         1
            color:          qgcPal.text
        }

        Row {
            spacing: ScreenTools.defaultFontPixelWidth

            QGCButton {
                text:       editorMap.polygonDraw.drawingPolygon ? qsTr("Finish Draw") : qsTr("Draw")
                visible:    !editorMap.polygonDraw.adjustingPolygon
                enabled:    ((editorMap.polygonDraw.drawingPolygon && editorMap.polygonDraw.polygonReady) || !editorMap.polygonDraw.drawingPolygon)

                onClicked: {
                    if (editorMap.polygonDraw.drawingPolygon) {
                        editorMap.polygonDraw.finishCapturePolygon()
                    } else {
                        editorMap.polygonDraw.startCapturePolygon()
                    }
141 142 143
                }
            }

144 145 146
            QGCButton {
                text:       editorMap.polygonDraw.adjustingPolygon ? qsTr("Finish Adjust") : qsTr("Adjust")
                visible:    missionItem.polygonPath.length > 0 && !editorMap.polygonDraw.drawingPolygon
147

148 149 150 151 152 153
                onClicked: {
                    if (editorMap.polygonDraw.adjustingPolygon) {
                        editorMap.polygonDraw.finishAdjustPolygon()
                    } else {
                        editorMap.polygonDraw.startAdjustPolygon(missionItem.polygonPath)
                    }
154 155 156
                }
            }
        }
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176

        QGCLabel { text: qsTr("Statistics:") }

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

        Grid {
            columns: 2
            spacing: ScreenTools.defaultFontPixelWidth

            QGCLabel { text: qsTr("Survey area:") }
            QGCLabel { text: QGroundControl.squareMetersToAppSettingsAreaUnits(missionItem.coveredArea).toFixed(2) + " " + QGroundControl.appSettingsAreaUnitsString }

            QGCLabel { text: qsTr("# shots:") }
            QGCLabel { text: missionItem.cameraShots }
        }
177 178
    }
}