62 scatterplot2dType = (
Scatterplot2dType)qSettings->value(
"scatterplot2dType").toUInt();
63 timeHorizon = qSettings->value(
"timeHorizon").toDouble();
65 int dataSourceCount = qSettings->value(
"dataSourceCount").toInt();
66 for (
int i = 0;
i < dataSourceCount;
i++) {
68 qSettings->beginGroup(QString(
"scatterplotDataSource") + QString().number(
i));
72 plotCurveConf->
uavObjectName = qSettings->value(
"uavObject").toString();
73 plotCurveConf->
uavFieldName = qSettings->value(
"uavField").toString();
74 plotCurveConf->
color = qSettings->value(
"color").value<QRgb>();
75 plotCurveConf->
yScalePower = qSettings->value(
"yScalePower").toInt();
76 plotCurveConf->
mathFunction = qSettings->value(
"mathFunction").toString();
77 plotCurveConf->
yMeanSamples = qSettings->value(
"yMeanSamples").toUInt();
80 qSettings->endGroup();
82 m_scatterplotSourceConfigs.append(plotCurveConf);
94 timeHorizon = options_page->spnDataSize->value();
96 ->itemData(options_page->cmbXAxisScatterplot2d->currentIndex())
99 for (
int iIndex = 0; iIndex < options_page->lst2dCurves->count(); iIndex++) {
100 QListWidgetItem *listItem = options_page->lst2dCurves->item(iIndex);
114 int rgb = varColor.toInt(&parseOK);
116 newPlotCurveConfigs->
color = QColor(Qt::black).rgb();
118 newPlotCurveConfigs->
color = (QRgb)rgb;
128 m_scatterplotSourceConfigs.append(newPlotCurveConfigs);
146 cloneObj->timeHorizon = originalScatterplot2dScopeConfig->timeHorizon;
147 cloneObj->scatterplot2dType = originalScatterplot2dScopeConfig->scatterplot2dType;
149 int scatterplotSourceCount =
150 originalScatterplot2dScopeConfig->m_scatterplotSourceConfigs.size();
152 for (
int i = 0;
i < scatterplotSourceCount;
i++) {
154 originalScatterplot2dScopeConfig->m_scatterplotSourceConfigs.at(
i);
159 newScatterplotSourceConf->
color = currentScatterplotSourceConf->
color;
164 cloneObj->m_scatterplotSourceConfigs.append(newScatterplotSourceConf);
177 qSettings->beginGroup(QString(
"plot2d"));
179 qSettings->setValue(
"timeHorizon", timeHorizon);
181 qSettings->setValue(
"scatterplot2dType", scatterplot2dType);
183 int dataSourceCount = m_scatterplotSourceConfigs.size();
184 qSettings->setValue(
"dataSourceCount", dataSourceCount);
187 for (
int i = 0;
i < dataSourceCount;
i++) {
189 qSettings->beginGroup(QString(
"scatterplotDataSource") + QString().number(
i));
191 qSettings->setValue(
"uavObject", plotCurveConf->
uavObjectName);
192 qSettings->setValue(
"uavField", plotCurveConf->
uavFieldName);
193 qSettings->setValue(
"color", plotCurveConf->
color);
194 qSettings->setValue(
"mathFunction", plotCurveConf->
mathFunction);
195 qSettings->setValue(
"yScalePower", plotCurveConf->
yScalePower);
196 qSettings->setValue(
"yMeanSamples", plotCurveConf->
yMeanSamples);
199 qSettings->endGroup();
202 qSettings->endGroup();
213 m_scatterplotSourceConfigs.clear();
214 m_scatterplotSourceConfigs.append(scatterplotSourceConfigs);
232 QRgb color = plotCurveConfig->
color;
236 switch (scatterplot2dType) {
238 scatterplotData =
new SeriesPlotData(uavObjectName, uavFieldName);
262 qDebug() <<
"Object " << scatterplotData->
getUavoName() <<
" is missing";
271 QString curveNameScaled;
273 curveNameScaled = curveName +
"(" + units +
")";
275 curveNameScaled = curveName +
"(x10^" + QString::number(plotCurveConfig->
yScalePower)
278 QString curveNameScaledMath;
280 curveNameScaledMath = curveNameScaled;
281 else if (plotCurveConfig->
mathFunction ==
"Boxcar average") {
282 curveNameScaledMath = curveNameScaled +
" (avg)";
283 }
else if (plotCurveConfig->
mathFunction ==
"Standard deviation") {
284 curveNameScaledMath = curveNameScaled +
" (std)";
291 while (scopeGadgetWidget->
getDataSources().keys().contains(curveNameScaledMath))
292 curveNameScaledMath = curveNameScaledMath +
"*";
295 QwtPlotCurve *plotCurve =
new QwtPlotCurve(curveNameScaledMath);
296 plotCurve->setPen(QPen(QBrush(QColor(color), Qt::SolidPattern), (qreal)1, Qt::SolidLine,
297 Qt::SquareCap, Qt::BevelJoin));
298 plotCurve->setSamples(*(scatterplotData->
getXData()), *(scatterplotData->
getYData()));
299 plotCurve->attach(scopeGadgetWidget);
300 scatterplotData->
setCurve(plotCurve);
308 scopeGadgetWidget->replot();
319 options_page->tabWidget2d3d->setCurrentWidget(options_page->tabPlot2d);
322 options_page->cmb2dPlotType->setCurrentIndex(
326 options_page->lst2dCurves->clear();
329 options_page->cmbXAxisScatterplot2d->setCurrentIndex(scatterplot2dType);
330 options_page->spnDataSize->setValue(timeHorizon);
337 QVariant varColor = plotData->
color;
339 QString listItemDisplayText = uavObjectName +
"." + uavFieldName;
340 options_page->lst2dCurves->addItem(listItemDisplayText);
342 options_page->lst2dCurves->count() - 1;
343 QListWidgetItem *listWidgetItem =
344 options_page->lst2dCurves->item(itemIdx);
346 bool parseOK =
false;
349 if (uavObjectName !=
"") {
351 listItemDisplayText = uavObjectName +
"." + uavFieldName;
352 rgbColor = (QRgb)varColor.toInt(&parseOK);
354 rgbColor = qRgb(255, 0, 0);
356 listItemDisplayText =
"New graph";
357 rgbColor = qRgb(255, 0, 0);
360 QColor color = QColor(rgbColor);
361 listWidgetItem->setText(listItemDisplayText);
362 listWidgetItem->setTextColor(color);
366 QVariant(uavObjectName));
368 QVariant(uavFieldName));
373 QVariant(mathFunction));
376 options_page->lst2dCurves->setCurrentRow(itemIdx);
380 options_page->lst2dCurves->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
389 scopeGadgetWidget->setMinimumSize(64, 64);
390 scopeGadgetWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
392 scopeGadgetWidget->setCanvasBackground(QColor(64, 64, 64));
395 scopeGadgetWidget->
m_grid->enableX(
true);
396 scopeGadgetWidget->
m_grid->enableY(
true);
397 scopeGadgetWidget->
m_grid->enableXMin(
false);
398 scopeGadgetWidget->
m_grid->enableYMin(
false);
399 scopeGadgetWidget->
m_grid->setMajorPen(QPen(Qt::gray, 0, Qt::DashLine));
400 scopeGadgetWidget->
m_grid->setMinorPen(QPen(Qt::lightGray, 0, Qt::DotLine));
401 scopeGadgetWidget->
m_grid->setPen(QPen(Qt::darkGray, 1, Qt::DotLine));
402 scopeGadgetWidget->
m_grid->attach(scopeGadgetWidget);
417 switch (scatterplot2dType) {
420 scopeGadgetWidget->setAxisScaleDraw(QwtPlot::xBottom,
new TimeScaleDraw());
421 uint NOW = QDateTime::currentDateTime().toTime_t();
422 scopeGadgetWidget->setAxisScale(QwtPlot::xBottom, NOW - timeHorizon / 1000, NOW);
427 scopeGadgetWidget->setAxisScaleDraw(QwtPlot::xBottom,
new QwtScaleDraw());
428 scopeGadgetWidget->setAxisScale(QwtPlot::xBottom, 0, timeHorizon);
432 scopeGadgetWidget->setAxisAutoScale(QwtPlot::yLeft,
true);
433 scopeGadgetWidget->setAxisLabelRotation(QwtPlot::xBottom, 0.0);
434 scopeGadgetWidget->setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
435 scopeGadgetWidget->axisWidget(QwtPlot::yRight)->setColorBarEnabled(
false);
436 scopeGadgetWidget->enableAxis(QwtPlot::yRight,
false);
439 QwtScaleWidget *scaleWidget = scopeGadgetWidget->axisWidget(QwtPlot::xBottom);
440 scaleWidget->setMargin(0);
443 QFont fnt(scopeGadgetWidget->axisFont(QwtPlot::xBottom));
445 scopeGadgetWidget->setAxisFont(QwtPlot::xBottom, fnt);
446 scopeGadgetWidget->setAxisFont(QwtPlot::yLeft, fnt);
447 scopeGadgetWidget->setAxisFont(QwtPlot::yRight, fnt);
This class is used to render the time values on the horizontal axis for the ChronoPlot.
virtual ScopeConfig * cloneScope(ScopeConfig *Scatterplot2dScopeConfig)
Scatterplot2dScopeConfig::cloneScope Clones scope from existing GUI configuration.
The Scatterplot2dScopeConfig class The scatterplot scope configuration.
void connectUAVO(UAVDataObject *obj)
ScopeGadgetWidget::connectUAVO Connects UAVO update signal, but only if it hasn't yet been connected...
void setXWindowSize(double val)
void setMathFunction(QString val)
Core plugin system that manages the plugins, their life cycle and their registered objects...
void setScalePower(int val)
virtual void preparePlot(ScopeGadgetWidget *)
Scatterplot2dScopeConfig::preparePlot Prepares the Qwt plot colors and axes.
QString getUavoFieldName()
void setScope(ScopeConfig *val)
QVector< double > * getYData()
void replaceScatterplotDataSource(QList< Plot2dCurveConfiguration * > scatterplotSourceConfigs)
Scatterplot2dScopeConfig::replaceScatterplotDataSource Replaces the list of scatterplot data sources...
Scatterplot2dType
The Scatterplot2dType enum Defines the different type of plots.
QString getUavoSubFieldName()
Scatterplot2dScopeConfig()
Scatterplot2dScopeConfig::Scatterplot2dScopeConfig Default constructor.
void setMeanSamples(int val)
virtual void saveConfiguration(QSettings *qSettings)
Scatterplot2dScopeConfig::saveConfiguration Saves configuration to XML file.
void addLegend()
ScopeGadgetWidget::addLegend Add legend to plot.
The TimeSeriesPlotData class The chrono plot has a variable sized buffer of data, where the data is f...
The SeriesPlotData class The sequential plot have a fixed size buffer of data. All the curves in one ...
QVector< double > * getXData()
~Scatterplot2dScopeConfig()
virtual void setGuiConfiguration(Ui::ScopeGadgetOptionsPage *options_page)
Scatterplot2dScopeConfig::setGuiConfigurationSet the GUI elements based on values from the XML settin...
void configureAxes(ScopeGadgetWidget *)
Scatterplot2dScopeConfig::configureAxes Configure the axes.
The ScopeConfig class The parent class for scope configuration classes data sources.
void insertDataSources(QString stringVal, PlotData *dataVal)
QString getUavObjectFieldUnits(QString uavObjectName, QString uavObjectFieldName)
QMap< QString, PlotData * > getDataSources()
void startTimer(int)
ScopeGadgetWidget::startTimer Starts timer.
void setCurve(QwtPlotCurve *val)
bool getHaveSubFieldFlag()
virtual void loadConfiguration(ScopeGadgetWidget *scopeGadgetWidget)
Scatterplot2dScopeConfig::loadConfiguration loads the plot configuration into the scope gadget widget...
unsigned int yMeanSamples
UAVObject * getObject(const QString &name, quint32 instId=0)
The Scatterplot2dData class Base class that keeps the data for each curve in the plot.