mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-03-15 07:29:15 +01:00
OP-138 Added Reset button for curves, and display of value when moving a curve point.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1816 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
b385ce961e
commit
b5eb89ed5e
@ -69,7 +69,7 @@
|
||||
<item>
|
||||
<widget class="QStackedWidget" name="airframesWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="fixedWing">
|
||||
<property name="enabled">
|
||||
@ -402,6 +402,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="fwThrottleCurveItemValue">
|
||||
<property name="text">
|
||||
<string>Val: 0.00</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
@ -616,7 +623,7 @@
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="resetMultiThrottleon_2">
|
||||
<widget class="QPushButton" name="mrThrottleCurveReset">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
@ -651,6 +658,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="mrThrottleCurveItemValue">
|
||||
<property name="text">
|
||||
<string>Val: 0.00</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
@ -823,6 +837,9 @@
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="multiMotor5">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
@ -845,6 +862,9 @@
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="multiMotor6">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
@ -861,6 +881,9 @@
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="multiMotor7">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
@ -877,6 +900,9 @@
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="multiMotor8">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>8</pointsize>
|
||||
@ -1294,12 +1320,12 @@
|
||||
<slot>setNum(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>127</x>
|
||||
<y>105</y>
|
||||
<x>309</x>
|
||||
<y>277</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>127</x>
|
||||
<y>105</y>
|
||||
<x>341</x>
|
||||
<y>300</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
@ -1310,12 +1336,12 @@
|
||||
<slot>setNum(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>127</x>
|
||||
<y>105</y>
|
||||
<x>236</x>
|
||||
<y>277</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>127</x>
|
||||
<y>105</y>
|
||||
<x>283</x>
|
||||
<y>300</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
@ -1326,12 +1352,12 @@
|
||||
<slot>setNum(int)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>214</x>
|
||||
<y>157</y>
|
||||
<x>118</x>
|
||||
<y>96</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>144</x>
|
||||
<y>161</y>
|
||||
<x>118</x>
|
||||
<y>96</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
|
@ -101,6 +101,11 @@ ConfigAirframeWidget::ConfigAirframeWidget(QWidget *parent) : ConfigTaskWidget(p
|
||||
connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), this, SLOT(switchAirframeType(int)));
|
||||
requestAircraftUpdate();
|
||||
|
||||
connect(m_aircraft->fwThrottleReset, SIGNAL(clicked()), this, SLOT(resetFwMixer()));
|
||||
connect(m_aircraft->mrThrottleCurveReset, SIGNAL(clicked()), this, SLOT(resetMrMixer()));
|
||||
connect(m_aircraft->fixedWingThrottle, SIGNAL(curveUpdated(QList<double>,double)), this, SLOT(updateFwThrottleCurveValue(QList<double>,double)));
|
||||
connect(m_aircraft->multiThrottleCurve, SIGNAL(curveUpdated(QList<double>,double)), this, SLOT(updateMrThrottleCurveValue(QList<double>,double)));
|
||||
|
||||
// connect(m_aircraft->fwAileron1Channel, SIGNAL(currentIndexChanged(int)), this, SLOT(toggleAileron2(int)));
|
||||
// connect(m_aircraft->fwElevator1Channel, SIGNAL(currentIndexChanged(int)), this, SLOT(toggleElevator2(int)));
|
||||
|
||||
@ -165,6 +170,58 @@ void ConfigAirframeWidget::toggleElevator2(int index)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Resets Fixed wing throttle mixer
|
||||
*/
|
||||
void ConfigAirframeWidget::resetFwMixer()
|
||||
{
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
UAVObjectField* field = obj->getField(QString("ThrottleCurve1"));
|
||||
resetMixer(m_aircraft->fixedWingThrottle, field->getNumElements());
|
||||
}
|
||||
|
||||
/**
|
||||
Resets Multirotor throttle mixer
|
||||
*/
|
||||
void ConfigAirframeWidget::resetMrMixer()
|
||||
{
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
UAVObjectField* field = obj->getField(QString("ThrottleCurve1"));
|
||||
resetMixer(m_aircraft->multiThrottleCurve, field->getNumElements());
|
||||
}
|
||||
|
||||
/**
|
||||
Resets a mixer curve
|
||||
*/
|
||||
void ConfigAirframeWidget::resetMixer(MixerCurveWidget *mixer, int numElements)
|
||||
{
|
||||
QList<double> curveValues;
|
||||
for (double i=0; i<numElements; i++) {
|
||||
curveValues.append(i/(numElements-1));
|
||||
}
|
||||
// Setup all Throttle1 curves for all types of airframes
|
||||
mixer->initCurve(curveValues);
|
||||
}
|
||||
|
||||
/**
|
||||
Updates the currently moved throttle curve item value
|
||||
*/
|
||||
void ConfigAirframeWidget::updateFwThrottleCurveValue(QList<double> list, double value)
|
||||
{
|
||||
Q_UNUSED(list);
|
||||
m_aircraft->fwThrottleCurveItemValue->setText(QString().sprintf("Val: %.2f",value));
|
||||
}
|
||||
|
||||
/**
|
||||
Updates the currently moved throttle curve item value
|
||||
*/
|
||||
void ConfigAirframeWidget::updateMrThrottleCurveValue(QList<double> list, double value)
|
||||
{
|
||||
Q_UNUSED(list);
|
||||
m_aircraft->mrThrottleCurveItemValue->setText(QString().sprintf("Val: %.2f",value));
|
||||
}
|
||||
|
||||
|
||||
/**************************
|
||||
* Aircraft settings
|
||||
**************************/
|
||||
@ -173,11 +230,8 @@ void ConfigAirframeWidget::toggleElevator2(int index)
|
||||
*/
|
||||
void ConfigAirframeWidget::requestAircraftUpdate()
|
||||
{
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
|
||||
// Get the Airframe type from the system settings:
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("SystemSettings")));
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("SystemSettings")));
|
||||
Q_ASSERT(obj);
|
||||
obj->requestUpdate();
|
||||
UAVObjectField *field = obj->getField(QString("AirframeType"));
|
||||
@ -187,7 +241,7 @@ void ConfigAirframeWidget::requestAircraftUpdate()
|
||||
QString frameType = field->getValue().toString();
|
||||
setupAirframeUI(frameType);
|
||||
|
||||
obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("MixerSettings")));
|
||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(obj);
|
||||
obj->requestUpdate();
|
||||
field = obj->getField(QString("ThrottleCurve1"));
|
||||
@ -211,7 +265,7 @@ void ConfigAirframeWidget::requestAircraftUpdate()
|
||||
// Load the Settings for fixed wing frames:
|
||||
if (frameType.startsWith("FixedWing")) {
|
||||
// Then retrieve how channels are setup
|
||||
obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("ActuatorSettings")));
|
||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
||||
Q_ASSERT(obj);
|
||||
field = obj->getField(QString("FixedWingThrottle"));
|
||||
Q_ASSERT(field);
|
||||
@ -265,7 +319,7 @@ void ConfigAirframeWidget::requestAircraftUpdate()
|
||||
// Retrieve Multirotor settings
|
||||
//////////////////////////////////////////////////////////////////
|
||||
|
||||
obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("ActuatorSettings")));
|
||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
||||
Q_ASSERT(obj);
|
||||
if (frameType == "QuadP") {
|
||||
// Motors 1/2/3/4 are: N / E / S / W
|
||||
@ -344,7 +398,7 @@ void ConfigAirframeWidget::requestAircraftUpdate()
|
||||
m_aircraft->multiMotor8->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
||||
}
|
||||
|
||||
obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("MixerSettings")));
|
||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
Q_ASSERT(obj);
|
||||
// Now, retrieve the Feedforward values:
|
||||
field = obj->getField(QString("FeedForward"));
|
||||
@ -1022,9 +1076,7 @@ void ConfigAirframeWidget::saveAircraftUpdate()
|
||||
{
|
||||
// Send update so that the latest value is saved
|
||||
sendAircraftUpdate();
|
||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(objManager->getObject(QString("SystemSettings")));
|
||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("SystemSettings")));
|
||||
Q_ASSERT(obj);
|
||||
saveObjectToSD(obj);
|
||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||
|
@ -53,6 +53,7 @@ private:
|
||||
bool setupQuad(bool pLayout);
|
||||
|
||||
void resetField(UAVObjectField * field);
|
||||
void resetMixer (MixerCurveWidget *mixer, int numElements);
|
||||
void resetActuators();
|
||||
//void setMixerChannel(int channelNumber, bool channelIsMotor, QList<double> vector);
|
||||
void setupQuadMotor(int channel, double roll, double pitch, double yaw);
|
||||
@ -69,6 +70,10 @@ private slots:
|
||||
void toggleAileron2(int index);
|
||||
void toggleElevator2(int index);
|
||||
void switchAirframeType(int index);
|
||||
void resetFwMixer();
|
||||
void resetMrMixer();
|
||||
void updateFwThrottleCurveValue(QList<double> list, double value);
|
||||
void updateMrThrottleCurveValue(QList<double> list, double value);
|
||||
|
||||
protected:
|
||||
void showEvent(QShowEvent *event);
|
||||
|
@ -102,17 +102,17 @@ void Node::verticalMove(bool flag){
|
||||
QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
|
||||
QPointF newPos = value.toPointF();
|
||||
double h = graph->sceneRect().height();
|
||||
switch (change) {
|
||||
case ItemPositionChange: {
|
||||
if (!vertical)
|
||||
break;
|
||||
// Force node to move vertically
|
||||
QPointF newPos = value.toPointF();
|
||||
newPos.setX(pos().x());
|
||||
// Stay inside graph
|
||||
if (newPos.y() < 0)
|
||||
newPos.setY(0);
|
||||
double h = graph->sceneRect().height();
|
||||
//qDebug() << h << " - " << newPos.y();
|
||||
if (newPos.y() > h)
|
||||
newPos.setY(h);
|
||||
@ -121,7 +121,7 @@ QVariant Node::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
case ItemPositionHasChanged:
|
||||
foreach (Edge *edge, edgeList)
|
||||
edge->adjust();
|
||||
graph->itemMoved();
|
||||
graph->itemMoved((h-newPos.y())/h);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -152,8 +152,8 @@ void MixerCurveWidget::resizeEvent(QResizeEvent* event)
|
||||
|
||||
|
||||
|
||||
void MixerCurveWidget::itemMoved()
|
||||
void MixerCurveWidget::itemMoved(double itemValue)
|
||||
{
|
||||
QList<double> list = getCurve();
|
||||
emit curveUpdated(list);
|
||||
emit curveUpdated(list, itemValue);
|
||||
}
|
||||
|
@ -42,13 +42,12 @@ class MixerCurveWidget : public QGraphicsView
|
||||
public:
|
||||
MixerCurveWidget(QWidget *parent = 0);
|
||||
~MixerCurveWidget();
|
||||
void itemMoved(); // Callback when a point is moved, to be updated
|
||||
void itemMoved(double itemValue); // Callback when a point is moved, to be updated
|
||||
void initCurve (QList<double> points);
|
||||
QList<double> getCurve();
|
||||
|
||||
signals:
|
||||
// Shall create a "curve updated" signal here, maybe ?
|
||||
void curveUpdated(QList<double> );
|
||||
void curveUpdated(QList<double>, double );
|
||||
|
||||
private slots:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user