From 487930a9dd9f0421d15349e637cd605efe054bdc 2017-11-10 08:42:51 From: Alexandre Leroux Date: 2017-11-10 08:42:51 Subject: [PATCH] Updates generation of spectrogram in the mock plugin to set values' unit --- diff --git a/plugins/mockplugin/src/CosinusProvider.cpp b/plugins/mockplugin/src/CosinusProvider.cpp index 47b029a..906a9d0 100644 --- a/plugins/mockplugin/src/CosinusProvider.cpp +++ b/plugins/mockplugin/src/CosinusProvider.cpp @@ -26,9 +26,7 @@ struct ICosinusType { virtual int componentCount() const = 0; /// @return the data series created for the type virtual std::shared_ptr createDataSeries(std::vector xAxisData, - std::vector valuesData, - Unit xAxisUnit, - Unit valuesUnit) const = 0; + std::vector valuesData) const = 0; /// Generates values (one value per component) /// @param x the x-axis data used to generate values /// @param values the vector in which to insert the generated values @@ -41,11 +39,10 @@ struct ScalarCosinus : public ICosinusType { int componentCount() const override { return 1; } std::shared_ptr createDataSeries(std::vector xAxisData, - std::vector valuesData, Unit xAxisUnit, - Unit valuesUnit) const override + std::vector valuesData) const override { return std::make_shared(std::move(xAxisData), std::move(valuesData), - xAxisUnit, valuesUnit); + Unit{QStringLiteral("t"), true}, Unit{}); } void generateValues(double x, std::vector &values, int dataIndex) const override @@ -56,20 +53,21 @@ struct ScalarCosinus : public ICosinusType { struct SpectrogramCosinus : public ICosinusType { /// Ctor with y-axis - explicit SpectrogramCosinus(std::vector yAxisData, Unit yAxisUnit) - : m_YAxisData{std::move(yAxisData)}, m_YAxisUnit{std::move(yAxisUnit)} + explicit SpectrogramCosinus(std::vector yAxisData, Unit yAxisUnit, Unit valuesUnit) + : m_YAxisData{std::move(yAxisData)}, + m_YAxisUnit{std::move(yAxisUnit)}, + m_ValuesUnit{std::move(valuesUnit)} { } int componentCount() const override { return m_YAxisData.size(); } std::shared_ptr createDataSeries(std::vector xAxisData, - std::vector valuesData, Unit xAxisUnit, - Unit valuesUnit) const override + std::vector valuesData) const override { - return std::make_shared(std::move(xAxisData), m_YAxisData, - std::move(valuesData), xAxisUnit, m_YAxisUnit, - valuesUnit); + return std::make_shared( + std::move(xAxisData), m_YAxisData, std::move(valuesData), + Unit{QStringLiteral("t"), true}, m_YAxisUnit, m_ValuesUnit); } void generateValues(double x, std::vector &values, int dataIndex) const override @@ -86,17 +84,17 @@ struct SpectrogramCosinus : public ICosinusType { std::vector m_YAxisData; Unit m_YAxisUnit; + Unit m_ValuesUnit; }; struct VectorCosinus : public ICosinusType { int componentCount() const override { return 3; } std::shared_ptr createDataSeries(std::vector xAxisData, - std::vector valuesData, Unit xAxisUnit, - Unit valuesUnit) const override + std::vector valuesData) const override { return std::make_shared(std::move(xAxisData), std::move(valuesData), - xAxisUnit, valuesUnit); + Unit{QStringLiteral("t"), true}, Unit{}); } void generateValues(double x, std::vector &values, int dataIndex) const override @@ -122,7 +120,8 @@ std::unique_ptr cosinusType(const QString &type) noexcept std::vector yAxisData(SPECTROGRAM_NUMBER_BANDS); std::iota(yAxisData.begin(), yAxisData.end(), 0.); - return std::make_unique(std::move(yAxisData), Unit{"eV"}); + return std::make_unique(std::move(yAxisData), Unit{"eV"}, + Unit{"eV/(cm^2-s-sr-eV)"}); } else if (type.compare(QStringLiteral("vector"), Qt::CaseInsensitive) == 0) { return std::make_unique(); @@ -226,8 +225,7 @@ std::shared_ptr CosinusProvider::retrieveData(QUuid acqIdentifier, // We can close progression beacause all data has been retrieved emit dataProvidedProgress(acqIdentifier, 100); } - return type->createDataSeries(std::move(xAxisData), std::move(valuesData), - Unit{QStringLiteral("t"), true}, Unit{}); + return type->createDataSeries(std::move(xAxisData), std::move(valuesData)); } void CosinusProvider::requestDataLoading(QUuid acqIdentifier,