1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

Bugfixes: spindelegate is online and fairly smart, knows min/max for curve;

heli config is fully on board with integrated curve;
custom vehicle now displays 10 channels in custom grid;
mixercurve ui getting better;
This commit is contained in:
Mike LaBranche 2012-07-05 15:31:36 -07:00
parent 23aea6eac4
commit 8692855208
6 changed files with 91 additions and 26 deletions

View File

@ -31,15 +31,14 @@
Helper delegate for the custom mixer editor table.
*/
DoubleSpinDelegate::DoubleSpinDelegate(QObject *parent)
: QItemDelegate(parent),
m_min(0.0),
m_max(1.0),
m_decimals(2),
m_step(0.01)
{
: QItemDelegate(parent)
{
m_min = 0.0;
m_max = 1.0;
m_decimals = 2;
m_step = 0.01;
}
QWidget *DoubleSpinDelegate::createEditor(QWidget *parent,
const QStyleOptionViewItem &/* option */,
const QModelIndex &/* index */) const
@ -49,6 +48,9 @@ QWidget *DoubleSpinDelegate::createEditor(QWidget *parent,
editor->setMaximum(m_max);
editor->setDecimals(m_decimals);
editor->setSingleStep(m_step);
connect(editor,SIGNAL(valueChanged(double)), this, SLOT(valueChanged()));
return editor;
}
@ -77,3 +79,8 @@ void DoubleSpinDelegate::updateEditorGeometry(QWidget *editor,
editor->setGeometry(option.rect);
}
void DoubleSpinDelegate::valueChanged()
{
emit ValueChanged();
}

View File

@ -30,6 +30,11 @@
#include <QDoubleSpinBox>
#include <QItemDelegate>
namespace Ui {
class DoubleSpinDelegate;
}
class DoubleSpinDelegate : public QItemDelegate
{
Q_OBJECT
@ -47,11 +52,23 @@ public:
void updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option, const QModelIndex &index) const;
void setMin(double min) { m_min = min; }
void setMax(double max) { m_max = max; }
void setRange(double min, double max) { m_min = min; m_max = max; }
void setStep(double step) { m_step = step; }
void setDecimals(int decimals) { m_decimals = decimals; }
private:
double m_min;
double m_max;
double m_step;
int m_decimals;
signals:
void ValueChanged();
private slots:
void valueChanged() ;
};
#endif // DOUBLESPINDELEGATE_H

View File

@ -135,10 +135,10 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : VehicleConfig(parent)
//initialize our two mixer curves
m_ccpm->ThrottleCurve->setMixerType(MixerCurve::MIXERCURVE_THROTTLE);
m_ccpm->ThrottleCurve->initLinearCurve(5, 1.0);
m_ccpm->ThrottleCurve->ResetCurve();
m_ccpm->PitchCurve->setMixerType(MixerCurve::MIXERCURVE_PITCH);
m_ccpm->PitchCurve->initLinearCurve(5, 1.0, -1.0);
m_ccpm->PitchCurve->ResetCurve();
//initialize channel names
m_ccpm->ccpmEngineChannel->addItems(channelNames);
@ -840,10 +840,24 @@ void ConfigCcpmWidget::getMixer()
QList<double> curveValues;
vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
m_ccpm->ThrottleCurve->setCurve(&curveValues);
// is at least one of the curve values != 0?
if (vconfig->isValidThrottleCurve(&curveValues)) {
m_ccpm->ThrottleCurve->setCurve(&curveValues);
}
else {
m_ccpm->ThrottleCurve->ResetCurve();
}
vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
m_ccpm->PitchCurve->setCurve(&curveValues);
// is at least one of the curve values != 0?
if (vconfig->isValidThrottleCurve(&curveValues)) {
m_ccpm->PitchCurve->setCurve(&curveValues);
}
else {
m_ccpm->PitchCurve->ResetCurve();
}
updatingFromHardware=FALSE;

View File

@ -325,7 +325,7 @@ void ConfigVehicleTypeWidget::switchAirframeType(int index)
m_aircraft->customMixerTable->resizeColumnsToContents();
for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) {
m_aircraft->customMixerTable->setColumnWidth(i,(m_aircraft->customMixerTable->width()-
m_aircraft->customMixerTable->verticalHeader()->width())/8);
m_aircraft->customMixerTable->verticalHeader()->width())/10);
}
}
}
@ -344,7 +344,7 @@ void ConfigVehicleTypeWidget::showEvent(QShowEvent *event)
m_aircraft->customMixerTable->resizeColumnsToContents();
for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) {
m_aircraft->customMixerTable->setColumnWidth(i,(m_aircraft->customMixerTable->width()-
m_aircraft->customMixerTable->verticalHeader()->width())/8);
m_aircraft->customMixerTable->verticalHeader()->width())/ 10);
}
}
@ -357,9 +357,9 @@ void ConfigVehicleTypeWidget::resizeEvent(QResizeEvent* event)
m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
// Make the custom table columns autostretch:
m_aircraft->customMixerTable->resizeColumnsToContents();
for (int i=0;i<8;i++) {
for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) {
m_aircraft->customMixerTable->setColumnWidth(i,(m_aircraft->customMixerTable->width()-
m_aircraft->customMixerTable->verticalHeader()->width())/8);
m_aircraft->customMixerTable->verticalHeader()->width())/ 10);
}
}

