From a0977b405b31499acb4f18fb0e3092fd18c60b1c Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Mon, 13 Aug 2012 10:13:35 +0300 Subject: [PATCH 01/16] CameraStab UI: use ConfigTaskWidget API with objrelation dynamic property This supports most of widgets which are directly related to UAVObjects. --- .../src/plugins/config/camerastabilization.ui | 223 +++++++++++++++++- .../configcamerastabilizationwidget.cpp | 132 +---------- .../config/configcamerastabilizationwidget.h | 5 +- 3 files changed, 226 insertions(+), 134 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/camerastabilization.ui b/ground/openpilotgcs/src/plugins/config/camerastabilization.ui index e535faa50..dd06b8379 100644 --- a/ground/openpilotgcs/src/plugins/config/camerastabilization.ui +++ b/ground/openpilotgcs/src/plugins/config/camerastabilization.ui @@ -27,8 +27,8 @@ 0 0 - 696 - 635 + 702 + 660 @@ -107,6 +107,16 @@ have to define channel output range using Output configuration tab. 20 + + + objname:CameraStabSettings + fieldname:OutputRange + element:Yaw + haslimits:no + scale:1 + buttongroup:1 + + @@ -126,6 +136,16 @@ have to define channel output range using Output configuration tab. 20 + + + objname:CameraStabSettings + fieldname:OutputRange + element:Pitch + haslimits:no + scale:1 + buttongroup:1 + + @@ -145,6 +165,16 @@ have to define channel output range using Output configuration tab. 20 + + + objname:CameraStabSettings + fieldname:OutputRange + element:Roll + haslimits:no + scale:1 + buttongroup:1 + + @@ -339,6 +369,14 @@ margin:1px; Don't forget to map this channel using Input configuration tab. + + + objname:CameraStabSettings + fieldname:Input + element:Yaw + buttongroup:1 + + None @@ -356,6 +394,14 @@ Don't forget to map this channel using Input configuration tab. Don't forget to map this channel using Input configuration tab. + + + objname:CameraStabSettings + fieldname:Input + element:Pitch + buttongroup:1 + + None @@ -373,6 +419,14 @@ Don't forget to map this channel using Input configuration tab. Don't forget to map this channel using Input configuration tab. + + + objname:CameraStabSettings + fieldname:Input + element:Roll + buttongroup:1 + + None @@ -398,6 +452,14 @@ Don't forget to map this channel using Input configuration tab. Attitude: camera tracks level for the axis. Input controls the deflection. AxisLock: camera remembers tracking attitude. Input controls the rate of deflection. + + + objname:CameraStabSettings + fieldname:StabilizationMode + element:Yaw + buttongroup:1 + + Attitude @@ -419,6 +481,16 @@ AxisLock: camera remembers tracking attitude. Input controls the rate of deflect 20 + + + objname:CameraStabSettings + fieldname:InputRange + element:Yaw + haslimits:no + scale:1 + buttongroup:1 + + @@ -435,6 +507,16 @@ AxisLock: camera remembers tracking attitude. Input controls the rate of deflect 50 + + + objname:CameraStabSettings + fieldname:InputRate + element:Yaw + haslimits:no + scale:1 + buttongroup:1 + + @@ -453,6 +535,16 @@ This option smoothes the stick input. Zero value disables LPF. 150 + + + objname:CameraStabSettings + fieldname:ResponseTime + element:Yaw + haslimits:no + scale:1 + buttongroup:1 + + @@ -466,6 +558,14 @@ This option smoothes the stick input. Zero value disables LPF. Attitude: camera tracks level for the axis. Input controls the deflection. AxisLock: camera remembers tracking attitude. Input controls the rate of deflection. + + + objname:CameraStabSettings + fieldname:StabilizationMode + element:Pitch + buttongroup:1 + + Attitude @@ -487,6 +587,16 @@ AxisLock: camera remembers tracking attitude. Input controls the rate of deflect 20 + + + objname:CameraStabSettings + fieldname:InputRange + element:Pitch + haslimits:no + scale:1 + buttongroup:1 + + @@ -503,6 +613,16 @@ AxisLock: camera remembers tracking attitude. Input controls the rate of deflect 50 + + + objname:CameraStabSettings + fieldname:InputRate + element:Pitch + haslimits:no + scale:1 + buttongroup:1 + + @@ -521,6 +641,16 @@ This option smoothes the stick input. Zero value disables LPF. 150 + + + objname:CameraStabSettings + fieldname:ResponseTime + element:Pitch + haslimits:no + scale:1 + buttongroup:1 + + @@ -534,6 +664,14 @@ This option smoothes the stick input. Zero value disables LPF. Attitude: camera tracks level for the axis. Input controls the deflection. AxisLock: camera remembers tracking attitude. Input controls the rate of deflection. + + + objname:CameraStabSettings + fieldname:StabilizationMode + element:Roll + buttongroup:1 + + Attitude @@ -555,6 +693,16 @@ AxisLock: camera remembers tracking attitude. Input controls the rate of deflect 20 + + + objname:CameraStabSettings + fieldname:InputRange + element:Roll + haslimits:no + scale:1 + buttongroup:1 + + @@ -571,6 +719,16 @@ AxisLock: camera remembers tracking attitude. Input controls the rate of deflect 50 + + + objname:CameraStabSettings + fieldname:InputRate + element:Roll + haslimits:no + scale:1 + buttongroup:1 + + @@ -589,6 +747,16 @@ This option smoothes the stick input. Zero value disables LPF. 150 + + + objname:CameraStabSettings + fieldname:ResponseTime + element:Roll + haslimits:no + scale:1 + buttongroup:1 + + @@ -657,6 +825,15 @@ value. 1.000000000000000 + + + objname:CameraStabSettings + fieldname:MaxAxisLockRate + haslimits:no + scale:1 + buttongroup:1 + + @@ -754,6 +931,32 @@ value. true + + + button:help + url:http://wiki.openpilot.org/display/Doc/Camera+Stabilization+Configuration + + + + + + + + Reloads current data from board into GCS. +Useful if you have accidentally changed some settings. + +Loaded settings are not applied automatically. You have to click the +Apply or Save button afterwards. + + + Reload Board Data + + + + button:reload + buttongroup:1 + + @@ -767,6 +970,12 @@ Apply or Save button afterwards. Reset To Defaults + + + button:default + buttongroup:1 + + @@ -777,6 +986,11 @@ Apply or Save button afterwards. Apply + + + button:apply + + @@ -790,6 +1004,11 @@ Apply or Save button afterwards. false + + + button:save + + diff --git a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp index 3e757de63..51b944d83 100644 --- a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp @@ -36,60 +36,26 @@ ConfigCameraStabilizationWidget::ConfigCameraStabilizationWidget(QWidget *parent) : ConfigTaskWidget(parent) { - // TODO: this widget should use the addUAVObjectToWidgetRelation() m_camerastabilization = new Ui_CameraStabilizationWidget(); m_camerastabilization->setupUi(this); + // These comboboxes require special processing QComboBox *outputs[3] = { m_camerastabilization->rollChannel, m_camerastabilization->pitchChannel, m_camerastabilization->yawChannel, }; - QComboBox *inputs[3] = { - m_camerastabilization->rollInputChannel, - m_camerastabilization->pitchInputChannel, - m_camerastabilization->yawInputChannel, - }; - - QComboBox *stabilizationMode[3] = { - m_camerastabilization->rollStabilizationMode, - m_camerastabilization->pitchStabilizationMode, - m_camerastabilization->yawStabilizationMode, - }; - - CameraStabSettings *cameraStab = CameraStabSettings::GetInstance(getObjectManager()); - CameraStabSettings::DataFields cameraStabData = cameraStab->getData(); - for (int i = 0; i < 3; i++) { outputs[i]->clear(); outputs[i]->addItem("None"); for (quint32 j = 0; j < ActuatorCommand::CHANNEL_NUMELEM; j++) outputs[i]->addItem(QString("Channel %1").arg(j+1)); - - UAVObjectField *field; - - field = cameraStab->getField("Input"); - Q_ASSERT(field); - inputs[i]->clear(); - inputs[i]->addItems(field->getOptions()); - inputs[i]->setCurrentIndex(cameraStabData.Input[i]); - - field = cameraStab->getField("StabilizationMode"); - Q_ASSERT(field); - stabilizationMode[i]->clear(); - stabilizationMode[i]->addItems(field->getOptions()); - stabilizationMode[i]->setCurrentIndex(cameraStabData.StabilizationMode[i]); } - connectUpdates(); - - // Connect buttons - connect(m_camerastabilization->camerastabilizationResetToDefaults, SIGNAL(clicked()), this, SLOT(resetToDefaults())); - connect(m_camerastabilization->camerastabilizationSaveRAM, SIGNAL(clicked()), this, SLOT(applySettings())); - connect(m_camerastabilization->camerastabilizationSaveSD, SIGNAL(clicked()), this, SLOT(saveSettings())); - connect(m_camerastabilization->camerastabilizationHelp, SIGNAL(clicked()), this, SLOT(openHelp())); - + autoLoadWidgets(); + populateWidgets(); + refreshWidgetsValues(); disableMouseWheelEvents(); } @@ -102,7 +68,6 @@ void ConfigCameraStabilizationWidget::connectUpdates() { // Now connect the widget to the StabilizationSettings object connect(MixerSettings::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(refreshValues())); - connect(CameraStabSettings::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(refreshValues())); // TODO: This will need to support both CC and OP later connect(HwSettings::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(refreshValues())); } @@ -111,7 +76,6 @@ void ConfigCameraStabilizationWidget::disconnectUpdates() { // Now connect the widget to the StabilizationSettings object disconnect(MixerSettings::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(refreshValues())); - disconnect(CameraStabSettings::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(refreshValues())); // TODO: This will need to support both CC and OP later disconnect(HwSettings::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(refreshValues())); } @@ -182,36 +146,6 @@ void ConfigCameraStabilizationWidget::applySettings() } } - // Update the settings - CameraStabSettings *cameraStab = CameraStabSettings::GetInstance(getObjectManager()); - CameraStabSettings::DataFields cameraStabData = cameraStab->getData(); - - cameraStabData.OutputRange[CameraStabSettings::OUTPUTRANGE_ROLL] = m_camerastabilization->rollOutputRange->value(); - cameraStabData.OutputRange[CameraStabSettings::OUTPUTRANGE_PITCH] = m_camerastabilization->pitchOutputRange->value(); - cameraStabData.OutputRange[CameraStabSettings::OUTPUTRANGE_YAW] = m_camerastabilization->yawOutputRange->value(); - - cameraStabData.Input[CameraStabSettings::INPUT_ROLL] = m_camerastabilization->rollInputChannel->currentIndex(); - cameraStabData.Input[CameraStabSettings::INPUT_PITCH] = m_camerastabilization->pitchInputChannel->currentIndex(); - cameraStabData.Input[CameraStabSettings::INPUT_YAW] = m_camerastabilization->yawInputChannel->currentIndex(); - - cameraStabData.StabilizationMode[CameraStabSettings::STABILIZATIONMODE_ROLL] = m_camerastabilization->rollStabilizationMode->currentIndex(); - cameraStabData.StabilizationMode[CameraStabSettings::STABILIZATIONMODE_PITCH] = m_camerastabilization->pitchStabilizationMode->currentIndex(); - cameraStabData.StabilizationMode[CameraStabSettings::STABILIZATIONMODE_YAW] = m_camerastabilization->yawStabilizationMode->currentIndex(); - - cameraStabData.InputRange[CameraStabSettings::INPUTRANGE_ROLL] = m_camerastabilization->rollInputRange->value(); - cameraStabData.InputRange[CameraStabSettings::INPUTRANGE_PITCH] = m_camerastabilization->pitchInputRange->value(); - cameraStabData.InputRange[CameraStabSettings::INPUTRANGE_YAW] = m_camerastabilization->yawInputRange->value(); - - cameraStabData.InputRate[CameraStabSettings::INPUTRATE_ROLL] = m_camerastabilization->rollInputRate->value(); - cameraStabData.InputRate[CameraStabSettings::INPUTRATE_PITCH] = m_camerastabilization->pitchInputRate->value(); - cameraStabData.InputRate[CameraStabSettings::INPUTRATE_YAW] = m_camerastabilization->yawInputRate->value(); - - cameraStabData.ResponseTime[CameraStabSettings::RESPONSETIME_ROLL] = m_camerastabilization->rollResponseTime->value(); - cameraStabData.ResponseTime[CameraStabSettings::RESPONSETIME_PITCH] = m_camerastabilization->pitchResponseTime->value(); - cameraStabData.ResponseTime[CameraStabSettings::RESPONSETIME_YAW] = m_camerastabilization->yawResponseTime->value(); - - cameraStabData.MaxAxisLockRate = m_camerastabilization->MaxAxisLockRate->value(); - // Because multiple objects are updated, and all of them trigger the callback // they must be done together (if update one then load settings from second // the first update would wipe the UI controls). However to be extra cautious @@ -219,7 +153,6 @@ void ConfigCameraStabilizationWidget::applySettings() disconnectUpdates(); hwSettings->setData(hwSettingsData); mixerSettings->setData(mixerSettingsData); - cameraStab->setData(cameraStabData); connectUpdates(); } @@ -237,40 +170,6 @@ void ConfigCameraStabilizationWidget::saveSettings() saveObjectToSD(obj); } -/** - * Refresh UI with new settings of CameraStabSettings object - * (either from active configuration or just loaded defaults - * to be applied or saved) - */ -void ConfigCameraStabilizationWidget::refreshUIValues(CameraStabSettings::DataFields &cameraStabData) -{ - m_camerastabilization->rollOutputRange->setValue(cameraStabData.OutputRange[CameraStabSettings::OUTPUTRANGE_ROLL]); - m_camerastabilization->pitchOutputRange->setValue(cameraStabData.OutputRange[CameraStabSettings::OUTPUTRANGE_PITCH]); - m_camerastabilization->yawOutputRange->setValue(cameraStabData.OutputRange[CameraStabSettings::OUTPUTRANGE_YAW]); - - m_camerastabilization->rollInputChannel->setCurrentIndex(cameraStabData.Input[CameraStabSettings::INPUT_ROLL]); - m_camerastabilization->pitchInputChannel->setCurrentIndex(cameraStabData.Input[CameraStabSettings::INPUT_PITCH]); - m_camerastabilization->yawInputChannel->setCurrentIndex(cameraStabData.Input[CameraStabSettings::INPUT_YAW]); - - m_camerastabilization->rollStabilizationMode->setCurrentIndex(cameraStabData.StabilizationMode[CameraStabSettings::STABILIZATIONMODE_ROLL]); - m_camerastabilization->pitchStabilizationMode->setCurrentIndex(cameraStabData.StabilizationMode[CameraStabSettings::STABILIZATIONMODE_PITCH]); - m_camerastabilization->yawStabilizationMode->setCurrentIndex(cameraStabData.StabilizationMode[CameraStabSettings::STABILIZATIONMODE_YAW]); - - m_camerastabilization->rollInputRange->setValue(cameraStabData.InputRange[CameraStabSettings::INPUTRANGE_ROLL]); - m_camerastabilization->pitchInputRange->setValue(cameraStabData.InputRange[CameraStabSettings::INPUTRANGE_PITCH]); - m_camerastabilization->yawInputRange->setValue(cameraStabData.InputRange[CameraStabSettings::INPUTRANGE_YAW]); - - m_camerastabilization->rollInputRate->setValue(cameraStabData.InputRate[CameraStabSettings::INPUTRATE_ROLL]); - m_camerastabilization->pitchInputRate->setValue(cameraStabData.InputRate[CameraStabSettings::INPUTRATE_PITCH]); - m_camerastabilization->yawInputRate->setValue(cameraStabData.InputRate[CameraStabSettings::INPUTRATE_YAW]); - - m_camerastabilization->rollResponseTime->setValue(cameraStabData.ResponseTime[CameraStabSettings::RESPONSETIME_ROLL]); - m_camerastabilization->pitchResponseTime->setValue(cameraStabData.ResponseTime[CameraStabSettings::RESPONSETIME_PITCH]); - m_camerastabilization->yawResponseTime->setValue(cameraStabData.ResponseTime[CameraStabSettings::RESPONSETIME_YAW]); - - m_camerastabilization->MaxAxisLockRate->setValue(cameraStabData.MaxAxisLockRate); -} - void ConfigCameraStabilizationWidget::refreshValues() { HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager()); @@ -279,10 +178,6 @@ void ConfigCameraStabilizationWidget::refreshValues() hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTAB] == HwSettings::OPTIONALMODULES_ENABLED); - CameraStabSettings *cameraStabSettings = CameraStabSettings::GetInstance(getObjectManager()); - CameraStabSettings::DataFields cameraStabData = cameraStabSettings->getData(); - refreshUIValues(cameraStabData); - MixerSettings *mixerSettings = MixerSettings::GetInstance(getObjectManager()); MixerSettings::DataFields mixerSettingsData = mixerSettings->getData(); const int NUM_MIXERS = 10; @@ -319,25 +214,6 @@ void ConfigCameraStabilizationWidget::refreshValues() } } -void ConfigCameraStabilizationWidget::resetToDefaults() -{ - CameraStabSettings cameraStabDefaults; - CameraStabSettings::DataFields defaults = cameraStabDefaults.getData(); - refreshUIValues(defaults); -} - -void ConfigCameraStabilizationWidget::openHelp() -{ - QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/display/Doc/Camera+Stabilization+Configuration", QUrl::StrictMode) ); -} - -void ConfigCameraStabilizationWidget::enableControls(bool enable) -{ - m_camerastabilization->camerastabilizationResetToDefaults->setEnabled(enable); - m_camerastabilization->camerastabilizationSaveSD->setEnabled(enable); - m_camerastabilization->camerastabilizationSaveRAM->setEnabled(enable); -} - /** @} @} diff --git a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.h b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.h index 743435adb..7c86ae021 100644 --- a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.h @@ -41,14 +41,11 @@ class ConfigCameraStabilizationWidget: public ConfigTaskWidget public: ConfigCameraStabilizationWidget(QWidget *parent = 0); ~ConfigCameraStabilizationWidget(); + private: Ui_CameraStabilizationWidget *m_camerastabilization; - virtual void enableControls(bool enable); - void refreshUIValues(CameraStabSettings::DataFields &cameraStabData); private slots: - void openHelp(); - void resetToDefaults(); void applySettings(); void saveSettings(); void refreshValues(); From c8e90a537e2056b914541ac1c73c01970e96d7a0 Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Tue, 14 Aug 2012 17:15:53 +0300 Subject: [PATCH 02/16] CameraStab UI: use ConfigTaskWidget API to take care of other widgets --- .../src/plugins/config/camerastabilization.ui | 44 ++-- .../configcamerastabilizationwidget.cpp | 224 +++++++++--------- .../config/configcamerastabilizationwidget.h | 11 +- 3 files changed, 132 insertions(+), 147 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/camerastabilization.ui b/ground/openpilotgcs/src/plugins/config/camerastabilization.ui index dd06b8379..a394820e7 100644 --- a/ground/openpilotgcs/src/plugins/config/camerastabilization.ui +++ b/ground/openpilotgcs/src/plugins/config/camerastabilization.ui @@ -939,30 +939,10 @@ value. - - - - Reloads current data from board into GCS. -Useful if you have accidentally changed some settings. - -Loaded settings are not applied automatically. You have to click the -Apply or Save button afterwards. - - - Reload Board Data - - - - button:reload - buttongroup:1 - - - - - Load default CameraStabilization settings except output channels + Load default CameraStabilization settings except output channels into GCS. Loaded settings are not applied automatically. You have to click the Apply or Save button afterwards. @@ -978,6 +958,27 @@ Apply or Save button afterwards. + + + + Reloads saved CameraStabilization settings except output channels +from board into GCS. Useful if you have accidentally changed some +settings. + +Loaded settings are not applied automatically. You have to click the +Apply or Save button afterwards. + + + Reload Board Data + + + + button:reload + buttongroup:1 + + + + @@ -1042,7 +1043,6 @@ Apply or Save button afterwards. yawResponseTime MaxAxisLockRate camerastabilizationHelp - camerastabilizationResetToDefaults camerastabilizationSaveRAM camerastabilizationSaveSD scrollArea diff --git a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp index 51b944d83..0a72be67d 100644 --- a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp @@ -30,32 +30,41 @@ #include "mixersettings.h" #include "actuatorcommand.h" -#include -#include -#include - ConfigCameraStabilizationWidget::ConfigCameraStabilizationWidget(QWidget *parent) : ConfigTaskWidget(parent) { m_camerastabilization = new Ui_CameraStabilizationWidget(); m_camerastabilization->setupUi(this); - // These comboboxes require special processing - QComboBox *outputs[3] = { + // These widgets don't have direct relation to UAVObjects + // and need special processing + QComboBox *outputs[] = { m_camerastabilization->rollChannel, m_camerastabilization->pitchChannel, m_camerastabilization->yawChannel, }; + const int NUM_OUTPUTS = sizeof(outputs) / sizeof(outputs[0]); - for (int i = 0; i < 3; i++) { + // Populate widgets with channel numbers + for (int i = 0; i < NUM_OUTPUTS; i++) { outputs[i]->clear(); outputs[i]->addItem("None"); for (quint32 j = 0; j < ActuatorCommand::CHANNEL_NUMELEM; j++) outputs[i]->addItem(QString("Channel %1").arg(j+1)); } + // Load UAVObjects to widget relations from UI file + // using objrelation dynamic property autoLoadWidgets(); - populateWidgets(); - refreshWidgetsValues(); + + // Add some widgets and UAVObjects to track widget dirty state + // and monitor UAVObject changes in addition to autoloaded ones + addWidget(m_camerastabilization->enableCameraStabilization); + addWidget(m_camerastabilization->rollChannel); + addWidget(m_camerastabilization->pitchChannel); + addWidget(m_camerastabilization->yawChannel); + addUAVObject("HwSettings"); + addUAVObject("MixerSettings"); + disableMouseWheelEvents(); } @@ -64,50 +73,32 @@ ConfigCameraStabilizationWidget::~ConfigCameraStabilizationWidget() // Do nothing } -void ConfigCameraStabilizationWidget::connectUpdates() +/* + * This overridden function refreshes widgets which have no direct relation + * to any of UAVObjects. It saves their dirty state first because update comes + * from UAVObjects, and then restores it. Aftewards it calls base class + * function to take care of other widgets which were dynamically added. + */ +void ConfigCameraStabilizationWidget::refreshWidgetsValues(UAVObject *obj) { - // Now connect the widget to the StabilizationSettings object - connect(MixerSettings::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(refreshValues())); - // TODO: This will need to support both CC and OP later - connect(HwSettings::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(refreshValues())); -} + bool dirty = isDirty(); -void ConfigCameraStabilizationWidget::disconnectUpdates() -{ - // Now connect the widget to the StabilizationSettings object - disconnect(MixerSettings::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(refreshValues())); - // TODO: This will need to support both CC and OP later - disconnect(HwSettings::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(refreshValues())); -} - -/** - * @brief Populate the gui settings into the appropriate - * UAV structures - */ -void ConfigCameraStabilizationWidget::applySettings() -{ - // Enable or disable the settings + // Set module enable checkbox from OptionalModules UAVObject item. + // It needs special processing because ConfigTaskWidget uses TRUE/FALSE + // for QCheckBox, but OptionalModules uses Enabled/Disabled enum values. HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager()); HwSettings::DataFields hwSettingsData = hwSettings->getData(); - hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTAB] = - m_camerastabilization->enableCameraStabilization->isChecked() ? - HwSettings::OPTIONALMODULES_ENABLED : - HwSettings::OPTIONALMODULES_DISABLED; - // Update the mixer settings + m_camerastabilization->enableCameraStabilization->setChecked( + hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTAB] == HwSettings::OPTIONALMODULES_ENABLED); + + // Load mixer outputs which are mapped to camera controls MixerSettings *mixerSettings = MixerSettings::GetInstance(getObjectManager()); MixerSettings::DataFields mixerSettingsData = mixerSettings->getData(); - const int NUM_MIXERS = 10; - - QComboBox *outputs[3] = { - m_camerastabilization->rollChannel, - m_camerastabilization->pitchChannel, - m_camerastabilization->yawChannel, - }; // TODO: Need to reformat object so types are an // array themselves. This gets really awkward - quint8 * mixerTypes[NUM_MIXERS] = { + quint8 *mixerTypes[] = { &mixerSettingsData.Mixer1Type, &mixerSettingsData.Mixer2Type, &mixerSettingsData.Mixer3Type, @@ -119,18 +110,83 @@ void ConfigCameraStabilizationWidget::applySettings() &mixerSettingsData.Mixer9Type, &mixerSettingsData.Mixer10Type, }; + const int NUM_MIXERS = sizeof(mixerTypes) / sizeof(mixerTypes[0]); + + QComboBox *outputs[] = { + m_camerastabilization->rollChannel, + m_camerastabilization->pitchChannel, + m_camerastabilization->yawChannel + }; + const int NUM_OUTPUTS = sizeof(outputs) / sizeof(outputs[0]); + + for (int i = 0; i < NUM_OUTPUTS; i++) { + // Default to none if not found. + // Then search for any mixer channels set to this + outputs[i]->setCurrentIndex(0); + for (int j = 0; j < NUM_MIXERS; j++) + if (*mixerTypes[j] == (MixerSettings::MIXER1TYPE_CAMERAROLL + i) && + outputs[i]->currentIndex() != (j + 1)) + outputs[i]->setCurrentIndex(j + 1); + } + + setDirty(dirty); + + ConfigTaskWidget::refreshWidgetsValues(obj); +} + +/* + * This overridden function updates UAVObjects which have no direct relation + * to any of widgets. Aftewards it calls base class function to take care of + * other object to widget relations which were dynamically added. + */ +void ConfigCameraStabilizationWidget::updateObjectsFromWidgets() +{ + // Save state of the module enable checkbox first + HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager()); + HwSettings::DataFields hwSettingsData = hwSettings->getData(); + hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTAB] = + m_camerastabilization->enableCameraStabilization->isChecked() ? + HwSettings::OPTIONALMODULES_ENABLED : HwSettings::OPTIONALMODULES_DISABLED; + hwSettings->setData(hwSettingsData); + + // Update mixer channels which were mapped to camera outputs in case they are + // not used for other function yet + MixerSettings *mixerSettings = MixerSettings::GetInstance(getObjectManager()); + MixerSettings::DataFields mixerSettingsData = mixerSettings->getData(); + + // TODO: Need to reformat object so types are an + // array themselves. This gets really awkward + quint8 *mixerTypes[] = { + &mixerSettingsData.Mixer1Type, + &mixerSettingsData.Mixer2Type, + &mixerSettingsData.Mixer3Type, + &mixerSettingsData.Mixer4Type, + &mixerSettingsData.Mixer5Type, + &mixerSettingsData.Mixer6Type, + &mixerSettingsData.Mixer7Type, + &mixerSettingsData.Mixer8Type, + &mixerSettingsData.Mixer9Type, + &mixerSettingsData.Mixer10Type, + }; + const int NUM_MIXERS = sizeof(mixerTypes) / sizeof(mixerTypes[0]); + + QComboBox *outputs[] = { + m_camerastabilization->rollChannel, + m_camerastabilization->pitchChannel, + m_camerastabilization->yawChannel + }; + const int NUM_OUTPUTS = sizeof(outputs) / sizeof(outputs[0]); m_camerastabilization->message->setText(""); - for (int i = 0; i < 3; i++) - { + for (int i = 0; i < NUM_OUTPUTS; i++) { // Channel 1 is second entry, so becomes zero int mixerNum = outputs[i]->currentIndex() - 1; - if ( mixerNum >= 0 && // Short circuit in case of none - *mixerTypes[mixerNum] != MixerSettings::MIXER1TYPE_DISABLED && - (*mixerTypes[mixerNum] != MixerSettings::MIXER1TYPE_CAMERAROLL + i) ) { - // If the mixer channel already to something that isn't what we are - // about to set it to reset to none + if ((mixerNum >= 0) && // Short circuit in case of none + (*mixerTypes[mixerNum] != MixerSettings::MIXER1TYPE_DISABLED) && + (*mixerTypes[mixerNum] != MixerSettings::MIXER1TYPE_CAMERAROLL + i) ) { + // If the mixer channel already mapped to something, it should not be + // used for camera output, we reset it to none outputs[i]->setCurrentIndex(0); m_camerastabilization->message->setText("One of the channels is already assigned, reverted to none"); } else { @@ -141,77 +197,13 @@ void ConfigCameraStabilizationWidget::applySettings() // If this channel is assigned to one of the outputs that is not disabled // set it - if(mixerNum >= 0 && mixerNum < NUM_MIXERS) + if ((mixerNum >= 0) && (mixerNum < NUM_MIXERS)) *mixerTypes[mixerNum] = MixerSettings::MIXER1TYPE_CAMERAROLL + i; } } - - // Because multiple objects are updated, and all of them trigger the callback - // they must be done together (if update one then load settings from second - // the first update would wipe the UI controls). However to be extra cautious - // I'm also disabling updates during the setting to the UAVObjects - disconnectUpdates(); - hwSettings->setData(hwSettingsData); mixerSettings->setData(mixerSettingsData); - connectUpdates(); -} -/** - * Push settings into UAV objects then save them - */ -void ConfigCameraStabilizationWidget::saveSettings() -{ - applySettings(); - UAVObject *obj = HwSettings::GetInstance(getObjectManager()); - saveObjectToSD(obj); - obj = MixerSettings::GetInstance(getObjectManager()); - saveObjectToSD(obj); - obj = CameraStabSettings::GetInstance(getObjectManager()); - saveObjectToSD(obj); -} - -void ConfigCameraStabilizationWidget::refreshValues() -{ - HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager()); - HwSettings::DataFields hwSettingsData = hwSettings->getData(); - m_camerastabilization->enableCameraStabilization->setChecked( - hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTAB] == - HwSettings::OPTIONALMODULES_ENABLED); - - MixerSettings *mixerSettings = MixerSettings::GetInstance(getObjectManager()); - MixerSettings::DataFields mixerSettingsData = mixerSettings->getData(); - const int NUM_MIXERS = 10; - QComboBox *outputs[3] = { - m_camerastabilization->rollChannel, - m_camerastabilization->pitchChannel, - m_camerastabilization->yawChannel - }; - - // TODO: Need to reformat object so types are an - // array themselves. This gets really awkward - quint8 * mixerTypes[NUM_MIXERS] = { - &mixerSettingsData.Mixer1Type, - &mixerSettingsData.Mixer2Type, - &mixerSettingsData.Mixer3Type, - &mixerSettingsData.Mixer4Type, - &mixerSettingsData.Mixer5Type, - &mixerSettingsData.Mixer6Type, - &mixerSettingsData.Mixer7Type, - &mixerSettingsData.Mixer8Type, - &mixerSettingsData.Mixer9Type, - &mixerSettingsData.Mixer10Type, - }; - - for (int i = 0; i < 3; i++) - { - // Default to none if not found. Then search for any mixer channels set to - // this - outputs[i]->setCurrentIndex(0); - for (int j = 0; j < NUM_MIXERS; j++) - if (*mixerTypes[j] == (MixerSettings::MIXER1TYPE_CAMERAROLL + i) && - outputs[i]->currentIndex() != (j + 1)) - outputs[i]->setCurrentIndex(j + 1); - } + ConfigTaskWidget::updateObjectsFromWidgets(); } /** diff --git a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.h b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.h index 7c86ae021..1b4230254 100644 --- a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.h @@ -44,15 +44,8 @@ public: private: Ui_CameraStabilizationWidget *m_camerastabilization; - -private slots: - void applySettings(); - void saveSettings(); - void refreshValues(); - -protected: - void connectUpdates(); - void disconnectUpdates(); + void refreshWidgetsValues(UAVObject *obj); + void updateObjectsFromWidgets(); }; #endif // CONFIGCAMERASTABILIZATIONWIDGET_H From 64e5ff8e6dd991c2204483cec628e560cfaaf354 Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Tue, 14 Aug 2012 17:52:44 +0300 Subject: [PATCH 03/16] CameraStab UI: rescan widget if changed during UAVObject update --- .../configcamerastabilizationwidget.cpp | 49 +++++++++++-------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp index 0a72be67d..95bcbbb28 100644 --- a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp @@ -178,29 +178,38 @@ void ConfigCameraStabilizationWidget::updateObjectsFromWidgets() const int NUM_OUTPUTS = sizeof(outputs) / sizeof(outputs[0]); m_camerastabilization->message->setText(""); - for (int i = 0; i < NUM_OUTPUTS; i++) { - // Channel 1 is second entry, so becomes zero - int mixerNum = outputs[i]->currentIndex() - 1; + bool widgetUpdated; + do { + widgetUpdated = false; - if ((mixerNum >= 0) && // Short circuit in case of none - (*mixerTypes[mixerNum] != MixerSettings::MIXER1TYPE_DISABLED) && - (*mixerTypes[mixerNum] != MixerSettings::MIXER1TYPE_CAMERAROLL + i) ) { - // If the mixer channel already mapped to something, it should not be - // used for camera output, we reset it to none - outputs[i]->setCurrentIndex(0); - m_camerastabilization->message->setText("One of the channels is already assigned, reverted to none"); - } else { - // Make sure no other channels have this output set - for (int j = 0; j < NUM_MIXERS; j++) - if (*mixerTypes[j] == (MixerSettings::MIXER1TYPE_CAMERAROLL + i)) - *mixerTypes[j] = MixerSettings::MIXER1TYPE_DISABLED; + for (int i = 0; i < NUM_OUTPUTS; i++) { + // Channel 1 is second entry, so becomes zero + int mixerNum = outputs[i]->currentIndex() - 1; - // If this channel is assigned to one of the outputs that is not disabled - // set it - if ((mixerNum >= 0) && (mixerNum < NUM_MIXERS)) - *mixerTypes[mixerNum] = MixerSettings::MIXER1TYPE_CAMERAROLL + i; + if ((mixerNum >= 0) && // Short circuit in case of none + (*mixerTypes[mixerNum] != MixerSettings::MIXER1TYPE_DISABLED) && + (*mixerTypes[mixerNum] != MixerSettings::MIXER1TYPE_CAMERAROLL + i) ) { + // If the mixer channel already mapped to something, it should not be + // used for camera output, we reset it to none + outputs[i]->setCurrentIndex(0); + m_camerastabilization->message->setText("One of the channels is already assigned, reverted to none"); + + // Loop again or we may have inconsistent widget and UAVObject + widgetUpdated = true; + } else { + // Make sure no other channels have this output set + for (int j = 0; j < NUM_MIXERS; j++) + if (*mixerTypes[j] == (MixerSettings::MIXER1TYPE_CAMERAROLL + i)) + *mixerTypes[j] = MixerSettings::MIXER1TYPE_DISABLED; + + // If this channel is assigned to one of the outputs that is not disabled + // set it + if ((mixerNum >= 0) && (mixerNum < NUM_MIXERS)) + *mixerTypes[mixerNum] = MixerSettings::MIXER1TYPE_CAMERAROLL + i; + } } - } + } while(widgetUpdated); + mixerSettings->setData(mixerSettingsData); ConfigTaskWidget::updateObjectsFromWidgets(); From 0f8974178a96337a3f888fb83a14225be9aa568a Mon Sep 17 00:00:00 2001 From: PT_Dreamer Date: Tue, 14 Aug 2012 18:12:07 +0100 Subject: [PATCH 04/16] GCS-Fixes crash if autoLoadWidgets is called after addUAVObject --- .../src/plugins/uavobjectwidgetutils/configtaskwidget.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index 7fb8d70c7..7bfbfb0c3 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -698,10 +698,12 @@ void ConfigTaskWidget::autoLoadWidgets() forceShadowUpdates(); foreach(objectToWidget * ow,objOfInterest) { - qDebug()<<"Master:"<widget->objectName(); + if(ow->widget) + qDebug()<<"Master:"<widget->objectName(); foreach(shadow * sh,ow->shadowsList) { - qDebug()<<"Child"<widget->objectName(); + if(sh->widget) + qDebug()<<"Child"<widget->objectName(); } } } From 2ddb0e63d2d37d4fbd662504f865f4f5aa85fbf5 Mon Sep 17 00:00:00 2001 From: PT_Dreamer Date: Tue, 14 Aug 2012 23:02:08 +0100 Subject: [PATCH 05/16] GCS-Couple of bug fixes and created a new defaultRequested signal --- .../plugins/config/configcamerastabilizationwidget.cpp | 5 +++++ .../src/plugins/config/configcamerastabilizationwidget.h | 2 ++ .../plugins/uavobjectwidgetutils/configtaskwidget.cpp | 9 +++------ .../src/plugins/uavobjectwidgetutils/configtaskwidget.h | 2 +- .../src/plugins/uavobjectwidgetutils/smartsavebutton.cpp | 1 + 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp index 95bcbbb28..95c58573b 100644 --- a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp @@ -66,6 +66,7 @@ ConfigCameraStabilizationWidget::ConfigCameraStabilizationWidget(QWidget *parent addUAVObject("MixerSettings"); disableMouseWheelEvents(); + connect(this,SIGNAL(defaultRequested(int)),this,SLOT(defaultRequestedSlot(int))); } ConfigCameraStabilizationWidget::~ConfigCameraStabilizationWidget() @@ -214,6 +215,10 @@ void ConfigCameraStabilizationWidget::updateObjectsFromWidgets() ConfigTaskWidget::updateObjectsFromWidgets(); } +void ConfigCameraStabilizationWidget::defaultRequestedSlot(int group) +{ + +} /** @} diff --git a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.h b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.h index 1b4230254..6c1a8d888 100644 --- a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.h @@ -46,6 +46,8 @@ private: Ui_CameraStabilizationWidget *m_camerastabilization; void refreshWidgetsValues(UAVObject *obj); void updateObjectsFromWidgets(); +private slots: + void defaultRequestedSlot(int group); }; #endif // CONFIGCAMERASTABILIZATIONWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index 7bfbfb0c3..bd95532dd 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -32,7 +32,7 @@ /** * Constructor */ -ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),isConnected(false),smartsave(NULL),dirty(false),outOfLimitsStyle("background-color: rgb(255, 0, 0);"),timeOut(NULL),allowWidgetUpdates(true) +ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),isConnected(false),smartsave(NULL),dirty(false),outOfLimitsStyle("background-color: rgb(255, 0, 0);"),allowWidgetUpdates(true) { pm = ExtensionSystem::PluginManager::instance(); objManager = pm->getObject(); @@ -176,10 +176,6 @@ ConfigTaskWidget::~ConfigTaskWidget() if(oTw) delete oTw; } - if(timeOut) - { - delete timeOut; - } } void ConfigTaskWidget::saveObjectToSD(UAVObject *obj) @@ -772,6 +768,7 @@ void ConfigTaskWidget::addReloadButton(QPushButton *button, int buttonGroup) void ConfigTaskWidget::defaultButtonClicked() { int group=sender()->property("group").toInt(); + emit defaultRequested(group); QList * list=defaultReloadGroups.value(group); foreach(objectToWidget * oTw,*list) { @@ -791,7 +788,7 @@ void ConfigTaskWidget::reloadButtonClicked() if(!list) return; ObjectPersistence* objper = dynamic_cast( getObjectManager()->getObject(ObjectPersistence::NAME) ); - timeOut=new QTimer(this); + QTimer * timeOut=new QTimer(this); QEventLoop * eventLoop=new QEventLoop(this); connect(timeOut, SIGNAL(timeout()),eventLoop,SLOT(quit())); connect(objper, SIGNAL(objectUpdated(UAVObject*)), eventLoop, SLOT(quit())); diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h index 3cac0abc0..ef2d9cd20 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h @@ -139,6 +139,7 @@ signals: void autoPilotConnected(); //fired when the autopilot disconnects void autoPilotDisconnected(); + void defaultRequested(int group); private slots: void objectUpdated(UAVObject*); void defaultButtonClicked(); @@ -165,7 +166,6 @@ private: void disconnectWidgetUpdatesToSlot(QWidget *widget, const char *function); void loadWidgetLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, double sclale); QString outOfLimitsStyle; - QTimer * timeOut; protected slots: virtual void disableObjUpdates(); virtual void enableObjUpdates(); diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.cpp index 9b0268a4e..28fe3c997 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/smartsavebutton.cpp @@ -151,6 +151,7 @@ void smartSaveButton::setObjects(QList list) void smartSaveButton::addObject(UAVDataObject * obj) { + Q_ASSERT(obj); if(!objects.contains(obj)) objects.append(obj); } From ae962f507bb0736e3889d43ce5b784645b027e96 Mon Sep 17 00:00:00 2001 From: PT_Dreamer Date: Tue, 14 Aug 2012 23:55:53 +0100 Subject: [PATCH 06/16] GCS-Couple of bug fixes and created a new defaultRequested signal --- .../src/plugins/uavobjectwidgetutils/configtaskwidget.cpp | 4 +++- .../src/plugins/uavobjectwidgetutils/configtaskwidget.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index bd95532dd..cdff00e53 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -783,12 +783,14 @@ void ConfigTaskWidget::defaultButtonClicked() */ void ConfigTaskWidget::reloadButtonClicked() { + if(timeOut) + return; int group=sender()->property("group").toInt(); QList * list=defaultReloadGroups.value(group,NULL); if(!list) return; ObjectPersistence* objper = dynamic_cast( getObjectManager()->getObject(ObjectPersistence::NAME) ); - QTimer * timeOut=new QTimer(this); + timeOut=new QTimer(this); QEventLoop * eventLoop=new QEventLoop(this); connect(timeOut, SIGNAL(timeout()),eventLoop,SLOT(quit())); connect(objper, SIGNAL(objectUpdated(UAVObject*)), eventLoop, SLOT(quit())); diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h index ef2d9cd20..25281a942 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h @@ -166,6 +166,7 @@ private: void disconnectWidgetUpdatesToSlot(QWidget *widget, const char *function); void loadWidgetLimits(QWidget *widget, UAVObjectField *field, int index, bool hasLimits, double sclale); QString outOfLimitsStyle; + QTimer * timeOut; protected slots: virtual void disableObjUpdates(); virtual void enableObjUpdates(); From d3c5fcfa7e10d1d9d64d5e2a6239200951c3daf7 Mon Sep 17 00:00:00 2001 From: PT_Dreamer Date: Wed, 15 Aug 2012 00:13:26 +0100 Subject: [PATCH 07/16] GCS-Handle reload operation config camera stab --- .../config/configcamerastabilizationwidget.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp index 95c58573b..74b89a653 100644 --- a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp @@ -217,7 +217,21 @@ void ConfigCameraStabilizationWidget::updateObjectsFromWidgets() } void ConfigCameraStabilizationWidget::defaultRequestedSlot(int group) { + HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager()); + HwSettings *hwSettingsDefault=(HwSettings*)hwSettings->dirtyClone(); + HwSettings::DataFields hwSettingsData = hwSettingsDefault->getData(); + m_camerastabilization->enableCameraStabilization->setChecked( + hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTAB] == HwSettings::OPTIONALMODULES_ENABLED); + QComboBox *outputs[] = { + m_camerastabilization->rollChannel, + m_camerastabilization->pitchChannel, + m_camerastabilization->yawChannel, + }; + const int NUM_OUTPUTS = sizeof(outputs) / sizeof(outputs[0]); + for (int i = 0; i < NUM_OUTPUTS; i++) { + outputs[i]->setCurrentIndex(0); + } } /** From fd9f1491bae442b3ace5a1c0108b29a3baad7ce5 Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Wed, 15 Aug 2012 10:31:19 +0300 Subject: [PATCH 08/16] CameraStab UI: fix spacing and add comments according to OP coding style guidelines More info: http://wiki.openpilot.org/display/Doc/Coding+Style http://qt-project.org/wiki/Qt_Coding_Style --- .../config/configcamerastabilizationwidget.cpp | 12 +++++++++++- .../plugins/config/configcamerastabilizationwidget.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp index 74b89a653..b28453d38 100644 --- a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp @@ -65,8 +65,10 @@ ConfigCameraStabilizationWidget::ConfigCameraStabilizationWidget(QWidget *parent addUAVObject("HwSettings"); addUAVObject("MixerSettings"); + // To set special widgets to defaults when requested + connect(this, SIGNAL(defaultRequested(int)), this, SLOT(defaultRequestedSlot(int))); + disableMouseWheelEvents(); - connect(this,SIGNAL(defaultRequested(int)),this,SLOT(defaultRequestedSlot(int))); } ConfigCameraStabilizationWidget::~ConfigCameraStabilizationWidget() @@ -215,13 +217,21 @@ void ConfigCameraStabilizationWidget::updateObjectsFromWidgets() ConfigTaskWidget::updateObjectsFromWidgets(); } + +/* + * This slot function is called when "Default" button is clicked. + * All special widgets which belong to the group passed should be set here. + */ void ConfigCameraStabilizationWidget::defaultRequestedSlot(int group) { + Q_UNUSED(group); + HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager()); HwSettings *hwSettingsDefault=(HwSettings*)hwSettings->dirtyClone(); HwSettings::DataFields hwSettingsData = hwSettingsDefault->getData(); m_camerastabilization->enableCameraStabilization->setChecked( hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTAB] == HwSettings::OPTIONALMODULES_ENABLED); + QComboBox *outputs[] = { m_camerastabilization->rollChannel, m_camerastabilization->pitchChannel, diff --git a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.h b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.h index 6c1a8d888..871193e82 100644 --- a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.h +++ b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.h @@ -46,6 +46,7 @@ private: Ui_CameraStabilizationWidget *m_camerastabilization; void refreshWidgetsValues(UAVObject *obj); void updateObjectsFromWidgets(); + private slots: void defaultRequestedSlot(int group); }; From 93124bbfeeffa4f89b7b9f133335c61591402561 Mon Sep 17 00:00:00 2001 From: PT_Dreamer Date: Wed, 15 Aug 2012 12:37:00 +0100 Subject: [PATCH 09/16] GCS-Fixed reload operation, sorry Oleg --- .../src/plugins/uavobjectwidgetutils/configtaskwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index cdff00e53..1e0246882 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -32,7 +32,7 @@ /** * Constructor */ -ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),isConnected(false),smartsave(NULL),dirty(false),outOfLimitsStyle("background-color: rgb(255, 0, 0);"),allowWidgetUpdates(true) +ConfigTaskWidget::ConfigTaskWidget(QWidget *parent) : QWidget(parent),isConnected(false),smartsave(NULL),dirty(false),outOfLimitsStyle("background-color: rgb(255, 0, 0);"),timeOut(NULL),allowWidgetUpdates(true) { pm = ExtensionSystem::PluginManager::instance(); objManager = pm->getObject(); From 57d4aaaf170a298feecdd8d0654073526b69f7a8 Mon Sep 17 00:00:00 2001 From: PT_Dreamer Date: Wed, 15 Aug 2012 22:50:09 +0100 Subject: [PATCH 10/16] GCS-Handle reload for unbounded objects --- .../configcamerastabilizationwidget.cpp | 6 +++-- .../uavobjectwidgetutils/configtaskwidget.cpp | 27 ++++++++++++++----- .../uavobjectwidgetutils/configtaskwidget.h | 2 +- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp index b28453d38..6defa9a6a 100644 --- a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp @@ -56,14 +56,16 @@ ConfigCameraStabilizationWidget::ConfigCameraStabilizationWidget(QWidget *parent // using objrelation dynamic property autoLoadWidgets(); + QList reloadGroups; + reloadGroups<<1; // Add some widgets and UAVObjects to track widget dirty state // and monitor UAVObject changes in addition to autoloaded ones addWidget(m_camerastabilization->enableCameraStabilization); addWidget(m_camerastabilization->rollChannel); addWidget(m_camerastabilization->pitchChannel); addWidget(m_camerastabilization->yawChannel); - addUAVObject("HwSettings"); - addUAVObject("MixerSettings"); + addUAVObject("HwSettings",&reloadGroups); + addUAVObject("MixerSettings",&reloadGroups); // To set special widgets to defaults when requested connect(this, SIGNAL(defaultRequested(int)), this, SLOT(defaultRequestedSlot(int))); diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index 1e0246882..a947ffe6e 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -57,9 +57,9 @@ void ConfigTaskWidget::addWidget(QWidget * widget) * Add an object to the management system * @param objectName name of the object to add to the management system */ -void ConfigTaskWidget::addUAVObject(QString objectName) +void ConfigTaskWidget::addUAVObject(QString objectName,QList * reloadGroups) { - addUAVObjectToWidgetRelation(objectName,"",NULL); + addUAVObjectToWidgetRelation(objectName,"",NULL,0,1,false,reloadGroups); } /** * Add an UAVObject field to widget relation to the management system @@ -148,7 +148,21 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString fiel } if(widget==NULL) { - // do nothing + if(defaultReloadGroups && obj) + { + foreach(int i,*defaultReloadGroups) + { + if(this->defaultReloadGroups.contains(i)) + { + this->defaultReloadGroups.value(i)->append(ow); + } + else + { + this->defaultReloadGroups.insert(i,new QList()); + this->defaultReloadGroups.value(i)->append(ow); + } + } + } } else { @@ -537,7 +551,7 @@ bool ConfigTaskWidget::addShadowWidget(QString object, QString field, QWidget *w { foreach(objectToWidget * oTw,objOfInterest) { - if(!oTw->object || !oTw->widget) + if(!oTw->object || !oTw->widget || !oTw->field) continue; if(oTw->object->getName()==object && oTw->field->getName()==field && oTw->index==index && oTw->object->getInstID()==instID) { @@ -772,7 +786,7 @@ void ConfigTaskWidget::defaultButtonClicked() QList * list=defaultReloadGroups.value(group); foreach(objectToWidget * oTw,*list) { - if(!oTw->object) + if(!oTw->object || !oTw->field) continue; UAVDataObject * temp=((UAVDataObject*)oTw->object)->dirtyClone(); setWidgetFromField(oTw->widget,temp->getField(oTw->field->getName()),oTw->index,oTw->scale,oTw->isLimited); @@ -810,7 +824,8 @@ void ConfigTaskWidget::reloadButtonClicked() if(timeOut->isActive()) { oTw->object->requestUpdate(); - setWidgetFromField(oTw->widget,oTw->field,oTw->index,oTw->scale,oTw->isLimited); + if(oTw->widget) + setWidgetFromField(oTw->widget,oTw->field,oTw->index,oTw->scale,oTw->isLimited); } timeOut->stop(); } diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h index 25281a942..f4f0b6b9c 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h @@ -93,7 +93,7 @@ public: UAVObjectManager* getObjectManager(); static double listMean(QList list); - void addUAVObject(QString objectName); + void addUAVObject(QString objectName, QList *reloadGroups=NULL); void addWidget(QWidget * widget); void addUAVObjectToWidgetRelation(QString object,QString field,QWidget * widget,int index=0,double scale=1,bool isLimited=false,QList* defaultReloadGroups=0,quint32 instID=0); From 0afd9237087ef16b6e0bcf50ac38338c3040f5c0 Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Sat, 18 Aug 2012 20:45:05 +0300 Subject: [PATCH 11/16] CameraStab UI: more comments to serve as a self-documented code sample Also disabled "module enable" checkbox reload/default actions. --- .../configcamerastabilizationwidget.cpp | 36 ++++++++++++------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp index 6defa9a6a..e7d60f018 100644 --- a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp @@ -2,7 +2,7 @@ ****************************************************************************** * * @file configcamerastabilizationwidget.cpp - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2011-2012. * @addtogroup GCSPlugins GCS Plugins * @{ * @addtogroup ConfigPlugin Config Plugin @@ -56,16 +56,21 @@ ConfigCameraStabilizationWidget::ConfigCameraStabilizationWidget(QWidget *parent // using objrelation dynamic property autoLoadWidgets(); - QList reloadGroups; - reloadGroups<<1; - // Add some widgets and UAVObjects to track widget dirty state - // and monitor UAVObject changes in addition to autoloaded ones + // Add some widgets to track their UI dirty state and handle smartsave addWidget(m_camerastabilization->enableCameraStabilization); addWidget(m_camerastabilization->rollChannel); addWidget(m_camerastabilization->pitchChannel); addWidget(m_camerastabilization->yawChannel); - addUAVObject("HwSettings",&reloadGroups); - addUAVObject("MixerSettings",&reloadGroups); + + // Add some UAVObjects to monitor their changes in addition to autoloaded ones. + // Note also that we want to reload some UAVObjects by "Reload" button and have + // to pass corresponding reload group numbers (defined also in objrelation property) + // to the montitor. We don't reload HwSettings (module enable state) but reload + // output channels. + QList reloadGroups; + reloadGroups << 1; + addUAVObject("HwSettings"); + addUAVObject("MixerSettings", &reloadGroups); // To set special widgets to defaults when requested connect(this, SIGNAL(defaultRequested(int)), this, SLOT(defaultRequestedSlot(int))); @@ -228,12 +233,19 @@ void ConfigCameraStabilizationWidget::defaultRequestedSlot(int group) { Q_UNUSED(group); - HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager()); - HwSettings *hwSettingsDefault=(HwSettings*)hwSettings->dirtyClone(); - HwSettings::DataFields hwSettingsData = hwSettingsDefault->getData(); - m_camerastabilization->enableCameraStabilization->setChecked( - hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTAB] == HwSettings::OPTIONALMODULES_ENABLED); + // Here is the example of how to reset the state of QCheckBox. It is + // commented out because we normally don't want to reset the module + // enable state to default "disabled" (or we don't care about values at all). + // But if you want, you could use the dirtyClone() function to get default + // values of an object and then use them to set a widget state. + // + //HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager()); + //HwSettings *hwSettingsDefault=(HwSettings*)hwSettings->dirtyClone(); + //HwSettings::DataFields hwSettingsData = hwSettingsDefault->getData(); + //m_camerastabilization->enableCameraStabilization->setChecked( + // hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTAB] == HwSettings::OPTIONALMODULES_ENABLED); + // For outputs we set them all to none, so don't use any UAVObject to get defaults QComboBox *outputs[] = { m_camerastabilization->rollChannel, m_camerastabilization->pitchChannel, From 45e21acefdec56571bc57c6779c15f86b5588c0a Mon Sep 17 00:00:00 2001 From: PT_Dreamer Date: Sun, 19 Aug 2012 14:41:09 +0100 Subject: [PATCH 12/16] GCS- Get rid of the double hwsettings update. setData triggers an update so the other functions should be used instead. MixerSettings should be refactored next. --- .../src/plugins/config/configcamerastabilizationwidget.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp index e7d60f018..9c4470a1d 100644 --- a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp @@ -153,11 +153,9 @@ void ConfigCameraStabilizationWidget::updateObjectsFromWidgets() { // Save state of the module enable checkbox first HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager()); - HwSettings::DataFields hwSettingsData = hwSettings->getData(); - hwSettingsData.OptionalModules[HwSettings::OPTIONALMODULES_CAMERASTAB] = - m_camerastabilization->enableCameraStabilization->isChecked() ? + quint8 value = m_camerastabilization->enableCameraStabilization->isChecked() ? HwSettings::OPTIONALMODULES_ENABLED : HwSettings::OPTIONALMODULES_DISABLED; - hwSettings->setData(hwSettingsData); + hwSettings->setOptionalModules(HwSettings::OPTIONALMODULES_CAMERASTAB,value); // Update mixer channels which were mapped to camera outputs in case they are // not used for other function yet From 84d55ca416bd6272df9140ff55bacb264f4f0f41 Mon Sep 17 00:00:00 2001 From: PT_Dreamer Date: Sun, 19 Aug 2012 14:41:57 +0100 Subject: [PATCH 13/16] GCS-Added a few overloaded functions so that object and field pointers can be used with confitaskwidget framework --- .../uavobjectwidgetutils/configtaskwidget.cpp | 42 +++++++++++++++++++ .../uavobjectwidgetutils/configtaskwidget.h | 7 ++++ 2 files changed, 49 insertions(+) diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp index a947ffe6e..88e7d868a 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.cpp @@ -61,6 +61,15 @@ void ConfigTaskWidget::addUAVObject(QString objectName,QList * reloadGroups { addUAVObjectToWidgetRelation(objectName,"",NULL,0,1,false,reloadGroups); } + +void ConfigTaskWidget::addUAVObject(UAVObject *objectName, QList *reloadGroups) +{ + QString objstr; + if(objectName) + objstr=objectName->getName(); + addUAVObject(objstr, reloadGroups); + +} /** * Add an UAVObject field to widget relation to the management system * @param object name of the object to add @@ -78,6 +87,17 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString fiel Q_ASSERT(_field); addUAVObjectToWidgetRelation(object,field,widget,_field->getElementNames().indexOf(index)); } + +void ConfigTaskWidget::addUAVObjectToWidgetRelation(UAVObject *obj, UAVObjectField * field, QWidget *widget, QString index) +{ + QString objstr; + QString fieldstr; + if(obj) + objstr=obj->getName(); + if(field) + fieldstr=field->getName(); + addUAVObjectToWidgetRelation(objstr, fieldstr, widget, index); +} /** * Add a UAVObject field to widget relation to the management system * @param object name of the object to add @@ -103,6 +123,28 @@ void ConfigTaskWidget::addUAVObjectToWidgetRelation(QString object, QString fiel } addUAVObjectToWidgetRelation(object, field, widget,index,scale,isLimited,defaultReloadGroups,instID); } + +void ConfigTaskWidget::addUAVObjectToWidgetRelation(UAVObject *obj, UAVObjectField *field, QWidget *widget, QString element, double scale, bool isLimited, QList *defaultReloadGroups, quint32 instID) +{ + QString objstr; + QString fieldstr; + if(obj) + objstr=obj->getName(); + if(field) + fieldstr=field->getName(); + addUAVObjectToWidgetRelation(objstr, fieldstr, widget, element, scale, isLimited, defaultReloadGroups, instID); +} +void ConfigTaskWidget::addUAVObjectToWidgetRelation(UAVObject * obj,UAVObjectField * field, QWidget * widget, int index,double scale,bool isLimited,QList* defaultReloadGroups, quint32 instID) +{ + QString objstr; + QString fieldstr; + if(obj) + objstr=obj->getName(); + if(field) + fieldstr=field->getName(); + addUAVObjectToWidgetRelation(objstr,fieldstr,widget,index,scale,isLimited,defaultReloadGroups,instID); +} + /** * Add an UAVObject field to widget relation to the management system * @param object name of the object to add diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h index f4f0b6b9c..3433a85c1 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/configtaskwidget.h @@ -94,11 +94,18 @@ public: static double listMean(QList list); void addUAVObject(QString objectName, QList *reloadGroups=NULL); + void addUAVObject(UAVObject * objectName, QList *reloadGroups=NULL); + void addWidget(QWidget * widget); void addUAVObjectToWidgetRelation(QString object,QString field,QWidget * widget,int index=0,double scale=1,bool isLimited=false,QList* defaultReloadGroups=0,quint32 instID=0); + void addUAVObjectToWidgetRelation(UAVObject *obj, UAVObjectField * field, QWidget *widget, int index=0, double scale=1, bool isLimited=false, QList *defaultReloadGroups=0, quint32 instID=0); + void addUAVObjectToWidgetRelation(QString object,QString field,QWidget * widget,QString element,double scale,bool isLimited=false,QList* defaultReloadGroups=0,quint32 instID=0); + void addUAVObjectToWidgetRelation(UAVObject *obj, UAVObjectField * field,QWidget * widget,QString element,double scale,bool isLimited=false,QList* defaultReloadGroups=0,quint32 instID=0); + void addUAVObjectToWidgetRelation(QString object, QString field, QWidget *widget, QString index); + void addUAVObjectToWidgetRelation(UAVObject *obj, UAVObjectField * field, QWidget *widget, QString index); //BUTTONS// void addApplySaveButtons(QPushButton * update,QPushButton * save); From ffd52200712b086b738133a12e51daa6a8051622 Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Tue, 21 Aug 2012 22:09:53 +0300 Subject: [PATCH 14/16] CameraStab UI: some reformatting and comments --- .../config/configcamerastabilizationwidget.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp index 9c4470a1d..55c170fd2 100644 --- a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp @@ -151,11 +151,13 @@ void ConfigCameraStabilizationWidget::refreshWidgetsValues(UAVObject *obj) */ void ConfigCameraStabilizationWidget::updateObjectsFromWidgets() { - // Save state of the module enable checkbox first - HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager()); - quint8 value = m_camerastabilization->enableCameraStabilization->isChecked() ? + // Save state of the module enable checkbox first. + // Do not use setData() member on whole object, if possible, since it triggers + // unnessesary UAVObect update. + quint8 enableModule = m_camerastabilization->enableCameraStabilization->isChecked() ? HwSettings::OPTIONALMODULES_ENABLED : HwSettings::OPTIONALMODULES_DISABLED; - hwSettings->setOptionalModules(HwSettings::OPTIONALMODULES_CAMERASTAB,value); + HwSettings *hwSettings = HwSettings::GetInstance(getObjectManager()); + hwSettings->setOptionalModules(HwSettings::OPTIONALMODULES_CAMERASTAB, enableModule); // Update mixer channels which were mapped to camera outputs in case they are // not used for other function yet @@ -218,6 +220,8 @@ void ConfigCameraStabilizationWidget::updateObjectsFromWidgets() } } while(widgetUpdated); + // FIXME: Should not use setData() to prevent double updates. + // It should be refactored after the reformatting of MixerSettings UAVObject. mixerSettings->setData(mixerSettingsData); ConfigTaskWidget::updateObjectsFromWidgets(); From b946d8162aae442be2047fb1505d9d7603e92de9 Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Thu, 23 Aug 2012 13:39:37 +0300 Subject: [PATCH 15/16] CameraStab UI: add comment about reference implementation --- .../plugins/config/configcamerastabilizationwidget.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp index 55c170fd2..ae5712f5e 100644 --- a/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configcamerastabilizationwidget.cpp @@ -24,6 +24,15 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +/* + * IMPORTANT: This module is meant to be a reference implementation which + * demostrates the use of ConfigTaskWidget API for widgets which are not directly + * related to UAVObjects. It contains a lot of comments including some commented + * out code samples. Please DO NOT COPY/PASTE them into any other module based + * on this. + */ + #include "configcamerastabilizationwidget.h" #include "camerastabsettings.h" #include "hwsettings.h" From d4794d139fa3f92ca226db51446abba22bee6600 Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Sat, 25 Aug 2012 23:46:40 -0400 Subject: [PATCH 16/16] gcs: fix pipx-related typos in GCS This also fixes the auto-selecting of FW images for pipx in the uploader GUI by making the board name match fw_pipxtreme. --- ground/openpilotgcs/src/plugins/config/pipxtreme.ui | 2 +- .../src/plugins/uavobjectutil/devicedescriptorstruct.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/pipxtreme.ui b/ground/openpilotgcs/src/plugins/config/pipxtreme.ui index 9de1a7120..89616441b 100644 --- a/ground/openpilotgcs/src/plugins/config/pipxtreme.ui +++ b/ground/openpilotgcs/src/plugins/config/pipxtreme.ui @@ -1612,7 +1612,7 @@ - AES Encription + AES Encryption diff --git a/ground/openpilotgcs/src/plugins/uavobjectutil/devicedescriptorstruct.h b/ground/openpilotgcs/src/plugins/uavobjectutil/devicedescriptorstruct.h index a725c0bfe..b83a76a15 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectutil/devicedescriptorstruct.h +++ b/ground/openpilotgcs/src/plugins/uavobjectutil/devicedescriptorstruct.h @@ -20,7 +20,7 @@ public: return QString("OpenPilot INS"); break; case 0x0301://PipX - return QString("PipXtreame"); + return QString("PipXtreme"); break; case 0x0401://Coptercontrol return QString("CopterControl");