mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +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:
parent
23aea6eac4
commit
8692855208
@ -31,15 +31,14 @@
|
|||||||
Helper delegate for the custom mixer editor table.
|
Helper delegate for the custom mixer editor table.
|
||||||
*/
|
*/
|
||||||
DoubleSpinDelegate::DoubleSpinDelegate(QObject *parent)
|
DoubleSpinDelegate::DoubleSpinDelegate(QObject *parent)
|
||||||
: QItemDelegate(parent),
|
: QItemDelegate(parent)
|
||||||
m_min(0.0),
|
|
||||||
m_max(1.0),
|
|
||||||
m_decimals(2),
|
|
||||||
m_step(0.01)
|
|
||||||
{
|
{
|
||||||
|
m_min = 0.0;
|
||||||
|
m_max = 1.0;
|
||||||
|
m_decimals = 2;
|
||||||
|
m_step = 0.01;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QWidget *DoubleSpinDelegate::createEditor(QWidget *parent,
|
QWidget *DoubleSpinDelegate::createEditor(QWidget *parent,
|
||||||
const QStyleOptionViewItem &/* option */,
|
const QStyleOptionViewItem &/* option */,
|
||||||
const QModelIndex &/* index */) const
|
const QModelIndex &/* index */) const
|
||||||
@ -49,6 +48,9 @@ QWidget *DoubleSpinDelegate::createEditor(QWidget *parent,
|
|||||||
editor->setMaximum(m_max);
|
editor->setMaximum(m_max);
|
||||||
editor->setDecimals(m_decimals);
|
editor->setDecimals(m_decimals);
|
||||||
editor->setSingleStep(m_step);
|
editor->setSingleStep(m_step);
|
||||||
|
|
||||||
|
connect(editor,SIGNAL(valueChanged(double)), this, SLOT(valueChanged()));
|
||||||
|
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,3 +79,8 @@ void DoubleSpinDelegate::updateEditorGeometry(QWidget *editor,
|
|||||||
editor->setGeometry(option.rect);
|
editor->setGeometry(option.rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DoubleSpinDelegate::valueChanged()
|
||||||
|
{
|
||||||
|
emit ValueChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,11 @@
|
|||||||
#include <QDoubleSpinBox>
|
#include <QDoubleSpinBox>
|
||||||
#include <QItemDelegate>
|
#include <QItemDelegate>
|
||||||
|
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class DoubleSpinDelegate;
|
||||||
|
}
|
||||||
|
|
||||||
class DoubleSpinDelegate : public QItemDelegate
|
class DoubleSpinDelegate : public QItemDelegate
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -47,11 +52,23 @@ public:
|
|||||||
void updateEditorGeometry(QWidget *editor,
|
void updateEditorGeometry(QWidget *editor,
|
||||||
const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
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:
|
private:
|
||||||
double m_min;
|
double m_min;
|
||||||
double m_max;
|
double m_max;
|
||||||
double m_step;
|
double m_step;
|
||||||
int m_decimals;
|
int m_decimals;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void ValueChanged();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void valueChanged() ;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DOUBLESPINDELEGATE_H
|
#endif // DOUBLESPINDELEGATE_H
|
||||||
|
@ -135,10 +135,10 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : VehicleConfig(parent)
|
|||||||
//initialize our two mixer curves
|
//initialize our two mixer curves
|
||||||
|
|
||||||
m_ccpm->ThrottleCurve->setMixerType(MixerCurve::MIXERCURVE_THROTTLE);
|
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->setMixerType(MixerCurve::MIXERCURVE_PITCH);
|
||||||
m_ccpm->PitchCurve->initLinearCurve(5, 1.0, -1.0);
|
m_ccpm->PitchCurve->ResetCurve();
|
||||||
|
|
||||||
//initialize channel names
|
//initialize channel names
|
||||||
m_ccpm->ccpmEngineChannel->addItems(channelNames);
|
m_ccpm->ccpmEngineChannel->addItems(channelNames);
|
||||||
@ -840,10 +840,24 @@ void ConfigCcpmWidget::getMixer()
|
|||||||
|
|
||||||
QList<double> curveValues;
|
QList<double> curveValues;
|
||||||
vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
|
vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues);
|
||||||
|
|
||||||
|
// is at least one of the curve values != 0?
|
||||||
|
if (vconfig->isValidThrottleCurve(&curveValues)) {
|
||||||
m_ccpm->ThrottleCurve->setCurve(&curveValues);
|
m_ccpm->ThrottleCurve->setCurve(&curveValues);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_ccpm->ThrottleCurve->ResetCurve();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
|
vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
|
||||||
|
// is at least one of the curve values != 0?
|
||||||
|
if (vconfig->isValidThrottleCurve(&curveValues)) {
|
||||||
m_ccpm->PitchCurve->setCurve(&curveValues);
|
m_ccpm->PitchCurve->setCurve(&curveValues);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_ccpm->PitchCurve->ResetCurve();
|
||||||
|
}
|
||||||
|
|
||||||
updatingFromHardware=FALSE;
|
updatingFromHardware=FALSE;
|
||||||
|
|
||||||
|
@ -325,7 +325,7 @@ void ConfigVehicleTypeWidget::switchAirframeType(int index)
|
|||||||
m_aircraft->customMixerTable->resizeColumnsToContents();
|
m_aircraft->customMixerTable->resizeColumnsToContents();
|
||||||
for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) {
|
for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) {
|
||||||
m_aircraft->customMixerTable->setColumnWidth(i,(m_aircraft->customMixerTable->width()-
|
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();
|
m_aircraft->customMixerTable->resizeColumnsToContents();
|
||||||
for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) {
|
for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) {
|
||||||
m_aircraft->customMixerTable->setColumnWidth(i,(m_aircraft->customMixerTable->width()-
|
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);
|
m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||||
// Make the custom table columns autostretch:
|
// Make the custom table columns autostretch:
|
||||||
m_aircraft->customMixerTable->resizeColumnsToContents();
|
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->setColumnWidth(i,(m_aircraft->customMixerTable->width()-
|
||||||
m_aircraft->customMixerTable->verticalHeader()->width())/8);
|
m_aircraft->customMixerTable->verticalHeader()->width())/ 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,18 +31,14 @@
|
|||||||
|
|
||||||
MixerCurve::MixerCurve(QWidget *parent) :
|
MixerCurve::MixerCurve(QWidget *parent) :
|
||||||
QFrame(parent),
|
QFrame(parent),
|
||||||
m_mixerUI(new Ui::MixerCurve),
|
m_mixerUI(new Ui::MixerCurve)
|
||||||
m_curveType(MixerCurve::MIXERCURVE_THROTTLE)
|
|
||||||
{
|
{
|
||||||
m_mixerUI->setupUi(this);
|
m_mixerUI->setupUi(this);
|
||||||
|
|
||||||
m_curve = m_mixerUI->CurveWidget;
|
m_curve = m_mixerUI->CurveWidget;
|
||||||
m_settings = m_mixerUI->CurveSettings;
|
m_settings = m_mixerUI->CurveSettings;
|
||||||
|
|
||||||
DoubleSpinDelegate *sbd = new DoubleSpinDelegate();
|
setMixerType(MixerCurve::MIXERCURVE_THROTTLE);
|
||||||
for (int i=0; i<MixerCurveWidget::NODE_NUMELEM; i++) {
|
|
||||||
m_settings->setItemDelegateForRow(i, sbd);
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateCurveUI();
|
UpdateCurveUI();
|
||||||
|
|
||||||
@ -50,7 +46,7 @@ MixerCurve::MixerCurve(QWidget *parent) :
|
|||||||
connect(m_mixerUI->ResetCurve, SIGNAL(clicked()), this, SLOT(ResetCurve()));
|
connect(m_mixerUI->ResetCurve, SIGNAL(clicked()), this, SLOT(ResetCurve()));
|
||||||
connect(m_mixerUI->GenerateCurve, SIGNAL(clicked()), this, SLOT(GenerateCurve()));
|
connect(m_mixerUI->GenerateCurve, SIGNAL(clicked()), this, SLOT(GenerateCurve()));
|
||||||
connect(m_curve, SIGNAL(curveUpdated()), this, SLOT(UpdateSettingsTable()));
|
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->CurveMin, SIGNAL(valueChanged(double)), this, SLOT(CurveMinChanged(double)));
|
||||||
connect(m_mixerUI->CurveMax, SIGNAL(valueChanged(double)), this, SLOT(CurveMaxChanged(double)));
|
connect(m_mixerUI->CurveMax, SIGNAL(valueChanged(double)), this, SLOT(CurveMaxChanged(double)));
|
||||||
connect(m_mixerUI->CurveStep, SIGNAL(valueChanged(double)), this, SLOT(GenerateCurve()));
|
connect(m_mixerUI->CurveStep, SIGNAL(valueChanged(double)), this, SLOT(GenerateCurve()));
|
||||||
@ -64,7 +60,33 @@ MixerCurve::~MixerCurve()
|
|||||||
void MixerCurve::setMixerType(MixerCurveType curveType)
|
void MixerCurve::setMixerType(MixerCurveType curveType)
|
||||||
{
|
{
|
||||||
m_curveType = 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()
|
void MixerCurve::ResetCurve()
|
||||||
@ -328,6 +350,9 @@ void MixerCurve::showEvent(QShowEvent *event)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
|
|
||||||
|
m_settings->resizeColumnsToContents();
|
||||||
|
m_settings->setColumnWidth(0,(m_settings->width()- m_settings->verticalHeader()->width()));
|
||||||
|
|
||||||
m_curve->showEvent(event);
|
m_curve->showEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,5 +360,8 @@ void MixerCurve::resizeEvent(QResizeEvent* event)
|
|||||||
{
|
{
|
||||||
Q_UNUSED(event);
|
Q_UNUSED(event);
|
||||||
|
|
||||||
|
m_settings->resizeColumnsToContents();
|
||||||
|
m_settings->setColumnWidth(0,(m_settings->width()- m_settings->verticalHeader()->width()));
|
||||||
|
|
||||||
m_curve->resizeEvent(event);
|
m_curve->resizeEvent(event);
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
<widget class="QGroupBox" name="CurveGroup">
|
<widget class="QGroupBox" name="CurveGroup">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>100</width>
|
<width>150</width>
|
||||||
<height>16777215</height>
|
<height>16777215</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
@ -74,7 +74,7 @@
|
|||||||
<widget class="QTableWidget" name="CurveSettings">
|
<widget class="QTableWidget" name="CurveSettings">
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>71</width>
|
<width>100</width>
|
||||||
<height>200</height>
|
<height>200</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
@ -281,7 +281,6 @@
|
|||||||
<pointsize>7</pointsize>
|
<pointsize>7</pointsize>
|
||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<zorder>CurveGroup</zorder>
|
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user