Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef RQT_MULTIPLOT_CURVE_DATA_CIRCULAR_BUFFER_H
00020 #define RQT_MULTIPLOT_CURVE_DATA_CIRCULAR_BUFFER_H
00021
00022 #include <boost/circular_buffer.hpp>
00023 #include <boost/heap/d_ary_heap.hpp>
00024
00025 #include <rqt_multiplot/CurveData.h>
00026
00027 namespace rqt_multiplot {
00028 class CurveDataCircularBuffer :
00029 public CurveData {
00030 public:
00031 CurveDataCircularBuffer(size_t capacity = 0);
00032 ~CurveDataCircularBuffer();
00033
00034 size_t getCapacity() const;
00035 size_t getNumPoints() const;
00036 QPointF getPoint(size_t index) const;
00037 QVector<size_t> getPointsInDistance(double x, double maxDistance)
00038 const;
00039 BoundingRectangle getBounds() const;
00040
00041 void appendPoint(const QPointF& point);
00042 void clearPoints();
00043
00044 private:
00045 class Point;
00046
00047 class XCoordinateRef {
00048 public:
00049 inline XCoordinateRef(double x = 0.0, size_t index = 0) :
00050 x_(x),
00051 index_(index) {
00052 };
00053
00054 inline XCoordinateRef(const XCoordinateRef& src) :
00055 x_(src.x_),
00056 index_(src.index_) {
00057 };
00058
00059 inline bool operator==(const XCoordinateRef& reference) const {
00060 return (x_ == reference.x_);
00061 };
00062
00063 inline bool operator>(const XCoordinateRef& reference) const {
00064 return (x_ > reference.x_);
00065 };
00066
00067 inline bool operator<(const XCoordinateRef& reference) const {
00068 return (x_ < reference.x_);
00069 };
00070
00071 double x_;
00072 size_t index_;
00073 };
00074
00075 typedef boost::circular_buffer<Point> Points;
00076 typedef boost::heap::d_ary_heap<XCoordinateRef, boost::
00077 heap::arity<2>, boost::heap::mutable_<true>, boost::
00078 heap::compare<std::greater<XCoordinateRef> > >
00079 XCoordinateRefMinHeap;
00080 typedef boost::heap::d_ary_heap<double, boost::heap::arity<2>,
00081 boost::heap::mutable_<true>, boost::heap::compare<std::
00082 greater<double> > > CoordinateMinHeap;
00083 typedef boost::heap::d_ary_heap<double, boost::heap::arity<2>,
00084 boost::heap::mutable_<true>, boost::heap::compare<std::
00085 less<double> > > CoordinateMaxHeap;
00086
00087 class Point {
00088 public:
00089 inline Point(const QPointF& point = QPointF(0.0, 0.0)) :
00090 x_(point.x()),
00091 y_(point.y()) {
00092 };
00093
00094 double x_;
00095 double y_;
00096
00097 XCoordinateRefMinHeap::handle_type xMinHandle_;
00098 CoordinateMaxHeap::handle_type xMaxHandle_;
00099 CoordinateMinHeap::handle_type yMinHandle_;
00100 CoordinateMaxHeap::handle_type yMaxHandle_;
00101 };
00102
00103 Points points_;
00104
00105 XCoordinateRefMinHeap xMin_;
00106 CoordinateMaxHeap xMax_;
00107 CoordinateMinHeap yMin_;
00108 CoordinateMaxHeap yMax_;
00109 };
00110 };
00111
00112 #endif