47 maxNumberOfBins = 1000;
57 binWidth = qSettings->value(
"binWidth").toDouble();
62 maxNumberOfBins = qSettings->value(
"maxNumberOfBins").toInt();
66 int dataSourceCount = qSettings->value(
"dataSourceCount").toInt();
67 for (
int i = 0;
i < dataSourceCount;
i++) {
69 qSettings->beginGroup(QString(
"histogramDataSource") + QString().number(
i));
73 plotCurveConf->
uavObjectName = qSettings->value(
"uavObject").toString();
74 plotCurveConf->
uavFieldName = qSettings->value(
"uavField").toString();
75 plotCurveConf->
color = qSettings->value(
"color").value<QRgb>();
76 plotCurveConf->
yScalePower = qSettings->value(
"yScalePower").toInt();
77 plotCurveConf->
mathFunction = qSettings->value(
"mathFunction").toString();
78 plotCurveConf->
yMeanSamples = qSettings->value(
"yMeanSamples").toUInt();
81 qSettings->endGroup();
83 m_HistogramSourceConfigs.append(plotCurveConf);
95 binWidth = options_page->spnBinWidth->value();
96 maxNumberOfBins = options_page->spnMaxNumBins->value();
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_HistogramSourceConfigs.append(newPlotCurveConfigs);
145 cloneObj->binWidth = originalHistogramScopeConfig->binWidth;
146 cloneObj->maxNumberOfBins = originalHistogramScopeConfig->maxNumberOfBins;
149 int histogramSourceCount = originalHistogramScopeConfig->m_HistogramSourceConfigs.size();
151 for (
int i = 0;
i < histogramSourceCount;
i++) {
153 originalHistogramScopeConfig->m_HistogramSourceConfigs.at(
i);
158 newHistogramSourceConf->
color = currentHistogramSourceConf->
color;
163 cloneObj->m_HistogramSourceConfigs.append(newHistogramSourceConf);
176 qSettings->beginGroup(QString(
"plot2d"));
178 qSettings->setValue(
"plot2dType",
HISTOGRAM);
179 qSettings->setValue(
"binWidth", binWidth);
180 qSettings->setValue(
"maxNumberOfBins", maxNumberOfBins);
182 int dataSourceCount = m_HistogramSourceConfigs.size();
183 qSettings->setValue(
"dataSourceCount", dataSourceCount);
186 for (
int i = 0;
i < dataSourceCount;
i++) {
188 qSettings->beginGroup(QString(
"histogramDataSource") + QString().number(
i));
190 qSettings->setValue(
"uavObject", plotCurveConf->
uavObjectName);
191 qSettings->setValue(
"uavField", plotCurveConf->
uavFieldName);
192 qSettings->setValue(
"color", plotCurveConf->
color);
193 qSettings->setValue(
"mathFunction", plotCurveConf->
mathFunction);
194 qSettings->setValue(
"yScalePower", plotCurveConf->
yScalePower);
195 qSettings->setValue(
"yMeanSamples", plotCurveConf->
yMeanSamples);
198 qSettings->endGroup();
202 qSettings->endGroup();
212 m_HistogramSourceConfigs.clear();
213 m_HistogramSourceConfigs.append(histogramSourceConfigs);
229 QRgb color = histogramDataSourceConfig->
color;
238 histogramDataSourceConfig->
uavFieldName, binWidth, maxNumberOfBins);
256 qDebug() <<
"Object " << histogramData->
getUavoName() <<
" is missing";
265 QString histogramNameScaled;
267 histogramNameScaled = curveName +
"(" + units +
")";
269 histogramNameScaled = curveName +
"(x10^"
270 + QString::number(histogramDataSourceConfig->
yScalePower) +
" " + units +
")";
272 while (scopeGadgetWidget->
getDataSources().keys().contains(histogramNameScaled))
273 histogramNameScaled = histogramNameScaled +
"*";
276 QwtPlotHistogram *plotHistogram =
new QwtPlotHistogram(histogramNameScaled);
277 plotHistogram->setStyle(QwtPlotHistogram::Columns);
278 plotHistogram->setBrush(QBrush(QColor(color)));
281 plotHistogram->attach(scopeGadgetWidget);
290 scopeGadgetWidget->replot();
301 options_page->tabWidget2d3d->setCurrentWidget(options_page->tabPlot2d);
304 options_page->cmb2dPlotType->setCurrentIndex(options_page->cmb2dPlotType->findData(
HISTOGRAM));
307 options_page->lst2dCurves->clear();
310 options_page->spnMaxNumBins->setValue(maxNumberOfBins);
311 options_page->spnBinWidth->setValue(binWidth);
318 QVariant varColor = dataSource->
color;
320 QString listItemDisplayText = uavObjectName +
"." + uavFieldName;
321 options_page->lst2dCurves->addItem(listItemDisplayText);
323 options_page->lst2dCurves->count() - 1;
324 QListWidgetItem *listWidgetItem =
325 options_page->lst2dCurves->item(itemIdx);
327 bool parseOK =
false;
330 if (uavObjectName !=
"") {
332 listItemDisplayText = uavObjectName +
"." + uavFieldName;
333 rgbColor = (QRgb)varColor.toInt(&parseOK);
335 rgbColor = qRgb(255, 0, 0);
337 listItemDisplayText =
"New graph";
338 rgbColor = qRgb(255, 0, 0);
341 QColor color = QColor(rgbColor);
342 listWidgetItem->setText(listItemDisplayText);
343 listWidgetItem->setTextColor(color);
348 QVariant(uavObjectName));
350 QVariant(uavFieldName));
355 QVariant(mathFunction));
358 options_page->lst2dCurves->setCurrentRow(itemIdx);
362 options_page->lst2dCurves->setCurrentRow(0, QItemSelectionModel::ClearAndSelect);
371 scopeGadgetWidget->setMinimumSize(64, 64);
372 scopeGadgetWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
374 scopeGadgetWidget->setCanvasBackground(QColor(64, 64, 64));
376 scopeGadgetWidget->plotLayout()->setAlignCanvasToScales(
false);
378 scopeGadgetWidget->
m_grid->enableX(
false);
379 scopeGadgetWidget->
m_grid->enableY(
true);
380 scopeGadgetWidget->
m_grid->enableXMin(
false);
381 scopeGadgetWidget->
m_grid->enableYMin(
false);
382 scopeGadgetWidget->
m_grid->setMajorPen(QPen(Qt::black, 0, Qt::DotLine));
383 scopeGadgetWidget->
m_grid->setMinorPen(QPen(Qt::lightGray, 0, Qt::DotLine));
384 scopeGadgetWidget->
m_grid->setPen(QPen(Qt::darkGray, 1, Qt::DotLine));
385 scopeGadgetWidget->
m_grid->attach(scopeGadgetWidget);
401 scopeGadgetWidget->setAxisScaleDraw(QwtPlot::xBottom,
new QwtScaleDraw());
402 scopeGadgetWidget->setAxisAutoScale(QwtPlot::xBottom);
403 scopeGadgetWidget->setAxisLabelRotation(QwtPlot::xBottom, 0.0);
404 scopeGadgetWidget->setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
405 scopeGadgetWidget->axisWidget(QwtPlot::yRight)->setColorBarEnabled(
false);
406 scopeGadgetWidget->enableAxis(QwtPlot::yRight,
false);
409 QwtScaleWidget *scaleWidget = scopeGadgetWidget->axisWidget(QwtPlot::xBottom);
410 scaleWidget->setMargin(0);
413 QFont fnt(scopeGadgetWidget->axisFont(QwtPlot::xBottom));
415 scopeGadgetWidget->setAxisFont(QwtPlot::xBottom, fnt);
416 scopeGadgetWidget->setAxisFont(QwtPlot::yLeft, fnt);
void setHistogram(QwtPlotHistogram *val)
void connectUAVO(UAVDataObject *obj)
ScopeGadgetWidget::connectUAVO Connects UAVO update signal, but only if it hasn't yet been connected...
virtual void loadConfiguration(ScopeGadgetWidget *scopeGadgetWidget)
HistogramScopeConfig::loadConfiguration loads the plot configuration into the scope gadget widget...
void setMathFunction(QString val)
Core plugin system that manages the plugins, their life cycle and their registered objects...
void setScalePower(int val)
HistogramScopeConfig()
HistogramScopeConfig::HistogramScopeConfig Default constructor.
QString getUavoFieldName()
void setScope(ScopeConfig *val)
QString getUavoSubFieldName()
void setMeanSamples(int val)
void addLegend()
ScopeGadgetWidget::addLegend Add legend to plot.
virtual void saveConfiguration(QSettings *qSettings)
HistogramScopeConfig::saveConfiguration Saves configuration to XML file.
virtual ScopeConfig * cloneScope(ScopeConfig *histogramSourceConfigs)
HistogramScopeConfig::cloneScope Clones scope from existing GUI configuration.
QwtIntervalSeriesData * getIntervalSeriesData()
PlotDimensions m_plotDimensions
virtual void preparePlot(ScopeGadgetWidget *)
HistogramScopeConfig::preparePlot Prepares the Qwt plot colors and axes.
The ScopeConfig class The parent class for scope configuration classes data sources.
The HistogramData class The histogram plot has a variable sized buffer of data, where the data is for...
The HistogramScopeConfig class The histogram scope configuration.
void insertDataSources(QString stringVal, PlotData *dataVal)
QString getUavObjectFieldUnits(QString uavObjectName, QString uavObjectFieldName)
QMap< QString, PlotData * > getDataSources()
virtual void setGuiConfiguration(Ui::ScopeGadgetOptionsPage *options_page)
HistogramScopeConfig::setGuiConfiguration Set the GUI elements based on values from the XML settings ...
void startTimer(int)
ScopeGadgetWidget::startTimer Starts timer.
bool getHaveSubFieldFlag()
unsigned int yMeanSamples
UAVObject * getObject(const QString &name, quint32 instId=0)
void replaceHistogramDataSource(QList< Plot2dCurveConfiguration * > histogramSourceConfigs)
HistogramScopeConfig::replaceHistogramSource Replaces the list of histogram data sources.
void configureAxes(ScopeGadgetWidget *)
HistogramScopeConfig::configureAxes Configure the axes.