From 54e194b00c35fb5f769eda61234c1b4dd6de3a43 2018-11-02 19:35:53 From: Alexis Jeandet Date: 2018-11-02 19:35:53 Subject: [PATCH] Restored Spectrograms plots X and Y axis resolution computation was broken which broke mesh generation and so Spectrogram plot. Signed-off-by: Alexis Jeandet --- diff --git a/include/Data/DataSeries.h b/include/Data/DataSeries.h index 8bdabac..9e5586c 100644 --- a/include/Data/DataSeries.h +++ b/include/Data/DataSeries.h @@ -319,7 +319,7 @@ public: std::make_unique >(*this, false)}}; } - void erase(DataSeriesIterator first, DataSeriesIterator last) + virtual void erase(DataSeriesIterator first, DataSeriesIterator last) { auto firstImpl = dynamic_cast *>(first->impl()); @@ -331,7 +331,7 @@ public: } } - void insert(DataSeriesIterator first, DataSeriesIterator last, bool prepend = false) + virtual void insert(DataSeriesIterator first, DataSeriesIterator last, bool prepend = false) { auto firstImpl = dynamic_cast *>(first->impl()); auto lastImpl = dynamic_cast *>(last->impl()); diff --git a/include/Data/SpectrogramSeries.h b/include/Data/SpectrogramSeries.h index 7155b3e..79e649e 100644 --- a/include/Data/SpectrogramSeries.h +++ b/include/Data/SpectrogramSeries.h @@ -33,7 +33,26 @@ public: inline double xResolution() const noexcept { return m_XResolution; } + void erase(DataSeriesIterator first, DataSeriesIterator last) override + { + DataSeries<2>::erase(first,last); + updateResolution(); + } + + void insert(DataSeriesIterator first, DataSeriesIterator last, bool prepend = false) override + { + DataSeries<2>::insert(first,last, prepend); + updateResolution(); + } + + void merge(IDataSeries *dataSeries) override + { + DataSeries<2>::merge(dataSeries); + updateResolution(); + } + private: + void updateResolution(); double m_XResolution; ///< Resolution used on x-axis to build the spectrogram }; diff --git a/src/Data/SpectrogramSeries.cpp b/src/Data/SpectrogramSeries.cpp index 81b8500..9345879 100644 --- a/src/Data/SpectrogramSeries.cpp +++ b/src/Data/SpectrogramSeries.cpp @@ -25,7 +25,7 @@ SpectrogramSeries::SpectrogramSeries(std::shared_ptr > xAxisData, { if(std::isnan(m_XResolution)) { - //m_XResolution = DataSeriesUtils::resolution(xAxisData->begin(), xAxisData->end()).m_Val; + updateResolution(); } } @@ -53,3 +53,9 @@ std::shared_ptr SpectrogramSeries::subDataSeries(const DateTimeRang std::make_shared >(subValuesData.toStdVector(), yAxis.size()), this->valuesUnit(), std::move(yAxis)); } + +void SpectrogramSeries::updateResolution() +{ + auto xAxisData = this->xAxisData()->cdata(); + m_XResolution = DataSeriesUtils::resolution(xAxisData.begin(), xAxisData.end()).m_Val; +} diff --git a/src/pybind11_wrappers/CoreWrappers.cpp b/src/pybind11_wrappers/CoreWrappers.cpp index 26620ce..3b3c2dd 100644 --- a/src/pybind11_wrappers/CoreWrappers.cpp +++ b/src/pybind11_wrappers/CoreWrappers.cpp @@ -90,6 +90,9 @@ PYBIND11_MODULE(pysciqlopcore,m){ }, py::keep_alive<0, 1>()) .def("__repr__",__repr__); + py::class_, std::shared_ptr> >(m,"ArrayData1d") + .def("cdata", [](ArrayData<1>& array) {return array.cdata();}); + py::class_, IDataSeries>(m, "ScalarSeries") .def("nbPoints", &ScalarSeries::nbPoints); @@ -97,10 +100,12 @@ PYBIND11_MODULE(pysciqlopcore,m){ .def("nbPoints", &VectorSeries::nbPoints); py::class_, std::shared_ptr>, IDataSeries>(m,"DataSeries2d") + .def_property_readonly("xAxis", py::overload_cast<>(&DataSeries<2>::xAxisData, py::const_)) .def_property_readonly("yAxis", py::overload_cast<>(&DataSeries<2>::yAxis, py::const_)); py::class_, DataSeries<2>>(m, "SpectrogramSeries") - .def("nbPoints", &SpectrogramSeries::nbPoints); + .def("nbPoints", &SpectrogramSeries::nbPoints) + .def("xRes", &SpectrogramSeries::xResolution); py::class_>(m, "IDataProvider");