##// END OF EJS Templates
Introduces NaN and zero values in data of the mock spectrogram...
Alexandre Leroux -
r922:e65d7f08d776
parent child
Show More
@@ -226,7 +226,16 struct PlottablesUpdater<T,
226 auto xIndex = 0;
226 auto xIndex = 0;
227 for (auto it = its.first; it != its.second; ++it, ++xIndex) {
227 for (auto it = its.first; it != its.second; ++it, ++xIndex) {
228 for (auto yIndex = 0; yIndex < nbY; ++yIndex) {
228 for (auto yIndex = 0; yIndex < nbY; ++yIndex) {
229 colormap->data()->setCell(xIndex, yIndex, it->value(yIndex));
229 auto value = it->value(yIndex);
230
231 colormap->data()->setCell(xIndex, yIndex, value);
232
233 // Processing spectrogram data for display in QCustomPlot
234 /// For the moment, we just make the NaN values to be transparent in the colormap
235 /// @todo ALX: complete treatments (mesh generation, etc.)
236 if (std::isnan(value)) {
237 colormap->data()->setAlpha(xIndex, yIndex, 0);
238 }
230 }
239 }
231 }
240 }
232
241
@@ -7,6 +7,7
7 #include <Data/VectorSeries.h>
7 #include <Data/VectorSeries.h>
8
8
9 #include <cmath>
9 #include <cmath>
10 #include <set>
10
11
11 #include <QFuture>
12 #include <QFuture>
12 #include <QThread>
13 #include <QThread>
@@ -19,6 +20,12 namespace {
19 /// Number of bands generated for a spectrogram
20 /// Number of bands generated for a spectrogram
20 const auto SPECTROGRAM_NUMBER_BANDS = 30;
21 const auto SPECTROGRAM_NUMBER_BANDS = 30;
21
22
23 /// Bands for which to generate NaN values for a spectrogram
24 const auto SPECTROGRAM_NAN_BANDS = std::set<int>{1, 3, 10, 20};
25
26 /// Bands for which to generate zeros for a spectrogram
27 const auto SPECTROGRAM_ZERO_BANDS = std::set<int>{2, 15, 19, 29};
28
22 /// Abstract cosinus type
29 /// Abstract cosinus type
23 struct ICosinusType {
30 struct ICosinusType {
24 virtual ~ICosinusType() = default;
31 virtual ~ICosinusType() = default;
@@ -75,8 +82,20 struct SpectrogramCosinus : public ICosinusType {
75 auto componentCount = this->componentCount();
82 auto componentCount = this->componentCount();
76 for (int i = 0; i < componentCount; ++i) {
83 for (int i = 0; i < componentCount; ++i) {
77 auto y = m_YAxisData[i];
84 auto y = m_YAxisData[i];
78 auto r = 3 * std::sqrt(x * x + y * y) + 1e-2;
85
79 auto value = 2 * x * (std::cos(r + 2) / r - std::sin(r + 2) / r);
86 double value;
87
88 if (SPECTROGRAM_ZERO_BANDS.find(y) != SPECTROGRAM_ZERO_BANDS.end()) {
89 value = 0.;
90 }
91 else if (SPECTROGRAM_NAN_BANDS.find(y) != SPECTROGRAM_NAN_BANDS.end()) {
92 value = std::numeric_limits<double>::quiet_NaN();
93 }
94 else {
95 // Generates value for non NaN/zero bands
96 auto r = 3 * std::sqrt(x * x + y * y) + 1e-2;
97 value = 2 * x * (std::cos(r + 2) / r - std::sin(r + 2) / r);
98 }
80
99
81 values[componentCount * dataIndex + i] = value;
100 values[componentCount * dataIndex + i] = value;
82 }
101 }
General Comments 0
You need to be logged in to leave comments. Login now