From 0c9e5c5e66bd389a12c2affe667aac2835466ac7 Mon Sep 17 00:00:00 2001 From: Mike LaBranche Date: Wed, 4 Jul 2012 10:21:48 -0700 Subject: [PATCH] MixerCurve: Move code into \config folder; slice out doublespindelegate; enhanced mixercurve in all airframes except heli; layout is better, not there yet. VehicleConfig, Bugfix: update custom mixer table to 10 channels. --- .../src/plugins/config/DoubleSpinDelegate.cpp | 79 ++++ .../src/plugins/config/DoubleSpinDelegate.h | 57 +++ .../src/plugins/config/airframe.ui | 161 ++++++-- .../openpilotgcs/src/plugins/config/ccpm.ui | 2 +- .../src/plugins/config/config.pro | 11 +- .../config/configvehicletypewidget.cpp | 12 +- .../mixercurve.cpp | 125 ++++-- .../src/plugins/config/mixercurve.h | 97 +++++ .../src/plugins/config/mixercurve.ui | 378 ++++++++++++++++++ .../plugins/uavobjectwidgetutils/mixercurve.h | 68 ---- .../uavobjectwidgetutils/mixercurve.ui | 303 -------------- .../uavobjectwidgetutils.pro | 9 +- 12 files changed, 850 insertions(+), 452 deletions(-) create mode 100644 ground/openpilotgcs/src/plugins/config/DoubleSpinDelegate.cpp create mode 100644 ground/openpilotgcs/src/plugins/config/DoubleSpinDelegate.h rename ground/openpilotgcs/src/plugins/{uavobjectwidgetutils => config}/mixercurve.cpp (70%) create mode 100644 ground/openpilotgcs/src/plugins/config/mixercurve.h create mode 100644 ground/openpilotgcs/src/plugins/config/mixercurve.ui delete mode 100644 ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurve.h delete mode 100644 ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurve.ui diff --git a/ground/openpilotgcs/src/plugins/config/DoubleSpinDelegate.cpp b/ground/openpilotgcs/src/plugins/config/DoubleSpinDelegate.cpp new file mode 100644 index 000000000..dd5921431 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/DoubleSpinDelegate.cpp @@ -0,0 +1,79 @@ +/** + ****************************************************************************** + * + * @file doublespindelegate.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief A double spinbox delegate + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "doublespindelegate.h" + +/** + 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) + { + } + + +QWidget *DoubleSpinDelegate::createEditor(QWidget *parent, + const QStyleOptionViewItem &/* option */, + const QModelIndex &/* index */) const +{ + QDoubleSpinBox *editor = new QDoubleSpinBox(parent); + editor->setMinimum(m_min); + editor->setMaximum(m_max); + editor->setDecimals(m_decimals); + editor->setSingleStep(m_step); + return editor; +} + +void DoubleSpinDelegate::setEditorData(QWidget *editor, + const QModelIndex &index) const +{ + double value = index.model()->data(index, Qt::EditRole).toDouble(); + + QDoubleSpinBox *spinBox = static_cast(editor); + spinBox->setValue(value); +} + +void DoubleSpinDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, + const QModelIndex &index) const +{ + QDoubleSpinBox *spinBox = static_cast(editor); + spinBox->interpretText(); + double value = spinBox->value(); + + model->setData(index, value, Qt::EditRole); +} + +void DoubleSpinDelegate::updateEditorGeometry(QWidget *editor, + const QStyleOptionViewItem &option, const QModelIndex &/* index */) const +{ + editor->setGeometry(option.rect); +} + diff --git a/ground/openpilotgcs/src/plugins/config/DoubleSpinDelegate.h b/ground/openpilotgcs/src/plugins/config/DoubleSpinDelegate.h new file mode 100644 index 000000000..8329abb75 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/DoubleSpinDelegate.h @@ -0,0 +1,57 @@ +/** + ****************************************************************************** + * + * @file doublespindelegate.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief A double spinbox delegate + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef DOUBLESPINDELEGATE_H +#define DOUBLESPINDELEGATE_H + +#include +#include + +class DoubleSpinDelegate : public QItemDelegate +{ + Q_OBJECT + +public: + DoubleSpinDelegate(QObject *parent = 0); + + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, + const QModelIndex &index) const; + + void setEditorData(QWidget *editor, const QModelIndex &index) const; + void setModelData(QWidget *editor, QAbstractItemModel *model, + const QModelIndex &index) const; + + void updateEditorGeometry(QWidget *editor, + const QStyleOptionViewItem &option, const QModelIndex &index) const; + +private: + double m_min; + double m_max; + double m_step; + int m_decimals; +}; + +#endif // DOUBLESPINDELEGATE_H diff --git a/ground/openpilotgcs/src/plugins/config/airframe.ui b/ground/openpilotgcs/src/plugins/config/airframe.ui index 5a6f81895..7ca5b937b 100644 --- a/ground/openpilotgcs/src/plugins/config/airframe.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe.ui @@ -7,7 +7,7 @@ 0 0 939 - 635 + 657 @@ -74,7 +74,7 @@ - 4 + 0 @@ -473,15 +473,15 @@ margin:1px; - - 0 - 0 + + 1 + 1 - 0 - 0 + 450 + 400 @@ -496,6 +496,12 @@ margin:1px; 10 + + + 300 + 300 + + @@ -1618,23 +1624,10 @@ margin:1px; - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + 0 100 @@ -1676,6 +1669,12 @@ margin:1px; + + + 0 + 0 + + Rear throttle curve @@ -1775,7 +1774,7 @@ margin:1px; - + 1 1 @@ -1800,8 +1799,8 @@ margin:1px; - 200 - 200 + 300 + 350 @@ -1818,7 +1817,7 @@ margin:1px; - + 1 1 @@ -1843,8 +1842,8 @@ margin:1px; - 200 - 200 + 300 + 350 @@ -1941,6 +1940,16 @@ margin:1px; Ch 8 + + + Ch 9 + + + + + Ch 10 + + - @@ -2005,6 +2014,22 @@ margin:1px; AlignHCenter|AlignVCenter|AlignCenter + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + - @@ -2069,6 +2094,22 @@ margin:1px; AlignHCenter|AlignVCenter|AlignCenter + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + - @@ -2133,6 +2174,22 @@ margin:1px; AlignHCenter|AlignVCenter|AlignCenter + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + - @@ -2197,6 +2254,22 @@ margin:1px; AlignHCenter|AlignVCenter|AlignCenter + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + - @@ -2261,6 +2334,22 @@ margin:1px; AlignHCenter|AlignVCenter|AlignCenter + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + - @@ -2325,6 +2414,22 @@ margin:1px; AlignHCenter|AlignVCenter|AlignCenter + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + @@ -2747,7 +2852,7 @@ p, li { white-space: pre-wrap; } MixerCurve QWidget -
uavobjectwidgetutils/mixercurve.h
+
mixercurve.h
1
diff --git a/ground/openpilotgcs/src/plugins/config/ccpm.ui b/ground/openpilotgcs/src/plugins/config/ccpm.ui index 1ebb2a71b..6b0cc1d83 100644 --- a/ground/openpilotgcs/src/plugins/config/ccpm.ui +++ b/ground/openpilotgcs/src/plugins/config/ccpm.ui @@ -87,7 +87,7 @@ QGroupBox::title { } - 2 + 0 diff --git a/ground/openpilotgcs/src/plugins/config/config.pro b/ground/openpilotgcs/src/plugins/config/config.pro index 8e49cb54d..af38ef4ce 100644 --- a/ground/openpilotgcs/src/plugins/config/config.pro +++ b/ground/openpilotgcs/src/plugins/config/config.pro @@ -36,7 +36,9 @@ HEADERS += configplugin.h \ cfg_vehicletypes/configfixedwingwidget.h \ cfg_vehicletypes/vehicleconfig.h \ configrevowidget.h \ - config_global.h + config_global.h \ + mixercurve.h \ + doublespindelegate.h SOURCES += configplugin.cpp \ configgadgetconfiguration.cpp \ configgadgetwidget.cpp \ @@ -67,7 +69,9 @@ SOURCES += configplugin.cpp \ cfg_vehicletypes/configfixedwingwidget.cpp \ cfg_vehicletypes/configccpmwidget.cpp \ outputchannelform.cpp \ - cfg_vehicletypes/vehicleconfig.cpp + cfg_vehicletypes/vehicleconfig.cpp \ + mixercurve.cpp \ + doublespindelegate.cpp FORMS += airframe.ui \ cc_hw_settings.ui \ pro_hw_settings.ui \ @@ -83,5 +87,6 @@ FORMS += airframe.ui \ outputchannelform.ui \ revosensors.ui \ txpid.ui \ - pipxtreme.ui + pipxtreme.ui \ + mixercurve.ui RESOURCES += configgadget.qrc diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp index 640d3a6f9..764f8800b 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp @@ -165,14 +165,14 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); UAVObjectField* field = obj->getField(QString("Mixer1Type")); QStringList list = field->getOptions(); - for (int i=0;i<8;i++) { + for (int i=0; i<(int)(VehicleConfig::CHANNEL_NUMELEM); i++) { QComboBox* qb = new QComboBox(m_aircraft->customMixerTable); qb->addItems(list); m_aircraft->customMixerTable->setCellWidget(0,i,qb); } SpinBoxDelegate *sbd = new SpinBoxDelegate(); - for (int i=1;i<8; i++) { + for (int i=1; i<(int)(VehicleConfig::CHANNEL_NUMELEM); i++) { m_aircraft->customMixerTable->setItemDelegateForRow(i, sbd); } @@ -323,7 +323,7 @@ void ConfigVehicleTypeWidget::switchAirframeType(int index) m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio); if (m_aircraft->aircraftType->findText("Custom")) { 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); } @@ -342,7 +342,7 @@ void ConfigVehicleTypeWidget::showEvent(QShowEvent *event) // the result is usually a ahrsbargraph that is way too small. m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio); 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); } @@ -651,7 +651,7 @@ void ConfigVehicleTypeWidget::updateCustomAirframeUI() } // Update the mixer table: - for (int channel=0; channel<8; channel++) { + for (int channel=0; channel<(int)(VehicleConfig::CHANNEL_NUMELEM); channel++) { UAVObjectField* field = mixer->getField(mixerTypes.at(channel)); if (field) { @@ -721,7 +721,7 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->customThrottle2Curve->getCurve()); // Update the table: - for (int channel=0; channel<8; channel++) { + for (int channel=0; channel<(int)(VehicleConfig::CHANNEL_NUMELEM); channel++) { QComboBox* q = (QComboBox*)m_aircraft->customMixerTable->cellWidget(0,channel); vconfig->setMixerType(mixer,channel, diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurve.cpp b/ground/openpilotgcs/src/plugins/config/mixercurve.cpp similarity index 70% rename from ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurve.cpp rename to ground/openpilotgcs/src/plugins/config/mixercurve.cpp index 5eb62485a..28d5e66cc 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurve.cpp +++ b/ground/openpilotgcs/src/plugins/config/mixercurve.cpp @@ -1,5 +1,33 @@ +/** + ****************************************************************************** + * + * @file mixercurve.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief A MixerCurve Gadget used to update settings in the firmware + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #include #include "mixercurve.h" +#include "doublespindelegate.h" MixerCurve::MixerCurve(QWidget *parent) : QFrame(parent), @@ -11,13 +39,18 @@ MixerCurve::MixerCurve(QWidget *parent) : m_curve = m_mixerUI->CurveWidget; m_settings = m_mixerUI->CurveSettings; - UpdateCurveSettings(); + DoubleSpinDelegate *sbd = new DoubleSpinDelegate(); + for (int i=0; isetItemDelegateForRow(i, sbd); + } - connect(m_mixerUI->CurveType, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateCurveSettings())); + UpdateCurveUI(); + + connect(m_mixerUI->CurveType, SIGNAL(currentIndexChanged(int)), this, SLOT(CurveTypeChanged())); 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(UpdateSettings())); - + connect(m_curve, SIGNAL(curveUpdated()), this, SLOT(UpdateSettingsTable())); + connect(m_settings, SIGNAL(itemChanged(QTableWidgetItem*)), 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())); @@ -35,19 +68,16 @@ void MixerCurve::setMixerType(MixerCurveType curveType) void MixerCurve::ResetCurve() { - m_curve->setMin((m_curveType == MixerCurve::MIXERCURVE_THROTTLE) ? 0.0 : -1.0); - m_curve->setMax(1.0); - m_mixerUI->CurveMin->setValue(m_curve->getMin()); m_mixerUI->CurveMax->setValue(m_curve->getMax()); m_mixerUI->CurveType->setCurrentIndex(m_mixerUI->CurveType->findText("Linear")); initLinearCurve(MixerCurveWidget::NODE_NUMELEM, m_curve->getMax(), m_curve->getMin()); - UpdateSettings(); + UpdateSettingsTable(); } -void MixerCurve::UpdateCurveSettings() +void MixerCurve::UpdateCurveUI() { //get the user settings QString curveType = m_mixerUI->CurveType->currentText(); @@ -60,7 +90,7 @@ void MixerCurve::UpdateCurveSettings() m_mixerUI->CurveStep->setMinimum(0.0); break; } - case MixerCurve::MIXERCURVEPITCH: + case MixerCurve::MIXERCURVE_PITCH: { m_mixerUI->CurveMin->setMinimum(-1.0); m_mixerUI->CurveMax->setMinimum(-1.0); @@ -68,8 +98,8 @@ void MixerCurve::UpdateCurveSettings() break; } } - m_mixerUI->CurveMin->setMaximum(1.0); - m_mixerUI->CurveMax->setMaximum(1.0); + m_mixerUI->CurveMin->setMaximum(m_curve->getMax()); + m_mixerUI->CurveMax->setMaximum(m_curve->getMax()); m_mixerUI->CurveStep->setMaximum(100.0); //set default visible @@ -168,50 +198,56 @@ void MixerCurve::GenerateCurve() } } - initCurve(&points); + setCurve(&points); } +/** + Wrappers for mixercurvewidget. + */ void MixerCurve::initCurve (const QList* points) { m_curve->setCurve(points); - UpdateSettings(); + UpdateSettingsTable(); } - QList MixerCurve::getCurve() { return m_curve->getCurve(); } - void MixerCurve::initLinearCurve(int numPoints, double maxValue, double minValue) { + setMin(minValue); + setMax(maxValue); + m_curve->initLinearCurve(numPoints, maxValue, minValue); } - void MixerCurve::setCurve(const QList* points) { m_curve->setCurve(points); - UpdateSettings(); + UpdateSettingsTable(); } - void MixerCurve::setMin(double value) { m_curve->setMin(value); + m_mixerUI->CurveMin->setMinimum(value); } - double MixerCurve::getMin() { return m_curve->getMin(); } - void MixerCurve::setMax(double value) { m_curve->setMax(value); + m_mixerUI->CurveMax->setMaximum(value); } - double MixerCurve::getMax() { return m_curve->getMax(); } +double MixerCurve::setRange(double min, double max) +{ + return m_curve->setRange(min, max); +} + double MixerCurve::getCurveMin() { @@ -227,26 +263,48 @@ double MixerCurve::getCurveStep() return m_mixerUI->CurveStep->value(); } -void MixerCurve::UpdateSettings() +void MixerCurve::UpdateSettingsTable() { QList points = m_curve->getCurve(); - int ptCnt = points.count(); + for (int i=0; iitem((ptCnt - 1) - i, 0); + QTableWidgetItem* item = m_settings->item(i, 0); if (item) - item->setText(QString().sprintf("%.2f",points.at(i))); + item->setText(QString().sprintf("%.2f",points.at( (ptCnt - 1) - i ))); } } +void MixerCurve::SettingsTableChanged() +{ + QList points; + + for (int i=0; i < m_settings->rowCount(); i++) + { + QTableWidgetItem* item = m_settings->item(i, 0); + + if (item) + points.push_front(item->text().toDouble()); + } + + m_curve->setCurve(&points); +} + +void MixerCurve::CurveTypeChanged() +{ + // setup the ui for this curvetype + UpdateCurveUI(); + + // and generate a curve based on the selection + GenerateCurve(); +} + void MixerCurve::CurveMinChanged(double value) { - //setMin(value); - // the min changed so redraw the curve // mixercurvewidget::setCurve will trim any points below min - QList points = getCurve(); + QList points = m_curve->getCurve(); points.removeFirst(); points.push_front(value); setCurve(&points); @@ -254,21 +312,14 @@ void MixerCurve::CurveMinChanged(double value) void MixerCurve::CurveMaxChanged(double value) { - //setMax(value); - // the max changed so redraw the curve // mixercurvewidget::setCurve will trim any points above max - QList points = getCurve(); + QList points = m_curve->getCurve(); points.removeLast(); points.append(value); setCurve(&points); } -double MixerCurve::setRange(double min, double max) -{ - return m_curve->setRange(min, max); -} - void MixerCurve::showEvent(QShowEvent *event) { Q_UNUSED(event); diff --git a/ground/openpilotgcs/src/plugins/config/mixercurve.h b/ground/openpilotgcs/src/plugins/config/mixercurve.h new file mode 100644 index 000000000..3133da660 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/mixercurve.h @@ -0,0 +1,97 @@ +/** + ****************************************************************************** + * + * @file mixercurve.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief A MixerCurve Gadget used to update settings in the firmware + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef MIXERCURVE_H +#define MIXERCURVE_H + +#include +#include +#include +#include + +#include "ui_mixercurve.h" +#include "mixercurvewidget.h" +#include "uavobjectwidgetutils_global.h" + + +namespace Ui { +class MixerCurve; +} + +class MixerCurve : public QFrame +{ + Q_OBJECT + +public: + explicit MixerCurve(QWidget *parent = 0); + ~MixerCurve(); + + + /* Enumeration options for ThrottleCurves */ + typedef enum { MIXERCURVE_THROTTLE=0, MIXERCURVE_PITCH=1 } MixerCurveType; + + void setMixerType(MixerCurveType curveType); + void initCurve (const QList* points); + QList getCurve(); + void initLinearCurve(int numPoints, double maxValue = 1, double minValue = 0); + void setCurve(const QList* points); + void setMin(double value); + double getMin(); + void setMax(double value); + double getMax(); + double getCurveMin(); + double getCurveMax(); + double getCurveStep(); + double setRange(double min, double max); + + +signals: + +protected: + void showEvent(QShowEvent *event); + void resizeEvent(QResizeEvent *event); + +public slots: + void ResetCurve(); + void GenerateCurve(); + void UpdateSettingsTable(); + +private slots: + void SettingsTableChanged(); + void CurveTypeChanged(); + void CurveMinChanged(double value); + void CurveMaxChanged(double value); + void UpdateCurveUI(); + +private: + Ui::MixerCurve* m_mixerUI; + MixerCurveWidget* m_curve; + QTableWidget* m_settings; + MixerCurveType m_curveType; + +}; + +#endif // MIXERCURVE_H diff --git a/ground/openpilotgcs/src/plugins/config/mixercurve.ui b/ground/openpilotgcs/src/plugins/config/mixercurve.ui new file mode 100644 index 000000000..65dbdc5f9 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/mixercurve.ui @@ -0,0 +1,378 @@ + + + MixerCurve + + + + 0 + 0 + 355 + 272 + + + + + 1 + 1 + + + + + 200 + 200 + + + + + 500 + 500 + + + + + 300 + 300 + + + + MixerCurve + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + 90 + 0 + 261 + 231 + + + + + QLayout::SetMinAndMaxSize + + + + + + 1 + 1 + + + + + 50 + 50 + + + + + 1000 + 1000 + + + + + 10 + 10 + + + + + 200 + 200 + + + + + + + + + + 0 + 0 + 91 + 271 + + + + + + 0 + 0 + 87 + 171 + + + + + 8 + + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + false + + + true + + + 5 + + + 1 + + + + 5 + + + + + 4 + + + + + 3 + + + + + 2 + + + + + 1 + + + + + Value + + + + + 1.0 + + + + + .75 + + + + + .50 + + + + + .25 + + + + + .00 + + + + + + + 0 + 180 + 87 + 20 + + + + + Linear + + + + + Log + + + + + Exp + + + + + Flat + + + + + Step + + + + + + + 0 + 200 + 87 + 23 + + + + Generate + + + + + + 0 + 240 + 87 + 23 + + + + Reset + + + + + + + 100 + 230 + 61 + 16 + + + + Min + + + + + + 100 + 250 + 61 + 20 + + + + QAbstractSpinBox::CorrectToNearestValue + + + -1.000000000000000 + + + 1.000000000000000 + + + 0.010000000000000 + + + 0.000000000000000 + + + + + + 240 + 230 + 87 + 13 + + + + Step + + + + + + 240 + 250 + 61 + 20 + + + + QAbstractSpinBox::CorrectToNearestValue + + + 50.000000000000000 + + + + + + 170 + 230 + 51 + 16 + + + + Max + + + + + + 170 + 250 + 61 + 20 + + + + QAbstractSpinBox::CorrectToNearestValue + + + 0.000000000000000 + + + 1.000000000000000 + + + 0.010000000000000 + + + 1.000000000000000 + + + groupBox + verticalGroupBox + minLabel + CurveMin + stepLabel + CurveStep + maxLabel + CurveMax + + + + MixerCurveWidget + QWidget +
uavobjectwidgetutils/mixercurvewidget.h
+ 1 +
+
+ + +
diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurve.h b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurve.h deleted file mode 100644 index faa326109..000000000 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurve.h +++ /dev/null @@ -1,68 +0,0 @@ -#ifndef MIXERCURVE_H -#define MIXERCURVE_H - -#include -#include -#include -#include - -#include "ui_mixercurve.h" -#include "mixercurvewidget.h" -#include "uavobjectwidgetutils_global.h" - -namespace Ui { -class MixerCurve; -} - -class UAVOBJECTWIDGETUTILS_EXPORT MixerCurve : public QFrame -{ - Q_OBJECT - -public: - explicit MixerCurve(QWidget *parent = 0); - ~MixerCurve(); - - - /* Enumeration options for ThrottleCurves */ - typedef enum { MIXERCURVE_THROTTLE=0, MIXERCURVEPITCH=1 } MixerCurveType; - - void setMixerType(MixerCurveType curveType); - void initCurve (const QList* points); - QList getCurve(); - void initLinearCurve(int numPoints, double maxValue = 1, double minValue = 0); - void setCurve(const QList* points); - void setMin(double value); - double getMin(); - void setMax(double value); - double getMax(); - double getCurveMin(); - double getCurveMax(); - double getCurveStep(); - double setRange(double min, double max); - - -signals: - -protected: - void showEvent(QShowEvent *event); - void resizeEvent(QResizeEvent *event); - -public slots: - void ResetCurve(); - void GenerateCurve(); - void UpdateSettings(); - -private slots: - void CurveMinChanged(double value); - void CurveMaxChanged(double value); - void UpdateCurveSettings(); - -private: - Ui::MixerCurve* m_mixerUI; - MixerCurveWidget* m_curve; - QTableWidget* m_settings; - MixerCurveType m_curveType; - -}; - -#endif // MIXERCURVE_H diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurve.ui b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurve.ui deleted file mode 100644 index 0ef6f3d80..000000000 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurve.ui +++ /dev/null @@ -1,303 +0,0 @@ - - - MixerCurve - - - - 0 - 0 - 490 - 390 - - - - - 1 - 1 - - - - - 442 - 328 - - - - - 500 - 500 - - - - - 300 - 300 - - - - MixerCurve - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - 120 - 0 - 371 - 391 - - - - - - - - 1 - 1 - - - - - 50 - 50 - - - - - 1000 - 1000 - - - - - 10 - 10 - - - - - 200 - 200 - - - - - - - - - - 0 - 0 - 121 - 391 - - - - - - - - Linear - - - - - Log - - - - - Exp - - - - - Flat - - - - - Step - - - - - - - - Generate - - - - - - - Max - - - - - - - QAbstractSpinBox::CorrectToNearestValue - - - 0.000000000000000 - - - 1.000000000000000 - - - 0.010000000000000 - - - 1.000000000000000 - - - - - - - - 8 - - - - Qt::ScrollBarAlwaysOff - - - Qt::ScrollBarAlwaysOff - - - false - - - 5 - - - 1 - - - - 5 - - - - - 4 - - - - - 3 - - - - - 2 - - - - - 1 - - - - - Value - - - - - 1.0 - - - - - .75 - - - - - .50 - - - - - .25 - - - - - .00 - - - - - - - - Min - - - - - - - QAbstractSpinBox::CorrectToNearestValue - - - -1.000000000000000 - - - 1.000000000000000 - - - 0.010000000000000 - - - 0.000000000000000 - - - - - - - Step - - - - - - - QAbstractSpinBox::CorrectToNearestValue - - - - - - - Reset - - - - - - - - - MixerCurveWidget - QWidget -
uavobjectwidgetutils/mixercurvewidget.h
- 1 -
-
- - -
diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/uavobjectwidgetutils.pro b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/uavobjectwidgetutils.pro index e4a0fee99..475526325 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/uavobjectwidgetutils.pro +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/uavobjectwidgetutils.pro @@ -10,18 +10,15 @@ HEADERS += uavobjectwidgetutils_global.h \ mixercurvewidget.h \ mixercurvepoint.h \ mixercurveline.h \ - smartsavebutton.h \ - mixercurve.h + smartsavebutton.h SOURCES += uavobjectwidgetutilsplugin.cpp \ configtaskwidget.cpp \ mixercurvewidget.cpp \ mixercurvepoint.cpp \ mixercurveline.cpp \ - smartsavebutton.cpp \ - mixercurve.cpp + smartsavebutton.cpp OTHER_FILES += UAVObjectWidgetUtils.pluginspec -FORMS += \ - mixercurve.ui +FORMS +=