mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +01:00
Enhancement: change mixercurve points from pass by value to pass by const ref;
This commit is contained in:
parent
5b64393f7f
commit
604a8e06cd
@ -489,7 +489,7 @@ void ConfigCcpmWidget::UpdateCurveWidgets()
|
|||||||
}
|
}
|
||||||
// Setup all Throttle1 curves for all types of airframes
|
// Setup all Throttle1 curves for all types of airframes
|
||||||
if (Changed==1)
|
if (Changed==1)
|
||||||
m_ccpm->ThrottleCurve->setCurve(curveValues);
|
m_ccpm->ThrottleCurve->setCurve(&curveValues);
|
||||||
|
|
||||||
curveValues.clear();
|
curveValues.clear();
|
||||||
Changed=0;
|
Changed=0;
|
||||||
@ -502,7 +502,7 @@ void ConfigCcpmWidget::UpdateCurveWidgets()
|
|||||||
}
|
}
|
||||||
// Setup all Throttle1 curves for all types of airframes
|
// Setup all Throttle1 curves for all types of airframes
|
||||||
if (Changed==1)
|
if (Changed==1)
|
||||||
m_ccpm->PitchCurve->setCurve(curveValues);
|
m_ccpm->PitchCurve->setCurve(&curveValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigCcpmWidget::updatePitchCurveValue(QList<double> curveValues0,double Value0)
|
void ConfigCcpmWidget::updatePitchCurveValue(QList<double> curveValues0,double Value0)
|
||||||
|
@ -274,7 +274,7 @@ QStringList ConfigVehicleTypeWidget::getChannelDescriptions()
|
|||||||
case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON:
|
case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON:
|
||||||
case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL:
|
case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL:
|
||||||
{
|
{
|
||||||
ConfigFixedWingWidget* fixedwing = new ConfigFixedWingWidget();
|
QPointer<ConfigFixedWingWidget> fixedwing = new ConfigFixedWingWidget();
|
||||||
channelDesc = fixedwing->getChannelDescriptions();
|
channelDesc = fixedwing->getChannelDescriptions();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -282,7 +282,7 @@ QStringList ConfigVehicleTypeWidget::getChannelDescriptions()
|
|||||||
// helicp
|
// helicp
|
||||||
case SystemSettings::AIRFRAMETYPE_HELICP:
|
case SystemSettings::AIRFRAMETYPE_HELICP:
|
||||||
{
|
{
|
||||||
ConfigCcpmWidget* heli = new ConfigCcpmWidget();
|
QPointer<ConfigCcpmWidget> heli = new ConfigCcpmWidget();
|
||||||
channelDesc = heli->getChannelDescriptions();
|
channelDesc = heli->getChannelDescriptions();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -300,7 +300,7 @@ QStringList ConfigVehicleTypeWidget::getChannelDescriptions()
|
|||||||
case SystemSettings::AIRFRAMETYPE_HEXACOAX:
|
case SystemSettings::AIRFRAMETYPE_HEXACOAX:
|
||||||
case SystemSettings::AIRFRAMETYPE_HEXA:
|
case SystemSettings::AIRFRAMETYPE_HEXA:
|
||||||
{
|
{
|
||||||
ConfigMultiRotorWidget* multi = new ConfigMultiRotorWidget();
|
QPointer<ConfigMultiRotorWidget> multi = new ConfigMultiRotorWidget();
|
||||||
channelDesc = multi->getChannelDescriptions();
|
channelDesc = multi->getChannelDescriptions();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -310,7 +310,7 @@ QStringList ConfigVehicleTypeWidget::getChannelDescriptions()
|
|||||||
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL:
|
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL:
|
||||||
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE:
|
case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE:
|
||||||
{
|
{
|
||||||
ConfigGroundVehicleWidget* ground = new ConfigGroundVehicleWidget();
|
QPointer<ConfigGroundVehicleWidget> ground = new ConfigGroundVehicleWidget();
|
||||||
channelDesc = ground->getChannelDescriptions();
|
channelDesc = ground->getChannelDescriptions();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -643,9 +643,9 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject * o)
|
|||||||
// is at least one of the curve values != 0?
|
// is at least one of the curve values != 0?
|
||||||
if (vconfig->isValidThrottleCurve(&curveValues)) {
|
if (vconfig->isValidThrottleCurve(&curveValues)) {
|
||||||
// yes, use the curve we just read from mixersettings
|
// yes, use the curve we just read from mixersettings
|
||||||
m_aircraft->multiThrottleCurve->initCurve(curveValues);
|
m_aircraft->multiThrottleCurve->initCurve(&curveValues);
|
||||||
m_aircraft->fixedWingThrottle->initCurve(curveValues);
|
m_aircraft->fixedWingThrottle->initCurve(&curveValues);
|
||||||
m_aircraft->groundVehicleThrottle1->initCurve(curveValues);
|
m_aircraft->groundVehicleThrottle1->initCurve(&curveValues);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// no, init a straight curve
|
// no, init a straight curve
|
||||||
@ -658,7 +658,7 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject * o)
|
|||||||
vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
|
vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues);
|
||||||
|
|
||||||
if (vconfig->isValidThrottleCurve(&curveValues)) {
|
if (vconfig->isValidThrottleCurve(&curveValues)) {
|
||||||
m_aircraft->groundVehicleThrottle2->initCurve(curveValues);
|
m_aircraft->groundVehicleThrottle2->initCurve(&curveValues);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0);
|
m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0);
|
||||||
@ -767,7 +767,7 @@ void ConfigVehicleTypeWidget::updateCustomAirframeUI()
|
|||||||
// yes, use the curve we just read from mixersettings
|
// yes, use the curve we just read from mixersettings
|
||||||
m_aircraft->customThrottle1Curve->setMin(vconfig->getCurveMin(&curveValues));
|
m_aircraft->customThrottle1Curve->setMin(vconfig->getCurveMin(&curveValues));
|
||||||
m_aircraft->customThrottle1Curve->setMax(vconfig->getCurveMax(&curveValues));
|
m_aircraft->customThrottle1Curve->setMax(vconfig->getCurveMax(&curveValues));
|
||||||
m_aircraft->customThrottle1Curve->initCurve(curveValues);
|
m_aircraft->customThrottle1Curve->initCurve(&curveValues);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// no, init a straight curve
|
// no, init a straight curve
|
||||||
@ -780,7 +780,7 @@ void ConfigVehicleTypeWidget::updateCustomAirframeUI()
|
|||||||
if (vconfig->isValidThrottleCurve(&curveValues)) {
|
if (vconfig->isValidThrottleCurve(&curveValues)) {
|
||||||
m_aircraft->customThrottle2Curve->setMin(vconfig->getCurveMin(&curveValues));
|
m_aircraft->customThrottle2Curve->setMin(vconfig->getCurveMin(&curveValues));
|
||||||
m_aircraft->customThrottle2Curve->setMax(vconfig->getCurveMax(&curveValues));
|
m_aircraft->customThrottle2Curve->setMax(vconfig->getCurveMax(&curveValues));
|
||||||
m_aircraft->customThrottle2Curve->initCurve(curveValues);
|
m_aircraft->customThrottle2Curve->initCurve(&curveValues);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_aircraft->customThrottle2Curve->initLinearCurve(curveValues.count(),(double)1);
|
m_aircraft->customThrottle2Curve->initLinearCurve(curveValues.count(),(double)1);
|
||||||
|
@ -123,9 +123,9 @@ Edge* MixerCurveWidget::getEdge(int index, Node* sourceNode, Node* destNode)
|
|||||||
If a curve exists already, resets it.
|
If a curve exists already, resets it.
|
||||||
Points should be between 0 and 1.
|
Points should be between 0 and 1.
|
||||||
*/
|
*/
|
||||||
void MixerCurveWidget::initCurve(QList<double> points)
|
void MixerCurveWidget::initCurve(const QList<double>* points)
|
||||||
{
|
{
|
||||||
if (points.length() < 2)
|
if (points->length() < 2)
|
||||||
return; // We need at least 2 points on a curve!
|
return; // We need at least 2 points on a curve!
|
||||||
|
|
||||||
// finally, set node positions
|
// finally, set node positions
|
||||||
@ -192,16 +192,16 @@ void MixerCurveWidget::initLinearCurve(int numPoints, double maxValue, double mi
|
|||||||
double val = (range * ( i / (double)(numPoints-1) ) ) + minValue;
|
double val = (range * ( i / (double)(numPoints-1) ) ) + minValue;
|
||||||
points.append(val);
|
points.append(val);
|
||||||
}
|
}
|
||||||
initCurve(points);
|
initCurve(&points);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
Setd the current curve settings
|
Setd the current curve settings
|
||||||
*/
|
*/
|
||||||
void MixerCurveWidget::setCurve(QList<double> points)
|
void MixerCurveWidget::setCurve(const QList<double>* points)
|
||||||
{
|
{
|
||||||
curveUpdating = true;
|
curveUpdating = true;
|
||||||
|
|
||||||
int ptCnt = points.count();
|
int ptCnt = points->count();
|
||||||
if (nodeList.count() != ptCnt)
|
if (nodeList.count() != ptCnt)
|
||||||
initNodes(ptCnt);
|
initNodes(ptCnt);
|
||||||
|
|
||||||
@ -211,7 +211,7 @@ void MixerCurveWidget::setCurve(QList<double> points)
|
|||||||
qreal h = plot->boundingRect().height();
|
qreal h = plot->boundingRect().height();
|
||||||
for (int i=0; i<ptCnt; i++) {
|
for (int i=0; i<ptCnt; i++) {
|
||||||
|
|
||||||
double val = (points.at(i) < curveMin) ? curveMin : (points.at(i) > curveMax) ? curveMax : points.at(i);
|
double val = (points->at(i) < curveMin) ? curveMin : (points->at(i) > curveMax) ? curveMax : points->at(i);
|
||||||
|
|
||||||
val += range;
|
val += range;
|
||||||
val -= (curveMin + range);
|
val -= (curveMin + range);
|
||||||
@ -248,7 +248,8 @@ void MixerCurveWidget::resizeEvent(QResizeEvent* event)
|
|||||||
void MixerCurveWidget::itemMoved(double itemValue)
|
void MixerCurveWidget::itemMoved(double itemValue)
|
||||||
{
|
{
|
||||||
if (!curveUpdating) {
|
if (!curveUpdating) {
|
||||||
emit curveUpdated(getCurve(), itemValue);
|
QList<double> curve = getCurve();
|
||||||
|
emit curveUpdated(&curve, itemValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,10 +44,10 @@ public:
|
|||||||
MixerCurveWidget(QWidget *parent = 0);
|
MixerCurveWidget(QWidget *parent = 0);
|
||||||
~MixerCurveWidget();
|
~MixerCurveWidget();
|
||||||
void itemMoved(double itemValue); // 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);
|
void initCurve (const QList<double>* points);
|
||||||
QList<double> getCurve();
|
QList<double> getCurve();
|
||||||
void initLinearCurve(int numPoints, double maxValue = 1, double minValue = 0);
|
void initLinearCurve(int numPoints, double maxValue = 1, double minValue = 0);
|
||||||
void setCurve(QList<double>);
|
void setCurve(const QList<double>* points);
|
||||||
void setMin(double value);
|
void setMin(double value);
|
||||||
double getMin();
|
double getMin();
|
||||||
void setMax(double value);
|
void setMax(double value);
|
||||||
@ -57,7 +57,7 @@ public:
|
|||||||
static const int NODE_NUMELEM = 5;
|
static const int NODE_NUMELEM = 5;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void curveUpdated(QList<double>, double );
|
void curveUpdated(const QList<double>* points, const double value);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user