1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

Resolves mixer/advanced tab switching issue;

semi-centralized channelNames;
renames ConfigCcpmWidget
This commit is contained in:
Mike LaBranche 2012-05-22 09:55:50 -07:00
parent 64688be0a1
commit 2db4f6b2b6
9 changed files with 134 additions and 139 deletions

View File

@ -1376,7 +1376,7 @@ margin:1px;</string>
<number>0</number> <number>0</number>
</property> </property>
<item> <item>
<widget class="ConfigccpmWidget" name="widget_3" native="true"/> <widget class="ConfigCcpmWidget" name="widget_3" native="true"/>
</item> </item>
</layout> </layout>
</item> </item>
@ -2801,12 +2801,12 @@ p, li { white-space: pre-wrap; }
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt; <string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt; &lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; } p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Ubuntu'; font-size:11pt; font-weight:400; font-style:normal;&quot;&gt; &lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;table border=&quot;0&quot; style=&quot;-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;&quot;&gt; &lt;table border=&quot;0&quot; style=&quot;-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;&quot;&gt;
&lt;tr&gt; &lt;tr&gt;
&lt;td style=&quot;border: none;&quot;&gt; &lt;td style=&quot;border: none;&quot;&gt;
&lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-size:14pt; font-weight:600; color:#ff0000;&quot;&gt;SETTING UP FEED FORWARD IS DANGEROUS&lt;/span&gt;&lt;/p&gt; &lt;p align=&quot;center&quot; style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:14pt; font-weight:600; color:#ff0000;&quot;&gt;SETTING UP FEED FORWARD IS DANGEROUS&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;/p&gt; &lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:11pt;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt;&quot;&gt;Beware: Feed Forward Tuning will launch all engines around mid-throttle, you have been warned!&lt;/span&gt;&lt;/p&gt; &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt;&quot;&gt;Beware: Feed Forward Tuning will launch all engines around mid-throttle, you have been warned!&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt;&quot;&gt;Remove your props initially, and for fine-tuning, make sure your airframe is safely held in place. Wear glasses and protect your face and body.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;</string> &lt;p style=&quot; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Lucida Grande'; font-size:13pt;&quot;&gt;Remove your props initially, and for fine-tuning, make sure your airframe is safely held in place. Wear glasses and protect your face and body.&lt;/span&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property> </property>
@ -2910,7 +2910,7 @@ p, li { white-space: pre-wrap; }
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget> <customwidget>
<class>ConfigccpmWidget</class> <class>ConfigCcpmWidget</class>
<extends>QWidget</extends> <extends>QWidget</extends>
<header>cfg_vehicletypes/configccpmwidget.h</header> <header>cfg_vehicletypes/configccpmwidget.h</header>
<container>1</container> <container>1</container>
@ -3016,22 +3016,6 @@ p, li { white-space: pre-wrap; }
</hint> </hint>
</hints> </hints>
</connection> </connection>
<connection>
<sender>mrPitchMixLevel</sender>
<signal>valueChanged(int)</signal>
<receiver>mrPitchMixValue</receiver>
<slot>setNum(int)</slot>
<hints>
<hint type="sourcelabel">
<x>83</x>
<y>228</y>
</hint>
<hint type="destinationlabel">
<x>82</x>
<y>168</y>
</hint>
</hints>
</connection>
<connection> <connection>
<sender>mrRollMixLevel</sender> <sender>mrRollMixLevel</sender>
<signal>valueChanged(int)</signal> <signal>valueChanged(int)</signal>

View File

