36 #include "qwt/src/qwt.h"
37 #include "qwt/src/qwt_color_map.h"
38 #include "qwt/src/qwt_matrix_raster_data.h"
39 #include "qwt/src/qwt_plot_spectrogram.h"
40 #include "qwt/src/qwt_scale_draw.h"
41 #include "qwt/src/qwt_scale_widget.h"
43 #define PI 3.1415926535897932384626433832795
54 unsigned int windowWidth,
double timeHorizon)
56 , spectrogram(nullptr)
60 this->samplingFrequency = samplingFrequency;
61 this->timeHorizon = timeHorizon;
62 autoscaleValueUpdated = 0;
65 rasterData =
new QwtMatrixRasterData();
72 this->windowWidth = windowWidth;
104 void SpectrogramData::resetAxisRanges()
108 rasterData->setInterval(Qt::ZAxis, QwtInterval(0,
zMaximum));
118 Q_UNUSED(plot3dData);
132 QwtInterval(0, newVal),
134 (dynamic_cast<SpectrogramScopeConfig *>(scopeConfig))->getColorMap()));
135 scopeGadgetWidget->setAxisScale(QwtPlot::yRight, 0, newVal);
149 QDateTime::currentDateTime();
163 Q_ASSERT(pm != NULL);
165 Q_ASSERT(objManager != NULL);
170 uint16_t newWindowWidth =
171 list.size() * list.front()->getField(
uavFieldName)->getNumElements();
180 newWindowWidth = field->
getValue().toDouble();
185 uint16_t valuesToProcess = newWindowWidth;
189 if (!((valuesToProcess != 0) && ((valuesToProcess & (valuesToProcess - 1)) == 0))) {
199 if (newWindowWidth != windowWidth) {
200 windowWidth = newWindowWidth;
206 qDebug() <<
"Spectrogram width adjusted to " << windowWidth;
210 Q_ASSERT(multiField);
223 && field->
getName() ==
"scale") {
224 scale = field->
getValue().toDouble();
230 int currentIndex = field->
getValue().toDouble();
231 if (currentIndex != (lastInstanceIndex + 1)) {
232 fprintf(stderr,
"Out of order index. Got %d expected %d\n",
233 currentIndex, lastInstanceIndex + 1);
235 lastInstanceIndex = -1;
244 double currentValue =
254 plotData += currentValue;
259 if (plotData.size() == valuesToProcess) {
265 if (plotData.size() != valuesToProcess) {
277 if (fft_object == NULL || fft_object->
get_length() != valuesToProcess) {
278 if (fft_object != NULL)
285 for (
int i = 0;
i < valuesToProcess;
i++) {
286 plotData[
i] *= pow(sin(
PI *
i / (valuesToProcess - 1)), 2);
289 QVector<double> fftout(valuesToProcess);
291 fft_object->
do_fft(&fftout[0], plotData.data());
299 for (
unsigned int i = 0;
i < valuesToProcess / 2;
i++) {
301 * sqrt(pow(fftout[
i], 2) + pow(fftout[valuesToProcess / 2 + i], 2))
308 for (
unsigned int i = 0;
i < windowWidth;
i++) {
311 if (plotData[
i] > rasterData->interval(Qt::ZAxis).maxValue()) {
313 rasterData->setInterval(Qt::ZAxis, QwtInterval(0, plotData[
i]));
314 autoscaleValueUpdated = plotData[
i];
327 lastInstanceIndex = -1;
341 spectrogram->detach();
348 delete spectrogramData;
QVector< UAVObject * > getObjectInstancesVector(const QString &name)
void do_fft(DataType f[], const DataType x[]) const
The ColorMap class Defines a program-wide colormap.
SpectrogramData(QString uavObject, QString uavField, double samplingFrequency, unsigned int windowWidth, double timeHorizon)
SpectrogramData.
QVector< double > * timeDataHistory
bool append(UAVObject *obj)
Append new data to the plot.
Core plugin system that manages the plugins, their life cycle and their registered objects...
QVariant getValue(int index=0) const
int getNumElements() const
QwtScaleWidget * rightAxis
virtual void setXMaximum(double val)
QVector< double > * zDataHistory
void clearPlots()
SpectrogramScopeConfig::clearPlots Clear all plot data.
The Plot3dData class Base class that keeps the data for each curve in the plot.
virtual void plotNewData(PlotData *, ScopeConfig *, ScopeGadgetWidget *)
SpectrogramScopeConfig::plotNewData Update plot with new data.
UAVObjectField * getField(const QString &name)
The ScopeConfig class The parent class for scope configuration classes data sources.
QList< UAVObjectField * > getFields()
virtual void setYMaximum(double val)
double readAndResetAutoscaleValue()
readAndResetAutoscaleFlag reads the flag value and resets it
virtual void setZMaximum(double val)
virtual void deletePlots(PlotData *)
SpectrogramScopeConfig::deletePlots Delete all plot data.
fprintf('\n\n ***dRonin log parser ***\n\n')
virtual bool readAndResetUpdatedFlag()
FieldType getType() const
virtual void removeStaleData()
Removes the old data from the buffer.