APMAirframeComponent.qml 8.79 KB
Newer Older
1 2 3 4 5 6 7 8
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/
9 10


11 12
import QtQuick          2.7
import QtQuick.Controls 2.1
Don Gagne's avatar
Don Gagne committed
13
import QtQuick.Dialogs  1.2
14
import QtQuick.Layouts  1.2
15

Don Gagne's avatar
Don Gagne committed
16
import QGroundControl.FactSystem    1.0
17
import QGroundControl.FactControls  1.0
Don Gagne's avatar
Don Gagne committed
18 19 20 21
import QGroundControl.Palette       1.0
import QGroundControl.Controls      1.0
import QGroundControl.Controllers   1.0
import QGroundControl.ScreenTools   1.0
22

23 24
SetupPage {
    id:             airframePage
25
    pageComponent:  _useOldFrameParam ?  oldFramePageComponent: newFramePageComponent
26

27 28 29 30 31
    property real _margins:             ScreenTools.defaultFontPixelWidth
    property bool _useOldFrameParam:    controller.parameterExists(-1, "FRAME")
    property Fact _oldFrameParam:       controller.getParameterFact(-1, "FRAME", false)
    property Fact _newFrameParam:       controller.getParameterFact(-1, "FRAME_CLASS", false)
    property Fact _frameTypeParam:      controller.getParameterFact(-1, "FRAME_TYPE", false)
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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
    property var  _flatParamList:       ListModel {
        ListElement {
            name: "3DR Aero M"
            file: "3DR_AERO_M.param"
        }
        ListElement {
            name: "3DR Aero RTF"
            file: "3DR_Aero_RTF.param"
        }
        ListElement {
            name: "3DR Rover"
            file: "3DR_Rover.param"
        }
        ListElement {
            name: "3DR Tarot"
            file: "3DR_Tarot.bgsc"
        }
        ListElement {
            name: "Parrot Bebop"
            file: "Parrot_Bebop.param"
        }
        ListElement {
            name: "Storm32"
            file: "SToRM32-MAVLink.param"
        }
        ListElement {
            name: "3DR X8-M RTF"
            file: "3DR_X8-M_RTF.param"
        }
        ListElement {
            name: "3DR Y6A"
            file: "3DR_Y6A_RTF.param"
        }
        ListElement {
            name: "3DR X8+ RTF"
            file: "3DR_X8+_RTF.param"
        }
        ListElement {
            name: "3DR QUAD X4 RTF"
            file: "3DR_QUAD_X4_RTF.param"
        }
        ListElement {
            name: "3DR X8"
            file: "3DR_X8_RTF.param"
        }
        ListElement {
            name: "Iris with GoPro"
            file: "Iris with Front Mount Go Pro.param"
        }
        ListElement {
            name: "Iris with Tarot"
            file: "Iris with Tarot Gimbal.param"
        }
        ListElement {
            name: "3DR Iris+"
            file: "3DR_Iris+.param"
        }
        ListElement {
            name: "Iris"
            file: "Iris.param"
        }
        ListElement {
            name: "3DR Y6B"
            file: "3DR_Y6B_RTF.param"
        }
    }

99 100 101

    APMAirframeComponentController {
        id:         controller
102
        factPanel:  airframePage.viewPanel
103 104
    }

Don Gagne's avatar
Don Gagne committed
105 106 107 108
    ExclusiveGroup {
        id: airframeTypeExclusive
    }

109 110 111 112 113 114 115 116 117 118 119 120 121 122
    Component {
        id: applyRestartDialogComponent

        QGCViewDialog {
            id: applyRestartDialog

            Connections {
                target: controller
                onCurrentAirframeTypeChanged: {
                    airframePicker.model = controller.currentAirframeType.airframes;
                }
            }

            QGCLabel {
Don Gagne's avatar
Don Gagne committed
123 124 125 126 127 128
                id:                 applyParamsText
                anchors.top:        parent.top
                anchors.left:       parent.left
                anchors.right:      parent.right
                anchors.margins:    _margins
                wrapMode:           Text.WordWrap
Don Gagne's avatar
Don Gagne committed
129
                text:               qsTr("Select your drone to load the default parameters for it. ")
130 131 132
            }

            Flow {
Don Gagne's avatar
Don Gagne committed
133 134 135 136 137 138 139 140
                anchors.margins:    _margins
                anchors.top:        applyParamsText.bottom
                anchors.left:       parent.left
                anchors.right:      parent.right
                anchors.bottom:     parent.bottom
                spacing :           _margins
                layoutDirection:    Qt.Vertical;

141
                Repeater {
Don Gagne's avatar
Don Gagne committed
142 143
                    id:     airframePicker
                    model:  controller.currentAirframeType.airframes;
144 145

                    delegate: QGCButton {
Don Gagne's avatar
Don Gagne committed
146
                        id:     btnParams
147 148
                        width:  parent.width / 2.1
                        height: (ScreenTools.defaultFontPixelHeight * 14) / 5
Don Gagne's avatar
Don Gagne committed
149
                        text:   controller.currentAirframeType.airframes[index].name;
150

Don Gagne's avatar
Don Gagne committed
151 152 153 154
                        onClicked : {
                            controller.loadParameters(controller.currentAirframeType.airframes[index].params)
                            hideDialog()
                        }
155 156 157 158 159 160
                    }
                }
            }
        }
    }

161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
    Component {
        id: selectParamFileDialogComponent

        QGCViewDialog {
            QGCLabel {
                id:                 applyParamsText
                anchors.top:        parent.top
                anchors.left:       parent.left
                anchors.right:      parent.right
                anchors.margins:    _margins
                wrapMode:           Text.WordWrap
                text:               qsTr("Select your drone to load the default parameters for it. ")
            }

            Flow {
                anchors.margins:    _margins
                anchors.top:        applyParamsText.bottom
                anchors.left:       parent.left
                anchors.right:      parent.right
                anchors.bottom:     parent.bottom
                spacing :           _margins
                layoutDirection:    Qt.Vertical;

                Repeater {
                    id:     airframePicker
                    model:  _flatParamList

                    delegate: QGCButton {
                        width:  parent.width / 2.1
                        height: (ScreenTools.defaultFontPixelHeight * 14) / 5
                        text:   name

                        onClicked : {
                            controller.loadParameters(file)
                            hideDialog()
                        }
                    }
                }
            }
        }
    }

203
    Component {
204
        id: oldFramePageComponent
205

206 207 208 209
        Column {
            width:      availableWidth
            height:     1000
            spacing:    _margins
210

211 212
            RowLayout {
                anchors.left:   parent.left
213
                anchors.right:  parent.right
214
                spacing:        _margins
215

216 217 218 219 220 221
                QGCLabel {
                    font.pointSize:     ScreenTools.mediumFontPointSize
                    wrapMode:           Text.WordWrap
                    text:               qsTr("Please select your airframe type")
                    Layout.fillWidth:   true
                }
Don Gagne's avatar
Don Gagne committed
222

223 224 225 226 227
                QGCButton {
                    text:       qsTr("Load common parameters")
                    onClicked:  showDialog(applyRestartDialogComponent, qsTr("Load common parameters"), qgcView.showDialogDefaultWidth, StandardButton.Close)
                }
            }
228

229 230
            Repeater {
                model: controller.airframeTypesModel
231

232 233 234 235
                QGCRadioButton {
                    text: object.name
                    checked: controller.currentAirframeType == object
                    exclusiveGroup: airframeTypeExclusive
236

237 238 239
                    onCheckedChanged: {
                        if (checked) {
                            controller.currentAirframeType = object
240 241 242 243
                        }
                    }
                }
            }
244
        } // Column
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
    } // Component - oldFramePageComponent

    Component {
        id: newFramePageComponent

        Grid {
            anchors.left:   parent.left
            anchors.right:  parent.right
            spacing:        _margins
            columns:        2

            QGCLabel {
                text:               qsTr("Frame Class:")
            }

            FactComboBox {
                fact:       _newFrameParam
                indexModel: false
                width:      ScreenTools.defaultFontPixelWidth * 15
            }

            QGCLabel {
                text:               qsTr("Frame Type:")
            }

            FactComboBox {
                fact:       _frameTypeParam
                indexModel: false
                width:      ScreenTools.defaultFontPixelWidth * 15
            }
275 276 277 278 279

            QGCButton {
                text:       qsTr("Load common parameters")
                onClicked:  showDialog(selectParamFileDialogComponent, qsTr("Load common parameters"), qgcView.showDialogDefaultWidth, StandardButton.Close)
            }
280 281
        }
    }
282
} // SetupPage