##// END OF EJS Templates
Updates generation of spectrogram in the mock plugin to set values' unit
Alexandre Leroux -
r915:487930a9dd9f
parent child
Show More
@@ -26,9 +26,7 struct ICosinusType {
26 virtual int componentCount() const = 0;
26 virtual int componentCount() const = 0;
27 /// @return the data series created for the type
27 /// @return the data series created for the type
28 virtual std::shared_ptr<IDataSeries> createDataSeries(std::vector<double> xAxisData,
28 virtual std::shared_ptr<IDataSeries> createDataSeries(std::vector<double> xAxisData,
29 std::vector<double> valuesData,
29 std::vector<double> valuesData) const = 0;
30 Unit xAxisUnit,
31 Unit valuesUnit) const = 0;
32 /// Generates values (one value per component)
30 /// Generates values (one value per component)
33 /// @param x the x-axis data used to generate values
31 /// @param x the x-axis data used to generate values
34 /// @param values the vector in which to insert the generated values
32 /// @param values the vector in which to insert the generated values
@@ -41,11 +39,10 struct ScalarCosinus : public ICosinusType {
41 int componentCount() const override { return 1; }
39 int componentCount() const override { return 1; }
42
40
43 std::shared_ptr<IDataSeries> createDataSeries(std::vector<double> xAxisData,
41 std::shared_ptr<IDataSeries> createDataSeries(std::vector<double> xAxisData,
44 std::vector<double> valuesData, Unit xAxisUnit,
42 std::vector<double> valuesData) const override
45 Unit valuesUnit) const override
46 {
43 {
47 return std::make_shared<ScalarSeries>(std::move(xAxisData), std::move(valuesData),
44 return std::make_shared<ScalarSeries>(std::move(xAxisData), std::move(valuesData),
48 xAxisUnit, valuesUnit);
45 Unit{QStringLiteral("t"), true}, Unit{});
49 }
46 }
50
47
51 void generateValues(double x, std::vector<double> &values, int dataIndex) const override
48 void generateValues(double x, std::vector<double> &values, int dataIndex) const override
@@ -56,20 +53,21 struct ScalarCosinus : public ICosinusType {
56
53
57 struct SpectrogramCosinus : public ICosinusType {
54 struct SpectrogramCosinus : public ICosinusType {
58 /// Ctor with y-axis
55 /// Ctor with y-axis
59 explicit SpectrogramCosinus(std::vector<double> yAxisData, Unit yAxisUnit)
56 explicit SpectrogramCosinus(std::vector<double> yAxisData, Unit yAxisUnit, Unit valuesUnit)
60 : m_YAxisData{std::move(yAxisData)}, m_YAxisUnit{std::move(yAxisUnit)}
57 : m_YAxisData{std::move(yAxisData)},
58 m_YAxisUnit{std::move(yAxisUnit)},
59 m_ValuesUnit{std::move(valuesUnit)}
61 {
60 {
62 }
61 }
63
62
64 int componentCount() const override { return m_YAxisData.size(); }
63 int componentCount() const override { return m_YAxisData.size(); }
65
64
66 std::shared_ptr<IDataSeries> createDataSeries(std::vector<double> xAxisData,
65 std::shared_ptr<IDataSeries> createDataSeries(std::vector<double> xAxisData,
67 std::vector<double> valuesData, Unit xAxisUnit,
66 std::vector<double> valuesData) const override
68 Unit valuesUnit) const override
69 {
67 {
70 return std::make_shared<SpectrogramSeries>(std::move(xAxisData), m_YAxisData,
68 return std::make_shared<SpectrogramSeries>(
71 std::move(valuesData), xAxisUnit, m_YAxisUnit,
69 std::move(xAxisData), m_YAxisData, std::move(valuesData),
72 valuesUnit);
70 Unit{QStringLiteral("t"), true}, m_YAxisUnit, m_ValuesUnit);
73 }
71 }
74
72
75 void generateValues(double x, std::vector<double> &values, int dataIndex) const override
73 void generateValues(double x, std::vector<double> &values, int dataIndex) const override
@@ -86,17 +84,17 struct SpectrogramCosinus : public ICosinusType {
86
84
87 std::vector<double> m_YAxisData;
85 std::vector<double> m_YAxisData;
88 Unit m_YAxisUnit;
86 Unit m_YAxisUnit;
87 Unit m_ValuesUnit;
89 };
88 };
90
89
91 struct VectorCosinus : public ICosinusType {
90 struct VectorCosinus : public ICosinusType {
92 int componentCount() const override { return 3; }
91 int componentCount() const override { return 3; }
93
92
94 std::shared_ptr<IDataSeries> createDataSeries(std::vector<double> xAxisData,
93 std::shared_ptr<IDataSeries> createDataSeries(std::vector<double> xAxisData,
95 std::vector<double> valuesData, Unit xAxisUnit,
94 std::vector<double> valuesData) const override
96 Unit valuesUnit) const override
97 {
95 {
98 return std::make_shared<VectorSeries>(std::move(xAxisData), std::move(valuesData),
96 return std::make_shared<VectorSeries>(std::move(xAxisData), std::move(valuesData),
99 xAxisUnit, valuesUnit);
97 Unit{QStringLiteral("t"), true}, Unit{});
100 }
98 }
101
99
102 void generateValues(double x, std::vector<double> &values, int dataIndex) const override
100 void generateValues(double x, std::vector<double> &values, int dataIndex) const override
@@ -122,7 +120,8 std::unique_ptr<ICosinusType> cosinusType(const QString &type) noexcept
122 std::vector<double> yAxisData(SPECTROGRAM_NUMBER_BANDS);
120 std::vector<double> yAxisData(SPECTROGRAM_NUMBER_BANDS);
123 std::iota(yAxisData.begin(), yAxisData.end(), 0.);
121 std::iota(yAxisData.begin(), yAxisData.end(), 0.);
124
122
125 return std::make_unique<SpectrogramCosinus>(std::move(yAxisData), Unit{"eV"});
123 return std::make_unique<SpectrogramCosinus>(std::move(yAxisData), Unit{"eV"},
124 Unit{"eV/(cm^2-s-sr-eV)"});
126 }
125 }
127 else if (type.compare(QStringLiteral("vector"), Qt::CaseInsensitive) == 0) {
126 else if (type.compare(QStringLiteral("vector"), Qt::CaseInsensitive) == 0) {
128 return std::make_unique<VectorCosinus>();
127 return std::make_unique<VectorCosinus>();
@@ -226,8 +225,7 std::shared_ptr<IDataSeries> CosinusProvider::retrieveData(QUuid acqIdentifier,
226 // We can close progression beacause all data has been retrieved
225 // We can close progression beacause all data has been retrieved
227 emit dataProvidedProgress(acqIdentifier, 100);
226 emit dataProvidedProgress(acqIdentifier, 100);
228 }
227 }
229 return type->createDataSeries(std::move(xAxisData), std::move(valuesData),
228 return type->createDataSeries(std::move(xAxisData), std::move(valuesData));
230 Unit{QStringLiteral("t"), true}, Unit{});
231 }
229 }
232
230
233 void CosinusProvider::requestDataLoading(QUuid acqIdentifier,
231 void CosinusProvider::requestDataLoading(QUuid acqIdentifier,
General Comments 0
You need to be logged in to leave comments. Login now