VibrationWidget.qml 5.95 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.3
import QtQuick.Controls 1.2
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

import QGroundControl.Controls      1.0
import QGroundControl.ScreenTools   1.0
import QGroundControl.FactSystem    1.0
import QGroundControl.Controllers   1.0
import QGroundControl.Palette       1.0
import QGroundControl               1.0

QGCFlickable {
    id:                 _root
    height:             Math.min(maxHeight, innerItem.height)
    contentHeight:      innerItem.height
    flickableDirection: Flickable.VerticalFlick
    clip:               true

    property color  textColor
    property color  backgroundColor
    property var    maxHeight

32
    property var    _activeVehicle: QGroundControl.multiVehicleManager.activeVehicle ? QGroundControl.multiVehicleManager.activeVehicle : QGroundControl.multiVehicleManager.offlineEditingVehicle
33 34 35 36 37 38 39 40 41
    property real   _margins:       ScreenTools.defaultFontPixelWidth / 2
    property real   _barWidth:      Math.round(ScreenTools.defaultFontPixelWidth * 3)

    readonly property real _barMinimum:     0.0
    readonly property real _barMaximum:     90.0
    readonly property real _barBadValue:    60.0

    QGCPalette { id:qgcPal; colorGroupEnabled: true }

Don Gagne's avatar
Don Gagne committed
42 43 44 45 46
    MouseArea {
        anchors.fill:   parent
        onClicked:      showNextPage()
    }

47 48 49 50 51 52 53 54
    Item {
        id:     innerItem
        width:  parent.width
        height: barRow.y + barRow.height

        QGCLabel {
            id:     title
            color:  textColor
55
            text:   qsTr("Vibe")
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
            anchors.horizontalCenter: barRow.horizontalCenter
        }

        Row {
            id:                 barRow
            anchors.margins:    _margins
            anchors.top:        title.bottom
            anchors.left:       parent.left
            spacing:            _margins

            Column {
                ProgressBar {
                    id:             xBar
                    height:         50
                    orientation:    Qt.Vertical
                    minimumValue:   _barMinimum
                    maximumValue:   _barMaximum
                    value:          _activeVehicle ? _activeVehicle.vibration.xAxis.value : 0
                }

                QGCLabel {
                    id:     xBarLabel
                    color:  textColor
79
                    text:   "X"
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
                    anchors.horizontalCenter: xBar.horizontalCenter
                }
            }

            Column {
                ProgressBar {
                    id:             yBar
                    height:         50
                    orientation:    Qt.Vertical
                    minimumValue:   _barMinimum
                    maximumValue:   _barMaximum
                    value:          _activeVehicle ? _activeVehicle.vibration.yAxis.value : 0
                }

                QGCLabel {
                    anchors.horizontalCenter: yBar.horizontalCenter
                    color:  textColor
97
                    text:   "Y"
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113
                }
            }

            Column {
                ProgressBar {
                    id:             zBar
                    height:         50
                    orientation:    Qt.Vertical
                    minimumValue:   _barMinimum
                    maximumValue:   _barMaximum
                    value:          _activeVehicle ? _activeVehicle.vibration.zAxis.value : 0
                }

                QGCLabel {
                    anchors.horizontalCenter: zBar.horizontalCenter
                    color:  textColor
114
                    text:   "Z"
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
                }
            }
        } // Row

        // Max vibe indication line at 60
        Rectangle {
            anchors.topMargin:      xBar.height * (1.0 - ((_barBadValue - _barMinimum) / (_barMaximum - _barMinimum)))
            anchors.top:            barRow.top
            anchors.left:           barRow.left
            anchors.right:          barRow.right
            width:                  barRow.width
            height:                 1
            color:                  "red"
        }

        QGCLabel {
            id:                 clipLabel
            anchors.margins:    _margins
            anchors.left:       barRow.right
            anchors.right:      parent.right
            color:              textColor
136
            text:               qsTr("Clip count")
137 138 139 140 141 142 143 144 145
            horizontalAlignment: Text.AlignHCenter
        }

        Column {
            id:             clipColumn
            anchors.top:    barRow.top
            anchors.horizontalCenter: clipLabel.horizontalCenter

            QGCLabel {
146
                text: qsTr("Accel 1: ") + (_activeVehicle ? _activeVehicle.vibration.clipCount1.valueString : "")
147 148 149 150
                color: textColor
            }

            QGCLabel {
151
                text: qsTr("Accel 2: ") + (_activeVehicle ? _activeVehicle.vibration.clipCount2.valueString : "")
152 153 154 155
                color: textColor
            }

            QGCLabel {
156
                text: qsTr("Accel 2: ") + (_activeVehicle ? _activeVehicle.vibration.clipCount3.valueString : "")
157 158 159 160 161 162 163 164
                color: textColor
            }
        }

        // Not available overlay
        Rectangle {
            anchors.fill:   parent
            color:          backgroundColor
165
            opacity:        0.75
166 167 168 169
            visible:        _activeVehicle ? isNaN(_activeVehicle.vibration.xAxis.value) : false

            QGCLabel {
                anchors.fill:   parent
170
                text:           qsTr("Not Available")
171 172 173 174 175 176 177
                color:          textColor
                horizontalAlignment:    Text.AlignHCenter
                verticalAlignment:      Text.AlignVCenter
            }
        }
    } // Item
} // QGCFLickable