##// END OF EJS Templates
Updates PlottablesRenderingUtils to use variable's type instead of dataseries
Updates PlottablesRenderingUtils to use variable's type instead of dataseries

File last commit:

r989:958f5923ee65
r1253:a119058eb032
Show More
DataSeries.h
507 lines | 17.5 KiB | text/x-c | CLexer
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125 #ifndef SCIQLOP_DATASERIES_H
#define SCIQLOP_DATASERIES_H
Alexandre Leroux
Updates declaration of logger to avoid multiple definitions
r562 #include "CoreGlobal.h"
Alexandre Leroux
Makes a Data series be sorted (2)...
r450 #include <Common/SortUtils.h>
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125 #include <Data/ArrayData.h>
Alexandre Leroux
Updates merge() method (1)...
r668 #include <Data/DataSeriesMergeHelper.h>
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125 #include <Data/IDataSeries.h>
Alexandre Leroux
Handles y-axis in DataSeries....
r861 #include <Data/OptionalAxis.h>
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125
Correction for pull request
r243 #include <QLoggingCategory>
Add current progression for thread fix
r364 #include <QReadLocker>
#include <QReadWriteLock>
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125 #include <memory>
Alexandre Leroux
Updates declaration of logger to avoid multiple definitions
r562 // We don't use the Qt macro since the log is used in the header file, which causes multiple log
// definitions with inheritance. Inline method is used instead
inline const QLoggingCategory &LOG_DataSeries()
{
static const QLoggingCategory category{"DataSeries"};
return category;
}
Correction for pull request
r243
Alexandre Leroux
Uses new iterator in DataSeries.cpp...
r596 template <int Dim>
class DataSeries;
namespace dataseries_detail {
Alexandre Leroux
Adapts SqpIterator to make non-const iterators
r673 template <int Dim, bool IsConst>
Alexandre Leroux
Uses new iterator in DataSeries.cpp...
r596 class IteratorValue : public DataSeriesIteratorValue::Impl {
public:
Alexandre Leroux
Adapts SqpIterator to make non-const iterators
r673 friend class DataSeries<Dim>;
template <bool IC = IsConst, typename = std::enable_if_t<IC == false> >
explicit IteratorValue(DataSeries<Dim> &dataSeries, bool begin)
: m_XIt(begin ? dataSeries.xAxisData()->begin() : dataSeries.xAxisData()->end()),
Alexandre Leroux
Updates access to y-axis properties of the data series (2)...
r989 m_ValuesIt(begin ? dataSeries.valuesData()->begin() : dataSeries.valuesData()->end()),
m_YItBegin{dataSeries.yAxis().begin()},
m_YItEnd{dataSeries.yAxis().end()}
Alexandre Leroux
Adapts SqpIterator to make non-const iterators
r673 {
}
template <bool IC = IsConst, typename = std::enable_if_t<IC == true> >
Alexandre Leroux
Uses new iterator in DataSeries.cpp...
r596 explicit IteratorValue(const DataSeries<Dim> &dataSeries, bool begin)
: m_XIt(begin ? dataSeries.xAxisData()->cbegin() : dataSeries.xAxisData()->cend()),
m_ValuesIt(begin ? dataSeries.valuesData()->cbegin()
Alexandre Leroux
Updates access to y-axis properties of the data series (2)...
r989 : dataSeries.valuesData()->cend()),
m_YItBegin{dataSeries.yAxis().cbegin()},
m_YItEnd{dataSeries.yAxis().cend()}
Alexandre Leroux
Uses new iterator in DataSeries.cpp...
r596 {
}
Alexandre Leroux
Adapts SqpIterator to make non-const iterators
r673
Alexandre Leroux
Uses new iterator in DataSeries.cpp...
r596 IteratorValue(const IteratorValue &other) = default;
std::unique_ptr<DataSeriesIteratorValue::Impl> clone() const override
{
Alexandre Leroux
Adapts SqpIterator to make non-const iterators
r673 return std::make_unique<IteratorValue<Dim, IsConst> >(*this);
Alexandre Leroux
Uses new iterator in DataSeries.cpp...
r596 }
Alexandre Leroux
Makes random access iterators...
r689 int distance(const DataSeriesIteratorValue::Impl &other) const override try {
const auto &otherImpl = dynamic_cast<const IteratorValue &>(other);
return m_XIt->distance(*otherImpl.m_XIt);
}
catch (const std::bad_cast &) {
return 0;
}
Alexandre Leroux
Uses new iterator in DataSeries.cpp...
r596 bool equals(const DataSeriesIteratorValue::Impl &other) const override try {
const auto &otherImpl = dynamic_cast<const IteratorValue &>(other);
Alexandre Leroux
Updates access to y-axis properties of the data series (2)...
r989 return std::tie(m_XIt, m_ValuesIt, m_YItBegin, m_YItEnd)
== std::tie(otherImpl.m_XIt, otherImpl.m_ValuesIt, otherImpl.m_YItBegin,
otherImpl.m_YItEnd);
Alexandre Leroux
Uses new iterator in DataSeries.cpp...
r596 }
catch (const std::bad_cast &) {
return false;
}
Alexandre Leroux
Makes random access iterators...
r689 bool lowerThan(const DataSeriesIteratorValue::Impl &other) const override try {
const auto &otherImpl = dynamic_cast<const IteratorValue &>(other);
return m_XIt->lowerThan(*otherImpl.m_XIt);
}
catch (const std::bad_cast &) {
return false;
}
std::unique_ptr<DataSeriesIteratorValue::Impl> advance(int offset) const override
{
auto result = clone();
Alexandre Leroux
Improves random access iterator performance
r697 result->next(offset);
Alexandre Leroux
Makes random access iterators...
r689 return result;
}
Alexandre Leroux
Improves random access iterator performance
r697 void next(int offset) override
Alexandre Leroux
Uses new iterator in DataSeries.cpp...
r596 {
Alexandre Leroux
Improves random access iterator performance
r697 m_XIt->next(offset);
m_ValuesIt->next(offset);
Alexandre Leroux
Uses new iterator in DataSeries.cpp...
r596 }
void prev() override
{
--m_XIt;
--m_ValuesIt;
}
double x() const override { return m_XIt->at(0); }
Alexandre Leroux
Updates access to y-axis properties of the data series (2)...
r989 std::vector<double> y() const override
{
std::vector<double> result{};
std::transform(m_YItBegin, m_YItEnd, std::back_inserter(result),
[](const auto &it) { return it.first(); });
return result;
}
Alexandre Leroux
Uses new iterator in DataSeries.cpp...
r596 double value() const override { return m_ValuesIt->at(0); }
double value(int componentIndex) const override { return m_ValuesIt->at(componentIndex); }
Alexandre Leroux
Implements method to get min/max values of a dataseries giving a range (2)
r609 double minValue() const override { return m_ValuesIt->min(); }
double maxValue() const override { return m_ValuesIt->max(); }
Alexandre Leroux
Adds method into ArrayData and DataSeries iterator to get all values
r667 QVector<double> values() const override { return m_ValuesIt->values(); }
Alexandre Leroux
Uses new iterator in DataSeries.cpp...
r596
Alexandre Leroux
Adapts iterator to be MoveAssignable...
r674 void swap(DataSeriesIteratorValue::Impl &other) override
{
auto &otherImpl = dynamic_cast<IteratorValue &>(other);
m_XIt->impl()->swap(*otherImpl.m_XIt->impl());
m_ValuesIt->impl()->swap(*otherImpl.m_ValuesIt->impl());
Alexandre Leroux
Updates access to y-axis properties of the data series (2)...
r989 m_YItBegin->impl()->swap(*otherImpl.m_YItBegin->impl());
m_YItEnd->impl()->swap(*otherImpl.m_YItEnd->impl());
Alexandre Leroux
Adapts iterator to be MoveAssignable...
r674 }
Alexandre Leroux
Uses new iterator in DataSeries.cpp...
r596 private:
Alexandre Leroux
Replaces current iterator of ArrayData by the previous iterator created
r641 ArrayDataIterator m_XIt;
ArrayDataIterator m_ValuesIt;
Alexandre Leroux
Updates access to y-axis properties of the data series (2)...
r989 ArrayDataIterator m_YItBegin;
ArrayDataIterator m_YItEnd;
Alexandre Leroux
Uses new iterator in DataSeries.cpp...
r596 };
} // namespace dataseries_detail
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125 /**
* @brief The DataSeries class is the base (abstract) implementation of IDataSeries.
*
Alexandre Leroux
Adds comments in DataSeries description
r862 * The DataSeries represents values on one or two axes, according to these rules:
* - the x-axis is always defined
* - an y-axis can be defined or not. If set, additional consistency checks apply to the values (see
* below)
* - the values are defined on one or two dimensions. In the case of 2-dim values, the data is
* distributed into components (for example, a vector defines three components)
* - New values can be added to the series, on the x-axis.
* - Once initialized to the series creation, the y-axis (if defined) is no longer modifiable
* - Data representing values and axes are associated with a unit
* - The data series is always sorted in ascending order on the x-axis.
Alexandre Leroux
Makes a Data series be sorted (1)
r449 *
Alexandre Leroux
Adds comments in DataSeries description
r862 * Consistency checks are carried out between the axes and the values. These controls are provided
* throughout the DataSeries lifecycle:
* - the number of data on the x-axis must be equal to the number of values (in the case of
* 2-dim ArrayData for values, the test is performed on the number of values per component)
* - if the y-axis is defined, the number of components of the ArrayData for values must equal the
* number of data on the y-axis.
*
* Examples:
* 1)
* - x-axis: [1 ; 2 ; 3]
* - y-axis: not defined
* - values: [10 ; 20 ; 30] (1-dim ArrayData)
* => the DataSeries is valid, as x-axis and values have the same number of data
*
* 2)
* - x-axis: [1 ; 2 ; 3]
* - y-axis: not defined
* - values: [10 ; 20 ; 30 ; 40] (1-dim ArrayData)
* => the DataSeries is invalid, as x-axis and values haven't the same number of data
*
* 3)
* - x-axis: [1 ; 2 ; 3]
* - y-axis: not defined
* - values: [10 ; 20 ; 30
* 40 ; 50 ; 60] (2-dim ArrayData)
* => the DataSeries is valid, as x-axis has 3 data and values contains 2 components with 3
* data each
*
* 4)
* - x-axis: [1 ; 2 ; 3]
* - y-axis: [1 ; 2]
* - values: [10 ; 20 ; 30
* 40 ; 50 ; 60] (2-dim ArrayData)
* => the DataSeries is valid, as:
* - x-axis has 3 data and values contains 2 components with 3 data each AND
* - y-axis has 2 data and values contains 2 components
*
* 5)
* - x-axis: [1 ; 2 ; 3]
* - y-axis: [1 ; 2 ; 3]
* - values: [10 ; 20 ; 30
* 40 ; 50 ; 60] (2-dim ArrayData)
* => the DataSeries is invalid, as:
* - x-axis has 3 data and values contains 2 components with 3 data each BUT
* - y-axis has 3 data and values contains only 2 components
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125 *
* @tparam Dim The dimension of the values data
*
*/
template <int Dim>
Alexandre Leroux
Updates declaration of logger to avoid multiple definitions
r562 class SCIQLOP_CORE_EXPORT DataSeries : public IDataSeries {
Alexandre Leroux
Updates merge() method (1)...
r668 friend class DataSeriesMergeHelper;
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125 public:
/// @sa IDataSeries::xAxisData()
std::shared_ptr<ArrayData<1> > xAxisData() override { return m_XAxisData; }
Alexandre Leroux
Use std::shared_ptr in CosinusProvider
r310 const std::shared_ptr<ArrayData<1> > xAxisData() const { return m_XAxisData; }
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125
/// @sa IDataSeries::xAxisUnit()
Alexandre Leroux
Replaces QString unit by a new struct...
r177 Unit xAxisUnit() const override { return m_XAxisUnit; }
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125
Alexandre Leroux
Updates access to y-axis properties of the data series (1)...
r988 /// @sa IDataSeries::yAxisUnit()
Unit yAxisUnit() const override { return m_YAxis.unit(); }
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125 /// @return the values dataset
Alexandre Leroux
Use std::shared_ptr in CosinusProvider
r310 std::shared_ptr<ArrayData<Dim> > valuesData() { return m_ValuesData; }
const std::shared_ptr<ArrayData<Dim> > valuesData() const { return m_ValuesData; }
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125
/// @sa IDataSeries::valuesUnit()
Alexandre Leroux
Replaces QString unit by a new struct...
r177 Unit valuesUnit() const override { return m_ValuesUnit; }
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125
Alexandre Leroux
Minor changes...
r858 int nbPoints() const override { return m_ValuesData->totalSize(); }
Implementation of V5 acquisition
r539
Alexandre Leroux
Updates access to y-axis properties of the data series (1)...
r988 std::pair<double, double> yBounds() const override { return m_YAxis.bounds(); }
Add current progression for thread fix
r364 void clear()
{
m_XAxisData->clear();
m_ValuesData->clear();
}
Alexandre Leroux
Updates merge() method (1)...
r668 bool isEmpty() const noexcept { return m_XAxisData->size() == 0; }
Alexandre Leroux
Handles y-axis in DataSeries....
r861 /// Merges into the data series an other data series.
///
/// The two dataseries:
/// - must be of the same dimension
/// - must have the same y-axis (if defined)
///
/// If the prerequisites are not valid, the method does nothing
///
Alexandre Leroux
Handles merge of two data series
r451 /// @remarks the data series to merge with is cleared after the operation
Add merge API and implement it for the DataSeries
r233 void merge(IDataSeries *dataSeries) override
{
Alexandre Leroux
Handles merge of two data series
r451 dataSeries->lockWrite();
lockWrite();
if (auto other = dynamic_cast<DataSeries<Dim> *>(dataSeries)) {
Alexandre Leroux
Handles y-axis in DataSeries....
r861 if (m_YAxis == other->m_YAxis) {
DataSeriesMergeHelper::merge(*other, *this);
}
else {
qCWarning(LOG_DataSeries())
<< QObject::tr("Can't merge data series that have not the same y-axis");
}
Add merge API and implement it for the DataSeries
r233 }
Correction for pull request
r243 else {
qCWarning(LOG_DataSeries())
Alexandre Leroux
Handles merge of two data series
r451 << QObject::tr("Detection of a type of IDataSeries we cannot merge with !");
Correction for pull request
r243 }
Alexandre Leroux
Handles merge of two data series
r451 unlock();
dataSeries->unlock();
Add merge API and implement it for the DataSeries
r233 }
Alexandre Leroux
Implements purge() method for DataSeries
r676 void purge(double min, double max) override
{
Alexandre Leroux
Improves purge method
r690 // Nothing to purge if series is empty
if (isEmpty()) {
return;
}
Alexandre Leroux
Implements purge() method for DataSeries
r676 if (min > max) {
std::swap(min, max);
}
Alexandre Leroux
Improves purge method
r690 // Nothing to purge if series min/max are inside purge range
auto xMin = cbegin()->x();
auto xMax = (--cend())->x();
if (xMin >= min && xMax <= max) {
return;
}
Alexandre Leroux
Implements purge() method for DataSeries
r676
Alexandre Leroux
Improves purge method
r690 auto lowerIt = std::lower_bound(
begin(), end(), min, [](const auto &it, const auto &val) { return it.x() < val; });
erase(begin(), lowerIt);
auto upperIt = std::upper_bound(
begin(), end(), max, [](const auto &val, const auto &it) { return val < it.x(); });
erase(upperIt, end());
Alexandre Leroux
Implements purge() method for DataSeries
r676 }
Alexandre Leroux
Creates iterator for DataSeries
r556 // ///////// //
// Iterators //
// ///////// //
Alexandre Leroux
Adapts SqpIterator to make non-const iterators
r673 DataSeriesIterator begin() override
{
return DataSeriesIterator{DataSeriesIteratorValue{
std::make_unique<dataseries_detail::IteratorValue<Dim, false> >(*this, true)}};
}
DataSeriesIterator end() override
{
return DataSeriesIterator{DataSeriesIteratorValue{
std::make_unique<dataseries_detail::IteratorValue<Dim, false> >(*this, false)}};
}
Alexandre Leroux
Uses new iterator in DataSeries.cpp...
r596 DataSeriesIterator cbegin() const override
{
return DataSeriesIterator{DataSeriesIteratorValue{
Alexandre Leroux
Adapts SqpIterator to make non-const iterators
r673 std::make_unique<dataseries_detail::IteratorValue<Dim, true> >(*this, true)}};
Alexandre Leroux
Uses new iterator in DataSeries.cpp...
r596 }
Alexandre Leroux
Creates iterator for DataSeries
r556
Alexandre Leroux
Uses new iterator in DataSeries.cpp...
r596 DataSeriesIterator cend() const override
{
return DataSeriesIterator{DataSeriesIteratorValue{
Alexandre Leroux
Adapts SqpIterator to make non-const iterators
r673 std::make_unique<dataseries_detail::IteratorValue<Dim, true> >(*this, false)}};
Alexandre Leroux
Uses new iterator in DataSeries.cpp...
r596 }
Alexandre Leroux
Creates iterator for DataSeries
r556
Alexandre Leroux
Adds erase() method for ArrayData and DataSeries
r675 void erase(DataSeriesIterator first, DataSeriesIterator last)
{
auto firstImpl
= dynamic_cast<dataseries_detail::IteratorValue<Dim, false> *>(first->impl());
auto lastImpl = dynamic_cast<dataseries_detail::IteratorValue<Dim, false> *>(last->impl());
if (firstImpl && lastImpl) {
m_XAxisData->erase(firstImpl->m_XIt, lastImpl->m_XIt);
m_ValuesData->erase(firstImpl->m_ValuesIt, lastImpl->m_ValuesIt);
}
}
Alexandre Leroux
Updates merge method...
r696 void insert(DataSeriesIterator first, DataSeriesIterator last, bool prepend = false)
{
auto firstImpl = dynamic_cast<dataseries_detail::IteratorValue<Dim, true> *>(first->impl());
auto lastImpl = dynamic_cast<dataseries_detail::IteratorValue<Dim, true> *>(last->impl());
if (firstImpl && lastImpl) {
m_XAxisData->insert(firstImpl->m_XIt, lastImpl->m_XIt, prepend);
m_ValuesData->insert(firstImpl->m_ValuesIt, lastImpl->m_ValuesIt, prepend);
}
}
Alexandre Leroux
(Refactoring) Renames IDataSeries::minData() and IDataSeries::maxData()
r604 /// @sa IDataSeries::minXAxisData()
DataSeriesIterator minXAxisData(double minXAxisData) const override
Alexandre Leroux
Shows min x-axis data in Variable widget (1)...
r599 {
return std::lower_bound(
cbegin(), cend(), minXAxisData,
[](const auto &itValue, const auto &value) { return itValue.x() < value; });
}
Alexandre Leroux
(Refactoring) Renames IDataSeries::minData() and IDataSeries::maxData()
r604 /// @sa IDataSeries::maxXAxisData()
DataSeriesIterator maxXAxisData(double maxXAxisData) const override
Alexandre Leroux
Shows min/max x-axis data in Variable widget (2)...
r600 {
// Gets the first element that greater than max value
auto it = std::upper_bound(
cbegin(), cend(), maxXAxisData,
[](const auto &value, const auto &itValue) { return value < itValue.x(); });
return it == cbegin() ? cend() : --it;
}
Alexandre Leroux
(Refactoring) Renames IDataSeries::subData()
r605 std::pair<DataSeriesIterator, DataSeriesIterator> xAxisRange(double minXAxisData,
double maxXAxisData) const override
Alexandre Leroux
Adds subData() method
r557 {
Alexandre Leroux
(Refactoring) Renames IDataSeries::subData()
r605 if (minXAxisData > maxXAxisData) {
std::swap(minXAxisData, maxXAxisData);
Alexandre Leroux
Adds subData() method
r557 }
auto begin = cbegin();
auto end = cend();
Alexandre Leroux
(Refactoring) Renames IDataSeries::subData()
r605 auto lowerIt = std::lower_bound(
begin, end, minXAxisData,
[](const auto &itValue, const auto &value) { return itValue.x() < value; });
auto upperIt = std::upper_bound(
Alexandre Leroux
Updates merge method...
r696 lowerIt, end, maxXAxisData,
Alexandre Leroux
(Refactoring) Renames IDataSeries::subData()
r605 [](const auto &value, const auto &itValue) { return value < itValue.x(); });
Alexandre Leroux
Adds subData() method
r557
return std::make_pair(lowerIt, upperIt);
}
Alexandre Leroux
Implements method to get min/max values of a dataseries giving a range (1)
r608 std::pair<DataSeriesIterator, DataSeriesIterator>
valuesBounds(double minXAxisData, double maxXAxisData) const override
{
// Places iterators to the correct x-axis range
auto xAxisRangeIts = xAxisRange(minXAxisData, maxXAxisData);
// Returns end iterators if the range is empty
if (xAxisRangeIts.first == xAxisRangeIts.second) {
return std::make_pair(cend(), cend());
}
Alexandre Leroux
Implements method to get min/max values of a dataseries giving a range (2)
r609 // Gets the iterator on the min of all values data
auto minIt = std::min_element(
xAxisRangeIts.first, xAxisRangeIts.second, [](const auto &it1, const auto &it2) {
return SortUtils::minCompareWithNaN(it1.minValue(), it2.minValue());
});
Alexandre Leroux
Implements method to get min/max values of a dataseries giving a range (1)
r608
Alexandre Leroux
Implements method to get min/max values of a dataseries giving a range (2)
r609 // Gets the iterator on the max of all values data
auto maxIt = std::max_element(
xAxisRangeIts.first, xAxisRangeIts.second, [](const auto &it1, const auto &it2) {
return SortUtils::maxCompareWithNaN(it1.maxValue(), it2.maxValue());
});
return std::make_pair(minIt, maxIt);
Alexandre Leroux
Implements method to get min/max values of a dataseries giving a range (1)
r608 }
Alexandre Leroux
Implements spectrograms display (1)...
r902 /// @return the y-axis associated to the data series
Alexandre Leroux
Updates access to y-axis properties of the data series (1)...
r988 const OptionalAxis &yAxis() const { return m_YAxis; }
OptionalAxis &yAxis() { return m_YAxis; }
Alexandre Leroux
Implements spectrograms display (1)...
r902
Alexandre Leroux
Creates iterator for DataSeries
r556 // /////// //
// Mutexes //
// /////// //
Add current progression for thread fix
r364 virtual void lockRead() { m_Lock.lockForRead(); }
virtual void lockWrite() { m_Lock.lockForWrite(); }
virtual void unlock() { m_Lock.unlock(); }
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125 protected:
Alexandre Leroux
Handles y-axis in DataSeries....
r861 /// Protected ctor (DataSeries is abstract).
///
/// Data vectors must be consistent with each other, otherwise an exception will be thrown (@sa
/// class description for consistent rules)
Alexandre Leroux
Makes a Data series be sorted (1)
r449 /// @remarks data series is automatically sorted on its x-axis data
Alexandre Leroux
Handles y-axis in DataSeries....
r861 /// @throws std::invalid_argument if the data are inconsistent with each other
Alexandre Leroux
Fixes after review
r188 explicit DataSeries(std::shared_ptr<ArrayData<1> > xAxisData, const Unit &xAxisUnit,
Alexandre Leroux
Handles y-axis in DataSeries....
r861 std::shared_ptr<ArrayData<Dim> > valuesData, const Unit &valuesUnit,
OptionalAxis yAxis = OptionalAxis{})
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125 : m_XAxisData{xAxisData},
Alexandre Leroux
Fixes after review
r188 m_XAxisUnit{xAxisUnit},
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125 m_ValuesData{valuesData},
Alexandre Leroux
Handles y-axis in DataSeries....
r861 m_ValuesUnit{valuesUnit},
m_YAxis{std::move(yAxis)}
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125 {
Alexandre Leroux
Makes a Data series be sorted (1)
r449 if (m_XAxisData->size() != m_ValuesData->size()) {
Alexandre Leroux
Handles y-axis in DataSeries....
r861 throw std::invalid_argument{
"The number of values by component must be equal to the number of x-axis data"};
}
// Validates y-axis (if defined)
if (yAxis.isDefined() && (yAxis.size() != m_ValuesData->componentCount())) {
throw std::invalid_argument{
"As the y-axis is defined, the number of value components must be equal to the "
"number of y-axis data"};
Alexandre Leroux
Makes a Data series be sorted (1)
r449 }
// Sorts data if it's not the case
const auto &xAxisCData = m_XAxisData->cdata();
if (!std::is_sorted(xAxisCData.cbegin(), xAxisCData.cend())) {
sort();
}
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125 }
Alexandre Leroux
Use std::shared_ptr in CosinusProvider
r310 /// Copy ctor
explicit DataSeries(const DataSeries<Dim> &other)
: m_XAxisData{std::make_shared<ArrayData<1> >(*other.m_XAxisData)},
m_XAxisUnit{other.m_XAxisUnit},
m_ValuesData{std::make_shared<ArrayData<Dim> >(*other.m_ValuesData)},
Alexandre Leroux
Handles y-axis in DataSeries....
r861 m_ValuesUnit{other.m_ValuesUnit},
m_YAxis{other.m_YAxis}
Alexandre Leroux
Use std::shared_ptr in CosinusProvider
r310 {
Alexandre Leroux
Makes a Data series be sorted (1)
r449 // Since a series is ordered from its construction and is always ordered, it is not
// necessary to call the sort method here ('other' is sorted)
Alexandre Leroux
Use std::shared_ptr in CosinusProvider
r310 }
/// Assignment operator
template <int D>
DataSeries &operator=(DataSeries<D> other)
{
std::swap(m_XAxisData, other.m_XAxisData);
std::swap(m_XAxisUnit, other.m_XAxisUnit);
std::swap(m_ValuesData, other.m_ValuesData);
std::swap(m_ValuesUnit, other.m_ValuesUnit);
Alexandre Leroux
Handles y-axis in DataSeries....
r861 std::swap(m_YAxis, other.m_YAxis);
Alexandre Leroux
Use std::shared_ptr in CosinusProvider
r310
return *this;
}
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125 private:
Alexandre Leroux
Makes a Data series be sorted (1)
r449 /**
* Sorts data series on its x-axis data
*/
void sort() noexcept
{
Alexandre Leroux
Makes a Data series be sorted (2)...
r450 auto permutation = SortUtils::sortPermutation(*m_XAxisData, std::less<double>());
m_XAxisData = m_XAxisData->sort(permutation);
m_ValuesData = m_ValuesData->sort(permutation);
Alexandre Leroux
Makes a Data series be sorted (1)
r449 }
Alexandre Leroux
Handles y-axis in DataSeries....
r861 // x-axis
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125 std::shared_ptr<ArrayData<1> > m_XAxisData;
Alexandre Leroux
Replaces QString unit by a new struct...
r177 Unit m_XAxisUnit;
Alexandre Leroux
Handles y-axis in DataSeries....
r861
// values
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125 std::shared_ptr<ArrayData<Dim> > m_ValuesData;
Alexandre Leroux
Replaces QString unit by a new struct...
r177 Unit m_ValuesUnit;
Add current progression for thread fix
r364
Alexandre Leroux
Handles y-axis in DataSeries....
r861 // y-axis (optional)
OptionalAxis m_YAxis;
Add current progression for thread fix
r364 QReadWriteLock m_Lock;
Alexandre Leroux
Creates IDataSeries interface and its default implementation
r125 };
#endif // SCIQLOP_DATASERIES_H