mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-06 21:54:15 +01:00
Revert "GCS/ScopePlugin: Allow SoftwareInterpolation of measurement value"
This reverts commit 4f485f7d61eddbd632b1db7d8e5a53cbfeb15a02.
This commit is contained in:
parent
98ee21ead3
commit
889a84da04
@ -49,12 +49,9 @@ PlotData::PlotData(QString p_uavObject, QString p_uavField)
|
|||||||
|
|
||||||
xData = new QVector<double>();
|
xData = new QVector<double>();
|
||||||
yData = new QVector<double>();
|
yData = new QVector<double>();
|
||||||
yDataHistory = new QVector<double>();
|
|
||||||
|
|
||||||
curve = 0;
|
curve = 0;
|
||||||
scalePower = 0;
|
scalePower = 0;
|
||||||
interpolationSamples = 1;
|
|
||||||
interpolationSum = 0.0f;
|
|
||||||
yMinimum = 0;
|
yMinimum = 0;
|
||||||
yMaximum = 0;
|
yMaximum = 0;
|
||||||
|
|
||||||
@ -81,7 +78,6 @@ PlotData::~PlotData()
|
|||||||
{
|
{
|
||||||
delete xData;
|
delete xData;
|
||||||
delete yData;
|
delete yData;
|
||||||
delete yDataHistory;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -95,13 +91,7 @@ bool SequencialPlotData::append(UAVObject* obj)
|
|||||||
if (field) {
|
if (field) {
|
||||||
|
|
||||||
//Shift data forward and put the new value at the front
|
//Shift data forward and put the new value at the front
|
||||||
yDataHistory->append( valueAsDouble(obj, field) * pow(10, scalePower));
|
yData->append( valueAsDouble(obj, field) * pow(10, scalePower));
|
||||||
interpolationSum += valueAsDouble(obj, field) * pow(10, scalePower);
|
|
||||||
if(yDataHistory->size() > interpolationSamples) {
|
|
||||||
interpolationSum -= yDataHistory->first();
|
|
||||||
yDataHistory->pop_front();
|
|
||||||
}
|
|
||||||
yData->append(interpolationSum/yDataHistory->size());
|
|
||||||
if (yData->size() > m_xWindowSize) {
|
if (yData->size() > m_xWindowSize) {
|
||||||
yData->pop_front();
|
yData->pop_front();
|
||||||
} else
|
} else
|
||||||
@ -127,15 +117,8 @@ bool ChronoPlotData::append(UAVObject* obj)
|
|||||||
//Put the new value at the front
|
//Put the new value at the front
|
||||||
QDateTime NOW = QDateTime::currentDateTime();
|
QDateTime NOW = QDateTime::currentDateTime();
|
||||||
|
|
||||||
yDataHistory->append( valueAsDouble(obj, field) * pow(10, scalePower));
|
|
||||||
interpolationSum += valueAsDouble(obj, field) * pow(10, scalePower);
|
|
||||||
if(yDataHistory->size() > interpolationSamples) {
|
|
||||||
interpolationSum -= yDataHistory->first();
|
|
||||||
yDataHistory->pop_front();
|
|
||||||
}
|
|
||||||
|
|
||||||
double valueX = NOW.toTime_t() + NOW.time().msec() / 1000.0;
|
double valueX = NOW.toTime_t() + NOW.time().msec() / 1000.0;
|
||||||
double valueY = interpolationSum/yDataHistory->size();
|
double valueY = valueAsDouble(obj, field) * pow(10, scalePower);
|
||||||
xData->append(valueX);
|
xData->append(valueX);
|
||||||
yData->append(valueY);
|
yData->append(valueY);
|
||||||
|
|
||||||
|
@ -72,15 +72,12 @@ public:
|
|||||||
QString uavSubField;
|
QString uavSubField;
|
||||||
bool haveSubField;
|
bool haveSubField;
|
||||||
int scalePower; //This is the power to which each value must be raised
|
int scalePower; //This is the power to which each value must be raised
|
||||||
int interpolationSamples;
|
|
||||||
double interpolationSum;
|
|
||||||
double yMinimum;
|
double yMinimum;
|
||||||
double yMaximum;
|
double yMaximum;
|
||||||
double m_xWindowSize;
|
double m_xWindowSize;
|
||||||
QwtPlotCurve* curve;
|
QwtPlotCurve* curve;
|
||||||
QVector<double>* xData;
|
QVector<double>* xData;
|
||||||
QVector<double>* yData;
|
QVector<double>* yData;
|
||||||
QVector<double>* yDataHistory;
|
|
||||||
|
|
||||||
virtual bool append(UAVObject* obj) = 0;
|
virtual bool append(UAVObject* obj) = 0;
|
||||||
virtual PlotType plotType() = 0;
|
virtual PlotType plotType() = 0;
|
||||||
|
@ -61,14 +61,12 @@ void ScopeGadget::loadConfiguration(IUAVGadgetConfiguration* config)
|
|||||||
QString uavObject = plotCurveConfig->uavObject;
|
QString uavObject = plotCurveConfig->uavObject;
|
||||||
QString uavField = plotCurveConfig->uavField;
|
QString uavField = plotCurveConfig->uavField;
|
||||||
int scale = plotCurveConfig->yScalePower;
|
int scale = plotCurveConfig->yScalePower;
|
||||||
int interpolation = plotCurveConfig->yInterpolationSamples;
|
|
||||||
QRgb color = plotCurveConfig->color;
|
QRgb color = plotCurveConfig->color;
|
||||||
|
|
||||||
widget->addCurvePlot(
|
widget->addCurvePlot(
|
||||||
uavObject,
|
uavObject,
|
||||||
uavField,
|
uavField,
|
||||||
scale,
|
scale,
|
||||||
interpolation,
|
|
||||||
QPen( QBrush(QColor(color),Qt::SolidPattern),
|
QPen( QBrush(QColor(color),Qt::SolidPattern),
|
||||||
// (qreal)2,
|
// (qreal)2,
|
||||||
(qreal)1,
|
(qreal)1,
|
||||||
|
@ -65,7 +65,6 @@ ScopeGadgetConfiguration::ScopeGadgetConfiguration(QString classId, QSettings* q
|
|||||||
color = qSettings->value("color").value<QRgb>();
|
color = qSettings->value("color").value<QRgb>();
|
||||||
plotCurveConf->color = color;
|
plotCurveConf->color = color;
|
||||||
plotCurveConf->yScalePower = qSettings->value("yScalePower").toInt();
|
plotCurveConf->yScalePower = qSettings->value("yScalePower").toInt();
|
||||||
plotCurveConf->yInterpolationSamples = qSettings->value("yInterpolationSamples").toInt();
|
|
||||||
plotCurveConf->yMinimum = qSettings->value("yMinimum").toDouble();
|
plotCurveConf->yMinimum = qSettings->value("yMinimum").toDouble();
|
||||||
plotCurveConf->yMaximum = qSettings->value("yMaximum").toDouble();
|
plotCurveConf->yMaximum = qSettings->value("yMaximum").toDouble();
|
||||||
|
|
||||||
@ -119,7 +118,6 @@ IUAVGadgetConfiguration *ScopeGadgetConfiguration::clone()
|
|||||||
newPlotCurveConf->uavField = currentPlotCurveConf->uavField;
|
newPlotCurveConf->uavField = currentPlotCurveConf->uavField;
|
||||||
newPlotCurveConf->color = currentPlotCurveConf->color;
|
newPlotCurveConf->color = currentPlotCurveConf->color;
|
||||||
newPlotCurveConf->yScalePower = currentPlotCurveConf->yScalePower;
|
newPlotCurveConf->yScalePower = currentPlotCurveConf->yScalePower;
|
||||||
newPlotCurveConf->yInterpolationSamples = currentPlotCurveConf->yInterpolationSamples;
|
|
||||||
newPlotCurveConf->yMinimum = currentPlotCurveConf->yMinimum;
|
newPlotCurveConf->yMinimum = currentPlotCurveConf->yMinimum;
|
||||||
newPlotCurveConf->yMaximum = currentPlotCurveConf->yMaximum;
|
newPlotCurveConf->yMaximum = currentPlotCurveConf->yMaximum;
|
||||||
|
|
||||||
@ -159,7 +157,6 @@ void ScopeGadgetConfiguration::saveConfig(QSettings* qSettings) const {
|
|||||||
qSettings->setValue("uavField", plotCurveConf->uavField);
|
qSettings->setValue("uavField", plotCurveConf->uavField);
|
||||||
qSettings->setValue("color", plotCurveConf->color);
|
qSettings->setValue("color", plotCurveConf->color);
|
||||||
qSettings->setValue("yScalePower", plotCurveConf->yScalePower);
|
qSettings->setValue("yScalePower", plotCurveConf->yScalePower);
|
||||||
qSettings->setValue("yInterpolationSamples", plotCurveConf->yInterpolationSamples);
|
|
||||||
qSettings->setValue("yMinimum", plotCurveConf->yMinimum);
|
qSettings->setValue("yMinimum", plotCurveConf->yMinimum);
|
||||||
qSettings->setValue("yMaximum", plotCurveConf->yMaximum);
|
qSettings->setValue("yMaximum", plotCurveConf->yMaximum);
|
||||||
|
|
||||||
|
@ -41,7 +41,6 @@ struct PlotCurveConfiguration
|
|||||||
QString uavField;
|
QString uavField;
|
||||||
int yScalePower; //This is the power to which each value must be raised
|
int yScalePower; //This is the power to which each value must be raised
|
||||||
QRgb color;
|
QRgb color;
|
||||||
int yInterpolationSamples;
|
|
||||||
double yMinimum;
|
double yMinimum;
|
||||||
double yMaximum;
|
double yMaximum;
|
||||||
};
|
};
|
||||||
|
@ -101,10 +101,9 @@ QWidget* ScopeGadgetOptionsPage::createPage(QWidget *parent)
|
|||||||
QString uavObject = plotData->uavObject;
|
QString uavObject = plotData->uavObject;
|
||||||
QString uavField = plotData->uavField;
|
QString uavField = plotData->uavField;
|
||||||
int scale = plotData->yScalePower;
|
int scale = plotData->yScalePower;
|
||||||
int interpolation = plotData->yInterpolationSamples;
|
|
||||||
QVariant varColor = plotData->color;
|
QVariant varColor = plotData->color;
|
||||||
|
|
||||||
addPlotCurveConfig(uavObject,uavField,scale,interpolation,varColor);
|
addPlotCurveConfig(uavObject,uavField,scale,varColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(m_config->plotCurveConfigs().count() > 0)
|
if(m_config->plotCurveConfigs().count() > 0)
|
||||||
@ -164,10 +163,6 @@ void ScopeGadgetOptionsPage::setYAxisWidgetFromPlotCurve()
|
|||||||
int rgb = varColor.toInt(&parseOK);
|
int rgb = varColor.toInt(&parseOK);
|
||||||
|
|
||||||
setButtonColor(QColor((QRgb)rgb));
|
setButtonColor(QColor((QRgb)rgb));
|
||||||
|
|
||||||
int interpolation = listItem->data(Qt::UserRole + 4).toInt(&parseOK);
|
|
||||||
if(!parseOK) interpolation = 1;
|
|
||||||
options_page->spnInterpolationSamples->setValue(interpolation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetOptionsPage::setButtonColor(const QColor &color)
|
void ScopeGadgetOptionsPage::setButtonColor(const QColor &color)
|
||||||
@ -241,10 +236,6 @@ void ScopeGadgetOptionsPage::apply()
|
|||||||
else
|
else
|
||||||
newPlotCurveConfigs->color = (QRgb)rgb;
|
newPlotCurveConfigs->color = (QRgb)rgb;
|
||||||
|
|
||||||
newPlotCurveConfigs->yInterpolationSamples = listItem->data(Qt::UserRole + 4).toInt(&parseOK);
|
|
||||||
if(!parseOK)
|
|
||||||
newPlotCurveConfigs->yInterpolationSamples = 1;
|
|
||||||
|
|
||||||
plotCurveConfigs.append(newPlotCurveConfigs);
|
plotCurveConfigs.append(newPlotCurveConfigs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +261,6 @@ void ScopeGadgetOptionsPage::on_btnAddCurve_clicked()
|
|||||||
if(!parseOK)
|
if(!parseOK)
|
||||||
scale = 0;
|
scale = 0;
|
||||||
|
|
||||||
int interpolation = options_page->spnInterpolationSamples->value();
|
|
||||||
|
|
||||||
QVariant varColor = (int)QColor(options_page->btnColor->text()).rgb();
|
QVariant varColor = (int)QColor(options_page->btnColor->text()).rgb();
|
||||||
|
|
||||||
@ -280,27 +270,27 @@ void ScopeGadgetOptionsPage::on_btnAddCurve_clicked()
|
|||||||
options_page->lstCurves->currentItem()->text() == uavObject + "." + uavField)
|
options_page->lstCurves->currentItem()->text() == uavObject + "." + uavField)
|
||||||
{
|
{
|
||||||
QListWidgetItem *listWidgetItem = options_page->lstCurves->currentItem();
|
QListWidgetItem *listWidgetItem = options_page->lstCurves->currentItem();
|
||||||
setCurvePlotProperties(listWidgetItem,uavObject,uavField,scale,interpolation,varColor);
|
setCurvePlotProperties(listWidgetItem,uavObject,uavField,scale,varColor);
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
addPlotCurveConfig(uavObject,uavField,scale,interpolation,varColor);
|
addPlotCurveConfig(uavObject,uavField,scale,varColor);
|
||||||
|
|
||||||
options_page->lstCurves->setCurrentRow(options_page->lstCurves->count() - 1);
|
options_page->lstCurves->setCurrentRow(options_page->lstCurves->count() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetOptionsPage::addPlotCurveConfig(QString uavObject, QString uavField, int scale, int interpolation, QVariant varColor)
|
void ScopeGadgetOptionsPage::addPlotCurveConfig(QString uavObject, QString uavField, int scale, QVariant varColor)
|
||||||
{
|
{
|
||||||
//Add a new curve config to the list
|
//Add a new curve config to the list
|
||||||
QString listItemDisplayText = uavObject + "." + uavField;
|
QString listItemDisplayText = uavObject + "." + uavField;
|
||||||
options_page->lstCurves->addItem(listItemDisplayText);
|
options_page->lstCurves->addItem(listItemDisplayText);
|
||||||
QListWidgetItem *listWidgetItem = options_page->lstCurves->item(options_page->lstCurves->count() - 1);
|
QListWidgetItem *listWidgetItem = options_page->lstCurves->item(options_page->lstCurves->count() - 1);
|
||||||
|
|
||||||
setCurvePlotProperties(listWidgetItem,uavObject,uavField,scale,interpolation,varColor);
|
setCurvePlotProperties(listWidgetItem,uavObject,uavField,scale,varColor);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetOptionsPage::setCurvePlotProperties(QListWidgetItem *listWidgetItem,QString uavObject, QString uavField, int scale, int interpolation, QVariant varColor)
|
void ScopeGadgetOptionsPage::setCurvePlotProperties(QListWidgetItem *listWidgetItem,QString uavObject, QString uavField, int scale, QVariant varColor)
|
||||||
{
|
{
|
||||||
bool parseOK = false;
|
bool parseOK = false;
|
||||||
|
|
||||||
@ -316,7 +306,6 @@ void ScopeGadgetOptionsPage::setCurvePlotProperties(QListWidgetItem *listWidgetI
|
|||||||
listWidgetItem->setData(Qt::UserRole + 1,QVariant(uavField));
|
listWidgetItem->setData(Qt::UserRole + 1,QVariant(uavField));
|
||||||
listWidgetItem->setData(Qt::UserRole + 2,QVariant(scale));
|
listWidgetItem->setData(Qt::UserRole + 2,QVariant(scale));
|
||||||
listWidgetItem->setData(Qt::UserRole + 3,varColor);
|
listWidgetItem->setData(Qt::UserRole + 3,varColor);
|
||||||
listWidgetItem->setData(Qt::UserRole + 4,QVariant(interpolation));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -66,8 +66,8 @@ private:
|
|||||||
Ui::ScopeGadgetOptionsPage *options_page;
|
Ui::ScopeGadgetOptionsPage *options_page;
|
||||||
ScopeGadgetConfiguration *m_config;
|
ScopeGadgetConfiguration *m_config;
|
||||||
|
|
||||||
void addPlotCurveConfig(QString uavObject, QString uavField, int scale, int interpolation, QVariant varColor);
|
void addPlotCurveConfig(QString uavObject, QString uavField, int scale, QVariant varColor);
|
||||||
void setCurvePlotProperties(QListWidgetItem *listWidgetItem, QString uavObject, QString uavField, int scale, int interpolation, QVariant varColor);
|
void setCurvePlotProperties(QListWidgetItem *listWidgetItem, QString uavObject, QString uavField, int scale, QVariant varColor);
|
||||||
void setYAxisWidgetFromPlotCurve();
|
void setYAxisWidgetFromPlotCurve();
|
||||||
void setButtonColor(const QColor &color);
|
void setButtonColor(const QColor &color);
|
||||||
|
|
||||||
|
@ -159,32 +159,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="0">
|
|
||||||
<widget class="QLabel" name="label_10">
|
|
||||||
<property name="text">
|
|
||||||
<string>Smooth Interpolation:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="9" column="1">
|
|
||||||
<widget class="QSpinBox" name="spnInterpolationSamples">
|
|
||||||
<property name="suffix">
|
|
||||||
<string> samples</string>
|
|
||||||
</property>
|
|
||||||
<property name="minimum">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>1001</number>
|
|
||||||
</property>
|
|
||||||
<property name="singleStep">
|
|
||||||
<number>10</number>
|
|
||||||
</property>
|
|
||||||
<property name="value">
|
|
||||||
<number>1</number>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -356,7 +356,7 @@ void ScopeGadgetWidget::setupChronoPlot()
|
|||||||
// scaleWidget->setMinBorderDist(0, fmw);
|
// scaleWidget->setMinBorderDist(0, fmw);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavFieldSubField, int scaleOrderFactor, int interpolationSamples, QPen pen)
|
void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavFieldSubField, int scaleOrderFactor, QPen pen)
|
||||||
{
|
{
|
||||||
PlotData* plotData;
|
PlotData* plotData;
|
||||||
|
|
||||||
@ -369,7 +369,6 @@ void ScopeGadgetWidget::addCurvePlot(QString uavObject, QString uavFieldSubField
|
|||||||
|
|
||||||
plotData->m_xWindowSize = m_xWindowSize;
|
plotData->m_xWindowSize = m_xWindowSize;
|
||||||
plotData->scalePower = scaleOrderFactor;
|
plotData->scalePower = scaleOrderFactor;
|
||||||
plotData->interpolationSamples = interpolationSamples;
|
|
||||||
|
|
||||||
//If the y-bounds are supplied, set them
|
//If the y-bounds are supplied, set them
|
||||||
if (plotData->yMinimum != plotData->yMaximum)
|
if (plotData->yMinimum != plotData->yMaximum)
|
||||||
|
@ -110,7 +110,7 @@ public:
|
|||||||
int refreshInterval(){return m_refreshInterval;}
|
int refreshInterval(){return m_refreshInterval;}
|
||||||
|
|
||||||
|
|
||||||
void addCurvePlot(QString uavObject, QString uavFieldSubField, int scaleOrderFactor = 0, int interpolationSamples = 1, QPen pen = QPen(Qt::black));
|
void addCurvePlot(QString uavObject, QString uavFieldSubField, int scaleOrderFactor = 0, QPen pen = QPen(Qt::black));
|
||||||
//void removeCurvePlot(QString uavObject, QString uavField);
|
//void removeCurvePlot(QString uavObject, QString uavField);
|
||||||
void clearCurvePlots();
|
void clearCurvePlots();
|
||||||
int csvLoggingStart();
|
int csvLoggingStart();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user