From c94199731de6ba8627b598333ae22ffcf0a3bcf1 Mon Sep 17 00:00:00 2001 From: Jacob Walser Date: Thu, 7 Sep 2017 09:58:53 -0400 Subject: [PATCH 1/2] Add FactTextFieldSlider control --- qgroundcontrol.qrc | 1 + .../FactControls/FactTextFieldSlider.qml | 157 +++++++++++++++++++++ src/FactSystem/FactControls/qmldir | 1 + 3 files changed, 159 insertions(+) create mode 100644 src/FactSystem/FactControls/FactTextFieldSlider.qml diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index b1c28a1..bdea8a6 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -146,6 +146,7 @@ src/FactSystem/FactControls/FactTextFieldGrid.qml src/FactSystem/FactControls/FactTextFieldRow.qml src/FactSystem/FactControls/FactValueSlider.qml + src/FactSystem/FactControls/FactTextFieldSlider.qml src/FactSystem/FactControls/qmldir src/FlightDisplay/FlightDisplayView.qml src/FlightDisplay/FlightDisplayViewMap.qml diff --git a/src/FactSystem/FactControls/FactTextFieldSlider.qml b/src/FactSystem/FactControls/FactTextFieldSlider.qml new file mode 100644 index 0000000..cf2a1e7 --- /dev/null +++ b/src/FactSystem/FactControls/FactTextFieldSlider.qml @@ -0,0 +1,157 @@ +import QtQuick 2.7 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.4 +import QtQuick.Layouts 1.2 + +import QGroundControl.FactSystem 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.ScreenTools 1.0 +import QGroundControl.FactControls 1.0 + + +Row { + id: sliderRoot + width: parent.width + + property Fact fact: null + property var _factValue: fact ? fact.value : null + property bool _loadComplete: false + + property real _range: Math.abs(fact.max - fact.min) + property real _minIncrement: _range/50 + property int precision: 2 + + on_FactValueChanged: { + slide.value = fact.value + } + + Component.onCompleted: { + slide.minimumValue = fact.min + slide.maximumValue = fact.max + slide.value = fact.value + _loadComplete = true + } + + // Used to find width of value string + QGCLabel { + id: textMeasure + visible: false + text: fact.value.toFixed(precision) + } + + // Param name, value, description and slider adjustment + Column { + id: sliderColumn + width: parent.width + spacing: _margins/2 + + // Param name and value + Row { + spacing: _margins + + QGCLabel { + text: fact.name + font.family: ScreenTools.demiboldFontFamily + font.pointSize: ScreenTools.defaultFontPointSize * 1.1 + anchors.verticalCenter: parent.verticalCenter + } + + // Row container for Value: xx.xx +/- (different spacing than parent) + Row { + spacing: ScreenTools.defaultFontPixelWidth + anchors.verticalCenter: parent.verticalCenter + + QGCLabel { + text: "Value: " + anchors.verticalCenter: parent.verticalCenter + } + + FactTextField { + anchors.verticalCenter: parent.verticalCenter + fact: sliderRoot.fact + showUnits: false + showHelp: false + text: fact.value.toFixed(precision) + width: textMeasure.width + ScreenTools.defaultFontPixelWidth*2 // Fudged, nothing else seems to work + } + + QGCLabel { + text: fact.units + anchors.verticalCenter: parent.verticalCenter + } + + QGCButton { + height: parent.height + width: height + text: "-" + anchors.verticalCenter: parent.verticalCenter + + onClicked: fact.value = Math.max(Math.min(fact.value - _minIncrement, fact.max), fact.min) + } + + QGCButton { + height: parent.height + width: height + text: "+" + anchors.verticalCenter: parent.verticalCenter + + onClicked: fact.value = Math.max(Math.min(fact.value + _minIncrement, fact.max), fact.min) + } + } // Row - container for Value: xx.xx +/- (different spacing than parent) + } // Row - Param name and value + + QGCLabel { + text: fact.shortDescription + } + + // Slider, with minimum and maximum values labeled + Row { + width: parent.width + spacing: _margins + + QGCLabel { + id: minLabel + width: ScreenTools.defaultFontPixelWidth * 10 + text: fact.min.toFixed(precision) + horizontalAlignment: Text.AlignRight + } + + QGCSlider { + id: slide + width: parent.width - minLabel.width - maxLabel.width - _margins * 2 + stepSize: fact.increment ? Math.max(fact.increment, _minIncrement) : _minIncrement + tickmarksEnabled: true + + onValueChanged: { + if (_loadComplete) { + if (Math.abs(fact.value - value) >= _minIncrement) { // prevent binding loop + fact.value = value + } + } + } + + MouseArea { + anchors.fill: parent + onWheel: { + // do nothing + wheel.accepted = true; + } + onPressed: { + // propogate/accept + mouse.accepted = false; + } + onReleased: { + // propogate/accept + mouse.accepted = false; + } + } + } // Slider + + QGCLabel { + id: maxLabel + width: ScreenTools.defaultFontPixelWidth * 10 + text: fact.max.toFixed(precision) + } + } // Row - Slider with minimum and maximum values labeled + } // Column - Param name, value, description and slider adjustment +} // Row diff --git a/src/FactSystem/FactControls/qmldir b/src/FactSystem/FactControls/qmldir index 02efebb..698cc92 100644 --- a/src/FactSystem/FactControls/qmldir +++ b/src/FactSystem/FactControls/qmldir @@ -9,3 +9,4 @@ FactTextField 1.0 FactTextField.qml FactTextFieldGrid 1.0 FactTextFieldGrid.qml FactTextFieldRow 1.0 FactTextFieldRow.qml FactValueSlider 1.0 FactValueSlider.qml +FactTextFieldSlider 1.0 FactTextFieldSlider.qml From df67dff5f5d96e748f7a67f2bd34a6d4b28b7d94 Mon Sep 17 00:00:00 2001 From: Jacob Walser Date: Thu, 7 Sep 2017 09:59:16 -0400 Subject: [PATCH 2/2] Add tuning component for Sub vehicles setup --- src/AutoPilotPlugins/APM/APMTuningComponent.cc | 3 + src/AutoPilotPlugins/APM/APMTuningComponentSub.qml | 162 +++++++++++++++++++++ src/FirmwarePlugin/APM/APMResources.qrc | 1 + 3 files changed, 166 insertions(+) create mode 100644 src/AutoPilotPlugins/APM/APMTuningComponentSub.qml diff --git a/src/AutoPilotPlugins/APM/APMTuningComponent.cc b/src/AutoPilotPlugins/APM/APMTuningComponent.cc index 231d2da..5406ef4 100644 --- a/src/AutoPilotPlugins/APM/APMTuningComponent.cc +++ b/src/AutoPilotPlugins/APM/APMTuningComponent.cc @@ -65,6 +65,9 @@ QUrl APMTuningComponent::setupSource(void) const qmlFile = QStringLiteral("qrc:/qml/APMTuningComponentCopter.qml"); } break; + case MAV_TYPE_SUBMARINE: + qmlFile = QStringLiteral("qrc:/qml/APMTuningComponentSub.qml"); + break; default: // No tuning panel break; diff --git a/src/AutoPilotPlugins/APM/APMTuningComponentSub.qml b/src/AutoPilotPlugins/APM/APMTuningComponentSub.qml new file mode 100644 index 0000000..ebda0c2 --- /dev/null +++ b/src/AutoPilotPlugins/APM/APMTuningComponentSub.qml @@ -0,0 +1,162 @@ +/**************************************************************************** + * + * (c) 2009-2018 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + + +import QtQuick 2.3 +import QtQuick.Controls 1.2 + +import QGroundControl.FactSystem 1.0 +import QGroundControl.FactControls 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.ScreenTools 1.0 + +SetupPage { + id: tuningPage + pageComponent: tuningPageComponent + + Component { + id: tuningPageComponent + + Column { + width: availableWidth + spacing: _margins + + FactPanelController { id: controller; factPanel: tuningPage.viewPanel } + + QGCPalette { id: palette; colorGroupEnabled: true } + + property real _margins: ScreenTools.defaultFontPixelHeight + + ExclusiveGroup { id: buttonGroup } + + Row { + spacing: _margins + QGCButton { + id: atcButton + text: qsTr("Attitude Controller Parameters") + exclusiveGroup: buttonGroup + checked: true + onClicked: checked = true + } + + QGCButton { + id: posButton + text: qsTr("Position Controller Parameters") + exclusiveGroup: buttonGroup + onClicked: checked = true + } + + QGCButton { + id: navButton + text: qsTr("Waypoint navigation parameters") + exclusiveGroup: buttonGroup + onClicked: checked = true + } + } + + Rectangle { + id: atcParams + visible: atcButton.checked + anchors.left: parent.left + anchors.right: parent.right + height: posColumn.height + _margins*2 + color: palette.windowShade + + Column { + id: posColumn + width: parent.width/2 + anchors.margins: _margins + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + spacing: _margins*1.5 + + FactTextFieldSlider { fact: controller.getParameterFact(-1, "ATC_ANG_PIT_P") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "ATC_ANG_RLL_P") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "ATC_ANG_YAW_P") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "ATC_RAT_PIT_P") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "ATC_RAT_PIT_I") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "ATC_RAT_PIT_IMAX") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "ATC_RAT_PIT_D") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "ATC_RAT_RLL_P") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "ATC_RAT_RLL_I") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "ATC_RAT_RLL_IMAX") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "ATC_RAT_RLL_D") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "ATC_RAT_YAW_P") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "ATC_RAT_YAW_I") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "ATC_RAT_YAW_IMAX") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "ATC_RAT_YAW_D") } + + } // Column - Position Controller Parameters + } // Rectangle - Position Controller Parameters + + Rectangle { + id: posParams + visible: posButton.checked + anchors.left: parent.left + anchors.right: parent.right + height: velColumn.height + _margins*2 + color: palette.windowShade + + Column { + id: velColumn + anchors.margins: _margins + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + spacing: _margins*1.5 + + FactTextFieldSlider { fact: controller.getParameterFact(-1, "POS_XY_P") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "POS_Z_P") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "VEL_XY_P") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "VEL_XY_I") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "VEL_XY_IMAX") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "VEL_Z_P") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "ACCEL_Z_D") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "ACCEL_Z_FILT") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "ACCEL_Z_I") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "ACCEL_Z_IMAX") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "ACCEL_Z_P") } + + } // Column - VEL parameters + } // Rectangle - VEL parameters + + Rectangle { + id: navParams + visible: navButton.checked + anchors.left: parent.left + anchors.right: parent.right + height: wpnavColumn.height + _margins*2 + color: palette.windowShade + + Column { + id: wpnavColumn + anchors.margins: _margins + anchors.left: parent.left + anchors.right: parent.right + anchors.top: parent.top + spacing: _margins*1.5 + + FactTextFieldSlider { fact: controller.getParameterFact(-1, "WPNAV_ACCEL") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "WPNAV_ACCEL_Z") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "WPNAV_LOIT_JERK") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "WPNAV_LOIT_MAXA") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "WPNAV_LOIT_MINA") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "WPNAV_LOIT_SPEED") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "WPNAV_RADIUS") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "WPNAV_SPEED") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "WPNAV_SPEED_DN") } + FactTextFieldSlider { fact: controller.getParameterFact(-1, "WPNAV_SPEED_UP") } + + } // Column - WPNAV parameters + } // Rectangle - WPNAV parameters + } // Column + } // Component +} // SetupView diff --git a/src/FirmwarePlugin/APM/APMResources.qrc b/src/FirmwarePlugin/APM/APMResources.qrc index b5e6a40..aa54a0b 100644 --- a/src/FirmwarePlugin/APM/APMResources.qrc +++ b/src/FirmwarePlugin/APM/APMResources.qrc @@ -25,6 +25,7 @@ ../../AutoPilotPlugins/APM/APMSensorsComponent.qml ../../AutoPilotPlugins/APM/APMSensorsComponentSummary.qml ../../AutoPilotPlugins/APM/APMTuningComponentCopter.qml + ../../AutoPilotPlugins/APM/APMTuningComponentSub.qml APMSensorParams.qml QGroundControl.ArduPilot.qmldir