From e65d7f08d7765427604f7924123f60192b0c96e5 2017-11-10 08:42:52 From: Alexandre Leroux Date: 2017-11-10 08:42:52 Subject: [PATCH] Introduces NaN and zero values in data of the mock spectrogram - NaN are seen as blanks in display --- diff --git a/gui/src/Visualization/VisualizationGraphHelper.cpp b/gui/src/Visualization/VisualizationGraphHelper.cpp index fd92438..fe6b244 100644 --- a/gui/src/Visualization/VisualizationGraphHelper.cpp +++ b/gui/src/Visualization/VisualizationGraphHelper.cpp @@ -226,7 +226,16 @@ struct PlottablesUpdaterdata()->setCell(xIndex, yIndex, it->value(yIndex)); + auto value = it->value(yIndex); + + colormap->data()->setCell(xIndex, yIndex, value); + + // Processing spectrogram data for display in QCustomPlot + /// For the moment, we just make the NaN values to be transparent in the colormap + /// @todo ALX: complete treatments (mesh generation, etc.) + if (std::isnan(value)) { + colormap->data()->setAlpha(xIndex, yIndex, 0); + } } } diff --git a/plugins/mockplugin/src/CosinusProvider.cpp b/plugins/mockplugin/src/CosinusProvider.cpp index 906a9d0..c222340 100644 --- a/plugins/mockplugin/src/CosinusProvider.cpp +++ b/plugins/mockplugin/src/CosinusProvider.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -19,6 +20,12 @@ namespace { /// Number of bands generated for a spectrogram const auto SPECTROGRAM_NUMBER_BANDS = 30; +/// Bands for which to generate NaN values for a spectrogram +const auto SPECTROGRAM_NAN_BANDS = std::set{1, 3, 10, 20}; + +/// Bands for which to generate zeros for a spectrogram +const auto SPECTROGRAM_ZERO_BANDS = std::set{2, 15, 19, 29}; + /// Abstract cosinus type struct ICosinusType { virtual ~ICosinusType() = default; @@ -75,8 +82,20 @@ struct SpectrogramCosinus : public ICosinusType { auto componentCount = this->componentCount(); for (int i = 0; i < componentCount; ++i) { auto y = m_YAxisData[i]; - auto r = 3 * std::sqrt(x * x + y * y) + 1e-2; - auto value = 2 * x * (std::cos(r + 2) / r - std::sin(r + 2) / r); + + double value; + + if (SPECTROGRAM_ZERO_BANDS.find(y) != SPECTROGRAM_ZERO_BANDS.end()) { + value = 0.; + } + else if (SPECTROGRAM_NAN_BANDS.find(y) != SPECTROGRAM_NAN_BANDS.end()) { + value = std::numeric_limits::quiet_NaN(); + } + else { + // Generates value for non NaN/zero bands + auto r = 3 * std::sqrt(x * x + y * y) + 1e-2; + value = 2 * x * (std::cos(r + 2) / r - std::sin(r + 2) / r); + } values[componentCount * dataIndex + i] = value; }