FWLandingPatternEditor.qml 8.66 KB
Newer Older
1 2 3 4 5 6 7 8 9
/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

10 11
import QtQuick          2.3
import QtQuick.Controls 1.2
12
import QtQuick.Dialogs  1.2
13
import QtQuick.Layouts  1.2
14 15 16 17 18

import QGroundControl               1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.Vehicle       1.0
import QGroundControl.Controls      1.0
19
import QGroundControl.FactSystem    1.0
20 21 22 23 24 25
import QGroundControl.FactControls  1.0
import QGroundControl.Palette       1.0

// Editor for Fixed Wing Landing Pattern complex mission item
Rectangle {
    id:         _root
26
    height:     visible ? ((editorColumn.visible ? editorColumn.height : editorColumnNeedLandingPoint.height) + (_margin * 2)) : 0
27 28 29 30 31 32 33 34
    width:      availableWidth
    color:      qgcPal.windowShadeDark
    radius:     _radius

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

35 36 37
    property var    _masterControler:               masterController
    property var    _missionController:             _masterControler.missionController
    property var    _missionVehicle:                _masterControler.controllerVehicle
38 39 40 41 42
    property real   _margin:                    ScreenTools.defaultFontPixelWidth / 2
    property real   _spacer:                    ScreenTools.defaultFontPixelWidth / 2
    property var    _activeVehicle:             QGroundControl.multiVehicleManager.activeVehicle
    property string _setToVehicleHeadingStr:    qsTr("Set to vehicle heading")
    property string _setToVehicleLocationStr:   qsTr("Set to vehicle location")
43
    property bool   _showCameraSection:         !_missionVehicle.apmFirmware
44

45

46 47
    ExclusiveGroup { id: distanceGlideGroup }

48
    Column {
49 50 51 52
        id:                 editorColumn
        anchors.margins:    _margin
        anchors.left:       parent.left
        anchors.right:      parent.right
53
        spacing:            _margin
54
        visible:            missionItem.landingCoordSet
55

56
        SectionHeader {
57 58
            id:     loiterPointSection
            text:   qsTr("Loiter point")
59
        }
60

61 62 63 64 65
        Column {
            anchors.left:       parent.left
            anchors.right:      parent.right
            spacing:            _margin
            visible:            loiterPointSection.checked
66

67
            Item { width: 1; height: _spacer }
68

69 70 71 72 73 74
            FactTextFieldGrid {
                anchors.left:   parent.left
                anchors.right:  parent.right
                factList:       [ missionItem.loiterAltitude, missionItem.loiterRadius ]
                factLabels:     [ qsTr("Altitude"), qsTr("Radius") ]
            }
75

76 77 78 79 80 81 82 83 84 85 86 87 88
            Item { width: 1; height: _spacer }

            QGCCheckBox {
                text:           qsTr("Loiter clockwise")
                checked:        missionItem.loiterClockwise
                onClicked:      missionItem.loiterClockwise = checked
            }

            QGCButton {
                text:       _setToVehicleHeadingStr
                visible:    _activeVehicle
                onClicked:  missionItem.landingHeading.rawValue = _activeVehicle.heading.rawValue
            }
89 90
        }

91 92 93 94
        SectionHeader {
            id:     landingPointSection
            text:   qsTr("Landing point")
        }
95

96 97 98 99 100 101 102
        Column {
            anchors.left:       parent.left
            anchors.right:      parent.right
            spacing:            _margin
            visible:            landingPointSection.checked

            Item { width: 1; height: _spacer }
103

104 105 106 107
            GridLayout {
                anchors.left:    parent.left
                anchors.right:   parent.right
                columns:         2
108

109
                QGCLabel { text: qsTr("Heading") }
DonLakeFlyer's avatar
DonLakeFlyer committed
110 111 112 113 114 115

                FactTextField {
                    Layout.fillWidth:   true
                    fact:               missionItem.landingHeading
                }

116
                QGCLabel { text: qsTr("Altitude") }
DonLakeFlyer's avatar
DonLakeFlyer committed
117 118 119 120 121 122

                FactTextField {
                    Layout.fillWidth:   true
                    fact:               missionItem.landingAltitude
                }

123 124 125
                QGCRadioButton {
                    id:                 specifyLandingDistance
                    text:               qsTr("Landing Dist")
126
                    checked:            missionItem.valueSetIsDistance.rawValue
127
                    exclusiveGroup:     distanceGlideGroup
128
                    onClicked:          missionItem.valueSetIsDistance.rawValue = checked
129 130
                    Layout.fillWidth:   true
                }
131

132 133 134 135 136
                FactTextField {
                    fact:               missionItem.landingDistance
                    enabled:            specifyLandingDistance.checked
                    Layout.fillWidth:   true
                }
137

138 139 140
                QGCRadioButton {
                    id:                 specifyGlideSlope
                    text:               qsTr("Glide Slope")
141
                    checked:            !missionItem.valueSetIsDistance.rawValue
142
                    exclusiveGroup:     distanceGlideGroup
143
                    onClicked:          missionItem.valueSetIsDistance.rawValue = !checked
144 145 146 147 148 149 150 151
                    Layout.fillWidth:   true
                }

                FactTextField {
                    fact:               missionItem.glideSlope
                    enabled:            specifyGlideSlope.checked
                    Layout.fillWidth:   true
                }
152

153 154 155 156 157 158
                QGCButton {
                    text:               _setToVehicleLocationStr
                    visible:            _activeVehicle
                    Layout.columnSpan:  2
                    onClicked:          missionItem.landingCoordinate = _activeVehicle.coordinate
                }
159
            }
160 161
        }

162 163 164 165
        Item { width: 1; height: _spacer }

        QGCCheckBox {
            anchors.right:  parent.right
166 167
            text:           qsTr("Altitudes relative to home")
            checked:        missionItem.altitudesAreRelative
168
            visible:        QGroundControl.corePlugin.options.showMissionAbsoluteAltitude || !missionItem.altitudesAreRelative
169
            onClicked:      missionItem.altitudesAreRelative = checked
170
        }
171 172

        SectionHeader {
173 174 175
            id:         cameraSection
            text:       qsTr("Camera")
            visible:    _showCameraSection
176 177 178 179 180 181
        }

        Column {
            anchors.left:       parent.left
            anchors.right:      parent.right
            spacing:            _margin
182
            visible:            _showCameraSection && cameraSection.checked
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199

            Item { width: 1; height: _spacer }

            FactCheckBox {
                text:       _stopTakingPhotos.shortDescription
                fact:       _stopTakingPhotos

                property Fact _stopTakingPhotos: missionItem.stopTakingPhotos
            }

            FactCheckBox {
                text:       _stopTakingVideo.shortDescription
                fact:       _stopTakingVideo

                property Fact _stopTakingVideo: missionItem.stopTakingVideo
            }
        }
200
    }
201 202 203 204

    Column {
        id:                 editorColumnNeedLandingPoint
        anchors.margins:    _margin
205
        anchors.top:        parent.top
206 207 208
        anchors.left:       parent.left
        anchors.right:      parent.right
        visible:            !missionItem.landingCoordSet
Don Gagne's avatar
Don Gagne committed
209
        spacing:            ScreenTools.defaultFontPixelHeight
210

Don Gagne's avatar
Don Gagne committed
211
        QGCLabel {
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
            anchors.left:           parent.left
            anchors.right:          parent.right
            wrapMode:               Text.WordWrap
            horizontalAlignment:    Text.AlignHCenter
            text:                   qsTr("Click in map to set landing point.")
        }

        QGCLabel {
            anchors.left:           parent.left
            anchors.right:          parent.right
            horizontalAlignment:    Text.AlignHCenter
            text:                   qsTr("- or -")
            visible:                _activeVehicle
        }

        QGCButton {
            anchors.horizontalCenter:   parent.horizontalCenter
            text:                       _setToVehicleLocationStr
            visible:                    _activeVehicle

            onClicked: {
                missionItem.landingCoordinate = _activeVehicle.coordinate
                missionItem.landingHeading.rawValue = _activeVehicle.heading.rawValue
            }
Don Gagne's avatar
Don Gagne committed
236
        }
237
    }
238
}