@ -44,7 +44,7 @@
#define Pi 3.14159265358979323846 #define Pi 3.14159265358979323846
ConfigccpmWidget::ConfigccpmWidget(QWidget *parent) : VehicleConfig(parent) ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : VehicleConfig(parent)
{ {
int i; int i;
SwashLvlConfigurationInProgress=0; SwashLvlConfigurationInProgress=0;
@ -143,20 +143,20 @@ ConfigccpmWidget::ConfigccpmWidget(QWidget *parent) : VehicleConfig(parent)
UAVObjectField * curve2source = mixerSettings->getField("Curve2Source"); UAVObjectField * curve2source = mixerSettings->getField("Curve2Source");
Q_ASSERT(curve2source); Q_ASSERT(curve2source);
QStringList channels; // QStringList channels;
channels << "None" << "Channel1" << "Channel2" << "Channel3" << "Channel4" << // channels << "None" << "Channel1" << "Channel2" << "Channel3" << "Channel4" <<
"Channel5" << "Channel6" << "Channel7" << "Channel8"; // "Channel5" << "Channel6" << "Channel7" << "Channel8";
m_ccpm->ccpmEngineChannel->addItems(channels); m_ccpm->ccpmEngineChannel->addItems(channelNames);
m_ccpm->ccpmEngineChannel->setCurrentIndex(0); m_ccpm->ccpmEngineChannel->setCurrentIndex(0);
m_ccpm->ccpmTailChannel->addItems(channels); m_ccpm->ccpmTailChannel->addItems(channelNames);
m_ccpm->ccpmTailChannel->setCurrentIndex(0); m_ccpm->ccpmTailChannel->setCurrentIndex(0);
m_ccpm->ccpmServoWChannel->addItems(channels); m_ccpm->ccpmServoWChannel->addItems(channelNames);
m_ccpm->ccpmServoWChannel->setCurrentIndex(0); m_ccpm->ccpmServoWChannel->setCurrentIndex(0);
m_ccpm->ccpmServoXChannel->addItems(channels); m_ccpm->ccpmServoXChannel->addItems(channelNames);
m_ccpm->ccpmServoXChannel->setCurrentIndex(0); m_ccpm->ccpmServoXChannel->setCurrentIndex(0);
m_ccpm->ccpmServoYChannel->addItems(channels); m_ccpm->ccpmServoYChannel->addItems(channelNames);
m_ccpm->ccpmServoYChannel->setCurrentIndex(0); m_ccpm->ccpmServoYChannel->setCurrentIndex(0);
m_ccpm->ccpmServoZChannel->addItems(channels); m_ccpm->ccpmServoZChannel->addItems(channelNames);
m_ccpm->ccpmServoZChannel->setCurrentIndex(0); m_ccpm->ccpmServoZChannel->setCurrentIndex(0);
QStringList Types; QStringList Types;
@ -222,16 +222,16 @@ ConfigccpmWidget::ConfigccpmWidget(QWidget *parent) : VehicleConfig(parent)
ccpmSwashplateRedraw(); ccpmSwashplateRedraw();
} }
ConfigccpmWidget::~ConfigccpmWidget() ConfigCcpmWidget::~ConfigCcpmWidget()
{ {
// Do nothing // Do nothing
} }
void ConfigccpmWidget::setupUI(QString frameType) void ConfigCcpmWidget::setupUI(QString frameType)
{ {
} }
void ConfigccpmWidget::ResetActuators(GUIConfigDataUnion* configData) void ConfigCcpmWidget::ResetActuators(GUIConfigDataUnion* configData)
{ {
configData->heli.Throttle = 0; configData->heli.Throttle = 0;
configData->heli.Tail = 0; configData->heli.Tail = 0;
@ -241,13 +241,13 @@ void ConfigccpmWidget::ResetActuators(GUIConfigDataUnion* configData)
configData->heli.ServoIndexZ = 0; configData->heli.ServoIndexZ = 0;
} }
QStringList ConfigccpmWidget::getChannelDescriptions() QStringList ConfigCcpmWidget::getChannelDescriptions()
{ {
int i; int i;
QStringList channelDesc; QStringList channelDesc;
// init a channel_numelem list of channel desc defaults // init a channel_numelem list of channel desc defaults
for (i=0; i < (int)(ConfigccpmWidget::CHANNEL_NUMELEM); i++) for (i=0; i < (int)(ConfigCcpmWidget::CHANNEL_NUMELEM); i++)
{ {
channelDesc.append(QString("-")); channelDesc.append(QString("-"));
} }
@ -306,7 +306,7 @@ QStringList ConfigccpmWidget::getChannelDescriptions()
return channelDesc; return channelDesc;
} }
void ConfigccpmWidget::UpdateType() void ConfigCcpmWidget::UpdateType()
{ {
int TypeInt,SingleServoIndex,NumServosDefined; int TypeInt,SingleServoIndex,NumServosDefined;
QString TypeText; QString TypeText;
@ -483,12 +483,12 @@ void ConfigccpmWidget::UpdateType()
/** /**
Resets a mixer curve Resets a mixer curve
*/ */
void ConfigccpmWidget::resetMixer(MixerCurveWidget *mixer, int numElements) void ConfigCcpmWidget::resetMixer(MixerCurveWidget *mixer, int numElements)
{ {
mixer->initLinearCurve(numElements,(double)1); mixer->initLinearCurve(numElements,(double)1);
} }
void ConfigccpmWidget::UpdateCurveWidgets() void ConfigCcpmWidget::UpdateCurveWidgets()
{ {
int NumCurvePoints,i,Changed; int NumCurvePoints,i,Changed;
QList<double> curveValues; QList<double> curveValues;
@ -522,7 +522,7 @@ void ConfigccpmWidget::UpdateCurveWidgets()
if (Changed==1)m_ccpm->PitchCurve->setCurve(curveValues); if (Changed==1)m_ccpm->PitchCurve->setCurve(curveValues);
} }
void ConfigccpmWidget::updatePitchCurveValue(QList<double> curveValues0,double Value0) void ConfigCcpmWidget::updatePitchCurveValue(QList<double> curveValues0,double Value0)
{ {
Q_UNUSED(curveValues0); Q_UNUSED(curveValues0);
Q_UNUSED(Value0); Q_UNUSED(Value0);
@ -546,7 +546,7 @@ void ConfigccpmWidget::updatePitchCurveValue(QList<double> curveValues0,double V
} }
void ConfigccpmWidget::updateThrottleCurveValue(QList<double> curveValues0,double Value0) void ConfigCcpmWidget::updateThrottleCurveValue(QList<double> curveValues0,double Value0)
{ {
Q_UNUSED(curveValues0); Q_UNUSED(curveValues0);
Q_UNUSED(Value0); Q_UNUSED(Value0);
@ -571,7 +571,7 @@ void ConfigccpmWidget::updateThrottleCurveValue(QList<double> curveValues0,doubl
} }
void ConfigccpmWidget::UpdateCurveSettings() void ConfigCcpmWidget::UpdateCurveSettings()
{ {
int NumCurvePoints,i; int NumCurvePoints,i;
double scale; double scale;
@ -701,7 +701,7 @@ void ConfigccpmWidget::UpdateCurveSettings()
UpdateCurveWidgets(); UpdateCurveWidgets();
} }
void ConfigccpmWidget::GenerateCurve() void ConfigCcpmWidget::GenerateCurve()
{ {
int NumCurvePoints,CurveToGenerate,i; int NumCurvePoints,CurveToGenerate,i;
double value1, value2, value3, scale; double value1, value2, value3, scale;
@ -771,7 +771,7 @@ void ConfigccpmWidget::GenerateCurve()
} }
void ConfigccpmWidget::ccpmSwashplateRedraw() void ConfigCcpmWidget::ccpmSwashplateRedraw()
{ {
double angle[CCPM_MAX_SWASH_SERVOS],CorrectionAngle,x,y,w,h,radius,CenterX,CenterY; double angle[CCPM_MAX_SWASH_SERVOS],CorrectionAngle,x,y,w,h,radius,CenterX,CenterY;
int used[CCPM_MAX_SWASH_SERVOS],defined[CCPM_MAX_SWASH_SERVOS],i; int used[CCPM_MAX_SWASH_SERVOS],defined[CCPM_MAX_SWASH_SERVOS],i;
@ -872,14 +872,14 @@ void ConfigccpmWidget::ccpmSwashplateRedraw()
//m_ccpm->SwashplateImage->fitInView(SwashplateImg, Qt::KeepAspectRatio); //m_ccpm->SwashplateImage->fitInView(SwashplateImg, Qt::KeepAspectRatio);
} }
void ConfigccpmWidget::ccpmSwashplateUpdate() void ConfigCcpmWidget::ccpmSwashplateUpdate()
{ {
ccpmSwashplateRedraw(); ccpmSwashplateRedraw();
SetUIComponentVisibilities(); SetUIComponentVisibilities();
UpdateMixer(); UpdateMixer();
} }
void ConfigccpmWidget::UpdateMixer() void ConfigCcpmWidget::UpdateMixer()
{ {
bool useCCPM; bool useCCPM;
bool useCyclic; bool useCyclic;
@ -995,7 +995,7 @@ void ConfigccpmWidget::UpdateMixer()
} }
} }
QString ConfigccpmWidget::updateConfigObjectsFromWidgets() //UpdateCCPMOptionsFromUI() QString ConfigCcpmWidget::updateConfigObjectsFromWidgets() //UpdateCCPMOptionsFromUI()
{ {
QString airframeType = "HeliCP"; QString airframeType = "HeliCP";
@ -1061,7 +1061,7 @@ QString ConfigccpmWidget::updateConfigObjectsFromWidgets() //UpdateCCPMOptionsFr
return airframeType; return airframeType;
} }
void ConfigccpmWidget::refreshWidgetsValues(QString frameType) //UpdateCCPMUIFromOptions() void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) //UpdateCCPMUIFromOptions()
{ {
Q_UNUSED(frameType); Q_UNUSED(frameType);
@ -1106,8 +1106,10 @@ void ConfigccpmWidget::refreshWidgetsValues(QString frameType) //UpdateCCPMUIFro
} }
void ConfigccpmWidget::SetUIComponentVisibilities() void ConfigCcpmWidget::SetUIComponentVisibilities()
{ {
//mdl updateObjectsFromWidgets();
GUIConfigDataUnion config = GetConfigData(); GUIConfigDataUnion config = GetConfigData();
//set which sliders are user... //set which sliders are user...
@ -1137,7 +1139,7 @@ void ConfigccpmWidget::SetUIComponentVisibilities()
/** /**
Request the current value of the SystemSettings which holds the ccpm type Request the current value of the SystemSettings which holds the ccpm type
*/ */
void ConfigccpmWidget::getMixer() void ConfigCcpmWidget::getMixer()
{ {
if (SwashLvlConfigurationInProgress)return; if (SwashLvlConfigurationInProgress)return;
if (updatingToHardware)return; if (updatingToHardware)return;
@ -1167,7 +1169,7 @@ void ConfigccpmWidget::getMixer()
/** /**
Sends the config to the board (ccpm type) Sends the config to the board (ccpm type)
*/ */
void ConfigccpmWidget::setMixer() void ConfigCcpmWidget::setMixer()
{ {
int i,j; int i,j;
@ -1242,7 +1244,7 @@ void ConfigccpmWidget::setMixer()
/** /**
Send ccpm type to the board and request saving to SD card Send ccpm type to the board and request saving to SD card
*/ */
void ConfigccpmWidget::saveccpmUpdate() void ConfigCcpmWidget::saveccpmUpdate()
{ {
if (SwashLvlConfigurationInProgress)return; if (SwashLvlConfigurationInProgress)return;
ShowDisclaimer(0); ShowDisclaimer(0);
@ -1254,7 +1256,7 @@ void ConfigccpmWidget::saveccpmUpdate()
saveObjectToSD(obj); saveObjectToSD(obj);
} }
void ConfigccpmWidget::resizeEvent(QResizeEvent* event) void ConfigCcpmWidget::resizeEvent(QResizeEvent* event)
{ {
Q_UNUSED(event); Q_UNUSED(event);
// Make the custom table columns autostretch: // Make the custom table columns autostretch:
@ -1266,7 +1268,7 @@ void ConfigccpmWidget::resizeEvent(QResizeEvent* event)
ccpmSwashplateRedraw(); ccpmSwashplateRedraw();
} }
void ConfigccpmWidget::showEvent(QShowEvent *event) void ConfigCcpmWidget::showEvent(QShowEvent *event)
{ {
Q_UNUSED(event) Q_UNUSED(event)
m_ccpm->ccpmAdvancedSettingsTable->resizeColumnsToContents(); m_ccpm->ccpmAdvancedSettingsTable->resizeColumnsToContents();
@ -1278,7 +1280,7 @@ void ConfigccpmWidget::showEvent(QShowEvent *event)
} }
void ConfigccpmWidget::SwashLvlStartButtonPressed() void ConfigCcpmWidget::SwashLvlStartButtonPressed()
{ {
QMessageBox msgBox; QMessageBox msgBox;
int i; int i;
@ -1377,7 +1379,7 @@ void ConfigccpmWidget::SwashLvlStartButtonPressed()
} }
void ConfigccpmWidget::SwashLvlNextButtonPressed() void ConfigCcpmWidget::SwashLvlNextButtonPressed()
{ {
//ShowDisclaimer(2); //ShowDisclaimer(2);
SwashLvlState++; SwashLvlState++;
@ -1480,7 +1482,7 @@ void ConfigccpmWidget::SwashLvlNextButtonPressed()
break; break;
} }
} }
void ConfigccpmWidget::SwashLvlCancelButtonPressed() void ConfigCcpmWidget::SwashLvlCancelButtonPressed()
{ {
int i; int i;
SwashLvlState=0; SwashLvlState=0;
@ -1528,7 +1530,7 @@ void ConfigccpmWidget::SwashLvlCancelButtonPressed()
} }
void ConfigccpmWidget::SwashLvlFinishButtonPressed() void ConfigCcpmWidget::SwashLvlFinishButtonPressed()
{ {
int i; int i;
@ -1572,7 +1574,7 @@ void ConfigccpmWidget::SwashLvlFinishButtonPressed()
} }
int ConfigccpmWidget::ShowDisclaimer(int messageID) int ConfigCcpmWidget::ShowDisclaimer(int messageID)
{ {
QMessageBox msgBox; QMessageBox msgBox;
msgBox.setText("<font color=red><h1>Warning!!!</h2></font>"); msgBox.setText("<font color=red><h1>Warning!!!</h2></font>");
@ -1621,7 +1623,7 @@ int ConfigccpmWidget::ShowDisclaimer(int messageID)
Toggles the channel testing mode by making the GCS take over Toggles the channel testing mode by making the GCS take over
the ActuatorCommand objects the ActuatorCommand objects
*/ */
void ConfigccpmWidget::enableSwashplateLevellingControl(bool state) void ConfigCcpmWidget::enableSwashplateLevellingControl(bool state)
{ {
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>(); UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
@ -1661,7 +1663,7 @@ void ConfigccpmWidget::enableSwashplateLevellingControl(bool state)
Sets the swashplate level to a given value based on current settings for Max, Neutral and Min values. Sets the swashplate level to a given value based on current settings for Max, Neutral and Min values.
level ranges -1 to +1 level ranges -1 to +1
*/ */
void ConfigccpmWidget::setSwashplateLevel(int percent) void ConfigCcpmWidget::setSwashplateLevel(int percent)
{ {
if (percent<0)return;// -1; if (percent<0)return;// -1;
if (percent>100)return;// -1; if (percent>100)return;// -1;
@ -1696,7 +1698,7 @@ return;
} }
void ConfigccpmWidget::SwashLvlSpinBoxChanged(int value) void ConfigCcpmWidget::SwashLvlSpinBoxChanged(int value)
{ {
Q_UNUSED(value); Q_UNUSED(value);
int i; int i;
@ -1740,7 +1742,7 @@ void ConfigccpmWidget::SwashLvlSpinBoxChanged(int value)
/** /**
This function displays text and color formatting in order to help the user understand what channels have not yet been configured. This function displays text and color formatting in order to help the user understand what channels have not yet been configured.
*/ */
void ConfigccpmWidget::throwConfigError(QString airframeType) void ConfigCcpmWidget::throwConfigError(QString airframeType)
{ {
Q_UNUSED(airframeType); Q_UNUSED(airframeType);

View File

@ -52,13 +52,13 @@ typedef struct {
} SwashplateServoSettingsStruct; } SwashplateServoSettingsStruct;
class ConfigccpmWidget: public VehicleConfig class ConfigCcpmWidget: public VehicleConfig
{ {
Q_OBJECT Q_OBJECT
public: public:
ConfigccpmWidget(QWidget *parent = 0); ConfigCcpmWidget(QWidget *parent = 0);
~ConfigccpmWidget(); ~ConfigCcpmWidget();
friend class ConfigVehicleTypeWidget; friend class ConfigVehicleTypeWidget;

View File

@ -52,6 +52,9 @@
ConfigMultiRotorWidget::ConfigMultiRotorWidget(Ui_AircraftWidget *aircraft, QWidget *parent) : VehicleConfig(parent) ConfigMultiRotorWidget::ConfigMultiRotorWidget(Ui_AircraftWidget *aircraft, QWidget *parent) : VehicleConfig(parent)
{ {
m_aircraft = aircraft; m_aircraft = aircraft;
//connect(m_aircraft->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString)));
} }
/** /**
@ -66,17 +69,23 @@ ConfigMultiRotorWidget::~ConfigMultiRotorWidget()
void ConfigMultiRotorWidget::setupUI(QString frameType) void ConfigMultiRotorWidget::setupUI(QString frameType)
{ {
Q_ASSERT(m_aircraft); Q_ASSERT(m_aircraft);
Q_ASSERT(uiowner);
Q_ASSERT(quad); Q_ASSERT(quad);
int i;
// set aircraftType to Multirotor, disable triyaw channel // set aircraftType to Multirotor, disable triyaw channel
setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor")); setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor"));
m_aircraft->triYawChannelBox->setEnabled(false); m_aircraft->triYawChannelBox->setEnabled(false);
// disable all motor channel boxes // disable all motor channel boxes
for (int i=1; i <=8; i++) { for (i=1; i <=8; i++) {
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i)); // do it manually so we can turn off any error decorations
if (combobox) QComboBox *combobox = qFindChild<QComboBox*>(uiowner, "multiMotorChannelBox" + QString::number(i));
if (combobox) {
combobox->setEnabled(false); combobox->setEnabled(false);
combobox->setItemData(0, 0, Qt::DecorationRole);
}
} }
if (frameType == "Tri" || frameType == "Tricopter Y") { if (frameType == "Tri" || frameType == "Tricopter Y") {
@ -84,10 +93,8 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
quad->setElementId("tri"); quad->setElementId("tri");
//Enable all necessary motor channel boxes... //Enable all necessary motor channel boxes...
for (int i=1; i <=3; i++) { for (i=1; i <=3; i++) {
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i)); enableComboBox(uiowner, QString("multiMotorChannelBox%0").arg(i), true);
if (combobox)
combobox->setEnabled(true);
} }
m_aircraft->triYawChannelBox->setEnabled(true); m_aircraft->triYawChannelBox->setEnabled(true);
@ -97,10 +104,8 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
quad->setElementId("quad-X"); quad->setElementId("quad-X");
//Enable all necessary motor channel boxes... //Enable all necessary motor channel boxes...
for (int i=1; i <=4; i++) { for (i=1; i <=4; i++) {
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i)); enableComboBox(uiowner, QString("multiMotorChannelBox%0").arg(i), true);
if (combobox)
combobox->setEnabled(true);
} }
m_aircraft->mrRollMixLevel->setValue(50); m_aircraft->mrRollMixLevel->setValue(50);
@ -112,10 +117,8 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
quad->setElementId("quad-plus"); quad->setElementId("quad-plus");
//Enable all necessary motor channel boxes... //Enable all necessary motor channel boxes...
for (int i=1; i <=4; i++) { for (i=1; i <=4; i++) {
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i)); enableComboBox(uiowner, QString("multiMotorChannelBox%0").arg(i), true);
if (combobox)
combobox->setEnabled(true);
} }
m_aircraft->mrRollMixLevel->setValue(100); m_aircraft->mrRollMixLevel->setValue(100);
@ -128,10 +131,8 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
quad->setElementId("quad-hexa"); quad->setElementId("quad-hexa");
//Enable all necessary motor channel boxes... //Enable all necessary motor channel boxes...
for (int i=1; i <=6; i++) { for (i=1; i <=6; i++) {
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i)); enableComboBox(uiowner, QString("multiMotorChannelBox%0").arg(i), true);
if (combobox)
combobox->setEnabled(true);
} }
m_aircraft->mrRollMixLevel->setValue(50); m_aircraft->mrRollMixLevel->setValue(50);
@ -143,10 +144,8 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
quad->setElementId("quad-hexa-H"); quad->setElementId("quad-hexa-H");
//Enable all necessary motor channel boxes... //Enable all necessary motor channel boxes...
for (int i=1; i <=6; i++) { for (i=1; i <=6; i++) {
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i)); enableComboBox(uiowner, QString("multiMotorChannelBox%0").arg(i), true);
if (combobox)
combobox->setEnabled(true);
} }
m_aircraft->mrRollMixLevel->setValue(33); m_aircraft->mrRollMixLevel->setValue(33);
@ -160,10 +159,8 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
quad->setElementId("hexa-coax"); quad->setElementId("hexa-coax");
//Enable all necessary motor channel boxes... //Enable all necessary motor channel boxes...
for (int i=1; i <=6; i++) { for (i=1; i <=6; i++) {
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i)); enableComboBox(uiowner, QString("multiMotorChannelBox%0").arg(i), true);
if (combobox)
combobox->setEnabled(true);
} }
m_aircraft->mrRollMixLevel->setValue(100); m_aircraft->mrRollMixLevel->setValue(100);
@ -177,10 +174,8 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
quad->setElementId("quad-octo"); quad->setElementId("quad-octo");
//Enable all necessary motor channel boxes //Enable all necessary motor channel boxes
for (int i=1; i <=8; i++) { for (i=1; i <=8; i++) {
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i)); enableComboBox(uiowner, QString("multiMotorChannelBox%0").arg(i), true);
if (combobox)
combobox->setEnabled(true);
} }
m_aircraft->mrRollMixLevel->setValue(33); m_aircraft->mrRollMixLevel->setValue(33);
@ -193,10 +188,8 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
quad->setElementId("quad-octo-v"); quad->setElementId("quad-octo-v");
//Enable all necessary motor channel boxes //Enable all necessary motor channel boxes
for (int i=1; i <=8; i++) { for (i=1; i <=8; i++) {
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i)); enableComboBox(uiowner, QString("multiMotorChannelBox%0").arg(i), true);
if (combobox)
combobox->setEnabled(true);
} }
m_aircraft->mrRollMixLevel->setValue(25); m_aircraft->mrRollMixLevel->setValue(25);
@ -211,9 +204,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
//Enable all necessary motor channel boxes //Enable all necessary motor channel boxes
for (int i=1; i <=8; i++) { for (int i=1; i <=8; i++) {
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i)); enableComboBox(uiowner, QString("multiMotorChannelBox%0").arg(i), true);
if (combobox)
combobox->setEnabled(true);
} }
m_aircraft->mrRollMixLevel->setValue(100); m_aircraft->mrRollMixLevel->setValue(100);
@ -228,9 +219,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType)
//Enable all necessary motor channel boxes //Enable all necessary motor channel boxes
for (int i=1; i <=8; i++) { for (int i=1; i <=8; i++) {
QComboBox *combobox = qFindChild<QComboBox*>(this->parent(), "multiMotorChannelBox" + QString::number(i)); enableComboBox(uiowner, QString("multiMotorChannelBox%0").arg(i), true);
if (combobox)
combobox->setEnabled(true);
} }
m_aircraft->mrRollMixLevel->setValue(50); m_aircraft->mrRollMixLevel->setValue(50);
@ -1125,27 +1114,17 @@ void ConfigMultiRotorWidget::throwConfigError(int numMotors)
//Iterate through all instances of multiMotorChannelBox //Iterate through all instances of multiMotorChannelBox
for (int i=0; i<numMotors; i++) { for (int i=0; i<numMotors; i++) {
//Fine widgets with text "multiMotorChannelBox.x", where x is an integer //Fine widgets with text "multiMotorChannelBox.x", where x is an integer
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i+1)); QComboBox *combobox = qFindChild<QComboBox*>(uiowner, "multiMotorChannelBox" + QString::number(i+1));
if (combobox){ //if QLabel exists if (combobox){
// QLabel *label = qFindChild<QLabel*>(this, "MotorOutputLabel" + QString::number(i+1)); if (combobox->currentText() == "None") {
if (combobox->currentText() == "None") {
// label->setText("<font color='red'>" + label->text() + "</font>");
int size = combobox->style()->pixelMetric(QStyle::PM_SmallIconSize); int size = combobox->style()->pixelMetric(QStyle::PM_SmallIconSize);
QPixmap pixmap(size,size); QPixmap pixmap(size,size);
pixmap.fill(QColor("red")); pixmap.fill(QColor("red"));
combobox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes combobox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
// combobox->setStyleSheet("QComboBox { color: red}");
error=true; error=true;
} }
else { else {
combobox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes combobox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
// combobox->setStyleSheet("color: black;");
// QTextEdit* htmlText=new QTextEdit(label->text()); // htmlText is any QString with html tags.
// label->setText(htmlText->toPlainText());
} }
} }
} }

View File

@ -53,6 +53,7 @@ public:
private: private:
Ui_AircraftWidget *m_aircraft; Ui_AircraftWidget *m_aircraft;
QWidget *uiowner;
QGraphicsSvgItem *quad; QGraphicsSvgItem *quad;
bool setupQuad(bool pLayout); bool setupQuad(bool pLayout);
@ -74,6 +75,8 @@ private slots:
protected: protected:
signals:
void configurationChanged();
}; };

View File

@ -36,9 +36,12 @@
VehicleConfig::VehicleConfig(QWidget *parent) : ConfigTaskWidget(parent) VehicleConfig::VehicleConfig(QWidget *parent) : ConfigTaskWidget(parent)
{ {
//Generate lists of mixerTypeNames, mixerVectorNames, channelNames
channelNames << "None";
for (int i = 0; i < (int)(VehicleConfig::CHANNEL_NUMELEM); i++) { for (int i = 0; i < (int)(VehicleConfig::CHANNEL_NUMELEM); i++) {
mixerTypes << QString("Mixer%1Type").arg(i+1); mixerTypes << QString("Mixer%1Type").arg(i+1);
mixerVectors << QString("Mixer%1Vector").arg(i+1); mixerVectors << QString("Mixer%1Vector").arg(i+1);
channelNames << QString("Channel%1").arg(i+1);
} }
} }
@ -119,6 +122,17 @@ void VehicleConfig::setComboCurrentIndex(QComboBox* box, int index)
box->setCurrentIndex(index); box->setCurrentIndex(index);
} }
/**
Helper function:
enables/disables the named combobox within supplied uiowner
*/
void VehicleConfig::enableComboBox(QWidget* owner, QString boxName, bool enable)
{
QComboBox* box = qFindChild<QComboBox*>(owner, boxName);
if (box)
box->setEnabled(enable);
}
/** /**
Reset the contents of a field Reset the contents of a field

View File

@ -115,10 +115,12 @@ class VehicleConfig: public ConfigTaskWidget
static void SetConfigData(GUIConfigDataUnion configData); static void SetConfigData(GUIConfigDataUnion configData);
static void resetField(UAVObjectField * field); static void resetField(UAVObjectField * field);
static void setComboCurrentIndex(QComboBox* box, int index); static void setComboCurrentIndex(QComboBox* box, int index);
static void enableComboBox(QWidget* owner, QString boxName, bool enable);
virtual void ResetActuators(GUIConfigDataUnion* configData); virtual void ResetActuators(GUIConfigDataUnion* configData);
virtual QStringList getChannelDescriptions(); virtual QStringList getChannelDescriptions();
QStringList channelNames;
QStringList mixerTypes; QStringList mixerTypes;
QStringList mixerVectors; QStringList mixerVectors;

View File

@ -106,13 +106,12 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
ffTuningInProgress = false; ffTuningInProgress = false;
ffTuningPhase = false; ffTuningPhase = false;
//Generate list of channels //Generate lists of mixerTypeNames, mixerVectorNames, channelNames
QStringList channels; channelNames << "None";
channels << "None";
for (int i = 0; i < ActuatorSettings::CHANNELADDR_NUMELEM; i++) { for (int i = 0; i < ActuatorSettings::CHANNELADDR_NUMELEM; i++) {
mixerTypes << QString("Mixer%1Type").arg(i+1); mixerTypes << QString("Mixer%1Type").arg(i+1);
mixerVectors << QString("Mixer%1Vector").arg(i+1); mixerVectors << QString("Mixer%1Vector").arg(i+1);
channels << QString("Channel%1").arg(i+1); channelNames << QString("Channel%1").arg(i+1);
} }
QStringList airframeTypes; QStringList airframeTypes;
@ -142,7 +141,7 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
// The upshot of this is that ALL new ComboBox widgets for selecting the output channel must have "ChannelBox" in their name // The upshot of this is that ALL new ComboBox widgets for selecting the output channel must have "ChannelBox" in their name
foreach(QComboBox *combobox, this->findChildren<QComboBox*>(QRegExp("\\S+ChannelBo\\S+")))//FOR WHATEVER REASON, THIS DOES NOT WORK WITH ChannelBox. ChannelBo is sufficiently accurate foreach(QComboBox *combobox, this->findChildren<QComboBox*>(QRegExp("\\S+ChannelBo\\S+")))//FOR WHATEVER REASON, THIS DOES NOT WORK WITH ChannelBox. ChannelBo is sufficiently accurate
{ {
combobox->addItems(channels); combobox->addItems(channelNames);
} }
// Setup the Multirotor picture in the Quad settings interface // Setup the Multirotor picture in the Quad settings interface
@ -173,19 +172,27 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
m_aircraft->customMixerTable->setItemDelegateForRow(i, sbd); m_aircraft->customMixerTable->setItemDelegateForRow(i, sbd);
} }
m_multirotor = new ConfigMultiRotorWidget(m_aircraft, this); // create and setup a MultiRotor config widget
m_multirotor = new ConfigMultiRotorWidget(m_aircraft);
m_multirotor->quad = quad; m_multirotor->quad = quad;
m_multirotor->uiowner = this;
m_multirotor->setupUI(m_aircraft->multirotorFrameType->currentText()); m_multirotor->setupUI(m_aircraft->multirotorFrameType->currentText());
m_groundvehicle = new ConfigGroundVehicleWidget(m_aircraft, this); // create and setup a GroundVehicle config widget
m_groundvehicle = new ConfigGroundVehicleWidget(m_aircraft);
m_groundvehicle->setupUI(m_aircraft->groundVehicleType->currentText() ); m_groundvehicle->setupUI(m_aircraft->groundVehicleType->currentText() );
m_fixedwing = new ConfigFixedWingWidget(m_aircraft, this); // create and setup a FixedWing config widget
m_fixedwing = new ConfigFixedWingWidget(m_aircraft);
m_fixedwing->setupUI(m_aircraft->fixedWingType->currentText() ); m_fixedwing->setupUI(m_aircraft->fixedWingType->currentText() );
m_heli = m_aircraft->widget_3;// new ConfigccpmWidget(this); // create and setup a Helicopter config widget
m_heli = m_aircraft->widget_3;
m_heli->setupUI(QString("HeliCP")); m_heli->setupUI(QString("HeliCP"));
// initialize the ui to show the mixersettings tab
//mdl m_aircraft->tabWidget->setCurrentIndex(0);
//Connect aircraft type selection dropbox to callback function //Connect aircraft type selection dropbox to callback function
connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), this, SLOT(switchAirframeType(int))); connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), this, SLOT(switchAirframeType(int)));
@ -238,6 +245,11 @@ ConfigVehicleTypeWidget::~ConfigVehicleTypeWidget()
// Do nothing // Do nothing
} }
/**
Static function to get currently assigned channelDescriptions
for all known vehicle types; instantiates the appropriate object
then asks it to supply channel descs
*/
QStringList ConfigVehicleTypeWidget::getChannelDescriptions() QStringList ConfigVehicleTypeWidget::getChannelDescriptions()
{ {
int i; int i;
@ -267,7 +279,7 @@ QStringList ConfigVehicleTypeWidget::getChannelDescriptions()
// helicp // helicp
case SystemSettings::AIRFRAMETYPE_HELICP: case SystemSettings::AIRFRAMETYPE_HELICP:
{ {
ConfigccpmWidget* heli = new ConfigccpmWidget(); ConfigCcpmWidget* heli = new ConfigCcpmWidget();
channelDesc = heli->getChannelDescriptions(); channelDesc = heli->getChannelDescriptions();
} }
break; break;
@ -402,7 +414,6 @@ void ConfigVehicleTypeWidget::toggleRudder2(int index)
} }
} }
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////
/// Feed Forward Testing /// Feed Forward Testing
///////////////////////////////////////////////////////// /////////////////////////////////////////////////////////

View File

@ -58,7 +58,7 @@ public:
private: private:
Ui_AircraftWidget *m_aircraft; Ui_AircraftWidget *m_aircraft;
ConfigccpmWidget *m_heli; ConfigCcpmWidget *m_heli;
ConfigFixedWingWidget *m_fixedwing; ConfigFixedWingWidget *m_fixedwing;
ConfigMultiRotorWidget *m_multirotor; ConfigMultiRotorWidget *m_multirotor;
ConfigGroundVehicleWidget *m_groundvehicle; ConfigGroundVehicleWidget *m_groundvehicle;
@ -70,9 +70,10 @@ private:
//void setMixerChannel(int channelNumber, bool channelIsMotor, QList<double> vector); //void setMixerChannel(int channelNumber, bool channelIsMotor, QList<double> vector);
QStringList channelNames;
QStringList mixerTypes; QStringList mixerTypes;
QStringList mixerVectors; QStringList mixerVectors;
QGraphicsSvgItem *quad; QGraphicsSvgItem *quad;
bool ffTuningInProgress; bool ffTuningInProgress;
bool ffTuningPhase; bool ffTuningPhase;
@ -85,7 +86,6 @@ private slots:
void setComboCurrentIndex(QComboBox* box, int index); void setComboCurrentIndex(QComboBox* box, int index);
void setupAirframeUI(QString type); void setupAirframeUI(QString type);
void toggleAileron2(int index); void toggleAileron2(int index);