CurveDataCircularBuffer.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright (C) 2015 by Ralf Kaestner *
3  * ralf.kaestner@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the Lesser GNU General Public License as published by*
7  * the Free Software Foundation; either version 3 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * Lesser GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the Lesser GNU General Public License *
16  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
17  ******************************************************************************/
18 
19 #ifndef RQT_MULTIPLOT_CURVE_DATA_CIRCULAR_BUFFER_H
20 #define RQT_MULTIPLOT_CURVE_DATA_CIRCULAR_BUFFER_H
21 
22 #include <boost/circular_buffer.hpp>
23 #include <boost/heap/d_ary_heap.hpp>
24 
26 
27 namespace rqt_multiplot {
29  public CurveData {
30  public:
31  CurveDataCircularBuffer(size_t capacity = 0);
33 
34  size_t getCapacity() const;
35  size_t getNumPoints() const;
36  QPointF getPoint(size_t index) const;
37  QVector<size_t> getPointsInDistance(double x, double maxDistance)
38  const;
40 
41  void appendPoint(const QPointF& point);
42  void clearPoints();
43 
44  private:
45  class Point;
46 
48  public:
49  inline XCoordinateRef(double x = 0.0, size_t index = 0) :
50  x_(x),
51  index_(index) {
52  };
53 
54  inline XCoordinateRef(const XCoordinateRef& src) :
55  x_(src.x_),
56  index_(src.index_) {
57  };
58 
59  inline bool operator==(const XCoordinateRef& reference) const {
60  return (x_ == reference.x_);
61  };
62 
63  inline bool operator>(const XCoordinateRef& reference) const {
64  return (x_ > reference.x_);
65  };
66 
67  inline bool operator<(const XCoordinateRef& reference) const {
68  return (x_ < reference.x_);
69  };
70 
71  double x_;
72  size_t index_;
73  };
74 
75  typedef boost::circular_buffer<Point> Points;
76  typedef boost::heap::d_ary_heap<XCoordinateRef, boost::
77  heap::arity<2>, boost::heap::mutable_<true>, boost::
78  heap::compare<std::greater<XCoordinateRef> > >
80  typedef boost::heap::d_ary_heap<double, boost::heap::arity<2>,
81  boost::heap::mutable_<true>, boost::heap::compare<std::
82  greater<double> > > CoordinateMinHeap;
83  typedef boost::heap::d_ary_heap<double, boost::heap::arity<2>,
84  boost::heap::mutable_<true>, boost::heap::compare<std::
85  less<double> > > CoordinateMaxHeap;
86 
87  class Point {
88  public:
89  inline Point(const QPointF& point = QPointF(0.0, 0.0)) :
90  x_(point.x()),
91  y_(point.y()) {
92  };
93 
94  double x_;
95  double y_;
96 
97  XCoordinateRefMinHeap::handle_type xMinHandle_;
98  CoordinateMaxHeap::handle_type xMaxHandle_;
99  CoordinateMinHeap::handle_type yMinHandle_;
100  CoordinateMaxHeap::handle_type yMaxHandle_;
101  };
102 
103  Points points_;
104 
106  CoordinateMaxHeap xMax_;
107  CoordinateMinHeap yMin_;
108  CoordinateMaxHeap yMax_;
109  };
110 };
111 
112 #endif
boost::circular_buffer< Point > Points
boost::heap::d_ary_heap< double, boost::heap::arity< 2 >, boost::heap::mutable_< true >, boost::heap::compare< std::greater< double > > > CoordinateMinHeap
bool operator>(const XCoordinateRef &reference) const
QVector< size_t > getPointsInDistance(double x, double maxDistance) const
boost::heap::d_ary_heap< double, boost::heap::arity< 2 >, boost::heap::mutable_< true >, boost::heap::compare< std::less< double > > > CoordinateMaxHeap
bool operator<(const XCoordinateRef &reference) const
boost::heap::d_ary_heap< XCoordinateRef, boost::heap::arity< 2 >, boost::heap::mutable_< true >, boost::heap::compare< std::greater< XCoordinateRef > > > XCoordinateRefMinHeap
bool operator==(const XCoordinateRef &reference) const
XCoordinateRefMinHeap::handle_type xMinHandle_
Point(const QPointF &point=QPointF(0.0, 0.0))


rqt_multiplot
Author(s): Ralf Kaestner
autogenerated on Wed Jul 10 2019 03:49:44