diff --git a/QGCApplication.pro b/QGCApplication.pro index 3e28b74f5090aef458f82e052ecc87603d17401c..469e2400026bc93730a4abcc7f6b4a2dce5fbce9 100644 --- a/QGCApplication.pro +++ b/QGCApplication.pro @@ -548,7 +548,8 @@ SOURCES += \ # INCLUDEPATH += \ - src/VehicleSetup + src/VehicleSetup \ + src/AutoPilotPlugins/PX4 \ FORMS += \ src/VehicleSetup/SetupView.ui \ diff --git a/src/AutoPilotPlugins/PX4/AirframeComponent.qml b/src/AutoPilotPlugins/PX4/AirframeComponent.qml index 0301cbbe89c8173eaac44aebc04084e425304343..cb4540f84b20fef331b41a1996557b332e760b28 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponent.qml +++ b/src/AutoPilotPlugins/PX4/AirframeComponent.qml @@ -39,12 +39,8 @@ QGCView { Component { id: view - FactPanel { + QGCViewPanel { id: panel - anchors.fill: parent - - signal showDialog(Component component, string title, int charWidth, int buttons) - signal hideDialog Connections { target: rootQGCView diff --git a/src/AutoPilotPlugins/PX4/AirframeComponentController.cc b/src/AutoPilotPlugins/PX4/AirframeComponentController.cc index 8f96cacfd4446119649abfb45dbcc5d7b3fb4c1e..ef516a8be5cac42326143dfda69eca16b7032a21 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponentController.cc +++ b/src/AutoPilotPlugins/PX4/AirframeComponentController.cc @@ -38,14 +38,10 @@ bool AirframeComponentController::_typesRegistered = false; AirframeComponentController::AirframeComponentController(void) : - _uas(NULL), _currentVehicleIndex(0), _autostartId(0), _showCustomConfigPanel(false) { - _uas = UASManager::instance()->getActiveUAS(); - Q_ASSERT(_uas); - if (!_typesRegistered) { _typesRegistered = true; qmlRegisterUncreatableType("QGroundControl.Controllers", 1, 0, "AiframeType", "Can only reference AirframeType"); diff --git a/src/AutoPilotPlugins/PX4/AirframeComponentController.h b/src/AutoPilotPlugins/PX4/AirframeComponentController.h index 79cfdcbf8105171b4ccf8983560c9edfcd68c1d8..8a3f1a50be086a14ccf4af94033b8dffceef0f8d 100644 --- a/src/AutoPilotPlugins/PX4/AirframeComponentController.h +++ b/src/AutoPilotPlugins/PX4/AirframeComponentController.h @@ -66,7 +66,6 @@ signals: private: static bool _typesRegistered; - UASInterface* _uas; QVariantList _airframeTypes; QString _currentAirframeType; QString _currentVehicleName; diff --git a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc index 41204218075490efc67c74d40934e51ce2479ce7..0cfaa0487f47058b4bfaf0f0eadff2095c1d4398 100644 --- a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc +++ b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc @@ -75,9 +75,6 @@ PX4AutoPilotPlugin::PX4AutoPilotPlugin(UASInterface* uas, QObject* parent) : { Q_ASSERT(uas); - qmlRegisterType("QGroundControl.Controllers", 1, 0, "FlightModesComponentController"); - qmlRegisterType("QGroundControl.Controllers", 1, 0, "AirframeComponentController"); - _parameterFacts = new PX4ParameterLoader(this, uas, this); Q_CHECK_PTR(_parameterFacts); diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.cc b/src/AutoPilotPlugins/PX4/SensorsComponent.cc index 1f1c30afa5cd98f31c5c2ce72f447eefb8514064..ef7bfd2c562f3d82de38f0cad4ecdb6fa0312d6a 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.cc +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.cc @@ -110,11 +110,7 @@ QWidget* SensorsComponent::setupWidget(void) const QGCQmlWidgetHolder* holder = new QGCQmlWidgetHolder(); Q_CHECK_PTR(holder); - holder->setAutoPilot(_autopilot); - - SensorsComponentController* controller = new SensorsComponentController(_autopilot, holder); - holder->setContextPropertyObject("controller", controller); - + holder->setAutoPilot(_autopilot); holder->setSource(QUrl::fromUserInput("qrc:/qml/SensorsComponent.qml")); return holder; diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.qml b/src/AutoPilotPlugins/PX4/SensorsComponent.qml index 619de30c583f5868d57a372e0df8f0f8dd403352..eb6abfdf0c379a41af4bc26086bb73063c0a8def 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.qml +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.qml @@ -31,9 +31,28 @@ import QGroundControl.FactControls 1.0 import QGroundControl.Palette 1.0 import QGroundControl.Controls 1.0 import QGroundControl.ScreenTools 1.0 +import QGroundControl.Controllers 1.0 -Rectangle { - property QGCPalette qgcPal: QGCPalette { colorGroupEnabled: true } +QGCView { + id: rootQGCView + viewComponent: view + + // Help text which is shown both in the status text area prior to pressing a cal button and in the + // pre-calibration dialog. + + readonly property string compassHelp: "For Compass calibration you will need to rotate your vehicle through a number of positions. For this calibration it is best " + + "to be connected to your vehicle via radio instead of USB, since the USB cable will likely get in the way." + readonly property string gyroHelp: "For Gyroscope calibration you will need to place your vehicle right side up on solid surface and leave it still." + readonly property string accelHelp: "For Accelerometer calibration you will need to place your vehicle on all six sides and hold it still in each orientation for a few seconds." + readonly property string airspeedHelp: "For Airspeed calibration you will need to keep your airspeed sensor out of any wind and then blow across the sensor." + + readonly property string statusTextAreaDefaultText: compassHelp + "\n\n" + gyroHelp + "\n\n" + accelHelp + "\n\n" + airspeedHelp + "\n\n" + + // Used to pass what type of calibration is being performed to the preCalibrationDialog + property string preCalibrationDialogType + + // Used to pass help text to the preCalibrationDialog dialog + property string preCalibrationDialogHelp readonly property int rotationColumnWidth: 200 readonly property var rotations: [ @@ -66,179 +85,92 @@ Rectangle { "ROTATION_ROLL_270_YAW_270" ] - readonly property string statusTextAreaDefaultText: "Sensor config is a work in progress. Not all visuals for all calibration types fully implemented.\n\n" + - "For Compass calibration you will need to rotate your vehicle through a number of positions. For this calibration is is best " + - "to be connected to you vehicle via radio instead of USB since the USB cable will likely get in the way.\n\n" + - "For Gyroscope calibration you will need to place your vehicle right side up on solid surface and leave it still.\n\n" + - "For Accelerometer calibration you will need to place your vehicle on all six sides and hold it there for a few seconds.\n\n" + - "For Airspeed calibration you will need to keep your airspeed sensor out of any wind.\n\n" - - Fact { id: cal_mag0_id; name: "CAL_MAG0_ID" } - Fact { id: cal_mag1_id; name: "CAL_MAG1_ID" } - Fact { id: cal_mag2_id; name: "CAL_MAG2_ID" } - Fact { id: cal_mag0_rot; name: "CAL_MAG0_ROT" } - Fact { id: cal_mag1_rot; name: "CAL_MAG1_ROT" } - Fact { id: cal_mag2_rot; name: "CAL_MAG2_ROT" } + Fact { id: cal_mag0_id; name: "CAL_MAG0_ID"; onFactMissing: showMissingFactOverlay(name) } + Fact { id: cal_mag1_id; name: "CAL_MAG1_ID"; onFactMissing: showMissingFactOverlay(name) } + Fact { id: cal_mag2_id; name: "CAL_MAG2_ID"; onFactMissing: showMissingFactOverlay(name) } + Fact { id: cal_mag0_rot; name: "CAL_MAG0_ROT"; onFactMissing: showMissingFactOverlay(name) } + Fact { id: cal_mag1_rot; name: "CAL_MAG1_ROT"; onFactMissing: showMissingFactOverlay(name) } + Fact { id: cal_mag2_rot; name: "CAL_MAG2_ROT"; onFactMissing: showMissingFactOverlay(name) } // Id > = signals compass available, rot < 0 signals internal compass property bool showCompass0Rot: cal_mag0_id.value > 0 && cal_mag0_rot.value >= 0 property bool showCompass1Rot: cal_mag1_id.value > 0 && cal_mag1_rot.value >= 0 property bool showCompass2Rot: cal_mag2_id.value > 0 && cal_mag2_rot.value >= 0 - color: qgcPal.window - - // We use this bogus loader just so we can get an onLoaded signal to hook to in order to - // finish controller initialization. - Component { - id: loadSignal; - Item { } - } - Loader { - sourceComponent: loadSignal - onLoaded: { - controller.statusLog = statusTextArea - controller.progressBar = progressBar - controller.compassButton = compassButton - controller.gyroButton = gyroButton - controller.accelButton = accelButton - controller.airspeedButton = airspeedButton - controller.cancelButton = cancelButton - controller.orientationCalAreaHelpText = orientationCalAreaHelpText - } - } + SensorsComponentController { + id: controller - Connections { - target: controller + onResetStatusTextArea: statusLog.text = statusTextAreaDefaultText - onResetStatusTextArea: statusTextArea.text = statusTextAreaDefaultText - onSetCompassRotations: showCompassRotationOverlay() - } - - Rectangle { - id: overlay - anchors.fill: parent - color: qgcPal.window - opacity: 0.75 - z: 100 - visible: false - } - - Rectangle { - width: 300 - height: 100 - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - color: qgcPal.window - border.width: 1 - border.color: qgcPal.text - visible: controller.waitingForCancel - z: overlay.z + 1 - - onVisibleChanged: { - overlay.visible = visible + onSetCompassRotations: { + if (showCompass0Rot || showCompass1Rot || showCompass2Rot) { + showDialog(compassRotationDialogComponent, "Set Compass Rotation(s)", 50, StandardButton.Ok) + } } - QGCLabel { - anchors.fill: parent - verticalAlignment: Text.AlignVCenter - horizontalAlignment: Text.AlignHCenter - text: "Waiting for Cancel (may take a few seconds)" + onWaitingForCancelChanged: { + if (controller.waitingForCancel) { + showMessage("Calibration Cancel", "Waiting for Vehicle to response to Cancel. This may take a few seconds.", 0) + } else { + hideDialog() + } } } - Rectangle { - property string calibrationType - - id: boardRotationOverlay - width: 300 - height: boardRotationOverlayColumn.height + 11 - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - color: qgcPal.window - border.width: 1 - border.color: qgcPal.text - visible: false - z: overlay.z + 1 - - Column { - id: boardRotationOverlayColumn - anchors.topMargin: 10 - anchors.top: parent.top - width: parent.width - spacing: 10 + Component { + id: preCalibrationDialogComponent + + QGCViewDialog { + id: preCalibrationDialog + + function accept() { + if (preCalibrationDialogType == "gyro") { + controller.calibrateGyro() + } else if (preCalibrationDialogType == "accel") { + controller.calibrateAccel() + } else if (preCalibrationDialogType == "compass") { + controller.calibrateCompass() + } else if (preCalibrationDialogType == "airspeed") { + controller.calibrateAirspeed() + } + preCalibrationDialog.hideDialog() + } Column { - anchors.leftMargin: 10 - anchors.rightMargin: 10 - anchors.left: parent.left - anchors.right: parent.right + anchors.fill: parent spacing: 10 QGCLabel { width: parent.width wrapMode: Text.WordWrap - text: "Please check and/or update board rotation before calibrating" + text: preCalibrationDialogHelp } - FactComboBox { - width: rotationColumnWidth - model: rotations - fact: Fact { name: "SENS_BOARD_ROT" } + QGCLabel { + width: parent.width + wrapMode: Text.WordWrap + visible: preCalibrationDialogType != "airspeed" + text: "Please check and/or update board rotation before calibrating." } - } - QGCButton { - x: 1 - width: parent.width - 2 - primary: true - text: "OK" - - onClicked: { - boardRotationOverlay.visible = false - overlay.visible = false - - if (boardRotationOverlay.calibrationType == "gyro") { - controller.calibrateGyro() - } else if (boardRotationOverlay.calibrationType == "accel") { - controller.calibrateAccel() - } else if (boardRotationOverlay.calibrationType == "compass") { - controller.calibrateCompass() - } + FactComboBox { + width: rotationColumnWidth + model: rotations + visible: preCalibrationDialogType != "airspeed" + fact: Fact { name: "SENS_BOARD_ROT"; onFactMissing: showMissingFactOverlay(name) } } } } } - function showBoardRotationOverlay(calibrationType) { - boardRotationOverlay.calibrationType = calibrationType - boardRotationOverlay.visible = true - overlay.visible = true - } + Component { + id: compassRotationDialogComponent - Rectangle { - id: compassRotationOverlay - width: 300 - height: compassRotationOverlayColumn.height + 11 - anchors.verticalCenter: parent.verticalCenter - anchors.horizontalCenter: parent.horizontalCenter - color: qgcPal.window - border.width: 1 - border.color: qgcPal.text - visible: false - z: overlay.z + 1 - - Column { - id: compassRotationOverlayColumn - anchors.topMargin: 10 - anchors.top: parent.top - width: parent.width - spacing: 10 + QGCViewDialog { + id: compassRotationDialog Column { - anchors.leftMargin: 10 - anchors.rightMargin: 10 - anchors.left: parent.left - anchors.right: parent.right + anchors.fill: parent spacing: 10 QGCLabel { @@ -260,7 +192,7 @@ Rectangle { id: compass0RotationCombo width: rotationColumnWidth model: rotations - fact: Fact { name: "CAL_MAG0_ROT" } + fact: Fact { name: "CAL_MAG0_ROT"; onFactMissing: showMissingFactOverlay(name) } } } Loader { sourceComponent: showCompass0Rot ? compass0ComponentLabel : null } @@ -279,7 +211,7 @@ Rectangle { id: compass1RotationCombo width: rotationColumnWidth model: rotations - fact: Fact { name: "CAL_MAG1_ROT" } + fact: Fact { name: "CAL_MAG1_ROT"; onFactMissing: showMissingFactOverlay(name) } } } Loader { sourceComponent: showCompass1Rot ? compass1ComponentLabel : null } @@ -298,268 +230,296 @@ Rectangle { id: compass1RotationCombo width: rotationColumnWidth model: rotations - fact: Fact { name: "CAL_MAG2_ROT" } + fact: Fact { name: "CAL_MAG2_ROT"; onFactMissing: showMissingFactOverlay(name) } } } Loader { sourceComponent: showCompass2Rot ? compass2ComponentLabel : null } Loader { sourceComponent: showCompass2Rot ? compass2ComponentCombo : null } - } - - QGCButton { - x: 1 - width: parent.width - 2 - primary: true - text: "OK" + } // Column + } // QGCViewDialog + } // Component - compassRotationDialogComponent - onClicked: { - compassRotationOverlay.visible = false - overlay.visible = false - } + Component { + id: view + + QGCViewPanel { + id: viewPanel + + Connections { + target: rootQGCView + + onCompleted: { + controller.factPanel = viewPanel + controller.statusLog = statusTextArea + controller.progressBar = progressBar + controller.compassButton = compassButton + controller.gyroButton = gyroButton + controller.accelButton = accelButton + controller.airspeedButton = airspeedButton + controller.cancelButton = cancelButton + controller.orientationCalAreaHelpText = orientationCalAreaHelpText + } } - } - } - - function showCompassRotationOverlay() { - if (showCompass0Rot || showCompass1Rot || showCompass2Rot) { - compassRotationOverlay.visible = true - overlay.visible = true - } - } - - Column { - anchors.fill: parent - - QGCLabel { - text: "SENSORS CONFIG" - font.pointSize: ScreenTools.fontPointFactor * (20); - } - Item { height: 20; width: 10 } // spacer + QGCPalette { id: qgcPal; colorGroupEnabled: enabled } - Row { - readonly property int buttonWidth: 120 - spacing: 20 - QGCLabel { text: "Calibrate:"; anchors.baseline: compassButton.baseline } + color: qgcPal.window - IndicatorButton { - property Fact fact: Fact { name: "CAL_MAG0_ID" } - id: compassButton - width: parent.buttonWidth - text: "Compass" - indicatorGreen: fact.value != 0 - - onClicked: showBoardRotationOverlay("compass") - } + Column { + anchors.fill: parent - IndicatorButton { - property Fact fact: Fact { name: "CAL_GYRO0_ID" } + QGCLabel { + text: "SENSORS CONFIG" + font.pointSize: ScreenTools.fontPointFactor * (20); + } - id: gyroButton - width: parent.buttonWidth - text: "Gyroscope" - indicatorGreen: fact.value != 0 + Item { height: 20; width: 10 } // spacer - onClicked: showBoardRotationOverlay("gyro") - } + Row { + readonly property int buttonWidth: 120 - IndicatorButton { - property Fact fact: Fact { name: "CAL_ACC0_ID" } + spacing: 20 - id: accelButton - width: parent.buttonWidth - text: "Accelerometer" - indicatorGreen: fact.value != 0 + QGCLabel { text: "Calibrate:"; anchors.baseline: compassButton.baseline } - onClicked: showBoardRotationOverlay("accel") - } + IndicatorButton { + property Fact fact: Fact { name: "CAL_MAG0_ID" } - IndicatorButton { - property Fact fact: Fact { name: "SENS_DPRES_OFF" } + id: compassButton + width: parent.buttonWidth + text: "Compass" + indicatorGreen: fact.value != 0 - id: airspeedButton - width: parent.buttonWidth - text: "Airspeed" - visible: controller.fixedWing - indicatorGreen: fact.value != 0 - onClicked: controller.calibrateAirspeed() - } - - QGCButton { - id: cancelButton - text: "Cancel" - enabled: false - onClicked: controller.cancelCalibration() - } - } + onClicked: { + preCalibrationDialogType = "compass" + preCalibrationDialogHelp = compassHelp + showDialog(preCalibrationDialogComponent, "Calibrate Compass", 50, StandardButton.Cancel | StandardButton.Ok) + } + } - Item { height: 20; width: 10 } // spacer + IndicatorButton { + property Fact fact: Fact { name: "CAL_GYRO0_ID" } - ProgressBar { - id: progressBar - width: parent.width - rotationColumnWidth - } + id: gyroButton + width: parent.buttonWidth + text: "Gyroscope" + indicatorGreen: fact.value != 0 - Item { height: 10; width: 10 } // spacer - - Item { - readonly property int calibrationAreaHeight: 300 - property int calDisplayAreaWidth: parent.width - rotationColumnWidth + onClicked: { + preCalibrationDialogType = "gyro" + preCalibrationDialogHelp = gyroHelp + showDialog(preCalibrationDialogComponent, "Calibrate Gyro", 50, StandardButton.Cancel | StandardButton.Ok) + } + } - width: parent.width - height: parent.height - y + IndicatorButton { + property Fact fact: Fact { name: "CAL_ACC0_ID" } - TextArea { - id: statusTextArea - width: parent.calDisplayAreaWidth - height: parent.height - readOnly: true - frameVisible: false - text: statusTextAreaDefaultText + id: accelButton + width: parent.buttonWidth + text: "Accelerometer" + indicatorGreen: fact.value != 0 - style: TextAreaStyle { - textColor: qgcPal.text - backgroundColor: qgcPal.windowShade - } - } + onClicked: { + preCalibrationDialogType = "accel" + preCalibrationDialogHelp = accelHelp + showDialog(preCalibrationDialogComponent, "Calibrate Accelerometer", 50, StandardButton.Cancel | StandardButton.Ok) + } + } - Rectangle { - id: orientationCalArea - width: parent.calDisplayAreaWidth - height: parent.height - visible: controller.showOrientationCalArea - color: qgcPal.windowShade + IndicatorButton { + property Fact fact: Fact { name: "SENS_DPRES_OFF" } - QGCLabel { - id: orientationCalAreaHelpText - width: parent.width - wrapMode: Text.WordWrap - font.pointSize: ScreenTools.fontPointFactor * (17); - } + id: airspeedButton + width: parent.buttonWidth + text: "Airspeed" + visible: controller.fixedWing + indicatorGreen: fact.value != 0 - Flow { - y: orientationCalAreaHelpText.height - width: parent.width - height: parent.height - orientationCalAreaHelpText.implicitHeight - spacing: 5 - - VehicleRotationCal { - visible: controller.orientationCalDownSideVisible - calValid: controller.orientationCalDownSideDone - calInProgress: controller.orientationCalDownSideInProgress - calInProgressText: controller.orientationCalDownSideRotate ? "Rotate" : "Hold Still" - imageSource: controller.orientationCalDownSideRotate ? "qrc:///qml/VehicleDownRotate.png" : "qrc:///qml/VehicleDown.png" - } - VehicleRotationCal { - visible: controller.orientationCalUpsideDownSideVisible - calValid: controller.orientationCalUpsideDownSideDone - calInProgress: controller.orientationCalUpsideDownSideInProgress - calInProgressText: "Hold Still" - imageSource: "qrc:///qml/VehicleUpsideDown.png" - } - VehicleRotationCal { - visible: controller.orientationCalNoseDownSideVisible - calValid: controller.orientationCalNoseDownSideDone - calInProgress: controller.orientationCalNoseDownSideInProgress - calInProgressText: controller.orientationCalNoseDownSideRotate ? "Rotate" : "Hold Still" - imageSource: controller.orientationCalNoseDownSideRotate ? "qrc:///qml/VehicleNoseDownRotate.png" : "qrc:///qml/VehicleNoseDown.png" - } - VehicleRotationCal { - visible: controller.orientationCalTailDownSideVisible - calValid: controller.orientationCalTailDownSideDone - calInProgress: controller.orientationCalTailDownSideInProgress - calInProgressText: "Hold Still" - imageSource: "qrc:///qml/VehicleTailDown.png" + onClicked: { + preCalibrationDialogType = "airspeed" + preCalibrationDialogHelp = airspeedHelp + showDialog(preCalibrationDialogComponent, "Calibrate Airspeed", 50, StandardButton.Cancel | StandardButton.Ok) + } } - VehicleRotationCal { - visible: controller.orientationCalLeftSideVisible - calValid: controller.orientationCalLeftSideDone - calInProgress: controller.orientationCalLeftSideInProgress - calInProgressText: controller.orientationCalLeftSideRotate ? "Rotate" : "Hold Still" - imageSource: controller.orientationCalLeftSideRotate ? "qrc:///qml/VehicleLeftRotate.png" : "qrc:///qml/VehicleLeft.png" - } - VehicleRotationCal { - visible: controller.orientationCalRightSideVisible - calValid: controller.orientationCalRightSideDone - calInProgress: controller.orientationCalRightSideInProgress - calInProgressText: "Hold Still" - imageSource: "qrc:///qml/VehicleRight.png" + + QGCButton { + id: cancelButton + text: "Cancel" + enabled: false + onClicked: controller.cancelCalibration() } } - } - Column { - x: parent.width - rotationColumnWidth - - QGCLabel { text: "Autpilot Orientation" } + Item { height: 20; width: 10 } // spacer - FactComboBox { - id: boardRotationCombo - width: rotationColumnWidth; - model: rotations - fact: Fact { name: "SENS_BOARD_ROT" } + ProgressBar { + id: progressBar + width: parent.width - rotationColumnWidth } - // Compass 0 rotation - Component { - id: compass0ComponentLabel2 + Item { height: 10; width: 10 } // spacer - QGCLabel { text: "Compass Orientation" } - } - Component { - id: compass0ComponentCombo2 + Item { + readonly property int calibrationAreaHeight: 300 + property int calDisplayAreaWidth: parent.width - rotationColumnWidth - FactComboBox { - id: compass0RotationCombo - width: rotationColumnWidth - model: rotations - fact: Fact { name: "CAL_MAG0_ROT" } - } - } - Loader { sourceComponent: showCompass0Rot ? compass0ComponentLabel2 : null } - Loader { sourceComponent: showCompass0Rot ? compass0ComponentCombo2 : null } - - // Compass 1 rotation - Component { - id: compass1ComponentLabel2 + width: parent.width + height: parent.height - y - QGCLabel { text: "Compass 1 Orientation" } - } - Component { - id: compass1ComponentCombo2 + TextArea { + id: statusTextArea + width: parent.calDisplayAreaWidth + height: parent.height + readOnly: true + frameVisible: false + text: statusTextAreaDefaultText - FactComboBox { - id: compass1RotationCombo - width: rotationColumnWidth - model: rotations - fact: Fact { name: "CAL_MAG1_ROT" } + style: TextAreaStyle { + textColor: qgcPal.text + backgroundColor: qgcPal.windowShade + } } - } - Loader { sourceComponent: showCompass1Rot ? compass1ComponentLabel2 : null } - Loader { sourceComponent: showCompass1Rot ? compass1ComponentCombo2 : null } - - // Compass 2 rotation - Component { - id: compass2ComponentLabel2 - QGCLabel { text: "Compass 2 Orientation" } - } - Component { - id: compass2ComponentCombo2 + Rectangle { + id: orientationCalArea + width: parent.calDisplayAreaWidth + height: parent.height + visible: controller.showOrientationCalArea + color: qgcPal.windowShade + + QGCLabel { + id: orientationCalAreaHelpText + width: parent.width + wrapMode: Text.WordWrap + font.pointSize: ScreenTools.fontPointFactor * (17); + } + + Flow { + y: orientationCalAreaHelpText.height + width: parent.width + height: parent.height - orientationCalAreaHelpText.implicitHeight + spacing: 5 + + VehicleRotationCal { + visible: controller.orientationCalDownSideVisible + calValid: controller.orientationCalDownSideDone + calInProgress: controller.orientationCalDownSideInProgress + calInProgressText: controller.orientationCalDownSideRotate ? "Rotate" : "Hold Still" + imageSource: controller.orientationCalDownSideRotate ? "qrc:///qml/VehicleDownRotate.png" : "qrc:///qml/VehicleDown.png" + } + VehicleRotationCal { + visible: controller.orientationCalUpsideDownSideVisible + calValid: controller.orientationCalUpsideDownSideDone + calInProgress: controller.orientationCalUpsideDownSideInProgress + calInProgressText: "Hold Still" + imageSource: "qrc:///qml/VehicleUpsideDown.png" + } + VehicleRotationCal { + visible: controller.orientationCalNoseDownSideVisible + calValid: controller.orientationCalNoseDownSideDone + calInProgress: controller.orientationCalNoseDownSideInProgress + calInProgressText: controller.orientationCalNoseDownSideRotate ? "Rotate" : "Hold Still" + imageSource: controller.orientationCalNoseDownSideRotate ? "qrc:///qml/VehicleNoseDownRotate.png" : "qrc:///qml/VehicleNoseDown.png" + } + VehicleRotationCal { + visible: controller.orientationCalTailDownSideVisible + calValid: controller.orientationCalTailDownSideDone + calInProgress: controller.orientationCalTailDownSideInProgress + calInProgressText: "Hold Still" + imageSource: "qrc:///qml/VehicleTailDown.png" + } + VehicleRotationCal { + visible: controller.orientationCalLeftSideVisible + calValid: controller.orientationCalLeftSideDone + calInProgress: controller.orientationCalLeftSideInProgress + calInProgressText: controller.orientationCalLeftSideRotate ? "Rotate" : "Hold Still" + imageSource: controller.orientationCalLeftSideRotate ? "qrc:///qml/VehicleLeftRotate.png" : "qrc:///qml/VehicleLeft.png" + } + VehicleRotationCal { + visible: controller.orientationCalRightSideVisible + calValid: controller.orientationCalRightSideDone + calInProgress: controller.orientationCalRightSideInProgress + calInProgressText: "Hold Still" + imageSource: "qrc:///qml/VehicleRight.png" + } + } + } - FactComboBox { - id: compass1RotationCombo - width: rotationColumnWidth - model: rotations - fact: Fact { name: "CAL_MAG2_ROT" } + Column { + x: parent.width - rotationColumnWidth + + QGCLabel { text: "Autpilot Orientation" } + + FactComboBox { + id: boardRotationCombo + width: rotationColumnWidth; + model: rotations + fact: Fact { name: "SENS_BOARD_ROT" } + } + + // Compass 0 rotation + Component { + id: compass0ComponentLabel2 + + QGCLabel { text: "Compass Orientation" } + } + Component { + id: compass0ComponentCombo2 + + FactComboBox { + id: compass0RotationCombo + width: rotationColumnWidth + model: rotations + fact: Fact { name: "CAL_MAG0_ROT" } + } + } + Loader { sourceComponent: showCompass0Rot ? compass0ComponentLabel2 : null } + Loader { sourceComponent: showCompass0Rot ? compass0ComponentCombo2 : null } + + // Compass 1 rotation + Component { + id: compass1ComponentLabel2 + + QGCLabel { text: "Compass 1 Orientation" } + } + Component { + id: compass1ComponentCombo2 + + FactComboBox { + id: compass1RotationCombo + width: rotationColumnWidth + model: rotations + fact: Fact { name: "CAL_MAG1_ROT" } + } + } + Loader { sourceComponent: showCompass1Rot ? compass1ComponentLabel2 : null } + Loader { sourceComponent: showCompass1Rot ? compass1ComponentCombo2 : null } + + // Compass 2 rotation + Component { + id: compass2ComponentLabel2 + + QGCLabel { text: "Compass 2 Orientation" } + } + Component { + id: compass2ComponentCombo2 + + FactComboBox { + id: compass1RotationCombo + width: rotationColumnWidth + model: rotations + fact: Fact { name: "CAL_MAG2_ROT" } + } + } + Loader { sourceComponent: showCompass2Rot ? compass2ComponentLabel2 : null } + Loader { sourceComponent: showCompass2Rot ? compass2ComponentCombo2 : null } } } - Loader { sourceComponent: showCompass2Rot ? compass2ComponentLabel2 : null } - Loader { sourceComponent: showCompass2Rot ? compass2ComponentCombo2 : null } } - } - } + } // Rectangle + } // Component - view } - diff --git a/src/AutoPilotPlugins/PX4/SensorsComponentController.cc b/src/AutoPilotPlugins/PX4/SensorsComponentController.cc index c8e258f5920d919151f5aca0646e1706eb0cbaaf..c22b2f57007916f6cfa8676f0a82331cf94e9a41 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponentController.cc +++ b/src/AutoPilotPlugins/PX4/SensorsComponentController.cc @@ -32,8 +32,7 @@ #include #include -SensorsComponentController::SensorsComponentController(AutoPilotPlugin* autopilot, QObject* parent) : - QObject(parent), +SensorsComponentController::SensorsComponentController(void) : _statusLog(NULL), _progressBar(NULL), _compassButton(NULL), @@ -67,15 +66,8 @@ SensorsComponentController::SensorsComponentController(AutoPilotPlugin* autopilo _orientationCalLeftSideRotate(false), _orientationCalNoseDownSideRotate(false), _unknownFirmwareVersion(false), - _waitingForCancel(false), - _autopilot(autopilot) + _waitingForCancel(false) { - Q_ASSERT(_autopilot); - Q_ASSERT(_autopilot->pluginReady()); - - _uas = _autopilot->uas(); - Q_ASSERT(_uas); - // Mag rotation parameters are optional _showCompass0 = _autopilot->parameterExists("CAL_MAG0_ROT") && _autopilot->getParameterFact("CAL_MAG0_ROT")->value().toInt() >= 0; @@ -400,6 +392,15 @@ void SensorsComponentController::_handleUASTextMessage(int uasId, int compId, in void SensorsComponentController::_refreshParams(void) { + QStringList fastRefreshList; + + // We ask for a refresh on these first so that the rotation combo show up as fast as possible + fastRefreshList << "CAL_MAG0_ID" << "CAL_MAG1_ID" << "CAL_MAG2_ID" << "CAL_MAG0_ROT" << "CAL_MAG1_ROT" << "CAL_MAG2_ROT"; + foreach (QString paramName, fastRefreshList) { + _autopilot->refreshParameter(FactSystem::defaultComponentId, paramName); + } + + // Now ask for all to refresh _autopilot->refreshParametersPrefix(FactSystem::defaultComponentId, "CAL_"); _autopilot->refreshParametersPrefix(FactSystem::defaultComponentId, "SENS_"); } diff --git a/src/AutoPilotPlugins/PX4/SensorsComponentController.h b/src/AutoPilotPlugins/PX4/SensorsComponentController.h index dd5c62c7875bf6b322724d87380e70d329e3425c..fac472619f81ca8efaca1c4f217230ef78abc2b1 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponentController.h +++ b/src/AutoPilotPlugins/PX4/SensorsComponentController.h @@ -31,15 +31,15 @@ #include #include "UASInterface.h" -#include "AutoPilotPlugin.h" +#include "FactPanelController.h" /// Sensors Component MVC Controller for SensorsComponent.qml. -class SensorsComponentController : public QObject +class SensorsComponentController : public FactPanelController { Q_OBJECT public: - SensorsComponentController(AutoPilotPlugin* autopilot, QObject* parent = NULL); + SensorsComponentController(void); Q_PROPERTY(bool fixedWing READ fixedWing CONSTANT) @@ -167,9 +167,6 @@ private: bool _unknownFirmwareVersion; bool _waitingForCancel; - - AutoPilotPlugin* _autopilot; - UASInterface* _uas; }; #endif diff --git a/src/FactSystem/FactControls/FactPanel.qml b/src/FactSystem/FactControls/FactPanel.qml index dde0acf93689f3ca8602df554375f7468de2c49f..f941f82bbbfdfa64d17bb894f52db56a7949eca0 100644 --- a/src/FactSystem/FactControls/FactPanel.qml +++ b/src/FactSystem/FactControls/FactPanel.qml @@ -31,7 +31,11 @@ import QGroundControl.FactSystem 1.0 import QGroundControl.Controls 1.0 import QGroundControl.Palette 1.0 -Item { +Rectangle { + color: __qgcPal.window + + QGCPalette { id: __qgcPal; colorGroupEnabled: true } + property string __missingFacts: "" function showMissingFactOverlay(missingFactName) { @@ -43,8 +47,6 @@ Item { } Rectangle { - QGCPalette { id: __qgcPal; colorGroupEnabled: true } - id: __missingFactOverlay anchors.fill: parent z: 9999 diff --git a/src/FactSystem/FactControls/FactPanelController.cc b/src/FactSystem/FactControls/FactPanelController.cc index ddebadd4a75125195e7f140c745d1461e557c8a9..25df92b12fcc2807a7d5da8f47cda2e84808b3be 100644 --- a/src/FactSystem/FactControls/FactPanelController.cc +++ b/src/FactSystem/FactControls/FactPanelController.cc @@ -33,10 +33,10 @@ FactPanelController::FactPanelController(void) : _autopilot(NULL), _factPanel(NULL) { - UASInterface* uas = UASManager::instance()->getActiveUAS(); - Q_ASSERT(uas); + _uas = UASManager::instance()->getActiveUAS(); + Q_ASSERT(_uas); - _autopilot = AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(uas); + _autopilot = AutoPilotPluginManager::instance()->getInstanceForAutoPilotPlugin(_uas); Q_ASSERT(_autopilot); Q_ASSERT(_autopilot->pluginReady()); diff --git a/src/FactSystem/FactControls/FactPanelController.h b/src/FactSystem/FactControls/FactPanelController.h index 09411432037d815bd87b470fb5febf9816d7a89e..9d21b712b164f37aeb2df59e9a771666618c6017 100644 --- a/src/FactSystem/FactControls/FactPanelController.h +++ b/src/FactSystem/FactControls/FactPanelController.h @@ -56,6 +56,7 @@ protected: /// Report a missing fact to the FactPanel Qml element void _reportMissingFact(const QString& missingFact); + UASInterface* _uas; AutoPilotPlugin* _autopilot; private slots: diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index 67ae49eb5f1c29e7bf37a10e2767c6b61cd8a05c..ff533442c10890e963cc79fe38803ea841437993 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -62,6 +62,9 @@ #include "ViewWidgetController.h" #include "ParameterEditorController.h" #include "CustomCommandWidgetController.h" +#include "FlightModesComponentController.h" +#include "AirframeComponentController.h" +#include "SensorsComponentController.h" #include "ScreenTools.h" #include "MavManager.h" @@ -310,13 +313,20 @@ void QGCApplication::_initCommon(void) // setFont(fontDatabase.font(fontFamilyName, "Roman", 12)); // Register our Qml objects + qmlRegisterType("QGroundControl.Palette", 1, 0, "QGCPalette"); + qmlRegisterType("QGroundControl.Controllers", 1, 0, "ViewWidgetController"); qmlRegisterType("QGroundControl.Controllers", 1, 0, "ParameterEditorController"); qmlRegisterType("QGroundControl.Controllers", 1, 0, "CustomCommandWidgetController"); + qmlRegisterType("QGroundControl.Controllers", 1, 0, "FlightModesComponentController"); + qmlRegisterType("QGroundControl.Controllers", 1, 0, "AirframeComponentController"); + qmlRegisterType("QGroundControl.Controllers", 1, 0, "SensorsComponentController"); + //-- Create QML Singleton Interfaces qmlRegisterSingletonType("QGroundControl.ScreenTools", 1, 0, "ScreenTools", screenToolsSingletonFactory); qmlRegisterSingletonType("QGroundControl.MavManager", 1, 0, "MavManager", mavManagerSingletonFactory); + //-- Register Waypoint Interface qmlRegisterInterface("Waypoint"); } diff --git a/src/QmlControls/QGCView.qml b/src/QmlControls/QGCView.qml index 6a61211c8efbed9ad9e474fe7111dff4aadbbcd1..2fd8e97a3ccbeb11ca313f0729a664b6f33805b2 100644 --- a/src/QmlControls/QGCView.qml +++ b/src/QmlControls/QGCView.qml @@ -34,7 +34,7 @@ import QGroundControl.ScreenTools 1.0 import QGroundControl.FactSystem 1.0 import QGroundControl.FactControls 1.0 -Item { +FactPanel { id: __rootItem property Component viewComponent @@ -106,7 +106,7 @@ Item { } } - function __showDialog(component, title, charWidth, buttons) { + function showDialog(component, title, charWidth, buttons) { __dialogCharWidth = charWidth __dialogTitle = title @@ -117,7 +117,7 @@ Item { __dialogOverlay.visible = true } - function __showMessage(title, message, buttons) { + function showMessage(title, message, buttons) { __dialogCharWidth = 50 __dialogTitle = title __messageDialogText = message @@ -129,7 +129,7 @@ Item { __dialogOverlay.visible = true } - function __hideDialog() { + function hideDialog() { __dialogComponent = null __viewPanel.enabled = true __dialogOverlay.visible = false @@ -156,15 +156,15 @@ Item { Connections { target: __viewPanel.item - onShowDialog: __showDialog(component, title, charWidth, buttons) - onShowMessage: __showMessage(title, message, buttons) - onHideDialog: __hideDialog() + onShowDialog: __rootItem.showDialog(component, title, charWidth, buttons) + onShowMessage: __rootItem.showMessage(title, message, buttons) + onHideDialog: __rootItem.hideDialog() } Connections { target: __dialogComponentLoader.item - onHideDialog: __hideDialog() + onHideDialog: __rootItem.hideDialog() } Loader { diff --git a/src/QmlControls/QGCViewDialog.qml b/src/QmlControls/QGCViewDialog.qml index f65b9d61296c5d31430784b5001d5f2a03ef6abc..24a6da7b9925c6f1e7f923f2030ebfaa9586ffef 100644 --- a/src/QmlControls/QGCViewDialog.qml +++ b/src/QmlControls/QGCViewDialog.qml @@ -30,8 +30,11 @@ import QtQuick.Controls 1.3 import QGroundControl.Controls 1.0 import QGroundControl.Palette 1.0 -Rectangle { - QGCPalette { id: qgcPal; colorGroupEnabled: enabled } +import QGroundControl.FactSystem 1.0 +import QGroundControl.FactControls 1.0 + +FactPanel { + QGCPalette { id: __qgcPal; colorGroupEnabled: enabled } signal hideDialog @@ -43,5 +46,5 @@ Rectangle { hideDialog() } - color: qgcPal.windowShadeDark + color: __qgcPal.windowShadeDark } diff --git a/src/QmlControls/QGCViewPanel.qml b/src/QmlControls/QGCViewPanel.qml index de4a49bc4668f9f5e55ee5827c22b2285dd8a107..7cc4e75a95651fe66cfed9ae5ad2aea7e0555a2d 100644 --- a/src/QmlControls/QGCViewPanel.qml +++ b/src/QmlControls/QGCViewPanel.qml @@ -30,12 +30,15 @@ import QtQuick.Controls 1.3 import QGroundControl.Palette 1.0 import QGroundControl.Controls 1.0 -Rectangle { - property QGCPalette qgcPal: QGCPalette { colorGroupEnabled: enabled } +import QGroundControl.FactSystem 1.0 +import QGroundControl.FactControls 1.0 + +FactPanel { + QGCPalette { id: __qgcPal; colorGroupEnabled: enabled } signal showDialog(Component component, string title, int charWidth, int buttons) signal hideDialog signal showMessage(string title, string message, int buttons) - color: qgcPal.window + color: __qgcPal.window } diff --git a/src/VehicleSetup/FirmwareUpgrade.qml b/src/VehicleSetup/FirmwareUpgrade.qml index 94e28bb966436df65fb7f23a87757e9387380594..7aba5cdeec2ae189c920754c7a32192bc8424178 100644 --- a/src/VehicleSetup/FirmwareUpgrade.qml +++ b/src/VehicleSetup/FirmwareUpgrade.qml @@ -44,6 +44,8 @@ QGCView { QGCViewPanel { id: panel + QGCPalette { id: qgcPal; colorGroupEnabled: enabled } + FirmwareUpgradeController { id: controller upgradeButton: upgradeButton