From 90b0c5ca219c7c1ebcb9149d0b10e6894510ab44 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Wed, 3 Apr 2013 01:42:42 +0200 Subject: [PATCH] OP-907 step 3: cleaned up vehicleconfig.h + related cleanups --- .../cfg_vehicletypes/configccpmwidget.cpp | 596 +++++++++--------- .../cfg_vehicletypes/configccpmwidget.h | 40 +- .../cfg_vehicletypes/configcustomwidget.cpp | 5 + .../cfg_vehicletypes/configcustomwidget.h | 26 +- .../configfixedwingwidget.cpp | 8 +- .../cfg_vehicletypes/configfixedwingwidget.h | 15 +- .../configgroundvehiclewidget.cpp | 10 +- .../configgroundvehiclewidget.h | 14 +- .../configmultirotorwidget.cpp | 4 +- .../cfg_vehicletypes/configmultirotorwidget.h | 28 +- .../config/cfg_vehicletypes/vehicleconfig.cpp | 13 +- .../config/cfg_vehicletypes/vehicleconfig.h | 16 +- 12 files changed, 381 insertions(+), 394 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp index 7b322f10e..02cb3894a 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp @@ -42,6 +42,71 @@ #define Pi 3.14159265358979323846 +QStringList ConfigCcpmWidget::getChannelDescriptions() +{ + int i; + QStringList channelDesc; + + // init a channel_numelem list of channel desc defaults + for (i=0; i < (int)(ConfigCcpmWidget::CHANNEL_NUMELEM); i++) + { + channelDesc.append(QString("-")); + } + + // get the gui config data + GUIConfigDataUnion configData = GetConfigData(); + heliGUISettingsStruct heli = configData.heli; + + if (heli.Throttle > 0) + channelDesc[heli.Throttle - 1] = QString("Throttle"); + if (heli.Tail > 0) + channelDesc[heli.Tail - 1] = QString("Tail"); + + switch(heli.FirstServoIndex) + { + case 0: //front + if (heli.ServoIndexW > 0) + channelDesc[heli.ServoIndexW - 1] = QString("Elevator"); + if (heli.ServoIndexX > 0) + channelDesc[heli.ServoIndexX - 1] = QString("Roll1"); + if (heli.ServoIndexY > 0) + channelDesc[heli.ServoIndexY - 1] = QString("Roll2"); + break; + + case 1: //right + if (heli.ServoIndexW > 0) + channelDesc[heli.ServoIndexW - 1] = QString("ServoW"); + if (heli.ServoIndexX > 0) + channelDesc[heli.ServoIndexX - 1] = QString("ServoX"); + if (heli.ServoIndexY > 0) + channelDesc[heli.ServoIndexY - 1] = QString("ServoY"); + break; + + case 2: //rear + if (heli.ServoIndexW > 0) + channelDesc[heli.ServoIndexW - 1] = QString("Elevator"); + if (heli.ServoIndexX > 0) + channelDesc[heli.ServoIndexX - 1] = QString("Roll1"); + if (heli.ServoIndexY > 0) + channelDesc[heli.ServoIndexY - 1] = QString("Roll2"); + break; + + case 3: //left + if (heli.ServoIndexW > 0) + channelDesc[heli.ServoIndexW - 1] = QString("ServoW"); + if (heli.ServoIndexX > 0) + channelDesc[heli.ServoIndexX - 1] = QString("ServoX"); + if (heli.ServoIndexY > 0) + channelDesc[heli.ServoIndexY - 1] = QString("ServoY"); + break; + + } + if (heli.ServoIndexZ > 0) + channelDesc[heli.ServoIndexZ - 1] = QString("ServoZ"); + + return channelDesc; +} + ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : VehicleConfig(parent), m_aircraft(new Ui_CcpmConfigWidget()) { @@ -210,7 +275,7 @@ void ConfigCcpmWidget::setupUI(QString frameType) Q_UNUSED(frameType); } -void ConfigCcpmWidget::ResetActuators(GUIConfigDataUnion* configData) +void ConfigCcpmWidget::resetActuators(GUIConfigDataUnion *configData) { configData->heli.Throttle = 0; configData->heli.Tail = 0; @@ -220,197 +285,96 @@ void ConfigCcpmWidget::ResetActuators(GUIConfigDataUnion* configData) configData->heli.ServoIndexZ = 0; } -QStringList ConfigCcpmWidget::getChannelDescriptions() -{ - int i; - QStringList channelDesc; - - // init a channel_numelem list of channel desc defaults - for (i=0; i < (int)(ConfigCcpmWidget::CHANNEL_NUMELEM); i++) - { - channelDesc.append(QString("-")); - } - - // get the gui config data - GUIConfigDataUnion configData = GetConfigData(); - heliGUISettingsStruct heli = configData.heli; - - if (heli.Throttle > 0) - channelDesc[heli.Throttle - 1] = QString("Throttle"); - if (heli.Tail > 0) - channelDesc[heli.Tail - 1] = QString("Tail"); - - switch(heli.FirstServoIndex) - { - case 0: //front - if (heli.ServoIndexW > 0) - channelDesc[heli.ServoIndexW - 1] = QString("Elevator"); - if (heli.ServoIndexX > 0) - channelDesc[heli.ServoIndexX - 1] = QString("Roll1"); - if (heli.ServoIndexY > 0) - channelDesc[heli.ServoIndexY - 1] = QString("Roll2"); - break; - - case 1: //right - if (heli.ServoIndexW > 0) - channelDesc[heli.ServoIndexW - 1] = QString("ServoW"); - if (heli.ServoIndexX > 0) - channelDesc[heli.ServoIndexX - 1] = QString("ServoX"); - if (heli.ServoIndexY > 0) - channelDesc[heli.ServoIndexY - 1] = QString("ServoY"); - break; - - case 2: //rear - if (heli.ServoIndexW > 0) - channelDesc[heli.ServoIndexW - 1] = QString("Elevator"); - if (heli.ServoIndexX > 0) - channelDesc[heli.ServoIndexX - 1] = QString("Roll1"); - if (heli.ServoIndexY > 0) - channelDesc[heli.ServoIndexY - 1] = QString("Roll2"); - break; - - case 3: //left - if (heli.ServoIndexW > 0) - channelDesc[heli.ServoIndexW - 1] = QString("ServoW"); - if (heli.ServoIndexX > 0) - channelDesc[heli.ServoIndexX - 1] = QString("ServoX"); - if (heli.ServoIndexY > 0) - channelDesc[heli.ServoIndexY - 1] = QString("ServoY"); - break; - - } - if (heli.ServoIndexZ > 0) - channelDesc[heli.ServoIndexZ - 1] = QString("ServoZ"); - - return channelDesc; -} - void ConfigCcpmWidget::UpdateType() { - int TypeInt,SingleServoIndex,NumServosDefined; - double AdjustmentAngle=0; + int TypeInt, SingleServoIndex, NumServosDefined; + double AdjustmentAngle = 0; SetUIComponentVisibilities(); - - TypeInt = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex()-1; + + TypeInt = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex() - 1; TypeText = m_aircraft->ccpmType->currentText(); SingleServoIndex = m_aircraft->ccpmSingleServo->currentIndex(); //set visibility of user settings - m_aircraft->ccpmAdvancedSettingsTable->setEnabled(TypeInt==0); - m_aircraft->ccpmAdvancedSettingsTable->clearFocus();; + m_aircraft->ccpmAdvancedSettingsTable->setEnabled(TypeInt == 0); + m_aircraft->ccpmAdvancedSettingsTable->clearFocus(); - m_aircraft->ccpmAngleW->setEnabled(TypeInt==1); - m_aircraft->ccpmAngleX->setEnabled(TypeInt==1); - m_aircraft->ccpmAngleY->setEnabled(TypeInt==1); - m_aircraft->ccpmAngleZ->setEnabled(TypeInt==1); - m_aircraft->ccpmCorrectionAngle->setEnabled(TypeInt!=0); + m_aircraft->ccpmAngleW->setEnabled(TypeInt == 1); + m_aircraft->ccpmAngleX->setEnabled(TypeInt == 1); + m_aircraft->ccpmAngleY->setEnabled(TypeInt == 1); + m_aircraft->ccpmAngleZ->setEnabled(TypeInt == 1); + m_aircraft->ccpmCorrectionAngle->setEnabled(TypeInt != 0); - m_aircraft->ccpmServoWChannel->setEnabled(TypeInt>0); - m_aircraft->ccpmServoXChannel->setEnabled(TypeInt>0); - m_aircraft->ccpmServoYChannel->setEnabled(TypeInt>0); - m_aircraft->ccpmServoZChannel->setEnabled(TypeInt>0); - m_aircraft->ccpmSingleServo->setEnabled(TypeInt>1); + m_aircraft->ccpmServoWChannel->setEnabled(TypeInt > 0); + m_aircraft->ccpmServoXChannel->setEnabled(TypeInt > 0); + m_aircraft->ccpmServoYChannel->setEnabled(TypeInt > 0); + m_aircraft->ccpmServoZChannel->setEnabled(TypeInt > 0); + m_aircraft->ccpmSingleServo->setEnabled(TypeInt > 1); - m_aircraft->ccpmEngineChannel->setEnabled(TypeInt>0); - m_aircraft->ccpmTailChannel->setEnabled(TypeInt>0); - m_aircraft->ccpmCollectiveSlider->setEnabled(TypeInt>0); - m_aircraft->ccpmCollectivespinBox->setEnabled(TypeInt>0); - m_aircraft->ccpmRevoSlider->setEnabled(TypeInt>0); - m_aircraft->ccpmREVOspinBox->setEnabled(TypeInt>0); + m_aircraft->ccpmEngineChannel->setEnabled(TypeInt > 0); + m_aircraft->ccpmTailChannel->setEnabled(TypeInt > 0); + m_aircraft->ccpmCollectiveSlider->setEnabled(TypeInt > 0); + m_aircraft->ccpmCollectivespinBox->setEnabled(TypeInt > 0); + m_aircraft->ccpmRevoSlider->setEnabled(TypeInt > 0); + m_aircraft->ccpmREVOspinBox->setEnabled(TypeInt > 0); - AdjustmentAngle=SingleServoIndex*90; + AdjustmentAngle = SingleServoIndex * 90; m_aircraft->PitchCurve->setVisible(1); - NumServosDefined=4; + NumServosDefined = 4; //set values for pre defined heli types - if (TypeText.compare(QString::fromUtf8("CCPM 2 Servo 90º"), Qt::CaseInsensitive)==0) - { - m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); - m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360)); - m_aircraft->ccpmAngleY->setValue(0); - m_aircraft->ccpmAngleZ->setValue(0); - m_aircraft->ccpmAngleY->setEnabled(0); - m_aircraft->ccpmAngleZ->setEnabled(0); - m_aircraft->ccpmServoYChannel->setCurrentIndex(0); - m_aircraft->ccpmServoZChannel->setCurrentIndex(0); - m_aircraft->ccpmServoYChannel->setEnabled(0); - m_aircraft->ccpmServoZChannel->setEnabled(0); - NumServosDefined=2; - - } - else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 90º"), Qt::CaseInsensitive)==0) - { - m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); - m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360)); - m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180,360)); - m_aircraft->ccpmAngleZ->setValue(0); - m_aircraft->ccpmAngleZ->setEnabled(0); - m_aircraft->ccpmServoZChannel->setCurrentIndex(0); - m_aircraft->ccpmServoZChannel->setEnabled(0); - NumServosDefined=3; - - } - else if (TypeText.compare(QString::fromUtf8("CCPM 4 Servo 90º"), Qt::CaseInsensitive)==0) - { - m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); - m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360)); - m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180,360)); - m_aircraft->ccpmAngleZ->setValue(fmod(AdjustmentAngle + 270,360)); - m_aircraft->ccpmSingleServo->setEnabled(0); - m_aircraft->ccpmSingleServo->setCurrentIndex(0); - NumServosDefined=4; - - } - else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 120º"), Qt::CaseInsensitive)==0) - { - m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); - m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 120,360)); - m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 240,360)); - m_aircraft->ccpmAngleZ->setValue(0); - m_aircraft->ccpmAngleZ->setEnabled(0); - m_aircraft->ccpmServoZChannel->setCurrentIndex(0); - m_aircraft->ccpmServoZChannel->setEnabled(0); - NumServosDefined=3; - - } - else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 140º"), Qt::CaseInsensitive)==0) - { - m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); - m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 140,360)); - m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 220,360)); - m_aircraft->ccpmAngleZ->setValue(0); - m_aircraft->ccpmAngleZ->setEnabled(0); - m_aircraft->ccpmServoZChannel->setCurrentIndex(0); - m_aircraft->ccpmServoZChannel->setEnabled(0); - NumServosDefined=3; - - } - else if (TypeText.compare(QString::fromUtf8("FP 2 Servo 90º"), Qt::CaseInsensitive)==0) - { - m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); - m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360)); - m_aircraft->ccpmAngleY->setValue(0); - m_aircraft->ccpmAngleZ->setValue(0); - m_aircraft->ccpmAngleY->setEnabled(0); - m_aircraft->ccpmAngleZ->setEnabled(0); - m_aircraft->ccpmServoYChannel->setCurrentIndex(0); - m_aircraft->ccpmServoZChannel->setCurrentIndex(0); - m_aircraft->ccpmServoYChannel->setEnabled(0); - m_aircraft->ccpmServoZChannel->setEnabled(0); - - m_aircraft->ccpmCollectivespinBox->setEnabled(0); - m_aircraft->ccpmCollectiveSlider->setEnabled(0); - m_aircraft->ccpmCollectivespinBox->setValue(0); - m_aircraft->ccpmCollectiveSlider->setValue(0); - m_aircraft->PitchCurve->setVisible(0); - NumServosDefined=2; - } - else if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive)==0) - { + if (TypeText.compare(QString::fromUtf8("CCPM 2 Servo 90º"), Qt::CaseInsensitive) == 0) { m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); - m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360)); + m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360)); + m_aircraft->ccpmAngleY->setValue(0); + m_aircraft->ccpmAngleZ->setValue(0); + m_aircraft->ccpmAngleY->setEnabled(0); + m_aircraft->ccpmAngleZ->setEnabled(0); + m_aircraft->ccpmServoYChannel->setCurrentIndex(0); + m_aircraft->ccpmServoZChannel->setCurrentIndex(0); + m_aircraft->ccpmServoYChannel->setEnabled(0); + m_aircraft->ccpmServoZChannel->setEnabled(0); + NumServosDefined = 2; + } else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 90º"), Qt::CaseInsensitive) == 0) { + m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); + m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360)); + m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180, 360)); + m_aircraft->ccpmAngleZ->setValue(0); + m_aircraft->ccpmAngleZ->setEnabled(0); + m_aircraft->ccpmServoZChannel->setCurrentIndex(0); + m_aircraft->ccpmServoZChannel->setEnabled(0); + NumServosDefined = 3; + } else if (TypeText.compare(QString::fromUtf8("CCPM 4 Servo 90º"), Qt::CaseInsensitive) == 0) { + m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); + m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360)); + m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180, 360)); + m_aircraft->ccpmAngleZ->setValue(fmod(AdjustmentAngle + 270, 360)); + m_aircraft->ccpmSingleServo->setEnabled(0); + m_aircraft->ccpmSingleServo->setCurrentIndex(0); + NumServosDefined = 4; + } else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 120º"), Qt::CaseInsensitive) == 0) { + m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); + m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 120, 360)); + m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 240, 360)); + m_aircraft->ccpmAngleZ->setValue(0); + m_aircraft->ccpmAngleZ->setEnabled(0); + m_aircraft->ccpmServoZChannel->setCurrentIndex(0); + m_aircraft->ccpmServoZChannel->setEnabled(0); + NumServosDefined = 3; + } else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 140º"), Qt::CaseInsensitive) == 0) { + m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); + m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 140, 360)); + m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 220, 360)); + m_aircraft->ccpmAngleZ->setValue(0); + m_aircraft->ccpmAngleZ->setEnabled(0); + m_aircraft->ccpmServoZChannel->setCurrentIndex(0); + m_aircraft->ccpmServoZChannel->setEnabled(0); + NumServosDefined = 3; + } else if (TypeText.compare(QString::fromUtf8("FP 2 Servo 90º"), Qt::CaseInsensitive) == 0) { + m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); + m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360)); m_aircraft->ccpmAngleY->setValue(0); m_aircraft->ccpmAngleZ->setValue(0); m_aircraft->ccpmAngleY->setEnabled(0); @@ -425,55 +389,66 @@ void ConfigCcpmWidget::UpdateType() m_aircraft->ccpmCollectivespinBox->setValue(0); m_aircraft->ccpmCollectiveSlider->setValue(0); m_aircraft->PitchCurve->setVisible(0); - NumServosDefined=2; + NumServosDefined = 2; + } else if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive) == 0) { + m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); + m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360)); + m_aircraft->ccpmAngleY->setValue(0); + m_aircraft->ccpmAngleZ->setValue(0); + m_aircraft->ccpmAngleY->setEnabled(0); + m_aircraft->ccpmAngleZ->setEnabled(0); + m_aircraft->ccpmServoYChannel->setCurrentIndex(0); + m_aircraft->ccpmServoZChannel->setCurrentIndex(0); + m_aircraft->ccpmServoYChannel->setEnabled(0); + m_aircraft->ccpmServoZChannel->setEnabled(0); + m_aircraft->ccpmCollectivespinBox->setEnabled(0); + m_aircraft->ccpmCollectiveSlider->setEnabled(0); + m_aircraft->ccpmCollectivespinBox->setValue(0); + m_aircraft->ccpmCollectiveSlider->setValue(0); + m_aircraft->PitchCurve->setVisible(0); + NumServosDefined = 2; } //Set the text of the motor boxes - if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive)==0) - { + if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive) == 0) { m_aircraft->ccpmEngineLabel->setText("CW motor"); m_aircraft->ccpmTailLabel->setText("CCW motor"); - } - else{ + } else { m_aircraft->ccpmEngineLabel->setText("Engine"); m_aircraft->ccpmTailLabel->setText("Tail rotor"); } //set the visibility of the swashplate servo selection boxes - m_aircraft->ccpmServoWLabel->setVisible(NumServosDefined>=1); - m_aircraft->ccpmServoXLabel->setVisible(NumServosDefined>=2); - m_aircraft->ccpmServoYLabel->setVisible(NumServosDefined>=3); - m_aircraft->ccpmServoZLabel->setVisible(NumServosDefined>=4); - m_aircraft->ccpmServoWChannel->setVisible(NumServosDefined>=1); - m_aircraft->ccpmServoXChannel->setVisible(NumServosDefined>=2); - m_aircraft->ccpmServoYChannel->setVisible(NumServosDefined>=3); - m_aircraft->ccpmServoZChannel->setVisible(NumServosDefined>=4); - - //set the visibility of the swashplate angle selection boxes - m_aircraft->ccpmServoWLabel_2->setVisible(NumServosDefined>=1); - m_aircraft->ccpmServoXLabel_2->setVisible(NumServosDefined>=2); - m_aircraft->ccpmServoYLabel_2->setVisible(NumServosDefined>=3); - m_aircraft->ccpmServoZLabel_2->setVisible(NumServosDefined>=4); - m_aircraft->ccpmAngleW->setVisible(NumServosDefined>=1); - m_aircraft->ccpmAngleX->setVisible(NumServosDefined>=2); - m_aircraft->ccpmAngleY->setVisible(NumServosDefined>=3); - m_aircraft->ccpmAngleZ->setVisible(NumServosDefined>=4); - + m_aircraft->ccpmServoWLabel->setVisible(NumServosDefined >= 1); + m_aircraft->ccpmServoXLabel->setVisible(NumServosDefined >= 2); + m_aircraft->ccpmServoYLabel->setVisible(NumServosDefined >= 3); + m_aircraft->ccpmServoZLabel->setVisible(NumServosDefined >= 4); + m_aircraft->ccpmServoWChannel->setVisible(NumServosDefined >= 1); + m_aircraft->ccpmServoXChannel->setVisible(NumServosDefined >= 2); + m_aircraft->ccpmServoYChannel->setVisible(NumServosDefined >= 3); + m_aircraft->ccpmServoZChannel->setVisible(NumServosDefined >= 4); - m_aircraft->ccpmAdvancedSettingsTable->resizeColumnsToContents(); - for (int i=0;i<6;i++) { - m_aircraft->ccpmAdvancedSettingsTable->setColumnWidth(i,(m_aircraft->ccpmAdvancedSettingsTable->width()- - m_aircraft->ccpmAdvancedSettingsTable->verticalHeader()->width())/6); + //set the visibility of the swashplate angle selection boxes + m_aircraft->ccpmServoWLabel_2->setVisible(NumServosDefined >= 1); + m_aircraft->ccpmServoXLabel_2->setVisible(NumServosDefined >= 2); + m_aircraft->ccpmServoYLabel_2->setVisible(NumServosDefined >= 3); + m_aircraft->ccpmServoZLabel_2->setVisible(NumServosDefined >= 4); + m_aircraft->ccpmAngleW->setVisible(NumServosDefined >= 1); + m_aircraft->ccpmAngleX->setVisible(NumServosDefined >= 2); + m_aircraft->ccpmAngleY->setVisible(NumServosDefined >= 3); + m_aircraft->ccpmAngleZ->setVisible(NumServosDefined >= 4); + + QTableWidget *table = m_aircraft->ccpmAdvancedSettingsTable; + table->resizeColumnsToContents(); + for (int i = 0; i < 6; i++) { + table->setColumnWidth(i, (table->width() - table->verticalHeader()->width()) / 6); } //update UI ccpmSwashplateUpdate(); - } - - void ConfigCcpmWidget::ccpmSwashplateRedraw() { double angle[CCPM_MAX_SWASH_SERVOS],CorrectionAngle,x,y,w,h,radius,CenterX,CenterY; @@ -586,8 +561,9 @@ void ConfigCcpmWidget::UpdateMixer() { bool useCCPM; bool useCyclic; - int i,j,ThisEnable[6]; - float CollectiveConstant,PitchConstant,RollConstant,ThisAngle[6]; + int ThisEnable[6]; + float CollectiveConstant, PitchConstant, RollConstant; + float ThisAngle[6]; QString Channel; if (throwConfigError(QString("HeliCP"))) @@ -598,29 +574,24 @@ void ConfigCcpmWidget::UpdateMixer() useCCPM = !(config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState); useCyclic = config.heli.ccpmLinkRollState; - CollectiveConstant = (float)config.heli.SliderValue0 / 100.00; + CollectiveConstant = (float) config.heli.SliderValue0 / 100.00; - if (useCCPM) - {//cyclic = 1 - collective - PitchConstant = 1-CollectiveConstant; + if (useCCPM) { //cyclic = 1 - collective + PitchConstant = 1 - CollectiveConstant; RollConstant = PitchConstant; - } - else - { - PitchConstant = (float)config.heli.SliderValue1 / 100.00;; - if (useCyclic) - { + } else { + PitchConstant = (float) config.heli.SliderValue1 / 100.00; + ; + if (useCyclic) { RollConstant = PitchConstant; - } - else - { - RollConstant = (float)config.heli.SliderValue2 / 100.00;; - } + } else { + RollConstant = (float) config.heli.SliderValue2 / 100.00; + ; + } } - if (config.heli.SwashplateType>0) - {//not advanced settings - //get the channel data from the ui + if (config.heli.SwashplateType > 0) { //not advanced settings + //get the channel data from the ui MixerChannelData[0] = m_aircraft->ccpmEngineChannel->currentIndex(); MixerChannelData[1] = m_aircraft->ccpmTailChannel->currentIndex(); MixerChannelData[2] = m_aircraft->ccpmServoWChannel->currentIndex(); @@ -640,78 +611,92 @@ void ConfigCcpmWidget::UpdateMixer() ThisEnable[4] = m_aircraft->ccpmServoYChannel->isEnabled(); ThisEnable[5] = m_aircraft->ccpmServoZChannel->isEnabled(); - ServosText[0]->setPlainText(QString("%1").arg( MixerChannelData[2] )); - ServosText[1]->setPlainText(QString("%1").arg( MixerChannelData[3] )); - ServosText[2]->setPlainText(QString("%1").arg( MixerChannelData[4] )); - ServosText[3]->setPlainText(QString("%1").arg( MixerChannelData[5] )); - + ServosText[0]->setPlainText(QString("%1").arg(MixerChannelData[2])); + ServosText[1]->setPlainText(QString("%1").arg(MixerChannelData[3])); + ServosText[2]->setPlainText(QString("%1").arg(MixerChannelData[4])); + ServosText[3]->setPlainText(QString("%1").arg(MixerChannelData[5])); //go through the user data and update the mixer matrix - for (i=0;i<6;i++) - { - if ((MixerChannelData[i]>0) && ((ThisEnable[i])||(i<2))) - { - m_aircraft->ccpmAdvancedSettingsTable->item(i,0)->setText(QString("%1").arg( MixerChannelData[i] )); + QTableWidget *table = m_aircraft->ccpmAdvancedSettingsTable; + for (int i = 0; i < 6; i++) { + if ((MixerChannelData[i] > 0) && ((ThisEnable[i]) || (i < 2))) { + table->item(i, 0)->setText(QString("%1").arg(MixerChannelData[i])); //Generate the mixer vector - if (i==0) - {//main motor-engine - m_aircraft->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(127));//ThrottleCurve1 - m_aircraft->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg(0));//ThrottleCurve2 - m_aircraft->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg(0));//Roll - m_aircraft->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg(0));//Pitch + if (i == 0) { //main motor-engine + table->item(i, 1)->setText(QString("%1").arg(127)); //ThrottleCurve1 + table->item(i, 2)->setText(QString("%1").arg(0)); //ThrottleCurve2 + table->item(i, 3)->setText(QString("%1").arg(0)); //Roll + table->item(i, 4)->setText(QString("%1").arg(0)); //Pitch - if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive)==0) - m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(-127));//Yaw - else - m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(0));//Yaw - - } - if (i==1) - {//tailrotor --or-- counter-clockwise motor - if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive)==0) - { - m_aircraft->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(127));//ThrottleCurve1 - m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(127));//Yaw - } - else{ - m_aircraft->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(0));//ThrottleCurve1 - m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(127));//Yaw + if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive) == 0) { + // Yaw + table->item(i, 5)->setText(QString("%1").arg(-127)); + } else { + // Yaw + table->item(i, 5)->setText(QString("%1").arg(0)); } - m_aircraft->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg(0));//ThrottleCurve2 - m_aircraft->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg(0));//Roll - m_aircraft->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg(0));//Pitch + } + if (i == 1) { + // tailrotor --or-- counter-clockwise motor + if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive) == 0) { + // ThrottleCurve1 + table->item(i, 1)->setText(QString("%1").arg(127)); + // Yaw + table->item(i, 5)->setText(QString("%1").arg(127)); + } else { + // ThrottleCurve1 + table->item(i, 1)->setText(QString("%1").arg(0)); + // Yaw + table->item(i, 5)->setText(QString("%1").arg(127)); + } + //ThrottleCurve2 + table->item(i, 2)->setText(QString("%1").arg(0)); + // Roll + table->item(i, 3)->setText(QString("%1").arg(0)); + // Pitch + table->item(i, 4)->setText(QString("%1").arg(0)); } - if (i>1) - {//Swashplate - m_aircraft->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(0));//ThrottleCurve1 - m_aircraft->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg((int)(127.0*CollectiveConstant)));//ThrottleCurve2 - m_aircraft->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg((int)(127.0*(RollConstant)*sin((180+config.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Roll - m_aircraft->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg((int)(127.0*(PitchConstant)*cos((config.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Pitch - m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(0));//Yaw + if (i > 1) { + // Swashplate + //ThrottleCurve1 + table->item(i, 1)->setText(QString("%1").arg(0)); + //ThrottleCurve2 + table->item(i, 2)->setText(QString("%1").arg((int) (127.0 * CollectiveConstant))); + table->item(i, 3)->setText( + QString("%1").arg( + (int) (127.0 * (RollConstant) + * sin((180 + config.heli.CorrectionAngle + ThisAngle[i]) * Pi / 180.00)))); //Roll + table->item(i, 4)->setText( + QString("%1").arg( + (int) (127.0 * (PitchConstant) + * cos((config.heli.CorrectionAngle + ThisAngle[i]) * Pi / 180.00)))); //Pitch + // Yaw + table->item(i, 5)->setText(QString("%1").arg(0)); } - } - else - { - for (j=0;j<6;j++) m_aircraft->ccpmAdvancedSettingsTable->item(i,j)->setText(QString("-")); + } else { + for (int j = 0; j < 6; j++) { + table->item(i, j)->setText(QString("-")); + } } } + } else { + // advanced settings + QTableWidget *table = m_aircraft->ccpmAdvancedSettingsTable; + for (int i = 0; i < 6; i++) { + Channel = table->item(i, 0)->text(); + if (Channel == "-") { + Channel = QString("9"); + } + MixerChannelData[i] = Channel.toInt(); + } } - else - {//advanced settings - for (i=0;i<6;i++) - { - Channel =m_aircraft->ccpmAdvancedSettingsTable->item(i,0)->text(); - if (Channel == "-") Channel = QString("9"); - MixerChannelData[i]= Channel.toInt(); - } - } - } + QString ConfigCcpmWidget::updateConfigObjects() { QString airframeType = "HeliCP"; @@ -719,7 +704,8 @@ QString ConfigCcpmWidget::updateConfigObjects() bool useCCPM; bool useCyclic; - if (updatingFromHardware == TRUE) return airframeType; + if (updatingFromHardware == TRUE) + return airframeType; updatingFromHardware = TRUE; @@ -727,7 +713,7 @@ QString ConfigCcpmWidget::updateConfigObjects() GUIConfigDataUnion config = GetConfigData(); //swashplate config - config.heli.SwashplateType = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex()-1; + config.heli.SwashplateType = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex() - 1; config.heli.FirstServoIndex = m_aircraft->ccpmSingleServo->currentIndex(); //ccpm mixing options @@ -741,20 +727,14 @@ QString ConfigCcpmWidget::updateConfigObjects() config.heli.CorrectionAngle = m_aircraft->ccpmCorrectionAngle->value(); //update sliders - if (useCCPM) - { + if (useCCPM) { config.heli.SliderValue0 = m_aircraft->ccpmCollectiveSlider->value(); - } - else - { + } else { config.heli.SliderValue0 = m_aircraft->ccpmCollectiveScale->value(); } - if (useCyclic) - { + if (useCyclic) { config.heli.SliderValue1 = m_aircraft->ccpmCyclicScale->value(); - } - else - { + } else { config.heli.SliderValue1 = m_aircraft->ccpmPitchScale->value(); } config.heli.SliderValue2 = m_aircraft->ccpmRollScale->value(); @@ -776,7 +756,7 @@ QString ConfigCcpmWidget::updateConfigObjects() return airframeType; } -QString ConfigCcpmWidget::updateConfigObjectsFromWidgets() //UpdateCCPMOptionsFromUI() +QString ConfigCcpmWidget::updateConfigObjectsFromWidgets() { QString airframeType = updateConfigObjects(); @@ -785,7 +765,7 @@ QString ConfigCcpmWidget::updateConfigObjectsFromWidgets() //UpdateCCPMOptionsFr return airframeType; } -void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) //UpdateCCPMUIFromOptions() +void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) { Q_UNUSED(frameType); @@ -829,35 +809,34 @@ void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) //UpdateCCPMUIFro getMixer(); } - void ConfigCcpmWidget::SetUIComponentVisibilities() { m_aircraft->ccpmRevoMixingBox->setVisible(0); - - m_aircraft->ccpmPitchMixingBox->setVisible(!m_aircraft->ccpmCollectivePassthrough->isChecked() && - m_aircraft->ccpmLinkCyclic->isChecked()); - m_aircraft->ccpmCollectiveScalingBox->setVisible(m_aircraft->ccpmCollectivePassthrough->isChecked() || !m_aircraft->ccpmLinkCyclic->isChecked()); + m_aircraft->ccpmPitchMixingBox->setVisible( + !m_aircraft->ccpmCollectivePassthrough->isChecked() && m_aircraft->ccpmLinkCyclic->isChecked()); + + m_aircraft->ccpmCollectiveScalingBox->setVisible( + m_aircraft->ccpmCollectivePassthrough->isChecked() || !m_aircraft->ccpmLinkCyclic->isChecked()); m_aircraft->ccpmLinkCyclic->setVisible(!m_aircraft->ccpmCollectivePassthrough->isChecked()); - m_aircraft->ccpmCyclicScalingBox->setVisible((m_aircraft->ccpmCollectivePassthrough->isChecked() || !m_aircraft->ccpmLinkCyclic->isChecked()) && - m_aircraft->ccpmLinkRoll->isChecked()); + m_aircraft->ccpmCyclicScalingBox->setVisible( + (m_aircraft->ccpmCollectivePassthrough->isChecked() || !m_aircraft->ccpmLinkCyclic->isChecked()) + && m_aircraft->ccpmLinkRoll->isChecked()); - if (!m_aircraft->ccpmCollectivePassthrough->checkState() && m_aircraft->ccpmLinkCyclic->isChecked()) - { + if (!m_aircraft->ccpmCollectivePassthrough->checkState() && m_aircraft->ccpmLinkCyclic->isChecked()) { m_aircraft->ccpmPitchScalingBox->setVisible(0); m_aircraft->ccpmRollScalingBox->setVisible(0); m_aircraft->ccpmLinkRoll->setVisible(0); - } - else - { + } else { m_aircraft->ccpmPitchScalingBox->setVisible(!m_aircraft->ccpmLinkRoll->isChecked()); m_aircraft->ccpmRollScalingBox->setVisible(!m_aircraft->ccpmLinkRoll->isChecked()); m_aircraft->ccpmLinkRoll->setVisible(1); } } + /** Request the current value of the SystemSettings which holds the ccpm type */ @@ -899,7 +878,6 @@ void ConfigCcpmWidget::getMixer() ccpmSwashplateUpdate(); } - /** Sends the config to the board (ccpm type) */ diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h index 2890cffdb..c11146071 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h @@ -57,13 +57,28 @@ class ConfigCcpmWidget: public VehicleConfig Q_OBJECT public: + + static QStringList getChannelDescriptions(); + ConfigCcpmWidget(QWidget *parent = 0); ~ConfigCcpmWidget(); - friend class ConfigVehicleTypeWidget; + virtual void setupUI(QString airframeType); + virtual void refreshWidgetsValues(QString frameType); + virtual QString updateConfigObjectsFromWidgets(); + +public slots: + void getMixer(); + void setMixer(); + void saveccpmUpdate(); + +protected: + void showEvent(QShowEvent *event); + void resizeEvent(QResizeEvent *event); private: - //Ui_ccpmWidget *m_ccpm; + virtual void resetActuators(GUIConfigDataUnion *configData); + Ui_CcpmConfigWidget *m_aircraft; QGraphicsSvgItem *SwashplateImg; @@ -86,20 +101,16 @@ private: int MixerChannelData[6]; int ShowDisclaimer(int messageID); - virtual void enableControls(bool enable) { Q_UNUSED(enable)}; // Not used by this widget + virtual void enableControls(bool enable) { Q_UNUSED(enable) }; // Not used by this widget bool updatingFromHardware; bool updatingToHardware; - virtual void ResetActuators(GUIConfigDataUnion *configData); - static QStringList getChannelDescriptions(); - + // TODO ? QString updateConfigObjects(); private slots: - virtual void setupUI(QString airframeType); - virtual void refreshWidgetsValues(QString frameType); - virtual QString updateConfigObjectsFromWidgets(); + // TODO ? virtual bool throwConfigError(QString airframeType); void ccpmSwashplateUpdate(); @@ -120,17 +131,8 @@ private slots: void enableSwashplateLevellingControl(bool state); void setSwashplateLevel(int percent); void SwashLvlSpinBoxChanged(int value); + // TODO ? virtual void refreshValues() {}; // Not used - -public slots: - void getMixer(); - void setMixer(); - void saveccpmUpdate(); - -protected: - void showEvent(QShowEvent *event); - void resizeEvent(QResizeEvent *event); - }; #endif // CONFIGccpmWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp index 07c453c93..6181589cc 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp @@ -94,6 +94,11 @@ QStringList ConfigCustomWidget::getChannelDescriptions() return channelDesc; } +void ConfigCustomWidget::resetActuators(GUIConfigDataUnion *configData) +{ + +} + /** Helper function to update the UI widget objects */ diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h index 08fcd549a..4b0409421 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h @@ -46,30 +46,30 @@ class ConfigCustomWidget: public VehicleConfig Q_OBJECT public: + + static QStringList getChannelDescriptions(); + ConfigCustomWidget(QWidget *parent = 0); ~ConfigCustomWidget(); - friend class ConfigVehicleTypeWidget; - -private: - Ui_CustomConfigWidget *m_aircraft; - - //virtual void ResetActuators(GUIConfigDataUnion *configData); - static QStringList getChannelDescriptions(); -// static const QString CHANNELBOXNAME; - -private slots: virtual void setupUI(QString airframeType); virtual void refreshWidgetsValues(QString frameType); virtual QString updateConfigObjectsFromWidgets(); - virtual bool throwConfigError(int numMotors); protected: void showEvent(QShowEvent *event); void resizeEvent(QResizeEvent *event); -signals: - void configurationChanged(); +private: + virtual void resetActuators(GUIConfigDataUnion *configData); + + Ui_CustomConfigWidget *m_aircraft; + +private slots: + virtual bool throwConfigError(int numMotors); + +//signals: +// void configurationChanged(); }; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 8c3ae1167..c464b56ec 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -130,7 +130,7 @@ void ConfigFixedWingWidget::setupUI(QString frameType) } } -void ConfigFixedWingWidget::ResetActuators(GUIConfigDataUnion* configData) +void ConfigFixedWingWidget::resetActuators(GUIConfigDataUnion *configData) { configData->fixedwing.FixedWingPitch1 = 0; configData->fixedwing.FixedWingPitch2 = 0; @@ -297,7 +297,7 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType) // Now setup the channels: GUIConfigDataUnion config = GetConfigData(); - ResetActuators(&config); + resetActuators(&config); config.fixedwing.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex(); config.fixedwing.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex(); @@ -369,7 +369,7 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType) } GUIConfigDataUnion config = GetConfigData(); - ResetActuators(&config); + resetActuators(&config); config.fixedwing.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex(); config.fixedwing.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex(); @@ -441,7 +441,7 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType) } GUIConfigDataUnion config = GetConfigData(); - ResetActuators(&config); + resetActuators(&config); config.fixedwing.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex(); config.fixedwing.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex(); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h index 21dff9658..f7007302c 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h @@ -46,25 +46,26 @@ class ConfigFixedWingWidget: public VehicleConfig Q_OBJECT public: + + static QStringList getChannelDescriptions(); + ConfigFixedWingWidget(QWidget *parent = 0); ~ConfigFixedWingWidget(); - friend class ConfigVehicleTypeWidget; + virtual void setupUI(QString airframeType); + virtual void refreshWidgetsValues(QString frameType); + virtual QString updateConfigObjectsFromWidgets(); private: + virtual void resetActuators(GUIConfigDataUnion *configData); + Ui_FixedWingConfigWidget *m_aircraft; bool setupFrameFixedWing(QString airframeType); bool setupFrameElevon(QString airframeType); bool setupFrameVtail(QString airframeType); - virtual void ResetActuators(GUIConfigDataUnion* configData); - static QStringList getChannelDescriptions(); - private slots: - virtual void setupUI(QString airframeType); - virtual void refreshWidgetsValues(QString frameType); - virtual QString updateConfigObjectsFromWidgets(); virtual bool throwConfigError(QString airframeType); protected: diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp index b2e419f42..2b04a3c63 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp @@ -161,7 +161,7 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType) } } -void ConfigGroundVehicleWidget::ResetActuators(GUIConfigDataUnion* configData) +void ConfigGroundVehicleWidget::resetActuators(GUIConfigDataUnion *configData) { configData->ground.GroundVehicleSteering1 = 0; configData->ground.GroundVehicleSteering2 = 0; @@ -330,7 +330,7 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeTyp // Now setup the channels: GUIConfigDataUnion config = GetConfigData(); - ResetActuators(&config); + resetActuators(&config); config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex(); config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); @@ -379,14 +379,14 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeT // Now setup the channels: GUIConfigDataUnion config = GetConfigData(); - ResetActuators(&config); + resetActuators(&config); config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex(); config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); SetConfigData((config)); - UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); resetMotorAndServoMixers(mixer); @@ -423,7 +423,7 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType) // Now setup the channels: GUIConfigDataUnion config = GetConfigData(); - ResetActuators(&config); + resetActuators(&config); config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex(); config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h index 97b35c8e4..2b38d58ea 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h @@ -46,25 +46,25 @@ class ConfigGroundVehicleWidget: public VehicleConfig Q_OBJECT public: + static QStringList getChannelDescriptions(); + ConfigGroundVehicleWidget(QWidget *parent = 0); ~ConfigGroundVehicleWidget(); - friend class ConfigVehicleTypeWidget; + virtual void setupUI(QString airframeType); + virtual void refreshWidgetsValues(QString frameType); + virtual QString updateConfigObjectsFromWidgets(); private: + virtual void resetActuators(GUIConfigDataUnion *configData); + Ui_GroundConfigWidget *m_aircraft; bool setupGroundVehicleCar(QString airframeType); bool setupGroundVehicleDifferential(QString airframeType); bool setupGroundVehicleMotorcycle(QString airframeType); - virtual void ResetActuators(GUIConfigDataUnion* configData); - static QStringList getChannelDescriptions(); - private slots: - virtual void setupUI(QString airframeType); - virtual void refreshWidgetsValues(QString frameType); - virtual QString updateConfigObjectsFromWidgets(); virtual bool throwConfigError(QString airframeType); protected: diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp index f93aceba8..4e4180dcf 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp @@ -296,7 +296,7 @@ void ConfigMultiRotorWidget::drawAirframe(QString frameType) m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio); } -void ConfigMultiRotorWidget::ResetActuators(GUIConfigDataUnion* configData) +void ConfigMultiRotorWidget::resetActuators(GUIConfigDataUnion *configData) { configData->multi.VTOLMotorN = 0; configData->multi.VTOLMotorNE = 0; @@ -893,7 +893,7 @@ void ConfigMultiRotorWidget::setupMotors(QList motorList) << m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8; GUIConfigDataUnion configData = GetConfigData(); - ResetActuators(&configData); + resetActuators(&configData); int index; foreach (QString motor, motorList) { diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h index 210133a48..12b9d102b 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h @@ -46,12 +46,24 @@ class ConfigMultiRotorWidget: public VehicleConfig Q_OBJECT public: + + static QStringList getChannelDescriptions(); + static const QString CHANNELBOXNAME; + ConfigMultiRotorWidget(QWidget *parent = 0); ~ConfigMultiRotorWidget(); - friend class ConfigVehicleTypeWidget; + virtual void setupUI(QString airframeType); + virtual void refreshWidgetsValues(QString frameType); + virtual QString updateConfigObjectsFromWidgets(); + +protected: + void showEvent(QShowEvent *event); + void resizeEvent(QResizeEvent *event); private: + virtual void resetActuators(GUIConfigDataUnion *configData); + Ui_MultiRotorConfigWidget *m_aircraft; QWidget *uiowner; @@ -66,28 +78,14 @@ private: float invertMotors; - virtual void ResetActuators(GUIConfigDataUnion *configData); - static QStringList getChannelDescriptions(); - static const QString CHANNELBOXNAME; void setYawMixLevel(int); void drawAirframe(QString multiRotorType); private slots: - virtual void setupUI(QString airframeType); - virtual void refreshWidgetsValues(QString frameType); - virtual QString updateConfigObjectsFromWidgets(); virtual bool throwConfigError(int numMotors); void reverseMultirotorMotor(); - -protected: - void showEvent(QShowEvent *event); - void resizeEvent(QResizeEvent *event); - -signals: - void configurationChanged(); - }; #endif // CONFIGMULTIROTORWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp index caba82a7f..d9e5cbf00 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp @@ -35,7 +35,7 @@ VehicleConfig::VehicleConfig(QWidget *parent) : ConfigTaskWidget(parent) { - //Generate lists of mixerTypeNames, mixerVectorNames, channelNames + // Generate lists of mixerTypeNames, mixerVectorNames, channelNames channelNames << "None"; for (int i = 0; i < (int)(VehicleConfig::CHANNEL_NUMELEM); i++) { mixerTypes << QString("Mixer%1Type").arg(i+1); @@ -50,7 +50,7 @@ VehicleConfig::VehicleConfig(QWidget *parent) : ConfigTaskWidget(parent) // This is needed because new style tries to compact things as much as possible in grid // and on OSX the widget sizes of PushButtons is reported incorrectly: // https://bugreports.qt-project.org/browse/QTBUG-14591 - foreach( QPushButton * btn, findChildren() ) { + foreach(QPushButton *btn, findChildren()) { btn->setAttribute(Qt::WA_LayoutUsesWidgetRect); } } @@ -107,7 +107,6 @@ void VehicleConfig::SetConfigData(GUIConfigDataUnion configData) { void VehicleConfig::setupUI(QString frameType) { - } QString VehicleConfig::updateConfigObjectsFromWidgets() @@ -119,7 +118,7 @@ void VehicleConfig::refreshWidgetsValues(QString frameType) { } -void VehicleConfig::ResetActuators(GUIConfigDataUnion *configData) +void VehicleConfig::resetActuators(GUIConfigDataUnion *configData) { } @@ -277,7 +276,7 @@ void VehicleConfig::setThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveEle break; } - if (field && field->getNumElements() == curve.length()) { + if (field && (field->getNumElements() == (unsigned int) curve.length())) { for (int i = 0; i < curve.length(); i++) { field->setValue(curve.at(i), i); } @@ -338,6 +337,7 @@ double VehicleConfig::getCurveMax(QList *curve) } return max; } + /** Reset the contents of a field */ @@ -348,12 +348,11 @@ void VehicleConfig::resetField(UAVObjectField * field) } } - /** * Util function to get a pointer to the object manager * @return pointer to the UAVObjectManager */ -UAVObjectManager* VehicleConfig::getUAVObjectManager() { +UAVObjectManager *VehicleConfig::getUAVObjectManager() { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager * objMngr = pm->getObject(); Q_ASSERT(objMngr); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h index 1be3037e0..1569c2db3 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h @@ -107,8 +107,6 @@ class VehicleConfig: public ConfigTaskWidget Q_OBJECT public: - VehicleConfig(QWidget *parent = 0); - ~VehicleConfig(); /* Enumeration options for ThrottleCurves */ typedef enum { @@ -140,6 +138,8 @@ public: MIXERVECTOR_YAW = 4 } MixerVectorElem; + static const quint32 CHANNEL_NUMELEM = ActuatorCommand::CHANNEL_NUMELEM;; + // TODO remove 1st capital static GUIConfigDataUnion GetConfigData(); static void SetConfigData(GUIConfigDataUnion configData); @@ -148,12 +148,15 @@ public: static void setComboCurrentIndex(QComboBox *box, int index); static void enableComboBoxes(QWidget *owner, QString boxName, int boxCount, bool enable); + // VehicleConfig class + VehicleConfig(QWidget *parent = 0); + ~VehicleConfig(); + virtual void setupUI(QString airframeType); virtual QString updateConfigObjectsFromWidgets(); virtual void refreshWidgetsValues(QString frameType); - virtual void ResetActuators(GUIConfigDataUnion *configData); - + // TODO move to separate class double getMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName); void setMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName, double value); void resetMixerVector(UAVDataObject *mixer, int channel); @@ -168,16 +171,17 @@ public: double getCurveMin(QList *curve); double getCurveMax(QList *curve); +protected: QStringList channelNames; QStringList mixerTypes; QStringList mixerVectors; QStringList mixerTypeDescriptions; - static const quint32 CHANNEL_NUMELEM = ActuatorCommand::CHANNEL_NUMELEM;; - private: static UAVObjectManager *getUAVObjectManager(); + virtual void resetActuators(GUIConfigDataUnion *configData); + private slots: public slots: