From 5f39206ebd570c9c69f9df7411a4e6d42d56bd9a Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Mon, 22 Apr 2013 21:23:47 +0200 Subject: [PATCH] OP-907 vehicle config - removed uncessary setupUI calls. + fixed regression in multirotor config widget : svg display was not updated when switching frame type + formatting --- .../cfg_vehicletypes/configccpmwidget.cpp | 4 +- .../configfixedwingwidget.cpp | 2 +- .../configgroundvehiclewidget.cpp | 4 +- .../configmultirotorwidget.cpp | 44 +++++++++---------- .../cfg_vehicletypes/configmultirotorwidget.h | 8 ++-- .../config/cfg_vehicletypes/vehicleconfig.cpp | 6 ++- 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp index e11281754..9335df774 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp @@ -232,7 +232,7 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : m_aircraft->ccpmType->addItems(Types); m_aircraft->ccpmType->setCurrentIndex(m_aircraft->ccpmType->count() - 1); - refreshWidgetsValues(QString("HeliCP")); + //refreshWidgetsValues(QString("HeliCP")); UpdateType(); @@ -296,7 +296,7 @@ void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) GUIConfigDataUnion config = getConfigData(); // swashplate config - setComboCurrentIndex( m_aircraft->ccpmType, m_aircraft->ccpmType->count() - (config.heli.SwashplateType +1)); + setComboCurrentIndex(m_aircraft->ccpmType, m_aircraft->ccpmType->count() - (config.heli.SwashplateType + 1)); setComboCurrentIndex(m_aircraft->ccpmSingleServo, config.heli.FirstServoIndex); // ccpm mixing options diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 6d385c0a4..8f0365133 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -89,7 +89,7 @@ ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) : // Set default model to "Elevator aileron rudder" m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Elevator aileron rudder")); - setupUI(m_aircraft->fixedWingType->currentText()); + //setupUI(m_aircraft->fixedWingType->currentText()); connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString))); } diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp index 4b1e265b8..20c062a6e 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp @@ -81,7 +81,7 @@ ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(QWidget *parent) : // Set default model to "Turnable (car)" m_aircraft->groundVehicleType->setCurrentIndex(m_aircraft->groundVehicleType->findText("Turnable (car)")); - setupUI(m_aircraft->groundVehicleType->currentText()); + //setupUI(m_aircraft->groundVehicleType->currentText()); connect(m_aircraft->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString))); } @@ -199,8 +199,6 @@ void ConfigGroundVehicleWidget::resetActuators(GUIConfigDataUnion *configData) */ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType) { - qDebug() << "ConfigGroundVehicleWidget::refreshWidgetsValues - frame type:" << frameType; - setupUI(frameType); UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp index 2b412c977..52fd8aef6 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp @@ -86,7 +86,7 @@ QStringList ConfigMultiRotorWidget::getChannelDescriptions() } ConfigMultiRotorWidget::ConfigMultiRotorWidget(QWidget *parent) : - VehicleConfig(parent), m_aircraft(new Ui_MultiRotorConfigWidget()), invertMotors(1) + VehicleConfig(parent), m_aircraft(new Ui_MultiRotorConfigWidget()), invertMotors(false) { m_aircraft->setupUi(this); @@ -116,7 +116,7 @@ ConfigMultiRotorWidget::ConfigMultiRotorWidget(QWidget *parent) : // Set default model to "Quad X" m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Quad X")); - setupUI(m_aircraft->multirotorFrameType->currentText()); + //setupUI(m_aircraft->multirotorFrameType->currentText()); connect(m_aircraft->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString))); @@ -134,8 +134,6 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) Q_ASSERT(m_aircraft); Q_ASSERT(quad); - qDebug() << "ConfigMultiRotorWidget::setupUI - frame type" << frameType; - // disable triyaw channel m_aircraft->triYawChannelBox->setEnabled(false); @@ -246,8 +244,9 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) m_aircraft->mrPitchMixLevel->setValue(50); setYawMixLevel(50); } + // Draw the appropriate airframe - //drawAirframe(frameType); + updateAirframe(frameType); } void ConfigMultiRotorWidget::resetActuators(GUIConfigDataUnion *configData) @@ -503,7 +502,7 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) } } - drawAirframe(frameType); + updateAirframe(frameType); } /** @@ -720,12 +719,12 @@ void ConfigMultiRotorWidget::setYawMixLevel(int value) void ConfigMultiRotorWidget::reverseMultirotorMotor(){ QString frameType = m_aircraft->multirotorFrameType->currentText(); - drawAirframe(frameType); + updateAirframe(frameType); } -void ConfigMultiRotorWidget::drawAirframe(QString frameType) +void ConfigMultiRotorWidget::updateAirframe(QString frameType) { - qDebug() << "ConfigMultiRotorWidget::drawAirframe - frame type" << frameType; + qDebug() << "ConfigMultiRotorWidget::updateAirframe - frame type" << frameType; QString elementId; if (frameType == "Tri" || frameType == "Tricopter Y") { @@ -750,8 +749,8 @@ void ConfigMultiRotorWidget::drawAirframe(QString frameType) elementId = "octo-coax-X"; } - invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked() ? -1 : 1; - if (invertMotors <= 0) { + invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked(); + if (invertMotors) { elementId += "_reverse"; } @@ -953,27 +952,28 @@ bool ConfigMultiRotorWidget::setupHexa(bool pLayout) */ bool ConfigMultiRotorWidget::setupMultiRotorMixer(double mixerFactors[8][3]) { - QList mmList; - mmList << m_aircraft->multiMotorChannelBox1 << m_aircraft->multiMotorChannelBox2 - << m_aircraft->multiMotorChannelBox3 << m_aircraft->multiMotorChannelBox4 - << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6 - << m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8; - UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); resetMotorAndServoMixers(mixer); // and enable only the relevant channels: - double pFactor = (double) m_aircraft->mrPitchMixLevel->value() / 100; - double rFactor = (double) m_aircraft->mrRollMixLevel->value() / 100; - invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked() ? -1 : 1; - double yFactor = invertMotors * (double) m_aircraft->mrYawMixLevel->value() / 100; + double pFactor = (double) m_aircraft->mrPitchMixLevel->value() / 100.0; + double rFactor = (double) m_aircraft->mrRollMixLevel->value() / 100.0; + invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked(); + double yFactor = (invertMotors ? -1.0 : 1.0) * (double) m_aircraft->mrYawMixLevel->value() / 100.0; + + QList mmList; + mmList << m_aircraft->multiMotorChannelBox1 << m_aircraft->multiMotorChannelBox2 + << m_aircraft->multiMotorChannelBox3 << m_aircraft->multiMotorChannelBox4 + << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6 + << m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8; for (int i = 0; i < 8; i++) { if (mmList.at(i)->isEnabled()) { int channel = mmList.at(i)->currentIndex() - 1; - if (channel > -1) + if (channel > -1) { setupQuadMotor(channel, mixerFactors[i][0] * pFactor, rFactor * mixerFactors[i][1], yFactor * mixerFactors[i][2]); + } } } return true; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h index 2b2844fad..4726cee79 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h @@ -35,9 +35,9 @@ #include "uavobject.h" #include "uavtalk/telemetrymanager.h" +#include #include -#include -#include +#include class Ui_Widget; @@ -62,7 +62,7 @@ protected: private: Ui_MultiRotorConfigWidget *m_aircraft; QGraphicsSvgItem *quad; - float invertMotors; + bool invertMotors; virtual void resetActuators(GUIConfigDataUnion *configData); @@ -75,7 +75,7 @@ private: void setYawMixLevel(int); - void drawAirframe(QString multiRotorType); + void updateAirframe(QString multiRotorType); private slots: virtual void setupUI(QString airframeType); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp index d488744ed..725314591 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp @@ -102,6 +102,7 @@ void VehicleConfig::setConfigData(GUIConfigDataUnion configData) void VehicleConfig::setupUI(QString frameType) { + Q_UNUSED(frameType); } QString VehicleConfig::updateConfigObjectsFromWidgets() @@ -111,10 +112,12 @@ QString VehicleConfig::updateConfigObjectsFromWidgets() void VehicleConfig::refreshWidgetsValues(QString frameType) { + Q_UNUSED(frameType); } void VehicleConfig::resetActuators(GUIConfigDataUnion *configData) { + Q_UNUSED(configData); } // NEW STYLE: Loop through the widgets looking for all widgets that have "ChannelBox" in their name @@ -122,7 +125,7 @@ void VehicleConfig::resetActuators(GUIConfigDataUnion *configData) // FOR WHATEVER REASON, THIS DOES NOT WORK WITH ChannelBox. ChannelBo is sufficiently accurate void VehicleConfig::populateChannelComboBoxes() { - QList l = findChildren(QRegExp("\\S+ChannelBo\\S+")); + QList l = findChildren(QRegExp("\\S+ChannelBo\\S+")); foreach(QComboBox *combobox, l) { combobox->addItems(channelNames); } @@ -136,7 +139,6 @@ void VehicleConfig::populateChannelComboBoxes() void VehicleConfig::setComboCurrentIndex(QComboBox *box, int index) { Q_ASSERT(box); - if (index >= 0 && index < box->count()) { box->setCurrentIndex(index); }