9#ifndef PLOTTERDIAGRAMCOMPRESSOR_H
10#define PLOTTERDIAGRAMCOMPRESSOR_H
13#include <QAbstractItemModel>
25class PlotterDiagramCompressor :
public QObject
30 enum CompressionMode{ SLOPE = 0, DISTANCE, BOTH };
36 : key( std::numeric_limits< qreal >::quiet_NaN() ),
37 value( std::numeric_limits< qreal >::quiet_NaN() ),
40 inline qreal distance(
const DataPoint &other )
42 const qreal dx = key - other.key;
43 const qreal dy = value - other.value;
44 return std::sqrt( dx * dx + dy * dy );
47 inline bool operator==(
const DataPoint &other )
49 return key == other.key && value == other.value;
52 inline bool operator!=(
const DataPoint &other )
54 return !( *
this == other );
65 friend class PlotterDiagramCompressor;
67 Iterator(
int dataSet, PlotterDiagramCompressor *
parent );
70 Iterator& operator++();
71 Iterator operator++(
int );
72 Iterator& operator += (
int value );
73 Iterator& operator--();
74 Iterator operator--(
int );
75 Iterator& operator-=(
int value );
76 DataPoint operator*();
77 bool operator==(
const Iterator &other )
const;
78 bool operator!=(
const Iterator &other )
const;
83 void handleSlopeForward(
const DataPoint &dp );
100 CachePosition(
int first,
int second )
107 bool operator==(
const CachePosition& rhs )
const
109 return first == rhs.first &&
110 second == rhs.second;
113 explicit PlotterDiagramCompressor(
QObject *
parent =
nullptr);
114 ~PlotterDiagramCompressor()
override;
115 Iterator begin(
int dataSet );
116 Iterator end(
int dataSet );
117 void setMergeRadius( qreal radius );
118 void setMergeRadiusPercentage( qreal radius );
121 DataPoint data(
const CachePosition& pos )
const;
122 int rowCount()
const;
123 int datasetCount()
const;
124 void setCompressionModel( CompressionMode value );
125 void setMaxSlopeChange( qreal value );
126 qreal maxSlopeChange()
const;
128 QPair< QPointF, QPointF > dataBoundaries()
const;
129 void setForcedDataBoundaries(
const QPair< qreal, qreal > &bounds,
Qt::Orientation direction );
131 void boundariesChanged();
132 void rowCountChanged();
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 4 2024 12:04:16 by
doxygen 1.12.0 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.