From f75604dde9e3a866a36c6d544708f00767c55708 2017-11-10 08:42:52 From: Alexandre Leroux Date: 2017-11-10 08:42:52 Subject: [PATCH] Handles rendering of plottables (2) Handles rendering of scalars and vectors: the method that determines colors for each component is moved from VisualizationGraphHelper to the helper created previously --- diff --git a/gui/src/Visualization/PlottablesRenderingUtils.cpp b/gui/src/Visualization/PlottablesRenderingUtils.cpp index c9b90d6..42b7ae3 100644 --- a/gui/src/Visualization/PlottablesRenderingUtils.cpp +++ b/gui/src/Visualization/PlottablesRenderingUtils.cpp @@ -1,5 +1,7 @@ #include "Visualization/PlottablesRenderingUtils.h" +#include + #include #include @@ -28,7 +30,19 @@ struct PlottablesSetter::value> > { static void setProperties(T &dataSeries, PlottablesMap &plottables) { - /// @todo ALX + // Gets the number of components of the data series + dataSeries.lockRead(); + auto componentCount = dataSeries.valuesData()->componentCount(); + dataSeries.unlock(); + + // 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 + for (auto i = 0; i < componentCount; ++i) { + auto graph = plottables.at(i); + graph->setPen(QPen{colors.at(i)}); + } } }; diff --git a/gui/src/Visualization/VisualizationGraphHelper.cpp b/gui/src/Visualization/VisualizationGraphHelper.cpp index 5ec4d51..fd92438 100644 --- a/gui/src/Visualization/VisualizationGraphHelper.cpp +++ b/gui/src/Visualization/VisualizationGraphHelper.cpp @@ -1,8 +1,6 @@ #include "Visualization/VisualizationGraphHelper.h" #include "Visualization/qcustomplot.h" -#include - #include #include #include @@ -52,13 +50,9 @@ struct PlottablesCreatorcomponentCount(); dataSeries.unlock(); - auto colors = ColorUtils::colors(Qt::blue, Qt::red, componentCount); - // For each component of the data series, creates a QCPGraph to add to the plot for (auto i = 0; i < componentCount; ++i) { auto graph = plot.addGraph(); - graph->setPen(QPen{colors.at(i)}); - result.insert({i, graph}); }