##// END OF EJS Templates
Few rpath fixes on dmg build...
Few rpath fixes on dmg build Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>

File last commit:

r1432:db5304cf6c8c
r1468:82521d75dedb
Show More
PlottablesRenderingUtils.cpp
136 lines | 4.2 KiB | text/x-c | CppLexer
/ gui / src / Visualization / PlottablesRenderingUtils.cpp
Alexandre Leroux
Handles rendering of plottables (1)...
r917 #include "Visualization/PlottablesRenderingUtils.h"
Alexandre Leroux
Handles rendering of plottables (2)...
r918 #include <Common/ColorUtils.h>
Switched to new TS impl but quite broken!...
r1420 #include <Variable/Variable2.h>
Alexandre Leroux
Updates PlottablesRenderingUtils to use variable's type instead of dataseries
r1282
Alexandre Leroux
Handles rendering of plottables (1)...
r917 #include <Visualization/qcustomplot.h>
Alexandre Leroux
Adds logs to axe and plottable rendering utils
r928 Q_LOGGING_CATEGORY(LOG_PlottablesRenderingUtils, "PlottablesRenderingUtils")
Switched to new TS impl but quite broken!...
r1420 namespace
{
Alexandre Leroux
Handles rendering of plottables (1)...
r917
/**
* Delegate used to set plottables properties
*/
template <typename T, typename Enabled = void>
Switched to new TS impl but quite broken!...
r1420 struct PlottablesSetter
{
static void setProperties(PlottablesMap&)
Alexandre Leroux
Handles rendering of plottables (1)...
r917 {
// Default implementation does nothing
Alexandre Leroux
Adds logs to axe and plottable rendering utils
r928 qCCritical(LOG_PlottablesRenderingUtils())
<< "Can't set plottables properties: unmanaged type of data";
Alexandre Leroux
Handles rendering of plottables (1)...
r917 }
};
/**
* Specialization of PlottablesSetter for scalars and vectors
* @sa ScalarSeries
* @sa VectorSeries
*/
template <typename T>
Switched to new TS impl but quite broken!...
r1420 struct PlottablesSetter<T,
typename std::enable_if_t<std::is_base_of<ScalarTimeSerie, T>::value
MultiComponent TS almost complete...
r1432 or std::is_base_of<VectorTimeSerie, T>::value
or std::is_base_of<MultiComponentTimeSerie, T>::value>>
Switched to new TS impl but quite broken!...
r1420 {
static void setProperties(PlottablesMap& plottables)
Alexandre Leroux
Handles rendering of plottables (1)...
r917 {
Alexandre Leroux
Updates PlottablesRenderingUtils to use variable's type instead of dataseries
r1282 // Finds the plottable with the highest index to determine the number of colors to generate
auto end = plottables.cend();
Switched to new TS impl but quite broken!...
r1420 auto maxPlottableIndexIt = std::max_element(plottables.cbegin(), end,
[](const auto& it1, const auto& it2) { return it1.first < it2.first; });
Alexandre Leroux
Updates PlottablesRenderingUtils to use variable's type instead of dataseries
r1282 auto componentCount = maxPlottableIndexIt != end ? maxPlottableIndexIt->first + 1 : 0;
Alexandre Leroux
Handles rendering of plottables (2)...
r918
// Generates colors for each component
auto colors = ColorUtils::colors(Qt::blue, Qt::red, componentCount);
// For each component of the data series, creates a QCPGraph to add to the plot
Switched to new TS impl but quite broken!...
r1420 for (auto i = 0; i < componentCount; ++i)
{
Alexandre Leroux
Updates PlottablesRenderingUtils to use variable's type instead of dataseries
r1282 auto graphIt = plottables.find(i);
Switched to new TS impl but quite broken!...
r1420 if (graphIt != end)
{
graphIt->second->setPen(QPen { colors.at(i) });
Alexandre Leroux
Updates PlottablesRenderingUtils to use variable's type instead of dataseries
r1282 }
Alexandre Leroux
Handles rendering of plottables (2)...
r918 }
Alexandre Leroux
Handles rendering of plottables (1)...
r917 }
};
Alexandre Leroux
Handles rendering properties for spectrograms...
r921 /**
* Specialization of PlottablesSetter for spectrograms
* @sa SpectrogramSeries
*/
template <typename T>
struct PlottablesSetter<T,
Switched to new TS impl but quite broken!...
r1420 typename std::enable_if_t<std::is_base_of<SpectrogramTimeSerie, T>::value>>
{
static void setProperties(PlottablesMap& plottables)
Alexandre Leroux
Handles rendering properties for spectrograms...
r921 {
// Checks that for a spectrogram there is only one plottable, that is a colormap
Switched to new TS impl but quite broken!...
r1420 if (plottables.size() != 1)
{
Alexandre Leroux
Handles rendering properties for spectrograms...
r921 return;
}
Switched to new TS impl but quite broken!...
r1420 if (auto colormap = dynamic_cast<QCPColorMap*>(plottables.begin()->second))
{
Alexandre Leroux
Handles rendering properties for spectrograms...
r921 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);
Switched to new TS impl but quite broken!...
r1420 for (auto plotElement : plotElements)
{
if (auto colorScale = dynamic_cast<QCPColorScale*>(plotElement))
{
Alexandre Leroux
Handles rendering properties for spectrograms...
r921 colormap->setColorScale(colorScale);
}
}
colormap->rescaleDataRange();
}
Switched to new TS impl but quite broken!...
r1420 else
{
Alexandre Leroux
Adds logs to axe and plottable rendering utils
r928 qCCritical(LOG_PlottablesRenderingUtils()) << "Can't get colormap of the spectrogram";
}
Alexandre Leroux
Handles rendering properties for spectrograms...
r921 }
};
Alexandre Leroux
Handles rendering of plottables (1)...
r917 /**
* Default implementation of IPlottablesHelper, which takes data series to set plottables properties
* @tparam T the data series' type
*/
template <typename T>
Switched to new TS impl but quite broken!...
r1420 struct PlottablesHelper : public IPlottablesHelper
{
void setProperties(PlottablesMap& plottables) override
Alexandre Leroux
Handles rendering of plottables (1)...
r917 {
Alexandre Leroux
Updates PlottablesRenderingUtils to use variable's type instead of dataseries
r1282 PlottablesSetter<T>::setProperties(plottables);
Alexandre Leroux
Handles rendering of plottables (1)...
r917 }
};
} // namespace
Switched to new TS impl but quite broken!...
r1420 std::unique_ptr<IPlottablesHelper> IPlottablesHelperFactory::create(Variable2& variable) noexcept
Alexandre Leroux
Handles rendering of plottables (1)...
r917 {
Switched to new TS impl but quite broken!...
r1420 switch (variable.type())
{
Alexandre Leroux
Updates PlottablesRenderingUtils to use variable's type instead of dataseries
r1282 case DataSeriesType::SCALAR:
Switched to new TS impl but quite broken!...
r1420 return std::make_unique<PlottablesHelper<ScalarTimeSerie>>();
Alexandre Leroux
Updates PlottablesRenderingUtils to use variable's type instead of dataseries
r1282 case DataSeriesType::SPECTROGRAM:
Switched to new TS impl but quite broken!...
r1420 return std::make_unique<PlottablesHelper<SpectrogramTimeSerie>>();
Alexandre Leroux
Updates PlottablesRenderingUtils to use variable's type instead of dataseries
r1282 case DataSeriesType::VECTOR:
Switched to new TS impl but quite broken!...
r1420 return std::make_unique<PlottablesHelper<VectorTimeSerie>>();
MultiComponent TS almost complete...
r1432 case DataSeriesType::MULTICOMPONENT:
return std::make_unique<PlottablesHelper<MultiComponentTimeSerie>>();
Alexandre Leroux
Updates PlottablesRenderingUtils to use variable's type instead of dataseries
r1282 default:
// Returns default helper
break;
Alexandre Leroux
Handles rendering of plottables (1)...
r917 }
Alexandre Leroux
Updates PlottablesRenderingUtils to use variable's type instead of dataseries
r1282
Removed old Variable impl...
r1422 return std::make_unique<PlottablesHelper<TimeSeries::ITimeSerie>>();
Alexandre Leroux
Handles rendering of plottables (1)...
r917 }