20 #ifndef PLOTTERDIAGRAMCOMPRESSOR_H 21 #define PLOTTERDIAGRAMCOMPRESSOR_H 24 #include <QAbstractItemModel> 36 class PlotterDiagramCompressor :
public QObject 41 enum CompressionMode{ SLOPE = 0, DISTANCE, BOTH };
47 : key(
std::numeric_limits< qreal >::quiet_NaN() ),
48 value(
std::numeric_limits< qreal >::quiet_NaN() ),
51 inline qreal
distance(
const DataPoint &other )
53 const qreal dx = key - other.key;
54 const qreal dy = value - other.value;
55 return std::sqrt( dx * dx + dy * dy );
58 inline bool operator==(
const DataPoint &other )
60 return key == other.key && value == other.value;
63 inline bool operator!=(
const DataPoint &other )
65 return !( *
this == other );
76 friend class PlotterDiagramCompressor;
78 Iterator(
int dataSet, PlotterDiagramCompressor *parent );
81 Iterator& operator++();
82 Iterator operator++(
int );
83 Iterator& operator += (
int value );
84 Iterator& operator--();
85 Iterator operator--(
int );
86 Iterator& operator-=(
int value );
87 DataPoint operator*();
88 bool operator==(
const Iterator &other )
const;
89 bool operator!=(
const Iterator &other )
const;
94 void handleSlopeForward(
const DataPoint &dp );
105 class CachePosition {
111 CachePosition(
int first,
int second )
118 bool operator==(
const CachePosition& rhs )
const 120 return first == rhs.first &&
121 second == rhs.second;
124 explicit PlotterDiagramCompressor(
QObject *parent =
nullptr);
125 ~PlotterDiagramCompressor();
126 Iterator
begin(
int dataSet );
127 Iterator
end(
int dataSet );
128 void setMergeRadius( qreal radius );
129 void setMergeRadiusPercentage( qreal radius );
132 DataPoint data(
const CachePosition& pos )
const;
133 int rowCount()
const;
134 int datasetCount()
const;
135 void setCompressionModel( CompressionMode value );
136 void setMaxSlopeChange( qreal value );
137 qreal maxSlopeChange()
const;
142 void boundariesChanged();
143 void rowCountChanged();
152 #endif // PLOTTERDIAGRAMCOMPRESSOR_H
const QList< QKeySequence > & begin()
bool operator==(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
Class only listed here to document inheritance of some KChart classes.
int distance(const GeoCoordinates &coord1, const GeoCoordinates &coord2)
const QList< QKeySequence > & end()
bool operator!=(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)