@@ -1,6 +1,7 | |||||
1 | #include "Visualization/VisualizationGraphHelper.h" |
|
1 | #include "Visualization/VisualizationGraphHelper.h" | |
2 | #include "Visualization/qcustomplot.h" |
|
2 | #include "Visualization/qcustomplot.h" | |
3 |
|
3 | |||
|
4 | #include <Data/DataSeriesUtils.h> | |||
4 | #include <Data/ScalarSeries.h> |
|
5 | #include <Data/ScalarSeries.h> | |
5 | #include <Data/SpectrogramSeries.h> |
|
6 | #include <Data/SpectrogramSeries.h> | |
6 | #include <Data/VectorSeries.h> |
|
7 | #include <Data/VectorSeries.h> | |
@@ -203,43 +204,42 struct PlottablesUpdater<T, | |||||
203 |
|
204 | |||
204 | dataSeries.lockRead(); |
|
205 | dataSeries.lockRead(); | |
205 |
|
206 | |||
|
207 | // Processing spectrogram data for display in QCustomPlot | |||
206 | auto its = dataSeries.xAxisRange(range.m_TStart, range.m_TEnd); |
|
208 | auto its = dataSeries.xAxisRange(range.m_TStart, range.m_TEnd); | |
207 | /// @todo ALX: use iterators here |
|
|||
208 | auto yAxis = dataSeries.yAxis(); |
|
|||
209 |
|
||||
210 | // Gets properties of x-axis and y-axis to set size and range of the colormap |
|
|||
211 | auto nbX = std::distance(its.first, its.second); |
|
|||
212 | auto xMin = nbX != 0 ? its.first->x() : 0.; |
|
|||
213 | auto xMax = nbX != 0 ? (its.second - 1)->x() : 0.; |
|
|||
214 |
|
||||
215 | auto nbY = yAxis.size(); |
|
|||
216 | auto yMin = 0., yMax = 0.; |
|
|||
217 | if (nbY != 0) { |
|
|||
218 | std::tie(yMin, yMax) = yAxis.bounds(); |
|
|||
219 | } |
|
|||
220 |
|
209 | |||
221 | colormap->data()->setSize(nbX, nbY); |
|
210 | // Computes logarithmic y-axis resolution for the spectrogram | |
222 | colormap->data()->setRange(QCPRange{xMin, xMax}, QCPRange{yMin, yMax}); |
|
211 | auto yData = its.first->y(); | |
|
212 | auto yResolution = DataSeriesUtils::resolution(yData.begin(), yData.end(), true); | |||
|
213 | ||||
|
214 | // Generates mesh for colormap | |||
|
215 | auto mesh = DataSeriesUtils::regularMesh( | |||
|
216 | its.first, its.second, DataSeriesUtils::Resolution{dataSeries.xResolution()}, | |||
|
217 | yResolution); | |||
|
218 | ||||
|
219 | dataSeries.unlock(); | |||
223 |
|
220 | |||
224 | // Sets values |
|
221 | colormap->data()->setSize(mesh.m_NbX, mesh.m_NbY); | |
225 | auto xIndex = 0; |
|
222 | if (!mesh.isEmpty()) { | |
226 | for (auto it = its.first; it != its.second; ++it, ++xIndex) { |
|
223 | colormap->data()->setRange( | |
227 | for (auto yIndex = 0; yIndex < nbY; ++yIndex) { |
|
224 | QCPRange{mesh.m_XMin, mesh.xMax()}, | |
228 | auto value = it->value(yIndex); |
|
225 | // y-axis range is converted to linear values | |
|
226 | QCPRange{std::pow(10, mesh.m_YMin), std::pow(10, mesh.yMax())}); | |||
229 |
|
227 | |||
230 | colormap->data()->setCell(xIndex, yIndex, value); |
|
228 | // Sets values | |
|
229 | auto index = 0; | |||
|
230 | for (auto it = mesh.m_Data.begin(), end = mesh.m_Data.end(); it != end; ++it, ++index) { | |||
|
231 | auto xIndex = index % mesh.m_NbX; | |||
|
232 | auto yIndex = index / mesh.m_NbX; | |||
231 |
|
233 | |||
232 | // Processing spectrogram data for display in QCustomPlot |
|
234 | colormap->data()->setCell(xIndex, yIndex, *it); | |
233 | /// For the moment, we just make the NaN values to be transparent in the colormap |
|
235 | ||
234 | /// @todo ALX: complete treatments (mesh generation, etc.) |
|
236 | // Makes the NaN values to be transparent in the colormap | |
235 |
if (std::isnan( |
|
237 | if (std::isnan(*it)) { | |
236 | colormap->data()->setAlpha(xIndex, yIndex, 0); |
|
238 | colormap->data()->setAlpha(xIndex, yIndex, 0); | |
237 | } |
|
239 | } | |
238 | } |
|
240 | } | |
239 | } |
|
241 | } | |
240 |
|
242 | |||
241 | dataSeries.unlock(); |
|
|||
242 |
|
||||
243 | // Rescales axes |
|
243 | // Rescales axes | |
244 | auto plot = colormap->parentPlot(); |
|
244 | auto plot = colormap->parentPlot(); | |
245 |
|
245 |
General Comments 0
You need to be logged in to leave comments.
Login now