mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
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.
This commit is contained in:
parent
8088f7aee9
commit
0c9e5c5e66
@ -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<QDoubleSpinBox*>(editor);
|
||||
spinBox->setValue(value);
|
||||
}
|
||||
|
||||
void DoubleSpinDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||
const QModelIndex &index) const
|
||||
{
|
||||
QDoubleSpinBox *spinBox = static_cast<QDoubleSpinBox*>(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);
|
||||
}
|
||||
|
57
ground/openpilotgcs/src/plugins/config/DoubleSpinDelegate.h
Normal file
57
ground/openpilotgcs/src/plugins/config/DoubleSpinDelegate.h
Normal file
@ -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 <QDoubleSpinBox>
|
||||
#include <QItemDelegate>
|
||||
|
||||
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
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>939</width>
|
||||
<height>635</height>
|
||||
<height>657</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -74,7 +74,7 @@
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="airframesWidget">
|
||||
<property name="currentIndex">
|
||||
<number>4</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="fixedWing">
|
||||
<property name="enabled">
|
||||
@ -473,15 +473,15 @@ margin:1px;</string>
|
||||
<item>
|
||||
<widget class="MixerCurve" name="fixedWingThrottle" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
<width>450</width>
|
||||
<height>400</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
@ -496,6 +496,12 @@ margin:1px;</string>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -1618,23 +1624,10 @@ margin:1px;</string>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_24">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gvThrottleCurve1GroupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>100</verstretch>
|
||||
</sizepolicy>
|
||||
@ -1676,6 +1669,12 @@ margin:1px;</string>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gvThrottleCurve2GroupBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Rear throttle curve</string>
|
||||
</property>
|
||||
@ -1775,7 +1774,7 @@ margin:1px;</string>
|
||||
<item>
|
||||
<widget class="MixerCurve" name="customThrottle1Curve" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
@ -1800,8 +1799,8 @@ margin:1px;</string>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>200</height>
|
||||
<width>300</width>
|
||||
<height>350</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
@ -1818,7 +1817,7 @@ margin:1px;</string>
|
||||
<item>
|
||||
<widget class="MixerCurve" name="customThrottle2Curve" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
@ -1843,8 +1842,8 @@ margin:1px;</string>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>200</height>
|
||||
<width>300</width>
|
||||
<height>350</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
@ -1941,6 +1940,16 @@ margin:1px;</string>
|
||||
<string>Ch 8</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Ch 9</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Ch 10</string>
|
||||
</property>
|
||||
</column>
|
||||
<item row="0" column="0">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
@ -2005,6 +2014,22 @@ margin:1px;</string>
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</item>
|
||||
<item row="0" column="8">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</item>
|
||||
<item row="0" column="9">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
@ -2069,6 +2094,22 @@ margin:1px;</string>
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</item>
|
||||
<item row="1" column="8">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</item>
|
||||
<item row="1" column="9">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
@ -2133,6 +2174,22 @@ margin:1px;</string>
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</item>
|
||||
<item row="2" column="8">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</item>
|
||||
<item row="2" column="9">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
@ -2197,6 +2254,22 @@ margin:1px;</string>
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</item>
|
||||
<item row="3" column="8">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</item>
|
||||
<item row="3" column="9">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
@ -2261,6 +2334,22 @@ margin:1px;</string>
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</item>
|
||||
<item row="4" column="8">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</item>
|
||||
<item row="4" column="9">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
@ -2325,6 +2414,22 @@ margin:1px;</string>
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</item>
|
||||
<item row="5" column="8">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</item>
|
||||
<item row="5" column="9">
|
||||
<property name="text">
|
||||
<string>-</string>
|
||||
</property>
|
||||
<property name="textAlignment">
|
||||
<set>AlignHCenter|AlignVCenter|AlignCenter</set>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@ -2747,7 +2852,7 @@ p, li { white-space: pre-wrap; }
|
||||
<customwidget>
|
||||
<class>MixerCurve</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">uavobjectwidgetutils/mixercurve.h</header>
|
||||
<header location="global">mixercurve.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
|
@ -87,7 +87,7 @@ QGroupBox::title {
|
||||
}</string>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>2</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="BasicTab">
|
||||
<attribute name="title">
|
||||
|
@ -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
|
||||
|
@ -165,14 +165,14 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(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,
|
||||
|
@ -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 <math.h>
|
||||
#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; i<MixerCurveWidget::NODE_NUMELEM; i++) {
|
||||
m_settings->setItemDelegateForRow(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<double>* points)
|
||||
{
|
||||
m_curve->setCurve(points);
|
||||
UpdateSettings();
|
||||
UpdateSettingsTable();
|
||||
}
|
||||
|
||||
QList<double> 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<double>* 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<double> points = m_curve->getCurve();
|
||||
|
||||
int ptCnt = points.count();
|
||||
|
||||
for (int i=0; i<ptCnt; i++)
|
||||
{
|
||||
QTableWidgetItem* item = m_settings->item((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<double> 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<double> points = getCurve();
|
||||
QList<double> 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<double> points = getCurve();
|
||||
QList<double> 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);
|
97
ground/openpilotgcs/src/plugins/config/mixercurve.h
Normal file
97
ground/openpilotgcs/src/plugins/config/mixercurve.h
Normal file
@ -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 <QFrame>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QList>
|
||||
#include <QTableWidget>
|
||||
|
||||
#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<double>* points);
|
||||
QList<double> getCurve();
|
||||
void initLinearCurve(int numPoints, double maxValue = 1, double minValue = 0);
|
||||
void setCurve(const QList<double>* 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
|
378
ground/openpilotgcs/src/plugins/config/mixercurve.ui
Normal file
378
ground/openpilotgcs/src/plugins/config/mixercurve.ui
Normal file
@ -0,0 +1,378 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MixerCurve</class>
|
||||
<widget class="QFrame" name="MixerCurve">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>355</width>
|
||||
<height>272</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>500</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MixerCurve</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<widget class="QGroupBox" name="verticalGroupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>90</x>
|
||||
<y>0</y>
|
||||
<width>261</width>
|
||||
<height>231</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMinAndMaxSize</enum>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<widget class="MixerCurveWidget" name="CurveWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>1000</width>
|
||||
<height>1000</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sizeIncrement">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>91</width>
|
||||
<height>271</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QTableWidget" name="CurveSettings">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>87</width>
|
||||
<height>171</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="autoScroll">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="alternatingRowColors">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="rowCount">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<row>
|
||||
<property name="text">
|
||||
<string>5</string>
|
||||
</property>
|
||||
</row>
|
||||
<row>
|
||||
<property name="text">
|
||||
<string>4</string>
|
||||
</property>
|
||||
</row>
|
||||
<row>
|
||||
<property name="text">
|
||||
<string>3</string>
|
||||
</property>
|
||||
</row>
|
||||
<row>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</row>
|
||||
<row>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</row>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Value</string>
|
||||
</property>
|
||||
</column>
|
||||
<item row="0" column="0">
|
||||
<property name="text">
|
||||
<string>1.0</string>
|
||||
</property>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<property name="text">
|
||||
<string>.75</string>
|
||||
</property>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<property name="text">
|
||||
<string>.50</string>
|
||||
</property>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<property name="text">
|
||||
<string>.25</string>
|
||||
</property>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<property name="text">
|
||||
<string>.00</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="CurveType">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>180</y>
|
||||
<width>87</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Linear</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Log</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Exp</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Flat</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Step</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="GenerateCurve">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>200</y>
|
||||
<width>87</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Generate</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QPushButton" name="ResetCurve">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>240</y>
|
||||
<width>87</width>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QLabel" name="minLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>230</y>
|
||||
<width>61</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Min</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="CurveMin">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>100</x>
|
||||
<y>250</y>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="correctionMode">
|
||||
<enum>QAbstractSpinBox::CorrectToNearestValue</enum>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-1.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="stepLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>230</y>
|
||||
<width>87</width>
|
||||
<height>13</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Step</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="CurveStep">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>240</x>
|
||||
<y>250</y>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="correctionMode">
|
||||
<enum>QAbstractSpinBox::CorrectToNearestValue</enum>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>50.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="maxLabel">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>170</x>
|
||||
<y>230</y>
|
||||
<width>51</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Max</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QDoubleSpinBox" name="CurveMax">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>170</x>
|
||||
<y>250</y>
|
||||
<width>61</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="correctionMode">
|
||||
<enum>QAbstractSpinBox::CorrectToNearestValue</enum>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
<zorder>groupBox</zorder>
|
||||
<zorder>verticalGroupBox</zorder>
|
||||
<zorder>minLabel</zorder>
|
||||
<zorder>CurveMin</zorder>
|
||||
<zorder>stepLabel</zorder>
|
||||
<zorder>CurveStep</zorder>
|
||||
<zorder>maxLabel</zorder>
|
||||
<zorder>CurveMax</zorder>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>MixerCurveWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">uavobjectwidgetutils/mixercurvewidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,68 +0,0 @@
|
||||
#ifndef MIXERCURVE_H
|
||||
#define MIXERCURVE_H
|
||||
|
||||
#include <QFrame>
|
||||
#include <QtGui/QWidget>
|
||||
#include <QList>
|
||||
#include <QTableWidget>
|
||||
|
||||
#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<double>* points);
|
||||
QList<double> getCurve();
|
||||
void initLinearCurve(int numPoints, double maxValue = 1, double minValue = 0);
|
||||
void setCurve(const QList<double>* 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
|
@ -1,303 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MixerCurve</class>
|
||||
<widget class="QFrame" name="MixerCurve">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>490</width>
|
||||
<height>390</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>442</width>
|
||||
<height>328</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>500</width>
|
||||
<height>500</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>300</width>
|
||||
<height>300</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MixerCurve</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<widget class="QWidget" name="verticalLayoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>0</y>
|
||||
<width>371</width>
|
||||
<height>391</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="MixerCurveWidget" name="CurveWidget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>1</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>50</width>
|
||||
<height>50</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>1000</width>
|
||||
<height>1000</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="sizeIncrement">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>200</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>121</width>
|
||||
<height>391</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QComboBox" name="CurveType">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Linear</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Log</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Exp</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Flat</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>Step</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="GenerateCurve">
|
||||
<property name="text">
|
||||
<string>Generate</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="maxLabel">
|
||||
<property name="text">
|
||||
<string>Max</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="CurveMax">
|
||||
<property name="correctionMode">
|
||||
<enum>QAbstractSpinBox::CorrectToNearestValue</enum>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTableWidget" name="CurveSettings">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="verticalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="horizontalScrollBarPolicy">
|
||||
<enum>Qt::ScrollBarAlwaysOff</enum>
|
||||
</property>
|
||||
<property name="autoScroll">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="rowCount">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="columnCount">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<row>
|
||||
<property name="text">
|
||||
<string>5</string>
|
||||
</property>
|
||||
</row>
|
||||
<row>
|
||||
<property name="text">
|
||||
<string>4</string>
|
||||
</property>
|
||||
</row>
|
||||
<row>
|
||||
<property name="text">
|
||||
<string>3</string>
|
||||
</property>
|
||||
</row>
|
||||
<row>
|
||||
<property name="text">
|
||||
<string>2</string>
|
||||
</property>
|
||||
</row>
|
||||
<row>
|
||||
<property name="text">
|
||||
<string>1</string>
|
||||
</property>
|
||||
</row>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Value</string>
|
||||
</property>
|
||||
</column>
|
||||
<item row="0" column="0">
|
||||
<property name="text">
|
||||
<string>1.0</string>
|
||||
</property>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<property name="text">
|
||||
<string>.75</string>
|
||||
</property>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<property name="text">
|
||||
<string>.50</string>
|
||||
</property>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<property name="text">
|
||||
<string>.25</string>
|
||||
</property>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<property name="text">
|
||||
<string>.00</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="minLabel">
|
||||
<property name="text">
|
||||
<string>Min</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="CurveMin">
|
||||
<property name="correctionMode">
|
||||
<enum>QAbstractSpinBox::CorrectToNearestValue</enum>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<double>-1.000000000000000</double>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<property name="singleStep">
|
||||
<double>0.010000000000000</double>
|
||||
</property>
|
||||
<property name="value">
|
||||
<double>0.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="stepLabel">
|
||||
<property name="text">
|
||||
<string>Step</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDoubleSpinBox" name="CurveStep">
|
||||
<property name="correctionMode">
|
||||
<enum>QAbstractSpinBox::CorrectToNearestValue</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="ResetCurve">
|
||||
<property name="text">
|
||||
<string>Reset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>MixerCurveWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">uavobjectwidgetutils/mixercurvewidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -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 +=
|
||||
|
Loading…
x
Reference in New Issue
Block a user