1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

OP-907 vehicle config - removed uncessary setupUI calls.

+ fixed regression in multirotor config widget : svg display was not updated when switching frame type
+ formatting
This commit is contained in:
Philippe Renon 2013-04-22 21:23:47 +02:00
parent b03ebbaf3a
commit 5f39206ebd
6 changed files with 34 additions and 34 deletions

View File

@ -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

View File

@ -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)));
}

View File

@ -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<UAVDataObject *>(getObjectManager()->getObject(QString("MixerSettings")));

View File

@ -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<QComboBox*> 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<UAVDataObject*>(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<QComboBox*> 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;

View File

@ -35,9 +35,9 @@
#include "uavobject.h"
#include "uavtalk/telemetrymanager.h"
#include <QtCore/QList>
#include <QtGui/QWidget>
#include <QList>
#include <QItemDelegate>
#include <QtGui/QItemDelegate>
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);

View File

@ -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<QComboBox *> l = findChildren<QComboBox*>(QRegExp("\\S+ChannelBo\\S+"));
QList<QComboBox *> l = findChildren<QComboBox *>(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);
}