diff --git a/gui/src/Visualization/PlottablesRenderingUtils.cpp b/gui/src/Visualization/PlottablesRenderingUtils.cpp index 42b7ae3..69aa181 100644 --- a/gui/src/Visualization/PlottablesRenderingUtils.cpp +++ b/gui/src/Visualization/PlottablesRenderingUtils.cpp @@ -3,12 +3,16 @@ #include #include +#include #include #include namespace { +/// Default gradient used for colormap +const auto DEFAULT_COLORMAP_GRADIENT = QCPColorGradient::gpJet; + /** * Delegate used to set plottables properties */ @@ -47,6 +51,40 @@ struct PlottablesSetter +struct PlottablesSetter::value> > { + static void setProperties(T &, PlottablesMap &plottables) + { + // Checks that for a spectrogram there is only one plottable, that is a colormap + if (plottables.size() != 1) { + return; + } + + if (auto colormap = dynamic_cast(plottables.begin()->second)) { + colormap->setInterpolate(false); // No value interpolation + colormap->setTightBoundary(true); + + // Finds color scale in the colormap's plot to associate with it + auto plot = colormap->parentPlot(); + auto plotElements = plot->plotLayout()->elements(false); + for (auto plotElement : plotElements) { + if (auto colorScale = dynamic_cast(plotElement)) { + colormap->setColorScale(colorScale); + } + } + + // Sets gradient used for color scale + colormap->setGradient(DEFAULT_COLORMAP_GRADIENT); + colormap->rescaleDataRange(); + } + } +}; + +/** * Default implementation of IPlottablesHelper, which takes data series to set plottables properties * @tparam T the data series' type */ @@ -70,6 +108,9 @@ IPlottablesHelperFactory::create(std::shared_ptr dataSeries) noexce if (auto scalarSeries = std::dynamic_pointer_cast(dataSeries)) { return std::make_unique >(*scalarSeries); } + else if (auto spectrogramSeries = std::dynamic_pointer_cast(dataSeries)) { + return std::make_unique >(*spectrogramSeries); + } else if (auto vectorSeries = std::dynamic_pointer_cast(dataSeries)) { return std::make_unique >(*vectorSeries); }