##// END OF EJS Templates
Initializes spectrogram management in the plugin...
Alexandre Leroux -
r899:244a7d7caff1
parent child
Show More
@@ -3,6 +3,7
3
3
4 #include <Data/DataProviderParameters.h>
4 #include <Data/DataProviderParameters.h>
5 #include <Data/ScalarSeries.h>
5 #include <Data/ScalarSeries.h>
6 #include <Data/SpectrogramSeries.h>
6 #include <Data/VectorSeries.h>
7 #include <Data/VectorSeries.h>
7
8
8 #include <cmath>
9 #include <cmath>
@@ -15,6 +16,9 Q_LOGGING_CATEGORY(LOG_CosinusProvider, "CosinusProvider")
15
16
16 namespace {
17 namespace {
17
18
19 /// Number of bands generated for a spectrogram
20 const auto SPECTROGRAM_NUMBER_BANDS = 30;
21
18 /// Abstract cosinus type
22 /// Abstract cosinus type
19 struct ICosinusType {
23 struct ICosinusType {
20 virtual ~ICosinusType() = default;
24 virtual ~ICosinusType() = default;
@@ -49,6 +53,30 struct ScalarCosinus : public ICosinusType {
49 values[dataIndex] = std::cos(x);
53 values[dataIndex] = std::cos(x);
50 }
54 }
51 };
55 };
56
57 struct SpectrogramCosinus : public ICosinusType {
58 /// Ctor with y-axis
59 explicit SpectrogramCosinus(std::vector<double> yAxisData, Unit yAxisUnit)
60 : m_YAxisData{std::move(yAxisData)}, m_YAxisUnit{std::move(yAxisUnit)}
61 {
62 }
63
64 int componentCount() const override { return m_YAxisData.size(); }
65
66 std::shared_ptr<IDataSeries> createDataSeries(std::vector<double> xAxisData,
67 std::vector<double> valuesData, Unit xAxisUnit,
68 Unit valuesUnit) const override
69 {
70 }
71
72 void generateValues(double x, std::vector<double> &values, int dataIndex) const override
73 {
74 }
75
76 std::vector<double> m_YAxisData;
77 Unit m_YAxisUnit;
78 };
79
52 struct VectorCosinus : public ICosinusType {
80 struct VectorCosinus : public ICosinusType {
53 int componentCount() const override { return 3; }
81 int componentCount() const override { return 3; }
54
82
@@ -78,6 +106,13 std::unique_ptr<ICosinusType> cosinusType(const QString &type) noexcept
78 if (type.compare(QStringLiteral("scalar"), Qt::CaseInsensitive) == 0) {
106 if (type.compare(QStringLiteral("scalar"), Qt::CaseInsensitive) == 0) {
79 return std::make_unique<ScalarCosinus>();
107 return std::make_unique<ScalarCosinus>();
80 }
108 }
109 else if (type.compare(QStringLiteral("spectrogram"), Qt::CaseInsensitive) == 0) {
110 // Generates default y-axis data for spectrogram [0., 1., 2., ...]
111 std::vector<double> yAxisData(SPECTROGRAM_NUMBER_BANDS);
112 std::iota(yAxisData.begin(), yAxisData.end(), 0.);
113
114 return std::make_unique<SpectrogramCosinus>(std::move(yAxisData), Unit{"eV"});
115 }
81 else if (type.compare(QStringLiteral("vector"), Qt::CaseInsensitive) == 0) {
116 else if (type.compare(QStringLiteral("vector"), Qt::CaseInsensitive) == 0) {
82 return std::make_unique<VectorCosinus>();
117 return std::make_unique<VectorCosinus>();
83 }
118 }
General Comments 0
You need to be logged in to leave comments. Login now