mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-26 15:54:15 +01:00
LP-467 update custom mixers when saving vehicle config
This commit is contained in:
parent
97f1b53539
commit
f646ef1d37
@ -62,9 +62,6 @@ public:
|
|||||||
ConfigCcpmWidget(QWidget *parent = 0);
|
ConfigCcpmWidget(QWidget *parent = 0);
|
||||||
~ConfigCcpmWidget();
|
~ConfigCcpmWidget();
|
||||||
|
|
||||||
virtual void refreshWidgetsValues(QString frameType);
|
|
||||||
virtual QString updateConfigObjectsFromWidgets();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void getMixer();
|
void getMixer();
|
||||||
void setMixer();
|
void setMixer();
|
||||||
@ -74,6 +71,8 @@ protected:
|
|||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
|
|
||||||
virtual void enableControls(bool enable);
|
virtual void enableControls(bool enable);
|
||||||
|
virtual void refreshWidgetsValues(QString frameType);
|
||||||
|
virtual QString updateConfigObjectsFromWidgets();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui_CcpmConfigWidget *m_aircraft;
|
Ui_CcpmConfigWidget *m_aircraft;
|
||||||
|
@ -49,13 +49,13 @@ public:
|
|||||||
ConfigCustomWidget(QWidget *parent = 0);
|
ConfigCustomWidget(QWidget *parent = 0);
|
||||||
~ConfigCustomWidget();
|
~ConfigCustomWidget();
|
||||||
|
|
||||||
virtual void refreshWidgetsValues(QString frameType);
|
|
||||||
virtual QString updateConfigObjectsFromWidgets();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void showEvent(QShowEvent *event);
|
void showEvent(QShowEvent *event);
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
|
|
||||||
|
virtual void refreshWidgetsValues(QString frameType);
|
||||||
|
virtual QString updateConfigObjectsFromWidgets();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui_CustomConfigWidget *m_aircraft;
|
Ui_CustomConfigWidget *m_aircraft;
|
||||||
|
|
||||||
|
@ -50,9 +50,6 @@ public:
|
|||||||
ConfigFixedWingWidget(QWidget *parent = 0);
|
ConfigFixedWingWidget(QWidget *parent = 0);
|
||||||
~ConfigFixedWingWidget();
|
~ConfigFixedWingWidget();
|
||||||
|
|
||||||
virtual void refreshWidgetsValues(QString frameType);
|
|
||||||
virtual QString updateConfigObjectsFromWidgets();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui_FixedWingConfigWidget *m_aircraft;
|
Ui_FixedWingConfigWidget *m_aircraft;
|
||||||
QGraphicsSvgItem *planeimg;
|
QGraphicsSvgItem *planeimg;
|
||||||
@ -72,6 +69,8 @@ protected:
|
|||||||
void showEvent(QShowEvent *);
|
void showEvent(QShowEvent *);
|
||||||
|
|
||||||
virtual void enableControls(bool enable);
|
virtual void enableControls(bool enable);
|
||||||
|
virtual void refreshWidgetsValues(QString frameType);
|
||||||
|
virtual QString updateConfigObjectsFromWidgets();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
virtual void setupUI(QString airframeType);
|
virtual void setupUI(QString airframeType);
|
||||||
|
@ -49,15 +49,15 @@ public:
|
|||||||
ConfigGroundVehicleWidget(QWidget *parent = 0);
|
ConfigGroundVehicleWidget(QWidget *parent = 0);
|
||||||
~ConfigGroundVehicleWidget();
|
~ConfigGroundVehicleWidget();
|
||||||
|
|
||||||
virtual void refreshWidgetsValues(QString frameType);
|
|
||||||
virtual void initMixerCurves(QString frameType);
|
virtual void initMixerCurves(QString frameType);
|
||||||
virtual QString updateConfigObjectsFromWidgets();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void resizeEvent(QResizeEvent *);
|
void resizeEvent(QResizeEvent *);
|
||||||
void showEvent(QShowEvent *);
|
void showEvent(QShowEvent *);
|
||||||
|
|
||||||
virtual void enableControls(bool enable);
|
virtual void enableControls(bool enable);
|
||||||
|
virtual void refreshWidgetsValues(QString frameType);
|
||||||
|
virtual QString updateConfigObjectsFromWidgets();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui_GroundConfigWidget *m_aircraft;
|
Ui_GroundConfigWidget *m_aircraft;
|
||||||
|
@ -51,21 +51,21 @@ public:
|
|||||||
ConfigMultiRotorWidget(QWidget *parent = 0);
|
ConfigMultiRotorWidget(QWidget *parent = 0);
|
||||||
~ConfigMultiRotorWidget();
|
~ConfigMultiRotorWidget();
|
||||||
|
|
||||||
virtual void refreshWidgetsValues(QString frameType);
|
|
||||||
virtual QString updateConfigObjectsFromWidgets();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void showEvent(QShowEvent *event);
|
void showEvent(QShowEvent *event);
|
||||||
void resizeEvent(QResizeEvent *event);
|
void resizeEvent(QResizeEvent *event);
|
||||||
|
|
||||||
virtual void enableControls(bool enable);
|
virtual void enableControls(bool enable);
|
||||||
|
virtual void refreshWidgetsValues(QString frameType);
|
||||||
|
virtual QString updateConfigObjectsFromWidgets();
|
||||||
|
|
||||||
|
virtual void registerWidgets(ConfigTaskWidget &parent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui_MultiRotorConfigWidget *m_aircraft;
|
Ui_MultiRotorConfigWidget *m_aircraft;
|
||||||
QGraphicsSvgItem *quad;
|
QGraphicsSvgItem *quad;
|
||||||
bool invertMotors;
|
bool invertMotors;
|
||||||
|
|
||||||
virtual void registerWidgets(ConfigTaskWidget &parent);
|
|
||||||
virtual void resetActuators(GUIConfigDataUnion *configData);
|
virtual void resetActuators(GUIConfigDataUnion *configData);
|
||||||
virtual void resetRcOutputs(GUIConfigDataUnion *configData);
|
virtual void resetRcOutputs(GUIConfigDataUnion *configData);
|
||||||
|
|
||||||
|
@ -222,12 +222,6 @@ public:
|
|||||||
VehicleConfig(QWidget *parent = 0);
|
VehicleConfig(QWidget *parent = 0);
|
||||||
~VehicleConfig();
|
~VehicleConfig();
|
||||||
|
|
||||||
virtual void registerWidgets(ConfigTaskWidget &parent);
|
|
||||||
|
|
||||||
virtual void refreshWidgetsValues(QString frameType);
|
|
||||||
|
|
||||||
virtual QString updateConfigObjectsFromWidgets();
|
|
||||||
|
|
||||||
double getMixerValue(UAVDataObject *mixer, QString elementName);
|
double getMixerValue(UAVDataObject *mixer, QString elementName);
|
||||||
void setMixerValue(UAVDataObject *mixer, QString elementName, double value);
|
void setMixerValue(UAVDataObject *mixer, QString elementName, double value);
|
||||||
|
|
||||||
@ -256,6 +250,10 @@ protected:
|
|||||||
virtual void refreshWidgetsValuesImpl(UAVObject *obj);
|
virtual void refreshWidgetsValuesImpl(UAVObject *obj);
|
||||||
virtual void updateObjectsFromWidgetsImpl();
|
virtual void updateObjectsFromWidgetsImpl();
|
||||||
|
|
||||||
|
virtual void registerWidgets(ConfigTaskWidget &parent);
|
||||||
|
virtual void refreshWidgetsValues(QString frameType);
|
||||||
|
virtual QString updateConfigObjectsFromWidgets();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static UAVObjectManager *getUAVObjectManager();
|
static UAVObjectManager *getUAVObjectManager();
|
||||||
|
|
||||||
|
@ -161,6 +161,7 @@ ConfigVehicleTypeWidget::~ConfigVehicleTypeWidget()
|
|||||||
void ConfigVehicleTypeWidget::switchAirframeType(int index)
|
void ConfigVehicleTypeWidget::switchAirframeType(int index)
|
||||||
{
|
{
|
||||||
VehicleConfig *vehicleConfig = getVehicleConfigWidget(index);
|
VehicleConfig *vehicleConfig = getVehicleConfigWidget(index);
|
||||||
|
|
||||||
if (vehicleConfig) {
|
if (vehicleConfig) {
|
||||||
m_aircraft->airframesWidget->setCurrentWidget(vehicleConfig);
|
m_aircraft->airframesWidget->setCurrentWidget(vehicleConfig);
|
||||||
// enable controls
|
// enable controls
|
||||||
@ -177,6 +178,7 @@ void ConfigVehicleTypeWidget::enableControls(bool enable)
|
|||||||
int category = frameCategory(frameType());
|
int category = frameCategory(frameType());
|
||||||
|
|
||||||
VehicleConfig *vehicleConfig = getVehicleConfigWidget(category);
|
VehicleConfig *vehicleConfig = getVehicleConfigWidget(category);
|
||||||
|
|
||||||
if (vehicleConfig) {
|
if (vehicleConfig) {
|
||||||
vehicleConfig->enableControls(enable);
|
vehicleConfig->enableControls(enable);
|
||||||
}
|
}
|
||||||
@ -195,50 +197,26 @@ void ConfigVehicleTypeWidget::refreshWidgetsValuesImpl(UAVObject *obj)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the Airframe type from the system settings:
|
// update current vehicle tab
|
||||||
UAVDataObject *system = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("SystemSettings")));
|
QString ft = frameType();
|
||||||
Q_ASSERT(system);
|
int category = frameCategory(ft);
|
||||||
|
|
||||||
UAVObjectField *field = system->getField(QString("AirframeType"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
|
|
||||||
// At this stage, we will need to have some hardcoded settings in this code
|
|
||||||
QString frameType = field->getValue().toString();
|
|
||||||
|
|
||||||
// Always update custom tab from others airframe settings : debug/learn hardcoded mixers
|
|
||||||
int category = frameCategory("Custom");
|
|
||||||
m_aircraft->aircraftType->setCurrentIndex(category);
|
m_aircraft->aircraftType->setCurrentIndex(category);
|
||||||
|
|
||||||
VehicleConfig *vehicleConfig = getVehicleConfigWidget(category);
|
VehicleConfig *vehicleConfig = getVehicleConfigWidget(category);
|
||||||
|
|
||||||
if (vehicleConfig) {
|
if (vehicleConfig) {
|
||||||
vehicleConfig->refreshWidgetsValues("Custom");
|
vehicleConfig->refreshWidgetsValues(ft);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch to Airframe currently used
|
// update custom tab from others frame settings (to debug/learn hard coded mixers)
|
||||||
category = frameCategory(frameType);
|
if (ft != "Custom") {
|
||||||
|
int customCategory = frameCategory("Custom");
|
||||||
if (frameType != "Custom") {
|
VehicleConfig *vehicleConfig = getVehicleConfigWidget(customCategory);
|
||||||
m_aircraft->aircraftType->setCurrentIndex(category);
|
|
||||||
|
|
||||||
VehicleConfig *vehicleConfig = getVehicleConfigWidget(category);
|
|
||||||
|
|
||||||
if (vehicleConfig) {
|
if (vehicleConfig) {
|
||||||
vehicleConfig->refreshWidgetsValues(frameType);
|
vehicleConfig->refreshWidgetsValues("Custom");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
field = system->getField(QString("VehicleName"));
|
// update vehicle name
|
||||||
Q_ASSERT(field);
|
QString name = vehicleName();
|
||||||
QString name;
|
|
||||||
for (uint i = 0; i < field->getNumElements(); ++i) {
|
|
||||||
QChar chr = field->getValue(i).toChar();
|
|
||||||
if (chr != 0) {
|
|
||||||
name.append(chr);
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_aircraft->nameEdit->setText(name);
|
m_aircraft->nameEdit->setText(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,26 +230,87 @@ void ConfigVehicleTypeWidget::refreshWidgetsValuesImpl(UAVObject *obj)
|
|||||||
void ConfigVehicleTypeWidget::updateObjectsFromWidgetsImpl()
|
void ConfigVehicleTypeWidget::updateObjectsFromWidgetsImpl()
|
||||||
{
|
{
|
||||||
// Airframe type defaults to Custom
|
// Airframe type defaults to Custom
|
||||||
QString airframeType = "Custom";
|
QString ft = "Custom";
|
||||||
|
|
||||||
VehicleConfig *vehicleConfig = (VehicleConfig *)m_aircraft->airframesWidget->currentWidget();
|
VehicleConfig *vehicleConfig = (VehicleConfig *)m_aircraft->airframesWidget->currentWidget();
|
||||||
|
|
||||||
if (vehicleConfig) {
|
if (vehicleConfig) {
|
||||||
airframeType = vehicleConfig->updateConfigObjectsFromWidgets();
|
ft = vehicleConfig->updateConfigObjectsFromWidgets();
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the airframe type
|
// airframe type
|
||||||
UAVDataObject *system = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject(QString("SystemSettings")));
|
setFrameType(ft);
|
||||||
|
|
||||||
|
// vehicle name
|
||||||
|
QString name = m_aircraft->nameEdit->text();
|
||||||
|
setVehicleName(name);
|
||||||
|
|
||||||
|
// update custom tab from others frame settings (to debug/learn hard coded mixers)
|
||||||
|
if (ft != "Custom") {
|
||||||
|
int customCategory = frameCategory("Custom");
|
||||||
|
VehicleConfig *vehicleConfig = getVehicleConfigWidget(customCategory);
|
||||||
|
if (vehicleConfig) {
|
||||||
|
vehicleConfig->refreshWidgetsValues("Custom");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ConfigVehicleTypeWidget::frameType()
|
||||||
|
{
|
||||||
|
UAVDataObject *system = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject("SystemSettings"));
|
||||||
|
|
||||||
Q_ASSERT(system);
|
Q_ASSERT(system);
|
||||||
|
|
||||||
UAVObjectField *field = system->getField(QString("AirframeType"));
|
UAVObjectField *field = system->getField("AirframeType");
|
||||||
if (field) {
|
|
||||||
field->setValue(airframeType);
|
|
||||||
}
|
|
||||||
|
|
||||||
field = system->getField(QString("VehicleName"));
|
|
||||||
Q_ASSERT(field);
|
Q_ASSERT(field);
|
||||||
QString name = m_aircraft->nameEdit->text();
|
|
||||||
|
return field->getValue().toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigVehicleTypeWidget::setFrameType(QString frameType)
|
||||||
|
{
|
||||||
|
UAVDataObject *system = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject("SystemSettings"));
|
||||||
|
|
||||||
|
Q_ASSERT(system);
|
||||||
|
|
||||||
|
UAVObjectField *field = system->getField("AirframeType");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
|
||||||
|
if (field) {
|
||||||
|
field->setValue(frameType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ConfigVehicleTypeWidget::vehicleName()
|
||||||
|
{
|
||||||
|
UAVDataObject *system = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject("SystemSettings"));
|
||||||
|
|
||||||
|
Q_ASSERT(system);
|
||||||
|
|
||||||
|
UAVObjectField *field = system->getField("VehicleName");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
|
||||||
|
QString name;
|
||||||
|
for (uint i = 0; i < field->getNumElements(); ++i) {
|
||||||
|
QChar chr = field->getValue(i).toChar();
|
||||||
|
if (chr != 0) {
|
||||||
|
name.append(chr);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigVehicleTypeWidget::setVehicleName(QString name)
|
||||||
|
{
|
||||||
|
UAVDataObject *system = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject("SystemSettings"));
|
||||||
|
|
||||||
|
Q_ASSERT(system);
|
||||||
|
|
||||||
|
UAVObjectField *field = system->getField("VehicleName");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
|
||||||
for (uint i = 0; i < field->getNumElements(); ++i) {
|
for (uint i = 0; i < field->getNumElements(); ++i) {
|
||||||
if (i < (uint)name.length()) {
|
if (i < (uint)name.length()) {
|
||||||
field->setValue(name.at(i).toLatin1(), i);
|
field->setValue(name.at(i).toLatin1(), i);
|
||||||
@ -279,22 +318,6 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgetsImpl()
|
|||||||
field->setValue(0, i);
|
field->setValue(0, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// call refreshWidgetsValues() to reflect actual saved values
|
|
||||||
// TODO is this needed ?
|
|
||||||
refreshWidgetsValues();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ConfigVehicleTypeWidget::frameType()
|
|
||||||
{
|
|
||||||
// Get the Airframe type from the system settings
|
|
||||||
UAVDataObject *system = dynamic_cast<UAVDataObject *>(getObjectManager()->getObject("SystemSettings"));
|
|
||||||
Q_ASSERT(system);
|
|
||||||
|
|
||||||
UAVObjectField *field = system->getField("AirframeType");
|
|
||||||
Q_ASSERT(field);
|
|
||||||
|
|
||||||
return field->getValue().toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ConfigVehicleTypeWidget::frameCategory(QString frameType)
|
int ConfigVehicleTypeWidget::frameCategory(QString frameType)
|
||||||
|
@ -75,6 +75,11 @@ private:
|
|||||||
|
|
||||||
|
|
||||||
QString frameType();
|
QString frameType();
|
||||||
|
void setFrameType(QString frameType);
|
||||||
|
|
||||||
|
QString vehicleName();
|
||||||
|
void setVehicleName(QString name);
|
||||||
|
|
||||||
static int frameCategory(QString frameType);
|
static int frameCategory(QString frameType);
|
||||||
|
|
||||||
VehicleConfig *getVehicleConfigWidget(int frameCategory);
|
VehicleConfig *getVehicleConfigWidget(int frameCategory);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user