@@ -0,0 +1,33 | |||||
|
1 | #ifndef SCIQLOP_SPECTROGRAMSERIES_H | |||
|
2 | #define SCIQLOP_SPECTROGRAMSERIES_H | |||
|
3 | ||||
|
4 | #include "CoreGlobal.h" | |||
|
5 | ||||
|
6 | #include <Data/DataSeries.h> | |||
|
7 | ||||
|
8 | /** | |||
|
9 | * @brief The SpectrogramSeries class is the implementation for a data series representing a | |||
|
10 | * spectrogram. | |||
|
11 | * | |||
|
12 | * It defines values on a x-axis and a y-axis. | |||
|
13 | */ | |||
|
14 | class SCIQLOP_CORE_EXPORT SpectrogramSeries : public DataSeries<2> { | |||
|
15 | public: | |||
|
16 | /// Ctor | |||
|
17 | explicit SpectrogramSeries(std::vector<double> xAxisData, std::vector<double> yAxisData, | |||
|
18 | std::vector<double> valuesData, const Unit &xAxisUnit, | |||
|
19 | const Unit &yAxisUnit, const Unit &valuesUnit); | |||
|
20 | ||||
|
21 | /// Ctor directly with the y-axis | |||
|
22 | explicit SpectrogramSeries(std::shared_ptr<ArrayData<1> > xAxisData, const Unit &xAxisUnit, | |||
|
23 | std::shared_ptr<ArrayData<2> > valuesData, const Unit &valuesUnit, | |||
|
24 | OptionalAxis yAxis); | |||
|
25 | ||||
|
26 | /// @sa DataSeries::clone() | |||
|
27 | std::unique_ptr<IDataSeries> clone() const override; | |||
|
28 | ||||
|
29 | /// @sa DataSeries::subDataSeries() | |||
|
30 | std::shared_ptr<IDataSeries> subDataSeries(const SqpRange &range) override; | |||
|
31 | }; | |||
|
32 | ||||
|
33 | #endif // SCIQLOP_SPECTROGRAMSERIES_H |
@@ -0,0 +1,45 | |||||
|
1 | #include <Data/SpectrogramSeries.h> | |||
|
2 | ||||
|
3 | SpectrogramSeries::SpectrogramSeries(std::vector<double> xAxisData, std::vector<double> yAxisData, | |||
|
4 | std::vector<double> valuesData, const Unit &xAxisUnit, | |||
|
5 | const Unit &yAxisUnit, const Unit &valuesUnit) | |||
|
6 | : SpectrogramSeries{ | |||
|
7 | std::make_shared<ArrayData<1> >(std::move(xAxisData)), xAxisUnit, | |||
|
8 | std::make_shared<ArrayData<2> >(std::move(valuesData), yAxisData.size()), valuesUnit, | |||
|
9 | OptionalAxis{std::make_shared<ArrayData<1> >(std::move(yAxisData)), yAxisUnit}} | |||
|
10 | { | |||
|
11 | } | |||
|
12 | ||||
|
13 | SpectrogramSeries::SpectrogramSeries(std::shared_ptr<ArrayData<1> > xAxisData, | |||
|
14 | const Unit &xAxisUnit, | |||
|
15 | std::shared_ptr<ArrayData<2> > valuesData, | |||
|
16 | const Unit &valuesUnit, OptionalAxis yAxis) | |||
|
17 | : DataSeries{std::move(xAxisData), xAxisUnit, std::move(valuesData), valuesUnit, | |||
|
18 | std::move(yAxis)} | |||
|
19 | { | |||
|
20 | } | |||
|
21 | ||||
|
22 | std::unique_ptr<IDataSeries> SpectrogramSeries::clone() const | |||
|
23 | { | |||
|
24 | return std::make_unique<SpectrogramSeries>(*this); | |||
|
25 | } | |||
|
26 | ||||
|
27 | std::shared_ptr<IDataSeries> SpectrogramSeries::subDataSeries(const SqpRange &range) | |||
|
28 | { | |||
|
29 | auto subXAxisData = std::vector<double>(); | |||
|
30 | auto subValuesData = QVector<double>(); // Uses QVector to append easily values to it | |||
|
31 | this->lockRead(); | |||
|
32 | auto bounds = xAxisRange(range.m_TStart, range.m_TEnd); | |||
|
33 | for (auto it = bounds.first; it != bounds.second; ++it) { | |||
|
34 | subXAxisData.push_back(it->x()); | |||
|
35 | subValuesData.append(it->values()); | |||
|
36 | } | |||
|
37 | ||||
|
38 | auto yAxis = this->yAxis(); | |||
|
39 | this->unlock(); | |||
|
40 | ||||
|
41 | return std::make_shared<SpectrogramSeries>( | |||
|
42 | std::make_shared<ArrayData<1> >(std::move(subXAxisData)), this->xAxisUnit(), | |||
|
43 | std::make_shared<ArrayData<2> >(subValuesData.toStdVector(), yAxis.size()), | |||
|
44 | this->valuesUnit(), std::move(yAxis)); | |||
|
45 | } |
@@ -23,6 +23,7 core_sources = [ | |||||
23 | 'src/Common/StringUtils.cpp', |
|
23 | 'src/Common/StringUtils.cpp', | |
24 | 'src/Common/MimeTypesDef.cpp', |
|
24 | 'src/Common/MimeTypesDef.cpp', | |
25 | 'src/Data/ScalarSeries.cpp', |
|
25 | 'src/Data/ScalarSeries.cpp', | |
|
26 | 'src/Data/SpectrogramSeries.cpp', | |||
26 | 'src/Data/DataSeriesIterator.cpp', |
|
27 | 'src/Data/DataSeriesIterator.cpp', | |
27 | 'src/Data/ArrayDataIterator.cpp', |
|
28 | 'src/Data/ArrayDataIterator.cpp', | |
28 | 'src/Data/VectorSeries.cpp', |
|
29 | 'src/Data/VectorSeries.cpp', |
General Comments 0
You need to be logged in to leave comments.
Login now