View File

@ -31,18 +31,14 @@
MixerCurve::MixerCurve(QWidget *parent) :
QFrame(parent),
m_mixerUI(new Ui::MixerCurve),
m_curveType(MixerCurve::MIXERCURVE_THROTTLE)
m_mixerUI(new Ui::MixerCurve)
{
m_mixerUI->setupUi(this);
m_curve = m_mixerUI->CurveWidget;
m_settings = m_mixerUI->CurveSettings;
DoubleSpinDelegate *sbd = new DoubleSpinDelegate();
for (int i=0; i<MixerCurveWidget::NODE_NUMELEM; i++) {
m_settings->setItemDelegateForRow(i, sbd);
}
setMixerType(MixerCurve::MIXERCURVE_THROTTLE);
UpdateCurveUI();
@ -50,7 +46,7 @@ MixerCurve::MixerCurve(QWidget *parent) :
connect(m_mixerUI->ResetCurve, SIGNAL(clicked()), this, SLOT(ResetCurve()));
connect(m_mixerUI->GenerateCurve, SIGNAL(clicked()), this, SLOT(GenerateCurve()));
connect(m_curve, SIGNAL(curveUpdated()), this, SLOT(UpdateSettingsTable()));
connect(m_settings, SIGNAL(itemChanged(QTableWidgetItem*)), this, SLOT(SettingsTableChanged()));
connect(m_settings, SIGNAL(cellChanged(int,int)), this, SLOT(SettingsTableChanged()));
connect(m_mixerUI->CurveMin, SIGNAL(valueChanged(double)), this, SLOT(CurveMinChanged(double)));
connect(m_mixerUI->CurveMax, SIGNAL(valueChanged(double)), this, SLOT(CurveMaxChanged(double)));
connect(m_mixerUI->CurveStep, SIGNAL(valueChanged(double)), this, SLOT(GenerateCurve()));
@ -64,7 +60,33 @@ MixerCurve::~MixerCurve()
void MixerCurve::setMixerType(MixerCurveType curveType)
{
m_curveType = curveType;
m_mixerUI->CurveGroup->setTitle( (m_curveType == MixerCurve::MIXERCURVE_THROTTLE) ? "Throttle Curve" : "Pitch Curve");
switch (m_curveType) {
case MixerCurve::MIXERCURVE_THROTTLE:
{
m_mixerUI->CurveGroup->setTitle("Throttle Curve");
m_curve->setRange(0.0, 1.0);
m_mixerUI->CurveMin->setMinimum(0.0);
m_mixerUI->CurveMax->setMinimum(0.0);
break;
}
case MixerCurve::MIXERCURVE_PITCH:
{
m_mixerUI->CurveGroup->setTitle("Pitch Curve");
m_curve->setRange(-1.0, 1.0);
m_mixerUI->CurveMin->setMinimum(-1.0);
m_mixerUI->CurveMax->setMinimum(-1.0);
break;
}
}
DoubleSpinDelegate *sbd = new DoubleSpinDelegate();
sbd->setRange(m_curve->getMin(), m_curve->getMax());
for (int i=0; i<MixerCurveWidget::NODE_NUMELEM; i++) {
m_settings->setItemDelegateForRow(i, sbd);
}
ResetCurve();
}
void MixerCurve::ResetCurve()
@ -328,6 +350,9 @@ void MixerCurve::showEvent(QShowEvent *event)
{
Q_UNUSED(event);
m_settings->resizeColumnsToContents();
m_settings->setColumnWidth(0,(m_settings->width()- m_settings->verticalHeader()->width()));
m_curve->showEvent(event);
}
@ -335,5 +360,8 @@ void MixerCurve::resizeEvent(QResizeEvent* event)
{
Q_UNUSED(event);
m_settings->resizeColumnsToContents();
m_settings->setColumnWidth(0,(m_settings->width()- m_settings->verticalHeader()->width()));
m_curve->resizeEvent(event);
}

View File

@ -62,7 +62,7 @@
<widget class="QGroupBox" name="CurveGroup">
<property name="maximumSize">
<size>
<width>100</width>
<width>150</width>
<height>16777215</height>
</size>
</property>
@ -74,7 +74,7 @@
<widget class="QTableWidget" name="CurveSettings">
<property name="maximumSize">
<size>
<width>71</width>
<width>100</width>
<height>200</height>
</size>
</property>
@ -281,7 +281,6 @@
<pointsize>7</pointsize>
</font>
</property>
<zorder>CurveGroup</zorder>
</widget>
</item>
<item row="2" column="0">