SafetyComponent.qml 11.9 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
/*=====================================================================

 QGroundControl Open Source Ground Control Station

 (c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>

 This file is part of the QGROUNDCONTROL project

 QGROUNDCONTROL is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 QGROUNDCONTROL is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.

 ======================================================================*/

Don Gagne's avatar
Don Gagne committed
24 25 26
import QtQuick 2.2
import QtQuick.Controls 1.2
import QtQuick.Controls.Styles 1.2
27

Don Gagne's avatar
Don Gagne committed
28
import QGroundControl.FactSystem 1.0
29
import QGroundControl.FactControls 1.0
30
import QGroundControl.Palette 1.0
Don Gagne's avatar
Don Gagne committed
31
import QGroundControl.Controls 1.0
32
import QGroundControl.ScreenTools 1.0
Don Gagne's avatar
Don Gagne committed
33 34

Rectangle {
35
    QGCPalette { id: palette; colorGroupEnabled: true }
Don Gagne's avatar
Don Gagne committed
36

37
    width: 600
38
    height: 600
Don Gagne's avatar
Don Gagne committed
39
    color: palette.window
Don Gagne's avatar
Don Gagne committed
40 41 42 43 44 45 46 47 48 49

    property int flightLineWidth: 2             // width of lines for flight graphic
    property int loiterAltitudeColumnWidth: 180 // width of loiter altitude column
    property int shadedMargin: 20               // margin inset for shaded areas
    property int controlVerticalSpacing: 10     // vertical spacing between controls
    property int homeWidth: 50                  // width of home graphic
    property int planeWidth: 40                 // width of plane graphic
    property int arrowToHomeSpacing: 20         // space between down arrow and home graphic
    property int arrowWidth: 18                 // width for arrow graphic
    property int firstColumnWidth: 220          // Width of first column in return home triggers area
Don Gagne's avatar
Don Gagne committed
50 51

    Column {
52
        anchors.fill: parent
Don Gagne's avatar
Don Gagne committed
53 54 55

        QGCLabel {
            text: "SAFETY CONFIG"
56
            font.pointSize: ScreenTools.fontPointFactor * (20);
Don Gagne's avatar
Don Gagne committed
57 58 59 60
        }

        Item { height: 20; width: 10 } // spacer

61 62
        //-----------------------------------------------------------------
        //-- Return Home Triggers
Don Gagne's avatar
Don Gagne committed
63

64
        QGCLabel { text: "Triggers For Return Home"; color: palette.text; font.pointSize: ScreenTools.fontPointFactor * (20); }
Don Gagne's avatar
Don Gagne committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87

        Item { height: 10; width: 10 } // spacer

        Rectangle {
            width: parent.width
            height: triggerColumn.height
            color: palette.windowShade

            Column {
                id: triggerColumn
                spacing: controlVerticalSpacing
                anchors.margins: shadedMargin
                anchors.left: parent.left

                // Top margin
                Item { height: 1; width: 10 }

                Row {
                    spacing: 10
                    QGCLabel { text: "RC Transmitter Signal Loss"; width: firstColumnWidth; anchors.baseline: rcLossField.baseline }
                    QGCLabel { text: "Return Home after"; anchors.baseline: rcLossField.baseline }
                    FactTextField {
                        id: rcLossField
88
                        fact: Fact { name: "COM_RC_LOSS_T" }
Don Gagne's avatar
Don Gagne committed
89 90
                        showUnits: true
                    }
91
                }
Don Gagne's avatar
Don Gagne committed
92 93 94 95

                Row {
                    spacing: 10
                    FactCheckBox {
96
                        id: telemetryTimeoutCheckbox
97
                        fact: Fact { name: "COM_DL_LOSS_EN" }
Don Gagne's avatar
Don Gagne committed
98 99 100 101 102 103 104 105 106
                        checkedValue: 1
                        uncheckedValue: 0
                        text: "Telemetry Signal Timeout"
                        anchors.baseline: telemetryLossField.baseline
                        width: firstColumnWidth
                    }
                    QGCLabel { text: "Return Home after"; anchors.baseline: telemetryLossField.baseline }
                    FactTextField {
                        id: telemetryLossField
107
                        fact: Fact { name: "COM_DL_LOSS_T" }
Don Gagne's avatar
Don Gagne committed
108
                        showUnits: true
109
                        enabled: telemetryTimeoutCheckbox.checked
Don Gagne's avatar
Don Gagne committed
110
                    }
111
                }
Don Gagne's avatar
Don Gagne committed
112 113 114

                // Bottom margin
                Item { height: 1; width: 10 }
115
            }
116
        }
Don Gagne's avatar
Don Gagne committed
117 118 119

        Item { height: 20; width: 10 }    // spacer

120
        //-----------------------------------------------------------------
Don Gagne's avatar
Don Gagne committed
121 122
        //-- Return Home Settings

123
        QGCLabel { text: "Return Home Settings"; font.pointSize: ScreenTools.fontPointFactor * (20); }
Don Gagne's avatar
Don Gagne committed
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151

        Item { height: 10; width: 10 } // spacer

        Rectangle {
            width: parent.width
            height: settingsColumn.height
            color: palette.windowShade

            Column {
                id: settingsColumn
                width: parent.width
                anchors.margins: shadedMargin
                anchors.left: parent.left

                Item { height: shadedMargin; width: 10 } // top margin

                // This item is the holder for the climb alt and loiter seconds fields
                Item {
                    width: parent.width
                    height: climbAltitudeColumn.height

                    Column {
                        id: climbAltitudeColumn
                        spacing: controlVerticalSpacing

                        QGCLabel { text: "Climb to altitude of" }
                        FactTextField {
                            id: climbField
152
                            fact: Fact { name: "RTL_RETURN_ALT" }
Don Gagne's avatar
Don Gagne committed
153 154
                            showUnits: true
                        }
155
                    }
Don Gagne's avatar
Don Gagne committed
156 157 158 159 160 161 162 163


                    Column {
                        x: flightGraphic.width - 200
                        spacing: controlVerticalSpacing

                        QGCCheckBox {
                            id: homeLoiterCheckbox
164 165
                            property Fact fact: Fact { name: "RTL_LAND_DELAY" }

Don Gagne's avatar
Don Gagne committed
166 167 168 169 170 171 172
                            checked: fact.value > 0
                            text: "Loiter at Home altitude for"
                            onClicked: {
                                fact.value = checked ? 60 : -1
                            }
                        }
                        FactTextField {
173
                            fact: Fact { name: "RTL_LAND_DELAY" }
Don Gagne's avatar
Don Gagne committed
174 175
                            showUnits: true
                            enabled: homeLoiterCheckbox.checked == true
176 177 178
                        }
                    }
                }
Don Gagne's avatar
Don Gagne committed
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227

                Item { height: 20; width: 10 }    // spacer

                // This row holds the flight graphic and the home loiter alt column
                Row {
                    width: parent.width
                    spacing: 20

                    // Flight graphic
                    Item {
                        id: flightGraphic
                        width: parent.width - loiterAltitudeColumnWidth
                        height: 200 // controls the height of the flight graphic

                        Rectangle {
                            x: planeWidth / 2
                            height: planeImage.y - 5
                            width: flightLineWidth
                            color: palette.button
                        }
                        Rectangle {
                            x: planeWidth / 2
                            height: flightLineWidth
                            width: parent.width - x
                            color: palette.button
                        }
                        Rectangle {
                            x: parent.width - flightLineWidth
                            height: parent.height - homeWidth - arrowToHomeSpacing
                            width: flightLineWidth
                            color: palette.button
                        }

                        QGCColoredImage {
                            id: planeImage
                            y: parent.height - planeWidth - 40
                            source: "/qml/SafetyComponentPlane.png"
                            fillMode: Image.PreserveAspectFit
                            width: planeWidth
                            height: planeWidth
                            smooth: true
                            color: palette.button
                        }

                        QGCColoredImage {
                            x: planeWidth + 70
                            y: parent.height - height - 20
                            width: 80
                            height: parent.height / 2
228
                            source: "/qml/SafetyComponentTree.svg"
Don Gagne's avatar
Don Gagne committed
229 230 231 232 233 234 235 236 237 238
                            fillMode: Image.Stretch
                            smooth: true
                            color: palette.windowShadeDark
                        }

                        QGCColoredImage {
                            x: planeWidth + 15
                            y: parent.height - height
                            width: 100
                            height: parent.height * .75
239 240
                            source: "/qml/SafetyComponentTree.svg"
                            fillMode: Image.PreserveAspectFit
Don Gagne's avatar
Don Gagne committed
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274
                            smooth: true
                            color: palette.button
                        }

                        QGCColoredImage {
                            x: parent.width - (arrowWidth/2) - 1
                            y: parent.height - homeWidth - arrowToHomeSpacing - 2
                            source: "/qml/SafetyComponentArrowDown.png"
                            fillMode: Image.PreserveAspectFit
                            width: arrowWidth
                            height: arrowWidth
                            smooth: true
                            color: palette.button
                        }

                        QGCColoredImage {
                            id: homeImage
                            x: parent.width - (homeWidth / 2)
                            y: parent.height - homeWidth
                            source: "/qml/SafetyComponentHome.png"
                            fillMode: Image.PreserveAspectFit
                            width: homeWidth
                            height: homeWidth
                            smooth: true
                            color: palette.button
                        }
                    }

                    Column {
                        spacing: controlVerticalSpacing

                        QGCLabel {
                            text: "Home loiter altitude";
                            color: palette.text;
275
                            enabled: homeLoiterCheckbox.checked === true
Don Gagne's avatar
Don Gagne committed
276 277 278
                        }
                        FactTextField {
                            id: descendField;
279
                            fact: Fact { name: "RTL_DESCEND_ALT" }
280
                            enabled: homeLoiterCheckbox.checked === true
Don Gagne's avatar
Don Gagne committed
281 282 283
                            showUnits: true
                        }
                    }
284
                }
Don Gagne's avatar
Don Gagne committed
285 286

                Item { height: shadedMargin; width: 10 } // bottom margin
287 288 289
            }
        }

Don Gagne's avatar
Don Gagne committed
290
        QGCLabel {
291
            property Fact fact: Fact { name: "NAV_RCL_OBC" }
292
            width: parent.width
293
            font.pointSize: ScreenTools.fontPointFactor * (14);
294
            text: "Warning: You have an advanced safety configuration set using the NAV_RCL_OBC parameter. The above settings may not apply.";
295
            visible: fact.value !== 0
296 297
            wrapMode: Text.Wrap
        }
Don Gagne's avatar
Don Gagne committed
298
        QGCLabel {
299
            property Fact fact: Fact { name: "NAV_DLL_OBC" }
300
            width: parent.width
301
            font.pointSize: ScreenTools.fontPointFactor * (14);
302
            text: "Warning: You have an advanced safety configuration set using the NAV_DLL_OBC parameter. The above settings may not apply.";
303
            visible: fact.value !== 0
304 305
            wrapMode: Text.Wrap
        }
Don Gagne's avatar
Don Gagne committed
306 307
    }
}