48 samplingFrequency = 100;
60 timeHorizon = qSettings->value(
"timeHorizon").toDouble();
61 samplingFrequency = qSettings->value(
"samplingFrequency").toDouble();
62 windowWidth = qSettings->value(
"windowWidth").toInt();
63 zMaximum = qSettings->value(
"zMaximum").toDouble();
66 int plot3dCurveCount = qSettings->value(
"dataSourceCount").toInt();
68 for (
int i = 0;
i < plot3dCurveCount;
i++) {
72 qSettings->beginGroup(QString(
"spectrogramDataSource") + QString().number(
i));
74 plotCurveConf->
uavObjectName = qSettings->value(
"uavObject").toString();
75 plotCurveConf->
uavFieldName = qSettings->value(
"uavField").toString();
76 plotCurveConf->
color = qSettings->value(
"color").value<QRgb>();
77 plotCurveConf->
yScalePower = qSettings->value(
"yScalePower").toInt();
78 plotCurveConf->
mathFunction = qSettings->value(
"mathFunction").toString();
79 plotCurveConf->
yMeanSamples = qSettings->value(
"yMeanSamples").toInt();
82 qSettings->endGroup();
84 m_spectrogramSourceConfigs.append(plotCurveConf);
96 windowWidth = options_page->sbSpectrogramWidth->value();
97 samplingFrequency = options_page->sbSpectrogramFrequency->value();
98 timeHorizon = options_page->sbSpectrogramTimeHorizon->value();
99 zMaximum = options_page->spnMaxSpectrogramZ->value();
101 ->itemData(options_page->cmbColorMapSpectrogram->currentIndex())
105 newPlotCurveConfigs->
uavObjectName = options_page->cmbUAVObjectsSpectrogram->currentText();
106 newPlotCurveConfigs->
uavFieldName = options_page->cmbUavoFieldSpectrogram->currentText();
107 newPlotCurveConfigs->
yScalePower = options_page->sbSpectrogramDataMultiplier->value();
108 newPlotCurveConfigs->
yMeanSamples = options_page->spnMeanSamplesSpectrogram->value();
109 newPlotCurveConfigs->
mathFunction = options_page->cmbMathFunctionSpectrogram->currentText();
111 QVariant varColor = (int)QColor(options_page->btnColorSpectrogram->text()).rgb();
112 int rgb = varColor.toInt(&parseOK);
114 newPlotCurveConfigs->
color = QColor(Qt::red).rgb();
116 newPlotCurveConfigs->
color = (QRgb)rgb;
118 m_spectrogramSourceConfigs.append(newPlotCurveConfigs);
134 cloneObj->timeHorizon = originalSpectrogramScopeConfig->timeHorizon;
135 cloneObj->colorMapType = originalSpectrogramScopeConfig->colorMapType;
137 int plotCurveCount = originalSpectrogramScopeConfig->m_spectrogramSourceConfigs.size();
139 for (
int i = 0;
i < plotCurveCount;
i++) {
141 originalSpectrogramScopeConfig->m_spectrogramSourceConfigs.at(
i);
146 newSpectrogramConf->
color = currentPlotCurveConf->
color;
151 cloneObj->m_spectrogramSourceConfigs.append(newSpectrogramConf);
164 qSettings->beginGroup(QString(
"plot3d"));
166 int plot3dCurveCount = m_spectrogramSourceConfigs.size();
169 qSettings->setValue(
"dataSourceCount", plot3dCurveCount);
171 qSettings->setValue(
"colorMap", colorMapType);
172 qSettings->setValue(
"samplingFrequency", samplingFrequency);
173 qSettings->setValue(
"timeHorizon", timeHorizon);
174 qSettings->setValue(
"windowWidth", windowWidth);
175 qSettings->setValue(
"zMaximum", zMaximum);
177 for (
int i = 0;
i < plot3dCurveCount;
i++) {
181 qSettings->beginGroup(QString(
"spectrogramDataSource") + QString().number(
i));
183 qSettings->setValue(
"uavObject", plotCurveConf->
uavObjectName);
184 qSettings->setValue(
"uavField", plotCurveConf->
uavFieldName);
185 qSettings->setValue(
"colormap", plotCurveConf->
color);
188 qSettings->endGroup();
192 qSettings->endGroup();
203 m_spectrogramSourceConfigs.clear();
204 m_spectrogramSourceConfigs.append(spectrogramSourceConfigs);
220 if (m_spectrogramSourceConfigs.length() != 1)
224 QString uavObjectName = spectrogramSourceConfigs->
uavObjectName;
225 QString uavFieldName = spectrogramSourceConfigs->
uavFieldName;
231 uavObjectName, uavFieldName, samplingFrequency, windowWidth, timeHorizon);
233 spectrogramData->
setXMaximum(samplingFrequency / 2);
242 QString waterfallName =
253 qDebug() <<
"Object " << spectrogramData->
getUavoName() <<
" is missing";
262 QString waterfallNameScaled;
264 waterfallNameScaled = waterfallName +
"(" + units +
")";
266 waterfallNameScaled = waterfallName +
"(x10^"
267 + QString::number(spectrogramSourceConfigs->
yScalePower) +
" " + units +
")";
270 QwtPlotSpectrogram *plotSpectrogram =
new QwtPlotSpectrogram(waterfallNameScaled);
271 plotSpectrogram->setRenderThreadCount(0);
272 plotSpectrogram->setRenderHint(QwtPlotItem::RenderAntialiased);
273 plotSpectrogram->setColorMap(
new ColorMap(colorMapType));
278 QDateTime::currentDateTime();
279 for (uint
i = 0;
i < timeHorizon;
i++) {
280 spectrogramData->
timeDataHistory->append(NOW.toTime_t() + NOW.time().msec() / 1000.0 +
i);
283 if (((
double)windowWidth) * timeHorizon < (double)10000000.0
285 for (uint
i = 0;
i < windowWidth * timeHorizon;
i++) {
289 qDebug() <<
"For some reason, we're trying to allocate a gigantic spectrogram. This "
290 "probably represents a problem in the configuration file. TimeHorizion: "
291 << timeHorizon <<
", windowWidth: " << windowWidth;
297 spectrogramData->
rightAxis = scopeGadgetWidget->axisWidget(QwtPlot::yRight);
298 spectrogramData->
rightAxis->setTitle(
"Intensity");
299 spectrogramData->
rightAxis->setColorBarEnabled(
true);
300 spectrogramData->
rightAxis->setColorMap(QwtInterval(0, zMaximum),
new ColorMap(colorMapType));
301 scopeGadgetWidget->setAxisScale(QwtPlot::yRight, 0, zMaximum);
302 scopeGadgetWidget->enableAxis(QwtPlot::yRight);
306 plotSpectrogram->attach(scopeGadgetWidget);
315 scopeGadgetWidget->replot();
326 options_page->tabWidget2d3d->setCurrentWidget(options_page->tabPlot3d);
329 options_page->cmb3dPlotType->setCurrentIndex(
330 options_page->cmb3dPlotType->findData(
SPECTROGRAM));
332 options_page->sbSpectrogramTimeHorizon->setValue(timeHorizon);
333 options_page->sbSpectrogramFrequency->setValue(samplingFrequency);
334 options_page->spnMaxSpectrogramZ->setValue(zMaximum);
335 options_page->cmbColorMapSpectrogram->setCurrentIndex(
336 options_page->cmbColorMapSpectrogram->findData(colorMapType));
339 int uavoIdx = options_page->cmbUAVObjectsSpectrogram->findText(plot3dData->
uavObjectName);
340 options_page->cmbUAVObjectsSpectrogram->setCurrentIndex(uavoIdx);
341 options_page->sbSpectrogramWidth->setValue(windowWidth);
344 options_page->cmbUavoFieldSpectrogram->findText(plot3dData->
uavFieldName);
345 options_page->cmbUavoFieldSpectrogram->setCurrentIndex(uavoFieldIdx);
355 scopeGadgetWidget->setMinimumSize(64, 64);
356 scopeGadgetWidget->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
357 scopeGadgetWidget->setCanvasBackground(QColor(64, 64, 64));
360 scopeGadgetWidget->
m_grid->enableX(
false);
361 scopeGadgetWidget->
m_grid->enableY(
false);
362 scopeGadgetWidget->
m_grid->enableXMin(
false);
363 scopeGadgetWidget->
m_grid->enableYMin(
false);
364 scopeGadgetWidget->
m_grid->setMajorPen(QPen(Qt::gray, 0, Qt::DashLine));
365 scopeGadgetWidget->
m_grid->setMinorPen(QPen(Qt::lightGray, 0, Qt::DotLine));
366 scopeGadgetWidget->
m_grid->setPen(QPen(Qt::darkGray, 1, Qt::DotLine));
367 scopeGadgetWidget->
m_grid->attach(scopeGadgetWidget);
380 scopeGadgetWidget->setAxisScaleDraw(QwtPlot::xBottom,
new QwtScaleDraw());
381 scopeGadgetWidget->setAxisScale(QwtPlot::xBottom, 0,
382 (
unsigned int)(samplingFrequency / 2.0 + 0.5));
383 scopeGadgetWidget->setAxisAutoScale(QwtPlot::yLeft);
384 scopeGadgetWidget->setAxisLabelRotation(QwtPlot::xBottom, 0.0);
385 scopeGadgetWidget->setAxisLabelAlignment(QwtPlot::xBottom, Qt::AlignLeft | Qt::AlignBottom);
388 QFont fnt(scopeGadgetWidget->axisFont(QwtPlot::xBottom));
390 scopeGadgetWidget->setAxisFont(QwtPlot::xBottom, fnt);
391 scopeGadgetWidget->setAxisFont(QwtPlot::yLeft, fnt);
virtual void preparePlot(ScopeGadgetWidget *)
SpectrogramScopeConfig::preparePlot Prepares the Qwt plot colors and axes.
virtual void setGuiConfiguration(Ui::ScopeGadgetOptionsPage *options_page)
SpectrogramScopeConfig::setGuiConfiguration Set the GUI elements based on values from the XML setting...
virtual void saveConfiguration(QSettings *qSettings)
SpectrogramScopeConfig::saveConfiguration Saves configuration to XML file.
The ColorMap class Defines a program-wide colormap.
~SpectrogramScopeConfig()
void connectUAVO(UAVDataObject *obj)
ScopeGadgetWidget::connectUAVO Connects UAVO update signal, but only if it hasn't yet been connected...
QVector< double > * timeDataHistory
The SpectrogramScopeConfig class The spectrogram scope configuration.
void setMathFunction(QString val)
Core plugin system that manages the plugins, their life cycle and their registered objects...
void setScalePower(int val)
void replaceSpectrogramDataSource(QList< Plot3dCurveConfiguration * > spectrogramSourceConfigs)
SpectrogramScopeConfig::replaceSpectrogramDataSource Replaces the list of spectrogram data sources...
QString getUavoFieldName()
SpectrogramScopeConfig()
SpectrogramScopeConfig::SpectrogramScopeConfig Default constructor.
void setScope(ScopeConfig *val)
virtual ScopeConfig * cloneScope(ScopeConfig *)
SpectrogramScopeConfig::cloneScope Clones scope from existing GUI configuration.
ColorMapType
The ColorMapType enum Defines the different type of color maps.
QString getUavoSubFieldName()
void setMeanSamples(int val)
QwtScaleWidget * rightAxis
virtual void setXMaximum(double val)
void setYMinimum(double val)
QVector< double > * zDataHistory
QwtMatrixRasterData * getRasterData()
void setXMinimum(double val)
virtual void loadConfiguration(ScopeGadgetWidget *scopeGadgetWidget)
SpectrogramScopeConfig::loadConfiguration loads the plot configuration into the scope gadget widget...
The ScopeConfig class The parent class for scope configuration classes data sources.
virtual void setYMaximum(double val)
virtual void setZMaximum(double val)
void configureAxes(ScopeGadgetWidget *)
SpectrogramScopeConfig::configureAxes Configure the axes.
void insertDataSources(QString stringVal, PlotData *dataVal)
QString getUavObjectFieldUnits(QString uavObjectName, QString uavObjectFieldName)
void startTimer(int)
ScopeGadgetWidget::startTimer Starts timer.
bool getHaveSubFieldFlag()
UAVObject * getObject(const QString &name, quint32 instId=0)
The SpectrogramData class The spectrogram plot has a fixed size data buffer. All the curves in one pl...
void setSpectrogram(QwtPlotSpectrogram *val)